From 729caa30487a33e0f014a1412cee42c189b7bdae Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 9 Jan 2023 11:58:34 +0800 Subject: [PATCH 01/13] update dep --- gomod2nix.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gomod2nix.toml b/gomod2nix.toml index bc0d27ab68..2d57483431 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -406,8 +406,8 @@ schema = 3 version = "v0.9.1" hash = "sha256-YLGNrHHM+mN4ElW/XWuylOnFrA/VjSY+eBuC4LN//5c=" [mod."github.com/rs/cors"] - version = "v1.8.2" - hash = "sha256-FxBbQVb8zIoDGGaAJKfsYV0+POkh1tyX7P6A/Lk5Vsc=" + version = "v1.8.3" + hash = "sha256-VgVB4HKAhPSjNg96mIEUN1bt5ZQng8Fi3ZABy3CDWQE=" [mod."github.com/rs/zerolog"] version = "v1.27.0" hash = "sha256-BxQtP2TROeSSpj9l1irocuSfxn55UL4ugzB/og7r8eE=" From 34febb2f05d21de69fb15821a15352f390b1a066 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 9 Jan 2023 12:00:11 +0800 Subject: [PATCH 02/13] make proto-all --- x/evm/types/events.pb.go | 17 ++--- x/evm/types/tx.pb.go | 125 ++++++++++++++++----------------- x/evm/types/tx.pb.gw.go | 83 ---------------------- x/feemarket/types/events.pb.go | 4 +- 4 files changed, 73 insertions(+), 156 deletions(-) diff --git a/x/evm/types/events.pb.go b/x/evm/types/events.pb.go index 208a90db56..ca5ed58858 100644 --- a/x/evm/types/events.pb.go +++ b/x/evm/types/events.pb.go @@ -22,21 +22,21 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// EventEthereumTx defines the event for a Ethereum transaction +// EventEthereumTx defines the event for an Ethereum transaction type EventEthereumTx struct { // amount Amount string `protobuf:"bytes,1,opt,name=amount,proto3" json:"amount,omitempty"` - // eth_hash Ethereum hash of the transaction + // eth_hash is the Ethereum hash of the transaction EthHash string `protobuf:"bytes,2,opt,name=eth_hash,json=ethHash,proto3" json:"eth_hash,omitempty"` // index of the transaction in the block Index string `protobuf:"bytes,3,opt,name=index,proto3" json:"index,omitempty"` // gas_used is the amount of gas used by the transaction GasUsed string `protobuf:"bytes,4,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` - // hash Tendermint hash of the transaction + // hash is the Tendermint hash of the transaction Hash string `protobuf:"bytes,5,opt,name=hash,proto3" json:"hash,omitempty"` // recipient of the transaction Recipient string `protobuf:"bytes,6,opt,name=recipient,proto3" json:"recipient,omitempty"` - // eth_tx_failed the VM error + // eth_tx_failed contains a VM error should it occur EthTxFailed string `protobuf:"bytes,7,opt,name=eth_tx_failed,json=ethTxFailed,proto3" json:"eth_tx_failed,omitempty"` } @@ -122,9 +122,9 @@ func (m *EventEthereumTx) GetEthTxFailed() string { return "" } -// EventTxLog defines the event for a Ethereum transaction log +// EventTxLog defines the event for an Ethereum transaction log type EventTxLog struct { - // tx_logs is the log of the transaction + // tx_logs is an array of transaction logs TxLogs []string `protobuf:"bytes,1,rep,name=tx_logs,json=txLogs,proto3" json:"tx_logs,omitempty"` } @@ -170,9 +170,9 @@ func (m *EventTxLog) GetTxLogs() []string { // EventMessage type EventMessage struct { - // module is the module of the message + // module which emits the event Module string `protobuf:"bytes,1,opt,name=module,proto3" json:"module,omitempty"` - // sender is the sender of the message + // sender of the message Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"` // tx_type is the type of the message TxType string `protobuf:"bytes,3,opt,name=tx_type,json=txType,proto3" json:"tx_type,omitempty"` @@ -232,6 +232,7 @@ func (m *EventMessage) GetTxType() string { return "" } +// EventBlockBloom defines an Ethereum block bloom filter event type EventBlockBloom struct { // bloom is the bloom filter of the block Bloom string `protobuf:"bytes,1,opt,name=bloom,proto3" json:"bloom,omitempty"` diff --git a/x/evm/types/tx.pb.go b/x/evm/types/tx.pb.go index f563fc5ba6..c74acf9b26 100644 --- a/x/evm/types/tx.pb.go +++ b/x/evm/types/tx.pb.go @@ -454,69 +454,68 @@ func init() { func init() { proto.RegisterFile("ethermint/evm/v1/tx.proto", fileDescriptor_f75ac0a12d075f21) } var fileDescriptor_f75ac0a12d075f21 = []byte{ - // 990 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x4f, 0x8f, 0xdb, 0x44, - 0x14, 0x5f, 0x27, 0xce, 0xbf, 0x49, 0x58, 0xaa, 0xd1, 0x56, 0x75, 0x22, 0x1a, 0xa7, 0x96, 0xa0, - 0x69, 0xa5, 0xd8, 0xea, 0x82, 0x7a, 0xd8, 0x53, 0x37, 0xdd, 0x6d, 0xd5, 0x6a, 0x57, 0x54, 0x26, - 0xbd, 0xd0, 0x43, 0x34, 0xeb, 0xcc, 0x4e, 0x2c, 0x62, 0x8f, 0xe5, 0x19, 0x5b, 0x09, 0x12, 0x97, - 0x4a, 0x48, 0x1c, 0x90, 0x00, 0xf1, 0x05, 0x38, 0x70, 0xe2, 0x84, 0x44, 0x3f, 0x00, 0xc7, 0x8a, - 0x53, 0x05, 0x17, 0xc4, 0x21, 0xa0, 0x2c, 0x12, 0xd2, 0xde, 0xe0, 0x13, 0xa0, 0x99, 0x71, 0x36, - 0x9b, 0x86, 0x6d, 0xa1, 0x14, 0x71, 0xf2, 0xbc, 0x79, 0x6f, 0xde, 0x7b, 0xf3, 0xfb, 0xfd, 0x66, - 0xc6, 0xa0, 0x8e, 0xf9, 0x10, 0xc7, 0x81, 0x1f, 0x72, 0x07, 0xa7, 0x81, 0x93, 0x5e, 0x73, 0xf8, - 0xd8, 0x8e, 0x62, 0xca, 0x29, 0x3c, 0x77, 0xe2, 0xb2, 0x71, 0x1a, 0xd8, 0xe9, 0xb5, 0xc6, 0x05, - 0x8f, 0xb2, 0x80, 0x32, 0x27, 0x60, 0x44, 0x44, 0x06, 0x8c, 0x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21, 0x93, 0x1b, 0x95, 0xb7, - 0xbc, 0xa6, 0x2e, 0x71, 0x79, 0xb1, 0x5f, 0x01, 0xfa, 0x88, 0x12, 0x66, 0xe4, 0xe4, 0x26, 0xcf, - 0xaf, 0x6e, 0x72, 0x8f, 0x12, 0x57, 0x86, 0xc0, 0x73, 0x20, 0x1f, 0x63, 0x2e, 0x35, 0x53, 0x73, - 0xc5, 0x10, 0xd6, 0x41, 0x39, 0x0d, 0xfa, 0x38, 0x8e, 0x69, 0x9c, 0xdd, 0xba, 0xa5, 0x34, 0xd8, - 0x15, 0xa6, 0x70, 0x09, 0x71, 0x24, 0x0c, 0x0f, 0x14, 0xab, 0x6e, 0x89, 0x20, 0x76, 0x9f, 0xe1, - 0x41, 0xd6, 0xe6, 0x67, 0x1a, 0x78, 0x75, 0x9f, 0x91, 0xfb, 0xd1, 0x00, 0x71, 0x7c, 0x0f, 0xc5, - 0x28, 0x60, 0xf0, 0x3a, 0xa8, 0xa0, 0x84, 0x0f, 0x69, 0xec, 0xf3, 0x49, 0x76, 0x22, 0x8c, 0xef, - 0x1f, 0x75, 0x36, 0xb2, 0xd7, 0x76, 0x7b, 0x30, 0x88, 0x31, 0x63, 0xef, 0xf0, 0xd8, 0x0f, 0x89, - 0xbb, 0x08, 0x85, 0xd7, 0x41, 0x31, 0x92, 0x19, 0xa4, 0xd8, 0xab, 0x9b, 0xc6, 0xea, 0x36, 0x54, - 0x85, 0xae, 0x2e, 0x68, 0x72, 0xb3, 0xe8, 0xad, 0xf5, 0x87, 0xbf, 0x7d, 0x7d, 0x75, 0x91, 0xc7, - 0xaa, 0x83, 0x0b, 0x4f, 0xb5, 0x34, 0xc7, 0x6e, 0xf3, 0xe3, 0x1c, 0xc8, 0xef, 0x33, 0x02, 0x3f, - 0x00, 0xe0, 0xd4, 0xe3, 0x6b, 0xae, 0x16, 0x5a, 0x82, 0xbe, 0x71, 0xf9, 0x39, 0x01, 0xf3, 0xfc, - 0xd6, 0xeb, 0x0f, 0x7f, 0xf8, 0xf5, 0xf3, 0x9c, 0x69, 0x5d, 0x74, 0x56, 0x7f, 0x26, 0xb2, 0xe8, - 0x3e, 0x1f, 0xc3, 0x0f, 0x35, 0x50, 0x5b, 0x82, 0xec, 0xd2, 0x5f, 0x16, 0x38, 0x1d, 0xd2, 0xb8, - 0xf2, 0xdc, 0x90, 0x93, 0x2e, 0x2e, 0xcb, 0x2e, 0x2e, 0x59, 0xe6, 0x6a, 0x17, 0x89, 0x8c, 0xef, - 0x2b, 0xe4, 0xba, 0x37, 0x1e, 0xcf, 0x9a, 0xda, 0x93, 0x59, 0x53, 0xfb, 0x65, 0xd6, 0xd4, 0x3e, - 0x3d, 0x6a, 0xae, 0x3d, 0x39, 0x6a, 0xae, 0xfd, 0x78, 0xd4, 0x5c, 0x7b, 0xf7, 0xf4, 0x31, 0xc4, - 0xa9, 0x38, 0x85, 0x8b, 0x54, 0x63, 0x99, 0x4c, 0x1e, 0xc5, 0x83, 0xa2, 0xfc, 0x43, 0x79, 0xf3, - 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3c, 0x20, 0xbe, 0xf3, 0x9e, 0x09, 0x00, 0x00, + // 975 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcf, 0x8f, 0xdb, 0xc4, + 0x17, 0x8f, 0x13, 0xe7, 0xd7, 0x24, 0xdf, 0xfd, 0x56, 0xa3, 0xad, 0xea, 0x44, 0x34, 0x0e, 0x96, + 0x80, 0xb4, 0x52, 0x6c, 0x75, 0x41, 0x3d, 0xec, 0xa9, 0x9b, 0xee, 0xb6, 0x6a, 0xb5, 0x2b, 0x2a, + 0x93, 0x5e, 0x28, 0x52, 0x34, 0x6b, 0xcf, 0x4e, 0x2c, 0x62, 0x8f, 0xe5, 0x99, 0x58, 0x09, 0x12, + 0x97, 0x9e, 0xb8, 0x01, 0xe2, 0x1f, 0xe0, 0xc0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da, 0xee, 0xf8, 0x7e, 0x82, 0x19, 0x7b, 0x87, 0x27, 0x41, 0x44, 0xdc, + 0x65, 0x28, 0xbc, 0x0e, 0x4a, 0xb1, 0xcc, 0x20, 0xc5, 0x5e, 0xdb, 0x32, 0xd6, 0xb7, 0xa1, 0x2a, + 0xf4, 0x74, 0x41, 0x93, 0x9b, 0x45, 0x6f, 0x6f, 0x3c, 0xfc, 0xf5, 0xab, 0xab, 0xcb, 0x3c, 0x56, + 0x03, 0x5c, 0x7a, 0xaa, 0xa5, 0x05, 0x76, 0x5b, 0x73, 0x0d, 0x14, 0x0e, 0x18, 0x81, 0x1f, 0x02, + 0x70, 0xe6, 0xf1, 0x35, 0xd7, 0x0b, 0xad, 0x40, 0xdf, 0x7c, 0xe3, 0x39, 0x01, 0x8b, 0xfc, 0xd6, + 0x6b, 0x0f, 0xbf, 0xff, 0xe5, 0xb3, 0xbc, 0x69, 0x5d, 0x76, 0xd6, 0x7f, 0x26, 0xb2, 0xe8, 0x01, + 0x9f, 0xc0, 0xf7, 0x40, 0x7d, 0x05, 0xb1, 0x57, 0xff, 0x34, 0xff, 0xd9, 0x90, 0xe6, 0x95, 0xe7, + 0x86, 0x2c, 0x9a, 0xe8, 0xdd, 0x78, 0x3c, 0x6f, 0x69, 0x4f, 0xe6, 0x2d, 0xed, 0xe7, 0x79, 0x4b, + 0xfb, 0xe4, 0xb8, 0x95, 0x7b, 0x72, 0xdc, 0xca, 0xfd, 0x70, 0xdc, 0xca, 0xbd, 0x7b, 0xf6, 0x70, + 0xe1, 0x54, 0x9c, 0xad, 0x65, 0x9b, 0x13, 0xd9, 0xa8, 0x3c, 0x60, 0x87, 0x25, 0xf9, 0xdf, 0xf1, + 0xe6, 0x1f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x8d, 0xf3, 0xe0, 0xc6, 0x74, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/evm/types/tx.pb.gw.go b/x/evm/types/tx.pb.gw.go index 7bcb6a8f7d..f58f9572d6 100644 --- a/x/evm/types/tx.pb.gw.go +++ b/x/evm/types/tx.pb.gw.go @@ -69,42 +69,6 @@ func local_request_Msg_EthereumTx_0(ctx context.Context, marshaler runtime.Marsh } -var ( - filter_Msg_UpdateParams_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Msg_UpdateParams_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq MsgUpdateParams - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_UpdateParams_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.UpdateParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Msg_UpdateParams_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq MsgUpdateParams - var metadata runtime.ServerMetadata - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_UpdateParams_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.UpdateParams(ctx, &protoReq) - return msg, metadata, err - -} - // RegisterMsgHandlerServer registers the http handlers for service Msg to "mux". // UnaryRPC :call MsgServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -134,29 +98,6 @@ func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server }) - mux.Handle("POST", pattern_Msg_UpdateParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - var stream runtime.ServerTransportStream - ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Msg_UpdateParams_0(rctx, inboundMarshaler, server, req, pathParams) - md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_UpdateParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } @@ -218,37 +159,13 @@ func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client }) - mux.Handle("POST", pattern_Msg_UpdateParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Msg_UpdateParams_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Msg_UpdateParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - return nil } var ( pattern_Msg_EthereumTx_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ethermint", "evm", "v1", "ethereum_tx"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Msg_UpdateParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ethermint", "evm", "v1", "update_params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Msg_EthereumTx_0 = runtime.ForwardResponseMessage - - forward_Msg_UpdateParams_0 = runtime.ForwardResponseMessage ) diff --git a/x/feemarket/types/events.pb.go b/x/feemarket/types/events.pb.go index 53bc08c5f1..0ebc8966e5 100644 --- a/x/feemarket/types/events.pb.go +++ b/x/feemarket/types/events.pb.go @@ -68,9 +68,9 @@ func (m *EventFeeMarket) GetBaseFee() string { return "" } -// EventBlockGas defines the event for a Ethereum block gas +// EventBlockGas defines an Ethereum block gas event type EventBlockGas struct { - // height is the height of the block + // height of the block Height string `protobuf:"bytes,1,opt,name=height,proto3" json:"height,omitempty"` // amount of gas wanted by the block Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` From 177936fba0326ca153b16c27603e2f047ba8e411 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 5 Jan 2023 14:20:00 +0800 Subject: [PATCH 03/13] avoid duplicate register proto type in evm --- x/evm/keeper/migrations_test.go | 9 ++++----- x/evm/migrations/v4/migrate.go | 17 ++++++++--------- x/evm/migrations/v4/migrate_test.go | 27 +++++++++++++-------------- x/evm/types/params.go | 18 ++++++++++++++++++ 4 files changed, 43 insertions(+), 28 deletions(-) diff --git a/x/evm/keeper/migrations_test.go b/x/evm/keeper/migrations_test.go index 0875e4dae1..604d663e1c 100644 --- a/x/evm/keeper/migrations_test.go +++ b/x/evm/keeper/migrations_test.go @@ -3,24 +3,23 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" evmkeeper "github.com/evmos/ethermint/x/evm/keeper" - v4types "github.com/evmos/ethermint/x/evm/migrations/v4/types" "github.com/evmos/ethermint/x/evm/types" ) type mockSubspace struct { - ps v4types.V4Params + ps types.Params } -func newMockSubspace(ps v4types.V4Params) mockSubspace { +func newMockSubspace(ps types.Params) mockSubspace { return mockSubspace{ps: ps} } func (ms mockSubspace) GetParamSetIfExists(_ sdk.Context, ps types.LegacyParams) { - *ps.(*v4types.V4Params) = ms.ps + *ps.(*types.Params) = ms.ps } func (suite *KeeperTestSuite) TestMigrations() { - legacySubspace := newMockSubspace(v4types.DefaultParams()) + legacySubspace := newMockSubspace(types.DefaultParams()) migrator := evmkeeper.NewMigrator(*suite.app.EvmKeeper, legacySubspace) testCases := []struct { diff --git a/x/evm/migrations/v4/migrate.go b/x/evm/migrations/v4/migrate.go index 0bd9c23557..f9ba9eb1b2 100644 --- a/x/evm/migrations/v4/migrate.go +++ b/x/evm/migrations/v4/migrate.go @@ -4,7 +4,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - v4types "github.com/evmos/ethermint/x/evm/migrations/v4/types" "github.com/evmos/ethermint/x/evm/types" ) @@ -19,7 +18,7 @@ func MigrateStore( ) error { var ( store = ctx.KVStore(storeKey) - params v4types.V4Params + params types.Params ) legacySubspace.GetParamSetIfExists(ctx, ¶ms) @@ -29,22 +28,22 @@ func MigrateStore( } chainCfgBz := cdc.MustMarshal(¶ms.ChainConfig) - extraEIPsBz := cdc.MustMarshal(&v4types.ExtraEIPs{EIPs: v4types.AvailableExtraEIPs}) + extraEIPsBz := cdc.MustMarshal(&types.ExtraEIPs{EIPs: types.AvailableExtraEIPs}) - store.Set(v4types.ParamStoreKeyEVMDenom, []byte(params.EvmDenom)) - store.Set(v4types.ParamStoreKeyExtraEIPs, extraEIPsBz) - store.Set(v4types.ParamStoreKeyChainConfig, chainCfgBz) + store.Set(types.ParamStoreKeyEVMDenom, []byte(params.EvmDenom)) + store.Set(types.ParamStoreKeyExtraEIPs, extraEIPsBz) + store.Set(types.ParamStoreKeyChainConfig, chainCfgBz) if params.AllowUnprotectedTxs { - store.Set(v4types.ParamStoreKeyAllowUnprotectedTxs, []byte{0x01}) + store.Set(types.ParamStoreKeyAllowUnprotectedTxs, []byte{0x01}) } if params.EnableCall { - store.Set(v4types.ParamStoreKeyEnableCall, []byte{0x01}) + store.Set(types.ParamStoreKeyEnableCall, []byte{0x01}) } if params.EnableCreate { - store.Set(v4types.ParamStoreKeyEnableCreate, []byte{0x01}) + store.Set(types.ParamStoreKeyEnableCreate, []byte{0x01}) } return nil diff --git a/x/evm/migrations/v4/migrate_test.go b/x/evm/migrations/v4/migrate_test.go index 1261380208..fc643d98c7 100644 --- a/x/evm/migrations/v4/migrate_test.go +++ b/x/evm/migrations/v4/migrate_test.go @@ -11,20 +11,19 @@ import ( "github.com/evmos/ethermint/app" "github.com/evmos/ethermint/encoding" v4 "github.com/evmos/ethermint/x/evm/migrations/v4" - v4types "github.com/evmos/ethermint/x/evm/migrations/v4/types" "github.com/stretchr/testify/require" ) type mockSubspace struct { - ps v4types.V4Params + ps types.Params } -func newMockSubspace(ps v4types.V4Params) mockSubspace { +func newMockSubspace(ps types.Params) mockSubspace { return mockSubspace{ps: ps} } func (ms mockSubspace) GetParamSetIfExists(ctx sdk.Context, ps types.LegacyParams) { - *ps.(*v4types.V4Params) = ms.ps + *ps.(*types.Params) = ms.ps } func TestMigrate(t *testing.T) { @@ -36,29 +35,29 @@ func TestMigrate(t *testing.T) { ctx := testutil.DefaultContext(storeKey, tKey) kvStore := ctx.KVStore(storeKey) - legacySubspace := newMockSubspace(v4types.DefaultParams()) + legacySubspace := newMockSubspace(types.DefaultParams()) require.NoError(t, v4.MigrateStore(ctx, storeKey, legacySubspace, cdc)) // Get all the new parameters from the kvStore var evmDenom string - bz := kvStore.Get(v4types.ParamStoreKeyEVMDenom) + bz := kvStore.Get(types.ParamStoreKeyEVMDenom) evmDenom = string(bz) var allowUnprotectedTx gogotypes.BoolValue - bz = kvStore.Get(v4types.ParamStoreKeyAllowUnprotectedTxs) + bz = kvStore.Get(types.ParamStoreKeyAllowUnprotectedTxs) cdc.MustUnmarshal(bz, &allowUnprotectedTx) - enableCreate := kvStore.Has(v4types.ParamStoreKeyEnableCreate) - enableCall := kvStore.Has(v4types.ParamStoreKeyEnableCall) + enableCreate := kvStore.Has(types.ParamStoreKeyEnableCreate) + enableCall := kvStore.Has(types.ParamStoreKeyEnableCall) - var chainCfg v4types.ChainConfig - bz = kvStore.Get(v4types.ParamStoreKeyChainConfig) + var chainCfg types.ChainConfig + bz = kvStore.Get(types.ParamStoreKeyChainConfig) cdc.MustUnmarshal(bz, &chainCfg) - var extraEIPs v4types.ExtraEIPs - bz = kvStore.Get(v4types.ParamStoreKeyExtraEIPs) + var extraEIPs types.ExtraEIPs + bz = kvStore.Get(types.ParamStoreKeyExtraEIPs) cdc.MustUnmarshal(bz, &extraEIPs) - params := v4types.NewParams(evmDenom, allowUnprotectedTx.Value, enableCreate, enableCall, chainCfg, extraEIPs) + params := types.NewParams(evmDenom, allowUnprotectedTx.Value, enableCreate, enableCall, chainCfg, extraEIPs) require.Equal(t, legacySubspace.ps, params) } diff --git a/x/evm/types/params.go b/x/evm/types/params.go index dc5b714c9d..85a56b1621 100644 --- a/x/evm/types/params.go +++ b/x/evm/types/params.go @@ -22,6 +22,7 @@ import ( "github.com/ethereum/go-ethereum/params" sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/ethereum/go-ethereum/core/vm" "github.com/evmos/ethermint/types" ) @@ -56,6 +57,11 @@ var ( AvailableExtraEIPs = []int64{1344, 1884, 2200, 2929, 3198, 3529} ) +// ParamKeyTable returns the parameter key table. +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + // NewParams creates a new Params instance func NewParams(evmDenom string, allowUnprotectedTxs, enableCreate, enableCall bool, config ChainConfig, extraEIPs ExtraEIPs) Params { return Params{ @@ -81,6 +87,18 @@ func DefaultParams() Params { } } +// ParamSetPairs returns the parameter set pairs. +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(ParamStoreKeyEVMDenom, &p.EvmDenom, validateEVMDenom), + paramtypes.NewParamSetPair(ParamStoreKeyEnableCreate, &p.EnableCreate, validateBool), + paramtypes.NewParamSetPair(ParamStoreKeyEnableCall, &p.EnableCall, validateBool), + paramtypes.NewParamSetPair(ParamStoreKeyExtraEIPs, &p.ExtraEIPs.EIPs, validateEIPs), + paramtypes.NewParamSetPair(ParamStoreKeyChainConfig, &p.ChainConfig, validateChainConfig), + paramtypes.NewParamSetPair(ParamStoreKeyAllowUnprotectedTxs, &p.AllowUnprotectedTxs, validateBool), + } +} + // Validate performs basic validation on evm parameters. func (p Params) Validate() error { if err := validateEVMDenom(p.EvmDenom); err != nil { From fff69e3c431c73c9cec65df8e5fe27a7b6946dbc Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 5 Jan 2023 15:05:12 +0800 Subject: [PATCH 04/13] set KeyTable --- app/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index 40aa6cf76b..4912201c75 100644 --- a/app/app.go +++ b/app/app.go @@ -861,7 +861,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(ibctransfertypes.ModuleName) paramsKeeper.Subspace(ibchost.ModuleName) // ethermint subspaces - paramsKeeper.Subspace(evmtypes.ModuleName) + paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) paramsKeeper.Subspace(feemarkettypes.ModuleName) return paramsKeeper } From be653321c8b41752f5829adfcb42bf8c1e85cd2f Mon Sep 17 00:00:00 2001 From: mmsqe Date: Thu, 5 Jan 2023 15:19:26 +0800 Subject: [PATCH 05/13] update from version to v.19.x which support submit-proposal --- tests/integration_tests/configs/upgrade-test-package.nix | 5 ++--- tests/integration_tests/cosmoscli.py | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/integration_tests/configs/upgrade-test-package.nix b/tests/integration_tests/configs/upgrade-test-package.nix index 6b8345cef8..1863054dfb 100644 --- a/tests/integration_tests/configs/upgrade-test-package.nix +++ b/tests/integration_tests/configs/upgrade-test-package.nix @@ -3,10 +3,9 @@ let fetchEthermint = rev: builtins.fetchTarball "https://github.com/evmos/ethermint/archive/${rev}.tar.gz"; released = pkgs.buildGo118Module rec { name = "ethermintd"; - # the commit before https://github.com/evmos/ethermint/pull/943 - src = fetchEthermint "8866ae0ffd67a104e9d1cf4e50fba8391dda6c45"; + src = fetchEthermint "d29cdad6e667f6089dfecbedd36bb8d3a2a7d025"; subPackages = [ "cmd/ethermintd" ]; - vendorSha256 = "sha256-oDtMamNlwe/393fZd+RNtRy6ipWpusbco8Xg1ZuKWYw="; + vendorSha256 = "sha256-cQAol54b6hNzsA4Q3MP9mTqFWM1MvR5uMPrYpaoj3SY="; doCheck = false; }; current = pkgs.callPackage ../../../. { }; diff --git a/tests/integration_tests/cosmoscli.py b/tests/integration_tests/cosmoscli.py index 71bde8f61e..41c24c91e7 100644 --- a/tests/integration_tests/cosmoscli.py +++ b/tests/integration_tests/cosmoscli.py @@ -637,9 +637,8 @@ def edit_validator( ) def gov_propose(self, proposer, kind, proposal, **kwargs): - method = "submit-legacy-proposal" + method = "submit-proposal" kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE) - kwargs.setdefault("gas", DEFAULT_GAS) if kind == "software-upgrade": return json.loads( self.raw( @@ -649,7 +648,6 @@ def gov_propose(self, proposer, kind, proposal, **kwargs): kind, proposal["name"], "-y", - "--no-validate", from_=proposer, # content title=proposal.get("title"), From c2e01e8526e8a219c6411627f17455c25b5d68f0 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 6 Jan 2023 09:54:45 +0800 Subject: [PATCH 06/13] test AvailableExtraEIPs --- x/evm/migrations/v4/migrate_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/evm/migrations/v4/migrate_test.go b/x/evm/migrations/v4/migrate_test.go index fc643d98c7..8cfe022368 100644 --- a/x/evm/migrations/v4/migrate_test.go +++ b/x/evm/migrations/v4/migrate_test.go @@ -57,6 +57,7 @@ func TestMigrate(t *testing.T) { var extraEIPs types.ExtraEIPs bz = kvStore.Get(types.ParamStoreKeyExtraEIPs) cdc.MustUnmarshal(bz, &extraEIPs) + require.Equal(t, types.AvailableExtraEIPs, extraEIPs.EIPs) params := types.NewParams(evmDenom, allowUnprotectedTx.Value, enableCreate, enableCall, chainCfg, extraEIPs) require.Equal(t, legacySubspace.ps, params) From 864a001304af1122098766877e1f8553483c56bb Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 9 Jan 2023 11:13:53 +0800 Subject: [PATCH 07/13] keep grpc query compatible with version before migrate --- app/app.go | 5 +++-- x/evm/keeper/keeper.go | 5 +++++ x/evm/keeper/params.go | 31 +++++++++++++++++++++++++------ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/app/app.go b/app/app.go index 4912201c75..53df386cf0 100644 --- a/app/app.go +++ b/app/app.go @@ -418,10 +418,11 @@ func NewEthermintApp( ) // Set authority to x/gov module account to only expect the module account to update params + ss := app.GetSubspace(evmtypes.ModuleName) app.EvmKeeper = evmkeeper.NewKeeper( appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper, - nil, geth.NewEVM, tracer, + nil, geth.NewEVM, tracer, ss, ) // Create IBC Keeper @@ -508,7 +509,7 @@ func NewEthermintApp( transferModule, // Ethermint app modules feemarket.NewAppModule(app.FeeMarketKeeper, app.GetSubspace(feemarkettypes.ModuleName)), - evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, app.GetSubspace(evmtypes.ModuleName)), + evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, ss), ) // During begin block slashing happens after distr.BeginBlocker so that diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 4a1bc78866..7a3e839076 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -23,6 +23,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -75,6 +76,8 @@ type Keeper struct { // evm constructor function evmConstructor evm.Constructor + // Legacy subspace + ss paramstypes.Subspace } // NewKeeper generates new evm module keeper @@ -89,6 +92,7 @@ func NewKeeper( customPrecompiles evm.PrecompiledContracts, evmConstructor evm.Constructor, tracer string, + ss paramstypes.Subspace, ) *Keeper { // ensure evm module account is set if addr := ak.GetModuleAddress(types.ModuleName); addr == nil { @@ -113,6 +117,7 @@ func NewKeeper( customPrecompiles: customPrecompiles, evmConstructor: evmConstructor, tracer: tracer, + ss: ss, } } diff --git a/x/evm/keeper/params.go b/x/evm/keeper/params.go index 64f582c7f5..2ad6bd4891 100644 --- a/x/evm/keeper/params.go +++ b/x/evm/keeper/params.go @@ -48,13 +48,20 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { return nil } +// GetLegacyParams returns param set for version before migrate +func (k Keeper) GetLegacyParams(ctx sdk.Context) types.Params { + var params types.Params + k.ss.GetParamSetIfExists(ctx, ¶ms) + return params +} + // GetExtraEIPs returns the extra EIPs enabled on the chain. func (k Keeper) GetExtraEIPs(ctx sdk.Context) types.ExtraEIPs { var extraEIPs types.ExtraEIPs store := ctx.KVStore(k.storeKey) bz := store.Get(types.ParamStoreKeyExtraEIPs) if len(bz) == 0 { - return extraEIPs + return k.GetLegacyParams(ctx).ExtraEIPs } k.cdc.MustUnmarshal(bz, &extraEIPs) return extraEIPs @@ -66,7 +73,7 @@ func (k Keeper) GetChainConfig(ctx sdk.Context) types.ChainConfig { store := ctx.KVStore(k.storeKey) bz := store.Get(types.ParamStoreKeyChainConfig) if len(bz) == 0 { - return chainCfg + return k.GetLegacyParams(ctx).ChainConfig } k.cdc.MustUnmarshal(bz, &chainCfg) return chainCfg @@ -77,7 +84,7 @@ func (k Keeper) GetEVMDenom(ctx sdk.Context) string { store := ctx.KVStore(k.storeKey) bz := store.Get(types.ParamStoreKeyEVMDenom) if len(bz) == 0 { - return "" + return k.GetLegacyParams(ctx).EvmDenom } return string(bz) } @@ -85,19 +92,31 @@ func (k Keeper) GetEVMDenom(ctx sdk.Context) string { // GetEnableCall returns true if the EVM Call operation is enabled. func (k Keeper) GetEnableCall(ctx sdk.Context) bool { store := ctx.KVStore(k.storeKey) - return store.Has(types.ParamStoreKeyEnableCall) + exist := store.Has(types.ParamStoreKeyEnableCall) + if !exist { + exist = k.GetLegacyParams(ctx).EnableCall + } + return exist } // GetEnableCreate returns true if the EVM Create contract operation is enabled. func (k Keeper) GetEnableCreate(ctx sdk.Context) bool { store := ctx.KVStore(k.storeKey) - return store.Has(types.ParamStoreKeyEnableCreate) + exist := store.Has(types.ParamStoreKeyEnableCreate) + if !exist { + exist = k.GetLegacyParams(ctx).EnableCreate + } + return exist } // GetAllowUnprotectedTxs returns true if unprotected txs (i.e non-replay protected as per EIP-155) are supported by the chain. func (k Keeper) GetAllowUnprotectedTxs(ctx sdk.Context) bool { store := ctx.KVStore(k.storeKey) - return store.Has(types.ParamStoreKeyAllowUnprotectedTxs) + exist := store.Has(types.ParamStoreKeyAllowUnprotectedTxs) + if !exist { + exist = k.GetLegacyParams(ctx).AllowUnprotectedTxs + } + return exist } // setChainConfig sets the ChainConfig in the store From e42b3788e71eb067ac0da59be780a44195e23170 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 9 Jan 2023 12:40:39 +0800 Subject: [PATCH 08/13] fix duplicate register & migrate in feemarket --- app/app.go | 13 ++-- x/feemarket/keeper/keeper.go | 6 +- x/feemarket/keeper/migrations_test.go | 9 ++- x/feemarket/keeper/params.go | 4 +- x/feemarket/migrations/v4/migrate.go | 3 +- x/feemarket/migrations/v4/migrate_test.go | 13 ++-- x/feemarket/types/params.go | 88 ++++++++++++++++++++++- x/feemarket/types/params_test.go | 56 --------------- 8 files changed, 112 insertions(+), 80 deletions(-) diff --git a/app/app.go b/app/app.go index 53df386cf0..d9d42e82f8 100644 --- a/app/app.go +++ b/app/app.go @@ -412,17 +412,18 @@ func NewEthermintApp( tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer)) // Create Ethermint keepers + feeMarketSs := app.GetSubspace(feemarkettypes.ModuleName) app.FeeMarketKeeper = feemarketkeeper.NewKeeper( appCodec, authtypes.NewModuleAddress(govtypes.ModuleName), - keys[feemarkettypes.StoreKey], tkeys[feemarkettypes.TransientKey], + keys[feemarkettypes.StoreKey], tkeys[feemarkettypes.TransientKey], feeMarketSs, ) // Set authority to x/gov module account to only expect the module account to update params - ss := app.GetSubspace(evmtypes.ModuleName) + evmSs := app.GetSubspace(evmtypes.ModuleName) app.EvmKeeper = evmkeeper.NewKeeper( appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], authtypes.NewModuleAddress(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.FeeMarketKeeper, - nil, geth.NewEVM, tracer, ss, + nil, geth.NewEVM, tracer, evmSs, ) // Create IBC Keeper @@ -508,8 +509,8 @@ func NewEthermintApp( ibc.NewAppModule(app.IBCKeeper), transferModule, // Ethermint app modules - feemarket.NewAppModule(app.FeeMarketKeeper, app.GetSubspace(feemarkettypes.ModuleName)), - evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, ss), + feemarket.NewAppModule(app.FeeMarketKeeper, feeMarketSs), + evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, evmSs), ) // During begin block slashing happens after distr.BeginBlocker so that @@ -863,6 +864,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(ibchost.ModuleName) // ethermint subspaces paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(evmtypes.ParamKeyTable()) - paramsKeeper.Subspace(feemarkettypes.ModuleName) + paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable()) return paramsKeeper } diff --git a/x/feemarket/keeper/keeper.go b/x/feemarket/keeper/keeper.go index 466e4b418a..3d702a545c 100644 --- a/x/feemarket/keeper/keeper.go +++ b/x/feemarket/keeper/keeper.go @@ -21,6 +21,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" "github.com/evmos/ethermint/x/feemarket/types" @@ -38,11 +39,13 @@ type Keeper struct { transientKey storetypes.StoreKey // the address capable of executing a MsgUpdateParams message. Typically, this should be the x/gov module account. authority sdk.AccAddress + // Legacy subspace + ss paramstypes.Subspace } // NewKeeper generates new fee market module keeper func NewKeeper( - cdc codec.BinaryCodec, authority sdk.AccAddress, storeKey, transientKey storetypes.StoreKey, + cdc codec.BinaryCodec, authority sdk.AccAddress, storeKey, transientKey storetypes.StoreKey, ss paramstypes.Subspace, ) Keeper { // ensure authority account is correctly formatted if err := sdk.VerifyAddressFormat(authority); err != nil { @@ -54,6 +57,7 @@ func NewKeeper( storeKey: storeKey, authority: authority, transientKey: transientKey, + ss: ss, } } diff --git a/x/feemarket/keeper/migrations_test.go b/x/feemarket/keeper/migrations_test.go index 82a90b6533..71b0bca429 100644 --- a/x/feemarket/keeper/migrations_test.go +++ b/x/feemarket/keeper/migrations_test.go @@ -3,24 +3,23 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper" - v4types "github.com/evmos/ethermint/x/feemarket/migrations/v4/types" "github.com/evmos/ethermint/x/feemarket/types" ) type mockSubspace struct { - ps v4types.Params + ps types.Params } -func newMockSubspace(ps v4types.Params) mockSubspace { +func newMockSubspace(ps types.Params) mockSubspace { return mockSubspace{ps: ps} } func (ms mockSubspace) GetParamSetIfExists(_ sdk.Context, ps types.LegacyParams) { - *ps.(*v4types.Params) = ms.ps + *ps.(*types.Params) = ms.ps } func (suite *KeeperTestSuite) TestMigrations() { - legacySubspace := newMockSubspace(v4types.DefaultParams()) + legacySubspace := newMockSubspace(types.DefaultParams()) migrator := feemarketkeeper.NewMigrator(suite.app.FeeMarketKeeper, legacySubspace) testCases := []struct { diff --git a/x/feemarket/keeper/params.go b/x/feemarket/keeper/params.go index 4508e5f442..f8a1f3744f 100644 --- a/x/feemarket/keeper/params.go +++ b/x/feemarket/keeper/params.go @@ -28,7 +28,9 @@ func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.ParamsKey) if len(bz) == 0 { - return params + var p types.Params + k.ss.GetParamSetIfExists(ctx, &p) + return p } k.cdc.MustUnmarshal(bz, ¶ms) diff --git a/x/feemarket/migrations/v4/migrate.go b/x/feemarket/migrations/v4/migrate.go index 4a1649140f..a13861e861 100644 --- a/x/feemarket/migrations/v4/migrate.go +++ b/x/feemarket/migrations/v4/migrate.go @@ -4,7 +4,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - v4types "github.com/evmos/ethermint/x/feemarket/migrations/v4/types" "github.com/evmos/ethermint/x/feemarket/types" ) @@ -19,7 +18,7 @@ func MigrateStore( ) error { var ( store = ctx.KVStore(storeKey) - params v4types.Params + params types.Params ) legacySubspace.GetParamSetIfExists(ctx, ¶ms) diff --git a/x/feemarket/migrations/v4/migrate_test.go b/x/feemarket/migrations/v4/migrate_test.go index 7980158352..959bf16e5f 100644 --- a/x/feemarket/migrations/v4/migrate_test.go +++ b/x/feemarket/migrations/v4/migrate_test.go @@ -8,25 +8,24 @@ import ( "github.com/evmos/ethermint/app" "github.com/evmos/ethermint/encoding" v4 "github.com/evmos/ethermint/x/feemarket/migrations/v4" - v4types "github.com/evmos/ethermint/x/feemarket/migrations/v4/types" "github.com/evmos/ethermint/x/feemarket/types" "github.com/stretchr/testify/require" ) type mockSubspace struct { - ps v4types.Params + ps types.Params } func newMockSubspaceEmpty() mockSubspace { return mockSubspace{} } -func newMockSubspace(ps v4types.Params) mockSubspace { +func newMockSubspace(ps types.Params) mockSubspace { return mockSubspace{ps: ps} } func (ms mockSubspace) GetParamSetIfExists(ctx sdk.Context, ps types.LegacyParams) { - *ps.(*v4types.Params) = ms.ps + *ps.(*types.Params) = ms.ps } func TestMigrate(t *testing.T) { @@ -41,11 +40,11 @@ func TestMigrate(t *testing.T) { legacySubspaceEmpty := newMockSubspaceEmpty() require.Error(t, v4.MigrateStore(ctx, storeKey, legacySubspaceEmpty, cdc)) - legacySubspace := newMockSubspace(v4types.DefaultParams()) + legacySubspace := newMockSubspace(types.DefaultParams()) require.NoError(t, v4.MigrateStore(ctx, storeKey, legacySubspace, cdc)) - paramsBz := kvStore.Get(v4types.ParamsKey) - var params v4types.Params + paramsBz := kvStore.Get(types.ParamsKey) + var params types.Params cdc.MustUnmarshal(paramsBz, ¶ms) require.Equal(t, params, legacySubspace.ps) diff --git a/x/feemarket/types/params.go b/x/feemarket/types/params.go index 6d5d718e03..a3f1f6d696 100644 --- a/x/feemarket/types/params.go +++ b/x/feemarket/types/params.go @@ -20,11 +20,10 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/ethereum/go-ethereum/params" ) -var ParamsKey = []byte("Params") - var ( // DefaultMinGasMultiplier is 0.5 or 50% DefaultMinGasMultiplier = sdk.NewDecWithPrec(50, 2) @@ -36,6 +35,36 @@ var ( DefaultNoBaseFee = false ) +// Parameter keys +var ( + ParamsKey = []byte("Params") + ParamStoreKeyNoBaseFee = []byte("NoBaseFee") + ParamStoreKeyBaseFeeChangeDenominator = []byte("BaseFeeChangeDenominator") + ParamStoreKeyElasticityMultiplier = []byte("ElasticityMultiplier") + ParamStoreKeyBaseFee = []byte("BaseFee") + ParamStoreKeyEnableHeight = []byte("EnableHeight") + ParamStoreKeyMinGasPrice = []byte("MinGasPrice") + ParamStoreKeyMinGasMultiplier = []byte("MinGasMultiplier") +) + +// ParamKeyTable returns the parameter key table. +func ParamKeyTable() paramtypes.KeyTable { + return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) +} + +// ParamSetPairs returns the parameter set pairs. +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(ParamStoreKeyNoBaseFee, &p.NoBaseFee, validateBool), + paramtypes.NewParamSetPair(ParamStoreKeyBaseFeeChangeDenominator, &p.BaseFeeChangeDenominator, validateBaseFeeChangeDenominator), + paramtypes.NewParamSetPair(ParamStoreKeyElasticityMultiplier, &p.ElasticityMultiplier, validateElasticityMultiplier), + paramtypes.NewParamSetPair(ParamStoreKeyBaseFee, &p.BaseFee, validateBaseFee), + paramtypes.NewParamSetPair(ParamStoreKeyEnableHeight, &p.EnableHeight, validateEnableHeight), + paramtypes.NewParamSetPair(ParamStoreKeyMinGasPrice, &p.MinGasPrice, validateMinGasPrice), + paramtypes.NewParamSetPair(ParamStoreKeyMinGasMultiplier, &p.MinGasMultiplier, validateMinGasPrice), + } +} + // NewParams creates a new Params instance func NewParams( noBaseFee bool, @@ -91,6 +120,14 @@ func (p Params) Validate() error { return validateMinGasPrice(p.MinGasPrice) } +func validateBool(i interface{}) error { + _, ok := i.(bool) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + return nil +} + func (p *Params) IsBaseFeeEnabled(height int64) bool { return !p.NoBaseFee && height >= p.EnableHeight } @@ -113,6 +150,53 @@ func validateMinGasPrice(i interface{}) error { return nil } +func validateBaseFeeChangeDenominator(i interface{}) error { + value, ok := i.(uint32) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if value == 0 { + return fmt.Errorf("base fee change denominator cannot be 0") + } + + return nil +} + +func validateElasticityMultiplier(i interface{}) error { + _, ok := i.(uint32) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + return nil +} + +func validateBaseFee(i interface{}) error { + value, ok := i.(sdkmath.Int) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if value.IsNegative() { + return fmt.Errorf("base fee cannot be negative") + } + + return nil +} + +func validateEnableHeight(i interface{}) error { + value, ok := i.(int64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if value < 0 { + return fmt.Errorf("enable height cannot be negative: %d", value) + } + + return nil +} + func validateMinGasMultiplier(i interface{}) error { v, ok := i.(sdk.Dec) diff --git a/x/feemarket/types/params_test.go b/x/feemarket/types/params_test.go index 51dd16d9b2..822fb08d01 100644 --- a/x/feemarket/types/params_test.go +++ b/x/feemarket/types/params_test.go @@ -1,7 +1,6 @@ package types import ( - "fmt" "testing" sdkmath "cosmossdk.io/math" @@ -18,61 +17,6 @@ func TestParamsTestSuite(t *testing.T) { suite.Run(t, new(ParamsTestSuite)) } -func validateElasticityMultiplier(i interface{}) error { - _, ok := i.(uint32) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - return nil -} - -func validateBaseFeeChangeDenominator(i interface{}) error { - value, ok := i.(uint32) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if value == 0 { - return fmt.Errorf("base fee change denominator cannot be 0") - } - - return nil -} - -func validateEnableHeight(i interface{}) error { - value, ok := i.(int64) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if value < 0 { - return fmt.Errorf("enable height cannot be negative: %d", value) - } - - return nil -} - -func validateBool(i interface{}) error { - _, ok := i.(bool) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - return nil -} - -func validateBaseFee(i interface{}) error { - value, ok := i.(sdkmath.Int) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if value.IsNegative() { - return fmt.Errorf("base fee cannot be negative") - } - - return nil -} - func (suite *ParamsTestSuite) TestParamsValidate() { testCases := []struct { name string From 4bae8a1b920333050993f22194960fffafc442c6 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 9 Jan 2023 12:49:28 +0800 Subject: [PATCH 09/13] update nix --- gomod2nix.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gomod2nix.toml b/gomod2nix.toml index 2d57483431..fcea40f1cd 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -112,7 +112,7 @@ schema = 3 hash = "sha256-EmpRZ48pjPFq/fIHneut9Vyo5QJATfb3ZO7KzWnqs9g=" [mod."github.com/cosmos/ibc-go/v6"] version = "v6.1.0" - hash = "sha256-Gfqhdz9ZKEgb7LCkHiXCwYZYUYluQ+vMew/GkssfVj8=" + hash = "sha256-mHYCqLedcveDjfm1EiO2EMMNJqLm9u4WHwQTy1muOoc=" [mod."github.com/cosmos/ledger-cosmos-go"] version = "v0.12.1" hash = "sha256-9+nr+/r4MyiogddS0JcXOuriPqXP4nxln8ts+mYQRcg=" From 287d3aec30a951a7cece40a0c310858997850a3d Mon Sep 17 00:00:00 2001 From: mmsqe Date: Tue, 10 Jan 2023 09:21:59 +0800 Subject: [PATCH 10/13] support typed event for bloom & txLog --- rpc/backend/blocks.go | 9 ++++++--- rpc/backend/chain_info.go | 13 +------------ rpc/types/utils.go | 17 ++++++++++++++--- x/evm/types/events.go | 8 +++++--- x/feemarket/types/events.go | 6 +++--- 5 files changed, 29 insertions(+), 24 deletions(-) diff --git a/rpc/backend/blocks.go b/rpc/backend/blocks.go index c4f09d7009..a0eaa25c30 100644 --- a/rpc/backend/blocks.go +++ b/rpc/backend/blocks.go @@ -347,13 +347,16 @@ func (b *Backend) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error) // BlockBloom query block bloom filter from block results func (b *Backend) BlockBloom(blockRes *tmrpctypes.ResultBlockResults) (ethtypes.Bloom, error) { for _, event := range blockRes.EndBlockEvents { - if event.Type != evmtypes.EventTypeBlockBloom { + if event.Type != evmtypes.NewEventTypeBlockBloom { continue } - for _, attr := range event.Attributes { + val := rpctypes.UnmarshalMessageToString(attr.Value) + rawVal := []byte(val) + // Fix bloom bytes too big + rawVal = bytes.ReplaceAll(rawVal, []byte{239, 191, 189}, []byte{128}) if bytes.Equal(attr.Key, bAttributeKeyEthereumBloom) { - return ethtypes.BytesToBloom(attr.Value), nil + return ethtypes.BytesToBloom(rawVal), nil } } } diff --git a/rpc/backend/chain_info.go b/rpc/backend/chain_info.go index 732724bb50..ca2813e15f 100644 --- a/rpc/backend/chain_info.go +++ b/rpc/backend/chain_info.go @@ -18,7 +18,6 @@ package backend import ( "fmt" "math/big" - "strconv" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common/hexutil" @@ -82,17 +81,7 @@ func (b *Backend) BaseFee(blockRes *tmrpctypes.ResultBlockResults) (*big.Int, er // we can't tell if it's london HF not enabled or the state is pruned, // in either case, we'll fallback to parsing from begin blocker event, // faster to iterate reversely - for i := len(blockRes.BeginBlockEvents) - 1; i >= 0; i-- { - evt := blockRes.BeginBlockEvents[i] - if evt.Type == feemarkettypes.EventTypeFeeMarket && len(evt.Attributes) > 0 { - baseFee, err := strconv.ParseInt(string(evt.Attributes[0].Value), 10, 64) - if err == nil { - return big.NewInt(baseFee), nil - } - break - } - } - return nil, err + return rpctypes.BaseFeeFromEvents(blockRes.BeginBlockEvents), nil } if res.BaseFee == nil { diff --git a/rpc/types/utils.go b/rpc/types/utils.go index fcafeec019..e5c0540a17 100644 --- a/rpc/types/utils.go +++ b/rpc/types/utils.go @@ -18,6 +18,7 @@ package types import ( "bytes" "context" + "encoding/json" "fmt" "math/big" "strings" @@ -227,20 +228,30 @@ func NewRPCTransaction( return result, nil } +// UnmarshalMessageToString unmarshal message to string +func UnmarshalMessageToString(bz []byte) string { + var msg interface{} + err := json.Unmarshal(bz, &msg) + if err != nil { + return "" + } + return msg.(string) +} + // BaseFeeFromEvents parses the feemarket basefee from cosmos events func BaseFeeFromEvents(events []abci.Event) *big.Int { for _, event := range events { - if event.Type != feemarkettypes.EventTypeFeeMarket { + if event.Type != feemarkettypes.NewEventTypeFeeMarket { continue } for _, attr := range event.Attributes { if bytes.Equal(attr.Key, []byte(feemarkettypes.AttributeKeyBaseFee)) { - result, success := new(big.Int).SetString(string(attr.Value), 10) + val := UnmarshalMessageToString(attr.Value) + result, success := new(big.Int).SetString(val, 10) if success { return result } - return nil } } diff --git a/x/evm/types/events.go b/x/evm/types/events.go index 909ac2973f..8f9a01a4df 100644 --- a/x/evm/types/events.go +++ b/x/evm/types/events.go @@ -17,9 +17,11 @@ package types // Evm module events const ( - EventTypeEthereumTx = TypeMsgEthereumTx - EventTypeBlockBloom = "block_bloom" - EventTypeTxLog = "tx_log" + EventTypeEthereumTx = TypeMsgEthereumTx + EventTypeBlockBloom = "block_bloom" + NewEventTypeBlockBloom = "ethermint.evm.v1.EventBlockBloom" + EventTypeTxLog = "tx_log" + NewEventTypeTxLog = "ethermint.evm.v1.EventTxLog" AttributeKeyContractAddress = "contract" AttributeKeyRecipient = "recipient" diff --git a/x/feemarket/types/events.go b/x/feemarket/types/events.go index dc82e92089..1d47474662 100644 --- a/x/feemarket/types/events.go +++ b/x/feemarket/types/events.go @@ -17,7 +17,7 @@ package types // feemarket module events const ( - EventTypeFeeMarket = "fee_market" - - AttributeKeyBaseFee = "base_fee" + EventTypeFeeMarket = "fee_market" + NewEventTypeFeeMarket = "ethermint.feemarket.v1.EventFeeMarket" + AttributeKeyBaseFee = "base_fee" ) From 314bb288f385b79f6fff6badff79cd790b74a27e Mon Sep 17 00:00:00 2001 From: mmsqe Date: Tue, 10 Jan 2023 09:22:08 +0800 Subject: [PATCH 11/13] partial revert typed ethereumTx --- x/evm/keeper/msg_server.go | 50 ++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index ed1fadaecb..0e1b7eb6d5 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -89,52 +89,56 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t } }() - eventEthereumTx := &types.EventEthereumTx{ - Amount: tx.Value().String(), + attrs := []sdk.Attribute{ + sdk.NewAttribute(sdk.AttributeKeyAmount, tx.Value().String()), // add event for ethereum transaction hash format - EthHash: response.Hash, + sdk.NewAttribute(types.AttributeKeyEthereumTxHash, response.Hash), // add event for index of valid ethereum tx - Index: strconv.FormatUint(txIndex, 10), + sdk.NewAttribute(types.AttributeKeyTxIndex, strconv.FormatUint(txIndex, 10)), // add event for eth tx gas used, we can't get it from cosmos tx result when it contains multiple eth tx msgs. - GasUsed: strconv.FormatUint(response.GasUsed, 10), + sdk.NewAttribute(types.AttributeKeyTxGasUsed, strconv.FormatUint(response.GasUsed, 10)), } if len(ctx.TxBytes()) > 0 { // add event for tendermint transaction hash format hash := tmbytes.HexBytes(tmtypes.Tx(ctx.TxBytes()).Hash()) - eventEthereumTx.Hash = hash.String() + attrs = append(attrs, sdk.NewAttribute(types.AttributeKeyTxHash, hash.String())) } if to := tx.To(); to != nil { - eventEthereumTx.Recipient = to.Hex() + attrs = append(attrs, sdk.NewAttribute(types.AttributeKeyRecipient, to.Hex())) } if response.Failed() { - eventEthereumTx.EthTxFailed = response.VmError + attrs = append(attrs, sdk.NewAttribute(types.AttributeKeyEthereumTxFailed, response.VmError)) } - eventTxLogs := &types.EventTxLog{TxLogs: make([]string, len(response.Logs))} + txLogAttrs := make([]sdk.Attribute, len(response.Logs)) for i, log := range response.Logs { value, err := json.Marshal(log) if err != nil { return nil, errorsmod.Wrap(err, "failed to encode log") } - eventTxLogs.TxLogs[i] = string(value) + txLogAttrs[i] = sdk.NewAttribute(types.AttributeKeyTxLog, string(value)) } - err = ctx.EventManager().EmitTypedEvents( - eventEthereumTx, - eventTxLogs, - &types.EventMessage{ - Module: types.AttributeValueCategory, - Sender: sender, - TxType: fmt.Sprintf("%d", tx.Type()), - }, - ) - - if err != nil { - k.Logger(ctx).Error(err.Error()) - } + // emit events + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeEthereumTx, + attrs..., + ), + sdk.NewEvent( + types.EventTypeTxLog, + txLogAttrs..., + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender), + sdk.NewAttribute(types.AttributeKeyTxType, fmt.Sprintf("%d", tx.Type())), + ), + }) return response, nil } From 7849a352cc4f26aa974c0bcdcaf7ab428829a42d Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 11 Jan 2023 23:14:25 +0800 Subject: [PATCH 12/13] Revert "partial revert typed ethereumTx" This reverts commit 314bb288f385b79f6fff6badff79cd790b74a27e. --- x/evm/keeper/msg_server.go | 50 ++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index 0e1b7eb6d5..ed1fadaecb 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -89,56 +89,52 @@ func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*t } }() - attrs := []sdk.Attribute{ - sdk.NewAttribute(sdk.AttributeKeyAmount, tx.Value().String()), + eventEthereumTx := &types.EventEthereumTx{ + Amount: tx.Value().String(), // add event for ethereum transaction hash format - sdk.NewAttribute(types.AttributeKeyEthereumTxHash, response.Hash), + EthHash: response.Hash, // add event for index of valid ethereum tx - sdk.NewAttribute(types.AttributeKeyTxIndex, strconv.FormatUint(txIndex, 10)), + Index: strconv.FormatUint(txIndex, 10), // add event for eth tx gas used, we can't get it from cosmos tx result when it contains multiple eth tx msgs. - sdk.NewAttribute(types.AttributeKeyTxGasUsed, strconv.FormatUint(response.GasUsed, 10)), + GasUsed: strconv.FormatUint(response.GasUsed, 10), } if len(ctx.TxBytes()) > 0 { // add event for tendermint transaction hash format hash := tmbytes.HexBytes(tmtypes.Tx(ctx.TxBytes()).Hash()) - attrs = append(attrs, sdk.NewAttribute(types.AttributeKeyTxHash, hash.String())) + eventEthereumTx.Hash = hash.String() } if to := tx.To(); to != nil { - attrs = append(attrs, sdk.NewAttribute(types.AttributeKeyRecipient, to.Hex())) + eventEthereumTx.Recipient = to.Hex() } if response.Failed() { - attrs = append(attrs, sdk.NewAttribute(types.AttributeKeyEthereumTxFailed, response.VmError)) + eventEthereumTx.EthTxFailed = response.VmError } - txLogAttrs := make([]sdk.Attribute, len(response.Logs)) + eventTxLogs := &types.EventTxLog{TxLogs: make([]string, len(response.Logs))} for i, log := range response.Logs { value, err := json.Marshal(log) if err != nil { return nil, errorsmod.Wrap(err, "failed to encode log") } - txLogAttrs[i] = sdk.NewAttribute(types.AttributeKeyTxLog, string(value)) + eventTxLogs.TxLogs[i] = string(value) } - // emit events - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.EventTypeEthereumTx, - attrs..., - ), - sdk.NewEvent( - types.EventTypeTxLog, - txLogAttrs..., - ), - sdk.NewEvent( - sdk.EventTypeMessage, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, sender), - sdk.NewAttribute(types.AttributeKeyTxType, fmt.Sprintf("%d", tx.Type())), - ), - }) + err = ctx.EventManager().EmitTypedEvents( + eventEthereumTx, + eventTxLogs, + &types.EventMessage{ + Module: types.AttributeValueCategory, + Sender: sender, + TxType: fmt.Sprintf("%d", tx.Type()), + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } return response, nil } From d7f5cd0a3b3feb498834236551e0d41a308e9784 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 11 Jan 2023 23:14:33 +0800 Subject: [PATCH 13/13] Revert "support typed event for bloom & txLog" This reverts commit 287d3aec30a951a7cece40a0c310858997850a3d. --- rpc/backend/blocks.go | 9 +++------ rpc/backend/chain_info.go | 13 ++++++++++++- rpc/types/utils.go | 17 +++-------------- x/evm/types/events.go | 8 +++----- x/feemarket/types/events.go | 6 +++--- 5 files changed, 24 insertions(+), 29 deletions(-) diff --git a/rpc/backend/blocks.go b/rpc/backend/blocks.go index a0eaa25c30..c4f09d7009 100644 --- a/rpc/backend/blocks.go +++ b/rpc/backend/blocks.go @@ -347,16 +347,13 @@ func (b *Backend) HeaderByHash(blockHash common.Hash) (*ethtypes.Header, error) // BlockBloom query block bloom filter from block results func (b *Backend) BlockBloom(blockRes *tmrpctypes.ResultBlockResults) (ethtypes.Bloom, error) { for _, event := range blockRes.EndBlockEvents { - if event.Type != evmtypes.NewEventTypeBlockBloom { + if event.Type != evmtypes.EventTypeBlockBloom { continue } + for _, attr := range event.Attributes { - val := rpctypes.UnmarshalMessageToString(attr.Value) - rawVal := []byte(val) - // Fix bloom bytes too big - rawVal = bytes.ReplaceAll(rawVal, []byte{239, 191, 189}, []byte{128}) if bytes.Equal(attr.Key, bAttributeKeyEthereumBloom) { - return ethtypes.BytesToBloom(rawVal), nil + return ethtypes.BytesToBloom(attr.Value), nil } } } diff --git a/rpc/backend/chain_info.go b/rpc/backend/chain_info.go index ca2813e15f..732724bb50 100644 --- a/rpc/backend/chain_info.go +++ b/rpc/backend/chain_info.go @@ -18,6 +18,7 @@ package backend import ( "fmt" "math/big" + "strconv" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common/hexutil" @@ -81,7 +82,17 @@ func (b *Backend) BaseFee(blockRes *tmrpctypes.ResultBlockResults) (*big.Int, er // we can't tell if it's london HF not enabled or the state is pruned, // in either case, we'll fallback to parsing from begin blocker event, // faster to iterate reversely - return rpctypes.BaseFeeFromEvents(blockRes.BeginBlockEvents), nil + for i := len(blockRes.BeginBlockEvents) - 1; i >= 0; i-- { + evt := blockRes.BeginBlockEvents[i] + if evt.Type == feemarkettypes.EventTypeFeeMarket && len(evt.Attributes) > 0 { + baseFee, err := strconv.ParseInt(string(evt.Attributes[0].Value), 10, 64) + if err == nil { + return big.NewInt(baseFee), nil + } + break + } + } + return nil, err } if res.BaseFee == nil { diff --git a/rpc/types/utils.go b/rpc/types/utils.go index e5c0540a17..fcafeec019 100644 --- a/rpc/types/utils.go +++ b/rpc/types/utils.go @@ -18,7 +18,6 @@ package types import ( "bytes" "context" - "encoding/json" "fmt" "math/big" "strings" @@ -228,30 +227,20 @@ func NewRPCTransaction( return result, nil } -// UnmarshalMessageToString unmarshal message to string -func UnmarshalMessageToString(bz []byte) string { - var msg interface{} - err := json.Unmarshal(bz, &msg) - if err != nil { - return "" - } - return msg.(string) -} - // BaseFeeFromEvents parses the feemarket basefee from cosmos events func BaseFeeFromEvents(events []abci.Event) *big.Int { for _, event := range events { - if event.Type != feemarkettypes.NewEventTypeFeeMarket { + if event.Type != feemarkettypes.EventTypeFeeMarket { continue } for _, attr := range event.Attributes { if bytes.Equal(attr.Key, []byte(feemarkettypes.AttributeKeyBaseFee)) { - val := UnmarshalMessageToString(attr.Value) - result, success := new(big.Int).SetString(val, 10) + result, success := new(big.Int).SetString(string(attr.Value), 10) if success { return result } + return nil } } diff --git a/x/evm/types/events.go b/x/evm/types/events.go index 8f9a01a4df..909ac2973f 100644 --- a/x/evm/types/events.go +++ b/x/evm/types/events.go @@ -17,11 +17,9 @@ package types // Evm module events const ( - EventTypeEthereumTx = TypeMsgEthereumTx - EventTypeBlockBloom = "block_bloom" - NewEventTypeBlockBloom = "ethermint.evm.v1.EventBlockBloom" - EventTypeTxLog = "tx_log" - NewEventTypeTxLog = "ethermint.evm.v1.EventTxLog" + EventTypeEthereumTx = TypeMsgEthereumTx + EventTypeBlockBloom = "block_bloom" + EventTypeTxLog = "tx_log" AttributeKeyContractAddress = "contract" AttributeKeyRecipient = "recipient" diff --git a/x/feemarket/types/events.go b/x/feemarket/types/events.go index 1d47474662..dc82e92089 100644 --- a/x/feemarket/types/events.go +++ b/x/feemarket/types/events.go @@ -17,7 +17,7 @@ package types // feemarket module events const ( - EventTypeFeeMarket = "fee_market" - NewEventTypeFeeMarket = "ethermint.feemarket.v1.EventFeeMarket" - AttributeKeyBaseFee = "base_fee" + EventTypeFeeMarket = "fee_market" + + AttributeKeyBaseFee = "base_fee" )