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

Panic while updating an eth tx #2887

Closed
fbac opened this issue Sep 16, 2024 · 1 comment
Closed

Panic while updating an eth tx #2887

fbac opened this issue Sep 16, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@fbac
Copy link
Contributor

fbac commented Sep 16, 2024

Describe the Bug
Trying to get the receipt of an Ethereum transaction raises a panic.
Specifically, the transaction is initiated by e2e tests trying to call the method deposit() in the bank precompile. Later, when trying to get the receipt it panics while using WaitMined or any other receipt-retrieving method.

To Reproduce

  • Run e2e tests in branch feat/bank-precompile.
  • Try to get the receipt from the logged txHash.
  • cast receipt 0x6a602c7d384c40f00a6118d70221069fcc6eb151dcdff9dea86f68fba2e0327e --rpc-url=localhost:9545
  • This will raise a panic in zetacored:
2:59PM ERR RPC method eth_getTransactionReceipt crashed: runtime error: index out of range [1] with length 1
goroutine 10294 [running]:
github.com/ethereum/go-ethereum/rpc.(*callback).call.func1()
	/go/pkg/mod/github.com/zeta-chain/[email protected]/rpc/service.go:200 +0x74
panic({0x2d3eb60?, 0x4002e1c828?})
	/usr/local/go/src/runtime/panic.go:770 +0x124
github.com/zeta-chain/node/rpc/types.(*ParsedTxs).updateTx(0x4002694ac0, 0x1, {0x40023168c0?, 0x9f062102d718610a?, 0xdef9dfdc51b16ecc?})
	/go/delivery/zeta-node/rpc/types/events.go:334 +0x160
github.com/zeta-chain/node/rpc/types.ParseTxResult(0x40023172e8, {0x0, 0x0})
	/go/delivery/zeta-node/rpc/types/events.go:162 +0x318
github.com/zeta-chain/node/rpc/types.ParseTxIndexerResult(0x40023172c0, {0x0?, 0x0?}, 0x400246ef38)
	/go/delivery/zeta-node/rpc/types/events.go:209 +0x3c
github.com/zeta-chain/node/rpc/backend.(*Backend).queryTendermintTxIndexer(0x4000b6f908, {0x40024bd080?, 0x4000bbcf78?}, 0x400246ef38)
	/go/delivery/zeta-node/rpc/backend/tx_info.go:463 +0x118
github.com/zeta-chain/node/rpc/backend.(*Backend).GetTxByEthHash(0x4000b6f908, {0x90, 0x7c, 0x99, 0xfa, 0xf0, 0x18, 0x13, 0xe5, 0x7f, ...})
	/go/delivery/zeta-node/rpc/backend/tx_info.go:400 +0x1d0
github.com/zeta-chain/node/rpc/backend.(*Backend).GetTransactionReceipt(0x4000b6f908, {0x90, 0x7c, 0x99, 0xfa, 0xf0, 0x18, 0x13, 0xe5, 0x7f, ...})
	/go/delivery/zeta-node/rpc/backend/tx_info.go:171 +0x19c
github.com/zeta-chain/node/rpc/namespaces/ethereum/eth.(*PublicAPI).GetTransactionReceipt(0x40015a98c0, {0x90, 0x7c, 0x99, 0xfa, 0xf0, 0x18, 0x13, 0xe5, 0x7f, ...})
	/go/delivery/zeta-node/rpc/namespaces/ethereum/eth/api.go:216 +0x188
reflect.Value.call({0x4001f72300?, 0x40000aeb38?, 0x50?}, {0x2f3d5c8, 0x4}, {0x4001b13b80, 0x2, 0x1582a14?})
	/usr/local/go/src/reflect/value.go:596 +0x970
reflect.Value.Call({0x4001f72300?, 0x40000aeb38?, 0x16?}, {0x4001b13b80?, 0x0?, 0x40010b2008?})
	/usr/local/go/src/reflect/value.go:380 +0x94
github.com/ethereum/go-ethereum/rpc.(*callback).call(0x4001f72480, {0x41a1990, 0x4001b13ae0}, {0x400329a9e0, 0x19}, {0x4003b466f0, 0x1, 0x157c41c?})
	/go/pkg/mod/github.com/zeta-chain/[email protected]/rpc/service.go:206 +0x2d0
github.com/ethereum/go-ethereum/rpc.(*handler).runMethod(0x4003284f50?, {0x41a1990?, 0x4001b13ae0?}, 0x4002239500, 0x1?, {0x4003b466f0?, 0x0?, 0x0?})
	/go/pkg/mod/github.com/zeta-chain/[email protected]/rpc/handler.go:389 +0x40
github.com/ethereum/go-ethereum/rpc.(*handler).handleCall(0x40011b2480, 0x40033838f0, 0x4002239500)
	/go/pkg/mod/github.com/zeta-chain/[email protected]/rpc/handler.go:337 +0x1d8
github.com/ethereum/go-ethereum/rpc.(*handler).handleCallMsg(0x40011b2480, 0x40033838f0, 0x4002239500)
	/go/pkg/mod/github.com/zeta-chain/[email protected]/rpc/handler.go:298 +0x80
github.com/ethereum/go-ethereum/rpc.(*handler).handleMsg.func1(0x40033838f0)
	/go/pkg/mod/github.com/zeta-chain/[email protected]/rpc/handler.go:139 +0x34
github.com/ethereum/go-ethereum/rpc.(*handler).startCallProc.func1()
	/go/pkg/mod/github.com/zeta-chain/[email protected]/rpc/handler.go:226 +0xbc
created by github.com/ethereum/go-ethereum/rpc.(*handler).startCallProc in goroutine 10160
	/go/pkg/mod/github.com/zeta-chain/[email protected]/rpc/handler.go:222 +0x84

The out of range panic suggest that the replacement we're performing in updateTx is invalid somehow:

// updateTx updates an exiting tx from events, called during parsing.
// In event format 2, we update the tx with the attributes of the second `ethereum_tx` event,
// Due to bug https://github.com/zeta-chain/ethermint/issues/1175, the first `ethereum_tx` event may emit incorrect tx hash,
// so we prefer the second event and override the first one.
func (p *ParsedTxs) updateTx(eventIndex int, attrs []abci.EventAttribute) error {
	tx := NewParsedTx(eventIndex)
	if err := fillTxAttributes(&tx, attrs); err != nil {
		return err
	}
	if tx.Hash != p.Txs[eventIndex].Hash {
		// if hash is different, index the new one too
		p.TxHashes[tx.Hash] = eventIndex
	}

The raw []abci.EventAttribute slice:

{Key:txHash Value:6A602C7D384C40F00A6118D70221069FCC6EB151DCDFF9DEA86F68FBA2E0327E Index:true} 
{Key:amount Value:0 Index:true} 
{Key:ethereumTxHash Value:0x6a602c7d384c40f00a6118d70221069fcc6eb151dcdff9dea86f68fba2e0327e Index:true} 
{Key:txIndex Value:8888 Index:true} 
{Key:txGasUsed Value:24769 Index:true} 
{Key:recipient Value:0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf Index:true} 
{Key:txData Value:0xdd62ed3e000000000000000000000000b552ffab2500258c1a705ba4fe77a333275afe450000000000000000000000000000000000000000000000000000000000000067 Index:true} 
{Key:txNonce Value:0 Index:true}

The tx after fillTxAttributes:

DEBUG: Filled transaction {MsgIndex:1 Hash:0x6a602c7d384c40f00a6118d70221069fcc6eb151dcdff9dea86f68fba2e0327e 
EthTxIndex:8888 
GasUsed:24769 
Failed:false 
TxHash:6A602C7D384C40F00A6118D70221069FCC6EB151DCDFF9DEA86F68FBA2E0327E 
Type:0 
Amount:+0 
Recipient:0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf Sender:0x0000000000000000000000000000000000000000 
Nonce:0 
Data:[221 98 237 62 0 0 0 0 0 0 0 0 0 0 0 0 181 82 255 171 37 0 37 140 26 112 91 164 254 119 163 51 39 90 254 69 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 103]}
@fbac fbac added the bug Something isn't working label Sep 16, 2024
@skosito skosito self-assigned this Sep 16, 2024
@fbac
Copy link
Contributor Author

fbac commented Sep 16, 2024

Closing as duplicate. Work in progress in #2886.

@fbac fbac closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants