From e3cca152ff5eef3e2c3f197b10b4af73bd39e015 Mon Sep 17 00:00:00 2001 From: Unique Divine <51418232+Unique-Divine@users.noreply.github.com> Date: Mon, 7 Oct 2024 04:36:13 -0500 Subject: [PATCH] refactor(evm)!: Refactor out dead code from the evm.Params (#2065) * refactor(evm)!: Refactor out dead code from the evm.Params * fix(evm-genesis_test) * fix tests --- CHANGELOG.md | 2 + app/evmante/evmante_gas_consume.go | 10 +- app/evmante/evmante_mempool_fees.go | 2 +- app/evmante/evmante_sigverify.go | 3 +- app/evmante/evmante_validate_basic.go | 4 +- eth/eip712/eip712_test.go | 2 +- eth/rpc/backend/call_tx.go | 9 +- eth/rpc/backend/node_info.go | 7 +- eth/rpc/rpcapi/eth_api_test.go | 3 +- proto/eth/evm/v1/evm.proto | 11 +- x/evm/evm.pb.go | 245 ++++++++------------------ x/evm/genesis.go | 2 +- x/evm/genesis_test.go | 71 ++------ x/evm/keeper/gas_fees_test.go | 2 +- x/evm/keeper/grpc_query_test.go | 10 +- x/evm/keeper/keeper.go | 8 +- x/evm/keeper/msg_server.go | 4 +- x/evm/keeper/statedb.go | 7 +- x/evm/keeper/statedb_test.go | 8 +- x/evm/msg_test.go | 4 +- x/evm/params.go | 42 +---- 21 files changed, 137 insertions(+), 319 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99cb2ae94..d8e6c6fc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -127,6 +127,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#2054](https://github.com/NibiruChain/nibiru/pull/2054) - feat(evm-precompile): Precompile for one-way EVM calls to invoke/execute Wasm contracts. - [#2060](https://github.com/NibiruChain/nibiru/pull/2060) - fix(evm-precompiles): add assertNumArgs validation - [#2056](https://github.com/NibiruChain/nibiru/pull/2056) - feat(evm): add oracle precompile +- [#2065](https://github.com/NibiruChain/nibiru/pull/2065) - refactor(evm)!: Refactor out dead code from the evm.Params + #### Dapp modules: perp, spot, oracle, etc diff --git a/app/evmante/evmante_gas_consume.go b/app/evmante/evmante_gas_consume.go index 3a704a766..cd58a17d0 100644 --- a/app/evmante/evmante_gas_consume.go +++ b/app/evmante/evmante_gas_consume.go @@ -64,9 +64,6 @@ func (anteDec AnteDecEthGasConsume) AnteHandle( return next(newCtx, tx, simulate) } - evmParams := anteDec.evmKeeper.GetParams(ctx) - evmDenom := evmParams.GetEvmDenom() - var events sdk.Events // Use the lowest priority of all the messages as the final one. @@ -100,7 +97,12 @@ func (anteDec AnteDecEthGasConsume) AnteHandle( gasWanted += txData.GetGas() } - fees, err := keeper.VerifyFee(txData, evmDenom, baseFeeMicronibiPerGas, ctx.IsCheckTx()) + fees, err := keeper.VerifyFee( + txData, + evm.EVMBankDenom, + baseFeeMicronibiPerGas, + ctx.IsCheckTx(), + ) if err != nil { return ctx, errors.Wrapf(err, "failed to verify the fees") } diff --git a/app/evmante/evmante_mempool_fees.go b/app/evmante/evmante_mempool_fees.go index ca683ec59..0f27136ee 100644 --- a/app/evmante/evmante_mempool_fees.go +++ b/app/evmante/evmante_mempool_fees.go @@ -38,7 +38,7 @@ func (d MempoolGasPriceDecorator) AnteHandle( return next(ctx, tx, simulate) } - minGasPrice := ctx.MinGasPrices().AmountOf(d.evmKeeper.GetParams(ctx).EvmDenom) + minGasPrice := ctx.MinGasPrices().AmountOf(evm.EVMBankDenom) baseFeeMicronibi := d.evmKeeper.GetBaseFee(ctx) baseFeeDec := math.LegacyNewDecFromBigInt(baseFeeMicronibi) diff --git a/app/evmante/evmante_sigverify.go b/app/evmante/evmante_sigverify.go index 3735d9e8f..aff0481eb 100644 --- a/app/evmante/evmante_sigverify.go +++ b/app/evmante/evmante_sigverify.go @@ -34,7 +34,6 @@ func (esvd EthSigVerificationDecorator) AnteHandle( ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler, ) (newCtx sdk.Context, err error) { chainID := esvd.evmKeeper.EthChainID(ctx) - evmParams := esvd.evmKeeper.GetParams(ctx) ethCfg := evm.EthereumConfig(chainID) blockNum := big.NewInt(ctx.BlockHeight()) signer := gethcore.MakeSigner(ethCfg, blockNum) @@ -48,7 +47,7 @@ func (esvd EthSigVerificationDecorator) AnteHandle( ) } - allowUnprotectedTxs := evmParams.GetAllowUnprotectedTxs() + allowUnprotectedTxs := false ethTx := msgEthTx.AsTransaction() if !allowUnprotectedTxs && !ethTx.Protected() { return ctx, errors.Wrapf( diff --git a/app/evmante/evmante_validate_basic.go b/app/evmante/evmante_validate_basic.go index 5666a7bc8..8db5a96b9 100644 --- a/app/evmante/evmante_validate_basic.go +++ b/app/evmante/evmante_validate_basic.go @@ -89,9 +89,7 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu txFee := sdk.Coins{} txGasLimit := uint64(0) - evmParams := vbd.evmKeeper.GetParams(ctx) baseFee := vbd.evmKeeper.GetBaseFee(ctx) - evmDenom := evmParams.GetEvmDenom() for _, msg := range protoTx.GetMsgs() { msgEthTx, ok := msg.(*evm.MsgEthereumTx) @@ -126,7 +124,7 @@ func (vbd EthValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu txFee = txFee.Add( sdk.Coin{ - Denom: evmDenom, + Denom: evm.EVMBankDenom, Amount: sdkmath.NewIntFromBigInt(txData.Fee()), }, ) diff --git a/eth/eip712/eip712_test.go b/eth/eip712/eip712_test.go index 1ce492583..ab1538c34 100644 --- a/eth/eip712/eip712_test.go +++ b/eth/eip712/eip712_test.go @@ -80,7 +80,7 @@ func TestEIP712TestSuite(t *testing.T) { func (suite *EIP712TestSuite) SetupTest() { suite.config = encoding.MakeConfig(app.ModuleBasics) suite.clientCtx = client.Context{}.WithTxConfig(suite.config.TxConfig) - suite.denom = evm.DefaultEVMDenom + suite.denom = evm.EVMBankDenom sdk.GetConfig().SetBech32PrefixForAccount(appconst.AccountAddressPrefix, "") eip712.SetEncodingConfig(suite.config) diff --git a/eth/rpc/backend/call_tx.go b/eth/rpc/backend/call_tx.go index 4b64997e2..3e4de8037 100644 --- a/eth/rpc/backend/call_tx.go +++ b/eth/rpc/backend/call_tx.go @@ -49,14 +49,7 @@ func (b *Backend) SendRawTransaction(data hexutil.Bytes) (common.Hash, error) { return common.Hash{}, err } - // Query params to use the EVM denomination - res, err := b.queryClient.QueryClient.Params(b.ctx, &evm.QueryParamsRequest{}) - if err != nil { - b.logger.Error("failed to query evm params", "error", err.Error()) - return common.Hash{}, err - } - - cosmosTx, err := ethereumTx.BuildTx(b.clientCtx.TxConfig.NewTxBuilder(), res.Params.EvmDenom) + cosmosTx, err := ethereumTx.BuildTx(b.clientCtx.TxConfig.NewTxBuilder(), evm.EVMBankDenom) if err != nil { b.logger.Error("failed to build cosmos tx", "error", err.Error()) return common.Hash{}, err diff --git a/eth/rpc/backend/node_info.go b/eth/rpc/backend/node_info.go index 66d56d76c..402578dd5 100644 --- a/eth/rpc/backend/node_info.go +++ b/eth/rpc/backend/node_info.go @@ -86,13 +86,8 @@ func (b *Backend) RPCBlockRangeCap() int32 { // RPCMinGasPrice returns the minimum gas price for a transaction obtained from // the node config. If set value is 0, it will default to 20. func (b *Backend) RPCMinGasPrice() int64 { - evmParams, err := b.queryClient.Params(b.ctx, &evm.QueryParamsRequest{}) - if err != nil { - return eth.DefaultGasPrice - } - minGasPrice := b.cfg.GetMinGasPrices() - amt := minGasPrice.AmountOf(evmParams.Params.EvmDenom).TruncateInt64() + amt := minGasPrice.AmountOf(evm.EVMBankDenom).TruncateInt64() if amt == 0 { return eth.DefaultGasPrice } diff --git a/eth/rpc/rpcapi/eth_api_test.go b/eth/rpc/rpcapi/eth_api_test.go index 7ba8552f1..1d9eb3eb6 100644 --- a/eth/rpc/rpcapi/eth_api_test.go +++ b/eth/rpc/rpcapi/eth_api_test.go @@ -278,8 +278,7 @@ func (s *NodeSuite) Test_SimpleTransferTransaction() { pendingEthTxEventIndex := int32(-1) for _, event := range events { if event.Type == evm.PendingEthereumTxEvent { - pendingEthTxEventHash, pendingEthTxEventIndex, err = - evm.GetEthHashAndIndexFromPendingEthereumTxEvent(event) + pendingEthTxEventHash, pendingEthTxEventIndex, err = evm.GetEthHashAndIndexFromPendingEthereumTxEvent(event) s.Require().NoError(err) } if event.Type == evm.TypeUrlEventEthereumTx { diff --git a/proto/eth/evm/v1/evm.proto b/proto/eth/evm/v1/evm.proto index 7be577a1c..6720afff9 100644 --- a/proto/eth/evm/v1/evm.proto +++ b/proto/eth/evm/v1/evm.proto @@ -29,9 +29,8 @@ message FunToken { // Params defines the EVM module parameters message Params { option (gogoproto.equal) = true; - // evm_denom represents the token denomination used to run the EVM state - // transitions. - string evm_denom = 1 [ (gogoproto.moretags) = "yaml:\"evm_denom\"" ]; + // DEPRECATED: evm_denom + reserved 1; // DEPRECATED: enable_create reserved 2; // DEPRECATED: enable_call @@ -44,9 +43,9 @@ message Params { ]; // DEPRECATED: chain_config reserved 5; - // allow_unprotected_txs defines if replay-protected (i.e non EIP155 - // signed) transactions can be executed on the state machine. - bool allow_unprotected_txs = 6; + // DEPRECATED: allow_unprotected_txs + reserved 6; + // DEPRECATED: active_precompiles // All precompiles present according to the VM are active. reserved 7; diff --git a/x/evm/evm.pb.go b/x/evm/evm.pb.go index 13c357492..fa9c6988e 100644 --- a/x/evm/evm.pb.go +++ b/x/evm/evm.pb.go @@ -89,14 +89,8 @@ func (m *FunToken) GetIsMadeFromCoin() bool { // Params defines the EVM module parameters type Params struct { - // evm_denom represents the token denomination used to run the EVM state - // transitions. - EvmDenom string `protobuf:"bytes,1,opt,name=evm_denom,json=evmDenom,proto3" json:"evm_denom,omitempty" yaml:"evm_denom"` // extra_eips defines the additional EIPs for the vm.Config ExtraEIPs []int64 `protobuf:"varint,4,rep,packed,name=extra_eips,json=extraEips,proto3" json:"extra_eips,omitempty" yaml:"extra_eips"` - // allow_unprotected_txs defines if replay-protected (i.e non EIP155 - // signed) transactions can be executed on the state machine. - AllowUnprotectedTxs bool `protobuf:"varint,6,opt,name=allow_unprotected_txs,json=allowUnprotectedTxs,proto3" json:"allow_unprotected_txs,omitempty"` // evm_channels is the list of channel identifiers from EVM compatible chains EVMChannels []string `protobuf:"bytes,8,rep,name=evm_channels,json=evmChannels,proto3" json:"evm_channels,omitempty"` // Fee deducted and burned when calling "CreateFunToken" in units of @@ -137,13 +131,6 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetEvmDenom() string { - if m != nil { - return m.EvmDenom - } - return "" -} - func (m *Params) GetExtraEIPs() []int64 { if m != nil { return m.ExtraEIPs @@ -151,13 +138,6 @@ func (m *Params) GetExtraEIPs() []int64 { return nil } -func (m *Params) GetAllowUnprotectedTxs() bool { - if m != nil { - return m.AllowUnprotectedTxs - } - return false -} - func (m *Params) GetEVMChannels() []string { if m != nil { return m.EVMChannels @@ -683,80 +663,77 @@ func init() { func init() { proto.RegisterFile("eth/evm/v1/evm.proto", fileDescriptor_98abbdadb327b7d0) } var fileDescriptor_98abbdadb327b7d0 = []byte{ - // 1153 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x55, 0x3f, 0x6f, 0xdb, 0x46, - 0x14, 0xb7, 0x2c, 0xca, 0xa6, 0x4e, 0x72, 0xa4, 0x9c, 0x9d, 0x94, 0x4d, 0x10, 0xd3, 0x60, 0x81, + // 1113 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x55, 0x31, 0x6f, 0xdb, 0x46, + 0x14, 0xb6, 0x2c, 0x4a, 0xa2, 0x4e, 0x72, 0xc4, 0x5c, 0xdc, 0x94, 0x4d, 0x10, 0xd3, 0x60, 0x81, 0xc2, 0x05, 0x02, 0xa9, 0x71, 0x90, 0x0e, 0xe9, 0x52, 0xcb, 0xb1, 0x51, 0xab, 0x76, 0x1a, 0x5c, - 0x94, 0x0e, 0x5d, 0x88,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 0x69, 0xa3, - 0x2a, 0x07, 0xa9, 0xd7, 0xd5, 0x24, 0xca, 0xc4, 0x0f, 0x90, 0xcd, 0x61, 0x0a, 0x5c, 0x42, 0xa8, - 0xd7, 0x62, 0x93, 0x6b, 0x8c, 0x3f, 0x46, 0x76, 0x44, 0x85, 0x9f, 0x0b, 0x08, 0xcd, 0x0e, 0xc8, - 0x7a, 0x44, 0xc5, 0x1b, 0x01, 0xe1, 0x73, 0xeb, 0xa7, 0xb7, 0xee, 0x8a, 0x47, 0x51, 0x63, 0x3f, - 0x08, 0x40, 0x88, 0x41, 0x3e, 0x49, 0xe0, 0x3f, 0xb4, 0xb5, 0x87, 0x9a, 0x42, 0x32, 0x4e, 0x23, - 0xf0, 0xc7, 0x70, 0x5e, 0x2a, 0xcc, 0xe8, 0xa5, 0xe4, 0xbf, 0x81, 0x73, 0x41, 0x96, 0x41, 0x59, - 0xe2, 0x00, 0x35, 0x07, 0x9c, 0x06, 0xc0, 0x0f, 0x58, 0x76, 0x16, 0x47, 0xf8, 0x29, 0xda, 0x60, - 0x59, 0x72, 0xee, 0x4b, 0x36, 0xf1, 0x03, 0x9a, 0x24, 0xba, 0x92, 0x6d, 0x52, 0x29, 0xc7, 0x80, - 0x4d, 0x0e, 0x68, 0x92, 0x90, 0x65, 0xe0, 0xfd, 0x5d, 0x45, 0x0d, 0x9d, 0xa5, 0x4c, 0xa2, 0xa4, - 0xae, 0x93, 0x96, 0x7d, 0x96, 0x48, 0x5d, 0x40, 0xc6, 0x29, 0xb0, 0x5c, 0x96, 0x2f, 0xe2, 0x15, - 0x54, 0x11, 0x1c, 0x60, 0x06, 0x81, 0xde, 0x82, 0x45, 0x4a, 0x84, 0x9f, 0xa1, 0x8d, 0x30, 0x16, - 0x74, 0x98, 0x80, 0x2f, 0x24, 0x0d, 0xc6, 0x66, 0x86, 0xbd, 0xf6, 0xbc, 0x70, 0x9b, 0xa5, 0xe3, - 0xb5, 0xe2, 0xc9, 0x0d, 0x84, 0xbf,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b, 0x9a, + 0x8a, 0x79, 0xa1, 0x08, 0xfc, 0x39, 0xba, 0x1b, 0x09, 0x2f, 0xa1, 0x01, 0x78, 0x17, 0x9c, 0x25, + 0x9e, 0xcf, 0xa2, 0xd4, 0xae, 0xee, 0x56, 0xf6, 0x4c, 0x72, 0x27, 0x12, 0x67, 0x34, 0x80, 0x63, + 0xce, 0x92, 0x43, 0x16, 0xa5, 0xee, 0x5f, 0x15, 0x54, 0x7f, 0x45, 0x39, 0x4d, 0x04, 0x3e, 0x40, + 0x08, 0x66, 0x92, 0x53, 0x0f, 0xa2, 0x89, 0xb0, 0x8d, 0xdd, 0xea, 0x5e, 0xb5, 0xef, 0x5e, 0xe6, + 0x4e, 0xf3, 0x48, 0xb1, 0x47, 0x27, 0xaf, 0xc4, 0x55, 0xee, 0xdc, 0x9d, 0xd3, 0x24, 0x7e, 0xee, + 0xae, 0x0e, 0xba, 0xa4, 0xa9, 0xc1, 0x51, 0x34, 0x11, 0x78, 0x1f, 0xb5, 0x61, 0x9a, 0x78, 0xfe, + 0x88, 0xa6, 0x29, 0xc4, 0xc2, 0x36, 0x77, 0xab, 0x7b, 0xcd, 0x7e, 0xe7, 0x32, 0x77, 0x5a, 0x47, + 0xdf, 0x9f, 0x1d, 0x96, 0x34, 0x69, 0xc1, 0x34, 0x59, 0x02, 0x7c, 0x86, 0xee, 0xf9, 0x1c, 0xa8, + 0x04, 0xef, 0x22, 0x4b, 0xa5, 0x52, 0xcd, 0xbb, 0x00, 0xb0, 0x9b, 0x5a, 0xab, 0x47, 0xa5, 0x56, + 0x1f, 0xf9, 0x4c, 0x24, 0x4c, 0x88, 0x60, 0xdc, 0x8d, 0x58, 0x2f, 0xa1, 0x72, 0xd4, 0x3d, 0x49, + 0x25, 0xb9, 0x5b, 0x54, 0x1e, 0x97, 0x85, 0xc7, 0x00, 0xcf, 0x8d, 0x3f, 0xdf, 0x3a, 0x95, 0x81, + 0x61, 0x56, 0xac, 0xcd, 0x81, 0x61, 0x6e,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, 0xd8, 0x38, 0x4a, 0x22, 0xa9, + 0xbd, 0x5a, 0x23, 0x05, 0x50, 0xf7, 0x83, 0x54, 0xcf, 0x49, 0x20, 0x61, 0x7c, 0x6e, 0xb7, 0x56, + 0xf7, 0x2b, 0x12, 0x67, 0x9a, 0x27, 0x37, 0x10, 0xee, 0x23, 0x5c, 0x96, 0x71, 0x90, 0x19, 0x4f, + 0x3d, 0xfd, 0x0f, 0xd0, 0xd6, 0xb5, 0xfa, 0x3d, 0x2c, 0xb2, 0x44, 0x27, 0x5f, 0x50, 0x49, 0xc9, + 0xbf, 0x18, 0xfc, 0x1d, 0xda, 0x2a, 0x64, 0xf5, 0x7c, 0xad, 0xba, 0xbd, 0xa5, 0xfd, 0x6b, 0xdf, + 0xf2, 0xef, 0xf5, 0x6a, 0x8b, 0x4b, 0xc9, 0x35, 0x86, 0xdc, 0x40, 0x03, 0xc3, 0x34, 0xac, 0x5a, + 0xf1, 0x5f, 0x3a, 0x30, 0x4c, 0x64, 0xb5, 0xae, 0x95, 0x29, 0x1f, 0x8e, 0xdc, 0x5b, 0xe2, 0xb5, + 0x5b, 0xf7, 0xbf, 0x7e, 0x77, 0xb9, 0x53, 0x79, 0x7f, 0xb9, 0x53, 0xf9, 0xe3, 0x72, 0xa7, 0xf2, + 0xf3, 0x87, 0x9d, 0x8d, 0xf7, 0x1f, 0x76, 0x36, 0x7e, 0xfb, 0xb0, 0xb3, 0xf1, 0xc3, 0x67, 0xff, + 0xfb, 0x41, 0x9c, 0xa9, 0x2f, 0xf1, 0xb0, 0xae, 0x3f, 0xb4, 0x4f, 0xff, 0x09, 0x00, 0x00, 0xff, + 0xff, 0xab, 0xac, 0xcf, 0xa2, 0xa2, 0x07, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -778,9 +755,6 @@ func (this *Params) Equal(that interface{}) bool { } else if this == nil { return false } - if this.EvmDenom != that1.EvmDenom { - return false - } if len(this.ExtraEIPs) != len(that1.ExtraEIPs) { return false } @@ -789,9 +763,6 @@ func (this *Params) Equal(that interface{}) bool { return false } } - if this.AllowUnprotectedTxs != that1.AllowUnprotectedTxs { - return false - } if len(this.EVMChannels) != len(that1.EVMChannels) { return false } @@ -894,16 +865,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x42 } } - if m.AllowUnprotectedTxs { - i-- - if m.AllowUnprotectedTxs { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x30 - } if len(m.ExtraEIPs) > 0 { dAtA2 := make([]byte, len(m.ExtraEIPs)*10) var j1 int @@ -923,13 +884,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - if len(m.EvmDenom) > 0 { - i -= len(m.EvmDenom) - copy(dAtA[i:], m.EvmDenom) - i = encodeVarintEvm(dAtA, i, uint64(len(m.EvmDenom))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } @@ -1384,10 +1338,6 @@ func (m *Params) Size() (n int) { } var l int _ = l - l = len(m.EvmDenom) - if l > 0 { - n += 1 + l + sovEvm(uint64(l)) - } if len(m.ExtraEIPs) > 0 { l = 0 for _, e := range m.ExtraEIPs { @@ -1395,9 +1345,6 @@ func (m *Params) Size() (n int) { } n += 1 + sovEvm(uint64(l)) + l } - if m.AllowUnprotectedTxs { - n += 2 - } if len(m.EVMChannels) > 0 { for _, s := range m.EVMChannels { l = len(s) @@ -1761,38 +1708,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EvmDenom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvm - } - 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 ErrInvalidLengthEvm - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvm - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EvmDenom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 4: if wireType == 0 { var v int64 @@ -1869,26 +1784,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { } else { return fmt.Errorf("proto: wrong wireType = %d for field ExtraEIPs", wireType) } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AllowUnprotectedTxs", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.AllowUnprotectedTxs = bool(v != 0) case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field EVMChannels", wireType) diff --git a/x/evm/genesis.go b/x/evm/genesis.go index d5e786356..15a9d72de 100644 --- a/x/evm/genesis.go +++ b/x/evm/genesis.go @@ -30,7 +30,7 @@ func (gs GenesisState) Validate() error { seenAccounts := make(map[string]bool) for _, acc := range gs.Accounts { if seenAccounts[acc.Address] { - return fmt.Errorf("duplicated genesis account %s", acc.Address) + return fmt.Errorf("duplicate genesis account %s", acc.Address) } if err := acc.Validate(); err != nil { return fmt.Errorf("invalid genesis account %s: %w", acc.Address, err) diff --git a/x/evm/genesis_test.go b/x/evm/genesis_test.go index 4c007fd7b..46c30f2d2 100644 --- a/x/evm/genesis_test.go +++ b/x/evm/genesis_test.go @@ -1,6 +1,7 @@ package evm_test import ( + "encoding/json" "testing" gethcommon "github.com/ethereum/go-ethereum/common" @@ -87,12 +88,11 @@ func (s *GenesisSuite) TestValidateGenesis() { testCases := []struct { name string genState *evm.GenesisState - expPass bool + wantErr string }{ { name: "default", genState: evm.DefaultGenesisState(), - expPass: true, }, { name: "valid genesis", @@ -109,12 +109,10 @@ func (s *GenesisSuite) TestValidateGenesis() { }, Params: evm.DefaultParams(), }, - expPass: true, }, { name: "empty genesis", genState: &evm.GenesisState{}, - expPass: false, }, { name: "copied genesis", @@ -122,25 +120,23 @@ func (s *GenesisSuite) TestValidateGenesis() { Accounts: evm.DefaultGenesisState().Accounts, Params: evm.DefaultGenesisState().Params, }, - expPass: true, }, { - name: "invalid genesis", + name: "happy genesis with account", genState: &evm.GenesisState{ Accounts: []evm.GenesisAccount{ { - Address: gethcommon.Address{}.String(), + Address: gethcommon.Address{}.String(), // zero address }, }, }, - expPass: false, }, { name: "invalid genesis account", genState: &evm.GenesisState{ Accounts: []evm.GenesisAccount{ { - Address: "123456", + Address: "123456", // not a valid ethereum hex address Code: s.code, Storage: evm.Storage{ @@ -150,34 +146,11 @@ func (s *GenesisSuite) TestValidateGenesis() { }, Params: evm.DefaultParams(), }, - expPass: false, + wantErr: "not a valid ethereum hex address", }, { - name: "duplicated genesis account", - genState: &evm.GenesisState{ - Accounts: []evm.GenesisAccount{ - { - Address: s.address, - - Code: s.code, - Storage: evm.Storage{ - evm.NewStateFromEthHashes(s.hash, s.hash), - }, - }, - { - Address: s.address, - - Code: s.code, - Storage: evm.Storage{ - evm.NewStateFromEthHashes(s.hash, s.hash), - }, - }, - }, - }, - expPass: false, - }, - { - name: "duplicated tx log", + name: "duplicate account", + wantErr: "duplicate genesis account", genState: &evm.GenesisState{ Accounts: []evm.GenesisAccount{ { @@ -188,14 +161,6 @@ func (s *GenesisSuite) TestValidateGenesis() { {Key: s.hash.String()}, }, }, - }, - }, - expPass: false, - }, - { - name: "invalid tx log", - genState: &evm.GenesisState{ - Accounts: []evm.GenesisAccount{ { Address: s.address, @@ -206,23 +171,25 @@ func (s *GenesisSuite) TestValidateGenesis() { }, }, }, - expPass: false, }, { - name: "invalid params", + name: "happy: empty params", genState: &evm.GenesisState{ Params: evm.Params{}, }, - expPass: false, }, } for _, tc := range testCases { - err := tc.genState.Validate() - if tc.expPass { - s.Require().NoError(err, tc.name) - continue - } - s.Require().Error(err, tc.name) + s.Run(tc.name, func() { + err := tc.genState.Validate() + jsonBz, _ := json.Marshal(tc.genState) + jsonStr := string(jsonBz) + if tc.wantErr != "" { + s.Require().ErrorContains(err, tc.wantErr, jsonStr) + return + } + s.Require().NoError(err, jsonStr) + }) } } diff --git a/x/evm/keeper/gas_fees_test.go b/x/evm/keeper/gas_fees_test.go index 1840d9e1b..efefff44c 100644 --- a/x/evm/keeper/gas_fees_test.go +++ b/x/evm/keeper/gas_fees_test.go @@ -96,7 +96,7 @@ func (s *Suite) TestVerifyFee() { } }, } { - feeDenom := evm.DefaultEVMDenom + feeDenom := evm.EVMBankDenom isCheckTx := true tc := getTestCase() s.Run(tc.name, func() { diff --git a/x/evm/keeper/grpc_query_test.go b/x/evm/keeper/grpc_query_test.go index 6fc4da754..193711d36 100644 --- a/x/evm/keeper/grpc_query_test.go +++ b/x/evm/keeper/grpc_query_test.go @@ -76,7 +76,7 @@ func (s *Suite) TestQueryEvmAccount() { setup: func(deps *evmtest.TestDeps) { // fund account with 420 tokens ethAddr := deps.Sender.EthAddr - coins := sdk.Coins{sdk.NewInt64Coin(evm.DefaultEVMDenom, 420)} + coins := sdk.Coins{sdk.NewInt64Coin(evm.EVMBankDenom, 420)} err := testapp.FundAccount(deps.App.BankKeeper, deps.Ctx, ethAddr.Bytes(), coins) s.Require().NoError(err) }, @@ -101,7 +101,7 @@ func (s *Suite) TestQueryEvmAccount() { setup: func(deps *evmtest.TestDeps) { // fund account with 420 tokens ethAddr := deps.Sender.EthAddr - coins := sdk.Coins{sdk.NewInt64Coin(evm.DefaultEVMDenom, 420)} + coins := sdk.Coins{sdk.NewInt64Coin(evm.EVMBankDenom, 420)} err := testapp.FundAccount(deps.App.BankKeeper, deps.Ctx, ethAddr.Bytes(), coins) s.Require().NoError(err) }, @@ -457,7 +457,7 @@ func (s *Suite) TestQueryParams() { s.Require().True(want.Equal(got), "want %s, got %s", want, got) // Empty params to test the setter - want.EvmDenom = "wei" + want.EVMChannels = []string{"channel-420"} deps.EvmKeeper.SetParams(deps.Ctx, want) gotResp, err = deps.EvmKeeper.Params(sdk.WrapSDKContext(deps.Ctx), nil) s.Require().NoError(err) @@ -560,7 +560,7 @@ func (s *Suite) TestQueryBalance() { ethAddr := deps.Sender.EthAddr // fund account with 420 tokens - coins := sdk.Coins{sdk.NewInt64Coin(evm.DefaultEVMDenom, 420)} + coins := sdk.Coins{sdk.NewInt64Coin(evm.EVMBankDenom, 420)} err := chain.BankKeeper.MintCoins(deps.Ctx, evm.ModuleName, coins) s.NoError(err) err = chain.BankKeeper.SendCoinsFromModuleToAccount( @@ -677,7 +677,7 @@ func (s *Suite) TestEstimateGasForEvmCallType() { // fund the account chain := deps.App ethAddr := deps.Sender.EthAddr - coins := sdk.Coins{sdk.NewInt64Coin(evm.DefaultEVMDenom, 1000)} + coins := sdk.Coins{sdk.NewInt64Coin(evm.EVMBankDenom, 1000)} err := chain.BankKeeper.MintCoins(deps.Ctx, evm.ModuleName, coins) s.NoError(err) err = chain.BankKeeper.SendCoinsFromModuleToAccount( diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 4728adec5..d86b1a36d 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -89,13 +89,7 @@ func NewKeeper( // tokens for EVM execution in EVM denom units. func (k *Keeper) GetEvmGasBalance(ctx sdk.Context, addr gethcommon.Address) (balance *big.Int) { nibiruAddr := sdk.AccAddress(addr.Bytes()) - evmParams := k.GetParams(ctx) - evmDenom := evmParams.GetEvmDenom() - // if node is pruned, params is empty. Return invalid value - if evmDenom == "" { - return big.NewInt(-1) - } - return k.bankKeeper.GetBalance(ctx, nibiruAddr, evmDenom).Amount.BigInt() + return k.bankKeeper.GetBalance(ctx, nibiruAddr, evm.EVMBankDenom).Amount.BigInt() } func (k Keeper) EthChainID(ctx sdk.Context) *big.Int { diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index 36f2d2d9b..3eaf8bd44 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -111,7 +111,7 @@ func (k *Keeper) ApplyEvmTx( if msg.Gas() > evmResp.GasUsed { refundGas = msg.Gas() - evmResp.GasUsed } - if err = k.RefundGas(ctx, msg, refundGas, evmConfig.Params.EvmDenom); err != nil { + if err = k.RefundGas(ctx, msg, refundGas, evm.EVMBankDenom); err != nil { return nil, errors.Wrapf(err, "failed to refund leftover gas to sender %s", msg.From()) } @@ -503,7 +503,7 @@ func (k Keeper) deductCreateFunTokenFee(ctx sdk.Context, msg *evm.MsgCreateFunTo func (k Keeper) FeeForCreateFunToken(ctx sdk.Context) sdk.Coins { evmParams := k.GetParams(ctx) - return sdk.NewCoins(sdk.NewCoin(evmParams.EvmDenom, evmParams.CreateFuntokenFee)) + return sdk.NewCoins(sdk.NewCoin(evm.EVMBankDenom, evmParams.CreateFuntokenFee)) } // ConvertCoinToEvm Sends a coin with a valid "FunToken" mapping to the diff --git a/x/evm/keeper/statedb.go b/x/evm/keeper/statedb.go index 9c5716d24..6eb46f990 100644 --- a/x/evm/keeper/statedb.go +++ b/x/evm/keeper/statedb.go @@ -70,14 +70,13 @@ func (k *Keeper) SetAccBalance( ctx sdk.Context, addr gethcommon.Address, amountEvmDenom *big.Int, ) error { nativeAddr := sdk.AccAddress(addr.Bytes()) - params := k.GetParams(ctx) - balance := k.bankKeeper.GetBalance(ctx, nativeAddr, params.EvmDenom).Amount.BigInt() + balance := k.bankKeeper.GetBalance(ctx, nativeAddr, evm.EVMBankDenom).Amount.BigInt() delta := new(big.Int).Sub(amountEvmDenom, balance) switch delta.Sign() { case 1: // mint - coins := sdk.NewCoins(sdk.NewCoin(params.EvmDenom, sdkmath.NewIntFromBigInt(delta))) + coins := sdk.NewCoins(sdk.NewCoin(evm.EVMBankDenom, sdkmath.NewIntFromBigInt(delta))) if err := k.bankKeeper.MintCoins(ctx, evm.ModuleName, coins); err != nil { return err } @@ -86,7 +85,7 @@ func (k *Keeper) SetAccBalance( } case -1: // burn - coins := sdk.NewCoins(sdk.NewCoin(params.EvmDenom, sdkmath.NewIntFromBigInt(new(big.Int).Neg(delta)))) + coins := sdk.NewCoins(sdk.NewCoin(evm.EVMBankDenom, sdkmath.NewIntFromBigInt(new(big.Int).Neg(delta)))) if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, nativeAddr, evm.ModuleName, coins); err != nil { return err } diff --git a/x/evm/keeper/statedb_test.go b/x/evm/keeper/statedb_test.go index e80d0f501..a918039a8 100644 --- a/x/evm/keeper/statedb_test.go +++ b/x/evm/keeper/statedb_test.go @@ -29,7 +29,7 @@ func (s *Suite) TestStateDBBalance() { deps.App.BankKeeper, deps.Ctx, deps.Sender.NibiruAddr, - sdk.NewCoins(sdk.NewInt64Coin(evm.DefaultEVMDenom, 42)), + sdk.NewCoins(sdk.NewInt64Coin(evm.EVMBankDenom, 42)), ) s.NoError(err) s.Equal( @@ -38,7 +38,7 @@ func (s *Suite) TestStateDBBalance() { ) s.Equal( "42", - deps.App.BankKeeper.GetBalance(deps.Ctx, deps.Sender.NibiruAddr, evm.DefaultEVMDenom).Amount.String(), + deps.App.BankKeeper.GetBalance(deps.Ctx, deps.Sender.NibiruAddr, evm.EVMBankDenom).Amount.String(), ) } @@ -70,13 +70,13 @@ func (s *Suite) TestStateDBBalance() { deps.App.BankKeeper, deps.Ctx, deps.Sender.NibiruAddr, - sdk.NewCoins(sdk.NewInt64Coin(evm.DefaultEVMDenom, 8)), + sdk.NewCoins(sdk.NewInt64Coin(evm.EVMBankDenom, 8)), ) s.NoError(err) err = deps.App.BankKeeper.SendCoins( deps.Ctx, deps.Sender.NibiruAddr, toNibiAddr, - sdk.NewCoins(sdk.NewInt64Coin(evm.DefaultEVMDenom, 3)), + sdk.NewCoins(sdk.NewInt64Coin(evm.EVMBankDenom, 3)), ) s.NoError(err) diff --git a/x/evm/msg_test.go b/x/evm/msg_test.go index 0dd7d8fb9..e9b8533ba 100644 --- a/x/evm/msg_test.go +++ b/x/evm/msg_test.go @@ -112,7 +112,7 @@ func (s *MsgsSuite) TestMsgEthereumTx_BuildTx() { tc.msg.Data = nil } - tx, err := tc.msg.BuildTx(s.clientCtx.TxConfig.NewTxBuilder(), evm.DefaultEVMDenom) + tx, err := tc.msg.BuildTx(s.clientCtx.TxConfig.NewTxBuilder(), evm.EVMBankDenom) if tc.expError { s.Require().Error(err) } else { @@ -121,7 +121,7 @@ func (s *MsgsSuite) TestMsgEthereumTx_BuildTx() { s.Require().Empty(tx.GetMemo()) s.Require().Empty(tx.GetTimeoutHeight()) s.Require().Equal(uint64(100000), tx.GetGas()) - s.Require().Equal(sdk.NewCoins(sdk.NewCoin(evm.DefaultEVMDenom, sdkmath.NewInt(100000))), tx.GetFee()) + s.Require().Equal(sdk.NewCoins(sdk.NewCoin(evm.EVMBankDenom, sdkmath.NewInt(100000))), tx.GetFee()) } } } diff --git a/x/evm/params.go b/x/evm/params.go index 60545b2aa..66d31e035 100644 --- a/x/evm/params.go +++ b/x/evm/params.go @@ -6,7 +6,6 @@ import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v7/modules/core/24-host" @@ -17,19 +16,21 @@ import ( ) const ( - // DefaultEVMDenom defines the default EVM denomination - DefaultEVMDenom = appconst.BondDenom + // EVMBankDenom specifies the bank denomination for the asset used to run EVM + // state transitions as the analog to "ether". 1 ether in solidity means 1 + // NIBI on Nibru EVM, implying that the EVMBankDenom is "unibi", the coin + // base of the NIBI token. + EVMBankDenom = appconst.BondDenom ) // DefaultParams returns default evm parameters // ExtraEIPs is empty to prevent overriding the latest hard fork instruction set func DefaultParams() Params { return Params{ - EvmDenom: DefaultEVMDenom, - ExtraEIPs: []int64{}, - AllowUnprotectedTxs: false, - EVMChannels: []string{}, - CreateFuntokenFee: math.NewIntWithDecimal(10_000, 6), // 10_000 NIBI + ExtraEIPs: []int64{}, + // EVMChannels: Unused but intended for use with future IBC functionality + EVMChannels: []string{}, + CreateFuntokenFee: math.NewIntWithDecimal(10_000, 6), // 10_000 NIBI } } @@ -53,18 +54,10 @@ func validateChannels(i interface{}) error { // Validate performs basic validation on evm parameters. func (p Params) Validate() error { - if err := validateEVMDenom(p.EvmDenom); err != nil { - return err - } - if err := validateEIPs(p.ExtraEIPs); err != nil { return err } - if err := validateBool(p.AllowUnprotectedTxs); err != nil { - return err - } - return validateChannels(p.EVMChannels) } @@ -83,23 +76,6 @@ func (p Params) IsEVMChannel(channel string) bool { return slices.Contains(p.EVMChannels, channel) } -func validateEVMDenom(i interface{}) error { - denom, ok := i.(string) - if !ok { - return fmt.Errorf("invalid parameter EVM denom type: %T", i) - } - - return sdk.ValidateDenom(denom) -} - -func validateBool(i interface{}) error { - _, ok := i.(bool) - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - return nil -} - func validateEIPs(i interface{}) error { eips, ok := i.([]int64) if !ok {