Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ethclient: support networkID in hex format #30263

Merged
merged 1 commit into from
Aug 6, 2024
Merged

Conversation

kkqy
Copy link
Contributor

@kkqy kkqy commented Aug 3, 2024

Some chains’ network IDs use hexadecimal such as Optimism ("0xa" instead of "10"), so when converting the string to big.Int, we cannot specify base 10; otherwise, it will encounter errors with hexadecimal network IDs.

@fjl fjl changed the title Fix the base for networkID with hex format. ethclient: support networkID in hex format Aug 3, 2024
@lightclient
Copy link
Member

I get 10 when querying Optimism's RPC:

$ curl -X POST https://mainnet.optimism.io -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "id": 0, "method": "net_version", "params": []}'
{"jsonrpc":"2.0","result":"10","id":0}

@lightclient lightclient closed this Aug 3, 2024
@fjl
Copy link
Contributor

fjl commented Aug 3, 2024

I think we should support hex.

@fjl fjl reopened this Aug 3, 2024
@fjl
Copy link
Contributor

fjl commented Aug 3, 2024

The problem is, there is no spec for this method. While Geth has been returning decimal, most other methods return numbers as hex.

@fjl
Copy link
Contributor

fjl commented Aug 3, 2024

There is an issue for adding a spec here (and the proposed spec uses hex...): ethereum/execution-apis#540

@kkqy
Copy link
Contributor Author

kkqy commented Aug 4, 2024

I get 10 when querying Optimism's RPC:

$ curl -X POST https://mainnet.optimism.io -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "id": 0, "method": "net_version", "params": []}'
{"jsonrpc":"2.0","result":"10","id":0}

Maybe it depends on the RPC server.
please try: https://optimism.llamarpc.com

curl -X POST https://optimism.llamarpc.com -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "id": 0, "method": "net_version", "params": []}'
{"jsonrpc":"2.0","id":0,"result":"0xa"}

Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@karalabe karalabe added this to the 1.14.8 milestone Aug 6, 2024
@karalabe karalabe merged commit e9981bc into ethereum:master Aug 6, 2024
3 checks passed
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

leeren pushed a commit to storyprotocol/story-geth that referenced this pull request Aug 16, 2024
Some chains’ network IDs use hexadecimal such as Optimism ("0xa" instead
of "10"), so when converting the string to big.Int, we cannot specify
base 10; otherwise, it will encounter errors with hexadecimal network
IDs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants