diff --git a/go.mod b/go.mod index 7f6480208..3383e4767 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 c7de0ca4d..4f0b12d30 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/proto/evm/genesis.proto b/proto/evm/genesis.proto index 6862e42f9..4ce0ae02d 100644 --- a/proto/evm/genesis.proto +++ b/proto/evm/genesis.proto @@ -12,8 +12,34 @@ message AddressAssociation { string eth_address = 2; // Ethereum address } +message Code { + string address = 1; + bytes code = 2; +} + +message ContractState { + string address = 1; + bytes key = 2; + bytes value = 3; +} + +message Nonce { + string address = 1; + uint64 nonce = 2; +} + +message Serialized { + bytes prefix = 1; + bytes key = 2; + bytes value = 3; +} + // GenesisState defines the evm module's genesis state. message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; repeated AddressAssociation address_associations = 2; // List of address associations + repeated Code codes = 3; // List of stored code + repeated ContractState states = 4; // List of contract state + repeated Nonce nonces = 5; + repeated Serialized serialized = 6; } diff --git a/x/evm/genesis.go b/x/evm/genesis.go index 54eacf22d..a32db21ae 100644 --- a/x/evm/genesis.go +++ b/x/evm/genesis.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" "github.com/sei-protocol/sei-chain/x/evm/keeper" "github.com/sei-protocol/sei-chain/x/evm/types" ) @@ -12,11 +13,71 @@ import ( func InitGenesis(ctx sdk.Context, k *keeper.Keeper, genState types.GenesisState) { k.InitGenesis(ctx, genState) k.SetParams(ctx, genState.Params) + for _, aa := range genState.AddressAssociations { + k.SetAddressMapping(ctx, sdk.MustAccAddressFromBech32(aa.SeiAddress), common.HexToAddress(aa.EthAddress)) + } + for _, code := range genState.Codes { + k.SetCode(ctx, common.HexToAddress(code.Address), code.Code) + } + for _, state := range genState.States { + k.SetState(ctx, common.HexToAddress(state.Address), common.BytesToHash(state.Key), common.BytesToHash(state.Value)) + } + for _, nonce := range genState.Nonces { + k.SetNonce(ctx, common.HexToAddress(nonce.Address), nonce.Nonce) + } + for _, serialized := range genState.Serialized { + k.PrefixStore(ctx, serialized.Prefix).Set(serialized.Key, serialized.Value) + } } func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) + k.IterateSeiAddressMapping(ctx, func(evmAddr common.Address, seiAddr sdk.AccAddress) bool { + genesis.AddressAssociations = append(genesis.AddressAssociations, &types.AddressAssociation{ + SeiAddress: seiAddr.String(), + EthAddress: evmAddr.Hex(), + }) + return false + }) + k.IterateAllCode(ctx, func(addr common.Address, code []byte) bool { + genesis.Codes = append(genesis.Codes, &types.Code{ + Address: addr.Hex(), + Code: code, + }) + return false + }) + k.IterateState(ctx, func(addr common.Address, key, val common.Hash) bool { + genesis.States = append(genesis.States, &types.ContractState{ + Address: addr.Hex(), + Key: key[:], + Value: val[:], + }) + return false + }) + k.IterateAllNonces(ctx, func(addr common.Address, nonce uint64) bool { + genesis.Nonces = append(genesis.Nonces, &types.Nonce{ + Address: addr.Hex(), + Nonce: nonce, + }) + return false + }) + for _, prefix := range [][]byte{ + types.ReceiptKeyPrefix, + types.BlockBloomPrefix, + types.TxHashesPrefix, + types.PointerRegistryPrefix, + types.PointerCWCodePrefix, + } { + k.IterateAll(ctx, prefix, func(key, val []byte) bool { + genesis.Serialized = append(genesis.Serialized, &types.Serialized{ + Prefix: prefix, + Key: key, + Value: val, + }) + return false + }) + } return genesis } diff --git a/x/evm/genesis_test.go b/x/evm/genesis_test.go index e2b815129..19a0a9f96 100644 --- a/x/evm/genesis_test.go +++ b/x/evm/genesis_test.go @@ -3,14 +3,28 @@ package evm_test import ( "testing" + "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" testkeeper "github.com/sei-protocol/sei-chain/testutil/keeper" "github.com/sei-protocol/sei-chain/x/evm" "github.com/sei-protocol/sei-chain/x/evm/types" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) -func TestExportGenesis(t *testing.T) { - keeper, ctx := testkeeper.MockEVMKeeper() +func TestExportImportGenesis(t *testing.T) { + keeper, origctx := testkeeper.MockEVMKeeper() + ctx := origctx.WithMultiStore(origctx.MultiStore().CacheMultiStore()) + seiAddr, evmAddr := testkeeper.MockAddressPair() + keeper.SetAddressMapping(ctx, seiAddr, evmAddr) + _, codeAddr := testkeeper.MockAddressPair() + keeper.SetCode(ctx, codeAddr, []byte("abcde")) + keeper.SetState(ctx, codeAddr, common.BytesToHash([]byte("123")), common.BytesToHash([]byte("456"))) + keeper.SetNonce(ctx, evmAddr, 2) + keeper.SetReceipt(ctx, common.BytesToHash([]byte("789")), &types.Receipt{TxType: 2}) + keeper.SetBlockBloom(ctx, 5, []ethtypes.Bloom{{1}}) + keeper.SetTxHashesOnHeight(ctx, 5, []common.Hash{common.BytesToHash([]byte("123"))}) + keeper.SetERC20CW20Pointer(ctx, "cw20addr", codeAddr) genesis := evm.ExportGenesis(ctx, keeper) assert.NoError(t, genesis.Validate()) param := genesis.GetParams() @@ -18,4 +32,17 @@ func TestExportGenesis(t *testing.T) { assert.Equal(t, types.DefaultParams().BaseFeePerGas, param.BaseFeePerGas) assert.Equal(t, types.DefaultParams().MinimumFeePerGas, param.MinimumFeePerGas) assert.Equal(t, types.DefaultParams().WhitelistedCwCodeHashesForDelegateCall, param.WhitelistedCwCodeHashesForDelegateCall) + evm.InitGenesis(origctx, keeper, *genesis) + require.Equal(t, evmAddr, keeper.GetEVMAddressOrDefault(origctx, seiAddr)) + require.Equal(t, keeper.GetCode(ctx, codeAddr), keeper.GetCode(origctx, codeAddr)) + require.Equal(t, keeper.GetCodeHash(ctx, codeAddr), keeper.GetCodeHash(origctx, codeAddr)) + require.Equal(t, keeper.GetCodeSize(ctx, codeAddr), keeper.GetCodeSize(origctx, codeAddr)) + require.Equal(t, keeper.GetState(ctx, codeAddr, common.BytesToHash([]byte("123"))), keeper.GetState(origctx, codeAddr, common.BytesToHash([]byte("123")))) + require.Equal(t, keeper.GetNonce(ctx, evmAddr), keeper.GetNonce(origctx, evmAddr)) + _, err := keeper.GetReceipt(origctx, common.BytesToHash([]byte("789"))) + require.Nil(t, err) + require.Equal(t, keeper.GetBlockBloom(ctx, 5), keeper.GetBlockBloom(origctx, 5)) + require.Equal(t, keeper.GetTxHashesOnHeight(ctx, 5), keeper.GetTxHashesOnHeight(origctx, 5)) + _, _, exists := keeper.GetERC20CW20Pointer(origctx, "cw20addr") + require.True(t, exists) } diff --git a/x/evm/keeper/address.go b/x/evm/keeper/address.go index 2f65f205c..5b67c9102 100644 --- a/x/evm/keeper/address.go +++ b/x/evm/keeper/address.go @@ -2,6 +2,7 @@ package keeper import ( wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/sei-protocol/sei-chain/x/evm/types" @@ -68,3 +69,15 @@ func (k *Keeper) GetSeiAddressOrDefault(ctx sdk.Context, evmAddress common.Addre } return sdk.AccAddress(evmAddress[:]) } + +func (k *Keeper) IterateSeiAddressMapping(ctx sdk.Context, cb func(evmAddr common.Address, seiAddr sdk.AccAddress) bool) { + iter := prefix.NewStore(ctx.KVStore(k.storeKey), types.EVMAddressToSeiAddressKeyPrefix).Iterator(nil, nil) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + evmAddr := common.BytesToAddress(iter.Key()) + seiAddr := sdk.AccAddress(iter.Value()) + if cb(evmAddr, seiAddr) { + break + } + } +} diff --git a/x/evm/keeper/code.go b/x/evm/keeper/code.go index d2412f26d..be7d1fe20 100644 --- a/x/evm/keeper/code.go +++ b/x/evm/keeper/code.go @@ -3,6 +3,7 @@ package keeper import ( "encoding/binary" + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -48,3 +49,14 @@ func (k *Keeper) GetCodeSize(ctx sdk.Context, addr common.Address) int { } return int(binary.BigEndian.Uint64(bz)) } + +func (k *Keeper) IterateAllCode(ctx sdk.Context, cb func(addr common.Address, code []byte) bool) { + iter := prefix.NewStore(ctx.KVStore(k.storeKey), types.CodeKeyPrefix).Iterator(nil, nil) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + evmAddr := common.BytesToAddress(iter.Key()) + if cb(evmAddr, iter.Value()) { + break + } + } +} diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 209732843..b019f9c09 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -153,6 +153,16 @@ func (k *Keeper) GetStoreKey() sdk.StoreKey { return k.storeKey } +func (k *Keeper) IterateAll(ctx sdk.Context, pref []byte, cb func(key, val []byte) bool) { + iter := k.PrefixStore(ctx, pref).Iterator(nil, nil) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + if cb(iter.Key(), iter.Value()) { + break + } + } +} + func (k *Keeper) PrefixStore(ctx sdk.Context, pref []byte) sdk.KVStore { store := ctx.KVStore(k.GetStoreKey()) return prefix.NewStore(store, pref) diff --git a/x/evm/keeper/nonce.go b/x/evm/keeper/nonce.go index 27e937ee4..253f66548 100644 --- a/x/evm/keeper/nonce.go +++ b/x/evm/keeper/nonce.go @@ -3,6 +3,7 @@ package keeper import ( "encoding/binary" + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/sei-protocol/sei-chain/x/evm/types" @@ -21,3 +22,14 @@ func (k *Keeper) SetNonce(ctx sdk.Context, addr common.Address, nonce uint64) { binary.BigEndian.PutUint64(length, nonce) k.PrefixStore(ctx, types.NonceKeyPrefix).Set(addr[:], length) } + +func (k *Keeper) IterateAllNonces(ctx sdk.Context, cb func(addr common.Address, nonce uint64) bool) { + iter := prefix.NewStore(ctx.KVStore(k.storeKey), types.NonceKeyPrefix).Iterator(nil, nil) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + evmAddr := common.BytesToAddress(iter.Key()) + if cb(evmAddr, binary.BigEndian.Uint64(iter.Value())) { + break + } + } +} diff --git a/x/evm/keeper/state.go b/x/evm/keeper/state.go index 2cd0ab722..b2279bb41 100644 --- a/x/evm/keeper/state.go +++ b/x/evm/keeper/state.go @@ -1,6 +1,7 @@ package keeper import ( + "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/sei-protocol/sei-chain/x/evm/types" @@ -29,3 +30,15 @@ func (k *Keeper) GetState(ctx sdk.Context, addr common.Address, hash common.Hash func (k *Keeper) SetState(ctx sdk.Context, addr common.Address, key common.Hash, val common.Hash) { k.PrefixStore(ctx, types.StateKey(addr)).Set(key[:], val[:]) } + +func (k *Keeper) IterateState(ctx sdk.Context, cb func(addr common.Address, key common.Hash, val common.Hash) bool) { + iter := prefix.NewStore(ctx.KVStore(k.storeKey), types.StateKeyPrefix).Iterator(nil, nil) + defer iter.Close() + for ; iter.Valid(); iter.Next() { + k := iter.Key() + evmAddr := common.BytesToAddress(k[:common.AddressLength]) + if cb(evmAddr, common.BytesToHash(k[common.AddressLength:]), common.BytesToHash(iter.Value())) { + break + } + } +} diff --git a/x/evm/module_test.go b/x/evm/module_test.go index 8456c5cba..d64095ee0 100644 --- a/x/evm/module_test.go +++ b/x/evm/module_test.go @@ -45,7 +45,7 @@ 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\":[]}", 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\":[\"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) } func TestConsensusVersion(t *testing.T) { diff --git a/x/evm/types/genesis.pb.go b/x/evm/types/genesis.pb.go index 5b00c8a07..00b8fbf54 100644 --- a/x/evm/types/genesis.pb.go +++ b/x/evm/types/genesis.pb.go @@ -76,17 +76,245 @@ func (m *AddressAssociation) GetEthAddress() string { return "" } +type Code struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Code []byte `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` +} + +func (m *Code) Reset() { *m = Code{} } +func (m *Code) String() string { return proto.CompactTextString(m) } +func (*Code) ProtoMessage() {} +func (*Code) Descriptor() ([]byte, []int) { + return fileDescriptor_9f044f30507c97ed, []int{1} +} +func (m *Code) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Code) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Code.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 *Code) XXX_Merge(src proto.Message) { + xxx_messageInfo_Code.Merge(m, src) +} +func (m *Code) XXX_Size() int { + return m.Size() +} +func (m *Code) XXX_DiscardUnknown() { + xxx_messageInfo_Code.DiscardUnknown(m) +} + +var xxx_messageInfo_Code proto.InternalMessageInfo + +func (m *Code) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *Code) GetCode() []byte { + if m != nil { + return m.Code + } + return nil +} + +type ContractState struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *ContractState) Reset() { *m = ContractState{} } +func (m *ContractState) String() string { return proto.CompactTextString(m) } +func (*ContractState) ProtoMessage() {} +func (*ContractState) Descriptor() ([]byte, []int) { + return fileDescriptor_9f044f30507c97ed, []int{2} +} +func (m *ContractState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ContractState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ContractState.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 *ContractState) XXX_Merge(src proto.Message) { + xxx_messageInfo_ContractState.Merge(m, src) +} +func (m *ContractState) XXX_Size() int { + return m.Size() +} +func (m *ContractState) XXX_DiscardUnknown() { + xxx_messageInfo_ContractState.DiscardUnknown(m) +} + +var xxx_messageInfo_ContractState proto.InternalMessageInfo + +func (m *ContractState) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *ContractState) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *ContractState) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +type Nonce struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Nonce uint64 `protobuf:"varint,2,opt,name=nonce,proto3" json:"nonce,omitempty"` +} + +func (m *Nonce) Reset() { *m = Nonce{} } +func (m *Nonce) String() string { return proto.CompactTextString(m) } +func (*Nonce) ProtoMessage() {} +func (*Nonce) Descriptor() ([]byte, []int) { + return fileDescriptor_9f044f30507c97ed, []int{3} +} +func (m *Nonce) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Nonce) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Nonce.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 *Nonce) XXX_Merge(src proto.Message) { + xxx_messageInfo_Nonce.Merge(m, src) +} +func (m *Nonce) XXX_Size() int { + return m.Size() +} +func (m *Nonce) XXX_DiscardUnknown() { + xxx_messageInfo_Nonce.DiscardUnknown(m) +} + +var xxx_messageInfo_Nonce proto.InternalMessageInfo + +func (m *Nonce) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *Nonce) GetNonce() uint64 { + if m != nil { + return m.Nonce + } + return 0 +} + +type Serialized struct { + Prefix []byte `protobuf:"bytes,1,opt,name=prefix,proto3" json:"prefix,omitempty"` + Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` +} + +func (m *Serialized) Reset() { *m = Serialized{} } +func (m *Serialized) String() string { return proto.CompactTextString(m) } +func (*Serialized) ProtoMessage() {} +func (*Serialized) Descriptor() ([]byte, []int) { + return fileDescriptor_9f044f30507c97ed, []int{4} +} +func (m *Serialized) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Serialized) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Serialized.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 *Serialized) XXX_Merge(src proto.Message) { + xxx_messageInfo_Serialized.Merge(m, src) +} +func (m *Serialized) XXX_Size() int { + return m.Size() +} +func (m *Serialized) XXX_DiscardUnknown() { + xxx_messageInfo_Serialized.DiscardUnknown(m) +} + +var xxx_messageInfo_Serialized proto.InternalMessageInfo + +func (m *Serialized) GetPrefix() []byte { + if m != nil { + return m.Prefix + } + return nil +} + +func (m *Serialized) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *Serialized) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + // GenesisState defines the evm module's genesis state. type GenesisState struct { Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` AddressAssociations []*AddressAssociation `protobuf:"bytes,2,rep,name=address_associations,json=addressAssociations,proto3" json:"address_associations,omitempty"` + Codes []*Code `protobuf:"bytes,3,rep,name=codes,proto3" json:"codes,omitempty"` + States []*ContractState `protobuf:"bytes,4,rep,name=states,proto3" json:"states,omitempty"` + Nonces []*Nonce `protobuf:"bytes,5,rep,name=nonces,proto3" json:"nonces,omitempty"` + Serialized []*Serialized `protobuf:"bytes,6,rep,name=serialized,proto3" json:"serialized,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_9f044f30507c97ed, []int{1} + return fileDescriptor_9f044f30507c97ed, []int{5} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -129,33 +357,76 @@ func (m *GenesisState) GetAddressAssociations() []*AddressAssociation { return nil } +func (m *GenesisState) GetCodes() []*Code { + if m != nil { + return m.Codes + } + return nil +} + +func (m *GenesisState) GetStates() []*ContractState { + if m != nil { + return m.States + } + return nil +} + +func (m *GenesisState) GetNonces() []*Nonce { + if m != nil { + return m.Nonces + } + return nil +} + +func (m *GenesisState) GetSerialized() []*Serialized { + if m != nil { + return m.Serialized + } + return nil +} + func init() { proto.RegisterType((*AddressAssociation)(nil), "seiprotocol.seichain.evm.AddressAssociation") + proto.RegisterType((*Code)(nil), "seiprotocol.seichain.evm.Code") + proto.RegisterType((*ContractState)(nil), "seiprotocol.seichain.evm.ContractState") + proto.RegisterType((*Nonce)(nil), "seiprotocol.seichain.evm.Nonce") + proto.RegisterType((*Serialized)(nil), "seiprotocol.seichain.evm.Serialized") proto.RegisterType((*GenesisState)(nil), "seiprotocol.seichain.evm.GenesisState") } func init() { proto.RegisterFile("evm/genesis.proto", fileDescriptor_9f044f30507c97ed) } var fileDescriptor_9f044f30507c97ed = []byte{ - // 284 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0xb1, 0x4e, 0xc3, 0x30, - 0x10, 0x86, 0x63, 0x40, 0x95, 0x70, 0x18, 0x20, 0x74, 0xa8, 0x3a, 0xb8, 0x55, 0xa7, 0x0e, 0xd4, - 0x91, 0xca, 0x8e, 0xd4, 0x2e, 0x5d, 0x51, 0x90, 0x18, 0x58, 0x22, 0x37, 0x3d, 0x25, 0x27, 0x91, - 0x38, 0xca, 0x99, 0x0a, 0xde, 0x82, 0x37, 0xe1, 0x35, 0x3a, 0x76, 0x64, 0x42, 0x28, 0x79, 0x11, - 0x14, 0xc7, 0xc0, 0x50, 0x75, 0x3b, 0xfb, 0xff, 0xfc, 0xff, 0xbf, 0x8f, 0x5f, 0xc1, 0x36, 0x0f, - 0x53, 0x28, 0x80, 0x90, 0x64, 0x59, 0x69, 0xa3, 0x83, 0x01, 0x01, 0xda, 0x29, 0xd1, 0xcf, 0x92, - 0x00, 0x93, 0x4c, 0x61, 0x21, 0x61, 0x9b, 0x0f, 0xfb, 0xa9, 0x4e, 0xb5, 0x95, 0xc2, 0x76, 0xea, - 0xf8, 0xe1, 0x65, 0x6b, 0x51, 0xaa, 0x4a, 0xe5, 0xce, 0x61, 0xf2, 0xc8, 0x83, 0xc5, 0x66, 0x53, - 0x01, 0xd1, 0x82, 0x48, 0x27, 0xa8, 0x0c, 0xea, 0x22, 0x18, 0x71, 0x9f, 0x00, 0x63, 0xd5, 0x29, - 0x03, 0x36, 0x66, 0xd3, 0xf3, 0x88, 0x13, 0xa0, 0x63, 0x5b, 0x00, 0x4c, 0xf6, 0x07, 0x9c, 0x74, - 0x00, 0x98, 0xcc, 0x01, 0x93, 0x0f, 0xc6, 0x2f, 0x56, 0x5d, 0xd7, 0x07, 0xa3, 0x0c, 0x04, 0x77, - 0xbc, 0xd7, 0x05, 0x5b, 0x37, 0x7f, 0x3e, 0x96, 0xc7, 0xba, 0xcb, 0x7b, 0xcb, 0x2d, 0xcf, 0x76, - 0x5f, 0x23, 0x2f, 0x72, 0xaf, 0x82, 0x98, 0xf7, 0x5d, 0x5a, 0xac, 0xfe, 0x9b, 0xb6, 0xd1, 0xa7, - 0x53, 0x7f, 0x7e, 0x73, 0xdc, 0xed, 0xf0, 0x7b, 0xd1, 0xb5, 0x3a, 0xb8, 0xa3, 0xe5, 0x6a, 0x57, - 0x0b, 0xb6, 0xaf, 0x05, 0xfb, 0xae, 0x05, 0x7b, 0x6f, 0x84, 0xb7, 0x6f, 0x84, 0xf7, 0xd9, 0x08, - 0xef, 0x69, 0x96, 0xa2, 0xc9, 0x5e, 0xd6, 0x32, 0xd1, 0x79, 0x48, 0x80, 0xb3, 0xdf, 0x1c, 0x7b, - 0xb0, 0x41, 0xe1, 0x6b, 0xd8, 0x6e, 0xd6, 0xbc, 0x95, 0x40, 0xeb, 0x9e, 0xd5, 0x6f, 0x7f, 0x02, - 0x00, 0x00, 0xff, 0xff, 0x71, 0xa9, 0x4b, 0x46, 0xb0, 0x01, 0x00, 0x00, + // 461 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xcf, 0x6b, 0x13, 0x41, + 0x14, 0xc7, 0x13, 0xf7, 0x87, 0xf8, 0x12, 0xa1, 0x8e, 0x41, 0x96, 0x1e, 0x36, 0x65, 0x11, 0xec, + 0xc1, 0xee, 0x42, 0x2d, 0xf4, 0xa6, 0xb4, 0x15, 0x7a, 0x11, 0xd1, 0x29, 0x78, 0xf0, 0x12, 0xa6, + 0xbb, 0xcf, 0x64, 0x30, 0xd9, 0x09, 0xfb, 0xa6, 0xa1, 0xf5, 0xaf, 0xf0, 0x9f, 0xf0, 0x7f, 0xe9, + 0xb1, 0x47, 0x4f, 0x22, 0xc9, 0x3f, 0x22, 0xf3, 0x76, 0xfb, 0x43, 0xca, 0x86, 0xde, 0xde, 0xdb, + 0xf9, 0x7e, 0x3f, 0xcc, 0xe4, 0x43, 0xe0, 0x19, 0x2e, 0x66, 0xd9, 0x18, 0x4b, 0x24, 0x4d, 0xe9, + 0xbc, 0x32, 0xd6, 0x88, 0x88, 0x50, 0xf3, 0x94, 0x9b, 0x69, 0x4a, 0xa8, 0xf3, 0x89, 0xd2, 0x65, + 0x8a, 0x8b, 0xd9, 0xe6, 0x60, 0x6c, 0xc6, 0x86, 0x8f, 0x32, 0x37, 0xd5, 0xf9, 0xcd, 0x0d, 0x87, + 0x98, 0xab, 0x4a, 0xcd, 0x1a, 0x42, 0xf2, 0x05, 0xc4, 0x41, 0x51, 0x54, 0x48, 0x74, 0x40, 0x64, + 0x72, 0xad, 0xac, 0x36, 0xa5, 0x18, 0x42, 0x8f, 0x50, 0x8f, 0x54, 0x7d, 0x12, 0x75, 0xb7, 0xba, + 0xdb, 0x4f, 0x24, 0x10, 0xea, 0x26, 0xeb, 0x02, 0x68, 0x27, 0x37, 0x81, 0x47, 0x75, 0x00, 0xed, + 0xa4, 0x09, 0x24, 0x7b, 0xe0, 0x1f, 0x99, 0x02, 0x45, 0x04, 0x8f, 0xff, 0xa7, 0x5c, 0xaf, 0x42, + 0x80, 0x9f, 0x9b, 0x02, 0xb9, 0xdb, 0x97, 0x3c, 0x27, 0x9f, 0xe1, 0xe9, 0x91, 0x29, 0x6d, 0xa5, + 0x72, 0x7b, 0x62, 0x95, 0x5d, 0x57, 0xdf, 0x00, 0xef, 0x3b, 0x5e, 0x34, 0x6d, 0x37, 0x8a, 0x01, + 0x04, 0x0b, 0x35, 0x3d, 0xc3, 0xc8, 0xe3, 0x6f, 0xf5, 0x92, 0xec, 0x43, 0xf0, 0xd1, 0x94, 0xf9, + 0x3a, 0xd4, 0x00, 0x82, 0xd2, 0x45, 0x18, 0xe6, 0xcb, 0x7a, 0x49, 0x3e, 0x00, 0x9c, 0x60, 0xa5, + 0xd5, 0x54, 0xff, 0xc0, 0x42, 0xbc, 0x80, 0x70, 0x5e, 0xe1, 0x37, 0x7d, 0xce, 0xe5, 0xbe, 0x6c, + 0xb6, 0x07, 0x5f, 0xe3, 0x97, 0x07, 0xfd, 0xe3, 0xda, 0x5d, 0xfd, 0xb2, 0xb7, 0x10, 0xd6, 0x22, + 0x18, 0xd8, 0xdb, 0xdd, 0x4a, 0xdb, 0x5c, 0xa6, 0x9f, 0x38, 0x77, 0xe8, 0x5f, 0xfe, 0x19, 0x76, + 0x64, 0xd3, 0x12, 0x23, 0x18, 0x34, 0xf7, 0x1f, 0xa9, 0x5b, 0x73, 0x4e, 0x85, 0xb7, 0xdd, 0xdb, + 0x7d, 0xdd, 0x4e, 0xbb, 0xaf, 0x5b, 0x3e, 0x57, 0xf7, 0xbe, 0x91, 0xd8, 0x83, 0xc0, 0x39, 0xa1, + 0xc8, 0x63, 0x62, 0xdc, 0x4e, 0x74, 0xa2, 0x65, 0x1d, 0x16, 0xef, 0x20, 0x24, 0xf7, 0x3e, 0x8a, + 0x7c, 0xae, 0xbd, 0x5a, 0x57, 0xbb, 0x63, 0x5a, 0x36, 0x35, 0xb1, 0x0f, 0x21, 0xff, 0xfe, 0x14, + 0x05, 0x0c, 0x18, 0xb6, 0x03, 0xd8, 0xab, 0x6c, 0xe2, 0xe2, 0x3d, 0x00, 0xdd, 0xf8, 0x8a, 0x42, + 0x2e, 0xbf, 0x6c, 0x2f, 0xdf, 0xba, 0x95, 0x77, 0x7a, 0x87, 0xc7, 0x97, 0xcb, 0xb8, 0x7b, 0xb5, + 0x8c, 0xbb, 0x7f, 0x97, 0x71, 0xf7, 0xe7, 0x2a, 0xee, 0x5c, 0xad, 0xe2, 0xce, 0xef, 0x55, 0xdc, + 0xf9, 0xba, 0x33, 0xd6, 0x76, 0x72, 0x76, 0x9a, 0xe6, 0x66, 0x96, 0x11, 0xea, 0x9d, 0x6b, 0x2c, + 0x2f, 0xcc, 0xcd, 0xce, 0x33, 0xf7, 0xff, 0xb2, 0x17, 0x73, 0xa4, 0xd3, 0x90, 0xcf, 0xdf, 0xfc, + 0x0b, 0x00, 0x00, 0xff, 0xff, 0x58, 0x59, 0xc2, 0xfb, 0xb6, 0x03, 0x00, 0x00, } func (m *AddressAssociation) Marshal() (dAtA []byte, err error) { @@ -195,7 +466,7 @@ func (m *AddressAssociation) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *GenesisState) Marshal() (dAtA []byte, err error) { +func (m *Code) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -205,95 +476,891 @@ func (m *GenesisState) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { +func (m *Code) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Code) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.AddressAssociations) > 0 { - for iNdEx := len(m.AddressAssociations) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.AddressAssociations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.Code) > 0 { + i -= len(m.Code) + copy(dAtA[i:], m.Code) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Code))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ContractState) 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 *ContractState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ContractState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x1a + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Nonce) 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 *Nonce) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Nonce) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Nonce != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Nonce)) + i-- + dAtA[i] = 0x10 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Serialized) 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 *Serialized) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Serialized) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x1a + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x12 + } + if len(m.Prefix) > 0 { + i -= len(m.Prefix) + copy(dAtA[i:], m.Prefix) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Prefix))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Serialized) > 0 { + for iNdEx := len(m.Serialized) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Serialized[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } + if len(m.Nonces) > 0 { + for iNdEx := len(m.Nonces) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Nonces[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } + if len(m.States) > 0 { + for iNdEx := len(m.States) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.States[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.Codes) > 0 { + for iNdEx := len(m.Codes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Codes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.AddressAssociations) > 0 { + for iNdEx := len(m.AddressAssociations) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AddressAssociations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *AddressAssociation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SeiAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.EthAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *Code) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.Code) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *ContractState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *Nonce) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if m.Nonce != 0 { + n += 1 + sovGenesis(uint64(m.Nonce)) + } + return n +} + +func (m *Serialized) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Prefix) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.AddressAssociations) > 0 { + for _, e := range m.AddressAssociations { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Codes) > 0 { + for _, e := range m.Codes { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.States) > 0 { + for _, e := range m.States { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Nonces) > 0 { + for _, e := range m.Nonces { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.Serialized) > 0 { + for _, e := range m.Serialized { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *AddressAssociation) 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 ErrIntOverflowGenesis + } + 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: AddressAssociation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: AddressAssociation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SeiAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SeiAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EthAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EthAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Code) 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 ErrIntOverflowGenesis + } + 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: Code: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Code: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Code = append(m.Code[:0], dAtA[iNdEx:postIndex]...) + if m.Code == nil { + m.Code = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ContractState) 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 ErrIntOverflowGenesis + } + 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: ContractState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ContractState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Nonce) 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 ErrIntOverflowGenesis + } + 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: Nonce: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Nonce: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + 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 ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) + } + m.Nonce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Nonce |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { - offset -= sovGenesis(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *AddressAssociation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.SeiAddress) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - l = len(m.EthAddress) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - return n -} -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) - if len(m.AddressAssociations) > 0 { - for _, e := range m.AddressAssociations { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } + if iNdEx > l { + return io.ErrUnexpectedEOF } - return n -} - -func sovGenesis(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGenesis(x uint64) (n int) { - return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + return nil } -func (m *AddressAssociation) Unmarshal(dAtA []byte) error { +func (m *Serialized) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -316,17 +1383,17 @@ func (m *AddressAssociation) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: AddressAssociation: wiretype end group for non-group") + return fmt.Errorf("proto: Serialized: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: AddressAssociation: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Serialized: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SeiAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Prefix", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -336,29 +1403,31 @@ func (m *AddressAssociation) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthGenesis } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthGenesis } if postIndex > l { return io.ErrUnexpectedEOF } - m.SeiAddress = string(dAtA[iNdEx:postIndex]) + m.Prefix = append(m.Prefix[:0], dAtA[iNdEx:postIndex]...) + if m.Prefix == nil { + m.Prefix = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EthAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -368,23 +1437,59 @@ func (m *AddressAssociation) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthGenesis } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthGenesis } if postIndex > l { return io.ErrUnexpectedEOF } - m.EthAddress = string(dAtA[iNdEx:postIndex]) + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex @@ -503,6 +1608,142 @@ 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 Codes", 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.Codes = append(m.Codes, &Code{}) + if err := m.Codes[len(m.Codes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field States", 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.States = append(m.States, &ContractState{}) + if err := m.States[len(m.States)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonces", 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.Nonces = append(m.Nonces, &Nonce{}) + if err := m.Nonces[len(m.Nonces)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Serialized", 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.Serialized = append(m.Serialized, &Serialized{}) + if err := m.Serialized[len(m.Serialized)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:])