Skip to content

fix: serialize accessList storageKeys in camelCase per Ethereum JSON-RPC spec#51

Open
ionodeionode wants to merge 1 commit intoopentensor:masterfrom
ionodeionode:fix/access-list-storage-keys-camelcase
Open

fix: serialize accessList storageKeys in camelCase per Ethereum JSON-RPC spec#51
ionodeionode wants to merge 1 commit intoopentensor:masterfrom
ionodeionode:fix/access-list-storage-keys-camelcase

Conversation

@ionodeionode
Copy link

Summary

Fixes opentensor/subtensor#2143

Problem

The ethereum crate's AccessListItem struct serializes the storage_keys field in snake_case:

{
  "address": "0x9dc08c6e2bf0f1eed1e00670f80df39145529f81",
  "storage_keys": []
}

However, the Ethereum JSON-RPC specification requires camelCase (storageKeys):

{
  "address": "0x9dc08c6e2bf0f1eed1e00670f80df39145529f81",
  "storageKeys": []
}

This breaks indexers and tooling that validate against the spec. The issue was reported by the Subsquid team who encountered problems while indexing the Bittensor mainnet.

Solution

Added a custom serialization wrapper (AccessListItemCamelCase) and a serialize_with module (access_list_camelcase) for the Transaction struct's access_list field. This ensures storageKeys is serialized in the correct camelCase format without modifying the underlying ethereum crate type.

Note: The rpc-v2 types already define their own AccessListItem with #[serde(rename_all = "camelCase")], so only rpc-core is affected by this bug.

Before

curl <bittensor-rpc-endpoint> -X POST -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","id":4, "params": ["0x98e15..."]}' | jq '.result.accessList'

[{ "address": "0x...", "storage_keys": [] }]

After

[{ "address": "0x...", "storageKeys": [] }]

…RPC spec

The ethereum crate's AccessListItem serializes storage_keys in
snake_case, but the Ethereum JSON-RPC specification requires camelCase
(storageKeys). This breaks indexers and tooling that validate against
the spec (e.g., subsquid).

Add a custom serializer wrapper (AccessListItemCamelCase) for the
Transaction struct's access_list field to ensure storageKeys is
serialized in the correct camelCase format.

The rpc-v2 types already have their own AccessListItem with the correct
rename_all = camelCase attribute, so only rpc-core is affected.

Fixes opentensor/subtensor#2143
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transaction.accessList.storageKeys has unexpected format

1 participant