zeta-chain / node

ZetaChain’s blockchain node and an observer validator client
https://zetachain.com
MIT License
163 stars 104 forks source link

Eth RPC: personal_sendTransaction panic #510

Open brewmaster012 opened 1 year ago

brewmaster012 commented 1 year ago

Some RPC calls might cause panic of the Ethermint RPC server. Here's a log.

Is there anything that we could do about it? The correct behavior should be to check the signature length and return error in JSON-RPC response, not panic.

3:52PM ERR RPC method personal_sendTransaction crashed: wrong size for signature: got 64, want 65                                                      
goroutine 3234061 [running]:                                                                                                                           
github.com/ethereum/go-ethereum/rpc.(*callback).call.func1()                                                                                           
        /go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/rpc/service.go:200 +0x89                                                                  
panic({0x2650260, 0xc001d7ecf0})                                                                                                                       
        /usr/local/go/src/runtime/panic.go:884 +0x212                                                                                                  
github.com/ethereum/go-ethereum/core/types.decodeSignature({0xc002358a40?, 0xf71793?, 0x3a36d20?})                                                     
        /go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/core/types/transaction_signing.go:474 +0x22a                                              
github.com/ethereum/go-ethereum/core/types.EIP155Signer.SignatureValues({0xc000c5d5c0?, 0xc001eeffe0?}, 0x2?, {0xc002358a40, 0x40, 0x40})              
        /go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/core/types/transaction_signing.go:381 +0x67                                               
github.com/ethereum/go-ethereum/core/types.eip2930Signer.SignatureValues({{0xc000c5d5c0?, 0xc001eeffe0?}}, 0x3a50ab8?, {0xc002358a40?, 0xc001ae4408?, 0
x4?})                                                                                                                                                  
        /go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/core/types/transaction_signing.go:281 +0x15c                                              
github.com/ethereum/go-ethereum/core/types.londonSigner.SignatureValues({{{0xc000c5d5c0?, 0xc001eeffe0?}}}, 0xc001ffac00?, {0xc002358a40?, 0x20?, 0x20?
})                                                                                                                                                     
        /go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/core/types/transaction_signing.go:206 +0x126                                              
github.com/ethereum/go-ethereum/core/types.(*Transaction).WithSignature(0xc003401980, {0x3a39320, 0xc001d7e720}, {0xc002358a40?, 0xc0022380c0?, 0x2a?})
        /go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/core/types/transaction.go:390 +0x44                                                       
github.com/evmos/ethermint/x/evm/types.(*MsgEthereumTx).Sign(0xc0017e4420, {0x3a39320, 0xc001d7e720}, {0x7fea14008c88, 0xc001a4d620})                  
        /go/pkg/mod/github.com/evmos/ethermint@v0.21.0/x/evm/types/msg.go:271 +0x1fd                                                                   
github.com/zeta-chain/zetacore/rpc/backend.(*Backend).SendTransaction(0xc0014e2500, {0xc00159a5a0, 0xc00159a5b8, 0xc000dcb9a8, 0xc001625980, 0x0, 0x0, 
0xc0016259a0, 0xc0019468c8, 0x0, ...})                                                                                                                 
        /go/delivery/zeta-node/rpc/backend/sign_tx.go:69 +0x7b8                                                                                        
github.com/zeta-chain/zetacore/rpc/namespaces/ethereum/personal.(*PrivateAccountAPI).SendTransaction(0xc00204e600, {0x10?, 0x27d6ba0?}, {0xc00159a5a0, 
0xc00159a5b8, 0xc000dcb9a8, 0xc001625980, 0x0, 0x0, 0xc0016259a0, ...}, ...)                                                                           
        /go/delivery/zeta-node/rpc/namespaces/ethereum/personal/api.go:133 +0x17c                                                                      
reflect.Value.call({0xc001942300?, 0xc0023b3ad8?, 0x7fea3f36e108?}, {0x2ad5a66, 0x4}, {0xc0014db200, 0x4, 0x1cc73b2?})                                 
        /usr/local/go/src/reflect/value.go:584 +0x8c5                                                                                                  
reflect.Value.Call({0xc001942300?, 0xc0023b3ad8?, 0x16?}, {0xc0014db200?, 0x2?, 0x2?})                                                                 
        /usr/local/go/src/reflect/value.go:368 +0xbc                                                                                                   
github.com/ethereum/go-ethereum/rpc.(*callback).call(0xc00211df80, {0x3a340c0?, 0xc0018742c0}, {0xc00159a480, 0x18}, {0xc000d69b30, 0x2, 0x4ded57?})   
        /go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/rpc/service.go:206 +0x3e5                                                                 
github.com/ethereum/go-ethereum/rpc.(*handler).runMethod(0xc0000eca80?, {0x3a340c0?, 0xc0018742c0?}, 0xc001612a80, 0x2?, {0xc000d69b30?, 0x0?, 0x4edd33
?})                                                                                                                                                    
        /go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/rpc/handler.go:389 +0x45                                                                  
github.com/ethereum/go-ethereum/rpc.(*handler).handleCall(0xc0018bbcb0, 0xc000d69950, 0xc001612a80)     
        /go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/rpc/handler.go:337 +0x239
github.com/ethereum/go-ethereum/rpc.(*handler).handleCallMsg(0xc0018bbcb0, 0xc00007b800?, 0xc001612a80)
        /go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/rpc/handler.go:298 +0xd1
github.com/ethereum/go-ethereum/rpc.(*handler).handleMsg.func1(0xc000d69950)
        /go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/rpc/handler.go:139 +0x35
github.com/ethereum/go-ethereum/rpc.(*handler).startCallProc.func1()
        /go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/rpc/handler.go:226 +0xc5
created by github.com/ethereum/go-ethereum/rpc.(*handler).startCallProc
        /go/pkg/mod/github.com/ethereum/go-ethereum@v1.10.26/rpc/handler.go:222 +0x8d
 module=geth
brewmaster012 commented 1 year ago

cc @aldapp7

aldapp7 commented 1 year ago

@brewmaster012 I will take a look.

aldapp7 commented 1 year ago

@brewmaster012 can you pls provide examples of txs when that happens?

aldapp7 commented 1 year ago

There are no signatures arguments being passed in TransactionArgs structure and signing is being done inside sign_tx method and fails deep inside signing ethermint and go-ethereum methods. The theory is that it might be due to incorrect chainId parsing and that signer/sender is failed to be derived from transaction message.

We can add additional checks (I've already did locally) to verify chainId for tx and check that signer and sender could be correctly derived from transaction msg before signing to avoid panics due to such reason.