Skip to content

Commit 19c2c53

Browse files
committed
fix: Fix parsing of legacy transactions without chain ID
Newer go-ethereum versions reject a zero `chainID` in `LatestSignerForChainID`. For legacy transactions without a chain ID, we now correctly pass `nil`.
1 parent 318aa53 commit 19c2c53

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

indexer/utils.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,14 @@ func blockToModels(
149149
for idx, ethTx := range transactions {
150150
ethTxHex := ethTx.Hash().Hex()
151151
v, r, s := ethTx.RawSignatureValues()
152-
signer := ethtypes.LatestSignerForChainID(ethTx.ChainId())
152+
chainID := ethTx.ChainId()
153+
if chainID != nil && chainID.Cmp(big.NewInt(0)) == 0 {
154+
// Legacy transactions don't have a chain ID but `ChainId()` returns 0, which is invalid
155+
// for `LatestSignerForChainId` which expects a null in that case (zero causes a panic).
156+
// https://github.com/ethereum/go-ethereum/issues/31653
157+
chainID = nil
158+
}
159+
signer := ethtypes.LatestSignerForChainID(chainID)
153160
from, _ := signer.Sender(ethTx)
154161
ethAccList := ethTx.AccessList()
155162
accList := make([]model.AccessTuple, 0, len(ethAccList))

0 commit comments

Comments
 (0)