From 8907a614f90ce728d2775c19e7e90f61aa6d2c42 Mon Sep 17 00:00:00 2001 From: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> Date: Fri, 8 Nov 2024 09:18:42 -0600 Subject: [PATCH] feat(evm-funtoken-precompile): Implement "balance", "bankBalance", and "whoAmI" methods (#2107) --- CHANGELOG.md | 2 + eth/rpc/backend/account_info.go | 3 +- eth/rpc/rpcapi/eth_api_test.go | 15 +- .../contracts/IFunToken.sol/IFunToken.json | 137 +++++++- .../TestERC20TransferThenPrecompileSend.json | 4 +- .../TestFunTokenPrecompileLocalGas.json | 4 +- .../TestNativeSendThenPrecompileSend.json | 22 +- .../TestPrecompileSelfCallRevert.json | 4 +- x/evm/embeds/contracts/IFunToken.sol | 47 ++- .../TestERC20TransferThenPrecompileSend.sol | 4 +- .../TestFunTokenPrecompileLocalGas.sol | 14 +- .../TestNativeSendThenPrecompileSend.sol | 25 +- .../TestPrecompileSelfCallRevert.sol | 8 +- x/evm/embeds/embeds.go | 18 +- x/evm/evmtest/erc20.go | 12 + x/evm/keeper/funtoken_from_coin_test.go | 94 ++++-- x/evm/keeper/funtoken_from_erc20_test.go | 12 +- x/evm/keeper/keeper.go | 9 - x/evm/keeper/msg_server.go | 16 +- x/evm/precompile/errors.go | 5 +- x/evm/precompile/funtoken.go | 317 ++++++++++++++++-- x/evm/precompile/funtoken_test.go | 205 ++++++++++- x/evm/precompile/oracle.go | 12 +- x/evm/precompile/precompile.go | 5 +- x/evm/precompile/wasm.go | 18 +- x/evm/precompile/wasm_parse.go | 20 +- 26 files changed, 872 insertions(+), 160 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4e5fa640..85be6188d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,6 +100,8 @@ tests for race conditions within funtoken precompile - [#2100](https://github.com/NibiruChain/nibiru/pull/2100) - refactor: cleanup statedb and precompile sections - [#2101](https://github.com/NibiruChain/nibiru/pull/2101) - fix(evm): tx receipt proper marshalling - [#2105](https://github.com/NibiruChain/nibiru/pull/2105) - test(evm): precompile call with revert +- [#2107](https://github.com/NibiruChain/nibiru/pull/2107) - +feat(evm-funtoken-precompile): Implement methods: balance, bankBalance, whoAmI #### Nibiru EVM | Before Audit 1 - 2024-10-18 diff --git a/eth/rpc/backend/account_info.go b/eth/rpc/backend/account_info.go index 53fcd222e..2a5de9245 100644 --- a/eth/rpc/backend/account_info.go +++ b/eth/rpc/backend/account_info.go @@ -61,7 +61,8 @@ func (b *Backend) GetProof( } ctx := rpc.NewContextWithHeight(height) - // if the height is equal to zero, meaning the query condition of the block is either "pending" or "latest" + // if the height is equal to zero, meaning the query condition of the block + // is either "pending" or "latest" if height == 0 { bn, err := b.BlockNumber() if err != nil { diff --git a/eth/rpc/rpcapi/eth_api_test.go b/eth/rpc/rpcapi/eth_api_test.go index 1a599d2f1..3f274d1cf 100644 --- a/eth/rpc/rpcapi/eth_api_test.go +++ b/eth/rpc/rpcapi/eth_api_test.go @@ -106,7 +106,11 @@ func (s *NodeSuite) Test_BlockNumber() { ethBlockNumber, err := s.ethClient.BlockNumber(context.Background()) s.NoError(err) - s.Equal(networkBlockNumber, int64(ethBlockNumber)) + // It might be off by 1 block in either direction. + blockDiff := networkBlockNumber - int64(ethBlockNumber) + s.Truef(blockDiff <= 2, "networkBlockNumber %d, ethBlockNumber %d", + networkBlockNumber, ethBlockNumber, + ) } // Test_BlockByNumber EVM method: eth_getBlockByNumber @@ -366,11 +370,10 @@ func (s *NodeSuite) Test_SmartContract() { txHash, err := s.ethAPI.SendRawTransaction(txBz) s.Require().NoError(err) - s.T().Log("Assert: tx IS pending just after execution") - pendingTxs, err := s.ethAPI.GetPendingTransactions() - s.NoError(err) - s.Require().Len(pendingTxs, 1) - _ = s.network.WaitForNextBlock() + s.T().Log("Wait a few blocks so the tx won't be pending") + for i := 0; i < 5; i++ { + _ = s.network.WaitForNextBlock() + } s.T().Log("Assert: tx NOT pending") { diff --git a/x/evm/embeds/artifacts/contracts/IFunToken.sol/IFunToken.json b/x/evm/embeds/artifacts/contracts/IFunToken.sol/IFunToken.json index 882e04696..5877e277b 100644 --- a/x/evm/embeds/artifacts/contracts/IFunToken.sol/IFunToken.json +++ b/x/evm/embeds/artifacts/contracts/IFunToken.sol/IFunToken.json @@ -3,6 +3,110 @@ "contractName": "IFunToken", "sourceName": "contracts/IFunToken.sol", "abi": [ + { + "inputs": [ + { + "internalType": "address", + "name": "who", + "type": "address" + }, + { + "internalType": "address", + "name": "funtoken", + "type": "address" + } + ], + "name": "balance", + "outputs": [ + { + "internalType": "uint256", + "name": "erc20Balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bankBalance", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "erc20", + "type": "address" + }, + { + "internalType": "string", + "name": "bankDenom", + "type": "string" + } + ], + "internalType": "struct IFunToken.FunToken", + "name": "token", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "address", + "name": "ethAddr", + "type": "address" + }, + { + "internalType": "string", + "name": "bech32Addr", + "type": "string" + } + ], + "internalType": "struct IFunToken.NibiruAccount", + "name": "whoAddrs", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "who", + "type": "address" + }, + { + "internalType": "string", + "name": "bankDenom", + "type": "string" + } + ], + "name": "bankBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "bankBalance", + "type": "uint256" + }, + { + "components": [ + { + "internalType": "address", + "name": "ethAddr", + "type": "address" + }, + { + "internalType": "string", + "name": "bech32Addr", + "type": "string" + } + ], + "internalType": "struct IFunToken.NibiruAccount", + "name": "whoAddrs", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -21,7 +125,7 @@ "type": "string" } ], - "name": "bankSend", + "name": "sendToBank", "outputs": [ { "internalType": "uint256", @@ -31,6 +135,37 @@ ], "stateMutability": "nonpayable", "type": "function" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "who", + "type": "string" + } + ], + "name": "whoAmI", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "ethAddr", + "type": "address" + }, + { + "internalType": "string", + "name": "bech32Addr", + "type": "string" + } + ], + "internalType": "struct IFunToken.NibiruAccount", + "name": "whoAddrs", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "function" } ], "bytecode": "0x", diff --git a/x/evm/embeds/artifacts/contracts/TestERC20TransferThenPrecompileSend.sol/TestERC20TransferThenPrecompileSend.json b/x/evm/embeds/artifacts/contracts/TestERC20TransferThenPrecompileSend.sol/TestERC20TransferThenPrecompileSend.json index 3a1411d37..a01b550fc 100644 --- a/x/evm/embeds/artifacts/contracts/TestERC20TransferThenPrecompileSend.sol/TestERC20TransferThenPrecompileSend.json +++ b/x/evm/embeds/artifacts/contracts/TestERC20TransferThenPrecompileSend.sol/TestERC20TransferThenPrecompileSend.json @@ -43,8 +43,8 @@ "type": "function" } ], - "bytecode": "0x608060405234801561001057600080fd5b50604051610c4c380380610c4c833981810160405281019061003291906100db565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b6100b88161009d565b81146100c357600080fd5b50565b6000815190506100d5816100af565b92915050565b6000602082840312156100f1576100f0610078565b5b60006100ff848285016100c6565b91505092915050565b610b35806101176000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063264c325814610030575b600080fd5b61004a6004803603810190610045919061065c565b61004c565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85856040518363ffffffff1660e01b81526004016100a792919061074d565b6020604051808303816000875af11580156100c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100ea91906107ae565b610129576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012090610838565b60405180910390fd5b600061080073ffffffffffffffffffffffffffffffffffffffff166303003bc560008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684866040518463ffffffff1660e01b815260040161018a939291906108e7565b6020604051808303816000875af11580156101a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101cd919061093a565b90508181146101db8261024d565b6101e48461024d565b6040516020016101f5929190610a61565b60405160208183030381529060405290610245576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023c9190610aae565b60405180910390fd5b505050505050565b60606000600161025c8461031b565b01905060008167ffffffffffffffff81111561027b5761027a610531565b5b6040519080825280601f01601f1916602001820160405280156102ad5781602001600182028036833780820191505090505b509050600082602001820190505b600115610310578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a858161030457610303610ad0565b5b049450600085036102bb575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310610379577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000838161036f5761036e610ad0565b5b0492506040810190505b6d04ee2d6d415b85acef810000000083106103b6576d04ee2d6d415b85acef810000000083816103ac576103ab610ad0565b5b0492506020810190505b662386f26fc1000083106103e557662386f26fc1000083816103db576103da610ad0565b5b0492506010810190505b6305f5e100831061040e576305f5e100838161040457610403610ad0565b5b0492506008810190505b612710831061043357612710838161042957610428610ad0565b5b0492506004810190505b60648310610456576064838161044c5761044b610ad0565b5b0492506002810190505b600a8310610465576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006104ad82610482565b9050919050565b6104bd816104a2565b81146104c857600080fd5b50565b6000813590506104da816104b4565b92915050565b6000819050919050565b6104f3816104e0565b81146104fe57600080fd5b50565b600081359050610510816104ea565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61056982610520565b810181811067ffffffffffffffff8211171561058857610587610531565b5b80604052505050565b600061059b61046e565b90506105a78282610560565b919050565b600067ffffffffffffffff8211156105c7576105c6610531565b5b6105d082610520565b9050602081019050919050565b82818337600083830152505050565b60006105ff6105fa846105ac565b610591565b90508281526020810184848401111561061b5761061a61051b565b5b6106268482856105dd565b509392505050565b600082601f83011261064357610642610516565b5b81356106538482602086016105ec565b91505092915050565b6000806000806080858703121561067657610675610478565b5b6000610684878288016104cb565b945050602061069587828801610501565b935050604085013567ffffffffffffffff8111156106b6576106b561047d565b5b6106c28782880161062e565b92505060606106d387828801610501565b91505092959194509250565b6000819050919050565b60006107046106ff6106fa84610482565b6106df565b610482565b9050919050565b6000610716826106e9565b9050919050565b60006107288261070b565b9050919050565b6107388161071d565b82525050565b610747816104e0565b82525050565b6000604082019050610762600083018561072f565b61076f602083018461073e565b9392505050565b60008115159050919050565b61078b81610776565b811461079657600080fd5b50565b6000815190506107a881610782565b92915050565b6000602082840312156107c4576107c3610478565b5b60006107d284828501610799565b91505092915050565b600082825260208201905092915050565b7f4552432d3230207472616e73666572206661696c656400000000000000000000600082015250565b60006108226016836107db565b915061082d826107ec565b602082019050919050565b6000602082019050818103600083015261085181610815565b9050919050565b600061086382610482565b9050919050565b61087381610858565b82525050565b600081519050919050565b60005b838110156108a2578082015181840152602081019050610887565b60008484015250505050565b60006108b982610879565b6108c381856107db565b93506108d3818560208601610884565b6108dc81610520565b840191505092915050565b60006060820190506108fc600083018661086a565b610909602083018561073e565b818103604083015261091b81846108ae565b9050949350505050565b600081519050610934816104ea565b92915050565b6000602082840312156109505761094f610478565b5b600061095e84828501610925565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e62616e6b53656e64207375636365656465642062757460008201527f207472616e73666572726564207468652077726f6e6720616d6f756e74000000602082015250565b60006109ce603d83610967565b91506109d982610972565b603d82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b6000610a1582610879565b610a1f8185610967565b9350610a2f818560208601610884565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b6000610a6c826109c1565b9150610a77826109e4565b600b82019150610a878285610a0a565b9150610a9282610a3b565b600982019150610aa28284610a0a565b91508190509392505050565b60006020820190508181036000830152610ac881846108ae565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea2646970667358221220f0624f3122eb5227189289362e14705abd19c84ea5ee45bc30dbf8eedcb157b064736f6c63430008180033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063264c325814610030575b600080fd5b61004a6004803603810190610045919061065c565b61004c565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85856040518363ffffffff1660e01b81526004016100a792919061074d565b6020604051808303816000875af11580156100c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100ea91906107ae565b610129576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012090610838565b60405180910390fd5b600061080073ffffffffffffffffffffffffffffffffffffffff166303003bc560008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684866040518463ffffffff1660e01b815260040161018a939291906108e7565b6020604051808303816000875af11580156101a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101cd919061093a565b90508181146101db8261024d565b6101e48461024d565b6040516020016101f5929190610a61565b60405160208183030381529060405290610245576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023c9190610aae565b60405180910390fd5b505050505050565b60606000600161025c8461031b565b01905060008167ffffffffffffffff81111561027b5761027a610531565b5b6040519080825280601f01601f1916602001820160405280156102ad5781602001600182028036833780820191505090505b509050600082602001820190505b600115610310578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a858161030457610303610ad0565b5b049450600085036102bb575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310610379577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000838161036f5761036e610ad0565b5b0492506040810190505b6d04ee2d6d415b85acef810000000083106103b6576d04ee2d6d415b85acef810000000083816103ac576103ab610ad0565b5b0492506020810190505b662386f26fc1000083106103e557662386f26fc1000083816103db576103da610ad0565b5b0492506010810190505b6305f5e100831061040e576305f5e100838161040457610403610ad0565b5b0492506008810190505b612710831061043357612710838161042957610428610ad0565b5b0492506004810190505b60648310610456576064838161044c5761044b610ad0565b5b0492506002810190505b600a8310610465576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006104ad82610482565b9050919050565b6104bd816104a2565b81146104c857600080fd5b50565b6000813590506104da816104b4565b92915050565b6000819050919050565b6104f3816104e0565b81146104fe57600080fd5b50565b600081359050610510816104ea565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61056982610520565b810181811067ffffffffffffffff8211171561058857610587610531565b5b80604052505050565b600061059b61046e565b90506105a78282610560565b919050565b600067ffffffffffffffff8211156105c7576105c6610531565b5b6105d082610520565b9050602081019050919050565b82818337600083830152505050565b60006105ff6105fa846105ac565b610591565b90508281526020810184848401111561061b5761061a61051b565b5b6106268482856105dd565b509392505050565b600082601f83011261064357610642610516565b5b81356106538482602086016105ec565b91505092915050565b6000806000806080858703121561067657610675610478565b5b6000610684878288016104cb565b945050602061069587828801610501565b935050604085013567ffffffffffffffff8111156106b6576106b561047d565b5b6106c28782880161062e565b92505060606106d387828801610501565b91505092959194509250565b6000819050919050565b60006107046106ff6106fa84610482565b6106df565b610482565b9050919050565b6000610716826106e9565b9050919050565b60006107288261070b565b9050919050565b6107388161071d565b82525050565b610747816104e0565b82525050565b6000604082019050610762600083018561072f565b61076f602083018461073e565b9392505050565b60008115159050919050565b61078b81610776565b811461079657600080fd5b50565b6000815190506107a881610782565b92915050565b6000602082840312156107c4576107c3610478565b5b60006107d284828501610799565b91505092915050565b600082825260208201905092915050565b7f4552432d3230207472616e73666572206661696c656400000000000000000000600082015250565b60006108226016836107db565b915061082d826107ec565b602082019050919050565b6000602082019050818103600083015261085181610815565b9050919050565b600061086382610482565b9050919050565b61087381610858565b82525050565b600081519050919050565b60005b838110156108a2578082015181840152602081019050610887565b60008484015250505050565b60006108b982610879565b6108c381856107db565b93506108d3818560208601610884565b6108dc81610520565b840191505092915050565b60006060820190506108fc600083018661086a565b610909602083018561073e565b818103604083015261091b81846108ae565b9050949350505050565b600081519050610934816104ea565b92915050565b6000602082840312156109505761094f610478565b5b600061095e84828501610925565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e62616e6b53656e64207375636365656465642062757460008201527f207472616e73666572726564207468652077726f6e6720616d6f756e74000000602082015250565b60006109ce603d83610967565b91506109d982610972565b603d82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b6000610a1582610879565b610a1f8185610967565b9350610a2f818560208601610884565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b6000610a6c826109c1565b9150610a77826109e4565b600b82019150610a878285610a0a565b9150610a9282610a3b565b600982019150610aa28284610a0a565b91508190509392505050565b60006020820190508181036000830152610ac881846108ae565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea2646970667358221220f0624f3122eb5227189289362e14705abd19c84ea5ee45bc30dbf8eedcb157b064736f6c63430008180033", + "bytecode": "0x608060405234801561001057600080fd5b50604051610c4c380380610c4c833981810160405281019061003291906100db565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b6100b88161009d565b81146100c357600080fd5b50565b6000815190506100d5816100af565b92915050565b6000602082840312156100f1576100f0610078565b5b60006100ff848285016100c6565b91505092915050565b610b35806101176000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063264c325814610030575b600080fd5b61004a6004803603810190610045919061065c565b61004c565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85856040518363ffffffff1660e01b81526004016100a792919061074d565b6020604051808303816000875af11580156100c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100ea91906107ae565b610129576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012090610838565b60405180910390fd5b600061080073ffffffffffffffffffffffffffffffffffffffff1663e77a47bf60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684866040518463ffffffff1660e01b815260040161018a939291906108e7565b6020604051808303816000875af11580156101a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101cd919061093a565b90508181146101db8261024d565b6101e48461024d565b6040516020016101f5929190610a61565b60405160208183030381529060405290610245576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023c9190610aae565b60405180910390fd5b505050505050565b60606000600161025c8461031b565b01905060008167ffffffffffffffff81111561027b5761027a610531565b5b6040519080825280601f01601f1916602001820160405280156102ad5781602001600182028036833780820191505090505b509050600082602001820190505b600115610310578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a858161030457610303610ad0565b5b049450600085036102bb575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310610379577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000838161036f5761036e610ad0565b5b0492506040810190505b6d04ee2d6d415b85acef810000000083106103b6576d04ee2d6d415b85acef810000000083816103ac576103ab610ad0565b5b0492506020810190505b662386f26fc1000083106103e557662386f26fc1000083816103db576103da610ad0565b5b0492506010810190505b6305f5e100831061040e576305f5e100838161040457610403610ad0565b5b0492506008810190505b612710831061043357612710838161042957610428610ad0565b5b0492506004810190505b60648310610456576064838161044c5761044b610ad0565b5b0492506002810190505b600a8310610465576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006104ad82610482565b9050919050565b6104bd816104a2565b81146104c857600080fd5b50565b6000813590506104da816104b4565b92915050565b6000819050919050565b6104f3816104e0565b81146104fe57600080fd5b50565b600081359050610510816104ea565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61056982610520565b810181811067ffffffffffffffff8211171561058857610587610531565b5b80604052505050565b600061059b61046e565b90506105a78282610560565b919050565b600067ffffffffffffffff8211156105c7576105c6610531565b5b6105d082610520565b9050602081019050919050565b82818337600083830152505050565b60006105ff6105fa846105ac565b610591565b90508281526020810184848401111561061b5761061a61051b565b5b6106268482856105dd565b509392505050565b600082601f83011261064357610642610516565b5b81356106538482602086016105ec565b91505092915050565b6000806000806080858703121561067657610675610478565b5b6000610684878288016104cb565b945050602061069587828801610501565b935050604085013567ffffffffffffffff8111156106b6576106b561047d565b5b6106c28782880161062e565b92505060606106d387828801610501565b91505092959194509250565b6000819050919050565b60006107046106ff6106fa84610482565b6106df565b610482565b9050919050565b6000610716826106e9565b9050919050565b60006107288261070b565b9050919050565b6107388161071d565b82525050565b610747816104e0565b82525050565b6000604082019050610762600083018561072f565b61076f602083018461073e565b9392505050565b60008115159050919050565b61078b81610776565b811461079657600080fd5b50565b6000815190506107a881610782565b92915050565b6000602082840312156107c4576107c3610478565b5b60006107d284828501610799565b91505092915050565b600082825260208201905092915050565b7f4552432d3230207472616e73666572206661696c656400000000000000000000600082015250565b60006108226016836107db565b915061082d826107ec565b602082019050919050565b6000602082019050818103600083015261085181610815565b9050919050565b600061086382610482565b9050919050565b61087381610858565b82525050565b600081519050919050565b60005b838110156108a2578082015181840152602081019050610887565b60008484015250505050565b60006108b982610879565b6108c381856107db565b93506108d3818560208601610884565b6108dc81610520565b840191505092915050565b60006060820190506108fc600083018661086a565b610909602083018561073e565b818103604083015261091b81846108ae565b9050949350505050565b600081519050610934816104ea565b92915050565b6000602082840312156109505761094f610478565b5b600061095e84828501610925565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e73656e64546f42616e6b20737563636565646564206260008201527f7574207472616e73666572726564207468652077726f6e6720616d6f756e7400602082015250565b60006109ce603f83610967565b91506109d982610972565b603f82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b6000610a1582610879565b610a1f8185610967565b9350610a2f818560208601610884565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b6000610a6c826109c1565b9150610a77826109e4565b600b82019150610a878285610a0a565b9150610a9282610a3b565b600982019150610aa28284610a0a565b91508190509392505050565b60006020820190508181036000830152610ac881846108ae565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea264697066735822122042f899f7461653cf1df35f26f5f40f53e56c43892fd0cebd16ecff8d5f83285464736f6c63430008180033", + "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063264c325814610030575b600080fd5b61004a6004803603810190610045919061065c565b61004c565b005b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85856040518363ffffffff1660e01b81526004016100a792919061074d565b6020604051808303816000875af11580156100c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100ea91906107ae565b610129576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161012090610838565b60405180910390fd5b600061080073ffffffffffffffffffffffffffffffffffffffff1663e77a47bf60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684866040518463ffffffff1660e01b815260040161018a939291906108e7565b6020604051808303816000875af11580156101a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101cd919061093a565b90508181146101db8261024d565b6101e48461024d565b6040516020016101f5929190610a61565b60405160208183030381529060405290610245576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023c9190610aae565b60405180910390fd5b505050505050565b60606000600161025c8461031b565b01905060008167ffffffffffffffff81111561027b5761027a610531565b5b6040519080825280601f01601f1916602001820160405280156102ad5781602001600182028036833780820191505090505b509050600082602001820190505b600115610310578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a858161030457610303610ad0565b5b049450600085036102bb575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310610379577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000838161036f5761036e610ad0565b5b0492506040810190505b6d04ee2d6d415b85acef810000000083106103b6576d04ee2d6d415b85acef810000000083816103ac576103ab610ad0565b5b0492506020810190505b662386f26fc1000083106103e557662386f26fc1000083816103db576103da610ad0565b5b0492506010810190505b6305f5e100831061040e576305f5e100838161040457610403610ad0565b5b0492506008810190505b612710831061043357612710838161042957610428610ad0565b5b0492506004810190505b60648310610456576064838161044c5761044b610ad0565b5b0492506002810190505b600a8310610465576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006104ad82610482565b9050919050565b6104bd816104a2565b81146104c857600080fd5b50565b6000813590506104da816104b4565b92915050565b6000819050919050565b6104f3816104e0565b81146104fe57600080fd5b50565b600081359050610510816104ea565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61056982610520565b810181811067ffffffffffffffff8211171561058857610587610531565b5b80604052505050565b600061059b61046e565b90506105a78282610560565b919050565b600067ffffffffffffffff8211156105c7576105c6610531565b5b6105d082610520565b9050602081019050919050565b82818337600083830152505050565b60006105ff6105fa846105ac565b610591565b90508281526020810184848401111561061b5761061a61051b565b5b6106268482856105dd565b509392505050565b600082601f83011261064357610642610516565b5b81356106538482602086016105ec565b91505092915050565b6000806000806080858703121561067657610675610478565b5b6000610684878288016104cb565b945050602061069587828801610501565b935050604085013567ffffffffffffffff8111156106b6576106b561047d565b5b6106c28782880161062e565b92505060606106d387828801610501565b91505092959194509250565b6000819050919050565b60006107046106ff6106fa84610482565b6106df565b610482565b9050919050565b6000610716826106e9565b9050919050565b60006107288261070b565b9050919050565b6107388161071d565b82525050565b610747816104e0565b82525050565b6000604082019050610762600083018561072f565b61076f602083018461073e565b9392505050565b60008115159050919050565b61078b81610776565b811461079657600080fd5b50565b6000815190506107a881610782565b92915050565b6000602082840312156107c4576107c3610478565b5b60006107d284828501610799565b91505092915050565b600082825260208201905092915050565b7f4552432d3230207472616e73666572206661696c656400000000000000000000600082015250565b60006108226016836107db565b915061082d826107ec565b602082019050919050565b6000602082019050818103600083015261085181610815565b9050919050565b600061086382610482565b9050919050565b61087381610858565b82525050565b600081519050919050565b60005b838110156108a2578082015181840152602081019050610887565b60008484015250505050565b60006108b982610879565b6108c381856107db565b93506108d3818560208601610884565b6108dc81610520565b840191505092915050565b60006060820190506108fc600083018661086a565b610909602083018561073e565b818103604083015261091b81846108ae565b9050949350505050565b600081519050610934816104ea565b92915050565b6000602082840312156109505761094f610478565b5b600061095e84828501610925565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e73656e64546f42616e6b20737563636565646564206260008201527f7574207472616e73666572726564207468652077726f6e6720616d6f756e7400602082015250565b60006109ce603f83610967565b91506109d982610972565b603f82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b6000610a1582610879565b610a1f8185610967565b9350610a2f818560208601610884565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b6000610a6c826109c1565b9150610a77826109e4565b600b82019150610a878285610a0a565b9150610a9282610a3b565b600982019150610aa28284610a0a565b91508190509392505050565b60006020820190508181036000830152610ac881846108ae565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea264697066735822122042f899f7461653cf1df35f26f5f40f53e56c43892fd0cebd16ecff8d5f83285464736f6c63430008180033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/x/evm/embeds/artifacts/contracts/TestFunTokenPrecompileLocalGas.sol/TestFunTokenPrecompileLocalGas.json b/x/evm/embeds/artifacts/contracts/TestFunTokenPrecompileLocalGas.sol/TestFunTokenPrecompileLocalGas.json index 723b779b5..83481bdd5 100644 --- a/x/evm/embeds/artifacts/contracts/TestFunTokenPrecompileLocalGas.sol/TestFunTokenPrecompileLocalGas.json +++ b/x/evm/embeds/artifacts/contracts/TestFunTokenPrecompileLocalGas.sol/TestFunTokenPrecompileLocalGas.json @@ -56,8 +56,8 @@ "type": "function" } ], - "bytecode": "0x608060405234801561001057600080fd5b50604051610b6a380380610b6a833981810160405281019061003291906100db565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b6100b88161009d565b81146100c357600080fd5b50565b6000815190506100d5816100af565b92915050565b6000602082840312156100f1576100f0610078565b5b60006100ff848285016100c6565b91505092915050565b610a53806101176000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806359b6ed891461003b57806390d2b5e714610057575b600080fd5b6100556004803603810190610050919061066b565b610073565b005b610071600480360381019061006c91906106da565b610198565b005b600061080073ffffffffffffffffffffffffffffffffffffffff166303003bc58360008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1687876040518563ffffffff1660e01b81526004016100d593929190610805565b60206040518083038160008887f11580156100f4573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906101199190610858565b9050838114610127826102ba565b610130866102ba565b60405160200161014192919061097f565b60405160208183030381529060405290610191576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161018891906109cc565b60405180910390fd5b5050505050565b600061080073ffffffffffffffffffffffffffffffffffffffff166303003bc560008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1685856040518463ffffffff1660e01b81526004016101f993929190610805565b6020604051808303816000875af1158015610218573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061023c9190610858565b905082811461024a826102ba565b610253856102ba565b60405160200161026492919061097f565b604051602081830303815290604052906102b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102ab91906109cc565b60405180910390fd5b50505050565b6060600060016102c984610388565b01905060008167ffffffffffffffff8111156102e8576102e7610540565b5b6040519080825280601f01601f19166020018201604052801561031a5781602001600182028036833780820191505090505b509050600082602001820190505b60011561037d578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8581610371576103706109ee565b5b04945060008503610328575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106103e6577a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083816103dc576103db6109ee565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310610423576d04ee2d6d415b85acef81000000008381610419576104186109ee565b5b0492506020810190505b662386f26fc10000831061045257662386f26fc100008381610448576104476109ee565b5b0492506010810190505b6305f5e100831061047b576305f5e1008381610471576104706109ee565b5b0492506008810190505b61271083106104a0576127108381610496576104956109ee565b5b0492506004810190505b606483106104c357606483816104b9576104b86109ee565b5b0492506002810190505b600a83106104d2576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b610502816104ef565b811461050d57600080fd5b50565b60008135905061051f816104f9565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6105788261052f565b810181811067ffffffffffffffff8211171561059757610596610540565b5b80604052505050565b60006105aa6104db565b90506105b6828261056f565b919050565b600067ffffffffffffffff8211156105d6576105d5610540565b5b6105df8261052f565b9050602081019050919050565b82818337600083830152505050565b600061060e610609846105bb565b6105a0565b90508281526020810184848401111561062a5761062961052a565b5b6106358482856105ec565b509392505050565b600082601f83011261065257610651610525565b5b81356106628482602086016105fb565b91505092915050565b600080600060608486031215610684576106836104e5565b5b600061069286828701610510565b935050602084013567ffffffffffffffff8111156106b3576106b26104ea565b5b6106bf8682870161063d565b92505060406106d086828701610510565b9150509250925092565b600080604083850312156106f1576106f06104e5565b5b60006106ff85828601610510565b925050602083013567ffffffffffffffff8111156107205761071f6104ea565b5b61072c8582860161063d565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061076182610736565b9050919050565b61077181610756565b82525050565b610780816104ef565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b838110156107c05780820151818401526020810190506107a5565b60008484015250505050565b60006107d782610786565b6107e18185610791565b93506107f18185602086016107a2565b6107fa8161052f565b840191505092915050565b600060608201905061081a6000830186610768565b6108276020830185610777565b818103604083015261083981846107cc565b9050949350505050565b600081519050610852816104f9565b92915050565b60006020828403121561086e5761086d6104e5565b5b600061087c84828501610843565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e62616e6b53656e64207375636365656465642062757460008201527f207472616e73666572726564207468652077726f6e6720616d6f756e74000000602082015250565b60006108ec603d83610885565b91506108f782610890565b603d82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b600061093382610786565b61093d8185610885565b935061094d8185602086016107a2565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b600061098a826108df565b915061099582610902565b600b820191506109a58285610928565b91506109b082610959565b6009820191506109c08284610928565b91508190509392505050565b600060208201905081810360008301526109e681846107cc565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea26469706673582212203b80aa046928bf6b13cd29898611f9a4f048688dc21bfd44094fd59d8080e66064736f6c63430008180033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c806359b6ed891461003b57806390d2b5e714610057575b600080fd5b6100556004803603810190610050919061066b565b610073565b005b610071600480360381019061006c91906106da565b610198565b005b600061080073ffffffffffffffffffffffffffffffffffffffff166303003bc58360008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1687876040518563ffffffff1660e01b81526004016100d593929190610805565b60206040518083038160008887f11580156100f4573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906101199190610858565b9050838114610127826102ba565b610130866102ba565b60405160200161014192919061097f565b60405160208183030381529060405290610191576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161018891906109cc565b60405180910390fd5b5050505050565b600061080073ffffffffffffffffffffffffffffffffffffffff166303003bc560008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1685856040518463ffffffff1660e01b81526004016101f993929190610805565b6020604051808303816000875af1158015610218573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061023c9190610858565b905082811461024a826102ba565b610253856102ba565b60405160200161026492919061097f565b604051602081830303815290604052906102b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102ab91906109cc565b60405180910390fd5b50505050565b6060600060016102c984610388565b01905060008167ffffffffffffffff8111156102e8576102e7610540565b5b6040519080825280601f01601f19166020018201604052801561031a5781602001600182028036833780820191505090505b509050600082602001820190505b60011561037d578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8581610371576103706109ee565b5b04945060008503610328575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106103e6577a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083816103dc576103db6109ee565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310610423576d04ee2d6d415b85acef81000000008381610419576104186109ee565b5b0492506020810190505b662386f26fc10000831061045257662386f26fc100008381610448576104476109ee565b5b0492506010810190505b6305f5e100831061047b576305f5e1008381610471576104706109ee565b5b0492506008810190505b61271083106104a0576127108381610496576104956109ee565b5b0492506004810190505b606483106104c357606483816104b9576104b86109ee565b5b0492506002810190505b600a83106104d2576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b610502816104ef565b811461050d57600080fd5b50565b60008135905061051f816104f9565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6105788261052f565b810181811067ffffffffffffffff8211171561059757610596610540565b5b80604052505050565b60006105aa6104db565b90506105b6828261056f565b919050565b600067ffffffffffffffff8211156105d6576105d5610540565b5b6105df8261052f565b9050602081019050919050565b82818337600083830152505050565b600061060e610609846105bb565b6105a0565b90508281526020810184848401111561062a5761062961052a565b5b6106358482856105ec565b509392505050565b600082601f83011261065257610651610525565b5b81356106628482602086016105fb565b91505092915050565b600080600060608486031215610684576106836104e5565b5b600061069286828701610510565b935050602084013567ffffffffffffffff8111156106b3576106b26104ea565b5b6106bf8682870161063d565b92505060406106d086828701610510565b9150509250925092565b600080604083850312156106f1576106f06104e5565b5b60006106ff85828601610510565b925050602083013567ffffffffffffffff8111156107205761071f6104ea565b5b61072c8582860161063d565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061076182610736565b9050919050565b61077181610756565b82525050565b610780816104ef565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b838110156107c05780820151818401526020810190506107a5565b60008484015250505050565b60006107d782610786565b6107e18185610791565b93506107f18185602086016107a2565b6107fa8161052f565b840191505092915050565b600060608201905061081a6000830186610768565b6108276020830185610777565b818103604083015261083981846107cc565b9050949350505050565b600081519050610852816104f9565b92915050565b60006020828403121561086e5761086d6104e5565b5b600061087c84828501610843565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e62616e6b53656e64207375636365656465642062757460008201527f207472616e73666572726564207468652077726f6e6720616d6f756e74000000602082015250565b60006108ec603d83610885565b91506108f782610890565b603d82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b600061093382610786565b61093d8185610885565b935061094d8185602086016107a2565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b600061098a826108df565b915061099582610902565b600b820191506109a58285610928565b91506109b082610959565b6009820191506109c08284610928565b91508190509392505050565b600060208201905081810360008301526109e681846107cc565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea26469706673582212203b80aa046928bf6b13cd29898611f9a4f048688dc21bfd44094fd59d8080e66064736f6c63430008180033", + "bytecode": "0x608060405234801561001057600080fd5b50604051610b6a380380610b6a833981810160405281019061003291906100db565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b6100b88161009d565b81146100c357600080fd5b50565b6000815190506100d5816100af565b92915050565b6000602082840312156100f1576100f0610078565b5b60006100ff848285016100c6565b91505092915050565b610a53806101176000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806359b6ed891461003b57806390d2b5e714610057575b600080fd5b6100556004803603810190610050919061066b565b610073565b005b610071600480360381019061006c91906106da565b610198565b005b600061080073ffffffffffffffffffffffffffffffffffffffff1663e77a47bf8360008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1687876040518563ffffffff1660e01b81526004016100d593929190610805565b60206040518083038160008887f11580156100f4573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906101199190610858565b9050838114610127826102ba565b610130866102ba565b60405160200161014192919061097f565b60405160208183030381529060405290610191576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161018891906109cc565b60405180910390fd5b5050505050565b600061080073ffffffffffffffffffffffffffffffffffffffff1663e77a47bf60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1685856040518463ffffffff1660e01b81526004016101f993929190610805565b6020604051808303816000875af1158015610218573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061023c9190610858565b905082811461024a826102ba565b610253856102ba565b60405160200161026492919061097f565b604051602081830303815290604052906102b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102ab91906109cc565b60405180910390fd5b50505050565b6060600060016102c984610388565b01905060008167ffffffffffffffff8111156102e8576102e7610540565b5b6040519080825280601f01601f19166020018201604052801561031a5781602001600182028036833780820191505090505b509050600082602001820190505b60011561037d578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8581610371576103706109ee565b5b04945060008503610328575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106103e6577a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083816103dc576103db6109ee565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310610423576d04ee2d6d415b85acef81000000008381610419576104186109ee565b5b0492506020810190505b662386f26fc10000831061045257662386f26fc100008381610448576104476109ee565b5b0492506010810190505b6305f5e100831061047b576305f5e1008381610471576104706109ee565b5b0492506008810190505b61271083106104a0576127108381610496576104956109ee565b5b0492506004810190505b606483106104c357606483816104b9576104b86109ee565b5b0492506002810190505b600a83106104d2576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b610502816104ef565b811461050d57600080fd5b50565b60008135905061051f816104f9565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6105788261052f565b810181811067ffffffffffffffff8211171561059757610596610540565b5b80604052505050565b60006105aa6104db565b90506105b6828261056f565b919050565b600067ffffffffffffffff8211156105d6576105d5610540565b5b6105df8261052f565b9050602081019050919050565b82818337600083830152505050565b600061060e610609846105bb565b6105a0565b90508281526020810184848401111561062a5761062961052a565b5b6106358482856105ec565b509392505050565b600082601f83011261065257610651610525565b5b81356106628482602086016105fb565b91505092915050565b600080600060608486031215610684576106836104e5565b5b600061069286828701610510565b935050602084013567ffffffffffffffff8111156106b3576106b26104ea565b5b6106bf8682870161063d565b92505060406106d086828701610510565b9150509250925092565b600080604083850312156106f1576106f06104e5565b5b60006106ff85828601610510565b925050602083013567ffffffffffffffff8111156107205761071f6104ea565b5b61072c8582860161063d565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061076182610736565b9050919050565b61077181610756565b82525050565b610780816104ef565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b838110156107c05780820151818401526020810190506107a5565b60008484015250505050565b60006107d782610786565b6107e18185610791565b93506107f18185602086016107a2565b6107fa8161052f565b840191505092915050565b600060608201905061081a6000830186610768565b6108276020830185610777565b818103604083015261083981846107cc565b9050949350505050565b600081519050610852816104f9565b92915050565b60006020828403121561086e5761086d6104e5565b5b600061087c84828501610843565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e73656e64546f42616e6b20737563636565646564206260008201527f7574207472616e73666572726564207468652077726f6e6720616d6f756e7400602082015250565b60006108ec603f83610885565b91506108f782610890565b603f82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b600061093382610786565b61093d8185610885565b935061094d8185602086016107a2565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b600061098a826108df565b915061099582610902565b600b820191506109a58285610928565b91506109b082610959565b6009820191506109c08284610928565b91508190509392505050565b600060208201905081810360008301526109e681846107cc565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea2646970667358221220518cb8e0a44ff5f83545c95e1dbc30a25da8ee95d0d23b6fac02d6a4c47c4c5164736f6c63430008180033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c806359b6ed891461003b57806390d2b5e714610057575b600080fd5b6100556004803603810190610050919061066b565b610073565b005b610071600480360381019061006c91906106da565b610198565b005b600061080073ffffffffffffffffffffffffffffffffffffffff1663e77a47bf8360008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1687876040518563ffffffff1660e01b81526004016100d593929190610805565b60206040518083038160008887f11580156100f4573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906101199190610858565b9050838114610127826102ba565b610130866102ba565b60405160200161014192919061097f565b60405160208183030381529060405290610191576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161018891906109cc565b60405180910390fd5b5050505050565b600061080073ffffffffffffffffffffffffffffffffffffffff1663e77a47bf60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1685856040518463ffffffff1660e01b81526004016101f993929190610805565b6020604051808303816000875af1158015610218573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061023c9190610858565b905082811461024a826102ba565b610253856102ba565b60405160200161026492919061097f565b604051602081830303815290604052906102b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102ab91906109cc565b60405180910390fd5b50505050565b6060600060016102c984610388565b01905060008167ffffffffffffffff8111156102e8576102e7610540565b5b6040519080825280601f01601f19166020018201604052801561031a5781602001600182028036833780820191505090505b509050600082602001820190505b60011561037d578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8581610371576103706109ee565b5b04945060008503610328575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106103e6577a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083816103dc576103db6109ee565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310610423576d04ee2d6d415b85acef81000000008381610419576104186109ee565b5b0492506020810190505b662386f26fc10000831061045257662386f26fc100008381610448576104476109ee565b5b0492506010810190505b6305f5e100831061047b576305f5e1008381610471576104706109ee565b5b0492506008810190505b61271083106104a0576127108381610496576104956109ee565b5b0492506004810190505b606483106104c357606483816104b9576104b86109ee565b5b0492506002810190505b600a83106104d2576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b610502816104ef565b811461050d57600080fd5b50565b60008135905061051f816104f9565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6105788261052f565b810181811067ffffffffffffffff8211171561059757610596610540565b5b80604052505050565b60006105aa6104db565b90506105b6828261056f565b919050565b600067ffffffffffffffff8211156105d6576105d5610540565b5b6105df8261052f565b9050602081019050919050565b82818337600083830152505050565b600061060e610609846105bb565b6105a0565b90508281526020810184848401111561062a5761062961052a565b5b6106358482856105ec565b509392505050565b600082601f83011261065257610651610525565b5b81356106628482602086016105fb565b91505092915050565b600080600060608486031215610684576106836104e5565b5b600061069286828701610510565b935050602084013567ffffffffffffffff8111156106b3576106b26104ea565b5b6106bf8682870161063d565b92505060406106d086828701610510565b9150509250925092565b600080604083850312156106f1576106f06104e5565b5b60006106ff85828601610510565b925050602083013567ffffffffffffffff8111156107205761071f6104ea565b5b61072c8582860161063d565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061076182610736565b9050919050565b61077181610756565b82525050565b610780816104ef565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b838110156107c05780820151818401526020810190506107a5565b60008484015250505050565b60006107d782610786565b6107e18185610791565b93506107f18185602086016107a2565b6107fa8161052f565b840191505092915050565b600060608201905061081a6000830186610768565b6108276020830185610777565b818103604083015261083981846107cc565b9050949350505050565b600081519050610852816104f9565b92915050565b60006020828403121561086e5761086d6104e5565b5b600061087c84828501610843565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e73656e64546f42616e6b20737563636565646564206260008201527f7574207472616e73666572726564207468652077726f6e6720616d6f756e7400602082015250565b60006108ec603f83610885565b91506108f782610890565b603f82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b600061093382610786565b61093d8185610885565b935061094d8185602086016107a2565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b600061098a826108df565b915061099582610902565b600b820191506109a58285610928565b91506109b082610959565b6009820191506109c08284610928565b91508190509392505050565b600060208201905081810360008301526109e681846107cc565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea2646970667358221220518cb8e0a44ff5f83545c95e1dbc30a25da8ee95d0d23b6fac02d6a4c47c4c5164736f6c63430008180033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/x/evm/embeds/artifacts/contracts/TestNativeSendThenPrecompileSend.sol/TestNativeSendThenPrecompileSend.json b/x/evm/embeds/artifacts/contracts/TestNativeSendThenPrecompileSend.sol/TestNativeSendThenPrecompileSend.json index e4a2ccfb1..60af0f4ee 100644 --- a/x/evm/embeds/artifacts/contracts/TestNativeSendThenPrecompileSend.sol/TestNativeSendThenPrecompileSend.json +++ b/x/evm/embeds/artifacts/contracts/TestNativeSendThenPrecompileSend.sol/TestNativeSendThenPrecompileSend.json @@ -14,6 +14,24 @@ "stateMutability": "nonpayable", "type": "constructor" }, + { + "inputs": [ + { + "internalType": "string", + "name": "precompileRecipient", + "type": "string" + }, + { + "internalType": "uint256", + "name": "precompileAmount", + "type": "uint256" + } + ], + "name": "justPrecompileSend", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, { "inputs": [ { @@ -43,8 +61,8 @@ "type": "function" } ], - "bytecode": "0x608060405234801561001057600080fd5b50604051610afc380380610afc833981810160405281019061003291906100db565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b6100b88161009d565b81146100c357600080fd5b50565b6000815190506100d5816100af565b92915050565b6000602082840312156100f1576100f0610078565b5b60006100ff848285016100c6565b91505092915050565b6109e5806101176000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063a4de557414610030575b600080fd5b61004a600480360381019061004591906105f9565b61004c565b005b60008473ffffffffffffffffffffffffffffffffffffffff166108fc859081150290604051600060405180830381858888f193505050509050806100c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bc906106d9565b60405180910390fd5b600061080073ffffffffffffffffffffffffffffffffffffffff166303003bc560008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1685876040518463ffffffff1660e01b815260040161012693929190610797565b6020604051808303816000875af1158015610145573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061016991906107ea565b9050828114610177826101ea565b610180856101ea565b604051602001610191929190610911565b604051602081830303815290604052906101e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101d8919061095e565b60405180910390fd5b50505050505050565b6060600060016101f9846102b8565b01905060008167ffffffffffffffff811115610218576102176104ce565b5b6040519080825280601f01601f19166020018201604052801561024a5781602001600182028036833780820191505090505b509050600082602001820190505b6001156102ad578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a85816102a1576102a0610980565b5b04945060008503610258575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310610316577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000838161030c5761030b610980565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310610353576d04ee2d6d415b85acef8100000000838161034957610348610980565b5b0492506020810190505b662386f26fc10000831061038257662386f26fc10000838161037857610377610980565b5b0492506010810190505b6305f5e10083106103ab576305f5e10083816103a1576103a0610980565b5b0492506008810190505b61271083106103d05761271083816103c6576103c5610980565b5b0492506004810190505b606483106103f357606483816103e9576103e8610980565b5b0492506002810190505b600a8310610402576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061044a8261041f565b9050919050565b61045a8161043f565b811461046557600080fd5b50565b60008135905061047781610451565b92915050565b6000819050919050565b6104908161047d565b811461049b57600080fd5b50565b6000813590506104ad81610487565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610506826104bd565b810181811067ffffffffffffffff82111715610525576105246104ce565b5b80604052505050565b600061053861040b565b905061054482826104fd565b919050565b600067ffffffffffffffff821115610564576105636104ce565b5b61056d826104bd565b9050602081019050919050565b82818337600083830152505050565b600061059c61059784610549565b61052e565b9050828152602081018484840111156105b8576105b76104b8565b5b6105c384828561057a565b509392505050565b600082601f8301126105e0576105df6104b3565b5b81356105f0848260208601610589565b91505092915050565b6000806000806080858703121561061357610612610415565b5b600061062187828801610468565b94505060206106328782880161049e565b935050604085013567ffffffffffffffff8111156106535761065261041a565b5b61065f878288016105cb565b92505060606106708782880161049e565b91505092959194509250565b600082825260208201905092915050565b7f4661696c656420746f2073656e64206e617469766520746f6b656e0000000000600082015250565b60006106c3601b8361067c565b91506106ce8261068d565b602082019050919050565b600060208201905081810360008301526106f2816106b6565b9050919050565b60006107048261041f565b9050919050565b610714816106f9565b82525050565b6107238161047d565b82525050565b600081519050919050565b60005b83811015610752578082015181840152602081019050610737565b60008484015250505050565b600061076982610729565b610773818561067c565b9350610783818560208601610734565b61078c816104bd565b840191505092915050565b60006060820190506107ac600083018661070b565b6107b9602083018561071a565b81810360408301526107cb818461075e565b9050949350505050565b6000815190506107e481610487565b92915050565b600060208284031215610800576107ff610415565b5b600061080e848285016107d5565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e62616e6b53656e64207375636365656465642062757460008201527f207472616e73666572726564207468652077726f6e6720616d6f756e74000000602082015250565b600061087e603d83610817565b915061088982610822565b603d82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b60006108c582610729565b6108cf8185610817565b93506108df818560208601610734565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b600061091c82610871565b915061092782610894565b600b8201915061093782856108ba565b9150610942826108eb565b60098201915061095282846108ba565b91508190509392505050565b60006020820190508181036000830152610978818461075e565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea2646970667358221220df7092cb424bd549df3b9d958db66a63c029a1e42d78f468fb93c7574ccea23864736f6c63430008180033", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063a4de557414610030575b600080fd5b61004a600480360381019061004591906105f9565b61004c565b005b60008473ffffffffffffffffffffffffffffffffffffffff166108fc859081150290604051600060405180830381858888f193505050509050806100c5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100bc906106d9565b60405180910390fd5b600061080073ffffffffffffffffffffffffffffffffffffffff166303003bc560008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1685876040518463ffffffff1660e01b815260040161012693929190610797565b6020604051808303816000875af1158015610145573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061016991906107ea565b9050828114610177826101ea565b610180856101ea565b604051602001610191929190610911565b604051602081830303815290604052906101e1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101d8919061095e565b60405180910390fd5b50505050505050565b6060600060016101f9846102b8565b01905060008167ffffffffffffffff811115610218576102176104ce565b5b6040519080825280601f01601f19166020018201604052801561024a5781602001600182028036833780820191505090505b509050600082602001820190505b6001156102ad578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a85816102a1576102a0610980565b5b04945060008503610258575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310610316577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000838161030c5761030b610980565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310610353576d04ee2d6d415b85acef8100000000838161034957610348610980565b5b0492506020810190505b662386f26fc10000831061038257662386f26fc10000838161037857610377610980565b5b0492506010810190505b6305f5e10083106103ab576305f5e10083816103a1576103a0610980565b5b0492506008810190505b61271083106103d05761271083816103c6576103c5610980565b5b0492506004810190505b606483106103f357606483816103e9576103e8610980565b5b0492506002810190505b600a8310610402576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061044a8261041f565b9050919050565b61045a8161043f565b811461046557600080fd5b50565b60008135905061047781610451565b92915050565b6000819050919050565b6104908161047d565b811461049b57600080fd5b50565b6000813590506104ad81610487565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b610506826104bd565b810181811067ffffffffffffffff82111715610525576105246104ce565b5b80604052505050565b600061053861040b565b905061054482826104fd565b919050565b600067ffffffffffffffff821115610564576105636104ce565b5b61056d826104bd565b9050602081019050919050565b82818337600083830152505050565b600061059c61059784610549565b61052e565b9050828152602081018484840111156105b8576105b76104b8565b5b6105c384828561057a565b509392505050565b600082601f8301126105e0576105df6104b3565b5b81356105f0848260208601610589565b91505092915050565b6000806000806080858703121561061357610612610415565b5b600061062187828801610468565b94505060206106328782880161049e565b935050604085013567ffffffffffffffff8111156106535761065261041a565b5b61065f878288016105cb565b92505060606106708782880161049e565b91505092959194509250565b600082825260208201905092915050565b7f4661696c656420746f2073656e64206e617469766520746f6b656e0000000000600082015250565b60006106c3601b8361067c565b91506106ce8261068d565b602082019050919050565b600060208201905081810360008301526106f2816106b6565b9050919050565b60006107048261041f565b9050919050565b610714816106f9565b82525050565b6107238161047d565b82525050565b600081519050919050565b60005b83811015610752578082015181840152602081019050610737565b60008484015250505050565b600061076982610729565b610773818561067c565b9350610783818560208601610734565b61078c816104bd565b840191505092915050565b60006060820190506107ac600083018661070b565b6107b9602083018561071a565b81810360408301526107cb818461075e565b9050949350505050565b6000815190506107e481610487565b92915050565b600060208284031215610800576107ff610415565b5b600061080e848285016107d5565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e62616e6b53656e64207375636365656465642062757460008201527f207472616e73666572726564207468652077726f6e6720616d6f756e74000000602082015250565b600061087e603d83610817565b915061088982610822565b603d82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b60006108c582610729565b6108cf8185610817565b93506108df818560208601610734565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b600061091c82610871565b915061092782610894565b600b8201915061093782856108ba565b9150610942826108eb565b60098201915061095282846108ba565b91508190509392505050565b60006020820190508181036000830152610978818461075e565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea2646970667358221220df7092cb424bd549df3b9d958db66a63c029a1e42d78f468fb93c7574ccea23864736f6c63430008180033", + "bytecode": "0x608060405234801561001057600080fd5b50604051610ca1380380610ca1833981810160405281019061003291906100db565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610108565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a88261007d565b9050919050565b6100b88161009d565b81146100c357600080fd5b50565b6000815190506100d5816100af565b92915050565b6000602082840312156100f1576100f0610078565b5b60006100ff848285016100c6565b91505092915050565b610b8a806101176000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80630a04fd4d1461003b578063a4de557414610057575b600080fd5b610055600480360381019061005091906106e4565b610073565b005b610071600480360381019061006c919061079e565b610195565b005b600061080073ffffffffffffffffffffffffffffffffffffffff1663e77a47bf60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684866040518463ffffffff1660e01b81526004016100d4939291906108d0565b6020604051808303816000875af11580156100f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101179190610923565b905081811461012582610333565b61012e84610333565b60405160200161013f929190610a4a565b6040516020818303038152906040529061018f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101869190610a97565b60405180910390fd5b50505050565b60008473ffffffffffffffffffffffffffffffffffffffff166108fc859081150290604051600060405180830381858888f1935050505090508061020e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161020590610b05565b60405180910390fd5b600061080073ffffffffffffffffffffffffffffffffffffffff1663e77a47bf60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1685876040518463ffffffff1660e01b815260040161026f939291906108d0565b6020604051808303816000875af115801561028e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102b29190610923565b90508281146102c082610333565b6102c985610333565b6040516020016102da929190610a4a565b6040516020818303038152906040529061032a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103219190610a97565b60405180910390fd5b50505050505050565b60606000600161034284610401565b01905060008167ffffffffffffffff81111561036157610360610583565b5b6040519080825280601f01601f1916602001820160405280156103935781602001600182028036833780820191505090505b509050600082602001820190505b6001156103f6578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a85816103ea576103e9610b25565b5b049450600085036103a1575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000831061045f577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000838161045557610454610b25565b5b0492506040810190505b6d04ee2d6d415b85acef8100000000831061049c576d04ee2d6d415b85acef8100000000838161049257610491610b25565b5b0492506020810190505b662386f26fc1000083106104cb57662386f26fc1000083816104c1576104c0610b25565b5b0492506010810190505b6305f5e10083106104f4576305f5e10083816104ea576104e9610b25565b5b0492506008810190505b612710831061051957612710838161050f5761050e610b25565b5b0492506004810190505b6064831061053c576064838161053257610531610b25565b5b0492506002810190505b600a831061054b576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6105bb82610572565b810181811067ffffffffffffffff821117156105da576105d9610583565b5b80604052505050565b60006105ed610554565b90506105f982826105b2565b919050565b600067ffffffffffffffff82111561061957610618610583565b5b61062282610572565b9050602081019050919050565b82818337600083830152505050565b600061065161064c846105fe565b6105e3565b90508281526020810184848401111561066d5761066c61056d565b5b61067884828561062f565b509392505050565b600082601f83011261069557610694610568565b5b81356106a584826020860161063e565b91505092915050565b6000819050919050565b6106c1816106ae565b81146106cc57600080fd5b50565b6000813590506106de816106b8565b92915050565b600080604083850312156106fb576106fa61055e565b5b600083013567ffffffffffffffff81111561071957610718610563565b5b61072585828601610680565b9250506020610736858286016106cf565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061076b82610740565b9050919050565b61077b81610760565b811461078657600080fd5b50565b60008135905061079881610772565b92915050565b600080600080608085870312156107b8576107b761055e565b5b60006107c687828801610789565b94505060206107d7878288016106cf565b935050604085013567ffffffffffffffff8111156107f8576107f7610563565b5b61080487828801610680565b9250506060610815878288016106cf565b91505092959194509250565b600061082c82610740565b9050919050565b61083c81610821565b82525050565b61084b816106ae565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561088b578082015181840152602081019050610870565b60008484015250505050565b60006108a282610851565b6108ac818561085c565b93506108bc81856020860161086d565b6108c581610572565b840191505092915050565b60006060820190506108e56000830186610833565b6108f26020830185610842565b81810360408301526109048184610897565b9050949350505050565b60008151905061091d816106b8565b92915050565b6000602082840312156109395761093861055e565b5b60006109478482850161090e565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e73656e64546f42616e6b20737563636565646564206260008201527f7574207472616e73666572726564207468652077726f6e6720616d6f756e7400602082015250565b60006109b7603f83610950565b91506109c28261095b565b603f82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b60006109fe82610851565b610a088185610950565b9350610a1881856020860161086d565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b6000610a55826109aa565b9150610a60826109cd565b600b82019150610a7082856109f3565b9150610a7b82610a24565b600982019150610a8b82846109f3565b91508190509392505050565b60006020820190508181036000830152610ab18184610897565b905092915050565b7f4661696c656420746f2073656e64206e617469766520746f6b656e0000000000600082015250565b6000610aef601b8361085c565b9150610afa82610ab9565b602082019050919050565b60006020820190508181036000830152610b1e81610ae2565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea26469706673582212200d00fcf0f8c292ec663c93dd26e426953911b9d9cfb7f41829934866e308cbde64736f6c63430008180033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80630a04fd4d1461003b578063a4de557414610057575b600080fd5b610055600480360381019061005091906106e4565b610073565b005b610071600480360381019061006c919061079e565b610195565b005b600061080073ffffffffffffffffffffffffffffffffffffffff1663e77a47bf60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684866040518463ffffffff1660e01b81526004016100d4939291906108d0565b6020604051808303816000875af11580156100f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101179190610923565b905081811461012582610333565b61012e84610333565b60405160200161013f929190610a4a565b6040516020818303038152906040529061018f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101869190610a97565b60405180910390fd5b50505050565b60008473ffffffffffffffffffffffffffffffffffffffff166108fc859081150290604051600060405180830381858888f1935050505090508061020e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161020590610b05565b60405180910390fd5b600061080073ffffffffffffffffffffffffffffffffffffffff1663e77a47bf60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1685876040518463ffffffff1660e01b815260040161026f939291906108d0565b6020604051808303816000875af115801561028e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102b29190610923565b90508281146102c082610333565b6102c985610333565b6040516020016102da929190610a4a565b6040516020818303038152906040529061032a576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103219190610a97565b60405180910390fd5b50505050505050565b60606000600161034284610401565b01905060008167ffffffffffffffff81111561036157610360610583565b5b6040519080825280601f01601f1916602001820160405280156103935781602001600182028036833780820191505090505b509050600082602001820190505b6001156103f6578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a85816103ea576103e9610b25565b5b049450600085036103a1575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000831061045f577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000838161045557610454610b25565b5b0492506040810190505b6d04ee2d6d415b85acef8100000000831061049c576d04ee2d6d415b85acef8100000000838161049257610491610b25565b5b0492506020810190505b662386f26fc1000083106104cb57662386f26fc1000083816104c1576104c0610b25565b5b0492506010810190505b6305f5e10083106104f4576305f5e10083816104ea576104e9610b25565b5b0492506008810190505b612710831061051957612710838161050f5761050e610b25565b5b0492506004810190505b6064831061053c576064838161053257610531610b25565b5b0492506002810190505b600a831061054b576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6105bb82610572565b810181811067ffffffffffffffff821117156105da576105d9610583565b5b80604052505050565b60006105ed610554565b90506105f982826105b2565b919050565b600067ffffffffffffffff82111561061957610618610583565b5b61062282610572565b9050602081019050919050565b82818337600083830152505050565b600061065161064c846105fe565b6105e3565b90508281526020810184848401111561066d5761066c61056d565b5b61067884828561062f565b509392505050565b600082601f83011261069557610694610568565b5b81356106a584826020860161063e565b91505092915050565b6000819050919050565b6106c1816106ae565b81146106cc57600080fd5b50565b6000813590506106de816106b8565b92915050565b600080604083850312156106fb576106fa61055e565b5b600083013567ffffffffffffffff81111561071957610718610563565b5b61072585828601610680565b9250506020610736858286016106cf565b9150509250929050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061076b82610740565b9050919050565b61077b81610760565b811461078657600080fd5b50565b60008135905061079881610772565b92915050565b600080600080608085870312156107b8576107b761055e565b5b60006107c687828801610789565b94505060206107d7878288016106cf565b935050604085013567ffffffffffffffff8111156107f8576107f7610563565b5b61080487828801610680565b9250506060610815878288016106cf565b91505092959194509250565b600061082c82610740565b9050919050565b61083c81610821565b82525050565b61084b816106ae565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b8381101561088b578082015181840152602081019050610870565b60008484015250505050565b60006108a282610851565b6108ac818561085c565b93506108bc81856020860161086d565b6108c581610572565b840191505092915050565b60006060820190506108e56000830186610833565b6108f26020830185610842565b81810360408301526109048184610897565b9050949350505050565b60008151905061091d816106b8565b92915050565b6000602082840312156109395761093861055e565b5b60006109478482850161090e565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e73656e64546f42616e6b20737563636565646564206260008201527f7574207472616e73666572726564207468652077726f6e6720616d6f756e7400602082015250565b60006109b7603f83610950565b91506109c28261095b565b603f82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b60006109fe82610851565b610a088185610950565b9350610a1881856020860161086d565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b6000610a55826109aa565b9150610a60826109cd565b600b82019150610a7082856109f3565b9150610a7b82610a24565b600982019150610a8b82846109f3565b91508190509392505050565b60006020820190508181036000830152610ab18184610897565b905092915050565b7f4661696c656420746f2073656e64206e617469766520746f6b656e0000000000600082015250565b6000610aef601b8361085c565b9150610afa82610ab9565b602082019050919050565b60006020820190508181036000830152610b1e81610ae2565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea26469706673582212200d00fcf0f8c292ec663c93dd26e426953911b9d9cfb7f41829934866e308cbde64736f6c63430008180033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/x/evm/embeds/artifacts/contracts/TestPrecompileSelfCallRevert.sol/TestPrecompileSelfCallRevert.json b/x/evm/embeds/artifacts/contracts/TestPrecompileSelfCallRevert.sol/TestPrecompileSelfCallRevert.json index c56dfefac..9f6f671d8 100644 --- a/x/evm/embeds/artifacts/contracts/TestPrecompileSelfCallRevert.sol/TestPrecompileSelfCallRevert.json +++ b/x/evm/embeds/artifacts/contracts/TestPrecompileSelfCallRevert.sol/TestPrecompileSelfCallRevert.json @@ -71,8 +71,8 @@ "type": "function" } ], - "bytecode": "0x60806040526000600155604051610c8e380380610c8e833981810160405281019061002a91906100d3565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610100565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a082610075565b9050919050565b6100b081610095565b81146100bb57600080fd5b50565b6000815190506100cd816100a7565b92915050565b6000602082840312156100e9576100e8610070565b5b60006100f7848285016100be565b91505092915050565b610b7f8061010f6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80636ad4fe961461003b578063705964db14610057575b600080fd5b610055600480360381019061005091906106c1565b610073565b005b610071600480360381019061006c91906106c1565b610208565b005b8373ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f193505050506100e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100de906107a1565b60405180910390fd5b600061080073ffffffffffffffffffffffffffffffffffffffff166303003bc560008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684866040518463ffffffff1660e01b81526004016101489392919061085f565b6020604051808303816000875af1158015610167573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061018b91906108b2565b9050818114610199856102b2565b6101a2846102b2565b6040516020016101b39291906109d9565b60405160208183030381529060405290610203576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101fa9190610a26565b60405180910390fd5b600080fd5b6001600081548092919061021b90610a77565b91905055503073ffffffffffffffffffffffffffffffffffffffff16636ad4fe96858585856040518563ffffffff1660e01b815260040161025f9493929190610ace565b600060405180830381600087803b15801561027957600080fd5b505af192505050801561028a575060015b6102ab57600160008154809291906102a190610a77565b91905055506102ac565b5b50505050565b6060600060016102c184610380565b01905060008167ffffffffffffffff8111156102e0576102df610596565b5b6040519080825280601f01601f1916602001820160405280156103125781602001600182028036833780820191505090505b509050600082602001820190505b600115610375578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a858161036957610368610b1a565b5b04945060008503610320575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106103de577a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083816103d4576103d3610b1a565b5b0492506040810190505b6d04ee2d6d415b85acef8100000000831061041b576d04ee2d6d415b85acef8100000000838161041157610410610b1a565b5b0492506020810190505b662386f26fc10000831061044a57662386f26fc1000083816104405761043f610b1a565b5b0492506010810190505b6305f5e1008310610473576305f5e100838161046957610468610b1a565b5b0492506008810190505b612710831061049857612710838161048e5761048d610b1a565b5b0492506004810190505b606483106104bb57606483816104b1576104b0610b1a565b5b0492506002810190505b600a83106104ca576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610512826104e7565b9050919050565b61052281610507565b811461052d57600080fd5b50565b60008135905061053f81610519565b92915050565b6000819050919050565b61055881610545565b811461056357600080fd5b50565b6000813590506105758161054f565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6105ce82610585565b810181811067ffffffffffffffff821117156105ed576105ec610596565b5b80604052505050565b60006106006104d3565b905061060c82826105c5565b919050565b600067ffffffffffffffff82111561062c5761062b610596565b5b61063582610585565b9050602081019050919050565b82818337600083830152505050565b600061066461065f84610611565b6105f6565b9050828152602081018484840111156106805761067f610580565b5b61068b848285610642565b509392505050565b600082601f8301126106a8576106a761057b565b5b81356106b8848260208601610651565b91505092915050565b600080600080608085870312156106db576106da6104dd565b5b60006106e987828801610530565b94505060206106fa87828801610566565b935050604085013567ffffffffffffffff81111561071b5761071a6104e2565b5b61072787828801610693565b925050606061073887828801610566565b91505092959194509250565b600082825260208201905092915050565b7f455448207472616e73666572206661696c656400000000000000000000000000600082015250565b600061078b601383610744565b915061079682610755565b602082019050919050565b600060208201905081810360008301526107ba8161077e565b9050919050565b60006107cc826104e7565b9050919050565b6107dc816107c1565b82525050565b6107eb81610545565b82525050565b600081519050919050565b60005b8381101561081a5780820151818401526020810190506107ff565b60008484015250505050565b6000610831826107f1565b61083b8185610744565b935061084b8185602086016107fc565b61085481610585565b840191505092915050565b600060608201905061087460008301866107d3565b61088160208301856107e2565b81810360408301526108938184610826565b9050949350505050565b6000815190506108ac8161054f565b92915050565b6000602082840312156108c8576108c76104dd565b5b60006108d68482850161089d565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e62616e6b53656e64207375636365656465642062757460008201527f207472616e73666572726564207468652077726f6e6720616d6f756e74000000602082015250565b6000610946603d836108df565b9150610951826108ea565b603d82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b600061098d826107f1565b61099781856108df565b93506109a78185602086016107fc565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b60006109e482610939565b91506109ef8261095c565b600b820191506109ff8285610982565b9150610a0a826109b3565b600982019150610a1a8284610982565b91508190509392505050565b60006020820190508181036000830152610a408184610826565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610a8282610545565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610ab457610ab3610a48565b5b600182019050919050565b610ac881610507565b82525050565b6000608082019050610ae36000830187610abf565b610af060208301866107e2565b8181036040830152610b028185610826565b9050610b1160608301846107e2565b95945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea26469706673582212209f94c0998ce7cd55cbc2c6e9d67d15c37043043fd2ad0f792c2c2c8b09b8284764736f6c63430008180033", - "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80636ad4fe961461003b578063705964db14610057575b600080fd5b610055600480360381019061005091906106c1565b610073565b005b610071600480360381019061006c91906106c1565b610208565b005b8373ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f193505050506100e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100de906107a1565b60405180910390fd5b600061080073ffffffffffffffffffffffffffffffffffffffff166303003bc560008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684866040518463ffffffff1660e01b81526004016101489392919061085f565b6020604051808303816000875af1158015610167573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061018b91906108b2565b9050818114610199856102b2565b6101a2846102b2565b6040516020016101b39291906109d9565b60405160208183030381529060405290610203576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101fa9190610a26565b60405180910390fd5b600080fd5b6001600081548092919061021b90610a77565b91905055503073ffffffffffffffffffffffffffffffffffffffff16636ad4fe96858585856040518563ffffffff1660e01b815260040161025f9493929190610ace565b600060405180830381600087803b15801561027957600080fd5b505af192505050801561028a575060015b6102ab57600160008154809291906102a190610a77565b91905055506102ac565b5b50505050565b6060600060016102c184610380565b01905060008167ffffffffffffffff8111156102e0576102df610596565b5b6040519080825280601f01601f1916602001820160405280156103125781602001600182028036833780820191505090505b509050600082602001820190505b600115610375578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a858161036957610368610b1a565b5b04945060008503610320575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106103de577a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083816103d4576103d3610b1a565b5b0492506040810190505b6d04ee2d6d415b85acef8100000000831061041b576d04ee2d6d415b85acef8100000000838161041157610410610b1a565b5b0492506020810190505b662386f26fc10000831061044a57662386f26fc1000083816104405761043f610b1a565b5b0492506010810190505b6305f5e1008310610473576305f5e100838161046957610468610b1a565b5b0492506008810190505b612710831061049857612710838161048e5761048d610b1a565b5b0492506004810190505b606483106104bb57606483816104b1576104b0610b1a565b5b0492506002810190505b600a83106104ca576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610512826104e7565b9050919050565b61052281610507565b811461052d57600080fd5b50565b60008135905061053f81610519565b92915050565b6000819050919050565b61055881610545565b811461056357600080fd5b50565b6000813590506105758161054f565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6105ce82610585565b810181811067ffffffffffffffff821117156105ed576105ec610596565b5b80604052505050565b60006106006104d3565b905061060c82826105c5565b919050565b600067ffffffffffffffff82111561062c5761062b610596565b5b61063582610585565b9050602081019050919050565b82818337600083830152505050565b600061066461065f84610611565b6105f6565b9050828152602081018484840111156106805761067f610580565b5b61068b848285610642565b509392505050565b600082601f8301126106a8576106a761057b565b5b81356106b8848260208601610651565b91505092915050565b600080600080608085870312156106db576106da6104dd565b5b60006106e987828801610530565b94505060206106fa87828801610566565b935050604085013567ffffffffffffffff81111561071b5761071a6104e2565b5b61072787828801610693565b925050606061073887828801610566565b91505092959194509250565b600082825260208201905092915050565b7f455448207472616e73666572206661696c656400000000000000000000000000600082015250565b600061078b601383610744565b915061079682610755565b602082019050919050565b600060208201905081810360008301526107ba8161077e565b9050919050565b60006107cc826104e7565b9050919050565b6107dc816107c1565b82525050565b6107eb81610545565b82525050565b600081519050919050565b60005b8381101561081a5780820151818401526020810190506107ff565b60008484015250505050565b6000610831826107f1565b61083b8185610744565b935061084b8185602086016107fc565b61085481610585565b840191505092915050565b600060608201905061087460008301866107d3565b61088160208301856107e2565b81810360408301526108938184610826565b9050949350505050565b6000815190506108ac8161054f565b92915050565b6000602082840312156108c8576108c76104dd565b5b60006108d68482850161089d565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e62616e6b53656e64207375636365656465642062757460008201527f207472616e73666572726564207468652077726f6e6720616d6f756e74000000602082015250565b6000610946603d836108df565b9150610951826108ea565b603d82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b600061098d826107f1565b61099781856108df565b93506109a78185602086016107fc565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b60006109e482610939565b91506109ef8261095c565b600b820191506109ff8285610982565b9150610a0a826109b3565b600982019150610a1a8284610982565b91508190509392505050565b60006020820190508181036000830152610a408184610826565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610a8282610545565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610ab457610ab3610a48565b5b600182019050919050565b610ac881610507565b82525050565b6000608082019050610ae36000830187610abf565b610af060208301866107e2565b8181036040830152610b028185610826565b9050610b1160608301846107e2565b95945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea26469706673582212209f94c0998ce7cd55cbc2c6e9d67d15c37043043fd2ad0f792c2c2c8b09b8284764736f6c63430008180033", + "bytecode": "0x60806040526000600155604051610c8e380380610c8e833981810160405281019061002a91906100d3565b806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050610100565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006100a082610075565b9050919050565b6100b081610095565b81146100bb57600080fd5b50565b6000815190506100cd816100a7565b92915050565b6000602082840312156100e9576100e8610070565b5b60006100f7848285016100be565b91505092915050565b610b7f8061010f6000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c80636ad4fe961461003b578063705964db14610057575b600080fd5b610055600480360381019061005091906106c1565b610073565b005b610071600480360381019061006c91906106c1565b610208565b005b8373ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f193505050506100e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100de906107a1565b60405180910390fd5b600061080073ffffffffffffffffffffffffffffffffffffffff1663e77a47bf60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684866040518463ffffffff1660e01b81526004016101489392919061085f565b6020604051808303816000875af1158015610167573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061018b91906108b2565b9050818114610199856102b2565b6101a2846102b2565b6040516020016101b39291906109d9565b60405160208183030381529060405290610203576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101fa9190610a26565b60405180910390fd5b600080fd5b6001600081548092919061021b90610a77565b91905055503073ffffffffffffffffffffffffffffffffffffffff16636ad4fe96858585856040518563ffffffff1660e01b815260040161025f9493929190610ace565b600060405180830381600087803b15801561027957600080fd5b505af192505050801561028a575060015b6102ab57600160008154809291906102a190610a77565b91905055506102ac565b5b50505050565b6060600060016102c184610380565b01905060008167ffffffffffffffff8111156102e0576102df610596565b5b6040519080825280601f01601f1916602001820160405280156103125781602001600182028036833780820191505090505b509050600082602001820190505b600115610375578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a858161036957610368610b1a565b5b04945060008503610320575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106103de577a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083816103d4576103d3610b1a565b5b0492506040810190505b6d04ee2d6d415b85acef8100000000831061041b576d04ee2d6d415b85acef8100000000838161041157610410610b1a565b5b0492506020810190505b662386f26fc10000831061044a57662386f26fc1000083816104405761043f610b1a565b5b0492506010810190505b6305f5e1008310610473576305f5e100838161046957610468610b1a565b5b0492506008810190505b612710831061049857612710838161048e5761048d610b1a565b5b0492506004810190505b606483106104bb57606483816104b1576104b0610b1a565b5b0492506002810190505b600a83106104ca576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610512826104e7565b9050919050565b61052281610507565b811461052d57600080fd5b50565b60008135905061053f81610519565b92915050565b6000819050919050565b61055881610545565b811461056357600080fd5b50565b6000813590506105758161054f565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6105ce82610585565b810181811067ffffffffffffffff821117156105ed576105ec610596565b5b80604052505050565b60006106006104d3565b905061060c82826105c5565b919050565b600067ffffffffffffffff82111561062c5761062b610596565b5b61063582610585565b9050602081019050919050565b82818337600083830152505050565b600061066461065f84610611565b6105f6565b9050828152602081018484840111156106805761067f610580565b5b61068b848285610642565b509392505050565b600082601f8301126106a8576106a761057b565b5b81356106b8848260208601610651565b91505092915050565b600080600080608085870312156106db576106da6104dd565b5b60006106e987828801610530565b94505060206106fa87828801610566565b935050604085013567ffffffffffffffff81111561071b5761071a6104e2565b5b61072787828801610693565b925050606061073887828801610566565b91505092959194509250565b600082825260208201905092915050565b7f455448207472616e73666572206661696c656400000000000000000000000000600082015250565b600061078b601383610744565b915061079682610755565b602082019050919050565b600060208201905081810360008301526107ba8161077e565b9050919050565b60006107cc826104e7565b9050919050565b6107dc816107c1565b82525050565b6107eb81610545565b82525050565b600081519050919050565b60005b8381101561081a5780820151818401526020810190506107ff565b60008484015250505050565b6000610831826107f1565b61083b8185610744565b935061084b8185602086016107fc565b61085481610585565b840191505092915050565b600060608201905061087460008301866107d3565b61088160208301856107e2565b81810360408301526108938184610826565b9050949350505050565b6000815190506108ac8161054f565b92915050565b6000602082840312156108c8576108c76104dd565b5b60006108d68482850161089d565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e73656e64546f42616e6b20737563636565646564206260008201527f7574207472616e73666572726564207468652077726f6e6720616d6f756e7400602082015250565b6000610946603f836108df565b9150610951826108ea565b603f82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b600061098d826107f1565b61099781856108df565b93506109a78185602086016107fc565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b60006109e482610939565b91506109ef8261095c565b600b820191506109ff8285610982565b9150610a0a826109b3565b600982019150610a1a8284610982565b91508190509392505050565b60006020820190508181036000830152610a408184610826565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610a8282610545565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610ab457610ab3610a48565b5b600182019050919050565b610ac881610507565b82525050565b6000608082019050610ae36000830187610abf565b610af060208301866107e2565b8181036040830152610b028185610826565b9050610b1160608301846107e2565b95945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea264697066735822122025f19b0c686ff339bb4b68de727beee11bc2a0c2b9709bd82cc14c13e1eadbe064736f6c63430008180033", + "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100365760003560e01c80636ad4fe961461003b578063705964db14610057575b600080fd5b610055600480360381019061005091906106c1565b610073565b005b610071600480360381019061006c91906106c1565b610208565b005b8373ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f193505050506100e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100de906107a1565b60405180910390fd5b600061080073ffffffffffffffffffffffffffffffffffffffff1663e77a47bf60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1684866040518463ffffffff1660e01b81526004016101489392919061085f565b6020604051808303816000875af1158015610167573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061018b91906108b2565b9050818114610199856102b2565b6101a2846102b2565b6040516020016101b39291906109d9565b60405160208183030381529060405290610203576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101fa9190610a26565b60405180910390fd5b600080fd5b6001600081548092919061021b90610a77565b91905055503073ffffffffffffffffffffffffffffffffffffffff16636ad4fe96858585856040518563ffffffff1660e01b815260040161025f9493929190610ace565b600060405180830381600087803b15801561027957600080fd5b505af192505050801561028a575060015b6102ab57600160008154809291906102a190610a77565b91905055506102ac565b5b50505050565b6060600060016102c184610380565b01905060008167ffffffffffffffff8111156102e0576102df610596565b5b6040519080825280601f01601f1916602001820160405280156103125781602001600182028036833780820191505090505b509050600082602001820190505b600115610375578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a858161036957610368610b1a565b5b04945060008503610320575b819350505050919050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106103de577a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083816103d4576103d3610b1a565b5b0492506040810190505b6d04ee2d6d415b85acef8100000000831061041b576d04ee2d6d415b85acef8100000000838161041157610410610b1a565b5b0492506020810190505b662386f26fc10000831061044a57662386f26fc1000083816104405761043f610b1a565b5b0492506010810190505b6305f5e1008310610473576305f5e100838161046957610468610b1a565b5b0492506008810190505b612710831061049857612710838161048e5761048d610b1a565b5b0492506004810190505b606483106104bb57606483816104b1576104b0610b1a565b5b0492506002810190505b600a83106104ca576001810190505b80915050919050565b6000604051905090565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610512826104e7565b9050919050565b61052281610507565b811461052d57600080fd5b50565b60008135905061053f81610519565b92915050565b6000819050919050565b61055881610545565b811461056357600080fd5b50565b6000813590506105758161054f565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6105ce82610585565b810181811067ffffffffffffffff821117156105ed576105ec610596565b5b80604052505050565b60006106006104d3565b905061060c82826105c5565b919050565b600067ffffffffffffffff82111561062c5761062b610596565b5b61063582610585565b9050602081019050919050565b82818337600083830152505050565b600061066461065f84610611565b6105f6565b9050828152602081018484840111156106805761067f610580565b5b61068b848285610642565b509392505050565b600082601f8301126106a8576106a761057b565b5b81356106b8848260208601610651565b91505092915050565b600080600080608085870312156106db576106da6104dd565b5b60006106e987828801610530565b94505060206106fa87828801610566565b935050604085013567ffffffffffffffff81111561071b5761071a6104e2565b5b61072787828801610693565b925050606061073887828801610566565b91505092959194509250565b600082825260208201905092915050565b7f455448207472616e73666572206661696c656400000000000000000000000000600082015250565b600061078b601383610744565b915061079682610755565b602082019050919050565b600060208201905081810360008301526107ba8161077e565b9050919050565b60006107cc826104e7565b9050919050565b6107dc816107c1565b82525050565b6107eb81610545565b82525050565b600081519050919050565b60005b8381101561081a5780820151818401526020810190506107ff565b60008484015250505050565b6000610831826107f1565b61083b8185610744565b935061084b8185602086016107fc565b61085481610585565b840191505092915050565b600060608201905061087460008301866107d3565b61088160208301856107e2565b81810360408301526108938184610826565b9050949350505050565b6000815190506108ac8161054f565b92915050565b6000602082840312156108c8576108c76104dd565b5b60006108d68482850161089d565b91505092915050565b600081905092915050565b7f4946756e546f6b656e2e73656e64546f42616e6b20737563636565646564206260008201527f7574207472616e73666572726564207468652077726f6e6720616d6f756e7400602082015250565b6000610946603f836108df565b9150610951826108ea565b603f82019050919050565b7f73656e74416d6f756e7420000000000000000000000000000000000000000000815250565b600061098d826107f1565b61099781856108df565b93506109a78185602086016107fc565b80840191505092915050565b7f6578706563746564200000000000000000000000000000000000000000000000815250565b60006109e482610939565b91506109ef8261095c565b600b820191506109ff8285610982565b9150610a0a826109b3565b600982019150610a1a8284610982565b91508190509392505050565b60006020820190508181036000830152610a408184610826565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610a8282610545565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203610ab457610ab3610a48565b5b600182019050919050565b610ac881610507565b82525050565b6000608082019050610ae36000830187610abf565b610af060208301866107e2565b8181036040830152610b028185610826565b9050610b1160608301846107e2565b95945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fdfea264697066735822122025f19b0c686ff339bb4b68de727beee11bc2a0c2b9709bd82cc14c13e1eadbe064736f6c63430008180033", "linkReferences": {}, "deployedLinkReferences": {} } diff --git a/x/evm/embeds/contracts/IFunToken.sol b/x/evm/embeds/contracts/IFunToken.sol index b571c0d00..70b130638 100644 --- a/x/evm/embeds/contracts/IFunToken.sol +++ b/x/evm/embeds/contracts/IFunToken.sol @@ -1,24 +1,53 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.19; -/// @dev Implements the "bankSend" functionality for sending ERC20 tokens as bank -/// coins to a Nibiru bech32 address using the "FunToken" mapping between the -/// ERC20 and bank. +address constant FUNTOKEN_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000800; +IFunToken constant FUNTOKEN_PRECOMPILE = IFunToken(FUNTOKEN_PRECOMPILE_ADDRESS); + +/// @dev Implements the functionality for sending ERC20 tokens and bank +/// coins to various Nibiru accounts using either the Nibiru Bech32 address +/// using the "FunToken" mapping between the ERC20 and bank. interface IFunToken { - /// @dev bankSend sends ERC20 tokens as coins to a Nibiru base account + /// @dev sendToBank sends ERC20 tokens as coins to a Nibiru base account /// @param erc20 - the address of the ERC20 token contract /// @param amount - the amount of tokens to send /// @param to - the receiving Nibiru base account address as a string /// @return sentAmount - amount of tokens received by the recipient. This may /// not be equal to `amount` if the corresponding ERC20 contract has a fee or /// deduction on transfer. - function bankSend( + function sendToBank( address erc20, uint256 amount, - string memory to + string calldata to ) external returns (uint256 sentAmount); -} -address constant FUNTOKEN_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000800; + struct NibiruAccount { + address ethAddr; + string bech32Addr; + } + struct FunToken { + address erc20; + string bankDenom; + } -IFunToken constant FUNTOKEN_PRECOMPILE = IFunToken(FUNTOKEN_PRECOMPILE_ADDRESS); + function balance( + address who, + address funtoken + ) + external + returns ( + uint256 erc20Balance, + uint256 bankBalance, + FunToken memory token, + NibiruAccount memory whoAddrs + ); + + function bankBalance( + address who, + string calldata bankDenom + ) external returns (uint256 bankBalance, NibiruAccount memory whoAddrs); + + function whoAmI( + string calldata who + ) external returns (NibiruAccount memory whoAddrs); +} diff --git a/x/evm/embeds/contracts/TestERC20TransferThenPrecompileSend.sol b/x/evm/embeds/contracts/TestERC20TransferThenPrecompileSend.sol index 984c00698..6f939448a 100644 --- a/x/evm/embeds/contracts/TestERC20TransferThenPrecompileSend.sol +++ b/x/evm/embeds/contracts/TestERC20TransferThenPrecompileSend.sol @@ -25,7 +25,7 @@ contract TestERC20TransferThenPrecompileSend { "ERC-20 transfer failed" ); - uint256 sentAmount = FUNTOKEN_PRECOMPILE.bankSend( + uint256 sentAmount = FUNTOKEN_PRECOMPILE.sendToBank( erc20, precompileAmount, precompileRecipient @@ -34,7 +34,7 @@ contract TestERC20TransferThenPrecompileSend { require( sentAmount == precompileAmount, string.concat( - "IFunToken.bankSend succeeded but transferred the wrong amount", + "IFunToken.sendToBank succeeded but transferred the wrong amount", "sentAmount ", Strings.toString(sentAmount), "expected ", diff --git a/x/evm/embeds/contracts/TestFunTokenPrecompileLocalGas.sol b/x/evm/embeds/contracts/TestFunTokenPrecompileLocalGas.sol index abb239381..131d509a2 100644 --- a/x/evm/embeds/contracts/TestFunTokenPrecompileLocalGas.sol +++ b/x/evm/embeds/contracts/TestFunTokenPrecompileLocalGas.sol @@ -11,21 +11,21 @@ contract TestFunTokenPrecompileLocalGas { erc20 = erc20_; } - // Calls bankSend of the FunToken Precompile with the default gas. + // Calls sendToBank of the FunToken Precompile with the default gas. // Internal call could use all the gas for the parent call. function callBankSend( uint256 amount, string memory bech32Recipient ) public { - uint256 sentAmount = FUNTOKEN_PRECOMPILE.bankSend( + uint256 sentAmount = FUNTOKEN_PRECOMPILE.sendToBank( erc20, - amount, + amount, bech32Recipient ); require( sentAmount == amount, string.concat( - "IFunToken.bankSend succeeded but transferred the wrong amount", + "IFunToken.sendToBank succeeded but transferred the wrong amount", "sentAmount ", Strings.toString(sentAmount), "expected ", @@ -34,14 +34,14 @@ contract TestFunTokenPrecompileLocalGas { ); } - // Calls bankSend of the FunToken Precompile with the gas amount set in parameter. + // Calls sendToBank of the FunToken Precompile with the gas amount set in parameter. // Internal call should fail if the gas provided is insufficient. function callBankSendLocalGas( uint256 amount, string memory bech32Recipient, uint256 customGas ) public { - uint256 sentAmount = FUNTOKEN_PRECOMPILE.bankSend{gas: customGas}( + uint256 sentAmount = FUNTOKEN_PRECOMPILE.sendToBank{gas: customGas}( erc20, amount, bech32Recipient @@ -49,7 +49,7 @@ contract TestFunTokenPrecompileLocalGas { require( sentAmount == amount, string.concat( - "IFunToken.bankSend succeeded but transferred the wrong amount", + "IFunToken.sendToBank succeeded but transferred the wrong amount", "sentAmount ", Strings.toString(sentAmount), "expected ", diff --git a/x/evm/embeds/contracts/TestNativeSendThenPrecompileSend.sol b/x/evm/embeds/contracts/TestNativeSendThenPrecompileSend.sol index 45ec757b9..07afd3293 100644 --- a/x/evm/embeds/contracts/TestNativeSendThenPrecompileSend.sol +++ b/x/evm/embeds/contracts/TestNativeSendThenPrecompileSend.sol @@ -20,7 +20,7 @@ contract TestNativeSendThenPrecompileSend { bool isSent = nativeRecipient.send(nativeAmount); require(isSent, "Failed to send native token"); - uint256 sentAmount = FUNTOKEN_PRECOMPILE.bankSend( + uint256 sentAmount = FUNTOKEN_PRECOMPILE.sendToBank( erc20, precompileAmount, precompileRecipient @@ -28,7 +28,28 @@ contract TestNativeSendThenPrecompileSend { require( sentAmount == precompileAmount, string.concat( - "IFunToken.bankSend succeeded but transferred the wrong amount", + "IFunToken.sendToBank succeeded but transferred the wrong amount", + "sentAmount ", + Strings.toString(sentAmount), + "expected ", + Strings.toString(precompileAmount) + ) + ); + } + + function justPrecompileSend( + string memory precompileRecipient, + uint256 precompileAmount + ) public { + uint256 sentAmount = FUNTOKEN_PRECOMPILE.sendToBank( + erc20, + precompileAmount, + precompileRecipient + ); + require( + sentAmount == precompileAmount, + string.concat( + "IFunToken.sendToBank succeeded but transferred the wrong amount", "sentAmount ", Strings.toString(sentAmount), "expected ", diff --git a/x/evm/embeds/contracts/TestPrecompileSelfCallRevert.sol b/x/evm/embeds/contracts/TestPrecompileSelfCallRevert.sol index 972691a71..9e38b0496 100644 --- a/x/evm/embeds/contracts/TestPrecompileSelfCallRevert.sol +++ b/x/evm/embeds/contracts/TestPrecompileSelfCallRevert.sol @@ -40,16 +40,16 @@ contract TestPrecompileSelfCallRevert { ) external { require(nativeRecipient.send(nativeAmount), "ETH transfer failed"); // wei - uint256 sentAmount = FUNTOKEN_PRECOMPILE.bankSend( + uint256 sentAmount = FUNTOKEN_PRECOMPILE.sendToBank( erc20, - precompileAmount, // micro-WNIBI - precompileRecipient + precompileAmount, // micro-WNIBI + precompileRecipient ); require( sentAmount == precompileAmount, string.concat( - "IFunToken.bankSend succeeded but transferred the wrong amount", + "IFunToken.sendToBank succeeded but transferred the wrong amount", "sentAmount ", Strings.toString(nativeAmount), "expected ", diff --git a/x/evm/embeds/embeds.go b/x/evm/embeds/embeds.go index b81a4b276..b3676de17 100644 --- a/x/evm/embeds/embeds.go +++ b/x/evm/embeds/embeds.go @@ -90,18 +90,20 @@ var ( Name: "TestFunTokenPrecompileLocalGas.sol", EmbedJSON: testFunTokenPrecompileLocalGasJson, } - // SmartContract_TestNativeSendThenPrecompileSendJson is a test contract - // that performs two sends in a single call: a native nibi send and a precompile bankSend. - // It tests a race condition where the state DB commit - // may overwrite the state after the precompile execution, potentially causing a loss of funds. + // SmartContract_TestNativeSendThenPrecompileSendJson is a test contract that + // performs two sends in a single call: a native nibi send and a precompile + // sendToBank. It tests a race condition where the state DB commit may + // overwrite the state after the precompile execution, potentially causing a + // loss of funds. SmartContract_TestNativeSendThenPrecompileSendJson = CompiledEvmContract{ Name: "TestNativeSendThenPrecompileSend.sol", EmbedJSON: testNativeSendThenPrecompileSendJson, } - // SmartContract_TestERC20TransferThenPrecompileSend is a test contract - // that performs two sends in a single call: an erc20 token transfer and a precompile bankSend. - // It tests a race condition where the state DB commit - // may overwrite the state after the precompile execution, potentially causing an infinite token mint. + // SmartContract_TestERC20TransferThenPrecompileSend is a test contract that + // performs two sends in a single call: an erc20 token transfer and a + // precompile sendToBank. It tests a race condition where the state DB commit + // may overwrite the state after the precompile execution, potentially + // causing an infinite token mint. SmartContract_TestERC20TransferThenPrecompileSend = CompiledEvmContract{ Name: "TestERC20TransferThenPrecompileSend.sol", EmbedJSON: testERC20TransferThenPrecompileSendJson, diff --git a/x/evm/evmtest/erc20.go b/x/evm/evmtest/erc20.go index 3d7dd4d76..df7751d00 100644 --- a/x/evm/evmtest/erc20.go +++ b/x/evm/evmtest/erc20.go @@ -163,3 +163,15 @@ func AssertBankBalanceEqualWithDescription( assert.Equalf(t, expectedBalance.String(), actualBalance.String(), "expected %s, got %s", expectedBalance, actualBalance, errSuffix) } + +const ( + // FunTokenGasLimitSendToEvm consists of gas for 3 calls: + // 1. transfer erc20 from sender to module + // ~60_000 gas for regular erc20 transfer (our own ERC20Minter contract) + // could be higher for user created contracts, let's cap with 200_000 + // 2. mint native coin (made from erc20) or burn erc20 token (made from coin) + // ~60_000 gas for either mint or burn + // 3. send from module to account: + // ~65_000 gas (bank send) + FunTokenGasLimitSendToEvm uint64 = 400_000 +) diff --git a/x/evm/keeper/funtoken_from_coin_test.go b/x/evm/keeper/funtoken_from_coin_test.go index 29c3f2daa..ed3f47c10 100644 --- a/x/evm/keeper/funtoken_from_coin_test.go +++ b/x/evm/keeper/funtoken_from_coin_test.go @@ -234,8 +234,8 @@ func (s *FunTokenFromCoinSuite) TestConvertCoinToEvmAndBack() { alice.EthAddr, &precompile.PrecompileAddr_FunToken, true, - precompile.FunTokenGasLimitBankSend, - "bankSend", + evmtest.FunTokenGasLimitSendToEvm, + "sendToBank", funToken.Erc20Addr.Address, big.NewInt(10), deps.Sender.NibiruAddr.String(), @@ -262,8 +262,8 @@ func (s *FunTokenFromCoinSuite) TestConvertCoinToEvmAndBack() { alice.EthAddr, &precompile.PrecompileAddr_FunToken, true, - precompile.FunTokenGasLimitBankSend, - "bankSend", + evmtest.FunTokenGasLimitSendToEvm, + "sendToBank", funToken.Erc20Addr.Address, big.NewInt(10), deps.Sender.NibiruAddr.String(), @@ -271,11 +271,15 @@ func (s *FunTokenFromCoinSuite) TestConvertCoinToEvmAndBack() { s.Require().ErrorContains(err, "transfer amount exceeds balance") } -// TestNativeSendThenPrecompileSend -// 1. Creates a funtoken from coin. -// 2. Using the test contract, performs two sends in a single call: a native nibi send and a precompile bankSend. -// It tests a race condition where the state DB commit may overwrite the state after the precompile execution, -// potentially causing a loss of funds. +// TestNativeSendThenPrecompileSend tests a race condition where the state DB +// commit may overwrite the state after the precompile execution, potentially +// causing a loss of funds. +// +// The order of operations is to: +// 1. Create a funtoken mapping from NIBI, a bank coin. +// 2. Use a test Solidity contract to perform two transfers in a single call: a +// transfer of NIBI with native send and a precompile "IFunToken.sendToBank" +// transfer for the same asset. // // INITIAL STATE: // - Test contract funds: 10 NIBI, 10 WNIBI @@ -352,6 +356,9 @@ func (s *FunTokenFromCoinSuite) TestNativeSendThenPrecompileSend() { }.Assert(s.T(), deps) s.T().Log("call test contract") + deps.ResetGasMeter() + newSendAmtSendToBank := new(big.Int).Quo(sendAmt, big.NewInt(2)) + newSendAmtEvmTransfer := evm.NativeToWei(newSendAmtSendToBank) evmResp, err := deps.EvmKeeper.CallContract( deps.Ctx, embeds.SmartContract_TestNativeSendThenPrecompileSendJson.ABI, @@ -361,26 +368,68 @@ func (s *FunTokenFromCoinSuite) TestNativeSendThenPrecompileSend() { 10_000_000, // 100% sufficient gas "nativeSendThenPrecompileSend", []any{ - alice.EthAddr, - evm.NativeToWei(sendAmt), // native send uses wei units - alice.NibiruAddr.String(), - sendAmt, // amount for precompile bankSend + alice.EthAddr, // nativeRecipient + newSendAmtEvmTransfer, // nativeAmount (wei units) + alice.NibiruAddr.String(), // precompileRecipient + newSendAmtSendToBank, // precompileAmount }..., ) s.Require().NoError(err) s.Empty(evmResp.VmError) + gasUsedFor2Ops := evmResp.GasUsed + + evmtest.FunTokenBalanceAssert{ + FunToken: funtoken, + Account: alice.EthAddr, + BalanceBank: new(big.Int).Mul( + newSendAmtSendToBank, big.NewInt(2)), + BalanceERC20: big.NewInt(0), + }.Assert(s.T(), deps) evmtest.FunTokenBalanceAssert{ FunToken: funtoken, - Account: alice.EthAddr, - BalanceBank: new(big.Int).Mul(sendAmt, big.NewInt(2)), + Account: testContractAddr, + BalanceBank: big.NewInt(5), + BalanceERC20: big.NewInt(5), + }.Assert(s.T(), deps) + + evmtest.FunTokenBalanceAssert{ + FunToken: funtoken, + Account: evm.EVM_MODULE_ADDRESS, + BalanceBank: big.NewInt(5), + BalanceERC20: big.NewInt(0), + }.Assert(s.T(), deps) + + deps.ResetGasMeter() + evmResp, err = deps.EvmKeeper.CallContract( + deps.Ctx, + embeds.SmartContract_TestNativeSendThenPrecompileSendJson.ABI, + deps.Sender.EthAddr, + &testContractAddr, + true, + 10_000_000, // 100% sufficient gas + "justPrecompileSend", + []any{ + alice.NibiruAddr.String(), // precompileRecipient + newSendAmtSendToBank, // precompileAmount + }..., + ) + s.Require().NoError(err) + s.Empty(evmResp.VmError) + gasUsedFor1Op := evmResp.GasUsed + + evmtest.FunTokenBalanceAssert{ + FunToken: funtoken, + Account: alice.EthAddr, + BalanceBank: new(big.Int).Mul( + newSendAmtSendToBank, big.NewInt(3)), BalanceERC20: big.NewInt(0), }.Assert(s.T(), deps) evmtest.FunTokenBalanceAssert{ FunToken: funtoken, Account: testContractAddr, - BalanceBank: big.NewInt(0), + BalanceBank: big.NewInt(5), BalanceERC20: big.NewInt(0), }.Assert(s.T(), deps) @@ -390,11 +439,13 @@ func (s *FunTokenFromCoinSuite) TestNativeSendThenPrecompileSend() { BalanceBank: big.NewInt(0), BalanceERC20: big.NewInt(0), }.Assert(s.T(), deps) + s.Require().Greater(gasUsedFor2Ops, gasUsedFor1Op, "2 operations should consume more gas") } // TestERC20TransferThenPrecompileSend // 1. Creates a funtoken from coin. -// 2. Using the test contract, performs two sends in a single call: a erc20 transfer and a precompile bankSend. +// 2. Using the test contract, performs two sends in a single call: a erc20 +// transfer and a precompile sendToBank. // It tests a race condition where the state DB commit may overwrite the state after the precompile execution, // potentially causing an infinite minting of funds. // @@ -449,7 +500,7 @@ func (s *FunTokenFromCoinSuite) TestERC20TransferThenPrecompileSend() { alice.EthAddr, big.NewInt(1e6), // erc20 created with 6 decimals alice.NibiruAddr.String(), - big.NewInt(9e6), // for precompile bankSend: 6 decimals + big.NewInt(9e6), // for precompile sendToBank: 6 decimals ) s.Require().NoError(err) @@ -539,7 +590,8 @@ func (s *FunTokenFromCoinSuite) TestPrecompileSelfCallRevert() { Description: "Initial contract state sanity check: 10 NIBI / 10 WNIBI", }.Assert(s.T(), deps) - // Create Alice and Charles. Contract will try to send Alice native coins and send Charles tokens via bankSend + // Create Alice and Charles. Contract will try to send Alice native coins and + // send Charles tokens via sendToBank alice := evmtest.NewEthPrivAcc() charles := evmtest.NewEthPrivAcc() @@ -550,12 +602,12 @@ func (s *FunTokenFromCoinSuite) TestPrecompileSelfCallRevert() { deps.Sender.EthAddr, &testContractAddr, true, - precompile.FunTokenGasLimitBankSend, + evmtest.FunTokenGasLimitSendToEvm, "selfCallTransferFunds", alice.EthAddr, evm.NativeToWei(big.NewInt(1e6)), // native send uses wei units, charles.NibiruAddr.String(), - big.NewInt(9e6), // for precompile bankSend: 6 decimals + big.NewInt(9e6), // for precompile sendToBank: 6 decimals ) s.Require().NoError(err) diff --git a/x/evm/keeper/funtoken_from_erc20_test.go b/x/evm/keeper/funtoken_from_erc20_test.go index 538d041d1..94c7b6960 100644 --- a/x/evm/keeper/funtoken_from_erc20_test.go +++ b/x/evm/keeper/funtoken_from_erc20_test.go @@ -220,8 +220,8 @@ func (s *FunTokenFromErc20Suite) TestSendFromEvmToBank() { deps.Sender.EthAddr, &precompile.PrecompileAddr_FunToken, true, - precompile.FunTokenGasLimitBankSend, - "bankSend", + evmtest.FunTokenGasLimitSendToEvm, + "sendToBank", deployResp.ContractAddr, big.NewInt(1), randomAcc.String(), @@ -244,8 +244,8 @@ func (s *FunTokenFromErc20Suite) TestSendFromEvmToBank() { deps.Sender.EthAddr, &precompile.PrecompileAddr_FunToken, true, - precompile.FunTokenGasLimitBankSend, - "bankSend", + evmtest.FunTokenGasLimitSendToEvm, + "sendToBank", deployResp.ContractAddr, big.NewInt(70_000), randomAcc.String(), @@ -376,8 +376,8 @@ func (s *FunTokenFromErc20Suite) TestFunTokenFromERC20MaliciousTransfer() { deps.Sender.EthAddr, &precompile.PrecompileAddr_FunToken, true, - precompile.FunTokenGasLimitBankSend, - "bankSend", + evmtest.FunTokenGasLimitSendToEvm, + "sendToBank", deployResp.ContractAddr, big.NewInt(1), randomAcc.String(), diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 6d413e687..79899bd89 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -5,7 +5,6 @@ import ( "fmt" "math/big" - "cosmossdk.io/math" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/vm" gethparams "github.com/ethereum/go-ethereum/params" @@ -116,14 +115,6 @@ func (k *Keeper) AddToBlockGasUsed( return blockGasUsed, nil } -// GetMinGasUsedMultiplier - value from 0 to 1 -// When executing evm msg, user specifies gasLimit. -// If the gasLimit is X times higher than the actual gasUsed then -// we update gasUsed = max(gasUsed, gasLimit * minGasUsedPct) -func (k Keeper) GetMinGasUsedMultiplier(ctx sdk.Context) math.LegacyDec { - return math.LegacyNewDecWithPrec(50, 2) // 50% -} - // BaseFeeMicronibiPerGas returns the gas base fee in units of the EVM denom. Note // that this function is currently constant/stateless. func (k Keeper) BaseFeeMicronibiPerGas(_ sdk.Context) *big.Int { diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index e7002d528..9914426fa 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -355,17 +355,20 @@ func (k *Keeper) ApplyEvmMsg(ctx sdk.Context, return nil, evmObj, errors.Wrapf(core.ErrGasUintOverflow, "ApplyEvmMsg: message gas limit (%d) < leftover gas (%d)", msg.Gas(), leftoverGas) } + // TODO: UD-DEBUG: Clarify text below. // GAS REFUND // If msg.Gas() > gasUsed, we need to refund extra gas. // leftoverGas = amount of extra (not used) gas. // If the msg comes from user, we apply refundQuotient capping the refund to 20% of used gas // If msg is internal (funtoken), we refund 100% - - refundQuotient := params.RefundQuotientEIP3529 // EIP-3529: refunds are capped to gasUsed / 5 - minGasUsedPct := k.GetMinGasUsedMultiplier(ctx) // Evmos invention: https://github.com/evmos/ethermint/issues/1085 + // + // EIP-3529: refunds are capped to gasUsed / 5 + // We evaluate "fullRefundLeftoverGas" and use only the gas consumed (not the + // gas limit) if the `ApplyEvmMsg` call originated from a state transition + // where the chain set the gas limit and not an end-user. + refundQuotient := params.RefundQuotientEIP3529 if fullRefundLeftoverGas { - refundQuotient = 1 // 100% refund - minGasUsedPct = math.LegacyZeroDec() // no minimum, get the actual gasUsed value + refundQuotient = 1 // 100% refund } temporaryGasUsed := msg.Gas() - leftoverGas refund := GasToRefund(stateDB.GetRefund(), temporaryGasUsed, refundQuotient) @@ -378,8 +381,7 @@ func (k *Keeper) ApplyEvmMsg(ctx sdk.Context, } // Min gas used is a % of gasLimit - minimumGasUsed := math.LegacyNewDec(int64(msg.Gas())).Mul(minGasUsedPct) - gasUsed := math.LegacyMaxDec(minimumGasUsed, math.LegacyNewDec(int64(temporaryGasUsed))).TruncateInt().Uint64() + gasUsed := math.LegacyNewDec(int64(temporaryGasUsed)).TruncateInt().Uint64() // This resulting "leftoverGas" is used by the tracer. This happens as a // result of the defer statement near the beginning of the function with diff --git a/x/evm/precompile/errors.go b/x/evm/precompile/errors.go index 438ffa750..eadd99e24 100644 --- a/x/evm/precompile/errors.go +++ b/x/evm/precompile/errors.go @@ -57,9 +57,10 @@ func assertContractQuery(contract *vm.Contract) error { // assertNumArgs checks if the number of provided arguments matches the expected // count. If lenArgs does not equal wantArgsLen, it returns an error describing // the mismatch between expected and actual argument counts. -func assertNumArgs(lenArgs, wantArgsLen int) error { +func assertNumArgs(args []any, wantArgsLen int) error { + lenArgs := len(args) if lenArgs != wantArgsLen { - return fmt.Errorf("expected %d arguments but got %d", wantArgsLen, lenArgs) + return fmt.Errorf("expected %d arguments but got %d; args: %v", wantArgsLen, lenArgs, args) } return nil } diff --git a/x/evm/precompile/funtoken.go b/x/evm/precompile/funtoken.go index 167c815f5..7aa22af09 100644 --- a/x/evm/precompile/funtoken.go +++ b/x/evm/precompile/funtoken.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/NibiruChain/nibiru/v2/app/keepers" + "github.com/NibiruChain/nibiru/v2/eth" "github.com/NibiruChain/nibiru/v2/x/evm" "github.com/NibiruChain/nibiru/v2/x/evm/embeds" evmkeeper "github.com/NibiruChain/nibiru/v2/x/evm/keeper" @@ -23,18 +24,6 @@ var _ vm.PrecompiledContract = (*precompileFunToken)(nil) // using the ERC20's `FunToken` mapping. var PrecompileAddr_FunToken = gethcommon.HexToAddress("0x0000000000000000000000000000000000000800") -const ( - // FunTokenGasLimitBankSend consists of gas for 3 calls: - // 1. transfer erc20 from sender to module - // ~60_000 gas for regular erc20 transfer (our own ERC20Minter contract) - // could be higher for user created contracts, let's cap with 200_000 - // 2. mint native coin (made from erc20) or burn erc20 token (made from coin) - // ~60_000 gas for either mint or burn - // 3. send from module to account: - // ~65_000 gas (bank send) - FunTokenGasLimitBankSend uint64 = 400_000 -) - func (p precompileFunToken) Address() gethcommon.Address { return PrecompileAddr_FunToken } @@ -49,7 +38,10 @@ func (p precompileFunToken) ABI() *gethabi.ABI { } const ( - FunTokenMethod_BankSend PrecompileMethod = "bankSend" + FunTokenMethod_sendToBank PrecompileMethod = "sendToBank" + FunTokenMethod_balance PrecompileMethod = "balance" + FunTokenMethod_bankBalance PrecompileMethod = "bankBalance" + FunTokenMethod_whoAmI PrecompileMethod = "whoAmI" ) // Run runs the precompiled contract @@ -70,11 +62,17 @@ func (p precompileFunToken) Run( method := startResult.Method switch PrecompileMethod(method.Name) { - case FunTokenMethod_BankSend: - bz, err = p.bankSend(startResult, contract.CallerAddress, readonly) + case FunTokenMethod_sendToBank: + bz, err = p.sendToBank(startResult, contract.CallerAddress, readonly) + case FunTokenMethod_balance: + bz, err = p.balance(startResult, contract) + case FunTokenMethod_bankBalance: + bz, err = p.bankBalance(startResult, contract) + case FunTokenMethod_whoAmI: + bz, err = p.whoAmI(startResult, contract) default: // Note that this code path should be impossible to reach since - // "DecomposeInput" parses methods directly from the ABI. + // "[decomposeInput]" parses methods directly from the ABI. err = fmt.Errorf("invalid method called with name \"%s\"", method.Name) return } @@ -97,18 +95,18 @@ type precompileFunToken struct { evmKeeper *evmkeeper.Keeper } -// bankSend: Implements "IFunToken.bankSend" +// sendToBank: Implements "IFunToken.sendToBank" // // The "args" populate the following function signature in Solidity: // // ```solidity -// /// @dev bankSend sends ERC20 tokens as coins to a Nibiru base account +// /// @dev sendToBank sends ERC20 tokens as coins to a Nibiru base account // /// @param erc20 the address of the ERC20 token contract // /// @param amount the amount of tokens to send // /// @param to the receiving Nibiru base account address as a string -// function bankSend(address erc20, uint256 amount, string memory to) external; +// function sendToBank(address erc20, uint256 amount, string memory to) external; // ``` -func (p precompileFunToken) bankSend( +func (p precompileFunToken) sendToBank( startResult OnRunStartResult, caller gethcommon.Address, readOnly bool, @@ -118,7 +116,7 @@ func (p precompileFunToken) bankSend( return nil, err } - erc20, amount, to, err := p.decomposeBankSendArgs(args) + erc20, amount, to, err := p.parseArgsSendToBank(args) if err != nil { return } @@ -206,38 +204,299 @@ func (p precompileFunToken) bankSend( } // TODO: UD-DEBUG: feat: Emit EVM events + // TODO: emit event for balance change of sender + // TODO: emit event for balance change of recipient return method.Outputs.Pack(gotAmount) } -func (p precompileFunToken) decomposeBankSendArgs(args []any) ( +func (p precompileFunToken) parseArgsSendToBank(args []any) ( erc20 gethcommon.Address, amount *big.Int, to string, err error, ) { - if e := assertNumArgs(len(args), 3); e != nil { + if e := assertNumArgs(args, 3); e != nil { err = e return } - erc20, ok := args[0].(gethcommon.Address) + argIdx := 0 + erc20, ok := args[argIdx].(gethcommon.Address) if !ok { - err = fmt.Errorf("type validation for failed for (address erc20) argument") + err = ErrArgTypeValidation("address erc20", args[argIdx]) return } - amount, ok = args[1].(*big.Int) + argIdx++ + amount, ok = args[argIdx].(*big.Int) if !ok { - err = fmt.Errorf("type validation for failed for (uint256 amount) argument") + err = ErrArgTypeValidation("uint256 amount", args[argIdx]) return } - to, ok = args[2].(string) + argIdx++ + to, ok = args[argIdx].(string) if !ok { - err = fmt.Errorf("type validation for failed for (string to) argument") + err = ErrArgTypeValidation("string to", args[argIdx]) return } return } + +// balance: Implements "IFunToken.balance" +// +// The "args" populate the following function signature in Solidity: +// +// ```solidity +// function balance( +// address who, +// address funtoken +// ) +// external +// returns ( +// uint256 erc20Balance, +// uint256 bankBalance, +// FunToken memory token, +// NibiruAccount memory whoAddrs +// ); +// ``` +func (p precompileFunToken) balance( + start OnRunStartResult, + contract *vm.Contract, +) (bz []byte, err error) { + method, args, ctx := start.Method, start.Args, start.CacheCtx + defer func() { + if err != nil { + err = ErrMethodCalled(method, err) + } + }() + if err := assertContractQuery(contract); err != nil { + return bz, err + } + + addrEth, addrBech32, funtoken, err := p.parseArgsBalance(args, ctx) + if err != nil { + err = ErrInvalidArgs(err) + return + } + + erc20Bal, err := p.evmKeeper.ERC20().BalanceOf(funtoken.Erc20Addr.Address, addrEth, ctx) + if err != nil { + return + } + bankBal := p.evmKeeper.Bank.GetBalance(ctx, addrBech32, funtoken.BankDenom).Amount.BigInt() + + return method.Outputs.Pack([]any{ + erc20Bal, + bankBal, + struct { + Erc20 gethcommon.Address `json:"erc20"` + BankDenom string `json:"bankDenom"` + }{ + Erc20: funtoken.Erc20Addr.Address, + BankDenom: funtoken.BankDenom, + }, + struct { + EthAddr gethcommon.Address `json:"ethAddr"` + Bech32Addr string `json:"bech32Addr"` + }{ + EthAddr: addrEth, + Bech32Addr: addrBech32.String(), + }, + }...) +} + +func (p precompileFunToken) parseArgsBalance(args []any, ctx sdk.Context) ( + addrEth gethcommon.Address, + addrBech32 sdk.AccAddress, + funtoken evm.FunToken, + err error, +) { + if e := assertNumArgs(args, 2); e != nil { + err = e + return + } + + argIdx := 0 + who, ok := args[argIdx].(gethcommon.Address) + if !ok { + err = ErrArgTypeValidation("bytes who", args[argIdx]) + return + } + req := &evm.QueryEthAccountRequest{Address: who.Hex()} + _, e := req.Validate() + if e != nil { + err = e + return + } + addrEth = gethcommon.HexToAddress(req.Address) + addrBech32 = eth.EthAddrToNibiruAddr(addrEth) + + argIdx++ + funtokenErc20, ok := args[argIdx].(gethcommon.Address) + if !ok { + err = ErrArgTypeValidation("bytes funtoken", args[argIdx]) + return + } + resp, e := p.evmKeeper.FunTokenMapping(ctx, &evm.QueryFunTokenMappingRequest{ + Token: funtokenErc20.Hex(), + }) + if e != nil { + err = e + return + } + + return addrEth, addrBech32, *resp.FunToken, nil +} + +// bankBalance: Implements "IFunToken.bankBalance" +// +// The "args" populate the following function signature in Solidity: +// +// ```solidity +// function bankBalance( +// address who, +// string calldata bankDenom +// ) external returns (uint256 bankBalance, NibiruAccount memory whoAddrs); +// ``` +func (p precompileFunToken) bankBalance( + start OnRunStartResult, + contract *vm.Contract, +) (bz []byte, err error) { + method, args, ctx := start.Method, start.Args, start.CacheCtx + defer func() { + if err != nil { + err = ErrMethodCalled(method, err) + } + }() + if err := assertContractQuery(contract); err != nil { + return bz, err + } + + addrEth, addrBech32, bankDenom, err := p.parseArgsBankBalance(args) + bankBal := p.evmKeeper.Bank.GetBalance(ctx, addrBech32, bankDenom).Amount.BigInt() + + return method.Outputs.Pack([]any{ + bankBal, + struct { + EthAddr gethcommon.Address `json:"ethAddr"` + Bech32Addr string `json:"bech32Addr"` + }{ + EthAddr: addrEth, + Bech32Addr: addrBech32.String(), + }, + }...) +} + +func (p precompileFunToken) parseArgsBankBalance(args []any) ( + addrEth gethcommon.Address, + addrBech32 sdk.AccAddress, + bankDenom string, + err error, +) { + if e := assertNumArgs(args, 2); e != nil { + err = e + return + } + + argIdx := 0 + who, ok := args[argIdx].(gethcommon.Address) + if !ok { + err = ErrArgTypeValidation("bytes who", args[argIdx]) + return + } + req := &evm.QueryEthAccountRequest{Address: who.Hex()} + _, e := req.Validate() + if e != nil { + err = e + return + } + addrEth = gethcommon.HexToAddress(req.Address) + addrBech32 = eth.EthAddrToNibiruAddr(addrEth) + + argIdx++ + bankDenom, ok = args[argIdx].(string) + if !ok { + err = ErrArgTypeValidation("string bankDenom", args[argIdx]) + return + } + if e := sdk.ValidateDenom(bankDenom); e != nil { + err = e + return + } + + return addrEth, addrBech32, bankDenom, nil +} + +// whoAmI: Implements "IFunToken.whoAmI" +// +// The "args" populate the following function signature in Solidity: +// +// ```solidity +// function whoAmI( +// string calldata who +// ) external returns (NibiruAccount memory whoAddrs); +// ``` +func (p precompileFunToken) whoAmI( + start OnRunStartResult, + contract *vm.Contract, +) (bz []byte, err error) { + method, args := start.Method, start.Args + defer func() { + if err != nil { + err = ErrMethodCalled(method, err) + } + }() + if err := assertContractQuery(contract); err != nil { + return bz, err + } + + addrEth, addrBech32, err := p.parseArgsWhoAmI(args) + if err != nil { + return bz, err + } + + return method.Outputs.Pack([]any{ + struct { + EthAddr gethcommon.Address `json:"ethAddr"` + Bech32Addr string `json:"bech32Addr"` + }{ + EthAddr: addrEth, + Bech32Addr: addrBech32.String(), + }, + }...) +} + +func (p precompileFunToken) parseArgsWhoAmI(args []any) ( + addrEth gethcommon.Address, + addrBech32 sdk.AccAddress, + err error, +) { + if e := assertNumArgs(args, 1); e != nil { + err = e + return + } + + argIdx := 0 + who, ok := args[argIdx].(string) + if !ok { + err = ErrArgTypeValidation("string calldata who", args[argIdx]) + return + } + req := &evm.QueryEthAccountRequest{Address: who} + isBech32, e := req.Validate() + if e != nil { + err = e + return + } + if isBech32 { + addrBech32 = sdk.MustAccAddressFromBech32(req.Address) + addrEth = eth.NibiruAddrToEthAddr(addrBech32) + } else { + addrEth = gethcommon.HexToAddress(req.Address) + addrBech32 = eth.EthAddrToNibiruAddr(addrEth) + } + return addrEth, addrBech32, nil +} diff --git a/x/evm/precompile/funtoken_test.go b/x/evm/precompile/funtoken_test.go index 6a6fe29d7..7645a26e5 100644 --- a/x/evm/precompile/funtoken_test.go +++ b/x/evm/precompile/funtoken_test.go @@ -1,6 +1,7 @@ package precompile_test import ( + "fmt" "math/big" "testing" @@ -47,25 +48,25 @@ func (s *FuntokenSuite) TestFailToPackABI() { }{ { name: "wrong amount of call args", - methodName: string(precompile.FunTokenMethod_BankSend), + methodName: string(precompile.FunTokenMethod_sendToBank), callArgs: []any{"nonsense", "args here", "to see if", "precompile is", "called"}, wantError: "argument count mismatch: got 5 for 3", }, { name: "wrong type for address", - methodName: string(precompile.FunTokenMethod_BankSend), + methodName: string(precompile.FunTokenMethod_sendToBank), callArgs: []any{"nonsense", "foo", "bar"}, wantError: "abi: cannot use string as type array as argument", }, { name: "wrong type for amount", - methodName: string(precompile.FunTokenMethod_BankSend), + methodName: string(precompile.FunTokenMethod_sendToBank), callArgs: []any{gethcommon.HexToAddress("0x7D4B7B8CA7E1a24928Bb96D59249c7a5bd1DfBe6"), "foo", testutil.AccAddress().String()}, wantError: "abi: cannot use string as type ptr as argument", }, { name: "wrong type for recipient", - methodName: string(precompile.FunTokenMethod_BankSend), + methodName: string(precompile.FunTokenMethod_sendToBank), callArgs: []any{gethcommon.HexToAddress("0x7D4B7B8CA7E1a24928Bb96D59249c7a5bd1DfBe6"), big.NewInt(1), 111}, wantError: "abi: cannot use int as type string as argument", }, @@ -88,6 +89,68 @@ func (s *FuntokenSuite) TestFailToPackABI() { } } +func (s *FuntokenSuite) TestWhoAmI() { + deps := evmtest.NewTestDeps() + + for accIdx, acc := range []evmtest.EthPrivKeyAcc{ + deps.Sender, evmtest.NewEthPrivAcc(), + } { + s.T().Logf("test account %d, use both address formats", accIdx) + callWhoAmIWithArg := func(arg string) (evmResp *evm.MsgEthereumTxResponse, err error) { + fmt.Printf("arg: %s", arg) + return deps.EvmKeeper.CallContract( + deps.Ctx, + embeds.SmartContract_FunToken.ABI, + deps.Sender.EthAddr, + &precompile.PrecompileAddr_FunToken, + false, + keeper.Erc20GasLimitExecute, + "whoAmI", + []any{ + arg, // who + }..., + ) + } + for _, arg := range []string{acc.NibiruAddr.String(), acc.EthAddr.Hex()} { + evmResp, err := callWhoAmIWithArg(arg) + s.Require().NoError(err, evmResp) + gotAddrEth, gotAddrBech32, err := new(FunTokenWhoAmIReturn).ParseFromResp(evmResp) + s.NoError(err) + s.Equal(acc.EthAddr.Hex(), gotAddrEth.Hex()) + s.Equal(acc.NibiruAddr.String(), gotAddrBech32) + } + // Sad path check + evmResp, err := callWhoAmIWithArg("not_an_address") + s.Require().ErrorContains( + err, "could not parse address as Nibiru Bech32 or Ethereum hexadecimal", evmResp, + ) + } +} + +// FunTokenWhoAmIReturn holds the return values from the "IFuntoken.whoAmI" +// method. The return bytes from successful calls of that method can be ABI +// unpacked into this struct. +type FunTokenWhoAmIReturn struct { + NibiruAcc struct { + EthAddr gethcommon.Address `abi:"ethAddr"` + Bech32Addr string `abi:"bech32Addr"` + } `abi:"whoAddrs"` +} + +func (out FunTokenWhoAmIReturn) ParseFromResp( + evmResp *evm.MsgEthereumTxResponse, +) (ethAddr gethcommon.Address, bech32Addr string, err error) { + err = embeds.SmartContract_FunToken.ABI.UnpackIntoInterface( + &out, + "whoAmI", + evmResp.Ret, + ) + if err != nil { + return + } + return out.NibiruAcc.EthAddr, out.NibiruAcc.Bech32Addr, nil +} + func (s *FuntokenSuite) TestHappyPath() { deps := evmtest.NewTestDeps() @@ -108,6 +171,30 @@ func (s *FuntokenSuite) TestHappyPath() { sdk.NewCoins(sdk.NewCoin(s.funtoken.BankDenom, sdk.NewInt(69_420))), )) + s.Run("IFunToken.bankBalance", func() { + s.Require().NotEmpty(funtoken.BankDenom) + evmResp, err := deps.EvmKeeper.CallContract( + deps.Ctx, + embeds.SmartContract_FunToken.ABI, + deps.Sender.EthAddr, + &precompile.PrecompileAddr_FunToken, + false, + keeper.Erc20GasLimitExecute, + "bankBalance", + []any{ + deps.Sender.EthAddr, // who + funtoken.BankDenom, // bankDenom + }..., + ) + s.Require().NoError(err, evmResp) + + bal, ethAddr, bech32Addr, err := new(FunTokenBankBalanceReturn).ParseFromResp(evmResp) + s.NoError(err) + s.Require().Equal("69420", bal.String()) + s.Equal(deps.Sender.EthAddr.Hex(), ethAddr.Hex()) + s.Equal(deps.Sender.NibiruAddr.String(), bech32Addr) + }) + _, err := deps.EvmKeeper.ConvertCoinToEvm( sdk.WrapSDKContext(deps.Ctx), &evm.MsgConvertCoinToEvm{ @@ -132,7 +219,7 @@ func (s *FuntokenSuite) TestHappyPath() { s.T().Log("Send NIBI (FunToken) using precompile") amtToSend := int64(420) callArgs := []any{erc20, big.NewInt(amtToSend), randomAcc.String()} - input, err := embeds.SmartContract_FunToken.ABI.Pack(string(precompile.FunTokenMethod_BankSend), callArgs...) + input, err := embeds.SmartContract_FunToken.ABI.Pack(string(precompile.FunTokenMethod_sendToBank), callArgs...) s.NoError(err) deps.ResetGasMeter() @@ -162,17 +249,104 @@ func (s *FuntokenSuite) TestHappyPath() { var sentAmt *big.Int err = embeds.SmartContract_FunToken.ABI.UnpackIntoInterface( &sentAmt, - string(precompile.FunTokenMethod_BankSend), + string(precompile.FunTokenMethod_sendToBank), ethTxResp.Ret, ) s.NoError(err) s.Require().Equal("420", sentAmt.String()) + + s.Run("IFuntoken.balance", func() { + evmResp, err := deps.EvmKeeper.CallContract( + deps.Ctx, + embeds.SmartContract_FunToken.ABI, + deps.Sender.EthAddr, + &precompile.PrecompileAddr_FunToken, + false, + keeper.Erc20GasLimitExecute, + "balance", + []any{ + deps.Sender.EthAddr, // who + erc20, // funtoken + }..., + ) + s.Require().NoError(err, evmResp) + + bals, err := new(FunTokenBalanceReturn).ParseFromResp(evmResp) + s.NoError(err) + s.Equal(funtoken.Erc20Addr, bals.FunToken.Erc20Addr) + s.Equal(funtoken.BankDenom, bals.FunToken.BankDenom) + s.Equal(deps.Sender.EthAddr, bals.Account) + s.Equal("0", bals.BalanceBank.String()) + s.Equal("69000", bals.BalanceERC20.String()) + }) +} + +// FunTokenBalanceReturn holds the return values from the "IFuntoken.balance" +// method. The return bytes from successful calls of that method can be ABI +// unpacked into this struct. +type FunTokenBalanceReturn struct { + Erc20Bal *big.Int `abi:"erc20Balance"` + BankBal *big.Int `abi:"bankBalance"` + Token struct { + Erc20 gethcommon.Address `abi:"erc20"` + BankDenom string `abi:"bankDenom"` + } `abi:"token"` + NibiruAcc struct { + EthAddr gethcommon.Address `abi:"ethAddr"` + Bech32Addr string `abi:"bech32Addr"` + } `abi:"whoAddrs"` +} + +func (out FunTokenBalanceReturn) ParseFromResp( + evmResp *evm.MsgEthereumTxResponse, +) (bals evmtest.FunTokenBalanceAssert, err error) { + err = embeds.SmartContract_FunToken.ABI.UnpackIntoInterface( + &out, + "balance", + evmResp.Ret, + ) + if err != nil { + return + } + return evmtest.FunTokenBalanceAssert{ + FunToken: evm.FunToken{ + Erc20Addr: eth.EIP55Addr{Address: out.Token.Erc20}, + BankDenom: out.Token.BankDenom, + }, + Account: out.NibiruAcc.EthAddr, + BalanceBank: out.BankBal, + BalanceERC20: out.Erc20Bal, + }, nil +} + +// FunTokenBankBalanceReturn holds the return values from the +// "IFuntoken.bankBalance" method. The return bytes from successful calls of that +// method can be ABI unpacked into this struct. +type FunTokenBankBalanceReturn struct { + BankBal *big.Int `abi:"bankBalance"` + NibiruAcc struct { + EthAddr gethcommon.Address `abi:"ethAddr"` + Bech32Addr string `abi:"bech32Addr"` + } `abi:"whoAddrs"` +} + +func (out FunTokenBankBalanceReturn) ParseFromResp( + evmResp *evm.MsgEthereumTxResponse, +) (bal *big.Int, ethAddr gethcommon.Address, bech32Addr string, err error) { + err = embeds.SmartContract_FunToken.ABI.UnpackIntoInterface( + &out, + "bankBalance", + evmResp.Ret, + ) + if err != nil { + return + } + return out.BankBal, out.NibiruAcc.EthAddr, out.NibiruAcc.Bech32Addr, nil } func (s *FuntokenSuite) TestPrecompileLocalGas() { deps := s.deps randomAcc := testutil.AccAddress() - deployResp, err := evmtest.DeployContract( &deps, embeds.SmartContract_TestFunTokenPrecompileLocalGas, s.funtoken.Erc20Addr.Address, @@ -201,49 +375,46 @@ func (s *FuntokenSuite) TestPrecompileLocalGas() { ) s.Require().NoError(err) - s.deps.ResetGasMeter() - s.T().Log("Happy: callBankSend with default gas") + s.deps.ResetGasMeter() _, err = deps.EvmKeeper.CallContract( deps.Ctx, embeds.SmartContract_TestFunTokenPrecompileLocalGas.ABI, deps.Sender.EthAddr, &contractAddr, true, - precompile.FunTokenGasLimitBankSend, + evmtest.FunTokenGasLimitSendToEvm, "callBankSend", big.NewInt(1), randomAcc.String(), ) s.Require().NoError(err) - s.deps.ResetGasMeter() - s.T().Log("Happy: callBankSend with local gas - sufficient gas amount") + s.deps.ResetGasMeter() _, err = deps.EvmKeeper.CallContract( deps.Ctx, embeds.SmartContract_TestFunTokenPrecompileLocalGas.ABI, deps.Sender.EthAddr, &contractAddr, true, - precompile.FunTokenGasLimitBankSend, // gasLimit for the entire call + evmtest.FunTokenGasLimitSendToEvm, // gasLimit for the entire call "callBankSendLocalGas", big.NewInt(1), // erc20 amount randomAcc.String(), // to - big.NewInt(int64(precompile.FunTokenGasLimitBankSend)), // customGas + big.NewInt(int64(evmtest.FunTokenGasLimitSendToEvm)), // customGas ) s.Require().NoError(err) - s.deps.ResetGasMeter() - s.T().Log("Sad: callBankSend with local gas - insufficient gas amount") + s.deps.ResetGasMeter() _, err = deps.EvmKeeper.CallContract( deps.Ctx, embeds.SmartContract_TestFunTokenPrecompileLocalGas.ABI, deps.Sender.EthAddr, &contractAddr, true, - precompile.FunTokenGasLimitBankSend, // gasLimit for the entire call + evmtest.FunTokenGasLimitSendToEvm, // gasLimit for the entire call "callBankSendLocalGas", big.NewInt(1), // erc20 amount randomAcc.String(), // to diff --git a/x/evm/precompile/oracle.go b/x/evm/precompile/oracle.go index 6aae97bcc..17894da56 100644 --- a/x/evm/precompile/oracle.go +++ b/x/evm/precompile/oracle.go @@ -50,11 +50,19 @@ func (p precompileOracle) Run( switch PrecompileMethod(method.Name) { case OracleMethod_queryExchangeRate: - return p.queryExchangeRate(ctx, method, args) + bz, err = p.queryExchangeRate(ctx, method, args) default: + // Note that this code path should be impossible to reach since + // "[decomposeInput]" parses methods directly from the ABI. err = fmt.Errorf("invalid method called with name \"%s\"", method.Name) return } + if err != nil { + return nil, err + } + + contract.UseGas(startResult.CacheCtx.GasMeter().GasConsumed()) + return bz, err } func PrecompileOracle(keepers keepers.PublicKeepers) vm.PrecompiledContract { @@ -93,7 +101,7 @@ func (p precompileOracle) parseQueryExchangeRateArgs(args []any) ( pair string, err error, ) { - if e := assertNumArgs(len(args), 1); e != nil { + if e := assertNumArgs(args, 1); e != nil { err = e return } diff --git a/x/evm/precompile/precompile.go b/x/evm/precompile/precompile.go index cf3056a5c..2c1f754e7 100644 --- a/x/evm/precompile/precompile.go +++ b/x/evm/precompile/precompile.go @@ -222,7 +222,10 @@ var isMutation map[PrecompileMethod]bool = map[PrecompileMethod]bool{ WasmMethod_query: false, WasmMethod_queryRaw: false, - FunTokenMethod_BankSend: true, + FunTokenMethod_sendToBank: true, + FunTokenMethod_balance: false, + FunTokenMethod_bankBalance: false, + FunTokenMethod_whoAmI: false, OracleMethod_queryExchangeRate: false, } diff --git a/x/evm/precompile/wasm.go b/x/evm/precompile/wasm.go index c42df76eb..dfc5d5042 100644 --- a/x/evm/precompile/wasm.go +++ b/x/evm/precompile/wasm.go @@ -64,7 +64,7 @@ func (p precompileWasm) Run( bz, err = p.queryRaw(startResult, contract) default: // Note that this code path should be impossible to reach since - // "DecomposeInput" parses methods directly from the ABI. + // "[decomposeInput]" parses methods directly from the ABI. err = fmt.Errorf("invalid method called with name \"%s\"", startResult.Method.Name) return } @@ -73,8 +73,10 @@ func (p precompileWasm) Run( } // Gas consumed by a local gas meter + // The reason it's unnecessary to check for a success value is because + // GasConsumed is guaranteed to be less than the contract.Gas because the gas + // meter was initialized.... contract.UseGas(startResult.CacheCtx.GasMeter().GasConsumed()) - return bz, err } @@ -147,7 +149,7 @@ func (p precompileWasm) execute( return nil, err } - wasmContract, msgArgsBz, funds, err := p.parseExecuteArgs(args) + wasmContract, msgArgsBz, funds, err := p.parseArgsWasmExecute(args) if err != nil { err = ErrInvalidArgs(err) return @@ -185,7 +187,7 @@ func (p precompileWasm) query( return bz, err } - wasmContract, req, err := p.parseQueryArgs(args) + wasmContract, req, err := p.parseArgsWasmQuery(args) if err != nil { err = ErrInvalidArgs(err) return @@ -232,7 +234,7 @@ func (p precompileWasm) instantiate( } callerBech32 := eth.EthAddrToNibiruAddr(caller) - txMsg, err := p.parseInstantiateArgs(args, callerBech32.String()) + txMsg, err := p.parseArgsWasmInstantiate(args, callerBech32.String()) if err != nil { err = ErrInvalidArgs(err) return @@ -282,7 +284,7 @@ func (p precompileWasm) executeMulti( return nil, err } - wasmExecMsgs, err := p.parseExecuteMultiArgs(args) + wasmExecMsgs, err := p.parseArgsWasmExecuteMulti(args) if err != nil { err = ErrInvalidArgs(err) return @@ -351,13 +353,13 @@ func (p precompileWasm) queryRaw( return bz, err } - if e := assertNumArgs(len(args), 2); e != nil { + if e := assertNumArgs(args, 2); e != nil { err = e return } argIdx := 0 - wasmContract, e := parseContractAddrArg(args[argIdx]) + wasmContract, e := parseArgContractAddr(args[argIdx]) if e != nil { err = e return diff --git a/x/evm/precompile/wasm_parse.go b/x/evm/precompile/wasm_parse.go index 97a532753..270050798 100644 --- a/x/evm/precompile/wasm_parse.go +++ b/x/evm/precompile/wasm_parse.go @@ -51,7 +51,7 @@ func parseFundsArg(arg any) (funds sdk.Coins, err error) { } // Parses [sdk.AccAddress] from a "string" solidity argument: -func parseContractAddrArg(arg any) (addr sdk.AccAddress, err error) { +func parseArgContractAddr(arg any) (addr sdk.AccAddress, err error) { addrStr, ok := arg.(string) if !ok { err = ErrArgTypeValidation("string contractAddr", arg) @@ -67,11 +67,11 @@ func parseContractAddrArg(arg any) (addr sdk.AccAddress, err error) { return addr, nil } -func (p precompileWasm) parseInstantiateArgs(args []any, sender string) ( +func (p precompileWasm) parseArgsWasmInstantiate(args []any, sender string) ( txMsg wasm.MsgInstantiateContract, err error, ) { - if e := assertNumArgs(len(args), 5); e != nil { + if e := assertNumArgs(args, 5); e != nil { err = e return } @@ -124,13 +124,13 @@ func (p precompileWasm) parseInstantiateArgs(args []any, sender string) ( return txMsg, txMsg.ValidateBasic() } -func (p precompileWasm) parseExecuteArgs(args []any) ( +func (p precompileWasm) parseArgsWasmExecute(args []any) ( wasmContract sdk.AccAddress, msgArgs []byte, funds sdk.Coins, err error, ) { - if e := assertNumArgs(len(args), 3); e != nil { + if e := assertNumArgs(args, 3); e != nil { err = e return } @@ -174,18 +174,18 @@ func (p precompileWasm) parseExecuteArgs(args []any) ( return contractAddr, msgArgs, funds, nil } -func (p precompileWasm) parseQueryArgs(args []any) ( +func (p precompileWasm) parseArgsWasmQuery(args []any) ( wasmContract sdk.AccAddress, req wasm.RawContractMessage, err error, ) { - if e := assertNumArgs(len(args), 2); e != nil { + if e := assertNumArgs(args, 2); e != nil { err = e return } argsIdx := 0 - wasmContract, e := parseContractAddrArg(args[argsIdx]) + wasmContract, e := parseArgContractAddr(args[argsIdx]) if e != nil { err = e return @@ -206,7 +206,7 @@ func (p precompileWasm) parseQueryArgs(args []any) ( return wasmContract, req, nil } -func (p precompileWasm) parseExecuteMultiArgs(args []any) ( +func (p precompileWasm) parseArgsWasmExecuteMulti(args []any) ( wasmExecMsgs []struct { ContractAddr string `json:"contractAddr"` MsgArgs []byte `json:"msgArgs"` @@ -217,7 +217,7 @@ func (p precompileWasm) parseExecuteMultiArgs(args []any) ( }, err error, ) { - if e := assertNumArgs(len(args), 1); e != nil { + if e := assertNumArgs(args, 1); e != nil { err = e return }