ethermint icon indicating copy to clipboard operation
ethermint copied to clipboard

Contract Call with internal tx transfer EVMOS not recorded into value field of tx

Open VictorTrustyDev opened this issue 2 years ago • 1 comments

System info: EVMOS main net

Steps to reproduce:

Deploy a smart contract with internal transfer

    function withdrawToRegisteredAddress() public virtual payable override returns (bool) {
        payable(_registered).transfer(1000000000);
        return true;
    }

Do something to register another address into _registered value and then use another wallet to call this method to trigger transfer some aevmos from balance of contract into the registered wallet

Expected behavior: value=0x3B9ACA00 (1000000000), transferred amount should be recorded into the value field when eth_getTransactionByHash

Actual behavior: value=0x0

Additional info: My test contract on mainnet: 0x84b835AD619A65B122e5C809cB86BBe94a1B6535

Transaction with internal tx: 0xad2032...37fb7d at 2,881,552

Before tx:

  • Contract balance: evmosd q bank balances evmos1sjurtttpnfjmzgh9eqyuhp4ma99pkef496tvvs --height 2881551 = 29999996000000000 aevmos
  • _registered wallet balance: evmosd q bank balances evmos13zywe67w439fasflavwungtvycm73zygg85glp --height 2881551 = 38750496500000000 aevmos

After tx:

  • Contract balance: evmosd q bank balances evmos1sjurtttpnfjmzgh9eqyuhp4ma99pkef496tvvs --height 2881552 = 29999995000000000 aevmos
  • _registered wallet balance: evmosd q bank balances evmos13zywe67w439fasflavwungtvycm73zygg85glp --height 2881552 = 38750497500000000 aevmos

Diff:

  • Contract: 29999995000000000 - 29999996000000000 = -1000000000 aevmos
  • _registered: 38750497500000000 - 38750496500000000 = +1000000000 aevmos

Refer to Ethereum's transaction 0x4885e2...c48f02 on etherscan.io. This tx has correct value: 0xc3663566a58000 (0.055 ETH, which is sum of 0.‍001375 + 0.‍0055 + 0.‍048125 as shown in etherscan) when I do eth_getTransactionByHash so I think Ethermint should have the same behavior?

Some eth_getTransactionByHash calls and results:

  • EVMOS:
{
     "id": 1,
     "jsonrpc": "2.0",
     "method": "eth_getTransactionByHash",
     "params":["0xad20322006c84a3a53ab784abb5a2c59f8621fbb608b394955841c19ba37fb7d"]
}
{"id":1,"jsonrpc":"2.0","result":{"accessList":[],"blockHash":"0xfa03aace4936529b2c652757242cab4904a65db75b3175f39b0f6947d1bd1822","blockNumber":"0x2bf810","chainId":"0x2329","from":"0xc3bcffe76cffca203fb78d7d9170a40a259a3059","gas":"0x88d3","gasPrice":"0x53d1ac100","hash":"0xad20322006c84a3a53ab784abb5a2c59f8621fbb608b394955841c19ba37fb7d","input":"0x89b8217a","maxFeePerGas":"0x9e5328900","maxPriorityFeePerGas":"0x9502f900","nonce":"0x5","r":"0x58b68391fdb851dc93da4fd842f0593e78ab2dd792741206a8f13df32043b18c","s":"0x17cf6adea52599a8b904e535c672b2aae49311a6a6f1fd54883a574ebc8b22cf","to":"0x84b835ad619a65b122e5c809cb86bbe94a1b6535","transactionIndex":"0x0","type":"0x2","v":"0x0","value":"0x0"}}
  • Ethereum:
{
     "id": 1,
     "jsonrpc": "2.0",
     "method": "eth_getTransactionByHash",
     "params":["0x4885e2a62d90a7c10af571044bca3890d828fa9e5f6ecbf1cd416e366ac48f02"]
}
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0xa8fdc416dd3756a023661d2b5c6dc4392fb0750aaedfa3df213ecea8ae3c9140","blockNumber":"0xe9fbe6","from":"0x53c337e57fbebd9ebf416c1eb2699c60a748983b","gas":"0x2494a","gasPrice":"0x22056d03b","maxFeePerGas":"0x3b0ca9840","maxPriorityFeePerGas":"0x9502f900","hash":"0x4885e2a62d90a7c10af571044bca3890d828fa9e5f6ecbf1cd416e366ac48f02","input":"0xfb0f3ee100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000aaf96eb9d0d0000000000000000000000000004ae06fb032508b39b6866e2597fb1104be22ae69000000000000000000000000004c00500000ad104d7dbd00e3ae0a5c00560c000000000000000000000000009450ff0503f3fbf2bc85e9d71f46e47d61777f630000000000000000000000000000000000000000000000000000000000000efa000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000062f7bcbf00000000000000000000000000000000000000000000000000000000631f9e0e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005161f1e483901e0000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f00000000007b02230091a7ed01230072f7006a004d60a8d4e71d599b8104250f00000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000004e28e2290f0000000000000000000000000008de9c5a032463c561423387a9648c5c7bcc5bc9000000000000000000000000000000000000000000000000000138a388a43c000000000000000000000000000a70387b87c8f850123e9f3c0ea6148e360eb681f0000000000000000000000000000000000000000000000000000000000000041c10fa49991d9516be24e39e70e529346a8923ec429753fdfea3bbbfdc62776247716e76b7eaf6bdd73312c99b47f6994c4f669e96201e3b52d37f1a1ecd63dec1c00000000000000000000000000000000000000000000000000000000000000","nonce":"0x51","to":"0x00000000006c3852cbef3e08e8df289169ede581","transactionIndex":"0x6","value":"0xc3663566a58000","type":"0x2","accessList":[],"chainId":"0x1","v":"0x0","r":"0xf883de2a882dc4e222c7a0d51a6a84c78af0543630cbea3129c1613e12075c3d","s":"0x6b13d979867e26b88f98fd450deb4906f7b64e3e58eed86f5e87ae67588edca6"}}

VictorTrustyDev avatar Aug 13 '22 16:08 VictorTrustyDev

My tool also detected this tx 0xbd132d923956fdbaa12fe79b1077699b8facb683c016357300a65b427e1b4185 from the same block with above tx

It's separated with the 0.55 WEVMOS token transfer as you see in blockscout

VictorTrustyDev avatar Aug 13 '22 17:08 VictorTrustyDev

@danburck my team mate said I was wrong in this case. He said the value represents for amount of coin base sent by the sender within tx.

In case of Ethereum tx, the method was called is a payable method and the sender did send ETH, that why the value != 0. I checked the source code of contract and they really read msg.value and split it and do some internal tx

In case of my contract, the method also payable but I did not send any EVMOS so that's why the value == 0

This makes sense but I'm not sure about the spec. If my friend explained correctly, we can close this case

VictorTrustyDev avatar Aug 17 '22 06:08 VictorTrustyDev