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

eth: change chainID method to return chainID from config or error if before EIP-155 #21686

Merged
merged 4 commits into from
Jan 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions eth/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64 {
}

// ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
func (api *PublicEthereumAPI) ChainId() hexutil.Uint64 {
chainID := new(big.Int)
func (api *PublicEthereumAPI) ChainId() (hexutil.Uint64, error) {
// if current block is at or past the EIP-155 replay-protection fork block, return chainID from config
if config := api.e.blockchain.Config(); config.IsEIP155(api.e.blockchain.CurrentBlock().Number()) {
chainID = config.ChainID
return (hexutil.Uint64)(config.ChainID.Uint64()), nil
}
return (hexutil.Uint64)(chainID.Uint64())
return hexutil.Uint64(0), fmt.Errorf("chain not synced beyond EIP-155 replay-protection fork block")
}

// PublicMinerAPI provides an API to control the miner.
Expand Down