Unverified Commit 984e752c authored by rene's avatar rene Committed by GitHub

eth: return error from eth_chainID during sync before EIP-155 activates (#21686)

This changes the chainID RPC method to return an error when EIP-155 is not yet
active at the current block height. It used to simply return zero in this case, but
that's confusing.
parent 39b3b8ff
...@@ -67,12 +67,12 @@ func (api *PublicEthereumAPI) Hashrate() hexutil.Uint64 { ...@@ -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. // ChainId is the EIP-155 replay-protection chain id for the current ethereum chain config.
func (api *PublicEthereumAPI) ChainId() hexutil.Uint64 { func (api *PublicEthereumAPI) ChainId() (hexutil.Uint64, error) {
chainID := new(big.Int) // 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()) { 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. // PublicMinerAPI provides an API to control the miner.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment