Skip to content

Commit

Permalink
Problem: method eth_chainId crashed occasionally
Browse files Browse the repository at this point in the history
add fallback default config to ensure no panic in IsEIP155 check
  • Loading branch information
mmsqe committed Aug 23, 2024
1 parent fe3f4fd commit 9c903b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (rpc) [#488](https://github.com/crypto-org-chain/ethermint/pull/488) Fix handling of pending transactions related APIs.
* (rpc) [#501](https://github.com/crypto-org-chain/ethermint/pull/501) Avoid invalid chain id for signer error when rpc call before chain id set in BeginBlock.
* (block-stm) [#510](https://github.com/crypto-org-chain/ethermint/pull/510) Include a fix to avoid nondeterministic account set when stm workers execute in parallel.
* (rpc) [#516](https://github.com/crypto-org-chain/ethermint/pull/516) Avoid method eth_chainId crashed due to nil pointer on IsEIP155 check.

### Improvements

Expand All @@ -80,7 +81,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (app) [#483](https://github.com/crypto-org-chain/ethermint/pull/483) Make keyring-backend client config accessible in app.
* (deps) [#489](https://github.com/crypto-org-chain/ethermint/pull/489) Update cosmos-sdk to `v0.50.7`.
* (rpc) [#491](https://github.com/crypto-org-chain/ethermint/pull/491) Avoid unnecessary tx decode in tx listener.
* [#496](https://github.com/crypto-org-chain/cronos/pull/496) Set mempool MaxTx from config.
* [#496](https://github.com/crypto-org-chain/ethermint/pull/496) Set mempool MaxTx from config.
* (ante) [#497](https://github.com/crypto-org-chain/ethermint/pull/497) Enforce positive value check in eth transaction.
* (deps) [#505](https://github.com/crypto-org-chain/ethermint/pull/505) Update cometbft to v0.38.10.
* (ante) [#504](https://github.com/crypto-org-chain/ethermint/pull/504) Optimize AnteHandle method to skip checks if disabledMsgs is empty.
Expand Down
6 changes: 5 additions & 1 deletion rpc/backend/chain_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ func (b *Backend) ChainID() (*hexutil.Big, error) {
return (*hexutil.Big)(eip155ChainID), nil
}

if config := b.ChainConfig(); config.IsEIP155(new(big.Int).SetUint64(uint64(bn))) {
config := b.ChainConfig()
if config == nil {
config = evmtypes.DefaultChainConfig().EthereumConfig(eip155ChainID)

Check warning on line 57 in rpc/backend/chain_info.go

View check run for this annotation

Codecov / codecov/patch

rpc/backend/chain_info.go#L57

Added line #L57 was not covered by tests
}
if config.IsEIP155(new(big.Int).SetUint64(uint64(bn))) {
return (*hexutil.Big)(config.ChainID), nil
}

Expand Down

0 comments on commit 9c903b9

Please sign in to comment.