@@ -807,6 +807,7 @@ func testEVMOnlyLoad(t *testing.T) {
807807 contract , deploy := assertEVMOnlyContractQueries (t , rpcCtx , clients )
808808 assertEVMOnlyTraces (t , rpcCtx , clients , contract , deploy )
809809 assertEVMOnlyNewHeads (t , rpcCtx , clients )
810+ assertEVMOnlyTransactionErrors (t , rpcCtx , clients , block .Txs [0 ])
810811}
811812
812813func assertEVMOnlyBalances (t * testing.T , ctx context.Context , clients []* ethrpc.Client , txs [][]byte ) {
@@ -1629,3 +1630,85 @@ func assertEVMOnlyNewHeads(t *testing.T, ctx context.Context, clients []*ethrpc.
16291630 }
16301631 }
16311632}
1633+
1634+ // evmOnlyFailingDeployerAccount is past the contract deployer, so the failing
1635+ // deploy is the first transaction from its account.
1636+ const evmOnlyFailingDeployerAccount = 2_000_001
1637+
1638+ // assertEVMOnlyTransactionErrors sends a deploy whose init code is the INVALID
1639+ // opcode and checks, on every node, that eth_getVMError and
1640+ // eth_getTransactionErrorByHash report its error and report "" for the
1641+ // successful transfer succeeded, that an unknown hash is "" for
1642+ // eth_getTransactionErrorByHash and an error for eth_getVMError, and that
1643+ // web3_clientVersion answers in the Sei/<seid version>/ format.
1644+ func assertEVMOnlyTransactionErrors (t * testing.T , ctx context.Context , clients []* ethrpc.Client , succeeded []byte ) {
1645+ t .Helper ()
1646+ key , err := scenarios .DeterministicPrivateKey (evmOnlyFailingDeployerAccount )
1647+ if err != nil {
1648+ t .Fatalf ("derive failing deployer key: %v" , err )
1649+ }
1650+ signed , err := ethtypes .SignTx (ethtypes .NewTx (& ethtypes.LegacyTx {
1651+ GasPrice : evmOnlyTransferConfig (1 ).GasPrice ,
1652+ Gas : evmOnlyContractGasLimit ,
1653+ Data : []byte {0xfe },
1654+ }), ethtypes .LatestSignerForChainID (new (big.Int ).SetUint64 (tmconfig .AutobahnEVMOnlyChainID )), key )
1655+ if err != nil {
1656+ t .Fatalf ("sign failing deploy: %v" , err )
1657+ }
1658+ raw , err := signed .MarshalBinary ()
1659+ if err != nil {
1660+ t .Fatalf ("encode failing deploy: %v" , err )
1661+ }
1662+ if err := clients [0 ].CallContext (ctx , nil , "eth_sendRawTransaction" , hexutil .Bytes (raw )); err != nil {
1663+ t .Fatalf ("send failing deploy: %v" , err )
1664+ }
1665+ var receipt evmOnlyReceiptSummary
1666+ decodeEVMOnlyResult (t , 0 , "eth_getTransactionReceipt" ,
1667+ waitForEVMOnlyResult (t , ctx , clients , "eth_getTransactionReceipt" , signed .Hash ()), & receipt )
1668+ if receipt .Status != hexutil .Uint64 (ethtypes .ReceiptStatusFailed ) {
1669+ t .Fatalf ("failing deploy %s has status %d, want failed" , signed .Hash (), receipt .Status )
1670+ }
1671+ successful := new (ethtypes.Transaction )
1672+ if err := successful .UnmarshalBinary (succeeded ); err != nil {
1673+ t .Fatalf ("decode successful transfer: %v" , err )
1674+ }
1675+
1676+ var wantVMError string
1677+ for nodeIndex , client := range clients {
1678+ var vmError , errorByHash string
1679+ decodeEVMOnlyResult (t , nodeIndex , "eth_getVMError" , evmOnlyCall (t , ctx , client , nodeIndex , "eth_getVMError" , signed .Hash ()), & vmError )
1680+ decodeEVMOnlyResult (t , nodeIndex , "eth_getTransactionErrorByHash" ,
1681+ evmOnlyCall (t , ctx , client , nodeIndex , "eth_getTransactionErrorByHash" , signed .Hash ()), & errorByHash )
1682+ if nodeIndex == 0 {
1683+ wantVMError = vmError
1684+ }
1685+ if vmError == "" || vmError != wantVMError || errorByHash != vmError {
1686+ t .Fatalf ("node %d failing deploy: eth_getVMError = %q, eth_getTransactionErrorByHash = %q, want node 0's non-empty %q from both" ,
1687+ nodeIndex , vmError , errorByHash , wantVMError )
1688+ }
1689+
1690+ for _ , method := range []string {"eth_getVMError" , "eth_getTransactionErrorByHash" } {
1691+ var got string
1692+ decodeEVMOnlyResult (t , nodeIndex , method , evmOnlyCall (t , ctx , client , nodeIndex , method , successful .Hash ()), & got )
1693+ if got != "" {
1694+ t .Fatalf ("node %d %s(%s) = %q for a successful transfer, want \" \" " , nodeIndex , method , successful .Hash (), got )
1695+ }
1696+ }
1697+
1698+ var unknown string
1699+ decodeEVMOnlyResult (t , nodeIndex , "eth_getTransactionErrorByHash" ,
1700+ evmOnlyCall (t , ctx , client , nodeIndex , "eth_getTransactionErrorByHash" , common.Hash {}), & unknown )
1701+ if unknown != "" {
1702+ t .Fatalf ("node %d eth_getTransactionErrorByHash for an unknown hash = %q, want \" \" " , nodeIndex , unknown )
1703+ }
1704+ if err := client .CallContext (ctx , & unknown , "eth_getVMError" , common.Hash {}); err == nil || ! strings .Contains (err .Error (), "receipt not found" ) {
1705+ t .Fatalf ("node %d eth_getVMError for an unknown hash = %q, %v; want the receipt-not-found error" , nodeIndex , unknown , err )
1706+ }
1707+
1708+ var version string
1709+ decodeEVMOnlyResult (t , nodeIndex , "web3_clientVersion" , evmOnlyCall (t , ctx , client , nodeIndex , "web3_clientVersion" ), & version )
1710+ if ! strings .HasPrefix (version , "Sei/" ) {
1711+ t .Fatalf ("node %d web3_clientVersion = %q, want the Sei/<seid version>/ form" , nodeIndex , version )
1712+ }
1713+ }
1714+ }
0 commit comments