Skip to content

Commit f59d394

Browse files
authored
Merge pull request #1109 from oasisprotocol/ptrus/feature/evm-raw-tx
analyzer/evm_raw_tx: Use nil for legacy evm txs chain id
2 parents 254a1ed + 5730d80 commit f59d394

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

.changelog/1109.trivial.md

Whitespace-only changes.

analyzer/uncategorized/evm_raw_tx.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ func decodeEthRawTx(body []byte, minGasPrice common.BigInt) (*sdkTypes.Transacti
2727
tb = evmV1.Create(ethTx.Value().Bytes(), ethTx.Data())
2828
}
2929

30-
chainIDBI := ethTx.ChainId()
31-
if chainIDBI == nil || chainIDBI.Cmp(big.NewInt(0)) == 0 {
32-
// Legacy transactions don't have a chain ID, use 1 in that case as a default.
30+
chainID := ethTx.ChainId()
31+
if chainID != nil && chainID.Cmp(big.NewInt(0)) == 0 {
32+
// Legacy transactions don't have a chain ID but `ChainId()` returns 0, which is invalid
33+
// for `LatestSignerForChainId` which expects a nil in that case (zero causes a panic).
3334
// https://github.com/ethereum/go-ethereum/issues/31653
34-
chainIDBI = big.NewInt(1)
35+
chainID = nil
3536
}
36-
signer := ethTypes.LatestSignerForChainID(chainIDBI)
37+
signer := ethTypes.LatestSignerForChainID(chainID)
3738
pubUncompressed, err := CancunSenderPub(signer, &ethTx)
3839
if err != nil {
3940
return nil, fmt.Errorf("recover signer public key: %w", err)

0 commit comments

Comments
 (0)