diff --git a/app/ibc-hooks/ack_test.go b/app/ibc-hooks/ack_test.go index 31f499a..4850a93 100644 --- a/app/ibc-hooks/ack_test.go +++ b/app/ibc-hooks/ack_test.go @@ -51,7 +51,7 @@ func Test_onAckIcs20Packet_memo(t *testing.T) { codeBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) - _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil) + _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil, nil) require.NoError(t, err) abi, err := counter.CounterMetaData.GetAbi() @@ -87,7 +87,7 @@ func Test_onAckIcs20Packet_memo(t *testing.T) { // check the contract state queryInputBz, err := abi.Pack("count") require.NoError(t, err) - queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil) + queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(0).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) @@ -102,7 +102,7 @@ func Test_onAckIcs20Packet_memo(t *testing.T) { require.NoError(t, err) // check the contract state; increased by 99 if ack is success - queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil) + queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(99).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) @@ -114,7 +114,7 @@ func Test_onAckIcs20Packet_memo(t *testing.T) { require.NoError(t, err) // check the contract state; increased by 1 if ack is failed - queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil) + queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(100).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) @@ -157,7 +157,7 @@ func Test_onAckPacket_memo_ICS721(t *testing.T) { codeBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) - _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil) + _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil, nil) require.NoError(t, err) abi, err := counter.CounterMetaData.GetAbi() @@ -197,7 +197,7 @@ func Test_onAckPacket_memo_ICS721(t *testing.T) { // check the contract state queryInputBz, err := abi.Pack("count") require.NoError(t, err) - queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil) + queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(0).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) @@ -212,7 +212,7 @@ func Test_onAckPacket_memo_ICS721(t *testing.T) { require.NoError(t, err) // check the contract state; increased by 99 if ack is success - queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil) + queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(99).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) @@ -224,7 +224,7 @@ func Test_onAckPacket_memo_ICS721(t *testing.T) { require.NoError(t, err) // check the contract state; increased by 1 if ack is failed - queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil) + queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(100).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) diff --git a/app/ibc-hooks/receive_test.go b/app/ibc-hooks/receive_test.go index d140d20..d2485a5 100644 --- a/app/ibc-hooks/receive_test.go +++ b/app/ibc-hooks/receive_test.go @@ -52,7 +52,7 @@ func Test_onReceiveIcs20Packet_memo(t *testing.T) { codeBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) - _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil) + _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil, nil) require.NoError(t, err) abi, err := counter.CounterMetaData.GetAbi() @@ -105,7 +105,7 @@ func Test_onReceiveIcs20Packet_memo(t *testing.T) { require.NoError(t, err) // check the contract state - queryRes, err := input.EVMKeeper.EVMStaticCall(ctx, evmAddr, contractAddr, queryInputBz) + queryRes, err := input.EVMKeeper.EVMStaticCall(ctx, evmAddr, contractAddr, queryInputBz, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(1).Bytes32(), [32]byte(queryRes)) @@ -114,7 +114,7 @@ func Test_onReceiveIcs20Packet_memo(t *testing.T) { require.NoError(t, err) queryInputBz, err = input.EVMKeeper.ERC20Keeper().GetERC20ABI().Pack("allowance", common.BytesToAddress(intermediateSender.Bytes()), contractAddr) require.NoError(t, err) - queryRes, err = input.EVMKeeper.EVMStaticCall(ctx, evmtypes.StdAddress, erc20Addr, queryInputBz) + queryRes, err = input.EVMKeeper.EVMStaticCall(ctx, evmtypes.StdAddress, erc20Addr, queryInputBz, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(10000).Bytes32(), [32]byte(queryRes)) } @@ -155,7 +155,7 @@ func Test_onReceivePacket_memo_ICS721(t *testing.T) { codeBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) - _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil) + _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil, nil) require.NoError(t, err) abi, err := counter.CounterMetaData.GetAbi() @@ -222,7 +222,7 @@ func Test_onReceivePacket_memo_ICS721(t *testing.T) { require.NoError(t, err) // check the contract state - queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil) + queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(1).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) @@ -234,7 +234,7 @@ func Test_onReceivePacket_memo_ICS721(t *testing.T) { require.NoError(t, err) queryInputBz, err = input.EVMKeeper.ERC721Keeper().GetERC721ABI().Pack("getApproved", tokenId) require.NoError(t, err) - queryRes, err = input.EVMKeeper.EVMStaticCall(ctx, evmtypes.StdAddress, erc721Addr, queryInputBz) + queryRes, err = input.EVMKeeper.EVMStaticCall(ctx, evmtypes.StdAddress, erc721Addr, queryInputBz, nil) require.NoError(t, err) require.Equal(t, contractAddr.Bytes(), common.HexToAddress(hexutil.Encode(queryRes)).Bytes()) } @@ -248,7 +248,7 @@ func Test_onReceivePacket_memo_ICS721_Wasm(t *testing.T) { codeBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) - _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil) + _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil, nil) require.NoError(t, err) abi, err := counter.CounterMetaData.GetAbi() @@ -316,7 +316,7 @@ func Test_onReceivePacket_memo_ICS721_Wasm(t *testing.T) { require.NoError(t, err) // check the contract state - queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil) + queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(1).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) @@ -328,7 +328,7 @@ func Test_onReceivePacket_memo_ICS721_Wasm(t *testing.T) { require.NoError(t, err) queryInputBz, err = input.EVMKeeper.ERC721Keeper().GetERC721ABI().Pack("getApproved", tokenId) require.NoError(t, err) - queryRes, err = input.EVMKeeper.EVMStaticCall(ctx, evmtypes.StdAddress, erc721Addr, queryInputBz) + queryRes, err = input.EVMKeeper.EVMStaticCall(ctx, evmtypes.StdAddress, erc721Addr, queryInputBz, nil) require.NoError(t, err) require.Equal(t, contractAddr.Bytes(), common.HexToAddress(hexutil.Encode(queryRes)).Bytes()) } diff --git a/app/ibc-hooks/timeout_test.go b/app/ibc-hooks/timeout_test.go index b11b736..7e18e9f 100644 --- a/app/ibc-hooks/timeout_test.go +++ b/app/ibc-hooks/timeout_test.go @@ -48,7 +48,7 @@ func Test_onTimeoutIcs20Packet_memo(t *testing.T) { codeBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) - _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil) + _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil, nil) require.NoError(t, err) abi, err := counter.CounterMetaData.GetAbi() @@ -81,7 +81,7 @@ func Test_onTimeoutIcs20Packet_memo(t *testing.T) { // check the contract state queryInputBz, err := abi.Pack("count") require.NoError(t, err) - queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil) + queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(0).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) @@ -96,7 +96,7 @@ func Test_onTimeoutIcs20Packet_memo(t *testing.T) { require.NoError(t, err) // check the contract state; increased by 99 - queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil) + queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(99).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) @@ -136,7 +136,7 @@ func Test_onTimeoutPacket_memo_ICS721(t *testing.T) { codeBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) - _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil) + _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, evmAddr, codeBz, nil, nil) require.NoError(t, err) abi, err := counter.CounterMetaData.GetAbi() @@ -169,7 +169,7 @@ func Test_onTimeoutPacket_memo_ICS721(t *testing.T) { // check the contract state queryInputBz, err := abi.Pack("count") require.NoError(t, err) - queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil) + queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(0).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) @@ -184,7 +184,7 @@ func Test_onTimeoutPacket_memo_ICS721(t *testing.T) { require.NoError(t, err) // check the contract state; increased by 99 - queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil) + queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, evmAddr, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(99).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) diff --git a/integration-tests/erc721_transfer_test.go b/integration-tests/erc721_transfer_test.go index d9e5d96..fea8fff 100644 --- a/integration-tests/erc721_transfer_test.go +++ b/integration-tests/erc721_transfer_test.go @@ -135,7 +135,7 @@ func (suite *KeeperTestSuite) CreateNftClass( inputBz, err := nftKeeper.ABI.Pack("", name, name) suite.Require().NoError(err) - _, contractAddr, _, err := evmKeeper.EVMCreate(ctx, createAccountAddr, append(nftKeeper.ERC721Bin, inputBz...), nil) + _, contractAddr, _, err := evmKeeper.EVMCreate(ctx, createAccountAddr, append(nftKeeper.ERC721Bin, inputBz...), nil, nil) suite.Require().NoError(err) classId, err := evmtypes.ClassIdFromCollectionAddress(endpoint.Chain.GetContext(), nftKeeper, contractAddr) @@ -166,7 +166,7 @@ func (suite *KeeperTestSuite) MintNft( contractAddr, err := evmtypes.ContractAddressFromClassId(ctx, nftKeeper, classId) suite.Require().NoError(err) - _, _, err = nftKeeper.EVMCall(ctx, createAccountAddr, contractAddr, inputBz, nil) + _, _, err = nftKeeper.EVMCall(ctx, createAccountAddr, contractAddr, inputBz, nil, nil) suite.Require().NoError(err) } diff --git a/proto/minievm/evm/v1/tx.proto b/proto/minievm/evm/v1/tx.proto index 7248758..d89e8c0 100644 --- a/proto/minievm/evm/v1/tx.proto +++ b/proto/minievm/evm/v1/tx.proto @@ -42,6 +42,8 @@ message MsgCreate { (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; + // AccessList is a predefined list of Ethereum addresses and their corresponding storage slots that a transaction will interact with during its execution. can be none + repeated AccessTuple access_list = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // MsgCreateResponse defines the Msg/Create response type. @@ -79,6 +81,9 @@ message MsgCreate2 { (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; + + // AccessList is a predefined list of Ethereum addresses and their corresponding storage slots that a transaction will interact with during its execution. can be none + repeated AccessTuple access_list = 5 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // MsgCreate2Response defines the Msg/Create2 response type. @@ -117,6 +122,9 @@ message MsgCall { (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; + + // AccessList is a predefined list of Ethereum addresses and their corresponding storage slots that a transaction will interact with during its execution. can be none + repeated AccessTuple access_list = 5 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } // MsgCallResponse defines the Msg/Call response type. diff --git a/proto/minievm/evm/v1/types.proto b/proto/minievm/evm/v1/types.proto index ee9565a..4c0e372 100644 --- a/proto/minievm/evm/v1/types.proto +++ b/proto/minievm/evm/v1/types.proto @@ -59,3 +59,12 @@ message Log { // supplied by the contract, usually ABI-encoded string data = 3; } + +message AccessTuple { + // Address of the contract that will be accessed during the transaction execution. + string address = 1; + + // A list of storage keys that the transaction will interact with within the specified contract. + // These keys represent specific storage slots in the contract's storage that are accessed or modified. + repeated string storage_keys = 2; +} \ No newline at end of file diff --git a/x/evm/keeper/context.go b/x/evm/keeper/context.go index 5fca15e..3782e3b 100644 --- a/x/evm/keeper/context.go +++ b/x/evm/keeper/context.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/tracing" + coretype "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/trie/utils" @@ -198,12 +199,12 @@ func (k Keeper) CreateEVM(ctx context.Context, caller common.Address, tracer *tr } // EVMStaticCall executes an EVM call with the given input data in static mode. -func (k Keeper) EVMStaticCall(ctx context.Context, caller common.Address, contractAddr common.Address, inputBz []byte) ([]byte, error) { - return k.EVMStaticCallWithTracer(ctx, caller, contractAddr, inputBz, nil) +func (k Keeper) EVMStaticCall(ctx context.Context, caller common.Address, contractAddr common.Address, inputBz []byte, accessList coretype.AccessList) ([]byte, error) { + return k.EVMStaticCallWithTracer(ctx, caller, contractAddr, inputBz, accessList, nil) } // EVMStaticCallWithTracer executes an EVM call with the given input data and tracer in static mode. -func (k Keeper) EVMStaticCallWithTracer(ctx context.Context, caller common.Address, contractAddr common.Address, inputBz []byte, tracer *tracing.Hooks) ([]byte, error) { +func (k Keeper) EVMStaticCallWithTracer(ctx context.Context, caller common.Address, contractAddr common.Address, inputBz []byte, accessList coretype.AccessList, tracer *tracing.Hooks) ([]byte, error) { ctx, evm, err := k.CreateEVM(ctx, caller, tracer) if err != nil { return nil, err @@ -211,9 +212,8 @@ func (k Keeper) EVMStaticCallWithTracer(ctx context.Context, caller common.Addre sdkCtx := sdk.UnwrapSDKContext(ctx) gasBalance := k.computeGasLimit(sdkCtx) - rules := evm.ChainConfig().Rules(evm.Context.BlockNumber, evm.Context.Random != nil, evm.Context.Time) - evm.StateDB.Prepare(rules, caller, types.NullAddress, &contractAddr, append(vm.ActivePrecompiles(rules), k.precompiles.toAddrs()...), nil) + evm.StateDB.Prepare(rules, caller, types.NullAddress, &contractAddr, append(vm.ActivePrecompiles(rules), k.precompiles.toAddrs()...), accessList) retBz, gasRemaining, err := evm.StaticCall( vm.AccountRef(caller), @@ -233,12 +233,12 @@ func (k Keeper) EVMStaticCallWithTracer(ctx context.Context, caller common.Addre } // EVMCall executes an EVM call with the given input data. -func (k Keeper) EVMCall(ctx context.Context, caller common.Address, contractAddr common.Address, inputBz []byte, value *uint256.Int) ([]byte, types.Logs, error) { - return k.EVMCallWithTracer(ctx, caller, contractAddr, inputBz, value, nil) +func (k Keeper) EVMCall(ctx context.Context, caller common.Address, contractAddr common.Address, inputBz []byte, value *uint256.Int, accessList coretype.AccessList) ([]byte, types.Logs, error) { + return k.EVMCallWithTracer(ctx, caller, contractAddr, inputBz, value, accessList, nil) } // EVMCallWithTracer executes an EVM call with the given input data and tracer. -func (k Keeper) EVMCallWithTracer(ctx context.Context, caller common.Address, contractAddr common.Address, inputBz []byte, value *uint256.Int, tracer *tracing.Hooks) ([]byte, types.Logs, error) { +func (k Keeper) EVMCallWithTracer(ctx context.Context, caller common.Address, contractAddr common.Address, inputBz []byte, value *uint256.Int, accessList coretype.AccessList, tracer *tracing.Hooks) ([]byte, types.Logs, error) { ctx, evm, err := k.CreateEVM(ctx, caller, tracer) if err != nil { return nil, nil, err @@ -251,7 +251,7 @@ func (k Keeper) EVMCallWithTracer(ctx context.Context, caller common.Address, co } rules := evm.ChainConfig().Rules(evm.Context.BlockNumber, evm.Context.Random != nil, evm.Context.Time) - evm.StateDB.Prepare(rules, caller, types.NullAddress, &contractAddr, append(vm.ActivePrecompiles(rules), k.precompiles.toAddrs()...), nil) + evm.StateDB.Prepare(rules, caller, types.NullAddress, &contractAddr, append(vm.ActivePrecompiles(rules), k.precompiles.toAddrs()...), accessList) retBz, gasRemaining, err := evm.Call( vm.AccountRef(caller), @@ -313,19 +313,19 @@ func (k Keeper) EVMCallWithTracer(ctx context.Context, caller common.Address, co } // EVMCreate creates a new contract with the given code. -func (k Keeper) EVMCreate(ctx context.Context, caller common.Address, codeBz []byte, value *uint256.Int) ([]byte, common.Address, types.Logs, error) { - return k.EVMCreateWithTracer(ctx, caller, codeBz, value, nil, nil) +func (k Keeper) EVMCreate(ctx context.Context, caller common.Address, codeBz []byte, value *uint256.Int, accessList coretype.AccessList) ([]byte, common.Address, types.Logs, error) { + return k.EVMCreateWithTracer(ctx, caller, codeBz, value, nil, accessList, nil) } // EVMCreate creates a new contract with the given code. -func (k Keeper) EVMCreate2(ctx context.Context, caller common.Address, codeBz []byte, value *uint256.Int, salt uint64) ([]byte, common.Address, types.Logs, error) { - return k.EVMCreateWithTracer(ctx, caller, codeBz, value, &salt, nil) +func (k Keeper) EVMCreate2(ctx context.Context, caller common.Address, codeBz []byte, value *uint256.Int, salt uint64, accessList coretype.AccessList) ([]byte, common.Address, types.Logs, error) { + return k.EVMCreateWithTracer(ctx, caller, codeBz, value, &salt, accessList, nil) } // EVMCreateWithTracer creates a new contract with the given code and tracer. // if salt is nil, it will create a contract with the CREATE opcode. // if salt is not nil, it will create a contract with the CREATE2 opcode. -func (k Keeper) EVMCreateWithTracer(ctx context.Context, caller common.Address, codeBz []byte, value *uint256.Int, salt *uint64, tracer *tracing.Hooks) (retBz []byte, contractAddr common.Address, logs types.Logs, err error) { +func (k Keeper) EVMCreateWithTracer(ctx context.Context, caller common.Address, codeBz []byte, value *uint256.Int, salt *uint64, accessList coretype.AccessList, tracer *tracing.Hooks) (retBz []byte, contractAddr common.Address, logs types.Logs, err error) { ctx, evm, err := k.CreateEVM(ctx, caller, tracer) if err != nil { return nil, common.Address{}, nil, err @@ -338,7 +338,7 @@ func (k Keeper) EVMCreateWithTracer(ctx context.Context, caller common.Address, } rules := evm.ChainConfig().Rules(evm.Context.BlockNumber, evm.Context.Random != nil, evm.Context.Time) - evm.StateDB.Prepare(rules, caller, types.NullAddress, nil, append(vm.ActivePrecompiles(rules), k.precompiles.toAddrs()...), nil) + evm.StateDB.Prepare(rules, caller, types.NullAddress, nil, append(vm.ActivePrecompiles(rules), k.precompiles.toAddrs()...), accessList) var gasRemaining uint64 if salt == nil { diff --git a/x/evm/keeper/context_test.go b/x/evm/keeper/context_test.go index 2bce1db..6112725 100644 --- a/x/evm/keeper/context_test.go +++ b/x/evm/keeper/context_test.go @@ -28,7 +28,7 @@ func Test_Create(t *testing.T) { require.NoError(t, err) caller := common.BytesToAddress(addr.Bytes()) - retBz, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil) + retBz, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil, nil) require.NoError(t, err) require.NotEmpty(t, retBz) require.Len(t, contractAddr, 20) @@ -53,7 +53,7 @@ func Test_CreateWithValue(t *testing.T) { EnableReturnData: true, }, tracerOutput) - retBz, contractAddr, _, err := input.EVMKeeper.EVMCreateWithTracer(ctx, caller, counterBz, uint256.NewInt(100), nil, tracer) + retBz, contractAddr, _, err := input.EVMKeeper.EVMCreateWithTracer(ctx, caller, counterBz, uint256.NewInt(100), nil, nil, tracer) require.NoError(t, err) require.NotEmpty(t, retBz) require.Len(t, contractAddr, 20) @@ -75,7 +75,7 @@ func Test_Call(t *testing.T) { require.NoError(t, err) caller := common.BytesToAddress(addr.Bytes()) - retBz, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil) + retBz, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil, nil) require.NoError(t, err) require.NotEmpty(t, retBz) require.Len(t, contractAddr, 20) @@ -86,7 +86,7 @@ func Test_Call(t *testing.T) { queryInputBz, err := parsed.Pack("count") require.NoError(t, err) - queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil) + queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(0).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) @@ -95,7 +95,7 @@ func Test_Call(t *testing.T) { require.NoError(t, err) // call with value - res, logs, err := input.EVMKeeper.EVMCall(ctx, caller, contractAddr, inputBz, uint256.NewInt(100)) + res, logs, err := input.EVMKeeper.EVMCall(ctx, caller, contractAddr, inputBz, uint256.NewInt(100), nil) require.NoError(t, err) require.Empty(t, res) require.NotEmpty(t, logs) @@ -105,7 +105,7 @@ func Test_Call(t *testing.T) { require.NoError(t, err) require.Equal(t, balance, math.NewInt(100)) - queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil) + queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(1).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) @@ -117,7 +117,7 @@ func Test_Call(t *testing.T) { queryInputBz, err = erc20ABI.Pack("balanceOf", caller) require.NoError(t, err) - _, _, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil) + _, _, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil, nil) require.ErrorContains(t, err, types.ErrReverted.Error()) } @@ -132,7 +132,7 @@ func Test_GetHash(t *testing.T) { require.NoError(t, err) caller := common.BytesToAddress(addr.Bytes()) - retBz, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil) + retBz, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil, nil) require.NoError(t, err) require.NotEmpty(t, retBz) require.Len(t, contractAddr, 20) @@ -155,7 +155,7 @@ func Test_GetHash(t *testing.T) { queryInputBz, err := parsed.Pack("get_blockhash", uint64(100)) require.NoError(t, err) - queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil) + queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, [32]byte{}, [32]byte(queryRes)) require.Empty(t, logs) @@ -164,7 +164,7 @@ func Test_GetHash(t *testing.T) { queryInputBz, err = parsed.Pack("get_blockhash", uint64(101)) require.NoError(t, err) - queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil) + queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, hash101, [32]byte(queryRes)) require.Empty(t, logs) @@ -173,7 +173,7 @@ func Test_GetHash(t *testing.T) { queryInputBz, err = parsed.Pack("get_blockhash", uint64(356)) require.NoError(t, err) - queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil) + queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, hash356, [32]byte(queryRes)) require.Empty(t, logs) @@ -182,7 +182,7 @@ func Test_GetHash(t *testing.T) { queryInputBz, err = parsed.Pack("get_blockhash", uint64(357)) require.NoError(t, err) - queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil) + queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, [32]byte{}, [32]byte(queryRes)) require.Empty(t, logs) diff --git a/x/evm/keeper/erc20.go b/x/evm/keeper/erc20.go index 363d6a2..813c143 100644 --- a/x/evm/keeper/erc20.go +++ b/x/evm/keeper/erc20.go @@ -85,7 +85,7 @@ func (k ERC20Keeper) BurnCoins(ctx context.Context, addr sdk.AccAddress, amount } // ignore the return values - _, _, err = k.EVMCall(ctx, types.StdAddress, contractAddr, inputBz, nil) + _, _, err = k.EVMCall(ctx, types.StdAddress, contractAddr, inputBz, nil, nil) if err != nil { return err } @@ -317,7 +317,7 @@ func (k ERC20Keeper) MintCoins(ctx context.Context, addr sdk.AccAddress, amount } // ignore the return values - _, _, err = k.EVMCall(ctx, types.StdAddress, contractAddr, inputBz, nil) + _, _, err = k.EVMCall(ctx, types.StdAddress, contractAddr, inputBz, nil, nil) if err != nil { return err } @@ -338,7 +338,7 @@ func (k ERC20Keeper) CreateERC20(ctx context.Context, denom string, decimals uin return types.ErrFailedToPackABI.Wrap(err.Error()) } - ret, _, err := k.EVMCall(ctx, types.StdAddress, factoryAddr, inputBz, nil) + ret, _, err := k.EVMCall(ctx, types.StdAddress, factoryAddr, inputBz, nil, nil) if err != nil { return err } @@ -392,7 +392,7 @@ func (k ERC20Keeper) SendCoins(ctx context.Context, fromAddr sdk.AccAddress, toA } // ignore the return values - _, _, err = k.EVMCall(ctx, types.StdAddress, contractAddr, inputBz, nil) + _, _, err = k.EVMCall(ctx, types.StdAddress, contractAddr, inputBz, nil, nil) if err != nil { return err } @@ -407,7 +407,7 @@ func (k ERC20Keeper) balanceOf(ctx context.Context, addr, contractAddr common.Ad return math.ZeroInt(), types.ErrFailedToPackABI.Wrap(err.Error()) } - retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz) + retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz, nil) if err != nil { return math.ZeroInt(), err } @@ -431,7 +431,7 @@ func (k ERC20Keeper) totalSupply(ctx context.Context, contractAddr common.Addres return math.ZeroInt(), types.ErrFailedToPackABI.Wrap(err.Error()) } - retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz) + retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz, nil) if err != nil { return math.ZeroInt(), err } @@ -455,7 +455,7 @@ func (k ERC20Keeper) name(ctx context.Context, contractAddr common.Address) (str return "", types.ErrFailedToPackABI.Wrap(err.Error()) } - retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz) + retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz, nil) if err != nil { return "", err } @@ -479,7 +479,7 @@ func (k ERC20Keeper) symbol(ctx context.Context, contractAddr common.Address) (s return "", types.ErrFailedToPackABI.Wrap(err.Error()) } - retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz) + retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz, nil) if err != nil { return "", err } @@ -515,7 +515,7 @@ func (k ERC20Keeper) Decimals(ctx context.Context, contractAddr common.Address) retBz, err := k.EVMStaticCall( // set the context value to prevent infinite loop sdk.UnwrapSDKContext(ctx).WithValue(types.ContextKeyLoadDecimals, true), - types.NullAddress, contractAddr, inputBz) + types.NullAddress, contractAddr, inputBz, nil) if err != nil { return 0, err } diff --git a/x/evm/keeper/erc20_stores_test.go b/x/evm/keeper/erc20_stores_test.go index fd02c14..ad3ef16 100644 --- a/x/evm/keeper/erc20_stores_test.go +++ b/x/evm/keeper/erc20_stores_test.go @@ -25,7 +25,7 @@ func deployCustomERC20(t *testing.T, ctx sdk.Context, input TestKeepers, caller inputBz, err := abi.Pack("", denom, denom, uint8(6)) require.NoError(t, err) - _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, caller, append(bin, inputBz...), uint256.NewInt(0)) + _, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, caller, append(bin, inputBz...), uint256.NewInt(0), nil) if success { require.NoError(t, err) } else { diff --git a/x/evm/keeper/erc20_test.go b/x/evm/keeper/erc20_test.go index 9faf654..511f6fa 100644 --- a/x/evm/keeper/erc20_test.go +++ b/x/evm/keeper/erc20_test.go @@ -5,7 +5,9 @@ import ( "cosmossdk.io/math" "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/require" + "golang.org/x/crypto/sha3" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -17,6 +19,23 @@ import ( "github.com/initia-labs/minievm/x/evm/types" ) +func getStorageKey(address common.Address, slot uint64) common.Hash { + addressBytes := address.Bytes() + paddedAddress := make([]byte, 32) + copy(paddedAddress[32-len(addressBytes):], addressBytes) + + slotBytes := make([]byte, 32) + slotBytes[31] = byte(slot) + + key := make([]byte, 0, 32) + key = append(key, paddedAddress...) + key = append(key, slotBytes...) + + hash := sha3.NewLegacyKeccak256() + hash.Write(key) + return common.BytesToHash(hash.Sum(nil)) +} + func deployERC20(t *testing.T, ctx sdk.Context, input TestKeepers, caller common.Address, denom string) common.Address { abi, err := erc20_factory.Erc20FactoryMetaData.GetAbi() require.NoError(t, err) @@ -27,7 +46,7 @@ func deployERC20(t *testing.T, ctx sdk.Context, input TestKeepers, caller common factoryAddr, err := input.EVMKeeper.GetERC20FactoryAddr(ctx) require.NoError(t, err) - ret, _, err := input.EVMKeeper.EVMCall(ctx, caller, factoryAddr, inputBz, nil) + ret, _, err := input.EVMKeeper.EVMCall(ctx, caller, factoryAddr, inputBz, nil, nil) require.NoError(t, err) return common.BytesToAddress(ret[12:]) @@ -49,7 +68,7 @@ func burnERC20(t *testing.T, ctx sdk.Context, input TestKeepers, caller, from co inputBz, err = abi.Pack("burnFrom", from, amount.Amount.BigInt()) require.NoError(t, err) - _, _, err = input.EVMKeeper.EVMCall(ctx, caller, erc20ContractAddr, inputBz, nil) + _, _, err = input.EVMKeeper.EVMCall(ctx, caller, erc20ContractAddr, inputBz, nil, nil) if expectErr { require.Error(t, err) } else { @@ -67,7 +86,7 @@ func mintERC20(t *testing.T, ctx sdk.Context, input TestKeepers, caller, recipie erc20ContractAddr, err := types.DenomToContractAddr(ctx, &input.EVMKeeper, amount.Denom) require.NoError(t, err) - _, _, err = input.EVMKeeper.EVMCall(ctx, caller, erc20ContractAddr, inputBz, nil) + _, _, err = input.EVMKeeper.EVMCall(ctx, caller, erc20ContractAddr, inputBz, nil, nil) if expectErr { require.Error(t, err) } else { @@ -85,7 +104,7 @@ func transferERC20(t *testing.T, ctx sdk.Context, input TestKeepers, caller, rec erc20ContractAddr, err := types.DenomToContractAddr(ctx, &input.EVMKeeper, amount.Denom) require.NoError(t, err) - _, _, err = input.EVMKeeper.EVMCall(ctx, caller, erc20ContractAddr, inputBz, nil) + _, _, err = input.EVMKeeper.EVMCall(ctx, caller, erc20ContractAddr, inputBz, nil, nil) if expectErr { require.Error(t, err) } else { @@ -104,7 +123,7 @@ func approveERC20(t *testing.T, ctx sdk.Context, input TestKeepers, caller, spen erc20ContractAddr, err := types.DenomToContractAddr(ctx, &input.EVMKeeper, amount.Denom) require.NoError(t, err) - _, _, err = input.EVMKeeper.EVMCall(ctx, caller, erc20ContractAddr, inputBz, nil) + _, _, err = input.EVMKeeper.EVMCall(ctx, caller, erc20ContractAddr, inputBz, nil, nil) if expectErr { require.Error(t, err) } else { @@ -122,7 +141,35 @@ func transferFromERC20(t *testing.T, ctx sdk.Context, input TestKeepers, caller, erc20ContractAddr, err := types.DenomToContractAddr(ctx, &input.EVMKeeper, amount.Denom) require.NoError(t, err) - _, _, err = input.EVMKeeper.EVMCall(ctx, caller, erc20ContractAddr, inputBz, nil) + _, _, err = input.EVMKeeper.EVMCall(ctx, caller, erc20ContractAddr, inputBz, nil, nil) + if expectErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } +} + +func transferFromERC20WithAccessList(t *testing.T, ctx sdk.Context, input TestKeepers, caller, from, to common.Address, amount sdk.Coin, expectErr bool) { + abi, err := erc20.Erc20MetaData.GetAbi() + require.NoError(t, err) + + inputBz, err := abi.Pack("transferFrom", from, to, amount.Amount.BigInt()) + require.NoError(t, err) + + erc20ContractAddr, err := types.DenomToContractAddr(ctx, &input.EVMKeeper, amount.Denom) + require.NoError(t, err) + balanceSlot := uint64(0) + fromStorageKey := getStorageKey(from, balanceSlot) + toStorageKey := getStorageKey(from, balanceSlot) + + _, _, err = input.EVMKeeper.EVMCall(ctx, caller, erc20ContractAddr, inputBz, nil, ethtypes.AccessList{ + ethtypes.AccessTuple{ + Address: erc20ContractAddr, + StorageKeys: []common.Hash{ + fromStorageKey, toStorageKey, + }, + }, + }) if expectErr { require.Error(t, err) } else { @@ -503,3 +550,40 @@ func Test_Approve(t *testing.T) { // should fail to transferFrom more than approved transferFromERC20(t, ctx, input, evmAddr2, evmAddr, evmAddr2, sdk.NewCoin(fooDenom, math.NewInt(50)), true) } + +func Test_ApproveWithAccessList(t *testing.T) { + ctx, input := createDefaultTestInput(t) + _, _, addr := keyPubAddr() + _, _, addr2 := keyPubAddr() + + evmAddr := common.BytesToAddress(addr.Bytes()) + evmAddr2 := common.BytesToAddress(addr2.Bytes()) + + erc20Keeper, err := keeper.NewERC20Keeper(&input.EVMKeeper) + require.NoError(t, err) + + // deploy erc20 contract + fooContractAddr := deployERC20(t, ctx, input, evmAddr, "foo") + fooDenom, err := types.ContractAddrToDenom(ctx, &input.EVMKeeper, fooContractAddr) + require.NoError(t, err) + require.Equal(t, "evm/"+fooContractAddr.Hex()[2:], fooDenom) + + // mint erc20 + mintERC20(t, ctx, input, evmAddr, evmAddr, sdk.NewCoin(fooDenom, math.NewInt(100)), false) + + // approve erc20 + approveERC20(t, ctx, input, evmAddr, evmAddr2, sdk.NewCoin(fooDenom, math.NewInt(50)), false) + + // transferFrom erc20 + transferFromERC20WithAccessList(t, ctx, input, evmAddr2, evmAddr, evmAddr2, sdk.NewCoin(fooDenom, math.NewInt(50)), false) + + amount, err := erc20Keeper.GetBalance(ctx, addr, fooDenom) + require.NoError(t, err) + require.Equal(t, math.NewInt(50), amount) + amount, err = erc20Keeper.GetBalance(ctx, addr2, fooDenom) + require.NoError(t, err) + require.Equal(t, math.NewInt(50), amount) + + // should fail to transferFrom more than approved + transferFromERC20WithAccessList(t, ctx, input, evmAddr2, evmAddr, evmAddr2, sdk.NewCoin(fooDenom, math.NewInt(50)), true) +} diff --git a/x/evm/keeper/erc721.go b/x/evm/keeper/erc721.go index 7f3f218..cd184a3 100644 --- a/x/evm/keeper/erc721.go +++ b/x/evm/keeper/erc721.go @@ -59,7 +59,7 @@ func (k ERC721Keeper) CreateOrUpdateClass(ctx context.Context, classId, classUri return types.ErrFailedToPackABI.Wrap(err.Error()) } - ret, contractAddr, _, err := k.EVMCreate(ctx, types.StdAddress, append(k.ERC721Bin, inputBz...), nil) + ret, contractAddr, _, err := k.EVMCreate(ctx, types.StdAddress, append(k.ERC721Bin, inputBz...), nil, nil) if err != nil { return err } @@ -123,7 +123,7 @@ func (k ERC721Keeper) Transfers(ctx context.Context, sender, receiver sdk.AccAdd } // ignore the return values - _, _, err = k.EVMCall(ctx, senderAddr, contractAddr, inputBz, nil) + _, _, err = k.EVMCall(ctx, senderAddr, contractAddr, inputBz, nil, nil) if err != nil { return err } @@ -140,7 +140,7 @@ func (k ERC721Keeper) Burn( return types.ErrFailedToPackABI.Wrap(err.Error()) } - _, _, err = k.EVMCall(ctx, owner, contractAddr, inputBz, nil) + _, _, err = k.EVMCall(ctx, owner, contractAddr, inputBz, nil, nil) if err != nil { return err } @@ -192,7 +192,7 @@ func (k ERC721Keeper) Mint( return types.ErrFailedToPackABI.Wrap(err.Error()) } - _, _, err = k.EVMCall(ctx, types.StdAddress, contractAddr, inputBz, nil) + _, _, err = k.EVMCall(ctx, types.StdAddress, contractAddr, inputBz, nil, nil) if err != nil { return err } @@ -288,7 +288,7 @@ func (k ERC721Keeper) balanceOf(ctx context.Context, addr, contractAddr common.A return math.ZeroInt(), types.ErrFailedToPackABI.Wrap(err.Error()) } - retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz) + retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz, nil) if err != nil { return math.ZeroInt(), err } @@ -326,7 +326,7 @@ func (k ERC721Keeper) ownerOf(ctx context.Context, tokenId *big.Int, contractAdd return types.NullAddress, types.ErrFailedToPackABI.Wrap(err.Error()) } - retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz) + retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz, nil) if err != nil { return types.NullAddress, err } @@ -364,7 +364,7 @@ func (k ERC721Keeper) name(ctx context.Context, contractAddr common.Address) (st return "", types.ErrFailedToPackABI.Wrap(err.Error()) } - retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz) + retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz, nil) if err != nil { return "", err } @@ -388,7 +388,7 @@ func (k ERC721Keeper) tokenURI(ctx context.Context, tokenId *big.Int, contractAd return "", types.ErrFailedToPackABI.Wrap(err.Error()) } - retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz) + retBz, err := k.EVMStaticCall(ctx, types.NullAddress, contractAddr, inputBz, nil) if err != nil { return "", err } diff --git a/x/evm/keeper/genesis.go b/x/evm/keeper/genesis.go index 1bc066e..f616b22 100644 --- a/x/evm/keeper/genesis.go +++ b/x/evm/keeper/genesis.go @@ -27,7 +27,7 @@ func (k Keeper) InitializeWithDecimals(ctx context.Context, decimals uint8) erro return err } - _, factoryAddr, _, err := k.EVMCreate2(ctx, types.StdAddress, code, nil, types.ERC20FactorySalt) + _, factoryAddr, _, err := k.EVMCreate2(ctx, types.StdAddress, code, nil, types.ERC20FactorySalt, nil) if err != nil { return err } diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index e1f5907..9450f72 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -4,8 +4,10 @@ import ( "context" "errors" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/tracing" + coretypes "github.com/ethereum/go-ethereum/core/types" "github.com/holiman/uint256" "cosmossdk.io/collections" @@ -47,7 +49,25 @@ func (ms *msgServerImpl) Create(ctx context.Context, msg *types.MsgCreate) (*typ if overflow { return nil, types.ErrInvalidValue.Wrap("value is out of range") } - + var accessList coretypes.AccessList + if len(msg.AccessList) > 0 { + accessList = func() coretypes.AccessList { + var als coretypes.AccessList + for _, al := range msg.AccessList { + als = append(als, coretypes.AccessTuple{ + Address: common.HexToAddress(al.Address), + StorageKeys: func() []common.Hash { + storageKeys := make([]common.Hash, len(al.StorageKeys)) + for _, sk := range al.StorageKeys { + storageKeys = append(storageKeys, common.HexToHash(sk)) + } + return storageKeys + }(), + }) + } + return als + }() + } // check the sender is allowed publisher params, err := ms.Params.Get(ctx) if err != nil { @@ -71,7 +91,7 @@ func (ms *msgServerImpl) Create(ctx context.Context, msg *types.MsgCreate) (*typ } // deploy a contract - retBz, contractAddr, logs, err := ms.EVMCreate(ctx, caller, codeBz, value) + retBz, contractAddr, logs, err := ms.EVMCreate(ctx, caller, codeBz, value, accessList) if err != nil { return nil, types.ErrEVMCallFailed.Wrap(err.Error()) } @@ -113,6 +133,20 @@ func (ms *msgServerImpl) Create2(ctx context.Context, msg *types.MsgCreate2) (*t return nil, err } + var accessList coretypes.AccessList + if len(msg.AccessList) > 0 { + accessList = make(coretypes.AccessList, len(msg.AccessList)) + for i, al := range msg.AccessList { + storageKeys := make([]common.Hash, len(al.StorageKeys)) + for j, sk := range al.StorageKeys { + storageKeys[j] = common.HexToHash(sk) + } + accessList[i] = coretypes.AccessTuple{ + Address: common.HexToAddress(al.Address), + StorageKeys: storageKeys, + } + } + } // assert deploy authorization if len(params.AllowedPublishers) != 0 { allowed := false @@ -130,7 +164,7 @@ func (ms *msgServerImpl) Create2(ctx context.Context, msg *types.MsgCreate2) (*t } // deploy a contract - retBz, contractAddr, logs, err := ms.EVMCreate2(ctx, caller, codeBz, value, msg.Salt) + retBz, contractAddr, logs, err := ms.EVMCreate2(ctx, caller, codeBz, value, msg.Salt, accessList) if err != nil { return nil, types.ErrEVMCallFailed.Wrap(err.Error()) } @@ -188,7 +222,7 @@ func (ms *msgServerImpl) Call(ctx context.Context, msg *types.MsgCall) (*types.M return nil, types.ErrInvalidValue.Wrap("value is out of range") } - retBz, logs, err := ms.EVMCall(ctx, caller, contractAddr, inputBz, value) + retBz, logs, err := ms.EVMCall(ctx, caller, contractAddr, inputBz, value, nil) if err != nil { return nil, types.ErrEVMCallFailed.Wrap(err.Error()) } diff --git a/x/evm/keeper/msg_server_test.go b/x/evm/keeper/msg_server_test.go index e477a8b..e9cc9fa 100644 --- a/x/evm/keeper/msg_server_test.go +++ b/x/evm/keeper/msg_server_test.go @@ -83,7 +83,7 @@ func Test_MsgServer_Call(t *testing.T) { counterBz, err := hexutil.Decode(counter.CounterBin) require.NoError(t, err) - retBz, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil) + retBz, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil, nil) require.NoError(t, err) require.NotEmpty(t, retBz) require.Len(t, contractAddr, 20) @@ -94,7 +94,7 @@ func Test_MsgServer_Call(t *testing.T) { queryInputBz, err := parsed.Pack("count") require.NoError(t, err) - queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil) + queryRes, logs, err := input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(0).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) @@ -112,7 +112,7 @@ func Test_MsgServer_Call(t *testing.T) { require.Equal(t, "0x", res.Result) require.NotEmpty(t, res.Logs) - queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil) + queryRes, logs, err = input.EVMKeeper.EVMCall(ctx, caller, contractAddr, queryInputBz, nil, nil) require.NoError(t, err) require.Equal(t, uint256.NewInt(1).Bytes32(), [32]byte(queryRes)) require.Empty(t, logs) diff --git a/x/evm/keeper/precompiles_test.go b/x/evm/keeper/precompiles_test.go index 6ea24ea..69b433f 100644 --- a/x/evm/keeper/precompiles_test.go +++ b/x/evm/keeper/precompiles_test.go @@ -49,7 +49,7 @@ func Test_ExecuteCosmosMessage(t *testing.T) { `, addr, addr2)) require.NoError(t, err) - _, _, err = input.EVMKeeper.EVMCall(ctx, evmAddr, types.CosmosPrecompileAddress, inputBz, nil) + _, _, err = input.EVMKeeper.EVMCall(ctx, evmAddr, types.CosmosPrecompileAddress, inputBz, nil, nil) require.NoError(t, err) balance := input.BankKeeper.GetBalance(ctx, addr2, "bar") @@ -79,7 +79,7 @@ func Test_QueryCosmosMessage(t *testing.T) { }`, addr)) require.NoError(t, err) - retBz, _, err := input.EVMKeeper.EVMCall(ctx, evmAddr, types.CosmosPrecompileAddress, inputBz, nil) + retBz, _, err := input.EVMKeeper.EVMCall(ctx, evmAddr, types.CosmosPrecompileAddress, inputBz, nil, nil) require.NoError(t, err) unpackedRet, err := abi.Methods["query_cosmos"].Outputs.Unpack(retBz) @@ -109,7 +109,7 @@ func Test_QueryCosmosFromContract(t *testing.T) { require.NoError(t, err) caller := common.BytesToAddress(addr.Bytes()) - retBz, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil) + retBz, contractAddr, _, err := input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil, nil) require.NoError(t, err) require.NotEmpty(t, retBz) require.Len(t, contractAddr, 20) @@ -123,7 +123,7 @@ func Test_QueryCosmosFromContract(t *testing.T) { }`, addr)) require.NoError(t, err) - retBz, _, err = input.EVMKeeper.EVMCall(ctx, contractAddr, types.CosmosPrecompileAddress, inputBz, nil) + retBz, _, err = input.EVMKeeper.EVMCall(ctx, contractAddr, types.CosmosPrecompileAddress, inputBz, nil, nil) require.NoError(t, err) unpackedRet, err := abi.Methods["query_cosmos"].Outputs.Unpack(retBz) @@ -159,7 +159,7 @@ func Test_ToDenom(t *testing.T) { inputBz, err := abi.Pack("to_denom", contractAddr) require.NoError(t, err) - retBz, _, err := input.EVMKeeper.EVMCall(ctx, evmAddr, types.CosmosPrecompileAddress, inputBz, nil) + retBz, _, err := input.EVMKeeper.EVMCall(ctx, evmAddr, types.CosmosPrecompileAddress, inputBz, nil, nil) require.NoError(t, err) unpackedRet, err := abi.Methods["to_denom"].Outputs.Unpack(retBz) @@ -191,7 +191,7 @@ func Test_ToERC20(t *testing.T) { inputBz, err := abi.Pack("to_erc20", "bar") require.NoError(t, err) - retBz, _, err := input.EVMKeeper.EVMCall(ctx, evmAddr, types.CosmosPrecompileAddress, inputBz, nil) + retBz, _, err := input.EVMKeeper.EVMCall(ctx, evmAddr, types.CosmosPrecompileAddress, inputBz, nil, nil) require.NoError(t, err) unpackedRet, err := abi.Methods["to_erc20"].Outputs.Unpack(retBz) diff --git a/x/evm/keeper/query_server.go b/x/evm/keeper/query_server.go index 6a3b074..ea9e2a5 100644 --- a/x/evm/keeper/query_server.go +++ b/x/evm/keeper/query_server.go @@ -81,9 +81,9 @@ func (qs *queryServerImpl) Call(ctx context.Context, req *types.QueryCallRequest var logs []types.Log if contractAddr == (common.Address{}) { // if contract address is not provided, then it's a contract creation - retBz, _, logs, err = qs.EVMCreateWithTracer(sdkCtx, caller, inputBz, value, nil, tracer) + retBz, _, logs, err = qs.EVMCreateWithTracer(sdkCtx, caller, inputBz, value, nil, nil, tracer) } else { - retBz, logs, err = qs.EVMCallWithTracer(sdkCtx, caller, contractAddr, inputBz, value, tracer) + retBz, logs, err = qs.EVMCallWithTracer(sdkCtx, caller, contractAddr, inputBz, value, nil, tracer) } diff --git a/x/evm/keeper/txutils.go b/x/evm/keeper/txutils.go index 1aec4d1..dc464d7 100644 --- a/x/evm/keeper/txutils.go +++ b/x/evm/keeper/txutils.go @@ -94,11 +94,24 @@ func (u *TxUtils) ConvertEthereumTxToCosmosTx(ctx context.Context, ethTx *corety // sig bytes v, r, s := ethTx.RawSignatureValues() - + var accessList []types.AccessTuple sigBytes := make([]byte, 65) switch ethTx.Type() { case coretypes.LegacyTxType: sigBytes[64] = byte(new(big.Int).Sub(v, new(big.Int).Add(new(big.Int).Add(ethChainID, ethChainID), big.NewInt(35))).Uint64()) + case coretypes.AccessListTxType: + sigBytes[64] = byte(v.Uint64()) + accessList = make([]types.AccessTuple, len(ethTx.AccessList())) + for i, al := range ethTx.AccessList() { + storageKeys := make([]string, len(al.StorageKeys)) + for j, s := range al.StorageKeys { + storageKeys[j] = s.String() + } + accessList[i] = types.AccessTuple{ + Address: al.Address.String(), + StorageKeys: storageKeys, + } + } case coretypes.DynamicFeeTxType: sigBytes[64] = byte(v.Uint64()) default: @@ -139,11 +152,15 @@ func (u *TxUtils) ConvertEthereumTxToCosmosTx(ctx context.Context, ethTx *corety } sdkMsgs := []sdk.Msg{} + if len(accessList) == 0 { + accessList = nil + } if ethTx.To() == nil { sdkMsgs = append(sdkMsgs, &types.MsgCreate{ - Sender: sender, - Code: hexutil.Encode(ethTx.Data()), - Value: math.NewIntFromBigInt(value), + Sender: sender, + Code: hexutil.Encode(ethTx.Data()), + Value: math.NewIntFromBigInt(value), + AccessList: accessList, }) } else { sdkMsgs = append(sdkMsgs, &types.MsgCall{ @@ -151,6 +168,7 @@ func (u *TxUtils) ConvertEthereumTxToCosmosTx(ctx context.Context, ethTx *corety ContractAddr: ethTx.To().String(), Input: hexutil.Encode(ethTx.Data()), Value: math.NewIntFromBigInt(value), + AccessList: accessList, }) } @@ -271,6 +289,7 @@ func (u *TxUtils) ConvertCosmosTxToEthereumTx(ctx context.Context, sdkTx sdk.Tx) var to *common.Address var input []byte var value *big.Int + var accessList []types.AccessTuple switch typeUrl { case "/minievm.evm.v1.MsgCall": callMsg := msg.(*types.MsgCall) @@ -290,6 +309,7 @@ func (u *TxUtils) ConvertCosmosTxToEthereumTx(ctx context.Context, sdkTx sdk.Tx) // the value is converted to cosmos fee unit from wei. // So we need to convert it back to wei to get original ethereum tx and verify signature. value = types.ToEthersUint(decimals, callMsg.Value.BigInt()) + accessList = callMsg.AccessList case "/minievm.evm.v1.MsgCreate": createMsg := msg.(*types.MsgCreate) data, err := hexutil.Decode(createMsg.Code) @@ -301,6 +321,7 @@ func (u *TxUtils) ConvertCosmosTxToEthereumTx(ctx context.Context, sdkTx sdk.Tx) input = data // Same as above (MsgCall) value = types.ToEthersUint(decimals, createMsg.Value.BigInt()) + accessList = createMsg.AccessList case "/minievm.evm.v1.MsgCreate2": // create2 is not supported return nil, nil, nil @@ -323,6 +344,34 @@ func (u *TxUtils) ConvertCosmosTxToEthereumTx(ctx context.Context, sdkTx sdk.Tx) S: new(big.Int).SetBytes(s), V: new(big.Int).Add(new(big.Int).SetBytes(v), new(big.Int).SetUint64(35+ethChainID.Uint64()*2)), } + case coretypes.AccessListTxType: + txData = &coretypes.AccessListTx{ + ChainID: types.ConvertCosmosChainIDToEthereumChainID(sdk.UnwrapSDKContext(ctx).ChainID()), + Nonce: sig.Sequence, + GasPrice: gasFeeCap, + Gas: gas, + Value: value, + To: to, + Data: input, + AccessList: func() coretypes.AccessList { + al := make(coretypes.AccessList, len(accessList)) + for i, a := range accessList { + storageKeys := make([]common.Hash, len(a.StorageKeys)) + for j, s := range a.StorageKeys { + storageKeys[j] = common.HexToHash(s) + } + al[i] = coretypes.AccessTuple{ + Address: common.HexToAddress(a.Address), + StorageKeys: storageKeys, + } + } + return al + }(), + R: new(big.Int).SetBytes(r), + S: new(big.Int).SetBytes(s), + V: new(big.Int).SetBytes(v), + } + case coretypes.DynamicFeeTxType: txData = &coretypes.DynamicFeeTx{ ChainID: types.ConvertCosmosChainIDToEthereumChainID(sdk.UnwrapSDKContext(ctx).ChainID()), @@ -337,6 +386,7 @@ func (u *TxUtils) ConvertCosmosTxToEthereumTx(ctx context.Context, sdkTx sdk.Tx) S: new(big.Int).SetBytes(s), V: new(big.Int).SetBytes(v), } + default: return nil, nil, fmt.Errorf("unsupported tx type: %d", md.Type) } diff --git a/x/evm/keeper/txutils_test.go b/x/evm/keeper/txutils_test.go index e057e6a..db4e665 100644 --- a/x/evm/keeper/txutils_test.go +++ b/x/evm/keeper/txutils_test.go @@ -15,6 +15,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" coretypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" @@ -121,6 +122,112 @@ func Test_DynamicFeeTxConversion(t *testing.T) { EqualEthTransaction(t, signedTx, ethTx2) } +func Test_AccessTxConversion(t *testing.T) { + ctx, input := createDefaultTestInput(t) + + _, _, addr := keyPubAddr() + input.Faucet.Mint(ctx, addr, sdk.NewCoin(sdk.DefaultBondDenom, math.NewInt(1000000000000000000))) + + decimals := input.Decimals + gasLimit := uint64(1_000_000) + feeAmount := new(big.Int).Mul( + big.NewInt(int64(gasLimit)), + new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(decimals)-8), nil), // gas price is 1e-8 + ) + + ethFactoryAddr, err := input.EVMKeeper.GetERC20FactoryAddr(ctx) + require.NoError(t, err) + + abi, err := erc20_factory.Erc20FactoryMetaData.GetAbi() + require.NoError(t, err) + + inputBz, err := abi.Pack("createERC20", "bar", "bar", uint8(6)) + require.NoError(t, err) + + value := types.ToEthersUint(decimals, big.NewInt(100)) + + gasFeeCap := types.ToEthersUint(decimals, feeAmount) + gasFeeCap = gasFeeCap.Quo(gasFeeCap, new(big.Int).SetUint64(gasLimit)) + + ethChainID := types.ConvertCosmosChainIDToEthereumChainID(ctx.ChainID()) + ethTx := coretypes.NewTx(&coretypes.AccessListTx{ + ChainID: types.ConvertCosmosChainIDToEthereumChainID(ctx.ChainID()), + Nonce: 100, + GasPrice: gasFeeCap, + Gas: gasLimit, + To: ðFactoryAddr, + Data: inputBz, + Value: value, + AccessList: coretypes.AccessList{ + coretypes.AccessTuple{Address: ethFactoryAddr, StorageKeys: []common.Hash{common.HexToHash("0x0")}}, + }, + }) + + signer := coretypes.LatestSignerForChainID(ethChainID) + + randBytes := make([]byte, 64) + _, err = rand.Read(randBytes) + require.NoError(t, err) + reader := bytes.NewReader(randBytes) + + privKey, err := ecdsa.GenerateKey(crypto.S256(), reader) + require.NoError(t, err) + signedTx, err := coretypes.SignTx(ethTx, signer, privKey) + require.NoError(t, err) + + cosmosKey := ethsecp256k1.PrivKey{ + Key: crypto.FromECDSA(privKey), + } + addrBz := cosmosKey.PubKey().Address() + + // Convert to cosmos tx + sdkTx, err := keeper.NewTxUtils(&input.EVMKeeper).ConvertEthereumTxToCosmosTx(ctx, signedTx) + require.NoError(t, err) + + msgs := sdkTx.GetMsgs() + require.Len(t, msgs, 1) + msg, ok := msgs[0].(*types.MsgCall) + require.True(t, ok) + require.Equal(t, msg, &types.MsgCall{ + Sender: sdk.AccAddress(addrBz).String(), + ContractAddr: ethFactoryAddr.Hex(), + Input: hexutil.Encode(inputBz), + Value: math.NewInt(100), + AccessList: []types.AccessTuple{ + { + Address: ethFactoryAddr.String(), + StorageKeys: []string{common.HexToHash("0x0").Hex()}, + }, + }, + }) + + authTx := sdkTx.(authsigning.Tx) + require.Equal(t, authTx.GetFee(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.NewIntFromBigInt(feeAmount).AddRaw(1)))) + + sigs, err := authTx.GetSignaturesV2() + require.NoError(t, err) + require.Len(t, sigs, 1) + + sig := sigs[0] + require.Equal(t, sig.PubKey, cosmosKey.PubKey()) + require.Equal(t, sig.Sequence, uint64(100)) + + v, r, s := signedTx.RawSignatureValues() + sigData := sig.Data.(*signing.SingleSignatureData) + require.Equal(t, sigData.SignMode, keeper.SignMode_SIGN_MODE_ETHEREUM) + + sigBytes := make([]byte, 65) + copy(sigBytes[32-len(r.Bytes()):32], r.Bytes()) + copy(sigBytes[64-len(s.Bytes()):64], s.Bytes()) + sigBytes[64] = byte(v.Uint64()) + + require.Equal(t, sigData.Signature, sigBytes) + + // Convert back to ethereum tx + ethTx2, _, err := keeper.NewTxUtils(&input.EVMKeeper).ConvertCosmosTxToEthereumTx(ctx, sdkTx) + require.NoError(t, err) + EqualEthTransaction(t, signedTx, ethTx2) +} func Test_LegacyTxConversion(t *testing.T) { ctx, input := createDefaultTestInput(t) diff --git a/x/evm/state/statedb_test.go b/x/evm/state/statedb_test.go index 9fb6ce8..2093084 100644 --- a/x/evm/state/statedb_test.go +++ b/x/evm/state/statedb_test.go @@ -171,10 +171,10 @@ func Test_SelfDestruct(t *testing.T) { require.NoError(t, err) caller := common.BytesToAddress(addr.Bytes()) - _, contractAddr, _, err := input.EVMKeeper.EVMCreate(sdkCtx, caller, counterBz, nil) + _, contractAddr, _, err := input.EVMKeeper.EVMCreate(sdkCtx, caller, counterBz, nil, nil) require.NoError(t, err) - _, contractAddr2, _, err := input.EVMKeeper.EVMCreate(sdkCtx, caller, counterBz, nil) + _, contractAddr2, _, err := input.EVMKeeper.EVMCreate(sdkCtx, caller, counterBz, nil, nil) require.NoError(t, err) // increase counter @@ -185,12 +185,12 @@ func Test_SelfDestruct(t *testing.T) { require.NoError(t, err) // call with value - res, logs, err := input.EVMKeeper.EVMCall(sdkCtx, caller, contractAddr, inputBz, uint256.NewInt(100)) + res, logs, err := input.EVMKeeper.EVMCall(sdkCtx, caller, contractAddr, inputBz, uint256.NewInt(100), nil) require.NoError(t, err) require.Empty(t, res) require.NotEmpty(t, logs) - res, logs, err = input.EVMKeeper.EVMCall(sdkCtx, caller, contractAddr2, inputBz, uint256.NewInt(100)) + res, logs, err = input.EVMKeeper.EVMCall(sdkCtx, caller, contractAddr2, inputBz, uint256.NewInt(100), nil) require.NoError(t, err) require.Empty(t, res) require.NotEmpty(t, logs) @@ -236,7 +236,7 @@ func Test_Selfdestruct6780_InDifferentTx(t *testing.T) { require.NoError(t, err) caller := common.BytesToAddress(addr.Bytes()) - _, contractAddr, _, err := input.EVMKeeper.EVMCreate(sdkCtx, caller, counterBz, nil) + _, contractAddr, _, err := input.EVMKeeper.EVMCreate(sdkCtx, caller, counterBz, nil, nil) require.NoError(t, err) // increase counter @@ -247,7 +247,7 @@ func Test_Selfdestruct6780_InDifferentTx(t *testing.T) { require.NoError(t, err) // call with value - res, logs, err := input.EVMKeeper.EVMCall(sdkCtx, caller, contractAddr, inputBz, uint256.NewInt(100)) + res, logs, err := input.EVMKeeper.EVMCall(sdkCtx, caller, contractAddr, inputBz, uint256.NewInt(100), nil) require.NoError(t, err) require.Empty(t, res) require.NotEmpty(t, logs) @@ -388,7 +388,7 @@ func Test_ContractAddrConfilct_DueToCosmosAccount(t *testing.T) { require.NoError(t, err) caller := common.BytesToAddress(addr.Bytes()) - _, _, _, err = input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil) + _, _, _, err = input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil, nil) require.ErrorContains(t, err, vm.ErrContractAddressCollision.Error()) } @@ -408,7 +408,7 @@ func Test_CreateContract_OverrideEmptyAccount(t *testing.T) { require.NoError(t, err) caller := common.BytesToAddress(addr.Bytes()) - _, _, _, err = input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil) + _, _, _, err = input.EVMKeeper.EVMCreate(ctx, caller, counterBz, nil, nil) require.NoError(t, err) contractAcc := input.AccountKeeper.GetAccount(ctx, sdk.AccAddress(contractAddr.Bytes())) diff --git a/x/evm/types/tx.pb.go b/x/evm/types/tx.pb.go index 83f02c6..df92d79 100644 --- a/x/evm/types/tx.pb.go +++ b/x/evm/types/tx.pb.go @@ -40,6 +40,8 @@ type MsgCreate struct { Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` // Value is the amount of fee denom token to transfer to the contract. Value cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=value,proto3,customtype=cosmossdk.io/math.Int" json:"value"` + // AccessList is a predefined list of Ethereum addresses and their corresponding storage slots that a transaction will interact with during its execution. can be none + AccessList []AccessTuple `protobuf:"bytes,4,rep,name=access_list,json=accessList,proto3" json:"access_list"` } func (m *MsgCreate) Reset() { *m = MsgCreate{} } @@ -89,6 +91,13 @@ func (m *MsgCreate) GetCode() string { return "" } +func (m *MsgCreate) GetAccessList() []AccessTuple { + if m != nil { + return m.AccessList + } + return nil +} + // MsgCreateResponse defines the Msg/Create response type. type MsgCreateResponse struct { Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` @@ -162,6 +171,8 @@ type MsgCreate2 struct { Salt uint64 `protobuf:"varint,3,opt,name=salt,proto3" json:"salt,omitempty"` // Value is the amount of fee denom token to transfer to the contract. Value cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=value,proto3,customtype=cosmossdk.io/math.Int" json:"value"` + // AccessList is a predefined list of Ethereum addresses and their corresponding storage slots that a transaction will interact with during its execution. can be none + AccessList []AccessTuple `protobuf:"bytes,5,rep,name=access_list,json=accessList,proto3" json:"access_list"` } func (m *MsgCreate2) Reset() { *m = MsgCreate2{} } @@ -218,6 +229,13 @@ func (m *MsgCreate2) GetSalt() uint64 { return 0 } +func (m *MsgCreate2) GetAccessList() []AccessTuple { + if m != nil { + return m.AccessList + } + return nil +} + // MsgCreate2Response defines the Msg/Create2 response type. type MsgCreate2Response struct { Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` @@ -292,6 +310,8 @@ type MsgCall struct { Input string `protobuf:"bytes,3,opt,name=input,proto3" json:"input,omitempty"` // Value is the amount of fee denom token to transfer to the contract. Value cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=value,proto3,customtype=cosmossdk.io/math.Int" json:"value"` + // AccessList is a predefined list of Ethereum addresses and their corresponding storage slots that a transaction will interact with during its execution. can be none + AccessList []AccessTuple `protobuf:"bytes,5,rep,name=access_list,json=accessList,proto3" json:"access_list"` } func (m *MsgCall) Reset() { *m = MsgCall{} } @@ -348,6 +368,13 @@ func (m *MsgCall) GetInput() string { return "" } +func (m *MsgCall) GetAccessList() []AccessTuple { + if m != nil { + return m.AccessList + } + return nil +} + // MsgCallResponse defines the Msg/Call response type. type MsgCallResponse struct { Result string `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` @@ -512,48 +539,50 @@ func init() { func init() { proto.RegisterFile("minievm/evm/v1/tx.proto", fileDescriptor_d925564029372f6a) } var fileDescriptor_d925564029372f6a = []byte{ - // 650 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x95, 0xcf, 0x6b, 0xd4, 0x40, - 0x14, 0xc7, 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16, 0x68, 0xb7, 0x07, 0x14, 0x64, 0xca, 0xda, 0xf0, - 0xeb, 0x04, 0xf8, 0xca, 0xa3, 0xfd, 0x63, 0x1d, 0x1d, 0x1c, 0xeb, 0xe8, 0xe7, 0xb1, 0x8e, 0x3e, - 0x9c, 0xe8, 0xa5, 0x83, 0x13, 0xbd, 0xf4, 0xed, 0x44, 0x2f, 0xbd, 0x68, 0x7a, 0xbe, 0xd8, 0xea, - 0x6c, 0x9a, 0x2d, 0x16, 0x5a, 0x7e, 0xe4, 0x0b, 0x9f, 0x2c, 0x04, 0x64, 0x93, 0x5b, 0xd9, 0xa5, - 0xb0, 0x2d, 0xaf, 0x05, 0x79, 0x27, 0x6c, 0x56, 0xe5, 0xa5, 0x70, 0xe7, 0x57, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x00, 0xbc, 0xa3, 0x7e, 0xb8, 0x06, 0x00, 0x00, + // 687 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0x41, 0x6b, 0xd4, 0x40, + 0x14, 0xde, 0xec, 0x66, 0xb7, 0xec, 0x6c, 0x5b, 0xe9, 0x58, 0xbb, 0xdb, 0x14, 0xd3, 0x1a, 0x0f, + 0x96, 0x85, 0x26, 0x6d, 0x04, 0xc1, 0x9e, 0x6c, 0x95, 0x4a, 0xa1, 0x05, 0x89, 0x0a, 0x22, 0x48, + 0x99, 0x26, 0x43, 0x1a, 0x4c, 0x32, 0x21, 0x33, 0xbb, 0xb4, 0x37, 0x15, 0xbd, 0x78, 0xf2, 0x20, + 0xf8, 0x07, 0x3c, 0x78, 0xec, 0xa1, 0x37, 0xff, 0x40, 0x8f, 0xa5, 0x27, 0xf1, 0x50, 0xa4, 0x3d, + 0xf4, 0x6f, 0x48, 0x26, 0x93, 0x6c, 0x1b, 0xba, 0xac, 0x96, 0x82, 0x1e, 0x12, 0xe6, 0xcd, 0xfb, + 0xde, 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b6, 0x3a, 0x9b, 0xba, 0x4d, 0x02, 0xc3, 0x0b, 0x3d, 0xe6, 0xa1, 0x39, + 0x1f, 0x6d, 0x52, 0x23, 0x9b, 0x77, 0xdb, 0x7c, 0xe2, 0xf1, 0x71, 0xb7, 0x59, 0xe3, 0xf3, 0xee, + 0xee, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb9, 0x0d, 0x44, 0x6f, 0x93, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -774,6 +803,20 @@ func (m *MsgCreate) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AccessList) > 0 { + for iNdEx := len(m.AccessList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AccessList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } { size := m.Value.Size() i -= size @@ -872,6 +915,20 @@ func (m *MsgCreate2) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AccessList) > 0 { + for iNdEx := len(m.AccessList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AccessList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } { size := m.Value.Size() i -= size @@ -975,6 +1032,20 @@ func (m *MsgCall) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AccessList) > 0 { + for iNdEx := len(m.AccessList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AccessList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } { size := m.Value.Size() i -= size @@ -1143,6 +1214,12 @@ func (m *MsgCreate) Size() (n int) { } l = m.Value.Size() n += 1 + l + sovTx(uint64(l)) + if len(m.AccessList) > 0 { + for _, e := range m.AccessList { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } return n } @@ -1188,6 +1265,12 @@ func (m *MsgCreate2) Size() (n int) { } l = m.Value.Size() n += 1 + l + sovTx(uint64(l)) + if len(m.AccessList) > 0 { + for _, e := range m.AccessList { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } return n } @@ -1234,6 +1317,12 @@ func (m *MsgCall) Size() (n int) { } l = m.Value.Size() n += 1 + l + sovTx(uint64(l)) + if len(m.AccessList) > 0 { + for _, e := range m.AccessList { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } return n } @@ -1413,6 +1502,40 @@ func (m *MsgCreate) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccessList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AccessList = append(m.AccessList, AccessTuple{}) + if err := m.AccessList[len(m.AccessList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -1728,6 +1851,40 @@ func (m *MsgCreate2) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccessList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AccessList = append(m.AccessList, AccessTuple{}) + if err := m.AccessList[len(m.AccessList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -2056,6 +2213,40 @@ func (m *MsgCall) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AccessList", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AccessList = append(m.AccessList, AccessTuple{}) + if err := m.AccessList[len(m.AccessList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/evm/types/types.pb.go b/x/evm/types/types.pb.go index 7aa0c8e..dde3bb4 100644 --- a/x/evm/types/types.pb.go +++ b/x/evm/types/types.pb.go @@ -119,48 +119,93 @@ func (m *Log) XXX_DiscardUnknown() { var xxx_messageInfo_Log proto.InternalMessageInfo +type AccessTuple struct { + // Address of the contract that will be accessed during the transaction execution. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // A list of storage keys that the transaction will interact with within the specified contract. + // These keys represent specific storage slots in the contract's storage that are accessed or modified. + StorageKeys []string `protobuf:"bytes,2,rep,name=storage_keys,json=storageKeys,proto3" json:"storage_keys,omitempty"` +} + +func (m *AccessTuple) Reset() { *m = AccessTuple{} } +func (m *AccessTuple) String() string { return proto.CompactTextString(m) } +func (*AccessTuple) ProtoMessage() {} +func (*AccessTuple) Descriptor() ([]byte, []int) { + return fileDescriptor_98c9eab1c4bf0154, []int{2} +} +func (m *AccessTuple) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *AccessTuple) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_AccessTuple.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *AccessTuple) XXX_Merge(src proto.Message) { + xxx_messageInfo_AccessTuple.Merge(m, src) +} +func (m *AccessTuple) XXX_Size() int { + return m.Size() +} +func (m *AccessTuple) XXX_DiscardUnknown() { + xxx_messageInfo_AccessTuple.DiscardUnknown(m) +} + +var xxx_messageInfo_AccessTuple proto.InternalMessageInfo + func init() { proto.RegisterType((*Params)(nil), "minievm.evm.v1.Params") proto.RegisterType((*Log)(nil), "minievm.evm.v1.Log") + proto.RegisterType((*AccessTuple)(nil), "minievm.evm.v1.AccessTuple") } func init() { proto.RegisterFile("minievm/evm/v1/types.proto", fileDescriptor_98c9eab1c4bf0154) } var fileDescriptor_98c9eab1c4bf0154 = []byte{ - // 522 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x52, 0x31, 0x6f, 0xda, 0x40, - 0x18, 0xb5, 0x0b, 0xa5, 0xf1, 0x0d, 0x11, 0x5c, 0x68, 0xe3, 0xd2, 0xca, 0x46, 0x9e, 0x10, 0x52, - 0x71, 0x48, 0xb7, 0xa8, 0x0b, 0x26, 0x0c, 0x55, 0x19, 0xa8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, 0x03, 0xa5, 0x21, 0x0b, 0xa1, 0x0e, 0x9e, 0xa0, - 0x20, 0x88, 0x31, 0x17, 0x51, 0x50, 0x5b, 0x9a, 0xbb, 0x6b, 0xe1, 0x33, 0x50, 0x49, 0x58, 0x44, - 0xfc, 0xe2, 0x61, 0xdd, 0xa2, 0x83, 0x10, 0x94, 0x03, 0x94, 0x20, 0xf9, 0x36, 0x9a, 0x2b, 0x6b, - 0x67, 0xb8, 0xfe, 0x65, 0x28, 0x37, 0x99, 0xa1, 0xae, 0x33, 0x43, 0xbd, 0xcb, 0x0c, 0xf5, 0x67, - 0x66, 0xa8, 0x5f, 0x37, 0x86, 0x72, 0xb7, 0x31, 0x94, 0xef, 0x1b, 0x43, 0xf9, 0xd0, 0x0e, 0x49, - 0x32, 0x5d, 0x8c, 0x3b, 0x3e, 0xa3, 0x36, 0x99, 0x93, 0x84, 0xa0, 0x57, 0x33, 0x34, 0xe6, 0xf6, - 0x2e, 0xec, 0x57, 0x32, 0xee, 0x32, 0xeb, 0xe3, 0x8a, 0xcc, 0xec, 0xeb, 0x3f, 0x01, 0x00, 0x00, - 0xff, 0xff, 0x6b, 0x16, 0x6e, 0x9c, 0x0a, 0x03, 0x00, 0x00, + // 561 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x53, 0xb1, 0x6f, 0xd3, 0x4e, + 0x14, 0xb6, 0x7f, 0xe9, 0x2f, 0xd4, 0x57, 0x54, 0xa5, 0xd7, 0x40, 0x4d, 0x40, 0x76, 0xf0, 0x14, + 0x45, 0x22, 0x6e, 0xca, 0x56, 0xb1, 0xc4, 0x69, 0x06, 0x68, 0x86, 0x60, 0x31, 0xb1, 0x58, 0x17, + 0xfb, 0xe2, 0x9c, 0x6a, 0xe7, 0x2c, 0x9f, 0x13, 0x9a, 0x7f, 0x81, 0x05, 0x46, 0xc6, 0x8e, 0x1d, + 0xfb, 0x67, 0x64, 0xec, 0x88, 0x18, 0x2c, 0x70, 0x86, 0x32, 0xe7, 0x2f, 0x40, 0x77, 0x76, 0x4a, + 0x02, 0x12, 0xc3, 0x59, 0xef, 0x7d, 0xdf, 0xf7, 0x3e, 0xbf, 0xd3, 0xbd, 0x07, 0x6a, 0x21, 0x99, + 0x10, 0x3c, 0x0b, 0x4d, 0x7e, 0x66, 0x6d, 0x33, 0x99, 0x47, 0x98, 0xb5, 0xa2, 0x98, 0x26, 0x14, + 0xee, 0x17, 0x5c, 0x8b, 0x9f, 0x59, 0xbb, 0x76, 0x80, 0x42, 0x32, 0xa1, 0xa6, 0xf8, 0xe6, 0x92, + 0x5a, 0xd5, 0xa7, 0x3e, 0x15, 0xa1, 0xc9, 0xa3, 0x1c, 0x35, 0x3e, 0xed, 0x80, 0xf2, 0x00, 0xc5, + 0x28, 0x64, 0xb0, 0x03, 0x00, 0xbe, 0x4c, 0x62, 0xe4, 0x60, 0x12, 0x31, 0x55, 0xae, 0x97, 0x1a, + 0x25, 0xcb, 0xc8, 0x52, 0x5d, 0xe9, 0x71, 0xb4, 0xf7, 0x7a, 0xc0, 0x56, 0xa9, 0x7e, 0x30, 0x47, + 0x61, 0x70, 0x6a, 0xfc, 0x16, 0x1a, 0xb6, 0x22, 0x92, 0x1e, 0x89, 0x18, 0x7c, 0x0b, 0x20, 0x0a, + 0x02, 0xfa, 0x01, 0x7b, 0x4e, 0x34, 0x1d, 0x06, 0x84, 0x8d, 0x71, 0xcc, 0xd4, 0xff, 0xea, 0xa5, + 0x86, 0x62, 0x19, 0xab, 0x54, 0x7f, 0x92, 0x57, 0xff, 0xad, 0x31, 0xae, 0xef, 0x6e, 0x9a, 0xb2, + 0x7d, 0x50, 0x30, 0x83, 0x7b, 0x02, 0x5a, 0x85, 0xa5, 0xe3, 0x4e, 0x59, 0x42, 0x43, 0x07, 0xc7, + 0xee, 0xc9, 0xb1, 0x5a, 0xaa, 0xcb, 0x8d, 0x5d, 0xab, 0x9a, 0xa5, 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0xf0, 0x31, 0x28, 0x27, 0x34, 0x22, 0x6e, 0xf1, 0xb0, 0x76, 0x91, 0x41, 0x08, 0x76, 0x3c, 0x94, + 0x20, 0xf1, 0x36, 0x8a, 0x2d, 0x62, 0xe3, 0x0d, 0xd8, 0xeb, 0xb8, 0x2e, 0x66, 0xec, 0xdd, 0x34, + 0x0a, 0xf0, 0x3f, 0x4c, 0x9f, 0x83, 0x87, 0x2c, 0xa1, 0x31, 0xf2, 0xb1, 0x73, 0x81, 0xe7, 0x6b, + 0xeb, 0xbd, 0x02, 0x3b, 0xc7, 0x73, 0x66, 0xf5, 0x17, 0x3f, 0x34, 0xe9, 0x3a, 0xd3, 0xe4, 0x45, + 0xa6, 0xc9, 0xb7, 0x99, 0x26, 0x7f, 0xcf, 0x34, 0xf9, 0xf3, 0x52, 0x93, 0x6e, 0x97, 0x9a, 0xf4, + 0x75, 0xa9, 0x49, 0xef, 0x9b, 0x3e, 0x49, 0xc6, 0xd3, 0x61, 0xcb, 0xa5, 0xa1, 0x49, 0x26, 0x24, + 0x21, 0xe8, 0x45, 0x80, 0x86, 0xcc, 0x5c, 0x2f, 0xce, 0xa5, 0x58, 0x1d, 0xb1, 0x37, 0xc3, 0xb2, + 0x98, 0xff, 0x97, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x17, 0x84, 0x6d, 0xd2, 0x56, 0x03, 0x00, + 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -252,6 +297,38 @@ func (this *Log) Equal(that interface{}) bool { } return true } +func (this *AccessTuple) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*AccessTuple) + if !ok { + that2, ok := that.(AccessTuple) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Address != that1.Address { + return false + } + if len(this.StorageKeys) != len(that1.StorageKeys) { + return false + } + for i := range this.StorageKeys { + if this.StorageKeys[i] != that1.StorageKeys[i] { + return false + } + } + return true +} func (m *Params) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -385,6 +462,45 @@ func (m *Log) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *AccessTuple) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *AccessTuple) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AccessTuple) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.StorageKeys) > 0 { + for iNdEx := len(m.StorageKeys) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.StorageKeys[iNdEx]) + copy(dAtA[i:], m.StorageKeys[iNdEx]) + i = encodeVarintTypes(dAtA, i, uint64(len(m.StorageKeys[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { offset -= sovTypes(v) base := offset @@ -456,6 +572,25 @@ func (m *Log) Size() (n int) { return n } +func (m *AccessTuple) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if len(m.StorageKeys) > 0 { + for _, s := range m.StorageKeys { + l = len(s) + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -884,6 +1019,120 @@ func (m *Log) Unmarshal(dAtA []byte) error { } return nil } +func (m *AccessTuple) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: AccessTuple: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AccessTuple: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StorageKeys", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StorageKeys = append(m.StorageKeys, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0