diff --git a/example/cosmwasm/cw721/artifacts/checksums.txt b/example/cosmwasm/cw721/artifacts/checksums.txt index a31da2c613..ae91b826c9 100644 --- a/example/cosmwasm/cw721/artifacts/checksums.txt +++ b/example/cosmwasm/cw721/artifacts/checksums.txt @@ -1 +1 @@ -94cdd9c3e85c26f7cec43c23bfb4b3b2b2d71a0a8d85c58df12ffec0741febc8 cwerc721.wasm +d34f50997bd0ad45badcf8174b67900806021abca011cbba658517d5af5e5eca cwerc721.wasm diff --git a/example/cosmwasm/cw721/artifacts/cwerc721.wasm b/example/cosmwasm/cw721/artifacts/cwerc721.wasm index 318ada77bc..f5ba0432f8 100644 Binary files a/example/cosmwasm/cw721/artifacts/cwerc721.wasm and b/example/cosmwasm/cw721/artifacts/cwerc721.wasm differ diff --git a/example/cosmwasm/cw721/src/contract.rs b/example/cosmwasm/cw721/src/contract.rs index 690bb262d4..8d7f678b78 100644 --- a/example/cosmwasm/cw721/src/contract.rs +++ b/example/cosmwasm/cw721/src/contract.rs @@ -35,16 +35,16 @@ pub fn execute( execute_send_nft(deps, info, contract, token_id, msg) }, ExecuteMsg::Approve { spender, token_id, expires: _ } => { - execute_approve(deps, spender, token_id) + execute_approve(deps, info, spender, token_id, true) }, - ExecuteMsg::Revoke { spender: _, token_id } => { - execute_approve(deps, "".to_string(), token_id) + ExecuteMsg::Revoke { spender, token_id } => { + execute_approve(deps, info, spender, token_id, false) }, ExecuteMsg::ApproveAll { operator, expires: _ } => { - execute_approve_all(deps, operator, true) + execute_approve_all(deps, info, operator, true) }, ExecuteMsg::RevokeAll { operator } => { - execute_approve_all(deps, operator, false) + execute_approve_all(deps, info, operator, false) }, ExecuteMsg::Burn { token_id: _ } => { execute_burn() } } @@ -82,17 +82,27 @@ pub fn execute_send_nft( pub fn execute_approve( deps: DepsMut, + info: MessageInfo, spender: String, token_id: String, + approved: bool, ) -> Result, ContractError> { let erc_addr = ERC721_ADDRESS.load(deps.storage)?; let querier = EvmQuerier::new(&deps.querier); - let payload = querier.erc721_approve_payload(spender.clone(), token_id.clone())?; + let mut payload_spender = spender.clone(); + let mut action = "approve"; + if !approved { + payload_spender = "".to_string(); + action = "revoke"; + } + let payload = querier.erc721_approve_payload(payload_spender, token_id.clone())?; let msg = EvmMsg::DelegateCallEvm { to: erc_addr, data: payload.encoded_payload }; let res = Response::new() - .add_attribute("action", "approve") + .add_attribute("action", action) .add_attribute("token_id", token_id) + .add_attribute("sender", info.sender) + .add_attribute("spender", spender.clone()) .add_message(msg); Ok(res) @@ -100,6 +110,7 @@ pub fn execute_approve( pub fn execute_approve_all( deps: DepsMut, + info: MessageInfo, to: String, approved: bool, ) -> Result, ContractError> { @@ -108,9 +119,14 @@ pub fn execute_approve_all( let querier = EvmQuerier::new(&deps.querier); let payload = querier.erc721_set_approval_all_payload(to.clone(), approved)?; let msg = EvmMsg::DelegateCallEvm { to: erc_addr, data: payload.encoded_payload }; + let mut action = "approve_all"; + if !approved { + action = "revoke_all"; + } let res = Response::new() - .add_attribute("action", "approve_all") - .add_attribute("to", to) + .add_attribute("action", action) + .add_attribute("operator", to) + .add_attribute("sender", info.sender) .add_attribute("approved", format!("{}", approved)) .add_message(msg); @@ -136,8 +152,8 @@ fn transfer_nft( let payload = querier.erc721_transfer_payload(owner, recipient.clone(), token_id.clone())?; let msg = EvmMsg::DelegateCallEvm { to: erc_addr, data: payload.encoded_payload }; let res = Response::new() - .add_attribute("from", info.sender) - .add_attribute("to", recipient) + .add_attribute("sender", info.sender) + .add_attribute("recipient", recipient) .add_attribute("token_id", token_id) .add_message(msg); diff --git a/go.mod b/go.mod index c483ecea63..abb68a669a 100644 --- a/go.mod +++ b/go.mod @@ -125,6 +125,7 @@ require ( github.com/fzipp/gocyclo v0.5.1 // indirect github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.6.3 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -172,6 +173,7 @@ require ( github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-bexpr v0.1.10 // indirect diff --git a/go.sum b/go.sum index eb91caacb6..6d4ac87043 100644 --- a/go.sum +++ b/go.sum @@ -457,6 +457,7 @@ github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2Gihuqh github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -765,6 +766,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= github.com/guptarohit/asciigraph v0.5.5/go.mod h1:dYl5wwK4gNsnFf9Zp+l06rFiDZ5YtXM6x7SRWZ3KGag= diff --git a/precompiles/ibc/ibc_test.go b/precompiles/ibc/ibc_test.go index 8a6da8c149..ad8b311dcd 100644 --- a/precompiles/ibc/ibc_test.go +++ b/precompiles/ibc/ibc_test.go @@ -2,12 +2,13 @@ package ibc_test import ( "errors" - "github.com/cosmos/ibc-go/v3/modules/core/exported" "math/big" "reflect" "testing" "time" + "github.com/cosmos/ibc-go/v3/modules/core/exported" + sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" "github.com/ethereum/go-ethereum/common" @@ -95,7 +96,7 @@ func TestPrecompile_Run(t *testing.T) { fields: fields{transferKeeper: &MockTransferKeeper{}}, args: commonArgs, wantBz: packedTrue, - wantRemainingGas: 994040, + wantRemainingGas: 994319, wantErr: false, }, { diff --git a/precompiles/wasmd/wasmd_test.go b/precompiles/wasmd/wasmd_test.go index 4dfbd65d44..95c8ba4a7b 100644 --- a/precompiles/wasmd/wasmd_test.go +++ b/precompiles/wasmd/wasmd_test.go @@ -79,7 +79,7 @@ func TestInstantiate(t *testing.T) { require.Equal(t, 2, len(outputs)) require.Equal(t, "sei1hrpna9v7vs3stzyd4z3xf00676kf78zpe2u5ksvljswn2vnjp3yslucc3n", outputs[0].(string)) require.Empty(t, outputs[1].([]byte)) - require.Equal(t, uint64(880848), g) + require.Equal(t, uint64(881127), g) amtsbz, err = sdk.NewCoins().MarshalJSON() require.Nil(t, err) @@ -102,7 +102,7 @@ func TestInstantiate(t *testing.T) { require.Equal(t, 2, len(outputs)) require.Equal(t, "sei1hrpna9v7vs3stzyd4z3xf00676kf78zpe2u5ksvljswn2vnjp3yslucc3n", outputs[0].(string)) require.Empty(t, outputs[1].([]byte)) - require.Equal(t, uint64(903904), g) + require.Equal(t, uint64(904183), g) // non-existent code ID args, _ = instantiateMethod.Inputs.Pack( @@ -174,7 +174,7 @@ func TestExecute(t *testing.T) { require.Nil(t, err) require.Equal(t, 1, len(outputs)) require.Equal(t, fmt.Sprintf("received test msg from %s with 1000usei", mockAddr.String()), string(outputs[0].([]byte))) - require.Equal(t, uint64(907107), g) + require.Equal(t, uint64(907386), g) require.Equal(t, int64(1000), testApp.BankKeeper.GetBalance(statedb.Ctx(), contractAddr, "usei").Amount.Int64()) amtsbz, err = sdk.NewCoins().MarshalJSON() @@ -263,7 +263,7 @@ func TestQuery(t *testing.T) { require.Nil(t, err) require.Equal(t, 1, len(outputs)) require.Equal(t, "{\"message\":\"query test\"}", string(outputs[0].([]byte))) - require.Equal(t, uint64(931433), g) + require.Equal(t, uint64(931712), g) // bad contract address args, _ = queryMethod.Inputs.Pack(mockAddr.String(), []byte("{\"info\":{}}")) @@ -326,7 +326,7 @@ func TestExecuteBatchOneMessage(t *testing.T) { require.Nil(t, err) require.Equal(t, 1, len(outputs)) require.Equal(t, fmt.Sprintf("received test msg from %s with 1000usei", mockAddr.String()), string((outputs[0].([][]byte))[0])) - require.Equal(t, uint64(907107), g) + require.Equal(t, uint64(907386), g) require.Equal(t, int64(1000), testApp.BankKeeper.GetBalance(statedb.Ctx(), contractAddr, "usei").Amount.Int64()) amtsbz, err = sdk.NewCoins().MarshalJSON() @@ -432,7 +432,7 @@ func TestExecuteBatchMultipleMessages(t *testing.T) { require.Equal(t, fmt.Sprintf("received test msg from %s with 1000usei", mockAddr.String()), string(parsedOutputs[0])) require.Equal(t, fmt.Sprintf("received test msg from %s with 1000usei", mockAddr.String()), string(parsedOutputs[1])) require.Equal(t, fmt.Sprintf("received test msg from %s with 1000usei", mockAddr.String()), string(parsedOutputs[2])) - require.Equal(t, uint64(726445), g) + require.Equal(t, uint64(726724), g) require.Equal(t, int64(3000), testApp.BankKeeper.GetBalance(statedb.Ctx(), contractAddr, "usei").Amount.Int64()) amtsbz2, err := sdk.NewCoins().MarshalJSON() @@ -459,7 +459,7 @@ func TestExecuteBatchMultipleMessages(t *testing.T) { require.Equal(t, fmt.Sprintf("received test msg from %s with", mockAddr.String()), string(parsedOutputs[0])) require.Equal(t, fmt.Sprintf("received test msg from %s with 1000usei", mockAddr.String()), string(parsedOutputs[1])) require.Equal(t, fmt.Sprintf("received test msg from %s with", mockAddr.String()), string(parsedOutputs[2])) - require.Equal(t, uint64(774966), g) + require.Equal(t, uint64(775245), g) require.Equal(t, int64(1000), testApp.BankKeeper.GetBalance(statedb.Ctx(), contractAddr, "usei").Amount.Int64()) // allowed delegatecall diff --git a/proto/evm/query.proto b/proto/evm/query.proto index 6f90daa9bd..f92d02df0c 100644 --- a/proto/evm/query.proto +++ b/proto/evm/query.proto @@ -23,6 +23,10 @@ service Query { rpc Pointer(QueryPointerRequest) returns (QueryPointerResponse) { option (google.api.http).get = "/sei-protocol/seichain/evm/pointer"; } + + rpc PointerVersion(QueryPointerVersionRequest) returns (QueryPointerVersionResponse) { + option (google.api.http).get = "/sei-protocol/seichain/evm/pointer_version"; + } } message QuerySeiAddressByEVMAddressRequest { @@ -62,3 +66,12 @@ message QueryPointerResponse { uint32 version = 2; bool exists = 3; } + +message QueryPointerVersionRequest { + PointerType pointer_type = 1; +} + +message QueryPointerVersionResponse { + uint32 version = 1; + uint64 cw_code_id = 2; +} diff --git a/x/evm/artifacts/erc721/artifacts.go b/x/evm/artifacts/erc721/artifacts.go index b542ee3b41..9bae2456a8 100644 --- a/x/evm/artifacts/erc721/artifacts.go +++ b/x/evm/artifacts/erc721/artifacts.go @@ -2,7 +2,7 @@ package erc721 import "embed" -const CurrentVersion uint16 = 1 +const CurrentVersion uint16 = 2 //go:embed cwerc721.wasm var f embed.FS diff --git a/x/evm/artifacts/erc721/cwerc721.wasm b/x/evm/artifacts/erc721/cwerc721.wasm index 318ada77bc..f5ba0432f8 100644 Binary files a/x/evm/artifacts/erc721/cwerc721.wasm and b/x/evm/artifacts/erc721/cwerc721.wasm differ diff --git a/x/evm/client/cli/query.go b/x/evm/client/cli/query.go index 6209125b71..ad8806f819 100644 --- a/x/evm/client/cli/query.go +++ b/x/evm/client/cli/query.go @@ -43,6 +43,7 @@ func GetQueryCmd(_ string) *cobra.Command { cmd.AddCommand(CmdQueryERC20()) cmd.AddCommand(CmdQueryPayload()) cmd.AddCommand(CmdQueryPointer()) + cmd.AddCommand(CmdQueryPointerVersion()) return cmd } @@ -301,8 +302,9 @@ func CmdQueryPointer() *cobra.Command { return err } queryClient := types.NewQueryClient(clientCtx) + ctx := cmd.Context() - res, err := queryClient.Pointer(context.Background(), &types.QueryPointerRequest{ + res, err := queryClient.Pointer(ctx, &types.QueryPointerRequest{ PointerType: types.PointerType(types.PointerType_value[args[0]]), Pointee: args[1], }) if err != nil { @@ -317,3 +319,32 @@ func CmdQueryPointer() *cobra.Command { return cmd } + +func CmdQueryPointerVersion() *cobra.Command { + cmd := &cobra.Command{ + Use: "pointer-version [type]", + Short: "Query for the current pointer version and stored code ID (if applicable)", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + ctx := cmd.Context() + + req := types.QueryPointerVersionRequest{PointerType: types.PointerType(types.PointerType_value[args[0]])} + res, err := queryClient.PointerVersion(ctx, &req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/evm/keeper/evm.go b/x/evm/keeper/evm.go index 357746c427..23db1e18e9 100644 --- a/x/evm/keeper/evm.go +++ b/x/evm/keeper/evm.go @@ -40,13 +40,16 @@ func (k *Keeper) HandleInternalEVMCall(ctx sdk.Context, req *types.MsgInternalEV } func (k *Keeper) HandleInternalEVMDelegateCall(ctx sdk.Context, req *types.MsgInternalEVMDelegateCall) (*sdk.Result, error) { - if !k.IsCWCodeHashWhitelistedForEVMDelegateCall(ctx, req.CodeHash) { - return nil, errors.New("code hash not authorized to make EVM delegate call") - } var to *common.Address if req.To != "" { addr := common.HexToAddress(req.To) to = &addr + } else { + return nil, errors.New("cannot use a CosmWasm contract to delegate-create an EVM contract") + } + addr, _, exists := k.GetPointerInfo(ctx, types.PointerReverseRegistryKey(common.BytesToAddress([]byte(req.FromContract)))) + if !exists || common.BytesToAddress(addr).Cmp(*to) != 0 { + return nil, errors.New("only pointer contract can make delegatecalls") } zeroInt := sdk.ZeroInt() senderAddr, err := sdk.AccAddressFromBech32(req.Sender) diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 451e2998e1..9fc3da36cd 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -7,6 +7,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/common" + "github.com/sei-protocol/sei-chain/x/evm/artifacts/cw20" + "github.com/sei-protocol/sei-chain/x/evm/artifacts/cw721" + "github.com/sei-protocol/sei-chain/x/evm/artifacts/erc20" + "github.com/sei-protocol/sei-chain/x/evm/artifacts/erc721" + "github.com/sei-protocol/sei-chain/x/evm/artifacts/native" "github.com/sei-protocol/sei-chain/x/evm/types" ) @@ -111,3 +116,33 @@ func (q Querier) Pointer(c context.Context, req *types.QueryPointerRequest) (*ty return nil, errors.ErrUnsupported } } + +func (q Querier) PointerVersion(c context.Context, req *types.QueryPointerVersionRequest) (*types.QueryPointerVersionResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + switch req.PointerType { + case types.PointerType_NATIVE: + return &types.QueryPointerVersionResponse{ + Version: uint32(native.CurrentVersion), + }, nil + case types.PointerType_CW20: + return &types.QueryPointerVersionResponse{ + Version: uint32(cw20.CurrentVersion), + }, nil + case types.PointerType_CW721: + return &types.QueryPointerVersionResponse{ + Version: uint32(cw721.CurrentVersion), + }, nil + case types.PointerType_ERC20: + return &types.QueryPointerVersionResponse{ + Version: uint32(erc20.CurrentVersion), + CwCodeId: q.GetStoredPointerCodeID(ctx, types.PointerType_ERC20), + }, nil + case types.PointerType_ERC721: + return &types.QueryPointerVersionResponse{ + Version: uint32(erc721.CurrentVersion), + CwCodeId: q.GetStoredPointerCodeID(ctx, types.PointerType_ERC721), + }, nil + default: + return nil, errors.ErrUnsupported + } +} diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index f8f0f426a9..234018cb33 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "encoding/binary" "encoding/json" "fmt" "math" @@ -10,7 +9,6 @@ import ( "runtime/debug" "github.com/armon/go-metrics" - "github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" @@ -24,7 +22,6 @@ import ( "github.com/sei-protocol/sei-chain/utils" "github.com/sei-protocol/sei-chain/x/evm/artifacts/erc20" "github.com/sei-protocol/sei-chain/x/evm/artifacts/erc721" - artifactsutils "github.com/sei-protocol/sei-chain/x/evm/artifacts/utils" "github.com/sei-protocol/sei-chain/x/evm/state" "github.com/sei-protocol/sei-chain/x/evm/types" ) @@ -289,19 +286,16 @@ func (server msgServer) RegisterPointer(goCtx context.Context, msg *types.MsgReg if exists && existingVersion >= currentVersion { return nil, fmt.Errorf("pointer %s already registered at version %d", existingPointer.String(), existingVersion) } - store := server.PrefixStore(ctx, types.PointerCWCodePrefix) payload := map[string]interface{}{} switch msg.PointerType { case types.PointerType_ERC20: - store = prefix.NewStore(store, types.PointerCW20ERC20Prefix) payload["erc20_address"] = msg.ErcAddress case types.PointerType_ERC721: - store = prefix.NewStore(store, types.PointerCW721ERC721Prefix) payload["erc721_address"] = msg.ErcAddress default: panic("unknown pointer type") } - codeID := binary.BigEndian.Uint64(store.Get(artifactsutils.GetVersionBz(currentVersion))) + codeID := server.GetStoredPointerCodeID(ctx, msg.PointerType) bz, err := json.Marshal(payload) if err != nil { return nil, err diff --git a/x/evm/keeper/params.go b/x/evm/keeper/params.go index 211e387d45..a70a52d864 100644 --- a/x/evm/keeper/params.go +++ b/x/evm/keeper/params.go @@ -46,7 +46,3 @@ func (k *Keeper) ChainID(ctx sdk.Context) *big.Int { return config.GetEVMChainID(ctx.ChainID()) } - -func (k *Keeper) WhitelistedCwCodeHashesForDelegateCall(ctx sdk.Context) [][]byte { - return k.GetParams(ctx).WhitelistedCwCodeHashesForDelegateCall -} diff --git a/x/evm/keeper/pointer.go b/x/evm/keeper/pointer.go index e9b2e1a07d..58f175304f 100644 --- a/x/evm/keeper/pointer.go +++ b/x/evm/keeper/pointer.go @@ -14,6 +14,7 @@ import ( "github.com/sei-protocol/sei-chain/x/evm/artifacts/erc20" "github.com/sei-protocol/sei-chain/x/evm/artifacts/erc721" "github.com/sei-protocol/sei-chain/x/evm/artifacts/native" + artifactsutils "github.com/sei-protocol/sei-chain/x/evm/artifacts/utils" "github.com/sei-protocol/sei-chain/x/evm/types" ) @@ -205,3 +206,23 @@ func (k *Keeper) deletePointerInfo(ctx sdk.Context, pref []byte, version uint16) binary.BigEndian.PutUint16(versionBz, version) store.Delete(versionBz) } + +func (k *Keeper) GetStoredPointerCodeID(ctx sdk.Context, pointerType types.PointerType) uint64 { + store := k.PrefixStore(ctx, types.PointerCWCodePrefix) + var versionBz []byte + switch pointerType { + case types.PointerType_ERC20: + store = prefix.NewStore(store, types.PointerCW20ERC20Prefix) + versionBz = artifactsutils.GetVersionBz(erc20.CurrentVersion) + case types.PointerType_ERC721: + store = prefix.NewStore(store, types.PointerCW721ERC721Prefix) + versionBz = artifactsutils.GetVersionBz(erc721.CurrentVersion) + default: + return 0 + } + bz := store.Get(versionBz) + if bz == nil { + return 0 + } + return binary.BigEndian.Uint64(bz) +} diff --git a/x/evm/keeper/whitelist.go b/x/evm/keeper/whitelist.go deleted file mode 100644 index 5e85bfbf43..0000000000 --- a/x/evm/keeper/whitelist.go +++ /dev/null @@ -1,16 +0,0 @@ -package keeper - -import ( - "bytes" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func (k *Keeper) IsCWCodeHashWhitelistedForEVMDelegateCall(ctx sdk.Context, h []byte) bool { - for _, w := range k.WhitelistedCwCodeHashesForDelegateCall(ctx) { - if bytes.Equal(w, h) { - return true - } - } - return false -} diff --git a/x/evm/keeper/whitelist_test.go b/x/evm/keeper/whitelist_test.go deleted file mode 100644 index f25db274b8..0000000000 --- a/x/evm/keeper/whitelist_test.go +++ /dev/null @@ -1,14 +0,0 @@ -package keeper_test - -import ( - "testing" - - keepertest "github.com/sei-protocol/sei-chain/testutil/keeper" - "github.com/stretchr/testify/require" -) - -func TestWhitelist(t *testing.T) { - k, ctx := keepertest.MockEVMKeeper() - require.True(t, k.IsCWCodeHashWhitelistedForEVMDelegateCall(ctx, k.WhitelistedCwCodeHashesForDelegateCall(ctx)[0])) - require.False(t, k.IsCWCodeHashWhitelistedForEVMDelegateCall(ctx, []byte("1"))) -} diff --git a/x/evm/migrations/store_cw_pointer_code.go b/x/evm/migrations/store_cw_pointer_code.go index 2e188ec24d..3dea8ed44c 100644 --- a/x/evm/migrations/store_cw_pointer_code.go +++ b/x/evm/migrations/store_cw_pointer_code.go @@ -10,23 +10,27 @@ import ( "github.com/sei-protocol/sei-chain/x/evm/types" ) -func StoreCWPointerCode(ctx sdk.Context, k *keeper.Keeper) error { - erc20CodeID, err := k.WasmKeeper().Create(ctx, k.AccountKeeper().GetModuleAddress(types.ModuleName), erc20.GetBin(), nil) - if err != nil { - panic(err) +func StoreCWPointerCode(ctx sdk.Context, k *keeper.Keeper, store20 bool, store721 bool) error { + if store20 { + erc20CodeID, err := k.WasmKeeper().Create(ctx, k.AccountKeeper().GetModuleAddress(types.ModuleName), erc20.GetBin(), nil) + if err != nil { + panic(err) + } + prefix.NewStore(k.PrefixStore(ctx, types.PointerCWCodePrefix), types.PointerCW20ERC20Prefix).Set( + artifactsutils.GetVersionBz(erc20.CurrentVersion), + artifactsutils.GetCodeIDBz(erc20CodeID), + ) } - prefix.NewStore(k.PrefixStore(ctx, types.PointerCWCodePrefix), types.PointerCW20ERC20Prefix).Set( - artifactsutils.GetVersionBz(erc20.CurrentVersion), - artifactsutils.GetCodeIDBz(erc20CodeID), - ) - erc721CodeID, err := k.WasmKeeper().Create(ctx, k.AccountKeeper().GetModuleAddress(types.ModuleName), erc721.GetBin(), nil) - if err != nil { - panic(err) + if store721 { + erc721CodeID, err := k.WasmKeeper().Create(ctx, k.AccountKeeper().GetModuleAddress(types.ModuleName), erc721.GetBin(), nil) + if err != nil { + panic(err) + } + prefix.NewStore(k.PrefixStore(ctx, types.PointerCWCodePrefix), types.PointerCW721ERC721Prefix).Set( + artifactsutils.GetVersionBz(erc721.CurrentVersion), + artifactsutils.GetCodeIDBz(erc721CodeID), + ) } - prefix.NewStore(k.PrefixStore(ctx, types.PointerCWCodePrefix), types.PointerCW721ERC721Prefix).Set( - artifactsutils.GetVersionBz(erc721.CurrentVersion), - artifactsutils.GetCodeIDBz(erc721CodeID), - ) return nil } diff --git a/x/evm/module.go b/x/evm/module.go index 1c834bcea0..0e42a94ba0 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -141,12 +141,16 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { }) _ = cfg.RegisterMigration(types.ModuleName, 4, func(ctx sdk.Context) error { - return migrations.StoreCWPointerCode(ctx, am.keeper) + return migrations.StoreCWPointerCode(ctx, am.keeper, true, true) }) _ = cfg.RegisterMigration(types.ModuleName, 5, func(ctx sdk.Context) error { return migrations.FixTotalSupply(ctx, am.keeper) }) + + _ = cfg.RegisterMigration(types.ModuleName, 6, func(ctx sdk.Context) error { + return migrations.StoreCWPointerCode(ctx, am.keeper, false, true) + }) } // RegisterInvariants registers the capability module's invariants. @@ -171,7 +175,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 6 } +func (AppModule) ConsensusVersion() uint64 { return 7 } // BeginBlock executes all ABCI BeginBlock logic respective to the capability module. func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { diff --git a/x/evm/module_test.go b/x/evm/module_test.go index 4082dcb86c..d91c6e109b 100644 --- a/x/evm/module_test.go +++ b/x/evm/module_test.go @@ -45,13 +45,13 @@ func TestModuleExportGenesis(t *testing.T) { module := evm.NewAppModule(nil, k) jsonMsg := module.ExportGenesis(ctx, types.ModuleCdc) jsonStr := string(jsonMsg) - assert.Equal(t, "{\"params\":{\"priority_normalizer\":\"1.000000000000000000\",\"base_fee_per_gas\":\"0.000000000000000000\",\"minimum_fee_per_gas\":\"1000000000.000000000000000000\",\"whitelisted_cw_code_hashes_for_delegate_call\":[\"ol1416zS7kfMOcIk4WL+ebU+a75u0qVujAqGWT6+YQI=\",\"lM3Zw+hcJvfOxDwjv7SzsrLXGgqNhcWN8S/+wHQf68g=\"]},\"address_associations\":[{\"sei_address\":\"sei17xpfvakm2amg962yls6f84z3kell8c5la4jkdu\",\"eth_address\":\"0x27F7B8B8B5A4e71E8E9aA671f4e4031E3773303F\"}],\"codes\":[],\"states\":[],\"nonces\":[],\"serialized\":[{\"prefix\":\"Fg==\",\"key\":\"AwAB\",\"value\":\"AAAAAAAAAAM=\"},{\"prefix\":\"Fg==\",\"key\":\"BAAB\",\"value\":\"AAAAAAAAAAQ=\"}]}", jsonStr) + assert.Equal(t, "{\"params\":{\"priority_normalizer\":\"1.000000000000000000\",\"base_fee_per_gas\":\"0.000000000000000000\",\"minimum_fee_per_gas\":\"1000000000.000000000000000000\",\"whitelisted_cw_code_hashes_for_delegate_call\":[]},\"address_associations\":[{\"sei_address\":\"sei17xpfvakm2amg962yls6f84z3kell8c5la4jkdu\",\"eth_address\":\"0x27F7B8B8B5A4e71E8E9aA671f4e4031E3773303F\"}],\"codes\":[],\"states\":[],\"nonces\":[],\"serialized\":[{\"prefix\":\"Fg==\",\"key\":\"AwAB\",\"value\":\"AAAAAAAAAAM=\"},{\"prefix\":\"Fg==\",\"key\":\"BAAC\",\"value\":\"AAAAAAAAAAQ=\"}]}", jsonStr) } func TestConsensusVersion(t *testing.T) { k, _ := testkeeper.MockEVMKeeper() module := evm.NewAppModule(nil, k) - assert.Equal(t, uint64(6), module.ConsensusVersion()) + assert.Equal(t, uint64(7), module.ConsensusVersion()) } func TestABCI(t *testing.T) { diff --git a/x/evm/types/params.go b/x/evm/types/params.go index ff99431f58..faff9e9ec6 100644 --- a/x/evm/types/params.go +++ b/x/evm/types/params.go @@ -1,7 +1,6 @@ package types import ( - "encoding/hex" "errors" fmt "fmt" @@ -11,9 +10,10 @@ import ( ) var ( - KeyPriorityNormalizer = []byte("KeyPriorityNormalizer") - KeyBaseFeePerGas = []byte("KeyBaseFeePerGas") - KeyMinFeePerGas = []byte("KeyMinFeePerGas") + KeyPriorityNormalizer = []byte("KeyPriorityNormalizer") + KeyBaseFeePerGas = []byte("KeyBaseFeePerGas") + KeyMinFeePerGas = []byte("KeyMinFeePerGas") + // deprecated KeyWhitelistedCwCodeHashesForDelegateCall = []byte("KeyWhitelistedCwCodeHashesForDelegateCall") ) @@ -120,7 +120,5 @@ func validateWhitelistedCwHashesForDelegateCall(i interface{}) error { } func generateDefaultWhitelistedCwCodeHashesForDelegateCall() [][]byte { - cw20, _ := hex.DecodeString("A25D78D7ACD2EE47CC39C224E162FE79B53E6BBE6ED2A56E8C0A86593EBE6102") - cw721, _ := hex.DecodeString("94CDD9C3E85C26F7CEC43C23BFB4B3B2B2D71A0A8D85C58DF12FFEC0741FEBC8") - return [][]byte{cw20, cw721} + return [][]byte(nil) } diff --git a/x/evm/types/query.pb.go b/x/evm/types/query.pb.go index 5c80febcc6..a13d537890 100644 --- a/x/evm/types/query.pb.go +++ b/x/evm/types/query.pb.go @@ -428,6 +428,102 @@ func (m *QueryPointerResponse) GetExists() bool { return false } +type QueryPointerVersionRequest struct { + PointerType PointerType `protobuf:"varint,1,opt,name=pointer_type,json=pointerType,proto3,enum=seiprotocol.seichain.evm.PointerType" json:"pointer_type,omitempty"` +} + +func (m *QueryPointerVersionRequest) Reset() { *m = QueryPointerVersionRequest{} } +func (m *QueryPointerVersionRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPointerVersionRequest) ProtoMessage() {} +func (*QueryPointerVersionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_11c0d37eed5339f7, []int{8} +} +func (m *QueryPointerVersionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPointerVersionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPointerVersionRequest.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 *QueryPointerVersionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPointerVersionRequest.Merge(m, src) +} +func (m *QueryPointerVersionRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryPointerVersionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPointerVersionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPointerVersionRequest proto.InternalMessageInfo + +func (m *QueryPointerVersionRequest) GetPointerType() PointerType { + if m != nil { + return m.PointerType + } + return PointerType_ERC20 +} + +type QueryPointerVersionResponse struct { + Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + CwCodeId uint64 `protobuf:"varint,2,opt,name=cw_code_id,json=cwCodeId,proto3" json:"cw_code_id,omitempty"` +} + +func (m *QueryPointerVersionResponse) Reset() { *m = QueryPointerVersionResponse{} } +func (m *QueryPointerVersionResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPointerVersionResponse) ProtoMessage() {} +func (*QueryPointerVersionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_11c0d37eed5339f7, []int{9} +} +func (m *QueryPointerVersionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryPointerVersionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryPointerVersionResponse.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 *QueryPointerVersionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPointerVersionResponse.Merge(m, src) +} +func (m *QueryPointerVersionResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryPointerVersionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPointerVersionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryPointerVersionResponse proto.InternalMessageInfo + +func (m *QueryPointerVersionResponse) GetVersion() uint32 { + if m != nil { + return m.Version + } + return 0 +} + +func (m *QueryPointerVersionResponse) GetCwCodeId() uint64 { + if m != nil { + return m.CwCodeId + } + return 0 +} + func init() { proto.RegisterType((*QuerySeiAddressByEVMAddressRequest)(nil), "seiprotocol.seichain.evm.QuerySeiAddressByEVMAddressRequest") proto.RegisterType((*QuerySeiAddressByEVMAddressResponse)(nil), "seiprotocol.seichain.evm.QuerySeiAddressByEVMAddressResponse") @@ -437,47 +533,54 @@ func init() { proto.RegisterType((*QueryStaticCallResponse)(nil), "seiprotocol.seichain.evm.QueryStaticCallResponse") proto.RegisterType((*QueryPointerRequest)(nil), "seiprotocol.seichain.evm.QueryPointerRequest") proto.RegisterType((*QueryPointerResponse)(nil), "seiprotocol.seichain.evm.QueryPointerResponse") + proto.RegisterType((*QueryPointerVersionRequest)(nil), "seiprotocol.seichain.evm.QueryPointerVersionRequest") + proto.RegisterType((*QueryPointerVersionResponse)(nil), "seiprotocol.seichain.evm.QueryPointerVersionResponse") } func init() { proto.RegisterFile("evm/query.proto", fileDescriptor_11c0d37eed5339f7) } var fileDescriptor_11c0d37eed5339f7 = []byte{ - // 547 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xcd, 0x6e, 0xd3, 0x4c, - 0x14, 0x8d, 0xf3, 0x7d, 0x6d, 0xe9, 0x6d, 0x29, 0xd2, 0x80, 0x42, 0x14, 0x21, 0x53, 0x99, 0x1f, - 0x45, 0x48, 0xb6, 0xa1, 0x6c, 0xcb, 0x82, 0xa0, 0x0a, 0x36, 0x48, 0x60, 0x10, 0x0b, 0x36, 0xd1, - 0xc4, 0xb9, 0xa4, 0x23, 0xc5, 0x1e, 0xd7, 0x33, 0xb1, 0xea, 0x2d, 0x4f, 0x80, 0x04, 0x2f, 0xc0, - 0xc3, 0x20, 0xb1, 0xac, 0x60, 0xc3, 0x12, 0x25, 0x3c, 0x08, 0xf2, 0x78, 0x9c, 0xb8, 0x6d, 0x62, - 0xb7, 0xec, 0xe6, 0x8e, 0xe7, 0x9c, 0x7b, 0xce, 0xf5, 0xb9, 0x70, 0x0d, 0x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, 0xdf, 0xcf, 0x44, 0x7d, 0x31, 0x60, 0x43, 0xa7, 0x93, - 0xd8, 0x35, 0xed, 0x4e, 0x2f, 0x50, 0xc7, 0xb9, 0xe8, 0x73, 0x2d, 0xed, 0x81, 0x92, 0x76, 0x97, - 0x58, 0x15, 0xd2, 0xf4, 0x1a, 0xf4, 0x9e, 0x7f, 0x9f, 0x9a, 0xc6, 0xc9, 0xd4, 0x34, 0x7e, 0x4f, - 0x4d, 0xe3, 0xd3, 0xcc, 0x6c, 0x9c, 0xcc, 0xcc, 0xc6, 0xaf, 0x99, 0xd9, 0x78, 0x6f, 0x8f, 0x98, - 0x3c, 0x9c, 0x0c, 0x1c, 0x9f, 0x07, 0xe7, 0x78, 0xec, 0x9c, 0xe8, 0x58, 0x51, 0x65, 0x4b, 0x2d, - 0x06, 0xeb, 0xea, 0xfb, 0xe3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7d, 0xec, 0x65, 0x60, 0x2a, - 0x06, 0x00, 0x00, + // 627 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xcd, 0x6e, 0xd3, 0x4e, + 0x14, 0xc5, 0xeb, 0xfc, 0xfb, 0xef, 0xc7, 0x6d, 0x29, 0xd2, 0x80, 0x4a, 0x64, 0x2a, 0x53, 0x99, + 0x0f, 0x55, 0x15, 0xb1, 0xa1, 0xc0, 0xae, 0x2c, 0x68, 0x55, 0x01, 0x0b, 0x24, 0x30, 0xd0, 0x05, + 0x1b, 0xcb, 0xb5, 0x6f, 0xdb, 0x91, 0x62, 0x8f, 0xeb, 0x99, 0xa4, 0xcd, 0x96, 0x05, 0x6b, 0x24, + 0x78, 0x01, 0x1e, 0x81, 0x87, 0x40, 0x62, 0x59, 0x89, 0x0d, 0x4b, 0xd4, 0xf0, 0x20, 0xc8, 0xe3, + 0x71, 0xe2, 0xb4, 0x89, 0x9d, 0x20, 0x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0xee, 0xd8, 0x1c, 0x69, 0x23, 0xf7, 0xb1, 0x73, 0x1f, 0x3b, 0xfd, 0x74, + 0x14, 0x62, 0x25, 0xe7, 0x18, 0x1e, 0xa0, 0xca, 0x39, 0x4a, 0xe3, 0x5b, 0x39, 0x47, 0x79, 0x6a, + 0xc7, 0x9a, 0xa3, 0x10, 0x6b, 0xf2, 0x45, 0x03, 0xe8, 0x47, 0x8c, 0xdc, 0xab, 0xba, 0xc5, 0xf3, + 0x59, 0xd6, 0xef, 0x4f, 0xa0, 0x98, 0xe4, 0xae, 0xa5, 0xcc, 0xf5, 0x53, 0xa8, 0xcf, 0x1a, 0xcc, + 0xaa, 0x07, 0x49, 0x1a, 0x15, 0xed, 0x06, 0xf3, 0xaf, 0x5b, 0xe3, 0x1e, 0x57, 0x68, 0xeb, 0x12, + 0xed, 0x16, 0x31, 0x4b, 0xd0, 0xf2, 0x14, 0x7f, 0xd5, 0x60, 0x69, 0x30, 0x27, 0xe4, 0xe1, 0x78, + 0xed, 0x06, 0xe3, 0xab, 0x3f, 0x9a, 0x50, 0xa5, 0x58, 0x37, 0x24, 0xeb, 0x5d, 0xb2, 0x5e, 0xcd, + 0xea, 0xaa, 0x98, 0x6e, 0x3d, 0xfd, 0x7e, 0x66, 0x68, 0xa7, 0x67, 0x86, 0xf6, 0xeb, 0xcc, 0xd0, + 0x3e, 0x76, 0x8d, 0xa9, 0xd3, 0xae, 0x31, 0xf5, 0xb3, 0x6b, 0x4c, 0xbd, 0x6b, 0x1c, 0x50, 0x71, + 0xd8, 0xda, 0xb3, 0x7c, 0x16, 0x5e, 0xf0, 0x6b, 0x64, 0x86, 0x27, 0xd2, 0x32, 0xfd, 0xc2, 0xf0, + 0xbd, 0x19, 0xf9, 0xfb, 0x83, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x5d, 0xbe, 0x8f, 0x9b, 0x9d, + 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -496,6 +599,7 @@ type QueryClient interface { EVMAddressBySeiAddress(ctx context.Context, in *QueryEVMAddressBySeiAddressRequest, opts ...grpc.CallOption) (*QueryEVMAddressBySeiAddressResponse, error) StaticCall(ctx context.Context, in *QueryStaticCallRequest, opts ...grpc.CallOption) (*QueryStaticCallResponse, error) Pointer(ctx context.Context, in *QueryPointerRequest, opts ...grpc.CallOption) (*QueryPointerResponse, error) + PointerVersion(ctx context.Context, in *QueryPointerVersionRequest, opts ...grpc.CallOption) (*QueryPointerVersionResponse, error) } type queryClient struct { @@ -542,12 +646,22 @@ func (c *queryClient) Pointer(ctx context.Context, in *QueryPointerRequest, opts return out, nil } +func (c *queryClient) PointerVersion(ctx context.Context, in *QueryPointerVersionRequest, opts ...grpc.CallOption) (*QueryPointerVersionResponse, error) { + out := new(QueryPointerVersionResponse) + err := c.cc.Invoke(ctx, "/seiprotocol.seichain.evm.Query/PointerVersion", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { SeiAddressByEVMAddress(context.Context, *QuerySeiAddressByEVMAddressRequest) (*QuerySeiAddressByEVMAddressResponse, error) EVMAddressBySeiAddress(context.Context, *QueryEVMAddressBySeiAddressRequest) (*QueryEVMAddressBySeiAddressResponse, error) StaticCall(context.Context, *QueryStaticCallRequest) (*QueryStaticCallResponse, error) Pointer(context.Context, *QueryPointerRequest) (*QueryPointerResponse, error) + PointerVersion(context.Context, *QueryPointerVersionRequest) (*QueryPointerVersionResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -566,6 +680,9 @@ func (*UnimplementedQueryServer) StaticCall(ctx context.Context, req *QueryStati func (*UnimplementedQueryServer) Pointer(ctx context.Context, req *QueryPointerRequest) (*QueryPointerResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Pointer not implemented") } +func (*UnimplementedQueryServer) PointerVersion(ctx context.Context, req *QueryPointerVersionRequest) (*QueryPointerVersionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PointerVersion not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -643,6 +760,24 @@ func _Query_Pointer_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } +func _Query_PointerVersion_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPointerVersionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).PointerVersion(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/seiprotocol.seichain.evm.Query/PointerVersion", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).PointerVersion(ctx, req.(*QueryPointerVersionRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "seiprotocol.seichain.evm.Query", HandlerType: (*QueryServer)(nil), @@ -663,6 +798,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Pointer", Handler: _Query_Pointer_Handler, }, + { + MethodName: "PointerVersion", + Handler: _Query_PointerVersion_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "evm/query.proto", @@ -955,6 +1094,67 @@ func (m *QueryPointerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryPointerVersionRequest) 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 *QueryPointerVersionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPointerVersionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PointerType != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.PointerType)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryPointerVersionResponse) 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 *QueryPointerVersionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryPointerVersionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CwCodeId != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.CwCodeId)) + i-- + dAtA[i] = 0x10 + } + if m.Version != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1089,6 +1289,33 @@ func (m *QueryPointerResponse) Size() (n int) { return n } +func (m *QueryPointerVersionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PointerType != 0 { + n += 1 + sovQuery(uint64(m.PointerType)) + } + return n +} + +func (m *QueryPointerVersionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Version != 0 { + n += 1 + sovQuery(uint64(m.Version)) + } + if m.CwCodeId != 0 { + n += 1 + sovQuery(uint64(m.CwCodeId)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1885,6 +2112,163 @@ func (m *QueryPointerResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryPointerVersionRequest) 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 ErrIntOverflowQuery + } + 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: QueryPointerVersionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPointerVersionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PointerType", wireType) + } + m.PointerType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PointerType |= PointerType(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryPointerVersionResponse) 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 ErrIntOverflowQuery + } + 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: QueryPointerVersionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryPointerVersionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CwCodeId", wireType) + } + m.CwCodeId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CwCodeId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/evm/types/query.pb.gw.go b/x/evm/types/query.pb.gw.go index 8d4d10c212..72c5e53f0c 100644 --- a/x/evm/types/query.pb.gw.go +++ b/x/evm/types/query.pb.gw.go @@ -177,6 +177,42 @@ func local_request_Query_Pointer_0(ctx context.Context, marshaler runtime.Marsha } +var ( + filter_Query_PointerVersion_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_PointerVersion_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPointerVersionRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PointerVersion_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.PointerVersion(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_PointerVersion_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPointerVersionRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_PointerVersion_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.PointerVersion(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -275,6 +311,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_PointerVersion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_PointerVersion_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PointerVersion_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -396,6 +455,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_PointerVersion_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_PointerVersion_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_PointerVersion_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -407,6 +486,8 @@ var ( pattern_Query_StaticCall_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sei-protocol", "seichain", "evm", "static_call"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_Pointer_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sei-protocol", "seichain", "evm", "pointer"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_PointerVersion_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sei-protocol", "seichain", "evm", "pointer_version"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -417,4 +498,6 @@ var ( forward_Query_StaticCall_0 = runtime.ForwardResponseMessage forward_Query_Pointer_0 = runtime.ForwardResponseMessage + + forward_Query_PointerVersion_0 = runtime.ForwardResponseMessage )