diff --git a/.golangci.yml b/.golangci.yml index 3902e83569..8bddfc6a7a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -62,6 +62,7 @@ linters: - third_party$ - builtin$ - examples$ + - x/evm/types/preinstall.go issues: max-same-issues: 50 formatters: @@ -72,4 +73,4 @@ formatters: paths: - third_party$ - builtin$ - - examples$ + - examples$ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d68bf5767c..a831e32b58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (evm) [#725](https://github.com/crypto-org-chain/ethermint/pull/725) feat(RPC): add authorizationList from eth_getTransactionByHash response for EIP-7702 transactions * (evm) [#740](https://github.com/crypto-org-chain/ethermint/pull/740) fix: missing tx context during vm initialisation * (evm) [#742](https://github.com/crypto-org-chain/ethermint/pull/742) fix: prevent nil pointer dereference in tracer hooks +* (evm) [#728](https://github.com/crypto-org-chain/ethermint/pull/728) feat: support preinstalls ## [v0.22.0] - 2025-08-12 diff --git a/evmd/app.go b/evmd/app.go index 88a5499366..947be5230e 100644 --- a/evmd/app.go +++ b/evmd/app.go @@ -191,8 +191,6 @@ var ( _ evmserver.AppWithPendingTxListener = (*EthermintApp)(nil) ) -type GenesisState map[string]json.RawMessage - // var _ server.Application (*EthermintApp)(nil) // EthermintApp implements an extended ABCI application. It is an application @@ -926,7 +924,11 @@ func (app *EthermintApp) InterfaceRegistry() types.InterfaceRegistry { // DefaultGenesis returns a default genesis from the registered AppModuleBasic's. func (app *EthermintApp) DefaultGenesis() map[string]json.RawMessage { - return app.BasicModuleManager.DefaultGenesis(app.appCodec) + genesis := app.BasicModuleManager.DefaultGenesis(app.appCodec) + evmGenState := NewEVMGenesisState() + genesis[evmtypes.ModuleName] = app.appCodec.MustMarshalJSON(evmGenState) + + return genesis } func (app *EthermintApp) TxConfig() client.TxConfig { diff --git a/evmd/genesis.go b/evmd/genesis.go new file mode 100644 index 0000000000..edf405fc88 --- /dev/null +++ b/evmd/genesis.go @@ -0,0 +1,27 @@ +package evmd + +import ( + "encoding/json" + + evmtypes "github.com/evmos/ethermint/x/evm/types" +) + +// GenesisState of the blockchain is represented here as a map of raw json +// messages key'd by an identifier string. +// The identifier is used to determine which module genesis information belongs +// to so it may be appropriately routed during init chain. +// Within this application default genesis information is retrieved from +// the ModuleBasicManager which populates json from each BasicModule +// object provided to it during init. +type GenesisState map[string]json.RawMessage + +// NewEVMGenesisState returns the default genesis state for the EVM module. +// +// NOTE: for the example chain implementation we need to set the default EVM denomination, +// enable ALL precompiles, and include default preinstalls. +func NewEVMGenesisState() *evmtypes.GenesisState { + evmGenState := evmtypes.DefaultGenesisState() + evmGenState.Preinstalls = evmtypes.DefaultPreinstalls + + return evmGenState +} diff --git a/go.mod b/go.mod index b542b09e1c..85a2c8e717 100644 --- a/go.mod +++ b/go.mod @@ -240,7 +240,7 @@ require ( github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ulikunitz/xz v0.5.14 // indirect + github.com/ulikunitz/xz v0.5.15 // indirect github.com/zeebo/errs v1.4.0 // indirect github.com/zondax/hid v0.9.2 // indirect github.com/zondax/ledger-go v0.14.3 // indirect diff --git a/go.sum b/go.sum index 9d04b6d738..e4b5f515b2 100644 --- a/go.sum +++ b/go.sum @@ -1701,8 +1701,8 @@ github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3C github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= -github.com/ulikunitz/xz v0.5.14 h1:uv/0Bq533iFdnMHZdRBTOlaNMdb1+ZxXIlHDZHIHcvg= -github.com/ulikunitz/xz v0.5.14/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY= +github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= diff --git a/proto/ethermint/evm/v1/genesis.proto b/proto/ethermint/evm/v1/genesis.proto index 67092d42d9..ad620b211a 100644 --- a/proto/ethermint/evm/v1/genesis.proto +++ b/proto/ethermint/evm/v1/genesis.proto @@ -1,7 +1,9 @@ syntax = "proto3"; package ethermint.evm.v1; +import "amino/amino.proto"; import "ethermint/evm/v1/params.proto"; +import "ethermint/evm/v1/preinstall.proto"; import "ethermint/evm/v1/state.proto"; import "gogoproto/gogo.proto"; @@ -13,6 +15,9 @@ message GenesisState { repeated GenesisAccount accounts = 1 [(gogoproto.nullable) = false]; // params defines all the parameters of the module. Params params = 2 [(gogoproto.nullable) = false]; + // preinstalls defines a set of predefined contracts + repeated Preinstall preinstalls = 3 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } // GenesisAccount defines an account to be initialized in the genesis state. diff --git a/proto/ethermint/evm/v1/preinstall.proto b/proto/ethermint/evm/v1/preinstall.proto new file mode 100644 index 0000000000..546ed32558 --- /dev/null +++ b/proto/ethermint/evm/v1/preinstall.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package ethermint.evm.v1; + +option go_package = "github.com/evmos/ethermint/x/evm/types"; + +// Preinstall defines a contract that is preinstalled on-chain with a specific +// contract address and bytecode +message Preinstall { + // name of the preinstall contract + string name = 1; + // address in hex format of the preinstall contract + string address = 2; + // code in hex format for the preinstall contract + string code = 3; +} \ No newline at end of file diff --git a/proto/ethermint/evm/v1/tx.proto b/proto/ethermint/evm/v1/tx.proto index 694ed9591f..45b9582d31 100644 --- a/proto/ethermint/evm/v1/tx.proto +++ b/proto/ethermint/evm/v1/tx.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package ethermint.evm.v1; +import "amino/amino.proto"; import "cosmos/msg/v1/msg.proto"; import "cosmos_proto/cosmos.proto"; import "gogoproto/gogo.proto"; @@ -9,6 +10,7 @@ import "google/protobuf/any.proto"; import "ethermint/evm/v1/access_tuple.proto"; import "ethermint/evm/v1/log.proto"; import "ethermint/evm/v1/params.proto"; +import "ethermint/evm/v1/preinstall.proto"; import "ethermint/evm/v1/set_code_authorization.proto"; option go_package = "github.com/evmos/ethermint/x/evm/types"; @@ -23,6 +25,10 @@ service Msg { // UpdateParams defined a governance operation for updating the x/evm module parameters. // The authority is hard-coded to the Cosmos SDK x/gov module account rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); + + // UpdateParams defined a governance operation for updating the x/evm module parameters. + // The authority is hard-coded to the Cosmos SDK x/gov module account + rpc RegisterPreinstalls(MsgRegisterPreinstalls) returns (MsgRegisterPreinstallsResponse); } // MsgEthereumTx encapsulates an Ethereum transaction as an SDK message. @@ -225,3 +231,19 @@ message MsgUpdateParams { // MsgUpdateParamsResponse defines the response structure for executing a // MsgUpdateParams message. message MsgUpdateParamsResponse {} + +// MsgRegisterPreinstalls defines a Msg for creating preinstalls in evm state. +message MsgRegisterPreinstalls { + option (cosmos.msg.v1.signer) = "authority"; + + // authority is the address of the governance account. + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // preinstalls defines the preinstalls to create. + repeated Preinstall preinstalls = 2 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; +} + +// MsgRegisterPreinstallsResponse defines the response structure for executing a +// MsgRegisterPreinstalls message. +message MsgRegisterPreinstallsResponse {} \ No newline at end of file diff --git a/x/evm/genesis.go b/x/evm/genesis.go index db3799d35b..2a62c68b1f 100644 --- a/x/evm/genesis.go +++ b/x/evm/genesis.go @@ -82,6 +82,10 @@ func InitGenesis( } } + if err := k.AddPreinstalls(ctx, data.Preinstalls); err != nil { + panic(fmt.Errorf("error adding preinstalls: %s", err)) + } + return []abci.ValidatorUpdate{} } diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 1d9fb38696..33d5732564 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -208,7 +208,6 @@ func (k Keeper) Code(c context.Context, req *types.QueryCodeRequest) (*types.Que address := common.HexToAddress(req.Address) acct := k.GetAccount(ctx, address) - var code []byte if acct != nil && acct.IsContract() { code = k.GetCode(ctx, common.BytesToHash(acct.CodeHash)) diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index fd223435e0..d41f613a5b 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -18,6 +18,8 @@ package keeper import ( "math/big" + "github.com/ethereum/go-ethereum/crypto" + errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" @@ -339,3 +341,68 @@ func (k Keeper) DeleteHeaderHash(ctx sdk.Context, height uint64) { store := ctx.KVStore(k.storeKey) store.Delete(types.GetHeaderHashKey(height)) } + +func (k *Keeper) AddPreinstalls(ctx sdk.Context, preinstalls []types.Preinstall) error { + for _, preinstall := range preinstalls { + address := common.HexToAddress(preinstall.Address) + accAddress := sdk.AccAddress(address.Bytes()) + + if len(preinstall.Code) == 0 { + return errorsmod.Wrapf(types.ErrInvalidPreinstall, + "preinstall %s, address %s has no code", preinstall.Name, preinstall.Address) + } + + // check that the address does not conflict with the precompiles + cfg, err := k.EVMBlockConfig(ctx, k.ChainID()) + if err != nil { + return err + } + for _, fn := range k.customContractFns { + c := fn(ctx, cfg.Rules) + if address == c.Address() { + return errorsmod.Wrapf(types.ErrInvalidPreinstall, + "preinstall %s, address %s already exists as a precompile", preinstall.Name, preinstall.Address) + } + } + + codeHash := crypto.Keccak256Hash(common.FromHex(preinstall.Code)) + codeHashBytes := codeHash.Bytes() + if types.IsEmptyCodeHash(codeHashBytes) { + k.Logger(ctx).Error("preinstall has empty code hash", + "preinstall address", preinstall.Address) + return errorsmod.Wrapf(types.ErrInvalidPreinstall, + "preinstall %s, address %s has empty code hash", preinstall.Name, preinstall.Address) + } + + acct := k.accountKeeper.GetAccount(ctx, accAddress) + // check that the account is not already set + if acct != nil { + return errorsmod.Wrapf(types.ErrInvalidPreinstall, + "preinstall %s, address %s already has an account in account keeper", preinstall.Name, preinstall.Address) + } + // create account with the account keeper and set code hash + acct = k.accountKeeper.NewAccountWithAddress(ctx, accAddress) + if ethAcct, ok := acct.(ethermint.EthAccountI); ok { + if err := ethAcct.SetCodeHash(codeHash); err != nil { + return err + } + } + k.accountKeeper.SetAccount(ctx, acct) + k.SetCode(ctx, codeHashBytes, common.FromHex(preinstall.Code)) + + // We are not setting any storage for preinstalls, so we skip that step. + } + return nil +} + +// GetCodeHash loads the code hash from the database for the given contract address. +func (k *Keeper) GetCodeHash(acct sdk.AccountI) common.Hash { + if ethAcct, ok := acct.(ethermint.EthAccountI); ok { + hash := ethAcct.GetCodeHash() + if len(hash.Bytes()) == 0 { + return common.BytesToHash(types.EmptyCodeHash) + } + return hash + } + return common.BytesToHash(types.EmptyCodeHash) +} diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go index e8f4f2c90c..bde3244214 100644 --- a/x/evm/keeper/keeper_test.go +++ b/x/evm/keeper/keeper_test.go @@ -104,28 +104,29 @@ func (suite *KeeperTestSuite) TestBaseFee() { func (suite *KeeperTestSuite) TestGetAccountStorage() { testCases := []struct { name string - malleate func() - expRes []int + malleate func() common.Address }{ { "Only one account that's not a contract (no storage)", - func() {}, - []int{0}, + nil, }, { "Two accounts - one contract (with storage), one wallet", - func() { + func() common.Address { supply := big.NewInt(100) - suite.DeployTestContract(suite.T(), suite.Address, supply, suite.enableFeemarket) + contractAddr := suite.DeployTestContract(suite.T(), suite.Address, supply, suite.enableFeemarket) + return contractAddr }, - []int{2, 0}, }, } for _, tc := range testCases { suite.Run(tc.name, func() { suite.SetupTest() - tc.malleate() + var contractAddr common.Address + if tc.malleate != nil { + contractAddr = tc.malleate() + } i := 0 suite.App.AccountKeeper.IterateAccounts(suite.Ctx, func(account sdk.AccountI) bool { ethAccount, ok := account.(ethermint.EthAccountI) @@ -137,7 +138,17 @@ func (suite *KeeperTestSuite) TestGetAccountStorage() { addr := ethAccount.EthAddress() storage := suite.App.EvmKeeper.GetAccountStorage(suite.Ctx, addr) - suite.Require().Equal(tc.expRes[i], len(storage)) + if addr == contractAddr { + s.Require().NotEqual(0, len(storage), + "expected account %d to have non-zero amount of storage slots, got %d", + i, len(storage), + ) + } else { + s.Require().Len(storage, 0, + "expected account %d to have %d storage slots, got %d", + i, 0, len(storage), + ) + } i++ return false }) diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index ed799c6ea7..54ac4a7633 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -150,3 +150,22 @@ func (k *Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) return &types.MsgUpdateParamsResponse{}, nil } + +// RegisterPreinstalls implements the gRPC MsgServer interface. When a RegisterPreinstalls +// proposal passes, it creates the preinstalls. The registration can only be +// performed if the requested authority is the Cosmos SDK governance module +// account. +func (k *Keeper) RegisterPreinstalls(goCtx context.Context, req *types.MsgRegisterPreinstalls) (*types. + MsgRegisterPreinstallsResponse, error, +) { + if k.authority.String() != req.Authority { + return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority, expected %s, got %s", k.authority.String(), req.Authority) + } + + ctx := sdk.UnwrapSDKContext(goCtx) + if err := k.AddPreinstalls(ctx, req.Preinstalls); err != nil { + return nil, err + } + + return &types.MsgRegisterPreinstallsResponse{}, nil +} diff --git a/x/evm/migrations/v4/types/params_v4.pb.go b/x/evm/migrations/v4/types/params_v4.pb.go index 3a93df5dd6..2d74ed4b13 100644 --- a/x/evm/migrations/v4/types/params_v4.pb.go +++ b/x/evm/migrations/v4/types/params_v4.pb.go @@ -6,11 +6,12 @@ package types import ( fmt "fmt" _ "github.com/cosmos/gogoproto/gogoproto" - proto "github.com/cosmos/gogoproto/proto" v0types "github.com/evmos/ethermint/x/evm/migrations/v0/types" + proto "github.com/cosmos/gogoproto/proto" io "io" math "math" math_bits "math/bits" + ) // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/evm/simulation/genesis.go b/x/evm/simulation/genesis.go index 21b79c6eb5..d8b68e2823 100644 --- a/x/evm/simulation/genesis.go +++ b/x/evm/simulation/genesis.go @@ -49,7 +49,7 @@ func RandomizedGenState(simState *module.SimulationState) { ) params := types.NewParams(types.DefaultEVMDenom, false, true, true, types.DefaultChainConfig(), extraEIPs) - evmGenesis := types.NewGenesisState(params, []types.GenesisAccount{}) + evmGenesis := types.NewGenesisState(params, []types.GenesisAccount{}, []types.Preinstall{}) bz, err := json.MarshalIndent(evmGenesis, "", " ") if err != nil { diff --git a/x/evm/types/codec.go b/x/evm/types/codec.go index acef01c2a0..e49147f800 100644 --- a/x/evm/types/codec.go +++ b/x/evm/types/codec.go @@ -38,7 +38,8 @@ var ( const ( // Amino names - updateParamsName = "ethermint/MsgUpdateParams" + updateParamsName = "ethermint/MsgUpdateParams" + registerPreinstallsName = "ethermint/MsgRegisterPreinstalls" ) // NOTE: This is required for the GetSignBytes function @@ -61,6 +62,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { (*sdk.Msg)(nil), &MsgEthereumTx{}, &MsgUpdateParams{}, + &MsgRegisterPreinstalls{}, ) registry.RegisterInterface( "ethermint.evm.v1.TxData", @@ -109,4 +111,5 @@ func UnpackTxData(codecAny *codectypes.Any) (TxData, error) { // RegisterLegacyAminoCodec required for EIP-712 func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgUpdateParams{}, updateParamsName, nil) + cdc.RegisterConcrete(&MsgRegisterPreinstalls{}, registerPreinstallsName, nil) } diff --git a/x/evm/types/errors.go b/x/evm/types/errors.go index 87179c50f6..faf8663eb8 100644 --- a/x/evm/types/errors.go +++ b/x/evm/types/errors.go @@ -49,6 +49,7 @@ const ( codeErrGasOverflow codeErrInvalidAccount codeErrInvalidGasLimit + codeErrInvalidPreinstall ) var ErrPostTxProcessing = errors.New("failed to execute post processing") @@ -116,6 +117,9 @@ var ( // ErrInvalidGasLimit returns an error if gas limit value is invalid ErrInvalidGasLimit = errorsmod.Register(ModuleName, codeErrInvalidGasLimit, "invalid gas limit") + + // ErrInvalidPreinstall returns an error if a preinstall is invalid + ErrInvalidPreinstall = errorsmod.Register(ModuleName, codeErrInvalidPreinstall, "invalid preinstall") ) // NewExecErrorWithReason unpacks the revert return bytes and returns a wrapped error diff --git a/x/evm/types/genesis.go b/x/evm/types/genesis.go index 3784237a38..762d30d183 100644 --- a/x/evm/types/genesis.go +++ b/x/evm/types/genesis.go @@ -33,16 +33,18 @@ func (ga GenesisAccount) Validate() error { // chain config values. func DefaultGenesisState() *GenesisState { return &GenesisState{ - Accounts: []GenesisAccount{}, - Params: DefaultParams(), + Accounts: []GenesisAccount{}, + Params: DefaultParams(), + Preinstalls: []Preinstall{}, } } // NewGenesisState creates a new genesis state. -func NewGenesisState(params Params, accounts []GenesisAccount) *GenesisState { +func NewGenesisState(params Params, accounts []GenesisAccount, preinstalls []Preinstall) *GenesisState { return &GenesisState{ - Accounts: accounts, - Params: params, + Accounts: accounts, + Params: params, + Preinstalls: preinstalls, } } @@ -60,5 +62,24 @@ func (gs GenesisState) Validate() error { seenAccounts[acc.Address] = true } + // Validate preinstalls + seenPreinstalls := make(map[string]bool) + for _, preinstall := range gs.Preinstalls { + if seenPreinstalls[preinstall.Address] { + return fmt.Errorf("duplicated preinstall address %s", preinstall.Address) + } + if err := preinstall.Validate(); err != nil { + return fmt.Errorf("invalid preinstall %s: %w", preinstall.Address, err) + } + + // Check that preinstall address doesn't conflict with any genesis account + // Both genesis accounts and preinstalls use Ethereum hex addresses + if seenAccounts[preinstall.Address] { + return fmt.Errorf("preinstall address %s conflicts with genesis account %s", preinstall.Address, preinstall.Address) + } + + seenPreinstalls[preinstall.Address] = true + } + return gs.Params.Validate() } diff --git a/x/evm/types/genesis.pb.go b/x/evm/types/genesis.pb.go index 8b9d6f33e6..a924f6c0e3 100644 --- a/x/evm/types/genesis.pb.go +++ b/x/evm/types/genesis.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -29,6 +30,8 @@ type GenesisState struct { Accounts []GenesisAccount `protobuf:"bytes,1,rep,name=accounts,proto3" json:"accounts"` // params defines all the parameters of the module. Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` + // preinstalls defines a set of predefined contracts + Preinstalls []Preinstall `protobuf:"bytes,3,rep,name=preinstalls,proto3" json:"preinstalls"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -78,6 +81,13 @@ func (m *GenesisState) GetParams() Params { return Params{} } +func (m *GenesisState) GetPreinstalls() []Preinstall { + if m != nil { + return m.Preinstalls + } + return nil +} + // GenesisAccount defines an account to be initialized in the genesis state. // Its main difference between with Geth's GenesisAccount is that it uses a // custom storage type and that it doesn't contain the private key field. @@ -152,27 +162,30 @@ func init() { func init() { proto.RegisterFile("ethermint/evm/v1/genesis.proto", fileDescriptor_9bcdec50cc9d156d) } var fileDescriptor_9bcdec50cc9d156d = []byte{ - // 305 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 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0xad, 0x7a, 0xfa, 0x82, 0xf0, 0xf1, - 0xdf, 0xd3, 0xc4, 0xc2, 0x26, 0x0f, 0xc3, 0x1c, 0x64, 0xdd, 0x06, 0x39, 0x43, 0x7f, 0xf7, 0x49, - 0x08, 0xee, 0x07, 0x22, 0x04, 0x1d, 0x31, 0xf4, 0x35, 0x26, 0x1e, 0x36, 0xa5, 0x12, 0x39, 0x8f, - 0xc0, 0xea, 0xe9, 0xee, 0xe7, 0xdd, 0x64, 0xfd, 0x4c, 0xef, 0xa4, 0x0e, 0x7e, 0xff, 0x9a, 0x98, - 0x8b, 0x46, 0xef, 0xef, 0x8c, 0xde, 0xed, 0xa6, 0xa4, 0x68, 0x5b, 0x52, 0xf4, 0x5d, 0x52, 0xf4, - 0x56, 0x51, 0x63, 0x5b, 0x51, 0xe3, 0xa3, 0xa2, 0xc6, 0xe3, 0x55, 0x14, 0xab, 0xd5, 0x7a, 0xc9, - 0x02, 0x91, 0xd4, 0x03, 0x0b, 0xe9, 0xfe, 0x0e, 0xfe, 0xa4, 0x27, 0x57, 0xcf, 0x19, 0xc8, 0xe5, - 0x40, 0x4f, 0x7b, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x26, 0xbe, 0x33, 0xe1, 0x01, 0x00, - 0x00, + // 361 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xcf, 0x4e, 0xea, 0x40, + 0x14, 0x87, 0x3b, 0x17, 0x02, 0x97, 0xc1, 0xf8, 0x67, 0x62, 0x62, 0x43, 0x70, 0x40, 0x16, 0x86, + 0xb8, 0x68, 0x03, 0x26, 0xae, 0xb5, 0x1b, 0xe3, 0xce, 0x94, 0x9d, 0xbb, 0xa1, 0x9c, 0x94, 0x26, + 0xb4, 0x43, 0x3a, 0x43, 0xa3, 0x5b, 0x9f, 0xc0, 0xc7, 0x30, 0xae, 0x7c, 0x0c, 0x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d9, 0xce, 0x3d, 0xc2, 0xdb, 0x3f, 0x2d, 0x89, 0x89, 0xab, 0x6c, 0x34, 0x8a, 0x41, + 0xa4, 0x07, 0x43, 0xdd, 0x9a, 0xbb, 0x7e, 0x25, 0x04, 0x97, 0x3d, 0x3e, 0x02, 0x65, 0x5b, 0x73, + 0x55, 0x4d, 0x1c, 0x5c, 0x15, 0x92, 0xc7, 0xcc, 0x07, 0xed, 0x71, 0x50, 0xf4, 0x50, 0x37, 0xe6, + 0xec, 0xa4, 0x0a, 0x4f, 0xef, 0xad, 0xea, 0x20, 0xe3, 0xdd, 0x75, 0xd0, 0x39, 0x9f, 0x2f, 0x29, + 0x5a, 0x2c, 0x29, 0xfa, 0x58, 0x52, 0xf4, 0xb0, 0xa2, 0xc6, 0x62, 0x45, 0x8d, 0xd7, 0x15, 0x35, + 0x6e, 0x8e, 0xfd, 0x40, 0x8e, 0x67, 0x43, 0xcb, 0xe3, 0x61, 0xba, 0x2b, 0x2e, 0xec, 0xcd, 0xee, + 0x6e, 0xd5, 0xf6, 0xe4, 0xdd, 0x14, 0xc4, 0xb0, 0xa2, 0xb6, 0x74, 0xfa, 0x15, 0x00, 0x00, 0xff, + 0xff, 0x89, 0xb0, 0x3a, 0x1c, 0x62, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -195,6 +208,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Preinstalls) > 0 { + for iNdEx := len(m.Preinstalls) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Preinstalls[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -298,6 +325,12 @@ func (m *GenesisState) Size() (n int) { } l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.Preinstalls) > 0 { + for _, e := range m.Preinstalls { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -426,6 +459,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Preinstalls", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Preinstalls = append(m.Preinstalls, Preinstall{}) + if err := m.Preinstalls[len(m.Preinstalls)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/evm/types/genesis_test.go b/x/evm/types/genesis_test.go index ad3e3a155e..ce6d2e385a 100644 --- a/x/evm/types/genesis_test.go +++ b/x/evm/types/genesis_test.go @@ -117,7 +117,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, { name: "copied genesis", - genState: NewGenesisState(DefaultGenesisState().Params, DefaultGenesisState().Accounts), + genState: NewGenesisState(DefaultGenesisState().Params, DefaultGenesisState().Accounts, DefaultPreinstalls), expPass: true, }, { diff --git a/x/evm/types/msg.go b/x/evm/types/msg.go index 9e147483a1..38f416fac6 100644 --- a/x/evm/types/msg.go +++ b/x/evm/types/msg.go @@ -46,6 +46,7 @@ var ( _ sdk.Tx = &MsgEthereumTx{} _ ante.GasTx = &MsgEthereumTx{} _ sdk.Msg = &MsgUpdateParams{} + _ sdk.Msg = &MsgRegisterPreinstalls{} _ codectypes.UnpackInterfacesMessage = MsgEthereumTx{} ) @@ -403,3 +404,18 @@ func (m *MsgUpdateParams) ValidateBasic() error { return m.Params.Validate() } + +// ValidateBasic does a sanity check for MsgRegisterPreinstalls +func (m *MsgRegisterPreinstalls) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return errorsmod.Wrap(err, "invalid authority address") + } + + for _, p := range m.Preinstalls { + err := p.Validate() + if err != nil { + return err + } + } + return nil +} diff --git a/x/evm/types/preinstall.go b/x/evm/types/preinstall.go new file mode 100644 index 0000000000..76dd298a0c --- /dev/null +++ b/x/evm/types/preinstall.go @@ -0,0 +1,72 @@ +package types + +import ( + "encoding/hex" + "fmt" + "strings" + + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/params" +) + +var DefaultPreinstalls = []Preinstall{ + { + Name: "Create2", + Address: "0x4e59b44847b379578588920ca78fbf26c0b4956c", + Code: "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", + }, + { + Name: "Multicall3", + Address: "0xcA11bde05977b3631167028862bE2a173976CA11", + Code: "0x6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e1461025a578063bce38bd714610275578063c3077fa914610288578063ee82ac5e1461029b57600080fd5b80634d2301cc146101ec57806372425d9d1461022157806382ad56cb1461023457806386d516e81461024757600080fd5b80633408e470116100c65780633408e47014610191578063399542e9146101a45780633e64a696146101c657806342cbb15c146101d957600080fd5b80630f28c97d146100f8578063174dea711461011a578063252dba421461013a57806327e86d6e1461015b575b600080fd5b34801561010457600080fd5b50425b6040519081526020015b60405180910390f35b61012d610128366004610a85565b6102ba565b6040516101119190610bbe565b61014d610148366004610a85565b6104ef565b604051610111929190610bd8565b34801561016757600080fd5b50437fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0140610107565b34801561019d57600080fd5b5046610107565b6101b76101b2366004610c60565b610690565b60405161011193929190610cba565b3480156101d257600080fd5b5048610107565b3480156101e557600080fd5b5043610107565b3480156101f857600080fd5b50610107610207366004610ce2565b73ffffffffffffffffffffffffffffffffffffffff163190565b34801561022d57600080fd5b5044610107565b61012d610242366004610a85565b6106ab565b34801561025357600080fd5b5045610107565b34801561026657600080fd5b50604051418152602001610111565b61012d610283366004610c60565b61085a565b6101b7610296366004610a85565b610a1a565b3480156102a757600080fd5b506101076102b6366004610d18565b4090565b60606000828067ffffffffffffffff8111156102d8576102d8610d31565b60405190808252806020026020018201604052801561031e57816020015b6040805180820190915260008152606060208201528152602001906001900390816102f65790505b5092503660005b8281101561047757600085828151811061034157610341610d60565b6020026020010151905087878381811061035d5761035d610d60565b905060200281019061036f9190610d8f565b6040810135958601959093506103886020850185610ce2565b73ffffffffffffffffffffffffffffffffffffffff16816103ac6060870187610dcd565b6040516103ba929190610e32565b60006040518083038185875af1925050503d80600081146103f7576040519150601f19603f3d011682016040523d82523d6000602084013e6103fc565b606091505b50602080850191909152901515808452908501351761046d577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b5050600101610325565b508234146104e6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4d756c746963616c6c333a2076616c7565206d69736d6174636800000000000060448201526064015b60405180910390fd5b50505092915050565b436060828067ffffffffffffffff81111561050c5761050c610d31565b60405190808252806020026020018201604052801561053f57816020015b606081526020019060019003908161052a5790505b5091503660005b8281101561068657600087878381811061056257610562610d60565b90506020028101906105749190610e42565b92506105836020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166105a66020850185610dcd565b6040516105b4929190610e32565b6000604051808303816000865af19150503d80600081146105f1576040519150601f19603f3d011682016040523d82523d6000602084013e6105f6565b606091505b5086848151811061060957610609610d60565b602090810291909101015290508061067d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b50600101610546565b5050509250929050565b43804060606106a086868661085a565b905093509350939050565b6060818067ffffffffffffffff8111156106c7576106c7610d31565b60405190808252806020026020018201604052801561070d57816020015b6040805180820190915260008152606060208201528152602001906001900390816106e55790505b5091503660005b828110156104e657600084828151811061073057610730610d60565b6020026020010151905086868381811061074c5761074c610d60565b905060200281019061075e9190610e76565b925061076d6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff166107906040850185610dcd565b60405161079e929190610e32565b6000604051808303816000865af19150503d80600081146107db576040519150601f19603f3d011682016040523d82523d6000602084013e6107e0565b606091505b506020808401919091529015158083529084013517610851577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b50600101610714565b6060818067ffffffffffffffff81111561087657610876610d31565b6040519080825280602002602001820160405280156108bc57816020015b6040805180820190915260008152606060208201528152602001906001900390816108945790505b5091503660005b82811015610a105760008482815181106108df576108df610d60565b602002602001015190508686838181106108fb576108fb610d60565b905060200281019061090d9190610e42565b925061091c6020840184610ce2565b73ffffffffffffffffffffffffffffffffffffffff1661093f6020850185610dcd565b60405161094d929190610e32565b6000604051808303816000865af19150503d806000811461098a576040519150601f19603f3d011682016040523d82523d6000602084013e61098f565b606091505b506020830152151581528715610a07578051610a07576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601760248201527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060448201526064016104dd565b506001016108c3565b5050509392505050565b6000806060610a2b60018686610690565b919790965090945092505050565b60008083601f840112610a4b57600080fd5b50813567ffffffffffffffff811115610a6357600080fd5b6020830191508360208260051b8501011115610a7e57600080fd5b9250929050565b60008060208385031215610a9857600080fd5b823567ffffffffffffffff811115610aaf57600080fd5b610abb85828601610a39565b90969095509350505050565b6000815180845260005b81811015610aed57602081850181015186830182015201610ad1565b81811115610aff576000602083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b600082825180855260208086019550808260051b84010181860160005b84811015610bb1578583037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe001895281518051151584528401516040858501819052610b9d81860183610ac7565b9a86019a9450505090830190600101610b4f565b5090979650505050505050565b602081526000610bd16020830184610b32565b9392505050565b600060408201848352602060408185015281855180845260608601915060608160051b870101935082870160005b82811015610c52577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0888703018452610c40868351610ac7565b95509284019290840190600101610c06565b509398975050505050505050565b600080600060408486031215610c7557600080fd5b83358015158114610c8557600080fd5b9250602084013567ffffffffffffffff811115610ca157600080fd5b610cad86828701610a39565b9497909650939450505050565b838152826020820152606060408201526000610cd96060830184610b32565b95945050505050565b600060208284031215610cf457600080fd5b813573ffffffffffffffffffffffffffffffffffffffff81168114610bd157600080fd5b600060208284031215610d2a57600080fd5b5035919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81833603018112610dc357600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112610e0257600080fd5b83018035915067ffffffffffffffff821115610e1d57600080fd5b602001915036819003821315610a7e57600080fd5b8183823760009101908152919050565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112610dc357600080fd5b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa1833603018112610dc357600080fdfea2646970667358221220bb2b5c71a328032f97c676ae39a1ec2148d3e5d6f73d95e9b17910152d61f16264736f6c634300080c0033", + }, + { + Name: "Permit2", + Address: "0x000000000022D473030F116dDEE9F6B43aC78BA3", + Code: "0x6040608081526004908136101561001557600080fd5b600090813560e01c80630d58b1db1461126c578063137c29fe146110755780632a2d80d114610db75780632b67b57014610bde57806330f28b7a14610ade5780633644e51514610a9d57806336c7851614610a285780633ff9dcb1146109a85780634fe02b441461093f57806365d9723c146107ac57806387517c451461067a578063927da105146105c3578063cc53287f146104a3578063edd9444b1461033a5763fe8ec1a7146100c657600080fd5b346103365760c07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103365767ffffffffffffffff833581811161033257610114903690860161164b565b60243582811161032e5761012b903690870161161a565b6101336114e6565b9160843585811161032a5761014b9036908a016115c1565b98909560a43590811161032657610164913691016115c1565b969095815190610173826113ff565b606b82527f5065726d697442617463685769746e6573735472616e7366657246726f6d285460208301527f6f6b656e5065726d697373696f6e735b5d207065726d69747465642c61646472838301527f657373207370656e6465722c75696e74323536206e6f6e63652c75696e74323560608301527f3620646561646c696e652c000000000000000000000000000000000000000000608083015282519a8b9181610222602085018096611f93565b918237018a8152039961025b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09b8c8101835282611437565b5190209085515161026b81611ebb565b908a5b8181106102f95750506102f6999a6102ed9183516102a081610294602082018095611f66565b03848101835282611437565b519020602089810151858b015195519182019687526040820192909252336060820152608081019190915260a081019390935260643560c08401528260e081015b03908101835282611437565b51902093611cf7565b80f35b8061031161030b610321938c5161175e565b51612054565b61031b828661175e565b52611f0a565b61026e565b8880fd5b8780fd5b8480fd5b8380fd5b5080fd5b5091346103365760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103365767ffffffffffffffff9080358281116103325761038b903690830161164b565b60243583811161032e576103a2903690840161161a565b9390926103ad6114e6565b9160643590811161049f576103c4913691016115c1565b949093835151976103d489611ebb565b98885b81811061047d5750506102f697988151610425816103f9602082018095611f66565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282611437565b5190206020860151828701519083519260208401947ffcf35f5ac6a2c28868dc44c302166470266239195f02b0ee408334829333b7668652840152336060840152608083015260a082015260a081526102ed8161141b565b808b61031b8261049461030b61049a968d5161175e565b9261175e565b6103d7565b8680fd5b5082346105bf57602090817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126103325780359067ffffffffffffffff821161032e576104f49136910161161a565b929091845b848110610504578580f35b8061051a610515600193888861196c565b61197c565b61052f84610529848a8a61196c565b0161197c565b3389528385528589209173ffffffffffffffffffffffffffffffffffffffff80911692838b528652868a20911690818a5285528589207fffffffffffffffffffffffff000000000000000000000000000000000000000081541690558551918252848201527f89b1add15eff56b3dfe299ad94e01f2b52fbcb80ae1a3baea6ae8c04cb2b98a4853392a2016104f9565b8280fd5b50346103365760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261033657610676816105ff6114a0565b936106086114c3565b6106106114e6565b73ffffffffffffffffffffffffffffffffffffffff968716835260016020908152848420928816845291825283832090871683528152919020549251938316845260a083901c65ffffffffffff169084015260d09190911c604083015281906060820190565b0390f35b50346103365760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610336576106b26114a0565b906106bb6114c3565b916106c46114e6565b65ffffffffffff926064358481169081810361032a5779ffffffffffff0000000000000000000000000000000000000000947fda9fa7c1b00402c17d0161b249b1ab8bbec047c5a52207b9c112deffd817036b94338a5260016020527fffffffffffff0000000000000000000000000000000000000000000000000000858b209873ffffffffffffffffffffffffffffffffffffffff809416998a8d5260205283878d209b169a8b8d52602052868c209486156000146107a457504216925b8454921697889360a01b16911617179055815193845260208401523392a480f35b905092610783565b5082346105bf5760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105bf576107e56114a0565b906107ee6114c3565b9265ffffffffffff604435818116939084810361032a57338852602091600183528489209673ffffffffffffffffffffffffffffffffffffffff80911697888b528452858a20981697888a5283528489205460d01c93848711156109175761ffff9085840316116108f05750907f55eb90d810e1700b35a8e7e25395ff7f2b2259abd7415ca2284dfb1c246418f393929133895260018252838920878a528252838920888a5282528389209079ffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffff000000000000000000000000000000000000000000000000000083549260d01b16911617905582519485528401523392a480f35b84517f24d35a26000000000000000000000000000000000000000000000000000000008152fd5b5084517f756688fe000000000000000000000000000000000000000000000000000000008152fd5b503461033657807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610336578060209273ffffffffffffffffffffffffffffffffffffffff61098f6114a0565b1681528084528181206024358252845220549051908152f35b5082346105bf57817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105bf577f3704902f963766a4e561bbaab6e6cdc1b1dd12f6e9e99648da8843b3f46b918d90359160243533855284602052818520848652602052818520818154179055815193845260208401523392a280f35b8234610a9a5760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610a9a57610a606114a0565b610a686114c3565b610a706114e6565b6064359173ffffffffffffffffffffffffffffffffffffffff8316830361032e576102f6936117a1565b80fd5b503461033657817ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261033657602090610ad7611b1e565b9051908152f35b508290346105bf576101007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105bf57610b1a3661152a565b90807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7c36011261033257610b4c611478565b9160e43567ffffffffffffffff8111610bda576102f694610b6f913691016115c1565b939092610b7c8351612054565b6020840151828501519083519260208401947f939c21a48a8dbe3a9a2404a1d46691e4d39f6583d6ec6b35714604c986d801068652840152336060840152608083015260a082015260a08152610bd18161141b565b51902091611c25565b8580fd5b509134610336576101007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261033657610c186114a0565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc360160c08112610332576080855191610c51836113e3565b1261033257845190610c6282611398565b73ffffffffffffffffffffffffffffffffffffffff91602435838116810361049f578152604435838116810361049f57602082015265ffffffffffff606435818116810361032a5788830152608435908116810361049f576060820152815260a435938285168503610bda576020820194855260c4359087830182815260e43567ffffffffffffffff811161032657610cfe90369084016115c1565b929093804211610d88575050918591610d786102f6999a610d7e95610d238851611fbe565b90898c511690519083519260208401947ff3841cd1ff0085026a6327b620b67997ce40f282c88a8e905a7a5626e310f3d086528401526060830152608082015260808152610d70816113ff565b519020611bd9565b916120c7565b519251169161199d565b602492508a51917fcd21db4f000000000000000000000000000000000000000000000000000000008352820152fd5b5091346103365760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc93818536011261033257610df36114a0565b9260249081359267ffffffffffffffff9788851161032a578590853603011261049f578051978589018981108282111761104a578252848301358181116103265785019036602383011215610326578382013591610e50836115ef565b90610e5d85519283611437565b838252602093878584019160071b83010191368311611046578801905b828210610fe9575050508a526044610e93868801611509565b96838c01978852013594838b0191868352604435908111610fe557610ebb90369087016115c1565b959096804211610fba575050508998995151610ed681611ebb565b908b5b818110610f9757505092889492610d7892610f6497958351610f02816103f98682018095611f66565b5190209073ffffffffffffffffffffffffffffffffffffffff9a8b8b51169151928551948501957faf1b0d30d2cab0380e68f0689007e3254993c596f2fdd0aaa7f4d04f794408638752850152830152608082015260808152610d70816113ff565b51169082515192845b848110610f78578580f35b80610f918585610f8b600195875161175e565b5161199d565b01610f6d565b80610311610fac8e9f9e93610fb2945161175e565b51611fbe565b9b9a9b610ed9565b8551917fcd21db4f000000000000000000000000000000000000000000000000000000008352820152fd5b8a80fd5b6080823603126110465785608091885161100281611398565b61100b85611509565b8152611018838601611509565b838201526110278a8601611607565b8a8201528d611037818701611607565b90820152815201910190610e7a565b8c80fd5b84896041867f4e487b7100000000000000000000000000000000000000000000000000000000835252fd5b5082346105bf576101407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126105bf576110b03661152a565b91807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7c360112610332576110e2611478565b67ffffffffffffffff93906101043585811161049f5761110590369086016115c1565b90936101243596871161032a57611125610bd1966102f6983691016115c1565b969095825190611134826113ff565b606482527f5065726d69745769746e6573735472616e7366657246726f6d28546f6b656e5060208301527f65726d697373696f6e73207065726d69747465642c6164647265737320737065848301527f6e6465722c75696e74323536206e6f6e63652c75696e7432353620646561646c60608301527f696e652c0000000000000000000000000000000000000000000000000000000060808301528351948591816111e3602085018096611f93565b918237018b8152039361121c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe095868101835282611437565b5190209261122a8651612054565b6020878101518589015195519182019687526040820192909252336060820152608081019190915260a081019390935260e43560c08401528260e081016102e1565b5082346105bf576020807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261033257813567ffffffffffffffff92838211610bda5736602383011215610bda5781013592831161032e576024906007368386831b8401011161049f57865b8581106112e5578780f35b80821b83019060807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdc83360301126103265761139288876001946060835161132c81611398565b611368608461133c8d8601611509565b9485845261134c60448201611509565b809785015261135d60648201611509565b809885015201611509565b918291015273ffffffffffffffffffffffffffffffffffffffff80808093169516931691166117a1565b016112da565b6080810190811067ffffffffffffffff8211176113b457604052565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6060810190811067ffffffffffffffff8211176113b457604052565b60a0810190811067ffffffffffffffff8211176113b457604052565b60c0810190811067ffffffffffffffff8211176113b457604052565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176113b457604052565b60c4359073ffffffffffffffffffffffffffffffffffffffff8216820361149b57565b600080fd5b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361149b57565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361149b57565b6044359073ffffffffffffffffffffffffffffffffffffffff8216820361149b57565b359073ffffffffffffffffffffffffffffffffffffffff8216820361149b57565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc01906080821261149b576040805190611563826113e3565b8082941261149b57805181810181811067ffffffffffffffff8211176113b457825260043573ffffffffffffffffffffffffffffffffffffffff8116810361149b578152602435602082015282526044356020830152606435910152565b9181601f8401121561149b5782359167ffffffffffffffff831161149b576020838186019501011161149b57565b67ffffffffffffffff81116113b45760051b60200190565b359065ffffffffffff8216820361149b57565b9181601f8401121561149b5782359167ffffffffffffffff831161149b576020808501948460061b01011161149b57565b91909160608184031261149b576040805191611666836113e3565b8294813567ffffffffffffffff9081811161149b57830182601f8201121561149b578035611693816115ef565b926116a087519485611437565b818452602094858086019360061b8501019381851161149b579086899897969594939201925b8484106116e3575050505050855280820135908501520135910152565b90919293949596978483031261149b578851908982019082821085831117611730578a928992845261171487611509565b81528287013583820152815201930191908897969594936116c6565b602460007f4e487b710000000000000000000000000000000000000000000000000000000081526041600452fd5b80518210156117725760209160051b010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b92919273ffffffffffffffffffffffffffffffffffffffff604060008284168152600160205282828220961695868252602052818120338252602052209485549565ffffffffffff8760a01c16804211611884575082871696838803611812575b5050611810955016926118b5565b565b878484161160001461184f57602488604051907ff96fb0710000000000000000000000000000000000000000000000000000000082526004820152fd5b7fffffffffffffffffffffffff000000000000000000000000000000000000000084846118109a031691161790553880611802565b602490604051907fd81b2f2e0000000000000000000000000000000000000000000000000000000082526004820152fd5b9060006064926020958295604051947f23b872dd0000000000000000000000000000000000000000000000000000000086526004860152602485015260448401525af13d15601f3d116001600051141617161561190e57565b60646040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601460248201527f5452414e534645525f46524f4d5f4641494c45440000000000000000000000006044820152fd5b91908110156117725760061b0190565b3573ffffffffffffffffffffffffffffffffffffffff8116810361149b5790565b9065ffffffffffff908160608401511673ffffffffffffffffffffffffffffffffffffffff908185511694826020820151169280866040809401511695169560009187835260016020528383208984526020528383209916988983526020528282209184835460d01c03611af5579185611ace94927fc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec98979694508715600014611ad35779ffffffffffff00000000000000000000000000000000000000009042165b60a01b167fffffffffffff00000000000000000000000000000000000000000000000000006001860160d01b1617179055519384938491604091949373ffffffffffffffffffffffffffffffffffffffff606085019616845265ffffffffffff809216602085015216910152565b0390a4565b5079ffffffffffff000000000000000000000000000000000000000087611a60565b600484517f756688fe000000000000000000000000000000000000000000000000000000008152fd5b467f000000000000000000000000000000000000000000000000000000000000000103611b69577f866a5aba21966af95d6c7ab78eb2b2fc913915c28be3b9aa07cc04ff903e3f2890565b60405160208101907f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86682527f9ac997416e8ff9d2ff6bebeb7149f65cdae5e32e2b90440b566bb3044041d36a604082015246606082015230608082015260808152611bd3816113ff565b51902090565b611be1611b1e565b906040519060208201927f190100000000000000000000000000000000000000000000000000000000000084526022830152604282015260428152611bd381611398565b9192909360a435936040840151804211611cc65750602084510151808611611c955750918591610d78611c6594611c60602088015186611e47565b611bd9565b73ffffffffffffffffffffffffffffffffffffffff809151511692608435918216820361149b57611810936118b5565b602490604051907f3728b83d0000000000000000000000000000000000000000000000000000000082526004820152fd5b602490604051907fcd21db4f0000000000000000000000000000000000000000000000000000000082526004820152fd5b959093958051519560409283830151804211611e175750848803611dee57611d2e918691610d7860209b611c608d88015186611e47565b60005b868110611d42575050505050505050565b611d4d81835161175e565b5188611d5a83878a61196c565b01359089810151808311611dbe575091818888886001968596611d84575b50505050505001611d31565b611db395611dad9273ffffffffffffffffffffffffffffffffffffffff6105159351169561196c565b916118b5565b803888888883611d78565b6024908651907f3728b83d0000000000000000000000000000000000000000000000000000000082526004820152fd5b600484517fff633a38000000000000000000000000000000000000000000000000000000008152fd5b6024908551907fcd21db4f0000000000000000000000000000000000000000000000000000000082526004820152fd5b9073ffffffffffffffffffffffffffffffffffffffff600160ff83161b9216600052600060205260406000209060081c6000526020526040600020818154188091551615611e9157565b60046040517f756688fe000000000000000000000000000000000000000000000000000000008152fd5b90611ec5826115ef565b611ed26040519182611437565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0611f0082946115ef565b0190602036910137565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114611f375760010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b805160208092019160005b828110611f7f575050505090565b835185529381019392810192600101611f71565b9081519160005b838110611fab575050016000815290565b8060208092840101518185015201611f9a565b60405160208101917f65626cad6cb96493bf6f5ebea28756c966f023ab9e8a83a7101849d5573b3678835273ffffffffffffffffffffffffffffffffffffffff8082511660408401526020820151166060830152606065ffffffffffff9182604082015116608085015201511660a082015260a0815260c0810181811067ffffffffffffffff8211176113b45760405251902090565b6040516020808201927f618358ac3db8dc274f0cd8829da7e234bd48cd73c4a740aede1adec9846d06a1845273ffffffffffffffffffffffffffffffffffffffff81511660408401520151606082015260608152611bd381611398565b919082604091031261149b576020823592013590565b6000843b61222e5750604182036121ac576120e4828201826120b1565b939092604010156117725760209360009360ff6040608095013560f81c5b60405194855216868401526040830152606082015282805260015afa156121a05773ffffffffffffffffffffffffffffffffffffffff806000511691821561217657160361214c57565b60046040517f815e1d64000000000000000000000000000000000000000000000000000000008152fd5b60046040517f8baa579f000000000000000000000000000000000000000000000000000000008152fd5b6040513d6000823e3d90fd5b60408203612204576121c0918101906120b1565b91601b7f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff84169360ff1c019060ff8211611f375760209360009360ff608094612102565b60046040517f4be6321b000000000000000000000000000000000000000000000000000000008152fd5b929391601f928173ffffffffffffffffffffffffffffffffffffffff60646020957fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0604051988997889687947f1626ba7e000000000000000000000000000000000000000000000000000000009e8f8752600487015260406024870152816044870152868601378b85828601015201168101030192165afa9081156123a857829161232a575b507fffffffff000000000000000000000000000000000000000000000000000000009150160361230057565b60046040517fb0669cbc000000000000000000000000000000000000000000000000000000008152fd5b90506020813d82116123a0575b8161234460209383611437565b810103126103365751907fffffffff0000000000000000000000000000000000000000000000000000000082168203610a9a57507fffffffff0000000000000000000000000000000000000000000000000000000090386122d4565b3d9150612337565b6040513d84823e3d90fdfea164736f6c6343000811000a", + }, + { + Name: "Safe singleton factory", + Address: "0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7", + Code: "0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3", + }, + { + Name: "EIP-2935 - Serve historical block hashes from state", + Address: params.HistoryStorageAddress.String(), + Code: common.Bytes2Hex(params.HistoryStorageCode), + }, +} + +// Validate performs basic validation checks on the Preinstall +func (p Preinstall) Validate() error { + if p.Address == "" { + return fmt.Errorf("preinstall address cannot be empty") + } + + // Check if Address is a valid hex string that can be converted to common.Address + if !common.IsHexAddress(p.Address) { + return fmt.Errorf("preinstall address %q is not a valid hex address", p.Address) + } + + if p.Code == "" { + return fmt.Errorf("preinstall code cannot be empty") + } + + // Check if Code is a valid hex string that can be converted to bytes + codeStr := p.Code + if strings.HasPrefix(codeStr, "0x") || strings.HasPrefix(codeStr, "0X") { + codeStr = codeStr[2:] + } + if _, err := hex.DecodeString(codeStr); err != nil { + return fmt.Errorf("preinstall code %q is not a valid hex string", p.Code) + } + + // Check if Code has Empty Code Hash + codeHash := crypto.Keccak256Hash(common.FromHex(p.Code)).Bytes() + if IsEmptyCodeHash(codeHash) { + return fmt.Errorf("preinstall code %q has empty code hash", p.Code) + } + + return nil +} diff --git a/x/evm/types/preinstall.pb.go b/x/evm/types/preinstall.pb.go new file mode 100644 index 0000000000..335308edfe --- /dev/null +++ b/x/evm/types/preinstall.pb.go @@ -0,0 +1,423 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ethermint/evm/v1/preinstall.proto + +package types + +import ( + fmt "fmt" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Preinstall defines a contract that is preinstalled on-chain with a specific +// contract address and bytecode +type Preinstall struct { + // name of the preinstall contract + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // address in hex format of the preinstall contract + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + // code in hex format for the preinstall contract + Code string `protobuf:"bytes,3,opt,name=code,proto3" json:"code,omitempty"` +} + +func (m *Preinstall) Reset() { *m = Preinstall{} } +func (m *Preinstall) String() string { return proto.CompactTextString(m) } +func (*Preinstall) ProtoMessage() {} +func (*Preinstall) Descriptor() ([]byte, []int) { + return fileDescriptor_ebf0ed25989afc58, []int{0} +} +func (m *Preinstall) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Preinstall) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Preinstall.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 *Preinstall) XXX_Merge(src proto.Message) { + xxx_messageInfo_Preinstall.Merge(m, src) +} +func (m *Preinstall) XXX_Size() int { + return m.Size() +} +func (m *Preinstall) XXX_DiscardUnknown() { + xxx_messageInfo_Preinstall.DiscardUnknown(m) +} + +var xxx_messageInfo_Preinstall proto.InternalMessageInfo + +func (m *Preinstall) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Preinstall) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *Preinstall) GetCode() string { + if m != nil { + return m.Code + } + return "" +} + +func init() { + proto.RegisterType((*Preinstall)(nil), "ethermint.evm.v1.Preinstall") +} + +func init() { proto.RegisterFile("ethermint/evm/v1/preinstall.proto", fileDescriptor_ebf0ed25989afc58) } + +var fileDescriptor_ebf0ed25989afc58 = []byte{ + // 183 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4c, 0x2d, 0xc9, 0x48, + 0x2d, 0xca, 0xcd, 0xcc, 0x2b, 0xd1, 0x4f, 0x2d, 0xcb, 0xd5, 0x2f, 0x33, 0xd4, 0x2f, 0x28, 0x4a, + 0xcd, 0xcc, 0x2b, 0x2e, 0x49, 0xcc, 0xc9, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x80, + 0x2b, 0xd1, 0x4b, 0x2d, 0xcb, 0xd5, 0x2b, 0x33, 0x54, 0xf2, 0xe3, 0xe2, 0x0a, 0x80, 0xab, 0x12, + 0x12, 0xe2, 0x62, 0xc9, 0x4b, 0xcc, 0x4d, 0x95, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xb3, + 0x85, 0x24, 0xb8, 0xd8, 0x13, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0x25, 0x98, 0xc0, 0xc2, 0x30, + 0x2e, 0x48, 0x75, 0x72, 0x7e, 0x4a, 0xaa, 0x04, 0x33, 0x44, 0x35, 0x88, 0xed, 0xe4, 0x70, 0xe2, + 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, + 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x6a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, + 0x7a, 0xc9, 0xf9, 0xb9, 0x20, 0xf7, 0xe5, 0x17, 0xeb, 0x23, 0xdc, 0x5b, 0x01, 0x76, 0x71, 0x49, + 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0xa9, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9d, + 0x60, 0xb7, 0xb0, 0xcf, 0x00, 0x00, 0x00, +} + +func (m *Preinstall) 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 *Preinstall) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Preinstall) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Code) > 0 { + i -= len(m.Code) + copy(dAtA[i:], m.Code) + i = encodeVarintPreinstall(dAtA, i, uint64(len(m.Code))) + i-- + dAtA[i] = 0x1a + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintPreinstall(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintPreinstall(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintPreinstall(dAtA []byte, offset int, v uint64) int { + offset -= sovPreinstall(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Preinstall) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovPreinstall(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovPreinstall(uint64(l)) + } + l = len(m.Code) + if l > 0 { + n += 1 + l + sovPreinstall(uint64(l)) + } + return n +} + +func sovPreinstall(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPreinstall(x uint64) (n int) { + return sovPreinstall(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Preinstall) 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 ErrIntOverflowPreinstall + } + 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: Preinstall: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Preinstall: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPreinstall + } + 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 ErrInvalidLengthPreinstall + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPreinstall + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowPreinstall + } + 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 ErrInvalidLengthPreinstall + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPreinstall + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPreinstall + } + 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 ErrInvalidLengthPreinstall + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPreinstall + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Code = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPreinstall(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPreinstall + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPreinstall(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPreinstall + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPreinstall + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowPreinstall + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthPreinstall + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPreinstall + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPreinstall + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPreinstall = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPreinstall = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPreinstall = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/evm/types/preinstall_test.go b/x/evm/types/preinstall_test.go new file mode 100644 index 0000000000..98fbc97b43 --- /dev/null +++ b/x/evm/types/preinstall_test.go @@ -0,0 +1,155 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestPreinstall_Validate(t *testing.T) { + tests := []struct { + name string + preinstall Preinstall + errorMsg string + }{ + { + name: "valid preinstall with 0x prefix", + preinstall: Preinstall{ + Name: "Test Contract", + Address: "0x1234567890123456789012345678901234567890", + Code: "0x608060405234801561001057600080fd5b50", + }, + errorMsg: "", + }, + { + name: "valid preinstall without 0x prefix", + preinstall: Preinstall{ + Name: "Test Contract", + Address: "1234567890123456789012345678901234567890", + Code: "608060405234801561001057600080fd5b50", + }, + errorMsg: "", + }, + { + name: "valid preinstall with uppercase hex", + preinstall: Preinstall{ + Name: "Test Contract", + Address: "0xABCDEF1234567890123456789012345678901234", + Code: "0x608060405234801561001057600080FD5B50", + }, + errorMsg: "", + }, + { + name: "valid preinstall with mixed case hex", + preinstall: Preinstall{ + Name: "Test Contract", + Address: "0xaBcDeF1234567890123456789012345678901234", + Code: "0x608060405234801561001057600080Fd5b50", + }, + errorMsg: "", + }, + { + name: "empty address", + preinstall: Preinstall{ + Name: "Test Contract", + Address: "", + Code: "0x608060405234801561001057600080fd5b50", + }, + errorMsg: "preinstall address cannot be empty", + }, + { + name: "empty code", + preinstall: Preinstall{ + Name: "Test Contract", + Address: "0x1234567890123456789012345678901234567890", + Code: "", + }, + errorMsg: "preinstall code cannot be empty", + }, + { + name: "invalid address - not hex", + preinstall: Preinstall{ + Name: "Test Contract", + Address: "0xGHIJ567890123456789012345678901234567890", + Code: "0x608060405234801561001057600080fd5b50", + }, + errorMsg: "preinstall address \"0xGHIJ567890123456789012345678901234567890\" is not a valid hex address", + }, + { + name: "invalid address - too short", + preinstall: Preinstall{ + Name: "Test Contract", + Address: "0x1234", + Code: "0x608060405234801561001057600080fd5b50", + }, + errorMsg: "preinstall address \"0x1234\" is not a valid hex address", + }, + { + name: "invalid address - too long", + preinstall: Preinstall{ + Name: "Test Contract", + Address: "0x123456789012345678901234567890123456789012", + Code: "0x608060405234801561001057600080fd5b50", + }, + errorMsg: "preinstall address \"0x123456789012345678901234567890123456789012\" is not a valid hex address", + }, + { + name: "invalid code - not hex", + preinstall: Preinstall{ + Name: "Test Contract", + Address: "0x1234567890123456789012345678901234567890", + Code: "0xGHIJ60405234801561001057600080fd5b50", + }, + errorMsg: "preinstall code \"0xGHIJ60405234801561001057600080fd5b50\" is not a valid hex string", + }, + { + name: "invalid code - odd length without 0x", + preinstall: Preinstall{ + Name: "Test Contract", + Address: "0x1234567890123456789012345678901234567890", + Code: "60806040523480156100057600080fd5b50", + }, + errorMsg: "preinstall code \"60806040523480156100057600080fd5b50\" is not a valid hex string", + }, + { + name: "invalid code - empty code hash", + preinstall: Preinstall{ + Name: "Test Contract", + Address: "0x1234567890123456789012345678901234567890", + Code: "0x", + }, + errorMsg: "preinstall code \"0x\" has empty code hash", + }, + { + name: "valid preinstall with empty name (name not validated)", + preinstall: Preinstall{ + Name: "", + Address: "0x1234567890123456789012345678901234567890", + Code: "0x608060405234801561001057600080fd5b50", + }, + errorMsg: "", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.preinstall.Validate() + if tt.errorMsg == "" { + require.NoError(t, err) + } else { + require.Error(t, err) + require.Contains(t, err.Error(), tt.errorMsg) + } + }) + } +} + +func TestDefaultPreinstalls_Validate(t *testing.T) { + // Test that all default preinstalls are valid + for i, preinstall := range DefaultPreinstalls { + t.Run(preinstall.Name, func(t *testing.T) { + err := preinstall.Validate() + require.NoError(t, err, "DefaultPreinstalls[%d] (%s) should be valid", i, preinstall.Name) + }) + } +} diff --git a/x/evm/types/tx.pb.go b/x/evm/types/tx.pb.go index ba9a97f612..d12dd99aa3 100644 --- a/x/evm/types/tx.pb.go +++ b/x/evm/types/tx.pb.go @@ -11,6 +11,7 @@ import ( _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -509,6 +510,99 @@ func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo +// MsgRegisterPreinstalls defines a Msg for creating preinstalls in evm state. +type MsgRegisterPreinstalls struct { + // authority is the address of the governance account. + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // preinstalls defines the preinstalls to create. + Preinstalls []Preinstall `protobuf:"bytes,2,rep,name=preinstalls,proto3" json:"preinstalls"` +} + +func (m *MsgRegisterPreinstalls) Reset() { *m = MsgRegisterPreinstalls{} } +func (m *MsgRegisterPreinstalls) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterPreinstalls) ProtoMessage() {} +func (*MsgRegisterPreinstalls) Descriptor() ([]byte, []int) { + return fileDescriptor_f75ac0a12d075f21, []int{9} +} +func (m *MsgRegisterPreinstalls) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterPreinstalls) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterPreinstalls.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 *MsgRegisterPreinstalls) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterPreinstalls.Merge(m, src) +} +func (m *MsgRegisterPreinstalls) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterPreinstalls) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterPreinstalls.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterPreinstalls proto.InternalMessageInfo + +func (m *MsgRegisterPreinstalls) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +func (m *MsgRegisterPreinstalls) GetPreinstalls() []Preinstall { + if m != nil { + return m.Preinstalls + } + return nil +} + +// MsgRegisterPreinstallsResponse defines the response structure for executing a +// MsgRegisterPreinstalls message. +type MsgRegisterPreinstallsResponse struct { +} + +func (m *MsgRegisterPreinstallsResponse) Reset() { *m = MsgRegisterPreinstallsResponse{} } +func (m *MsgRegisterPreinstallsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterPreinstallsResponse) ProtoMessage() {} +func (*MsgRegisterPreinstallsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f75ac0a12d075f21, []int{10} +} +func (m *MsgRegisterPreinstallsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterPreinstallsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterPreinstallsResponse.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 *MsgRegisterPreinstallsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterPreinstallsResponse.Merge(m, src) +} +func (m *MsgRegisterPreinstallsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterPreinstallsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterPreinstallsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterPreinstallsResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgEthereumTx)(nil), "ethermint.evm.v1.MsgEthereumTx") proto.RegisterType((*LegacyTx)(nil), "ethermint.evm.v1.LegacyTx") @@ -519,84 +613,92 @@ func init() { proto.RegisterType((*MsgEthereumTxResponse)(nil), "ethermint.evm.v1.MsgEthereumTxResponse") proto.RegisterType((*MsgUpdateParams)(nil), "ethermint.evm.v1.MsgUpdateParams") proto.RegisterType((*MsgUpdateParamsResponse)(nil), "ethermint.evm.v1.MsgUpdateParamsResponse") + proto.RegisterType((*MsgRegisterPreinstalls)(nil), "ethermint.evm.v1.MsgRegisterPreinstalls") + proto.RegisterType((*MsgRegisterPreinstallsResponse)(nil), "ethermint.evm.v1.MsgRegisterPreinstallsResponse") } func init() { proto.RegisterFile("ethermint/evm/v1/tx.proto", fileDescriptor_f75ac0a12d075f21) } var fileDescriptor_f75ac0a12d075f21 = []byte{ - // 1147 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0xcf, 0x6f, 0x1b, 0x45, - 0x14, 0xce, 0xda, 0xeb, 0x5f, 0x63, 0x27, 0xad, 0x46, 0x89, 0xba, 0xb6, 0x1a, 0xaf, 0x71, 0xa1, - 0xb8, 0x45, 0xb1, 0xd5, 0x80, 0x2a, 0x35, 0x27, 0xbc, 0xf9, 0x01, 0x45, 0x89, 0xa8, 0xb6, 0xee, - 0x05, 0x90, 0xac, 0xc9, 0xee, 0x64, 0xbd, 0xaa, 0x77, 0x67, 0xb5, 0x33, 0x36, 0x76, 0x25, 0xa4, - 0xaa, 0x27, 0x8e, 0x54, 0xfc, 0x03, 0x9c, 0x39, 0xf5, 0xd0, 0x33, 0x17, 0x2e, 0x15, 0xa7, 0x0a, - 0x2e, 0xa8, 0x42, 0x06, 0x25, 0x48, 0x15, 0x39, 0x72, 0xe6, 0x80, 0x66, 0x66, 0x1d, 0xdb, 0x5d, - 0x9c, 0x40, 0x25, 0x90, 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0x7c, 0x26, 0x8f, - 0xec, 0x86, 0xca, 0xd1, 0xd5, 0x6f, 0x15, 0xb0, 0x32, 0x33, 0x59, 0x98, 0x98, 0x06, 0xc4, 0xa7, - 0x82, 0x4b, 0x31, 0x11, 0x88, 0x56, 0x34, 0xc5, 0x1a, 0x5e, 0x01, 0x6a, 0x97, 0x38, 0x54, 0x4b, - 0x88, 0x4a, 0x57, 0xe2, 0x95, 0xee, 0x12, 0xc7, 0x14, 0x10, 0x78, 0x1e, 0x24, 0x43, 0xcc, 0x44, - 0x8f, 0x15, 0x4c, 0xbe, 0x84, 0x45, 0x90, 0xed, 0x7b, 0x6d, 0x1c, 0x86, 0x24, 0x8c, 0x1e, 0xd3, - 0x4c, 0xdf, 0xdb, 0xe6, 0x26, 0x77, 0xf1, 0xee, 0xea, 0x51, 0x6c, 0xcb, 0x3e, 0x31, 0x33, 0x0e, - 0xa2, 0x77, 0x28, 0xb6, 0xe1, 0x2a, 0x00, 0xfb, 0x5d, 0x62, 0xdd, 0x95, 0xe3, 0x89, 0x7c, 0x37, - 0x73, 0x62, 0x87, 0x0f, 0x23, 0x51, 0x15, 0x0f, 0x15, 0x70, 0x6e, 0x8f, 0x3a, 0x77, 0x02, 0x1b, - 0x31, 0x7c, 0x4b, 0x0c, 0x5a, 0xfc, 0xa5, 0x8a, 0x46, 0x29, 0x36, 0x8c, 0xbe, 0x27, 0xed, 0xfb, - 0xc7, 0x6b, 0xcb, 0xd1, 0xd8, 0xd8, 0xb4, 0xed, 0x10, 0x53, 0x7a, 0x9b, 0x85, 0xae, 0xef, 0x98, - 0x13, 0x28, 0xbc, 0x0e, 0xd2, 0x72, 0x54, 0x13, 0xdf, 0x4e, 0x7e, 0x5d, 0x8b, 0x57, 0x29, 0x6f, - 0x30, 0x54, 0xae, 0xa0, 0x19, 0xa1, 0x37, 0x96, 0xf8, 0xac, 0x32, 0x39, 0xa7, 0x5a, 0x04, 0x17, - 0x5e, 0x48, 0x69, 0x4c, 0xed, 0xfa, 0x6f, 0x0a, 0x48, 0xee, 0x51, 0x07, 0x7e, 0x06, 0xa6, 0xa6, - 0x1e, 0xa8, 0xc7, 0x2f, 0x9a, 0x51, 0xa6, 0xf4, 0xe6, 0x19, 0x80, 0xf1, 0xf9, 0xd5, 0x37, 0x1e, - 0xfc, 0xf0, 0xeb, 0x97, 0x09, 0xbd, 0xba, 0xda, 0x88, 0x8d, 0x99, 0x38, 0x42, 0xb7, 0xd9, 0x00, - 0x7e, 0x02, 0x0a, 0x33, 0x8c, 0xbd, 0xf6, 0x97, 0xe7, 0x4f, 0x43, 0x4a, 0x57, 0xce, 0x84, 0x8c, - 0x93, 0x28, 0xa5, 0xee, 0x3f, 0x7f, 0x74, 0x55, 0x31, 0xde, 0x7d, 0x72, 0x58, 0x56, 0x9e, 0x1e, - 0x96, 0x95, 0x5f, 0x0e, 0xcb, 0xca, 0x17, 0x47, 0xe5, 0x85, 0xa7, 0x47, 0xe5, 0x85, 0x1f, 0x8f, - 0xca, 0x0b, 0x1f, 0x5d, 0x76, 0x5c, 0xd6, 0xe9, 0xed, 0xd7, 0x2d, 0xe2, 0xf1, 0xec, 0x08, 0x9d, - 0xca, 0x76, 0x20, 0xf2, 0x65, 0xc3, 0x00, 0xd3, 0xfd, 0xb4, 0x18, 0x6a, 0xdf, 0xfe, 0x33, 0x00, - 0x00, 0xff, 0xff, 0xe8, 0x95, 0x8e, 0xe7, 0x44, 0x0c, 0x00, 0x00, + // 1241 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x57, 0xcf, 0x8f, 0xdb, 0xc4, + 0x17, 0x5f, 0x27, 0xce, 0x0f, 0x4f, 0xd2, 0x6d, 0xbf, 0xfe, 0x6e, 0xa9, 0x13, 0x75, 0xe3, 0x34, + 0x85, 0x92, 0x16, 0x6d, 0x4c, 0x17, 0x54, 0xa9, 0x7b, 0x22, 0xee, 0x0f, 0x28, 0xda, 0x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 0x4b, 0x77, 0xdb, 0x23, 0xb4, 0x35, 0x50, 0xdf, 0x07, 0x79, 0xbb, 0x03, 0xbd, 0xa0, 0xed, 0x39, + 0x9c, 0x1a, 0xc5, 0x34, 0x5e, 0x74, 0xb8, 0xdc, 0x05, 0x06, 0xbe, 0x72, 0xf1, 0xd9, 0x48, 0xcf, + 0xd9, 0x62, 0x68, 0xc5, 0x03, 0x67, 0xca, 0x71, 0x6a, 0x29, 0xc7, 0xe9, 0xbf, 0xcc, 0xb1, 0xfc, + 0x62, 0x8e, 0x33, 0x49, 0x8e, 0xb3, 0x07, 0xe6, 0x38, 0x37, 0xc3, 0xf1, 0x47, 0x20, 0x2f, 0xee, + 0x38, 0x22, 0x5a, 0xbe, 0x9a, 0xae, 0x17, 0x36, 0xd7, 0x1b, 0xcf, 0x7f, 0xad, 0x1a, 0x82, 0xca, + 0x16, 0xfb, 0x08, 0x98, 0x55, 0x56, 0x96, 0xcf, 0x46, 0x3a, 0x80, 0x13, 0x7e, 0xbf, 0xf9, 0x45, + 0x07, 0x53, 0xb6, 0xad, 0xc9, 0x82, 0x42, 0x40, 0x65, 0x4e, 0x40, 0x30, 0x27, 0x60, 0x61, 0x99, + 0x80, 0x7f, 0xa4, 0x41, 0xf1, 0xe2, 0x30, 0x80, 0xbe, 0x67, 0x5f, 0x46, 0xe8, 0x1f, 0x11, 0xf0, + 0x3c, 0x28, 0x30, 0x01, 0xa9, 0x17, 0xb6, 0x6d, 0x18, 0xee, 0x2f, 0x21, 0x93, 0xbb, 0xe5, 0x85, + 0x17, 0x60, 0x38, 0x0e, 0xbd, 0x81, 0x10, 0x0f, 0x95, 0x5f, 0x26, 0xf4, 0x32, 0x42, 0x2c, 0x34, + 0x96, 0x3f, 0xf3, 0x62, 0xf9, 0xb3, 0x49, 0xf9, 0x73, 0x07, 0x96, 0x3f, 0xbf, 0x44, 0x7e, 0xe5, + 0x6f, 0x91, 0x1f, 0xcc, 0xc9, 0x5f, 0x98, 0x93, 0xbf, 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27, 0x16, 0xae, 0x3f, 0x0b, 0x29, 0x9f, 0xde, 0x17, 0x32, 0xb9, 0x0f, 0x9f, + 0x80, 0xff, 0x2f, 0x12, 0xac, 0xbe, 0x70, 0x85, 0x05, 0xc8, 0xf2, 0x9b, 0x2f, 0x8b, 0x1c, 0x6f, + 0x59, 0xce, 0xdc, 0x66, 0xea, 0x98, 0xef, 0x3c, 0xd8, 0xab, 0x48, 0x0f, 0xf7, 0x2a, 0xd2, 0xaf, + 0x7b, 0x15, 0xe9, 0x8b, 0x27, 0x95, 0x95, 0x87, 0x4f, 0x2a, 0x2b, 0x3f, 0x3f, 0xa9, 0xac, 0x7c, + 0x78, 0xca, 0xf5, 0x68, 0xa7, 0xb7, 0xdb, 0xb0, 0xb1, 0xcf, 0x08, 0xc1, 0x64, 0x86, 0xa0, 0x01, + 0xa7, 0x88, 0x0e, 0x43, 0x44, 0x76, 0xb3, 0xfc, 0x7f, 0xc1, 0x5b, 0x7f, 0x06, 0x00, 0x00, 0xff, + 0xff, 0x8a, 0x83, 0x91, 0x5e, 0xbd, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -616,6 +718,9 @@ type MsgClient interface { // UpdateParams defined a governance operation for updating the x/evm module parameters. // The authority is hard-coded to the Cosmos SDK x/gov module account UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) + // UpdateParams defined a governance operation for updating the x/evm module parameters. + // The authority is hard-coded to the Cosmos SDK x/gov module account + RegisterPreinstalls(ctx context.Context, in *MsgRegisterPreinstalls, opts ...grpc.CallOption) (*MsgRegisterPreinstallsResponse, error) } type msgClient struct { @@ -644,6 +749,15 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts return out, nil } +func (c *msgClient) RegisterPreinstalls(ctx context.Context, in *MsgRegisterPreinstalls, opts ...grpc.CallOption) (*MsgRegisterPreinstallsResponse, error) { + out := new(MsgRegisterPreinstallsResponse) + err := c.cc.Invoke(ctx, "/ethermint.evm.v1.Msg/RegisterPreinstalls", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // EthereumTx defines a method submitting Ethereum transactions. @@ -651,6 +765,9 @@ type MsgServer interface { // UpdateParams defined a governance operation for updating the x/evm module parameters. // The authority is hard-coded to the Cosmos SDK x/gov module account UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) + // UpdateParams defined a governance operation for updating the x/evm module parameters. + // The authority is hard-coded to the Cosmos SDK x/gov module account + RegisterPreinstalls(context.Context, *MsgRegisterPreinstalls) (*MsgRegisterPreinstallsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -663,6 +780,9 @@ func (*UnimplementedMsgServer) EthereumTx(ctx context.Context, req *MsgEthereumT func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented") } +func (*UnimplementedMsgServer) RegisterPreinstalls(ctx context.Context, req *MsgRegisterPreinstalls) (*MsgRegisterPreinstallsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterPreinstalls not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -704,6 +824,24 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_RegisterPreinstalls_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRegisterPreinstalls) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterPreinstalls(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ethermint.evm.v1.Msg/RegisterPreinstalls", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterPreinstalls(ctx, req.(*MsgRegisterPreinstalls)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "ethermint.evm.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -716,6 +854,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateParams", Handler: _Msg_UpdateParams_Handler, }, + { + MethodName: "RegisterPreinstalls", + Handler: _Msg_RegisterPreinstalls_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ethermint/evm/v1/tx.proto", @@ -1433,6 +1575,73 @@ func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgRegisterPreinstalls) 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 *MsgRegisterPreinstalls) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterPreinstalls) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Preinstalls) > 0 { + for iNdEx := len(m.Preinstalls) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Preinstalls[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterPreinstallsResponse) 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 *MsgRegisterPreinstallsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterPreinstallsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1757,6 +1966,34 @@ func (m *MsgUpdateParamsResponse) Size() (n int) { return n } +func (m *MsgRegisterPreinstalls) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Preinstalls) > 0 { + for _, e := range m.Preinstalls { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgRegisterPreinstallsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -4069,6 +4306,172 @@ func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgRegisterPreinstalls) 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 ErrIntOverflowTx + } + 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: MsgRegisterPreinstalls: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterPreinstalls: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Preinstalls", 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.Preinstalls = append(m.Preinstalls, Preinstall{}) + if err := m.Preinstalls[len(m.Preinstalls)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRegisterPreinstallsResponse) 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 ErrIntOverflowTx + } + 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: MsgRegisterPreinstallsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterPreinstallsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/evm/types/utils.go b/x/evm/types/utils.go index da075df587..8929caf1ee 100644 --- a/x/evm/types/utils.go +++ b/x/evm/types/utils.go @@ -16,6 +16,7 @@ package types import ( + "bytes" "encoding/hex" "encoding/json" "fmt" @@ -251,3 +252,8 @@ func GetBaseFee(height int64, ethCfg *params.ChainConfig, feemarketParams *feema } return baseFee } + +// IsEmptyCodeHash checks if the given byte slice represents an empty code hash. +func IsEmptyCodeHash(bz []byte) bool { + return bytes.Equal(bz, EmptyCodeHash) +}