diff --git a/Makefile b/Makefile index 5bd994ea3..f7b5f2867 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,6 @@ export GO111MODULE = on # evmd is a separate module under ./evmd EVMD_DIR := evmd -EVMD_MAIN_PKG := ./cmd/evmd ############################################################################### ### Build & Install evmd ### @@ -91,7 +90,7 @@ endif build: go.sum $(BUILDDIR)/ @echo "🏗️ Building evmd to $(BUILDDIR)/$(EXAMPLE_BINARY) ..." @cd $(EVMD_DIR) && CGO_ENABLED="1" \ - go build $(BUILD_FLAGS) -o $(BUILDDIR)/$(EXAMPLE_BINARY) $(EVMD_MAIN_PKG) + go build $(BUILD_FLAGS) -o $(BUILDDIR)/$(EXAMPLE_BINARY) # Cross-compile for Linux AMD64 build-linux: @@ -101,7 +100,7 @@ build-linux: install: go.sum @echo "🚚 Installing evmd to $(BINDIR) ..." @cd $(EVMD_DIR) && CGO_ENABLED="1" \ - go install $(BUILD_FLAGS) $(EVMD_MAIN_PKG) + go install $(BUILD_FLAGS) $(BUILDDIR)/: mkdir -p $(BUILDDIR)/ diff --git a/ante/cosmos/authz_test.go b/ante/cosmos/authz_test.go index aee72f910..9208b3615 100644 --- a/ante/cosmos/authz_test.go +++ b/ante/cosmos/authz_test.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/evm/ante/cosmos" "github.com/cosmos/evm/encoding" "github.com/cosmos/evm/testutil" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" evmtypes "github.com/cosmos/evm/x/vm/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -21,12 +21,10 @@ import ( ) func TestAuthzLimiterDecorator(t *testing.T) { - evmConfigurator := evmtypes.NewEVMConfigurator(). - WithEVMCoinInfo(constants.ExampleChainCoinInfo[constants.ExampleChainID]) - err := evmConfigurator.Configure() + err := evmtypes.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) require.NoError(t, err) - encodingCfg := encoding.MakeConfig(constants.ExampleChainID.EVMChainID) + encodingCfg := encoding.MakeConfig(testconfig.ExampleChainID.EVMChainID) txCfg := encodingCfg.TxConfig testPrivKeys, testAddresses, err := testutil.GeneratePrivKeyAddressPairs(5) require.NoError(t, err) diff --git a/ante/evm/fee_checker_test.go b/ante/evm/fee_checker_test.go index a5cbc3734..d864d8cb0 100644 --- a/ante/evm/fee_checker_test.go +++ b/ante/evm/fee_checker_test.go @@ -10,9 +10,9 @@ import ( "github.com/cosmos/evm/ante/evm" anteinterfaces "github.com/cosmos/evm/ante/interfaces" + evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/encoding" - "github.com/cosmos/evm/testutil/config" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/types" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -57,10 +57,10 @@ func TestSDKTxFeeChecker(t *testing.T) { // with extension option // without extension option // london hardfork enableness - chainID := uint64(config.EighteenDecimalsChainID) - encodingConfig := encoding.MakeConfig(chainID) - err := config.EvmAppOptions(chainID) + + err := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, false).Apply() require.NoError(t, err) + encodingConfig := encoding.MakeConfig(evmtypes.DefaultEvmChainID) evmDenom := evmtypes.GetEVMCoinDenom() minGasPrices := sdk.NewDecCoins(sdk.NewDecCoin(evmDenom, math.NewInt(10))) @@ -110,7 +110,7 @@ func TestSDKTxFeeChecker(t *testing.T) { func() sdk.FeeTx { txBuilder := encodingConfig.TxConfig.NewTxBuilder() txBuilder.SetGasLimit(1) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(10)))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(10)))) return txBuilder.GetTx() }, false, @@ -155,7 +155,7 @@ func TestSDKTxFeeChecker(t *testing.T) { func() sdk.FeeTx { txBuilder := encodingConfig.TxConfig.NewTxBuilder() txBuilder.SetGasLimit(1) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(10)))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(10)))) return txBuilder.GetTx() }, true, @@ -172,7 +172,7 @@ func TestSDKTxFeeChecker(t *testing.T) { func() sdk.FeeTx { txBuilder := encodingConfig.TxConfig.NewTxBuilder() txBuilder.SetGasLimit(1) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(10).Mul(evmtypes.DefaultPriorityReduction).Add(math.NewInt(10))))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(10).Mul(evmtypes.DefaultPriorityReduction).Add(math.NewInt(10))))) return txBuilder.GetTx() }, true, @@ -189,7 +189,7 @@ func TestSDKTxFeeChecker(t *testing.T) { func() sdk.FeeTx { txBuilder := encodingConfig.TxConfig.NewTxBuilder().(authtx.ExtensionOptionsTxBuilder) txBuilder.SetGasLimit(1) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(10).Mul(evmtypes.DefaultPriorityReduction)))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(10).Mul(evmtypes.DefaultPriorityReduction)))) option, err := codectypes.NewAnyWithValue(&types.ExtensionOptionDynamicFeeTx{}) require.NoError(t, err) @@ -210,7 +210,7 @@ func TestSDKTxFeeChecker(t *testing.T) { func() sdk.FeeTx { txBuilder := encodingConfig.TxConfig.NewTxBuilder().(authtx.ExtensionOptionsTxBuilder) txBuilder.SetGasLimit(1) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(10).Mul(evmtypes.DefaultPriorityReduction).Add(math.NewInt(10))))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(10).Mul(evmtypes.DefaultPriorityReduction).Add(math.NewInt(10))))) option, err := codectypes.NewAnyWithValue(&types.ExtensionOptionDynamicFeeTx{ MaxPriorityPrice: math.LegacyNewDec(5).MulInt(evmtypes.DefaultPriorityReduction), @@ -233,7 +233,7 @@ func TestSDKTxFeeChecker(t *testing.T) { func() sdk.FeeTx { txBuilder := encodingConfig.TxConfig.NewTxBuilder().(authtx.ExtensionOptionsTxBuilder) txBuilder.SetGasLimit(1) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(10).Mul(evmtypes.DefaultPriorityReduction).Add(math.NewInt(10))))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(10).Mul(evmtypes.DefaultPriorityReduction).Add(math.NewInt(10))))) // set negative priority fee option, err := codectypes.NewAnyWithValue(&types.ExtensionOptionDynamicFeeTx{ diff --git a/ante/evm/mono_decorator_test.go b/ante/evm/mono_decorator_test.go index 295415734..e09f9d017 100644 --- a/ante/evm/mono_decorator_test.go +++ b/ante/evm/mono_decorator_test.go @@ -17,9 +17,9 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/cosmos/evm/ante/evm" + evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/encoding" - "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" "github.com/cosmos/evm/x/vm/statedb" @@ -144,9 +144,9 @@ func toMsgSlice(msgs []*evmsdktypes.MsgEthereumTx) []sdk.Msg { } func TestMonoDecorator(t *testing.T) { - chainID := uint64(config.EighteenDecimalsChainID) - require.NoError(t, config.EvmAppOptions(chainID)) - cfg := encoding.MakeConfig(chainID) + evmConfig := evmconfig.NewDefaultEvmConfig(evmsdktypes.DefaultEvmChainID, false) + require.NoError(t, evmConfig.Apply()) + cfg := encoding.MakeConfig(evmsdktypes.DefaultEvmChainID) testCases := []struct { name string diff --git a/api/cosmos/evm/vm/v1/evm.pulsar.go b/api/cosmos/evm/vm/v1/evm.pulsar.go index 7980ded78..43a9e65fa 100644 --- a/api/cosmos/evm/vm/v1/evm.pulsar.go +++ b/api/cosmos/evm/vm/v1/evm.pulsar.go @@ -160,6 +160,7 @@ var ( fd_Params_access_control protoreflect.FieldDescriptor fd_Params_active_static_precompiles protoreflect.FieldDescriptor fd_Params_history_serve_window protoreflect.FieldDescriptor + fd_Params_evm_chain_id protoreflect.FieldDescriptor ) func init() { @@ -171,6 +172,7 @@ func init() { fd_Params_access_control = md_Params.Fields().ByName("access_control") fd_Params_active_static_precompiles = md_Params.Fields().ByName("active_static_precompiles") fd_Params_history_serve_window = md_Params.Fields().ByName("history_serve_window") + fd_Params_evm_chain_id = md_Params.Fields().ByName("evm_chain_id") } var _ protoreflect.Message = (*fastReflection_Params)(nil) @@ -274,6 +276,12 @@ func (x *fastReflection_Params) Range(f func(protoreflect.FieldDescriptor, proto return } } + if x.EvmChainId != uint64(0) { + value := protoreflect.ValueOfUint64(x.EvmChainId) + if !f(fd_Params_evm_chain_id, value) { + return + } + } } // Has reports whether a field is populated. @@ -301,6 +309,8 @@ func (x *fastReflection_Params) Has(fd protoreflect.FieldDescriptor) bool { return len(x.ActiveStaticPrecompiles) != 0 case "cosmos.evm.vm.v1.Params.history_serve_window": return x.HistoryServeWindow != uint64(0) + case "cosmos.evm.vm.v1.Params.evm_chain_id": + return x.EvmChainId != uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.evm.vm.v1.Params")) @@ -329,6 +339,8 @@ func (x *fastReflection_Params) Clear(fd protoreflect.FieldDescriptor) { x.ActiveStaticPrecompiles = nil case "cosmos.evm.vm.v1.Params.history_serve_window": x.HistoryServeWindow = uint64(0) + case "cosmos.evm.vm.v1.Params.evm_chain_id": + x.EvmChainId = uint64(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.evm.vm.v1.Params")) @@ -372,6 +384,9 @@ func (x *fastReflection_Params) Get(descriptor protoreflect.FieldDescriptor) pro case "cosmos.evm.vm.v1.Params.history_serve_window": value := x.HistoryServeWindow return protoreflect.ValueOfUint64(value) + case "cosmos.evm.vm.v1.Params.evm_chain_id": + value := x.EvmChainId + return protoreflect.ValueOfUint64(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.evm.vm.v1.Params")) @@ -410,6 +425,8 @@ func (x *fastReflection_Params) Set(fd protoreflect.FieldDescriptor, value proto x.ActiveStaticPrecompiles = *clv.list case "cosmos.evm.vm.v1.Params.history_serve_window": x.HistoryServeWindow = value.Uint() + case "cosmos.evm.vm.v1.Params.evm_chain_id": + x.EvmChainId = value.Uint() default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.evm.vm.v1.Params")) @@ -457,6 +474,8 @@ func (x *fastReflection_Params) Mutable(fd protoreflect.FieldDescriptor) protore panic(fmt.Errorf("field evm_denom of message cosmos.evm.vm.v1.Params is not mutable")) case "cosmos.evm.vm.v1.Params.history_serve_window": panic(fmt.Errorf("field history_serve_window of message cosmos.evm.vm.v1.Params is not mutable")) + case "cosmos.evm.vm.v1.Params.evm_chain_id": + panic(fmt.Errorf("field evm_chain_id of message cosmos.evm.vm.v1.Params is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.evm.vm.v1.Params")) @@ -486,6 +505,8 @@ func (x *fastReflection_Params) NewField(fd protoreflect.FieldDescriptor) protor return protoreflect.ValueOfList(&_Params_9_list{list: &list}) case "cosmos.evm.vm.v1.Params.history_serve_window": return protoreflect.ValueOfUint64(uint64(0)) + case "cosmos.evm.vm.v1.Params.evm_chain_id": + return protoreflect.ValueOfUint64(uint64(0)) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.evm.vm.v1.Params")) @@ -585,6 +606,9 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { if x.HistoryServeWindow != 0 { n += 1 + runtime.Sov(uint64(x.HistoryServeWindow)) } + if x.EvmChainId != 0 { + n += 1 + runtime.Sov(uint64(x.EvmChainId)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -614,6 +638,11 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if x.EvmChainId != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.EvmChainId)) + i-- + dAtA[i] = 0x58 + } if x.HistoryServeWindow != 0 { i = runtime.EncodeVarint(dAtA, i, uint64(x.HistoryServeWindow)) i-- @@ -955,6 +984,25 @@ func (x *fastReflection_Params) ProtoMethods() *protoiface.Methods { break } } + case 11: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field EvmChainId", wireType) + } + x.EvmChainId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.EvmChainId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -2051,8 +2099,6 @@ var ( fd_ChainConfig_gray_glacier_block protoreflect.FieldDescriptor fd_ChainConfig_merge_netsplit_block protoreflect.FieldDescriptor fd_ChainConfig_chain_id protoreflect.FieldDescriptor - fd_ChainConfig_denom protoreflect.FieldDescriptor - fd_ChainConfig_decimals protoreflect.FieldDescriptor fd_ChainConfig_shanghai_time protoreflect.FieldDescriptor fd_ChainConfig_cancun_time protoreflect.FieldDescriptor fd_ChainConfig_prague_time protoreflect.FieldDescriptor @@ -2080,8 +2126,6 @@ func init() { fd_ChainConfig_gray_glacier_block = md_ChainConfig.Fields().ByName("gray_glacier_block") fd_ChainConfig_merge_netsplit_block = md_ChainConfig.Fields().ByName("merge_netsplit_block") fd_ChainConfig_chain_id = md_ChainConfig.Fields().ByName("chain_id") - fd_ChainConfig_denom = md_ChainConfig.Fields().ByName("denom") - fd_ChainConfig_decimals = md_ChainConfig.Fields().ByName("decimals") fd_ChainConfig_shanghai_time = md_ChainConfig.Fields().ByName("shanghai_time") fd_ChainConfig_cancun_time = md_ChainConfig.Fields().ByName("cancun_time") fd_ChainConfig_prague_time = md_ChainConfig.Fields().ByName("prague_time") @@ -2256,18 +2300,6 @@ func (x *fastReflection_ChainConfig) Range(f func(protoreflect.FieldDescriptor, return } } - if x.Denom != "" { - value := protoreflect.ValueOfString(x.Denom) - if !f(fd_ChainConfig_denom, value) { - return - } - } - if x.Decimals != uint64(0) { - value := protoreflect.ValueOfUint64(x.Decimals) - if !f(fd_ChainConfig_decimals, value) { - return - } - } if x.ShanghaiTime != "" { value := protoreflect.ValueOfString(x.ShanghaiTime) if !f(fd_ChainConfig_shanghai_time, value) { @@ -2347,10 +2379,6 @@ func (x *fastReflection_ChainConfig) Has(fd protoreflect.FieldDescriptor) bool { return x.MergeNetsplitBlock != "" case "cosmos.evm.vm.v1.ChainConfig.chain_id": return x.ChainId != uint64(0) - case "cosmos.evm.vm.v1.ChainConfig.denom": - return x.Denom != "" - case "cosmos.evm.vm.v1.ChainConfig.decimals": - return x.Decimals != uint64(0) case "cosmos.evm.vm.v1.ChainConfig.shanghai_time": return x.ShanghaiTime != "" case "cosmos.evm.vm.v1.ChainConfig.cancun_time": @@ -2411,10 +2439,6 @@ func (x *fastReflection_ChainConfig) Clear(fd protoreflect.FieldDescriptor) { x.MergeNetsplitBlock = "" case "cosmos.evm.vm.v1.ChainConfig.chain_id": x.ChainId = uint64(0) - case "cosmos.evm.vm.v1.ChainConfig.denom": - x.Denom = "" - case "cosmos.evm.vm.v1.ChainConfig.decimals": - x.Decimals = uint64(0) case "cosmos.evm.vm.v1.ChainConfig.shanghai_time": x.ShanghaiTime = "" case "cosmos.evm.vm.v1.ChainConfig.cancun_time": @@ -2492,12 +2516,6 @@ func (x *fastReflection_ChainConfig) Get(descriptor protoreflect.FieldDescriptor case "cosmos.evm.vm.v1.ChainConfig.chain_id": value := x.ChainId return protoreflect.ValueOfUint64(value) - case "cosmos.evm.vm.v1.ChainConfig.denom": - value := x.Denom - return protoreflect.ValueOfString(value) - case "cosmos.evm.vm.v1.ChainConfig.decimals": - value := x.Decimals - return protoreflect.ValueOfUint64(value) case "cosmos.evm.vm.v1.ChainConfig.shanghai_time": value := x.ShanghaiTime return protoreflect.ValueOfString(value) @@ -2567,10 +2585,6 @@ func (x *fastReflection_ChainConfig) Set(fd protoreflect.FieldDescriptor, value x.MergeNetsplitBlock = value.Interface().(string) case "cosmos.evm.vm.v1.ChainConfig.chain_id": x.ChainId = value.Uint() - case "cosmos.evm.vm.v1.ChainConfig.denom": - x.Denom = value.Interface().(string) - case "cosmos.evm.vm.v1.ChainConfig.decimals": - x.Decimals = value.Uint() case "cosmos.evm.vm.v1.ChainConfig.shanghai_time": x.ShanghaiTime = value.Interface().(string) case "cosmos.evm.vm.v1.ChainConfig.cancun_time": @@ -2635,10 +2649,6 @@ func (x *fastReflection_ChainConfig) Mutable(fd protoreflect.FieldDescriptor) pr panic(fmt.Errorf("field merge_netsplit_block of message cosmos.evm.vm.v1.ChainConfig is not mutable")) case "cosmos.evm.vm.v1.ChainConfig.chain_id": panic(fmt.Errorf("field chain_id of message cosmos.evm.vm.v1.ChainConfig is not mutable")) - case "cosmos.evm.vm.v1.ChainConfig.denom": - panic(fmt.Errorf("field denom of message cosmos.evm.vm.v1.ChainConfig is not mutable")) - case "cosmos.evm.vm.v1.ChainConfig.decimals": - panic(fmt.Errorf("field decimals of message cosmos.evm.vm.v1.ChainConfig is not mutable")) case "cosmos.evm.vm.v1.ChainConfig.shanghai_time": panic(fmt.Errorf("field shanghai_time of message cosmos.evm.vm.v1.ChainConfig is not mutable")) case "cosmos.evm.vm.v1.ChainConfig.cancun_time": @@ -2696,10 +2706,6 @@ func (x *fastReflection_ChainConfig) NewField(fd protoreflect.FieldDescriptor) p return protoreflect.ValueOfString("") case "cosmos.evm.vm.v1.ChainConfig.chain_id": return protoreflect.ValueOfUint64(uint64(0)) - case "cosmos.evm.vm.v1.ChainConfig.denom": - return protoreflect.ValueOfString("") - case "cosmos.evm.vm.v1.ChainConfig.decimals": - return protoreflect.ValueOfUint64(uint64(0)) case "cosmos.evm.vm.v1.ChainConfig.shanghai_time": return protoreflect.ValueOfString("") case "cosmos.evm.vm.v1.ChainConfig.cancun_time": @@ -2845,13 +2851,6 @@ func (x *fastReflection_ChainConfig) ProtoMethods() *protoiface.Methods { if x.ChainId != 0 { n += 2 + runtime.Sov(uint64(x.ChainId)) } - l = len(x.Denom) - if l > 0 { - n += 2 + l + runtime.Sov(uint64(l)) - } - if x.Decimals != 0 { - n += 2 + runtime.Sov(uint64(x.Decimals)) - } l = len(x.ShanghaiTime) if l > 0 { n += 2 + l + runtime.Sov(uint64(l)) @@ -2946,22 +2945,6 @@ func (x *fastReflection_ChainConfig) ProtoMethods() *protoiface.Methods { i-- dAtA[i] = 0xda } - if x.Decimals != 0 { - i = runtime.EncodeVarint(dAtA, i, uint64(x.Decimals)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xd0 - } - if len(x.Denom) > 0 { - i -= len(x.Denom) - copy(dAtA[i:], x.Denom) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Denom))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xca - } if x.ChainId != 0 { i = runtime.EncodeVarint(dAtA, i, uint64(x.ChainId)) i-- @@ -3660,57 +3643,6 @@ func (x *fastReflection_ChainConfig) ProtoMethods() *protoiface.Methods { break } } - case 25: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.Denom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 26: - if wireType != 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Decimals", wireType) - } - x.Decimals = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - x.Decimals |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } case 27: if wireType != 2 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ShanghaiTime", wireType) @@ -8835,6 +8767,7 @@ type Params struct { // precompiled contracts that are active ActiveStaticPrecompiles []string `protobuf:"bytes,9,rep,name=active_static_precompiles,json=activeStaticPrecompiles,proto3" json:"active_static_precompiles,omitempty"` HistoryServeWindow uint64 `protobuf:"varint,10,opt,name=history_serve_window,json=historyServeWindow,proto3" json:"history_serve_window,omitempty"` + EvmChainId uint64 `protobuf:"varint,11,opt,name=evm_chain_id,json=evmChainId,proto3" json:"evm_chain_id,omitempty"` } func (x *Params) Reset() { @@ -8899,6 +8832,13 @@ func (x *Params) GetHistoryServeWindow() uint64 { return 0 } +func (x *Params) GetEvmChainId() uint64 { + if x != nil { + return x.EvmChainId + } + return 0 +} + // AccessControl defines the permission policy of the EVM // for creating and calling contracts type AccessControl struct { @@ -9048,10 +8988,6 @@ type ChainConfig struct { MergeNetsplitBlock string `protobuf:"bytes,21,opt,name=merge_netsplit_block,json=mergeNetsplitBlock,proto3" json:"merge_netsplit_block,omitempty"` // chain_id is the id of the chain (EIP-155) ChainId uint64 `protobuf:"varint,24,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - // denom is the denomination used on the EVM - Denom string `protobuf:"bytes,25,opt,name=denom,proto3" json:"denom,omitempty"` - // decimals is the real decimal precision of the denomination used on the EVM - Decimals uint64 `protobuf:"varint,26,opt,name=decimals,proto3" json:"decimals,omitempty"` // shanghai_time: Shanghai switch time (nil = no fork, 0 = already on // shanghai) ShanghaiTime string `protobuf:"bytes,27,opt,name=shanghai_time,json=shanghaiTime,proto3" json:"shanghai_time,omitempty"` @@ -9204,20 +9140,6 @@ func (x *ChainConfig) GetChainId() uint64 { return 0 } -func (x *ChainConfig) GetDenom() string { - if x != nil { - return x.Denom - } - return "" -} - -func (x *ChainConfig) GetDecimals() uint64 { - if x != nil { - return x.Decimals - } - return 0 -} - func (x *ChainConfig) GetShanghaiTime() string { if x != nil { return x.ShanghaiTime @@ -9795,7 +9717,7 @@ var file_cosmos_evm_vm_v1_evm_proto_rawDesc = []byte{ 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x1a, 0x11, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x6d, 0x69, 0x6e, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, - 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb4, 0x03, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, + 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd6, 0x03, 0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x31, 0x0a, 0x09, 0x65, 0x76, 0x6d, 0x5f, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x14, 0xf2, 0xde, 0x1f, 0x10, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x65, 0x76, 0x6d, 0x5f, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x22, 0x52, 0x08, 0x65, 0x76, 0x6d, @@ -9819,137 +9741,136 @@ var file_cosmos_evm_vm_v1_evm_proto_rawDesc = []byte{ 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x30, 0x0a, 0x14, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x65, 0x5f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x52, 0x12, 0x68, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, - 0x72, 0x76, 0x65, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x3a, 0x1b, 0x8a, 0xe7, 0xb0, 0x2a, 0x16, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x6d, 0x2f, 0x78, 0x2f, 0x76, 0x6d, 0x2f, - 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x4a, 0x04, 0x08, 0x03, - 0x10, 0x04, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, 0x22, 0x91, - 0x01, 0x0a, 0x0d, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, - 0x12, 0x41, 0x0a, 0x06, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, - 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, - 0x6c, 0x54, 0x79, 0x70, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x06, 0x63, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x12, 0x3d, 0x0a, 0x04, 0x63, 0x61, 0x6c, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, - 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, - 0x6f, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x04, 0x63, 0x61, - 0x6c, 0x6c, 0x22, 0xdd, 0x01, 0x0a, 0x11, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, - 0x74, 0x72, 0x6f, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x12, 0x63, 0x0a, 0x0b, 0x61, 0x63, 0x63, 0x65, - 0x73, 0x73, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, - 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0x42, 0x24, 0xe2, 0xde, 0x1f, - 0x0a, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0xf2, 0xde, 0x1f, 0x12, 0x79, - 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x79, 0x70, 0x65, - 0x22, 0x52, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x63, 0x0a, - 0x13, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x5f, - 0x6c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x42, 0x33, 0xe2, 0xde, 0x1f, 0x11, - 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x4c, 0x69, 0x73, - 0x74, 0xf2, 0xde, 0x1f, 0x1a, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x61, 0x63, 0x63, 0x65, 0x73, - 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x52, - 0x11, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x4c, 0x69, - 0x73, 0x74, 0x22, 0xa8, 0x10, 0x0a, 0x0b, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x12, 0x5c, 0x0a, 0x0f, 0x68, 0x6f, 0x6d, 0x65, 0x73, 0x74, 0x65, 0x61, 0x64, 0x5f, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x33, 0xda, 0xde, 0x1f, - 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, - 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, 0x1f, 0x16, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, - 0x68, 0x6f, 0x6d, 0x65, 0x73, 0x74, 0x65, 0x61, 0x64, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, - 0x52, 0x0e, 0x68, 0x6f, 0x6d, 0x65, 0x73, 0x74, 0x65, 0x61, 0x64, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x12, 0x68, 0x0a, 0x0e, 0x64, 0x61, 0x6f, 0x5f, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x62, 0x6c, 0x6f, - 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x42, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, - 0x49, 0x6e, 0x74, 0xe2, 0xde, 0x1f, 0x0c, 0x44, 0x41, 0x4f, 0x46, 0x6f, 0x72, 0x6b, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0xf2, 0xde, 0x1f, 0x15, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x64, 0x61, 0x6f, - 0x5f, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0c, 0x64, 0x61, - 0x6f, 0x46, 0x6f, 0x72, 0x6b, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x57, 0x0a, 0x10, 0x64, 0x61, - 0x6f, 0x5f, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x08, 0x42, 0x2d, 0xe2, 0xde, 0x1f, 0x0e, 0x44, 0x41, 0x4f, 0x46, 0x6f, 0x72, - 0x6b, 0x53, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0xf2, 0xde, 0x1f, 0x17, 0x79, 0x61, 0x6d, 0x6c, - 0x3a, 0x22, 0x64, 0x61, 0x6f, 0x5f, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6f, - 0x72, 0x74, 0x22, 0x52, 0x0e, 0x64, 0x61, 0x6f, 0x46, 0x6f, 0x72, 0x6b, 0x53, 0x75, 0x70, 0x70, - 0x6f, 0x72, 0x74, 0x12, 0x62, 0x0a, 0x0c, 0x65, 0x69, 0x70, 0x31, 0x35, 0x30, 0x5f, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x3f, 0xda, 0xde, 0x1f, 0x15, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, - 0x2e, 0x49, 0x6e, 0x74, 0xe2, 0xde, 0x1f, 0x0b, 0x45, 0x49, 0x50, 0x31, 0x35, 0x30, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0xf2, 0xde, 0x1f, 0x13, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x65, 0x69, 0x70, - 0x31, 0x35, 0x30, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0b, 0x65, 0x69, 0x70, 0x31, - 0x35, 0x30, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x62, 0x0a, 0x0c, 0x65, 0x69, 0x70, 0x31, 0x35, - 0x35, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x42, 0x3f, 0xda, + 0x72, 0x76, 0x65, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x12, 0x20, 0x0a, 0x0c, 0x65, 0x76, 0x6d, + 0x5f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x0a, 0x65, 0x76, 0x6d, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x3a, 0x1b, 0x8a, 0xe7, 0xb0, + 0x2a, 0x16, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x6d, 0x2f, 0x78, 0x2f, 0x76, + 0x6d, 0x2f, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x4a, 0x04, + 0x08, 0x03, 0x10, 0x04, 0x4a, 0x04, 0x08, 0x05, 0x10, 0x06, 0x4a, 0x04, 0x08, 0x06, 0x10, 0x07, + 0x22, 0x91, 0x01, 0x0a, 0x0d, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, + 0x6f, 0x6c, 0x12, 0x41, 0x0a, 0x06, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, + 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, + 0x72, 0x6f, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x06, 0x63, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x12, 0x3d, 0x0a, 0x04, 0x63, 0x61, 0x6c, 0x6c, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, + 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, + 0x74, 0x72, 0x6f, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x04, + 0x63, 0x61, 0x6c, 0x6c, 0x22, 0xdd, 0x01, 0x0a, 0x11, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, + 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x12, 0x63, 0x0a, 0x0b, 0x61, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, + 0x1c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, + 0x76, 0x31, 0x2e, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0x42, 0x24, 0xe2, + 0xde, 0x1f, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0xf2, 0xde, 0x1f, + 0x12, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x74, 0x79, + 0x70, 0x65, 0x22, 0x52, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, + 0x63, 0x0a, 0x13, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, + 0x6c, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x42, 0x33, 0xe2, 0xde, + 0x1f, 0x11, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x4c, + 0x69, 0x73, 0x74, 0xf2, 0xde, 0x1f, 0x1a, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x61, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x5f, 0x6c, 0x69, 0x73, 0x74, + 0x22, 0x52, 0x11, 0x61, 0x63, 0x63, 0x65, 0x73, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, + 0x4c, 0x69, 0x73, 0x74, 0x22, 0x82, 0x10, 0x0a, 0x0b, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x12, 0x5c, 0x0a, 0x0f, 0x68, 0x6f, 0x6d, 0x65, 0x73, 0x74, 0x65, 0x61, + 0x64, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x33, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, - 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xe2, 0xde, 0x1f, 0x0b, 0x45, 0x49, 0x50, 0x31, - 0x35, 0x35, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0xf2, 0xde, 0x1f, 0x13, 0x79, 0x61, 0x6d, 0x6c, 0x3a, - 0x22, 0x65, 0x69, 0x70, 0x31, 0x35, 0x35, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0b, - 0x65, 0x69, 0x70, 0x31, 0x35, 0x35, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x62, 0x0a, 0x0c, 0x65, - 0x69, 0x70, 0x31, 0x35, 0x38, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x3f, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, - 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xe2, 0xde, 0x1f, 0x0b, - 0x45, 0x49, 0x50, 0x31, 0x35, 0x38, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0xf2, 0xde, 0x1f, 0x13, 0x79, - 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x65, 0x69, 0x70, 0x31, 0x35, 0x38, 0x5f, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x22, 0x52, 0x0b, 0x65, 0x69, 0x70, 0x31, 0x35, 0x38, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, - 0x5c, 0x0a, 0x0f, 0x62, 0x79, 0x7a, 0x61, 0x6e, 0x74, 0x69, 0x75, 0x6d, 0x5f, 0x62, 0x6c, 0x6f, - 0x63, 0x6b, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x33, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, - 0x49, 0x6e, 0x74, 0xf2, 0xde, 0x1f, 0x16, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x62, 0x79, 0x7a, - 0x61, 0x6e, 0x74, 0x69, 0x75, 0x6d, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0e, 0x62, - 0x79, 0x7a, 0x61, 0x6e, 0x74, 0x69, 0x75, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x6b, 0x0a, - 0x14, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x69, 0x6e, 0x6f, 0x70, 0x6c, 0x65, 0x5f, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x42, 0x38, 0xda, 0xde, 0x1f, + 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, 0x1f, 0x16, 0x79, 0x61, 0x6d, 0x6c, + 0x3a, 0x22, 0x68, 0x6f, 0x6d, 0x65, 0x73, 0x74, 0x65, 0x61, 0x64, 0x5f, 0x62, 0x6c, 0x6f, 0x63, + 0x6b, 0x22, 0x52, 0x0e, 0x68, 0x6f, 0x6d, 0x65, 0x73, 0x74, 0x65, 0x61, 0x64, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x12, 0x68, 0x0a, 0x0e, 0x64, 0x61, 0x6f, 0x5f, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x42, 0xda, 0xde, 0x1f, 0x15, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, + 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xe2, 0xde, 0x1f, 0x0c, 0x44, 0x41, 0x4f, 0x46, 0x6f, 0x72, 0x6b, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0xf2, 0xde, 0x1f, 0x15, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x64, + 0x61, 0x6f, 0x5f, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0c, + 0x64, 0x61, 0x6f, 0x46, 0x6f, 0x72, 0x6b, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x57, 0x0a, 0x10, + 0x64, 0x61, 0x6f, 0x5f, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x73, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x42, 0x2d, 0xe2, 0xde, 0x1f, 0x0e, 0x44, 0x41, 0x4f, 0x46, + 0x6f, 0x72, 0x6b, 0x53, 0x75, 0x70, 0x70, 0x6f, 0x72, 0x74, 0xf2, 0xde, 0x1f, 0x17, 0x79, 0x61, + 0x6d, 0x6c, 0x3a, 0x22, 0x64, 0x61, 0x6f, 0x5f, 0x66, 0x6f, 0x72, 0x6b, 0x5f, 0x73, 0x75, 0x70, + 0x70, 0x6f, 0x72, 0x74, 0x22, 0x52, 0x0e, 0x64, 0x61, 0x6f, 0x46, 0x6f, 0x72, 0x6b, 0x53, 0x75, + 0x70, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x62, 0x0a, 0x0c, 0x65, 0x69, 0x70, 0x31, 0x35, 0x30, 0x5f, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x3f, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, - 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, 0x1f, 0x1b, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, - 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x69, 0x6e, 0x6f, 0x70, 0x6c, 0x65, 0x5f, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x13, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x69, - 0x6e, 0x6f, 0x70, 0x6c, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x5f, 0x0a, 0x10, 0x70, 0x65, - 0x74, 0x65, 0x72, 0x73, 0x62, 0x75, 0x72, 0x67, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x34, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xe2, 0xde, 0x1f, 0x0b, 0x45, 0x49, 0x50, 0x31, 0x35, 0x30, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0xf2, 0xde, 0x1f, 0x13, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x65, + 0x69, 0x70, 0x31, 0x35, 0x30, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0b, 0x65, 0x69, + 0x70, 0x31, 0x35, 0x30, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x62, 0x0a, 0x0c, 0x65, 0x69, 0x70, + 0x31, 0x35, 0x35, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x3f, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, + 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xe2, 0xde, 0x1f, 0x0b, 0x45, 0x49, + 0x50, 0x31, 0x35, 0x35, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0xf2, 0xde, 0x1f, 0x13, 0x79, 0x61, 0x6d, + 0x6c, 0x3a, 0x22, 0x65, 0x69, 0x70, 0x31, 0x35, 0x35, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, + 0x52, 0x0b, 0x65, 0x69, 0x70, 0x31, 0x35, 0x35, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x62, 0x0a, + 0x0c, 0x65, 0x69, 0x70, 0x31, 0x35, 0x38, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x3f, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, + 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xe2, 0xde, + 0x1f, 0x0b, 0x45, 0x49, 0x50, 0x31, 0x35, 0x38, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0xf2, 0xde, 0x1f, + 0x13, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x65, 0x69, 0x70, 0x31, 0x35, 0x38, 0x5f, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0b, 0x65, 0x69, 0x70, 0x31, 0x35, 0x38, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x12, 0x5c, 0x0a, 0x0f, 0x62, 0x79, 0x7a, 0x61, 0x6e, 0x74, 0x69, 0x75, 0x6d, 0x5f, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x33, 0xda, 0xde, 0x1f, 0x15, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, + 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, 0x1f, 0x16, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x62, + 0x79, 0x7a, 0x61, 0x6e, 0x74, 0x69, 0x75, 0x6d, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, + 0x0e, 0x62, 0x79, 0x7a, 0x61, 0x6e, 0x74, 0x69, 0x75, 0x6d, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, + 0x6b, 0x0a, 0x14, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x69, 0x6e, 0x6f, 0x70, 0x6c, + 0x65, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x42, 0x38, 0xda, + 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, + 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, 0x1f, 0x1b, 0x79, 0x61, 0x6d, 0x6c, + 0x3a, 0x22, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x69, 0x6e, 0x6f, 0x70, 0x6c, 0x65, + 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x13, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, + 0x74, 0x69, 0x6e, 0x6f, 0x70, 0x6c, 0x65, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x5f, 0x0a, 0x10, + 0x70, 0x65, 0x74, 0x65, 0x72, 0x73, 0x62, 0x75, 0x72, 0x67, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x42, 0x34, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, + 0x74, 0xf2, 0xde, 0x1f, 0x17, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x70, 0x65, 0x74, 0x65, 0x72, + 0x73, 0x62, 0x75, 0x72, 0x67, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0f, 0x70, 0x65, + 0x74, 0x65, 0x72, 0x73, 0x62, 0x75, 0x72, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x59, 0x0a, + 0x0e, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, + 0x0b, 0x20, 0x01, 0x28, 0x09, 0x42, 0x32, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, + 0xf2, 0xde, 0x1f, 0x15, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, + 0x75, 0x6c, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0d, 0x69, 0x73, 0x74, 0x61, 0x6e, + 0x62, 0x75, 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x64, 0x0a, 0x12, 0x6d, 0x75, 0x69, 0x72, + 0x5f, 0x67, 0x6c, 0x61, 0x63, 0x69, 0x65, 0x72, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x0c, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x36, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, - 0xde, 0x1f, 0x17, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x70, 0x65, 0x74, 0x65, 0x72, 0x73, 0x62, - 0x75, 0x72, 0x67, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0f, 0x70, 0x65, 0x74, 0x65, - 0x72, 0x73, 0x62, 0x75, 0x72, 0x67, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x59, 0x0a, 0x0e, 0x69, - 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x0b, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x32, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, - 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, - 0x1f, 0x15, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, 0x6c, - 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0d, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x62, 0x75, - 0x6c, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x64, 0x0a, 0x12, 0x6d, 0x75, 0x69, 0x72, 0x5f, 0x67, - 0x6c, 0x61, 0x63, 0x69, 0x65, 0x72, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x0c, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x36, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, - 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, 0x1f, - 0x19, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6d, 0x75, 0x69, 0x72, 0x5f, 0x67, 0x6c, 0x61, 0x63, - 0x69, 0x65, 0x72, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x10, 0x6d, 0x75, 0x69, 0x72, - 0x47, 0x6c, 0x61, 0x63, 0x69, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x53, 0x0a, 0x0c, - 0x62, 0x65, 0x72, 0x6c, 0x69, 0x6e, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x0d, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x30, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, - 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, 0x1f, - 0x13, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x62, 0x65, 0x72, 0x6c, 0x69, 0x6e, 0x5f, 0x62, 0x6c, - 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0b, 0x62, 0x65, 0x72, 0x6c, 0x69, 0x6e, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x12, 0x53, 0x0a, 0x0c, 0x6c, 0x6f, 0x6e, 0x64, 0x6f, 0x6e, 0x5f, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x42, 0x30, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, - 0x6e, 0x74, 0xf2, 0xde, 0x1f, 0x13, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6c, 0x6f, 0x6e, 0x64, - 0x6f, 0x6e, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0b, 0x6c, 0x6f, 0x6e, 0x64, 0x6f, - 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x67, 0x0a, 0x13, 0x61, 0x72, 0x72, 0x6f, 0x77, 0x5f, - 0x67, 0x6c, 0x61, 0x63, 0x69, 0x65, 0x72, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x12, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x37, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, - 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, - 0x1f, 0x1a, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x61, 0x72, 0x72, 0x6f, 0x77, 0x5f, 0x67, 0x6c, - 0x61, 0x63, 0x69, 0x65, 0x72, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x11, 0x61, 0x72, - 0x72, 0x6f, 0x77, 0x47, 0x6c, 0x61, 0x63, 0x69, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, - 0x64, 0x0a, 0x12, 0x67, 0x72, 0x61, 0x79, 0x5f, 0x67, 0x6c, 0x61, 0x63, 0x69, 0x65, 0x72, 0x5f, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x42, 0x36, 0xda, 0xde, 0x1f, - 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, - 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, 0x1f, 0x19, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, - 0x67, 0x72, 0x61, 0x79, 0x5f, 0x67, 0x6c, 0x61, 0x63, 0x69, 0x65, 0x72, 0x5f, 0x62, 0x6c, 0x6f, - 0x63, 0x6b, 0x22, 0x52, 0x10, 0x67, 0x72, 0x61, 0x79, 0x47, 0x6c, 0x61, 0x63, 0x69, 0x65, 0x72, - 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x6a, 0x0a, 0x14, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x5f, 0x6e, - 0x65, 0x74, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x15, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x38, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, - 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, - 0x1f, 0x1b, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x5f, 0x6e, 0x65, - 0x74, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x12, 0x6d, - 0x65, 0x72, 0x67, 0x65, 0x4e, 0x65, 0x74, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x18, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, - 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x18, 0x19, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x65, 0x6e, - 0x6f, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x65, 0x63, 0x69, 0x6d, 0x61, 0x6c, 0x73, 0x18, 0x1a, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x64, 0x65, 0x63, 0x69, 0x6d, 0x61, 0x6c, 0x73, 0x12, 0x56, + 0xde, 0x1f, 0x19, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6d, 0x75, 0x69, 0x72, 0x5f, 0x67, 0x6c, + 0x61, 0x63, 0x69, 0x65, 0x72, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x10, 0x6d, 0x75, + 0x69, 0x72, 0x47, 0x6c, 0x61, 0x63, 0x69, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x53, + 0x0a, 0x0c, 0x62, 0x65, 0x72, 0x6c, 0x69, 0x6e, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x0d, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x30, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, + 0xde, 0x1f, 0x13, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x62, 0x65, 0x72, 0x6c, 0x69, 0x6e, 0x5f, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0b, 0x62, 0x65, 0x72, 0x6c, 0x69, 0x6e, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x12, 0x53, 0x0a, 0x0c, 0x6c, 0x6f, 0x6e, 0x64, 0x6f, 0x6e, 0x5f, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x18, 0x11, 0x20, 0x01, 0x28, 0x09, 0x42, 0x30, 0xda, 0xde, 0x1f, 0x15, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, + 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, 0x1f, 0x13, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6c, 0x6f, + 0x6e, 0x64, 0x6f, 0x6e, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x0b, 0x6c, 0x6f, 0x6e, + 0x64, 0x6f, 0x6e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x67, 0x0a, 0x13, 0x61, 0x72, 0x72, 0x6f, + 0x77, 0x5f, 0x67, 0x6c, 0x61, 0x63, 0x69, 0x65, 0x72, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, + 0x12, 0x20, 0x01, 0x28, 0x09, 0x42, 0x37, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, + 0xf2, 0xde, 0x1f, 0x1a, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x61, 0x72, 0x72, 0x6f, 0x77, 0x5f, + 0x67, 0x6c, 0x61, 0x63, 0x69, 0x65, 0x72, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x11, + 0x61, 0x72, 0x72, 0x6f, 0x77, 0x47, 0x6c, 0x61, 0x63, 0x69, 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, + 0x6b, 0x12, 0x64, 0x0a, 0x12, 0x67, 0x72, 0x61, 0x79, 0x5f, 0x67, 0x6c, 0x61, 0x63, 0x69, 0x65, + 0x72, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x14, 0x20, 0x01, 0x28, 0x09, 0x42, 0x36, 0xda, + 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, + 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, 0x1f, 0x19, 0x79, 0x61, 0x6d, 0x6c, + 0x3a, 0x22, 0x67, 0x72, 0x61, 0x79, 0x5f, 0x67, 0x6c, 0x61, 0x63, 0x69, 0x65, 0x72, 0x5f, 0x62, + 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, 0x10, 0x67, 0x72, 0x61, 0x79, 0x47, 0x6c, 0x61, 0x63, 0x69, + 0x65, 0x72, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x6a, 0x0a, 0x14, 0x6d, 0x65, 0x72, 0x67, 0x65, + 0x5f, 0x6e, 0x65, 0x74, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, + 0x15, 0x20, 0x01, 0x28, 0x09, 0x42, 0x38, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, + 0xf2, 0xde, 0x1f, 0x1b, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x5f, + 0x6e, 0x65, 0x74, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x5f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x52, + 0x12, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x4e, 0x65, 0x74, 0x73, 0x70, 0x6c, 0x69, 0x74, 0x42, 0x6c, + 0x6f, 0x63, 0x6b, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, + 0x18, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x56, 0x0a, 0x0d, 0x73, 0x68, 0x61, 0x6e, 0x67, 0x68, 0x61, 0x69, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x1b, 0x20, 0x01, 0x28, 0x09, 0x42, 0x31, 0xda, 0xde, 0x1f, 0x15, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, @@ -9976,126 +9897,127 @@ var file_cosmos_evm_vm_v1_evm_proto_rawDesc = []byte{ 0x69, 0x6f, 0x2f, 0x6d, 0x61, 0x74, 0x68, 0x2e, 0x49, 0x6e, 0x74, 0xf2, 0xde, 0x1f, 0x11, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x6f, 0x73, 0x61, 0x6b, 0x61, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x22, 0x52, 0x09, 0x6f, 0x73, 0x61, 0x6b, 0x61, 0x54, 0x69, 0x6d, 0x65, 0x4a, 0x04, 0x08, 0x05, 0x10, - 0x06, 0x4a, 0x04, 0x08, 0x16, 0x10, 0x17, 0x4a, 0x04, 0x08, 0x17, 0x10, 0x18, 0x22, 0x2f, 0x0a, - 0x05, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x50, - 0x0a, 0x0f, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x6f, 0x67, - 0x73, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x29, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, - 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, - 0x22, 0x87, 0x03, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, + 0x06, 0x4a, 0x04, 0x08, 0x16, 0x10, 0x17, 0x4a, 0x04, 0x08, 0x17, 0x10, 0x18, 0x4a, 0x04, 0x08, + 0x19, 0x10, 0x1a, 0x4a, 0x04, 0x08, 0x1a, 0x10, 0x1b, 0x22, 0x2f, 0x0a, 0x05, 0x53, 0x74, 0x61, + 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x50, 0x0a, 0x0f, 0x54, 0x72, + 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x12, 0x0a, + 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, + 0x68, 0x12, 0x29, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x15, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, + 0x76, 0x31, 0x2e, 0x4c, 0x6f, 0x67, 0x52, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0x87, 0x03, 0x0a, + 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, + 0x0a, 0x06, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, + 0x74, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x32, 0x0a, 0x0c, 0x62, 0x6c, + 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, + 0x42, 0x0f, 0xea, 0xde, 0x1f, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, + 0x72, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x2c, + 0x0a, 0x07, 0x74, 0x78, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x13, 0xea, 0xde, 0x1f, 0x0f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x48, 0x61, 0x73, 0x68, 0x52, 0x06, 0x74, 0x78, 0x48, 0x61, 0x73, 0x68, 0x12, 0x2f, 0x0a, 0x08, + 0x74, 0x78, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x42, 0x14, + 0xea, 0xde, 0x1f, 0x10, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x49, + 0x6e, 0x64, 0x65, 0x78, 0x52, 0x07, 0x74, 0x78, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x2c, 0x0a, + 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x0d, 0xea, 0xde, 0x1f, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, + 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, 0x22, 0x0a, 0x05, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x42, 0x0c, 0xea, 0xde, 0x1f, 0x08, + 0x6c, 0x6f, 0x67, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, + 0x18, 0x0a, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x12, 0x3b, 0x0a, 0x0f, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x04, 0x42, 0x12, 0xea, 0xde, 0x1f, 0x0e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0e, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x90, 0x02, 0x0a, 0x08, 0x54, 0x78, 0x52, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x12, 0x46, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x1b, 0xf2, + 0xde, 0x1f, 0x17, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, + 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x52, 0x0f, 0x63, 0x6f, 0x6e, 0x74, + 0x72, 0x61, 0x63, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x62, + 0x6c, 0x6f, 0x6f, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x6f, + 0x6d, 0x12, 0x57, 0x0a, 0x07, 0x74, 0x78, 0x5f, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, + 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x4c, 0x6f, 0x67, 0x73, 0x42, 0x1b, 0xc8, 0xde, 0x1f, 0x00, 0xf2, 0xde, 0x1f, 0x0e, 0x79, + 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x74, 0x78, 0x5f, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0xa8, 0xe7, 0xb0, + 0x2a, 0x01, 0x52, 0x06, 0x74, 0x78, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x65, + 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x72, 0x65, 0x74, 0x12, 0x1a, 0x0a, 0x08, + 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, + 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x61, 0x73, 0x5f, + 0x75, 0x73, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x61, 0x73, 0x55, + 0x73, 0x65, 0x64, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x61, 0x0a, 0x0b, 0x41, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x06, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, - 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x32, - 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x04, 0x42, 0x0f, 0xea, 0xde, 0x1f, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, - 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4e, 0x75, 0x6d, 0x62, - 0x65, 0x72, 0x12, 0x2c, 0x0a, 0x07, 0x74, 0x78, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x13, 0xea, 0xde, 0x1f, 0x0f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x48, 0x61, 0x73, 0x68, 0x52, 0x06, 0x74, 0x78, 0x48, 0x61, 0x73, 0x68, - 0x12, 0x2f, 0x0a, 0x08, 0x74, 0x78, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x04, 0x42, 0x14, 0xea, 0xde, 0x1f, 0x10, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x07, 0x74, 0x78, 0x49, 0x6e, 0x64, 0x65, - 0x78, 0x12, 0x2c, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, - 0x07, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0d, 0xea, 0xde, 0x1f, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x48, 0x61, 0x73, 0x68, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x61, 0x73, 0x68, 0x12, - 0x22, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x42, 0x0c, - 0xea, 0xde, 0x1f, 0x08, 0x6c, 0x6f, 0x67, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x05, 0x69, 0x6e, - 0x64, 0x65, 0x78, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x18, 0x09, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x72, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x64, 0x12, 0x3b, 0x0a, - 0x0f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x18, 0x0a, 0x20, 0x01, 0x28, 0x04, 0x42, 0x12, 0xea, 0xde, 0x1f, 0x0e, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x0e, 0x62, 0x6c, 0x6f, 0x63, - 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x90, 0x02, 0x0a, 0x08, 0x54, - 0x78, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x46, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x74, 0x72, - 0x61, 0x63, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x42, 0x1b, 0xf2, 0xde, 0x1f, 0x17, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x63, 0x6f, 0x6e, - 0x74, 0x72, 0x61, 0x63, 0x74, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x52, 0x0f, - 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, - 0x14, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x6f, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, - 0x62, 0x6c, 0x6f, 0x6f, 0x6d, 0x12, 0x57, 0x0a, 0x07, 0x74, 0x78, 0x5f, 0x6c, 0x6f, 0x67, 0x73, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x21, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x4c, 0x6f, 0x67, 0x73, 0x42, 0x1b, 0xc8, 0xde, 0x1f, 0x00, 0xf2, - 0xde, 0x1f, 0x0e, 0x79, 0x61, 0x6d, 0x6c, 0x3a, 0x22, 0x74, 0x78, 0x5f, 0x6c, 0x6f, 0x67, 0x73, - 0x22, 0xa8, 0xe7, 0xb0, 0x2a, 0x01, 0x52, 0x06, 0x74, 0x78, 0x4c, 0x6f, 0x67, 0x73, 0x12, 0x10, - 0x0a, 0x03, 0x72, 0x65, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x72, 0x65, 0x74, - 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x76, 0x65, 0x72, 0x74, 0x65, 0x64, 0x12, 0x19, 0x0a, 0x08, - 0x67, 0x61, 0x73, 0x5f, 0x75, 0x73, 0x65, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, - 0x67, 0x61, 0x73, 0x55, 0x73, 0x65, 0x64, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x61, 0x0a, - 0x0b, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x75, 0x70, 0x6c, 0x65, 0x12, 0x18, 0x0a, 0x07, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x32, 0x0a, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, - 0x65, 0x5f, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x42, 0x0f, 0xea, 0xde, - 0x1f, 0x0b, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x0b, 0x73, - 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x4b, 0x65, 0x79, 0x73, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, - 0x22, 0xa0, 0x04, 0x0a, 0x0b, 0x54, 0x72, 0x61, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x12, 0x16, 0x0a, 0x06, 0x74, 0x72, 0x61, 0x63, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x74, 0x72, 0x61, 0x63, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, - 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, - 0x75, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x65, 0x78, 0x65, 0x63, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x06, 0x72, 0x65, 0x65, 0x78, 0x65, 0x63, 0x12, 0x35, 0x0a, 0x0d, 0x64, 0x69, - 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x08, 0x42, 0x10, 0xea, 0xde, 0x1f, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, - 0x61, 0x63, 0x6b, 0x52, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x63, - 0x6b, 0x12, 0x3b, 0x0a, 0x0f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x73, 0x74, 0x6f, - 0x72, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x42, 0x12, 0xea, 0xde, 0x1f, 0x0e, - 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x52, 0x0e, - 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x14, - 0x0a, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x64, - 0x65, 0x62, 0x75, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x3b, 0x0a, 0x09, 0x6f, 0x76, - 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, - 0x2e, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x09, 0x6f, 0x76, - 0x65, 0x72, 0x72, 0x69, 0x64, 0x65, 0x73, 0x12, 0x35, 0x0a, 0x0d, 0x65, 0x6e, 0x61, 0x62, 0x6c, - 0x65, 0x5f, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x42, 0x10, - 0xea, 0xde, 0x1f, 0x0c, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, - 0x52, 0x0c, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x42, - 0x0a, 0x12, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x5f, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x42, 0x14, 0xea, 0xde, 0x1f, 0x10, - 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x44, 0x61, 0x74, 0x61, - 0x52, 0x10, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x44, 0x61, - 0x74, 0x61, 0x12, 0x3e, 0x0a, 0x12, 0x74, 0x72, 0x61, 0x63, 0x65, 0x72, 0x5f, 0x6a, 0x73, 0x6f, - 0x6e, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x42, 0x10, - 0xea, 0xde, 0x1f, 0x0c, 0x74, 0x72, 0x61, 0x63, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, - 0x52, 0x10, 0x74, 0x72, 0x61, 0x63, 0x65, 0x72, 0x4a, 0x73, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x66, - 0x69, 0x67, 0x4a, 0x04, 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x52, 0x0e, - 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x52, 0x13, - 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x5f, 0x64, - 0x61, 0x74, 0x61, 0x22, 0x4e, 0x0a, 0x0a, 0x50, 0x72, 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, - 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, - 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, - 0x6f, 0x64, 0x65, 0x2a, 0xc0, 0x01, 0x0a, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x79, - 0x70, 0x65, 0x12, 0x3c, 0x0a, 0x1a, 0x41, 0x43, 0x43, 0x45, 0x53, 0x53, 0x5f, 0x54, 0x59, 0x50, - 0x45, 0x5f, 0x50, 0x45, 0x52, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x4c, 0x45, 0x53, 0x53, - 0x10, 0x00, 0x1a, 0x1c, 0x8a, 0x9d, 0x20, 0x18, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x79, - 0x70, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x6c, 0x65, 0x73, 0x73, - 0x12, 0x34, 0x0a, 0x16, 0x41, 0x43, 0x43, 0x45, 0x53, 0x53, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, - 0x52, 0x45, 0x53, 0x54, 0x52, 0x49, 0x43, 0x54, 0x45, 0x44, 0x10, 0x01, 0x1a, 0x18, 0x8a, 0x9d, - 0x20, 0x14, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x73, 0x74, - 0x72, 0x69, 0x63, 0x74, 0x65, 0x64, 0x12, 0x38, 0x0a, 0x18, 0x41, 0x43, 0x43, 0x45, 0x53, 0x53, - 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x50, 0x45, 0x52, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4f, 0x4e, - 0x45, 0x44, 0x10, 0x02, 0x1a, 0x1a, 0x8a, 0x9d, 0x20, 0x16, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, - 0x54, 0x79, 0x70, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x64, - 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x42, 0xab, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x42, - 0x08, 0x45, 0x76, 0x6d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x26, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x6d, 0x2f, 0x76, 0x6d, 0x2f, 0x76, 0x31, 0x3b, 0x76, - 0x6d, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x45, 0x56, 0xaa, 0x02, 0x10, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x45, 0x76, 0x6d, 0x2e, 0x56, 0x6d, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x10, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x45, 0x76, 0x6d, 0x5c, 0x56, 0x6d, 0x5c, 0x56, 0x31, 0xe2, - 0x02, 0x1c, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x45, 0x76, 0x6d, 0x5c, 0x56, 0x6d, 0x5c, - 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x45, 0x76, 0x6d, 0x3a, 0x3a, 0x56, 0x6d, - 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x73, 0x12, 0x32, 0x0a, 0x0c, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x5f, 0x6b, 0x65, + 0x79, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x42, 0x0f, 0xea, 0xde, 0x1f, 0x0b, 0x73, 0x74, + 0x6f, 0x72, 0x61, 0x67, 0x65, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x0b, 0x73, 0x74, 0x6f, 0x72, 0x61, + 0x67, 0x65, 0x4b, 0x65, 0x79, 0x73, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0xa0, 0x04, 0x0a, + 0x0b, 0x54, 0x72, 0x61, 0x63, 0x65, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x16, 0x0a, 0x06, + 0x74, 0x72, 0x61, 0x63, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x72, + 0x61, 0x63, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x16, + 0x0a, 0x06, 0x72, 0x65, 0x65, 0x78, 0x65, 0x63, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, + 0x72, 0x65, 0x65, 0x78, 0x65, 0x63, 0x12, 0x35, 0x0a, 0x0d, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, + 0x65, 0x5f, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x42, 0x10, 0xea, + 0xde, 0x1f, 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x52, + 0x0c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x53, 0x74, 0x61, 0x63, 0x6b, 0x12, 0x3b, 0x0a, + 0x0f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x73, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x42, 0x12, 0xea, 0xde, 0x1f, 0x0e, 0x64, 0x69, 0x73, 0x61, + 0x62, 0x6c, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x52, 0x0e, 0x64, 0x69, 0x73, 0x61, + 0x62, 0x6c, 0x65, 0x53, 0x74, 0x6f, 0x72, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65, + 0x62, 0x75, 0x67, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, + 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x05, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x3b, 0x0a, 0x09, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, + 0x64, 0x65, 0x73, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x68, 0x61, + 0x69, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x09, 0x6f, 0x76, 0x65, 0x72, 0x72, 0x69, + 0x64, 0x65, 0x73, 0x12, 0x35, 0x0a, 0x0d, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6d, 0x65, + 0x6d, 0x6f, 0x72, 0x79, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x42, 0x10, 0xea, 0xde, 0x1f, 0x0c, + 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x52, 0x0c, 0x65, 0x6e, + 0x61, 0x62, 0x6c, 0x65, 0x4d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x12, 0x42, 0x0a, 0x12, 0x65, 0x6e, + 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x5f, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x0c, 0x20, 0x01, 0x28, 0x08, 0x42, 0x14, 0xea, 0xde, 0x1f, 0x10, 0x65, 0x6e, 0x61, 0x62, + 0x6c, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x44, 0x61, 0x74, 0x61, 0x52, 0x10, 0x65, 0x6e, + 0x61, 0x62, 0x6c, 0x65, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x44, 0x61, 0x74, 0x61, 0x12, 0x3e, + 0x0a, 0x12, 0x74, 0x72, 0x61, 0x63, 0x65, 0x72, 0x5f, 0x6a, 0x73, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x42, 0x10, 0xea, 0xde, 0x1f, 0x0c, + 0x74, 0x72, 0x61, 0x63, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x10, 0x74, 0x72, + 0x61, 0x63, 0x65, 0x72, 0x4a, 0x73, 0x6f, 0x6e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x4a, 0x04, + 0x08, 0x04, 0x10, 0x05, 0x4a, 0x04, 0x08, 0x07, 0x10, 0x08, 0x52, 0x0e, 0x64, 0x69, 0x73, 0x61, + 0x62, 0x6c, 0x65, 0x5f, 0x6d, 0x65, 0x6d, 0x6f, 0x72, 0x79, 0x52, 0x13, 0x64, 0x69, 0x73, 0x61, + 0x62, 0x6c, 0x65, 0x5f, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x22, + 0x4e, 0x0a, 0x0a, 0x50, 0x72, 0x65, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6c, 0x6c, 0x12, 0x12, 0x0a, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x63, + 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x2a, + 0xc0, 0x01, 0x0a, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x3c, + 0x0a, 0x1a, 0x41, 0x43, 0x43, 0x45, 0x53, 0x53, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x50, 0x45, + 0x52, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x4c, 0x45, 0x53, 0x53, 0x10, 0x00, 0x1a, 0x1c, + 0x8a, 0x9d, 0x20, 0x18, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0x50, 0x65, + 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x6c, 0x65, 0x73, 0x73, 0x12, 0x34, 0x0a, 0x16, + 0x41, 0x43, 0x43, 0x45, 0x53, 0x53, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, 0x45, 0x53, 0x54, + 0x52, 0x49, 0x43, 0x54, 0x45, 0x44, 0x10, 0x01, 0x1a, 0x18, 0x8a, 0x9d, 0x20, 0x14, 0x41, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x73, 0x74, 0x72, 0x69, 0x63, 0x74, + 0x65, 0x64, 0x12, 0x38, 0x0a, 0x18, 0x41, 0x43, 0x43, 0x45, 0x53, 0x53, 0x5f, 0x54, 0x59, 0x50, + 0x45, 0x5f, 0x50, 0x45, 0x52, 0x4d, 0x49, 0x53, 0x53, 0x49, 0x4f, 0x4e, 0x45, 0x44, 0x10, 0x02, + 0x1a, 0x1a, 0x8a, 0x9d, 0x20, 0x16, 0x41, 0x63, 0x63, 0x65, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, + 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x65, 0x64, 0x1a, 0x04, 0x88, 0xa3, + 0x1e, 0x00, 0x42, 0xab, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x65, 0x76, 0x6d, 0x2e, 0x76, 0x6d, 0x2e, 0x76, 0x31, 0x42, 0x08, 0x45, 0x76, 0x6d, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x26, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, + 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2f, 0x65, 0x76, 0x6d, 0x2f, 0x76, 0x6d, 0x2f, 0x76, 0x31, 0x3b, 0x76, 0x6d, 0x76, 0x31, 0xa2, + 0x02, 0x03, 0x43, 0x45, 0x56, 0xaa, 0x02, 0x10, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x45, + 0x76, 0x6d, 0x2e, 0x56, 0x6d, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x10, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x5c, 0x45, 0x76, 0x6d, 0x5c, 0x56, 0x6d, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1c, 0x43, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x45, 0x76, 0x6d, 0x5c, 0x56, 0x6d, 0x5c, 0x56, 0x31, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x13, 0x43, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x45, 0x76, 0x6d, 0x3a, 0x3a, 0x56, 0x6d, 0x3a, 0x3a, 0x56, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/client/config.go b/client/config.go deleted file mode 100644 index 1b6303599..000000000 --- a/client/config.go +++ /dev/null @@ -1,46 +0,0 @@ -package client - -import ( - "os" - "path/filepath" - - "github.com/spf13/cobra" - "github.com/spf13/viper" - - "github.com/cometbft/cometbft/libs/cli" - - "github.com/cosmos/cosmos-sdk/client/flags" -) - -// InitConfig adds the chain-id, encoding and output flags to the persistent flag set. -func InitConfig(cmd *cobra.Command) error { - home, err := cmd.PersistentFlags().GetString(cli.HomeFlag) - if err != nil { - return err - } - - configFile := filepath.Join(home, "config", "config.toml") - _, err = os.Stat(configFile) - if err != nil && !os.IsNotExist(err) { - // Immediately return if the error isn't related to the file not existing. - // See issue https://github.com/evmos/ethermint/issues/539 - return err - } - if err == nil { - viper.SetConfigFile(configFile) - - if err := viper.ReadInConfig(); err != nil { - return err - } - } - - if err := viper.BindPFlag(flags.FlagChainID, cmd.PersistentFlags().Lookup(flags.FlagChainID)); err != nil { - return err - } - - if err := viper.BindPFlag(cli.EncodingFlag, cmd.PersistentFlags().Lookup(cli.EncodingFlag)); err != nil { - return err - } - - return viper.BindPFlag(cli.OutputFlag, cmd.PersistentFlags().Lookup(cli.OutputFlag)) -} diff --git a/client/config_test.go b/client/config_test.go deleted file mode 100644 index 0b94d35f5..000000000 --- a/client/config_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package client - -import ( - "os" - "path/filepath" - "testing" - - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client/flags" -) - -func TestInitConfigNonNotExistError(t *testing.T) { - tempDir := t.TempDir() - subDir := filepath.Join(tempDir, "nonPerms") - if err := os.Mkdir(subDir, 0o600); err != nil { - t.Fatalf("Failed to create sub directory: %v", err) - } - cmd := &cobra.Command{} - cmd.PersistentFlags().String(flags.FlagHome, "", "") - if err := cmd.PersistentFlags().Set(flags.FlagHome, subDir); err != nil { - t.Fatalf("Could not set home flag [%T] %v", err, err) - } - - if err := InitConfig(cmd); !os.IsPermission(err) { - t.Fatalf("Failed to catch permissions error, got: [%T] %v", err, err) - } -} diff --git a/client/context.go b/client/context.go deleted file mode 100644 index e29319b59..000000000 --- a/client/context.go +++ /dev/null @@ -1,18 +0,0 @@ -package client - -import ( - "github.com/cosmos/cosmos-sdk/client" // import the original package -) - -// EVMContext embeds the original Context and adds your own field -type EVMContext struct { - client.Context // Embedding the original Context - EVMChainID uint64 `json:"evm_chain_id"` -} - -func (ctx EVMContext) WithEVMChainID(evmChainID uint64) EVMContext { - return EVMContext{ - Context: ctx.Context, - EVMChainID: evmChainID, - } -} diff --git a/client/keys.go b/client/keys.go deleted file mode 100644 index 288507a6c..000000000 --- a/client/keys.go +++ /dev/null @@ -1,101 +0,0 @@ -package client - -import ( - "bufio" - - "github.com/spf13/cobra" - - "github.com/cometbft/cometbft/libs/cli" - - clientkeys "github.com/cosmos/evm/client/keys" - "github.com/cosmos/evm/crypto/hd" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/keys" - "github.com/cosmos/cosmos-sdk/crypto/keyring" -) - -// KeyCommands registers a subtree of commands to interact with -// local private key storage. -// -// The defaultToEthKeys boolean indicates whether to use -// Ethereum compatible keys by default or stick with the Cosmos SDK default. -func KeyCommands(defaultNodeHome string, defaultToEthKeys bool) *cobra.Command { - cmd := &cobra.Command{ - Use: "keys", - Short: "Manage your application's keys", - Long: `Keyring management commands. These keys may be in any format supported by the -CometBFT crypto library and can be used by light-clients, full nodes, or any other application -that needs to sign with a private key. - -The keyring supports the following backends: - - os Uses the operating system's default credentials store. - file Uses encrypted file-based keystore within the app's configuration directory. - This keyring will request a password each time it is accessed, which may occur - multiple times in a single command resulting in repeated password prompts. - kwallet Uses KDE Wallet Manager as a credentials management application. - pass Uses the pass command line utility to store and retrieve keys. - test Stores keys insecurely to disk. It does not prompt for a password to be unlocked - and it should be use only for testing purposes. - -kwallet and pass backends depend on external tools. Refer to their respective documentation for more -information: - KWallet https://github.com/KDE/kwallet - pass https://www.passwordstore.org/ - -The pass backend requires GnuPG: https://gnupg.org/ -`, - } - - // support adding Ethereum supported keys - addCmd := keys.AddKeyCommand() - - if defaultToEthKeys { - ethSecp256k1Str := string(hd.EthSecp256k1Type) - - // update the default signing algorithm value to "eth_secp256k1" - algoFlag := addCmd.Flag(flags.FlagKeyType) - algoFlag.DefValue = ethSecp256k1Str - err := algoFlag.Value.Set(ethSecp256k1Str) - if err != nil { - panic(err) - } - } - - addCmd.RunE = runAddCmd - - cmd.AddCommand( - keys.MnemonicKeyCommand(), - addCmd, - keys.ExportKeyCommand(), - keys.ImportKeyCommand(), - keys.ListKeysCmd(), - keys.ListKeyTypesCmd(), - keys.ShowKeysCmd(), - keys.DeleteKeyCommand(), - keys.RenameKeyCommand(), - keys.ParseKeyStringCommand(), - keys.MigrateCommand(), - flags.LineBreak, - UnsafeExportEthKeyCommand(), - UnsafeImportKeyCommand(), - ) - - cmd.PersistentFlags().String(flags.FlagHome, defaultNodeHome, "The application home directory") - cmd.PersistentFlags().String(flags.FlagKeyringDir, "", "The client Keyring directory; if omitted, the default 'home' directory will be used") - cmd.PersistentFlags().String(flags.FlagKeyringBackend, keyring.BackendOS, "Select keyring's backend (os|file|test)") - cmd.PersistentFlags().String(cli.OutputFlag, "text", "Output format (text|json)") - return cmd -} - -func runAddCmd(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd).WithKeyringOptions(hd.EthSecp256k1Option()) - clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags()) - if err != nil { - return err - } - buf := bufio.NewReader(clientCtx.Input) - return clientkeys.RunAddCmd(clientCtx, cmd, args, buf) -} diff --git a/client/keys/add.go b/client/keys/add.go index 23ebf13f7..39e516222 100644 --- a/client/keys/add.go +++ b/client/keys/add.go @@ -10,6 +10,9 @@ import ( "github.com/spf13/cobra" + "github.com/cometbft/cometbft/libs/cli" + + "github.com/cosmos/cosmos-sdk/crypto/hd" cryptohd "github.com/cosmos/evm/crypto/hd" bip39 "github.com/cosmos/go-bip39" @@ -17,7 +20,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/input" "github.com/cosmos/cosmos-sdk/client/keys" - "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -39,6 +41,90 @@ const ( mnemonicEntropySize = 256 ) +// KeyCommands registers a subtree of commands to interact with +// local private key storage. +// +// The defaultToEthKeys boolean indicates whether to use +// Ethereum compatible keys by default or stick with the Cosmos SDK default. +func KeyCommands(defaultNodeHome string, defaultToEthKeys bool) *cobra.Command { + cmd := &cobra.Command{ + Use: "keys", + Short: "Manage your application's keys", + Long: `Keyring management commands. These keys may be in any format supported by the +CometBFT crypto library and can be used by light-clients, full nodes, or any other application +that needs to sign with a private key. + +The keyring supports the following backends: + + os Uses the operating system's default credentials store. + file Uses encrypted file-based keystore within the app's configuration directory. + This keyring will request a password each time it is accessed, which may occur + multiple times in a single command resulting in repeated password prompts. + kwallet Uses KDE Wallet Manager as a credentials management application. + pass Uses the pass command line utility to store and retrieve keys. + test Stores keys insecurely to disk. It does not prompt for a password to be unlocked + and it should be use only for testing purposes. + +kwallet and pass backends depend on external tools. Refer to their respective documentation for more +information: + KWallet https://github.com/KDE/kwallet + pass https://www.passwordstore.org/ + +The pass backend requires GnuPG: https://gnupg.org/ +`, + } + + // support adding Ethereum supported keys + addCmd := keys.AddKeyCommand() + + if defaultToEthKeys { + ethSecp256k1Str := string(cryptohd.EthSecp256k1Type) + + // update the default signing algorithm value to "eth_secp256k1" + algoFlag := addCmd.Flag(flags.FlagKeyType) + algoFlag.DefValue = ethSecp256k1Str + err := algoFlag.Value.Set(ethSecp256k1Str) + if err != nil { + panic(err) + } + } + + addCmd.RunE = runAddCmd + + cmd.AddCommand( + keys.MnemonicKeyCommand(), + addCmd, + keys.ExportKeyCommand(), + keys.ImportKeyCommand(), + keys.ListKeysCmd(), + keys.ListKeyTypesCmd(), + keys.ShowKeysCmd(), + keys.DeleteKeyCommand(), + keys.RenameKeyCommand(), + keys.ParseKeyStringCommand(), + keys.MigrateCommand(), + flags.LineBreak, + UnsafeExportEthKeyCommand(), + UnsafeImportKeyCommand(), + ) + + cmd.PersistentFlags().String(flags.FlagHome, defaultNodeHome, "The application home directory") + cmd.PersistentFlags().String(flags.FlagKeyringDir, "", "The client Keyring directory; if omitted, the default 'home' directory will be used") + cmd.PersistentFlags().String(flags.FlagKeyringBackend, keyring.BackendOS, "Select keyring's backend (os|file|test)") + cmd.PersistentFlags().String(cli.OutputFlag, "text", "Output format (text|json)") + return cmd +} + +func runAddCmd(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd).WithKeyringOptions(cryptohd.EthSecp256k1Option()) + clientCtx, err := client.ReadPersistentCommandFlags(clientCtx, cmd.Flags()) + if err != nil { + return err + } + buf := bufio.NewReader(clientCtx.Input) + return RunAddCmd(clientCtx, cmd, args, buf) +} + /* RunAddCmd input diff --git a/client/export.go b/client/keys/export.go similarity index 99% rename from client/export.go rename to client/keys/export.go index 49c59b5e2..37f8c0942 100644 --- a/client/export.go +++ b/client/keys/export.go @@ -1,4 +1,4 @@ -package client +package keys import ( "bufio" diff --git a/client/import.go b/client/keys/import.go similarity index 98% rename from client/import.go rename to client/keys/import.go index b9a97e357..844ec12ae 100644 --- a/client/import.go +++ b/client/keys/import.go @@ -1,4 +1,4 @@ -package client +package keys import ( "bufio" diff --git a/evmd/cmd/evmd/config/evmd_config.go b/config/app_config.go similarity index 97% rename from evmd/cmd/evmd/config/evmd_config.go rename to config/app_config.go index 2f9303699..641715e42 100644 --- a/evmd/cmd/evmd/config/evmd_config.go +++ b/config/app_config.go @@ -96,7 +96,7 @@ type EVMAppConfig struct { // InitAppConfig helps to override default appConfig template and configs. // return "", nil if no custom configuration is required for the application. -func InitAppConfig(denom string, evmChainID uint64) (string, interface{}) { +func InitAppConfig(denom string, evmChainID uint64) (string, *EVMAppConfig) { // Optionally allow the chain developer to overwrite the SDK's default // server config. srvCfg := serverconfig.DefaultConfig() @@ -124,7 +124,7 @@ func InitAppConfig(denom string, evmChainID uint64) (string, interface{}) { TLS: *cosmosevmserverconfig.DefaultTLSConfig(), } - return EVMAppTemplate, customAppConfig + return EVMAppTemplate, &customAppConfig } const EVMAppTemplate = serverconfig.DefaultConfigTemplate + cosmosevmserverconfig.DefaultEVMConfigTemplate diff --git a/config/chain_config.go b/config/chain_config.go new file mode 100644 index 000000000..154951efc --- /dev/null +++ b/config/chain_config.go @@ -0,0 +1,16 @@ +package config + +import ( + "github.com/cosmos/evm/config/eips" + evmtypes "github.com/cosmos/evm/x/vm/types" +) + +func NewDefaultEvmConfig( + evmChainID uint64, + reset bool, +) *evmtypes.EvmConfig { + chainConfig := evmtypes.DefaultChainConfig(evmtypes.DefaultEvmChainID) + return evmtypes.NewEvmConfig(). + WithChainConfig(chainConfig). + WithExtendedEips(eips.CosmosEVMActivators) +} diff --git a/evmd/eips/README.md b/config/eips/README.md similarity index 97% rename from evmd/eips/README.md rename to config/eips/README.md index ac498503e..93f5572d8 100644 --- a/evmd/eips/README.md +++ b/config/eips/README.md @@ -134,7 +134,7 @@ In this way, even though the custom activators defined $3$ new EIPs, we are goin The EVM configuration is the type used to modify the EVM configuration before starting a node. The type is defined as: ```go -type EVMConfigurator struct { +type EvmConfig struct { extendedEIPs map[int]func(*vm.JumpTable) extendedDefaultExtraEIPs []int64 sealed bool @@ -151,18 +151,18 @@ It is important to notice that the configurator will only allow to append new en **Cosmos EVM**. The reason behind this choice is to ensure the correct and safe execution of the virtual machine but still allowing partners to customize their implementation. -The `EVMConfigurator` type should be constructed using the builder pattern inside the `init()` function of the file so +The `EvmConfig` type should be constructed using the builder pattern inside the `init()` function of the file so that it is run during the creation of the application. An example of the usage of the configurator is reported below: ```go -configurator := evmconfig.NewEVMConfigurator(). +configurator := evmconfig.NewEvmConfig(). WithExtendedEips(customActivators). WithExtendedDefaultExtraEIPs(defaultEnabledEIPs...). - Configure() + Apply() -err := configurator.Configure() +err := configurator.Apply() ``` Errors are raised when the configurator tries to append an item with the same name of one of the default one. Since diff --git a/testutil/config/activators.go b/config/eips/activators.go similarity index 55% rename from testutil/config/activators.go rename to config/eips/activators.go index a88b99e69..f349cddea 100644 --- a/testutil/config/activators.go +++ b/config/eips/activators.go @@ -1,12 +1,12 @@ -package config +package eips import ( "github.com/ethereum/go-ethereum/core/vm" ) -// cosmosEVMActivators defines a map of opcode modifiers associated +// CosmosEVMActivators defines a map of opcode modifiers associated // with a key defining the corresponding EIP. -var cosmosEVMActivators = map[int]func(*vm.JumpTable){ +var CosmosEVMActivators = map[int]func(*vm.JumpTable){ 0o000: Enable0000, 0o001: Enable0001, 0o002: Enable0002, diff --git a/evmd/eips/eips.go b/config/eips/eips.go similarity index 100% rename from evmd/eips/eips.go rename to config/eips/eips.go diff --git a/config/evm_app_options.go b/config/evm_app_options.go deleted file mode 100644 index 63b06dbc6..000000000 --- a/config/evm_app_options.go +++ /dev/null @@ -1,91 +0,0 @@ -package config - -import ( - "fmt" - - "github.com/ethereum/go-ethereum/core/vm" - - evmtypes "github.com/cosmos/evm/x/vm/types" - - "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// EVMOptionsFn defines a function type for setting app options specifically for -// the Cosmos EVM app. The function should receive the chainID and return an error if -// any. -type EVMOptionsFn func(uint64) error - -var sealed = false - -func EvmAppOptionsWithConfig( - chainID uint64, - chainsCoinInfo map[uint64]evmtypes.EvmCoinInfo, - cosmosEVMActivators map[int]func(*vm.JumpTable), -) error { - if sealed { - return nil - } - - if err := EvmAppOptionsWithConfigWithReset(chainID, chainsCoinInfo, cosmosEVMActivators, false); err != nil { - return err - } - - sealed = true - return nil -} - -func EvmAppOptionsWithConfigWithReset( - chainID uint64, - chainsCoinInfo map[uint64]evmtypes.EvmCoinInfo, - cosmosEVMActivators map[int]func(*vm.JumpTable), - withReset bool, -) error { - coinInfo, found := chainsCoinInfo[chainID] - if !found { - return fmt.Errorf("unknown chain id: %d", chainID) - } - - // set the denom info for the chain - if err := setBaseDenom(coinInfo); err != nil { - return err - } - - ethCfg := evmtypes.DefaultChainConfig(chainID) - configurator := evmtypes.NewEVMConfigurator() - if withReset { - // reset configuration to set the new one - configurator.ResetTestConfig() - } - err := configurator. - WithExtendedEips(cosmosEVMActivators). - WithChainConfig(ethCfg). - // NOTE: we're using the 18 decimals default for the example chain - WithEVMCoinInfo(coinInfo). - Configure() - if err != nil { - return err - } - - return nil -} - -// setBaseDenom registers the display denom and base denom and sets the -// base denom for the chain. The function registered different values based on -// the EvmCoinInfo to allow different configurations in mainnet and testnet. -func setBaseDenom(ci evmtypes.EvmCoinInfo) (err error) { - // Defer setting the base denom, and capture any potential error from it. - // So when failing because the denom was already registered, we ignore it and set - // the corresponding denom to be base denom - defer func() { - err = sdk.SetBaseDenom(ci.Denom) - }() - if err := sdk.RegisterDenom(ci.DisplayDenom, math.LegacyOneDec()); err != nil { - return err - } - - // sdk.RegisterDenom will automatically overwrite the base denom when the - // new setBaseDenom() units are lower than the current base denom's units. - return sdk.RegisterDenom(ci.Denom, math.LegacyNewDecWithPrec(1, int64(ci.Decimals))) -} diff --git a/config/sdk_config.go b/config/sdk_config.go new file mode 100644 index 000000000..47d11d06d --- /dev/null +++ b/config/sdk_config.go @@ -0,0 +1,26 @@ +package config + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/evm/types" +) + +func SetupSdkConfig() { + config := sdk.GetConfig() + SetBech32Prefixes(config) + config.Seal() +} + +// SetBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings. +func SetBech32Prefixes(config *sdk.Config) { + config.SetBech32PrefixForAccount(sdk.Bech32PrefixAccAddr, sdk.Bech32PrefixAccPub) + config.SetBech32PrefixForValidator(sdk.Bech32PrefixValAddr, sdk.Bech32PrefixValPub) + config.SetBech32PrefixForConsensusNode(sdk.Bech32PrefixConsAddr, sdk.Bech32PrefixConsPub) +} + +// SetBip44CoinType sets the global coin type to be used in hierarchical deterministic wallets. +func SetBip44CoinType(config *sdk.Config) { + config.SetCoinType(types.Bip44CoinType) + config.SetPurpose(sdk.Purpose) // Shared + config.SetFullFundraiserPath(types.BIP44HDPath) //nolint: staticcheck +} diff --git a/config/server_app_options.go b/config/server_app_options.go index cac9cc7a1..68dd16933 100644 --- a/config/server_app_options.go +++ b/config/server_app_options.go @@ -1,6 +1,7 @@ package config import ( + "errors" "math" "path/filepath" @@ -11,11 +12,14 @@ import ( "cosmossdk.io/log" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/flags" sdkserver "github.com/cosmos/cosmos-sdk/server" servertypes "github.com/cosmos/cosmos-sdk/server/types" sdk "github.com/cosmos/cosmos-sdk/types" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + evmtypes "github.com/cosmos/evm/x/vm/types" ) // GetBlockGasLimit reads the genesis json file using AppGenesisFromFile @@ -92,3 +96,56 @@ func GetMinTip(appOpts servertypes.AppOptions, logger log.Logger) *uint256.Int { logger.Error("invalid min tip value in app.toml or flag, falling back to nil", "min_tip", minTipUint64) return nil } + +// GetChainID returns the chain ID from the app options, set from flags or app.toml +func GetChainID(appOpts servertypes.AppOptions) (string, error) { + chainID := cast.ToString(appOpts.Get(flags.FlagChainID)) + if chainID == "" { + // if not available, load from client.toml + homeDir := cast.ToString(appOpts.Get(flags.FlagHome)) + if homeDir == "" { + return "", errors.New("home directory flag not found in app options") + } + clientCtx := client.Context{}.WithHomeDir(homeDir) + clientCtx, err := config.ReadFromClientConfig(clientCtx) + if err != nil { + return "", err + } + chainID = clientCtx.ChainID + } + + return chainID, nil +} + +// GetEvmChainID returns the EVM chain ID from the app options, set from flags or app.toml +func GetEvmChainID(appOpts servertypes.AppOptions) (uint64, error) { + evmChainID := cast.ToUint64(appOpts.Get(srvflags.EVMChainID)) + if evmChainID == 0 { + return 0, errors.New("evm chain id flag not found in app options") + } + + return evmChainID, nil +} + +func GetEvmChainIDWithDefault( + appOpts servertypes.AppOptions, + evmConfig *evmtypes.EvmConfig, + logger log.Logger) uint64 { + evmChainID, err := GetEvmChainID(appOpts) + if err == nil { + return evmChainID + } + logger.Warn("failed to get evm chain id from app options", "error", err) + + if evmConfig != nil { + evmChainConfig := evmConfig.GetChainConfig() + if evmChainConfig != nil { + return evmChainConfig.ChainId + } + logger.Warn("failed to get evm chain config, evm chain config is nil") + } + + logger.Info("failed to get evm chain id, using default evm chain id", "default_evm_chain_id", evmtypes.DefaultEvmChainID) + + return evmtypes.DefaultEvmChainID +} diff --git a/encoding/config.go b/encoding/config.go index aa0c25629..6302c8a73 100644 --- a/encoding/config.go +++ b/encoding/config.go @@ -4,7 +4,6 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" enccodec "github.com/cosmos/evm/encoding/codec" - "github.com/cosmos/evm/ethereum/eip712" erc20types "github.com/cosmos/evm/x/erc20/types" evmtypes "github.com/cosmos/evm/x/vm/types" "github.com/cosmos/gogoproto/proto" @@ -30,7 +29,7 @@ type Config struct { } // MakeConfig creates a new Config and returns it -func MakeConfig(evmChainID uint64) Config { +func MakeConfig() Config { cdc := amino.NewLegacyAmino() signingOptions := signing.Options{ AddressCodec: address.Bech32Codec{ @@ -56,7 +55,6 @@ func MakeConfig(evmChainID uint64) Config { // This is needed for the EIP712 txs because currently is using // the deprecated method legacytx.StdSignBytes legacytx.RegressionTestingAminoCodec = cdc - eip712.SetEncodingConfig(cdc, interfaceRegistry, evmChainID) return Config{ InterfaceRegistry: interfaceRegistry, diff --git a/ethereum/eip712/preprocess_test.go b/ethereum/eip712/preprocess_test.go index c0376fda0..129d2e738 100644 --- a/ethereum/eip712/preprocess_test.go +++ b/ethereum/eip712/preprocess_test.go @@ -8,9 +8,10 @@ import ( "github.com/stretchr/testify/require" + evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/encoding" "github.com/cosmos/evm/ethereum/eip712" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -30,7 +31,7 @@ import ( // Testing Constants var ( // chainID is used in EIP-712 tests. - chainID = uint64(constants.ExampleEIP155ChainID) + chainID = uint64(testconfig.EighteenDecimalsChainID) ctx = client.Context{}.WithTxConfig( encoding.MakeConfig(chainID).TxConfig, @@ -39,7 +40,7 @@ var ( // feePayerAddress is the address of the fee payer used in EIP-712 tests. feePayerAddress = fmt.Sprintf( "%s17xpfvakm2amg962yls6f84z3kell8c5lserqta", - constants.ExampleBech32Prefix, + sdk.Bech32MainPrefix, ) ) @@ -55,10 +56,12 @@ type TestCaseStruct struct { func TestLedgerPreprocessing(t *testing.T) { // Update bech32 prefix - sdk.GetConfig().SetBech32PrefixForAccount(constants.ExampleBech32Prefix, "") - evmConfigurator := evmtypes.NewEVMConfigurator(). - WithEVMCoinInfo(constants.ExampleChainCoinInfo[constants.ExampleChainID]) - err := evmConfigurator.Configure() + sdk.GetConfig().SetBech32PrefixForAccount(sdk.Bech32MainPrefix, "") + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + err := evmConfig.Apply() + require.NoError(t, err) + err = evmtypes.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) require.NoError(t, err) testCases := []TestCaseStruct{ diff --git a/evmd/app.go b/evmd/app/app.go similarity index 94% rename from evmd/app.go rename to evmd/app/app.go index d4ec9ebe3..cecc4b34a 100644 --- a/evmd/app.go +++ b/evmd/app/app.go @@ -1,4 +1,4 @@ -package evmd +package app import ( "encoding/json" @@ -18,9 +18,10 @@ import ( abci "github.com/cometbft/cometbft/abci/types" dbm "github.com/cosmos/cosmos-db" + authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" evmante "github.com/cosmos/evm/ante" cosmosevmante "github.com/cosmos/evm/ante/evm" - evmconfig "github.com/cosmos/evm/config" + "github.com/cosmos/evm/config" evmosencoding "github.com/cosmos/evm/encoding" "github.com/cosmos/evm/evmd/ante" evmmempool "github.com/cosmos/evm/mempool" @@ -36,7 +37,6 @@ import ( ibccallbackskeeper "github.com/cosmos/evm/x/ibc/callbacks/keeper" // NOTE: override ICS20 keeper to support IBC transfers of ERC20 tokens - evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" "github.com/cosmos/evm/x/ibc/transfer" transferkeeper "github.com/cosmos/evm/x/ibc/transfer/keeper" transferv2 "github.com/cosmos/evm/x/ibc/transfer/v2" @@ -85,7 +85,7 @@ import ( runtimeservices "github.com/cosmos/cosmos-sdk/runtime/services" sdkserver "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" - "github.com/cosmos/cosmos-sdk/server/config" + servercfg "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" testdata_pulsar "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb" sdk "github.com/cosmos/cosmos-sdk/types" @@ -99,7 +99,6 @@ import ( authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/posthandler" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" - authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" @@ -137,13 +136,13 @@ func init() { // manually update the power reduction by replacing micro (u) -> atto (a) evmos sdk.DefaultPowerReduction = cosmosevmtypes.AttoPowerReduction - defaultNodeHome = evmdconfig.MustGetDefaultNodeHome() + DefaultNodeHome = config.MustGetDefaultNodeHome() } const appName = "evmd" -// defaultNodeHome default home directories for the application daemon -var defaultNodeHome string +// DefaultNodeHome default home directories for the application daemon +var DefaultNodeHome string var ( _ runtime.AppI = (*EVMD)(nil) @@ -206,49 +205,14 @@ type EVMD struct { } // NewExampleApp returns a reference to an initialized EVMD. -func NewExampleApp( - logger log.Logger, - db dbm.DB, - traceStore io.Writer, - loadLatest bool, - appOpts servertypes.AppOptions, - evmChainID uint64, - evmAppOptions evmconfig.EVMOptionsFn, - baseAppOptions ...func(*baseapp.BaseApp), -) *EVMD { - encodingConfig := evmosencoding.MakeConfig(evmChainID) +func NewExampleApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp)) *EVMD { + encodingConfig := evmosencoding.MakeConfig() appCodec := encodingConfig.Codec legacyAmino := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry txConfig := encodingConfig.TxConfig - // Below we could construct and set an application specific mempool and - // ABCI 1.0 PrepareProposal and ProcessProposal handlers. These defaults are - // already set in the SDK's BaseApp, this shows an example of how to override - // them. - // - // Example: - // - // bApp := baseapp.NewBaseApp(...) - // nonceMempool := evmmempool.NewSenderNonceMempool() - // abciPropHandler := NewDefaultProposalHandler(nonceMempool, bApp) - // - // bApp.SetMempool(nonceMempool) - // bApp.SetPrepareProposal(abciPropHandler.PrepareProposalHandler()) - // bApp.SetProcessProposal(abciPropHandler.ProcessProposalHandler()) - // - // Alternatively, you can construct BaseApp options, append those to - // baseAppOptions and pass them to NewBaseApp. - // - // Example: - // - // prepareOpt = func(app *baseapp.BaseApp) { - // abciPropHandler := baseapp.NewDefaultProposalHandler(nonceMempool, app) - // app.SetPrepareProposal(abciPropHandler.PrepareProposalHandler()) - // } - // baseAppOptions = append(baseAppOptions, prepareOpt) - bApp := baseapp.NewBaseApp( appName, logger, @@ -262,11 +226,6 @@ func NewExampleApp( bApp.SetInterfaceRegistry(interfaceRegistry) bApp.SetTxEncoder(txConfig.TxEncoder()) - // initialize the Cosmos EVM application configuration - if err := evmAppOptions(evmChainID); err != nil { - panic(err) - } - keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, @@ -318,7 +277,7 @@ func NewExampleApp( // add keepers app.AccountKeeper = authkeeper.NewAccountKeeper( appCodec, runtime.NewKVStoreService(keys[authtypes.StoreKey]), - authtypes.ProtoBaseAccount, evmdconfig.GetMaccPerms(), + authtypes.ProtoBaseAccount, config.GetMaccPerms(), authcodec.NewBech32Codec(sdk.GetConfig().GetBech32AccountAddrPrefix()), sdk.GetConfig().GetBech32AccountAddrPrefix(), authAddr, @@ -328,7 +287,7 @@ func NewExampleApp( appCodec, runtime.NewKVStoreService(keys[banktypes.StoreKey]), app.AccountKeeper, - evmdconfig.BlockedAddresses(), + config.BlockedAddresses(), authAddr, logger, ) @@ -473,11 +432,15 @@ func NewExampleApp( // Set up EVM keeper tracer := cast.ToString(appOpts.Get(srvflags.EVMTracer)) + evmChainID := cast.ToUint64(appOpts.Get(srvflags.EVMChainID)) + if evmChainID == 0 { + evmChainID = evmtypes.DefaultEvmChainID + } // NOTE: it's required to set up the EVM keeper before the ERC-20 keeper, because it is used in its instantiation. app.EVMKeeper = evmkeeper.NewKeeper( // TODO: check why this is not adjusted to use the runtime module methods like SDK native keepers - appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], keys, + &encodingConfig, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], keys, authtypes.NewModuleAddress(govtypes.ModuleName), app.AccountKeeper, app.PreciseBankKeeper, @@ -486,6 +449,7 @@ func NewExampleApp( &app.ConsensusParamsKeeper, &app.Erc20Keeper, tracer, + evmChainID, ) app.Erc20Keeper = erc20keeper.NewKeeper( @@ -605,7 +569,7 @@ func NewExampleApp( ibctm.NewAppModule(tmLightClientModule), transferModule, // Cosmos EVM modules - vm.NewAppModule(app.EVMKeeper, app.AccountKeeper, app.AccountKeeper.AddressCodec()), + vm.NewAppModule(app.EVMKeeper, app.AccountKeeper, app.StakingKeeper, app.BankKeeper, app.AccountKeeper.AddressCodec()), feemarket.NewAppModule(app.FeeMarketKeeper), erc20.NewAppModule(app.Erc20Keeper, app.AccountKeeper), precisebank.NewAppModule(app.PreciseBankKeeper, app.BankKeeper, app.AccountKeeper), @@ -755,9 +719,9 @@ func NewExampleApp( // If you wish to use the noop mempool, remove this codeblock if evmtypes.GetChainConfig() != nil { // Get the block gas limit from genesis file - blockGasLimit := evmconfig.GetBlockGasLimit(appOpts, logger) + blockGasLimit := config.GetBlockGasLimit(appOpts, logger) // Get GetMinTip from app.toml or cli flag configuration - mipTip := evmconfig.GetMinTip(appOpts, logger) + mipTip := config.GetMinTip(appOpts, logger) mempoolConfig := &evmmempool.EVMMempoolConfig{ AnteHandler: app.GetAnteHandler(), @@ -981,7 +945,7 @@ func (app *EVMD) SimulationManager() *module.SimulationManager { // RegisterAPIRoutes registers all application module routes with the provided // API server. -func (app *EVMD) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { +func (app *EVMD) RegisterAPIRoutes(apiSvr *api.Server, apiConfig servercfg.APIConfig) { clientCtx := apiSvr.ClientCtx // Register new tx routes from grpc-gateway. authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) @@ -1016,7 +980,7 @@ func (app *EVMD) RegisterTendermintService(clientCtx client.Context) { ) } -func (app *EVMD) RegisterNodeService(clientCtx client.Context, cfg config.Config) { +func (app *EVMD) RegisterNodeService(clientCtx client.Context, cfg servercfg.Config) { node.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) } diff --git a/evmd/cmd/evmd/cmd/creator.go b/evmd/app/creator.go similarity index 91% rename from evmd/cmd/evmd/cmd/creator.go rename to evmd/app/creator.go index c6238998d..f75741457 100644 --- a/evmd/cmd/evmd/cmd/creator.go +++ b/evmd/app/creator.go @@ -1,4 +1,4 @@ -package cmd +package app import ( "errors" @@ -12,8 +12,6 @@ import ( servertypes "github.com/cosmos/cosmos-sdk/server/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/cosmos/evm/evmd" - evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" "github.com/spf13/cast" "github.com/spf13/viper" @@ -24,9 +22,9 @@ import ( storetypes "cosmossdk.io/store/types" ) -type appCreator struct{} +type AppCreator struct{} -func (a appCreator) newApp( +func (a AppCreator) newApp( logger log.Logger, db dbm.DB, traceStore io.Writer, @@ -88,19 +86,17 @@ func (a appCreator) newApp( baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))), } - return evmd.NewExampleApp( + return NewExampleApp( logger, db, traceStore, true, simtestutil.EmptyAppOptions{}, - evmdconfig.EVMChainID, - evmdconfig.EvmAppOptions, baseappOptions..., ) } -func (a appCreator) appExport( +func (a AppCreator) appExport( logger log.Logger, db dbm.DB, traceStore io.Writer, @@ -110,7 +106,7 @@ func (a appCreator) appExport( appOpts servertypes.AppOptions, modulesToExport []string, ) (servertypes.ExportedApp, error) { - var evmApp *evmd.EVMD + var evmApp *EVMD homePath, ok := appOpts.Get(flags.FlagHome).(string) if !ok || homePath == "" { @@ -131,14 +127,13 @@ func (a appCreator) appExport( loadLatest = true } - evmApp = evmd.NewExampleApp( + evmApp = NewExampleApp( logger, db, traceStore, loadLatest, appOpts, - evmdconfig.EVMChainID, - evmdconfig.EvmAppOptions, + nil, ) if height != -1 { diff --git a/evmd/export.go b/evmd/app/export.go similarity index 99% rename from evmd/export.go rename to evmd/app/export.go index 096f5eb2c..e308428da 100644 --- a/evmd/export.go +++ b/evmd/app/export.go @@ -1,4 +1,4 @@ -package evmd +package app import ( "encoding/json" diff --git a/evmd/genesis.go b/evmd/app/genesis.go similarity index 87% rename from evmd/genesis.go rename to evmd/app/genesis.go index 7d656730b..b56f5899a 100644 --- a/evmd/genesis.go +++ b/evmd/app/genesis.go @@ -1,10 +1,9 @@ -package evmd +package app import ( "encoding/json" - "github.com/cosmos/evm/evmd/cmd/evmd/config" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" erc20types "github.com/cosmos/evm/x/erc20/types" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -39,8 +38,8 @@ func NewEVMGenesisState() *evmtypes.GenesisState { // which is the base denomination of the chain (i.e. the WEVMOS contract). func NewErc20GenesisState() *erc20types.GenesisState { erc20GenState := erc20types.DefaultGenesisState() - erc20GenState.TokenPairs = testconstants.ExampleTokenPairs - erc20GenState.NativePrecompiles = []string{testconstants.WEVMOSContractMainnet} + erc20GenState.TokenPairs = testconfig.ExampleTokenPairs + erc20GenState.NativePrecompiles = []string{evmtypes.DefaultWevmosContractMainnet} return erc20GenState } @@ -50,7 +49,7 @@ func NewErc20GenesisState() *erc20types.GenesisState { // NOTE: for the example chain implementation we are also adding a default minter. func NewMintGenesisState() *minttypes.GenesisState { mintGenState := minttypes.DefaultGenesisState() - mintGenState.Params.MintDenom = config.ExampleChainDenom + mintGenState.Params.MintDenom = evmtypes.DefaultEvmCoinInfo.GetDenom() return mintGenState } diff --git a/evmd/interfaces.go b/evmd/app/interfaces.go similarity index 93% rename from evmd/interfaces.go rename to evmd/app/interfaces.go index 98a22647c..ed391bc14 100644 --- a/evmd/interfaces.go +++ b/evmd/app/interfaces.go @@ -1,4 +1,4 @@ -package evmd +package app import ( cmn "github.com/cosmos/evm/precompiles/common" diff --git a/evmd/precompiles.go b/evmd/app/precompiles.go similarity index 99% rename from evmd/precompiles.go rename to evmd/app/precompiles.go index cd7fe94b4..f557c2c40 100644 --- a/evmd/precompiles.go +++ b/evmd/app/precompiles.go @@ -1,4 +1,4 @@ -package evmd +package app import ( "fmt" diff --git a/evmd/upgrades.go b/evmd/app/upgrades.go similarity index 99% rename from evmd/upgrades.go rename to evmd/app/upgrades.go index 2413912c1..4bc34c7c2 100644 --- a/evmd/upgrades.go +++ b/evmd/app/upgrades.go @@ -1,4 +1,4 @@ -package evmd +package app import ( "context" diff --git a/evmd/cmd/evmd/config/activators.go b/evmd/cmd/evmd/config/activators.go deleted file mode 100644 index 136f1f2b8..000000000 --- a/evmd/cmd/evmd/config/activators.go +++ /dev/null @@ -1,15 +0,0 @@ -package config - -import ( - "github.com/ethereum/go-ethereum/core/vm" - - "github.com/cosmos/evm/evmd/eips" -) - -// cosmosEVMActivators defines a map of opcode modifiers associated -// with a key defining the corresponding EIP. -var cosmosEVMActivators = map[int]func(*vm.JumpTable){ - 0o000: eips.Enable0000, - 0o001: eips.Enable0001, - 0o002: eips.Enable0002, -} diff --git a/evmd/cmd/evmd/config/chain_id.go b/evmd/cmd/evmd/config/chain_id.go deleted file mode 100644 index 8de2e4543..000000000 --- a/evmd/cmd/evmd/config/chain_id.go +++ /dev/null @@ -1,29 +0,0 @@ -package config - -import ( - "path/filepath" - - "github.com/spf13/viper" - - "github.com/cosmos/cosmos-sdk/client/config" -) - -// GetChainIDFromHome returns the chain ID from the client configuration -// in the given home directory. -func GetChainIDFromHome(home string) (string, error) { - v := viper.New() - v.AddConfigPath(filepath.Join(home, "config")) - v.SetConfigName("client") - v.SetConfigType("toml") - - if err := v.ReadInConfig(); err != nil { - return "", err - } - conf := new(config.ClientConfig) - - if err := v.Unmarshal(conf); err != nil { - return "", err - } - - return conf.ChainID, nil -} diff --git a/evmd/cmd/evmd/config/config.go b/evmd/cmd/evmd/config/config.go deleted file mode 100644 index 2699ca0b6..000000000 --- a/evmd/cmd/evmd/config/config.go +++ /dev/null @@ -1,73 +0,0 @@ -package config - -import ( - "github.com/cosmos/evm/types" - evmtypes "github.com/cosmos/evm/x/vm/types" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// ChainsCoinInfo is a map of the chain id and its corresponding EvmCoinInfo -// that allows initializing the app with different coin info based on the -// chain id -var ChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ - EighteenDecimalsChainID: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, - }, - // SixDecimalsChainID provides a chain ID which is being set up with 6 decimals - SixDecimalsChainID: { - Denom: "utest", - ExtendedDenom: "atest", - DisplayDenom: "test", - Decimals: evmtypes.SixDecimals, - }, - // EVMChainID provides a chain ID used for internal testing - EVMChainID: { - Denom: "atest", - ExtendedDenom: "atest", - DisplayDenom: "test", - Decimals: evmtypes.EighteenDecimals, - }, -} - -const ( - // Bech32Prefix defines the Bech32 prefix used for accounts on the exemplary Cosmos EVM blockchain. - Bech32Prefix = "cosmos" - // Bech32PrefixAccAddr defines the Bech32 prefix of an account's address. - Bech32PrefixAccAddr = Bech32Prefix - // Bech32PrefixAccPub defines the Bech32 prefix of an account's public key. - Bech32PrefixAccPub = Bech32Prefix + sdk.PrefixPublic - // Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address. - Bech32PrefixValAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator - // Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key. - Bech32PrefixValPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic - // Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address. - Bech32PrefixConsAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus - // Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key. - Bech32PrefixConsPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic - // DisplayDenom defines the denomination displayed to users in client applications. - DisplayDenom = "atom" - // BaseDenom defines to the default denomination used in the Cosmos EVM example chain. - BaseDenom = "aatom" - // BaseDenomUnit defines the precision of the base denomination. - BaseDenomUnit = 18 - // EVMChainID defines the EIP-155 replay-protection chain id for the current ethereum chain config. - EVMChainID = 262144 -) - -// SetBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings. -func SetBech32Prefixes(config *sdk.Config) { - config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub) - config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub) - config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub) -} - -// SetBip44CoinType sets the global coin type to be used in hierarchical deterministic wallets. -func SetBip44CoinType(config *sdk.Config) { - config.SetCoinType(types.Bip44CoinType) - config.SetPurpose(sdk.Purpose) // Shared - config.SetFullFundraiserPath(types.BIP44HDPath) //nolint: staticcheck -} diff --git a/evmd/cmd/evmd/config/config_testing.go b/evmd/cmd/evmd/config/config_testing.go deleted file mode 100644 index 504d57427..000000000 --- a/evmd/cmd/evmd/config/config_testing.go +++ /dev/null @@ -1,15 +0,0 @@ -//go:build test -// +build test - -package config - -import ( - evmconfig "github.com/cosmos/evm/config" - testconfig "github.com/cosmos/evm/testutil/config" -) - -// EvmAppOptions allows to setup the global configuration -// for the Cosmos EVM chain. -func EvmAppOptions(chainID uint64) error { - return evmconfig.EvmAppOptionsWithConfigWithReset(chainID, testconfig.TestChainsCoinInfo, cosmosEVMActivators, true) -} diff --git a/evmd/cmd/evmd/config/constants.go b/evmd/cmd/evmd/config/constants.go deleted file mode 100644 index fb9bdbe4b..000000000 --- a/evmd/cmd/evmd/config/constants.go +++ /dev/null @@ -1,31 +0,0 @@ -package config - -const ( - // ExampleChainDenom is the denomination of the Cosmos EVM example chain's base coin. - ExampleChainDenom = "aatom" - - // ExampleDisplayDenom is the display denomination of the Cosmos EVM example chain's base coin. - ExampleDisplayDenom = "atom" - - // EighteenDecimalsChainID is the chain ID for the 18 decimals chain. - EighteenDecimalsChainID = 9001 - - // SixDecimalsChainID is the chain ID for the 6 decimals chain. - SixDecimalsChainID = 9002 - - // TwelveDecimalsChainID is the chain ID for the 12 decimals chain. - TwelveDecimalsChainID = 9003 - - // TwoDecimalsChainID is the chain ID for the 2 decimals chain. - TwoDecimalsChainID = 9004 - - CosmosChainID = 262144 - - // TestChainID1 is test chain IDs for IBC E2E test - TestChainID1 = 9005 - // TestChainID2 is test chain IDs for IBC E2E test - TestChainID2 = 9006 - - // WEVMOSContractMainnet is the WEVMOS contract address for mainnet - WEVMOSContractMainnet = "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517" -) diff --git a/evmd/cmd/evmd/config/evm_app_options.go b/evmd/cmd/evmd/config/evm_app_options.go deleted file mode 100644 index 07e73107d..000000000 --- a/evmd/cmd/evmd/config/evm_app_options.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build !test -// +build !test - -package config - -import ( - evmconfig "github.com/cosmos/evm/config" -) - -// EvmAppOptions allows to setup the global configuration -// for the Cosmos EVM chain. -func EvmAppOptions(chainID uint64) error { - return evmconfig.EvmAppOptionsWithConfig(chainID, ChainsCoinInfo, cosmosEVMActivators) -} diff --git a/evmd/cmd/evmd/main.go b/evmd/cmd/evmd/main.go deleted file mode 100644 index 0669a5891..000000000 --- a/evmd/cmd/evmd/main.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "fmt" - "os" - - "github.com/cosmos/evm/evmd/cmd/evmd/cmd" - evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" - - svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func main() { - setupSDKConfig() - - rootCmd := cmd.NewRootCmd() - if err := svrcmd.Execute(rootCmd, "evmd", evmdconfig.MustGetDefaultNodeHome()); err != nil { - fmt.Fprintln(rootCmd.OutOrStderr(), err) - os.Exit(1) - } -} - -func setupSDKConfig() { - config := sdk.GetConfig() - evmdconfig.SetBech32Prefixes(config) - config.Seal() -} diff --git a/evmd/cmd/evmd/cmd/root.go b/evmd/cmd/root.go similarity index 82% rename from evmd/cmd/evmd/cmd/root.go rename to evmd/cmd/root.go index 8a540cf0a..fa3ca3427 100644 --- a/evmd/cmd/evmd/cmd/root.go +++ b/evmd/cmd/root.go @@ -2,6 +2,7 @@ package cmd import ( "errors" + "github.com/cosmos/evm/x/vm/types" "io" "os" @@ -14,10 +15,12 @@ import ( cmtcli "github.com/cometbft/cometbft/libs/cli" dbm "github.com/cosmos/cosmos-db" - cosmosevmcmd "github.com/cosmos/evm/client" + clientkeys "github.com/cosmos/evm/client/keys" + "github.com/cosmos/evm/config" + evmconfig "github.com/cosmos/evm/config" cosmosevmkeyring "github.com/cosmos/evm/crypto/keyring" - "github.com/cosmos/evm/evmd" - evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" + evmdapp "github.com/cosmos/evm/evmd/app" + testnetcmd "github.com/cosmos/evm/evmd/cmd/testnet" cosmosevmserver "github.com/cosmos/evm/server" srvflags "github.com/cosmos/evm/server/flags" @@ -29,7 +32,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" - clientcfg "github.com/cosmos/cosmos-sdk/client/config" + sdkclientcfg "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/debug" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/pruning" @@ -51,20 +54,17 @@ import ( // NewRootCmd creates a new root command for evmd. It is called once in the // main function. func NewRootCmd() *cobra.Command { + config.SetupSdkConfig() // we "pre"-instantiate the application for getting the injected/configured encoding configuration // and the CLI options for the modules // add keyring to autocli opts - noOpEvmAppOptions := func(_ uint64) error { - return nil - } - tempApp := evmd.NewExampleApp( + + tempApp := evmdapp.NewExampleApp( log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}, - evmdconfig.EVMChainID, - noOpEvmAppOptions, ) encodingConfig := sdktestutil.TestEncodingConfig{ @@ -81,7 +81,7 @@ func NewRootCmd() *cobra.Command { WithInput(os.Stdin). WithAccountRetriever(authtypes.AccountRetriever{}). WithBroadcastMode(flags.FlagBroadcastMode). - WithHomeDir(evmdconfig.MustGetDefaultNodeHome()). + WithHomeDir(evmconfig.MustGetDefaultNodeHome()). WithViper(""). // In simapp, we don't use any prefix for env variables. // Cosmos EVM specific setup WithKeyringOptions(cosmosevmkeyring.Option()). @@ -101,7 +101,7 @@ func NewRootCmd() *cobra.Command { return err } - initClientCtx, err = clientcfg.ReadFromClientConfig(initClientCtx) + initClientCtx, err = sdkclientcfg.ReadFromClientConfig(initClientCtx) if err != nil { return err } @@ -130,29 +130,27 @@ func NewRootCmd() *cobra.Command { return err } - customAppTemplate, customAppConfig := evmdconfig.InitAppConfig(evmdconfig.BaseDenom, evmdconfig.EVMChainID) + customAppTemplate, customAppConfig := evmconfig.InitAppConfig(types.DefaultEvmCoinInfo.GetDenom(), types.DefaultEvmChainID) customTMConfig := initCometConfig() - return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig) + return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, *customAppConfig, customTMConfig) }, } initRootCmd(rootCmd, tempApp) + if initClientCtx.ChainID == "" { + // if the chain id is not set in client.toml, populate it with the default evm chain id + initClientCtx = initClientCtx.WithChainID(types.DefaultChainID) + } + initClientCtx, _ = sdkclientcfg.ReadFromClientConfig(initClientCtx) + autoCliOpts := tempApp.AutoCliOpts() - initClientCtx, _ = clientcfg.ReadFromClientConfig(initClientCtx) autoCliOpts.ClientCtx = initClientCtx - if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil { panic(err) } - if initClientCtx.ChainID != "" { - if err := evmdconfig.EvmAppOptions(evmdconfig.EVMChainID); err != nil { - panic(err) - } - } - return rootCmd } @@ -168,11 +166,11 @@ func initCometConfig() *cmtcfg.Config { return cfg } -func initRootCmd(rootCmd *cobra.Command, evmApp *evmd.EVMD) { +func initRootCmd(rootCmd *cobra.Command, evmApp *evmdapp.EVMD) { cfg := sdk.GetConfig() cfg.Seal() - defaultNodeHome := evmdconfig.MustGetDefaultNodeHome() + defaultNodeHome := evmconfig.MustGetDefaultNodeHome() sdkAppCreator := func(l log.Logger, d dbm.DB, w io.Writer, ao servertypes.AppOptions) servertypes.Application { return newApp(l, d, w, ao) } @@ -184,7 +182,7 @@ func initRootCmd(rootCmd *cobra.Command, evmApp *evmd.EVMD) { confixcmd.ConfigCommand(), pruning.Cmd(sdkAppCreator, defaultNodeHome), snapshot.Cmd(sdkAppCreator), - NewTestnetCmd(evmApp.BasicModuleManager, banktypes.GenesisBalancesIterator{}, appCreator{}), + testnetcmd.NewTestnetCmd(evmApp.BasicModuleManager, banktypes.GenesisBalancesIterator{}, evmdapp.AppCreator{}), ) // add Cosmos EVM' flavored TM commands to start server, etc. @@ -197,7 +195,7 @@ func initRootCmd(rootCmd *cobra.Command, evmApp *evmd.EVMD) { // add Cosmos EVM key commands rootCmd.AddCommand( - cosmosevmcmd.KeyCommands(defaultNodeHome, true), + clientkeys.KeyCommands(defaultNodeHome, true), ) // add keybase, auxiliary RPC, query, genesis, and tx child commands @@ -286,7 +284,7 @@ func newApp( } // get the chain id - chainID, err := getChainIDFromOpts(appOpts) + chainID, err := evmconfig.GetChainID(appOpts) if err != nil { panic(err) } @@ -316,13 +314,7 @@ func newApp( baseapp.SetChainID(chainID), } - return evmd.NewExampleApp( - logger, db, traceStore, true, - appOpts, - evmdconfig.EVMChainID, - evmdconfig.EvmAppOptions, - baseappOptions..., - ) + return evmdapp.NewExampleApp(logger, db, traceStore, true, appOpts, baseappOptions...) } // appExport creates a new application (optionally at a given height) and exports state. @@ -336,7 +328,7 @@ func appExport( appOpts servertypes.AppOptions, modulesToExport []string, ) (servertypes.ExportedApp, error) { - var exampleApp *evmd.EVMD + var exampleApp *evmdapp.EVMD // this check is necessary as we use the flag in x/upgrade. // we can exit more gracefully by checking the flag here. @@ -355,38 +347,20 @@ func appExport( appOpts = viperAppOpts // get the chain id - chainID, err := getChainIDFromOpts(appOpts) + chainID, err := evmconfig.GetChainID(appOpts) if err != nil { return servertypes.ExportedApp{}, err } if height != -1 { - exampleApp = evmd.NewExampleApp(logger, db, traceStore, false, appOpts, evmdconfig.EVMChainID, evmdconfig.EvmAppOptions, baseapp.SetChainID(chainID)) + exampleApp = evmdapp.NewExampleApp(logger, db, traceStore, false, appOpts, baseapp.SetChainID(chainID)) if err := exampleApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } else { - exampleApp = evmd.NewExampleApp(logger, db, traceStore, true, appOpts, evmdconfig.EVMChainID, evmdconfig.EvmAppOptions, baseapp.SetChainID(chainID)) + exampleApp = evmdapp.NewExampleApp(logger, db, traceStore, true, appOpts, baseapp.SetChainID(chainID)) } return exampleApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) } - -// getChainIDFromOpts returns the chain Id from app Opts -// It first tries to get from the chainId flag, if not available -// it will load from home -func getChainIDFromOpts(appOpts servertypes.AppOptions) (chainID string, err error) { - // Get the chain Id from appOpts - chainID = cast.ToString(appOpts.Get(flags.FlagChainID)) - if chainID == "" { - // If not available load from home - homeDir := cast.ToString(appOpts.Get(flags.FlagHome)) - chainID, err = evmdconfig.GetChainIDFromHome(homeDir) - if err != nil { - return "", err - } - } - - return -} diff --git a/evmd/cmd/evmd/cmd/testnet.go b/evmd/cmd/testnet/testnet.go similarity index 96% rename from evmd/cmd/evmd/cmd/testnet.go rename to evmd/cmd/testnet/testnet.go index c90690cb0..5d6985943 100644 --- a/evmd/cmd/evmd/cmd/testnet.go +++ b/evmd/cmd/testnet/testnet.go @@ -1,9 +1,10 @@ -package cmd +package testnet import ( "bufio" "encoding/json" "fmt" + types2 "github.com/cosmos/evm/x/vm/types" "net" "os" "path/filepath" @@ -11,8 +12,6 @@ import ( cosmosevmhd "github.com/cosmos/evm/crypto/hd" cosmosevmkeyring "github.com/cosmos/evm/crypto/keyring" - "github.com/cosmos/evm/evmd" - evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" cosmosevmserverconfig "github.com/cosmos/evm/server/config" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -20,6 +19,8 @@ import ( cmtconfig "github.com/cometbft/cometbft/config" "github.com/cometbft/cometbft/types" tmtime "github.com/cometbft/cometbft/types/time" + "github.com/cosmos/evm/config" + evmdapp "github.com/cosmos/evm/evmd/app" dbm "github.com/cosmos/cosmos-db" @@ -74,7 +75,7 @@ var mnemonics = []string{ "doll midnight silk carpet brush boring pluck office gown inquiry duck chief aim exit gain never tennis crime fragile ship cloud surface exotic patch", } -type UnsafeStartValidatorCmdCreator func(ac appCreator) *cobra.Command +type UnsafeStartValidatorCmdCreator func(ac evmdapp.AppCreator) *cobra.Command type initArgs struct { algo string @@ -125,7 +126,7 @@ func addTestnetFlagsToCmd(cmd *cobra.Command) { // 1. run an in-process testnet or // 2. initialize validator configuration files for running a multi-validator testnet in a separate process or // 3. update application and consensus state with the local validator info -func NewTestnetCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator, appCreator appCreator) *cobra.Command { +func NewTestnetCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator, appCreator evmdapp.AppCreator) *cobra.Command { testnetCmd := &cobra.Command{ Use: "testnet", Short: "subcommands for starting or configuring local testnets", @@ -268,8 +269,8 @@ func initTestnetFiles( appConfig.Telemetry.EnableHostnameLabel = false appConfig.Telemetry.GlobalLabels = [][]string{{"chain_id", args.chainID}} evm := cosmosevmserverconfig.DefaultEVMConfig() - evm.EVMChainID = evmdconfig.EVMChainID - evmCfg := evmdconfig.EVMAppConfig{ + evm.EVMChainID = types2.DefaultEvmChainID + evmCfg := config.EVMAppConfig{ Config: *appConfig, EVM: *evm, JSONRPC: *cosmosevmserverconfig.DefaultJSONRPCConfig(), @@ -441,7 +442,7 @@ func initTestnetFiles( return err } - srvconfig.SetConfigTemplate(evmdconfig.EVMAppTemplate) + srvconfig.SetConfigTemplate(config.EVMAppTemplate) srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config", "app.toml"), evmCfg) } @@ -677,36 +678,34 @@ func NewTestNetworkFixture() network.TestFixture { } defer os.RemoveAll(dir) - app := evmd.NewExampleApp( + newApp := evmdapp.NewExampleApp( log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}, - evmdconfig.EVMChainID, - evmdconfig.EvmAppOptions, + nil, ) appCtr := func(val network.ValidatorI) servertypes.Application { - return evmd.NewExampleApp( + return evmdapp.NewExampleApp( log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}, - evmdconfig.EVMChainID, - evmdconfig.EvmAppOptions, + nil, ) } return network.TestFixture{ AppConstructor: appCtr, - GenesisState: app.DefaultGenesis(), + GenesisState: newApp.DefaultGenesis(), EncodingConfig: moduletestutil.TestEncodingConfig{ - InterfaceRegistry: app.InterfaceRegistry(), - Codec: app.AppCodec(), - TxConfig: app.GetTxConfig(), - Amino: app.LegacyAmino(), + InterfaceRegistry: newApp.InterfaceRegistry(), + Codec: newApp.AppCodec(), + TxConfig: newApp.GetTxConfig(), + Amino: newApp.LegacyAmino(), }, } } diff --git a/evmd/config/client.toml b/evmd/config/client.toml deleted file mode 100644 index 2a8569c81..000000000 --- a/evmd/config/client.toml +++ /dev/null @@ -1,17 +0,0 @@ -# This is a TOML config file. -# For more information, see https://github.com/toml-lang/toml - -############################################################################### -### Client Configuration ### -############################################################################### - -# The network chain ID -chain-id = "" -# The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) -keyring-backend = "os" -# CLI output format (text|json) -output = "text" -# : to CometBFT RPC interface for this chain -node = "tcp://localhost:26657" -# Transaction broadcasting mode (sync|async) -broadcast-mode = "sync" diff --git a/evmd/main.go b/evmd/main.go new file mode 100644 index 000000000..8c38275e4 --- /dev/null +++ b/evmd/main.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "os" + + "github.com/cosmos/evm/config" + "github.com/cosmos/evm/evmd/cmd" + + svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" +) + +func main() { + rootCmd := cmd.NewRootCmd() + if err := svrcmd.Execute(rootCmd, "evmd", config.MustGetDefaultNodeHome()); err != nil { + fmt.Fprintln(rootCmd.OutOrStderr(), err) + os.Exit(1) + } +} diff --git a/evmd/eips/eips_test.go b/evmd/tests/eips/eips_test.go similarity index 98% rename from evmd/eips/eips_test.go rename to evmd/tests/eips/eips_test.go index 512881342..8e0cc7ae4 100644 --- a/evmd/eips/eips_test.go +++ b/evmd/tests/eips/eips_test.go @@ -1,4 +1,4 @@ -package eips_test +package eips import ( "fmt" @@ -13,9 +13,9 @@ import ( //nolint:revive // dot imports are fine for Ginkgo . "github.com/onsi/gomega" - "github.com/cosmos/evm/evmd/eips/testdata" + "github.com/cosmos/evm/config/eips" + "github.com/cosmos/evm/evmd/tests/eips/testdata" "github.com/cosmos/evm/evmd/tests/integration" - testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -107,7 +107,7 @@ func RunTests(t *testing.T, create network.CreateEvmApp, options ...network.Conf }) It("should enable the new EIP", func() { - testconfig.Multiplier = eipMultiplier + eips.Multiplier = eipMultiplier newEIP := 0o000 qRes, err := gh.GetEvmParams() @@ -259,7 +259,7 @@ func RunTests(t *testing.T, create network.CreateEvmApp, options ...network.Conf Expect(counter.String()).To(Equal(fmt.Sprintf("%d", initialCounterValue+1)), "counter is not correct") }) It("should enable the new EIP", func() { - testconfig.Multiplier = eipMultiplier + eips.Multiplier = eipMultiplier newEIP := 0o001 qRes, err := gh.GetEvmParams() @@ -403,7 +403,7 @@ func RunTests(t *testing.T, create network.CreateEvmApp, options ...network.Conf }) It("should enable the new EIP", func() { - testconfig.SstoreConstantGas = constantGas + eips.SstoreConstantGas = constantGas newEIP := 0o002 qRes, err := gh.GetEvmParams() diff --git a/evmd/eips/testdata/Counter.json b/evmd/tests/eips/testdata/Counter.json similarity index 100% rename from evmd/eips/testdata/Counter.json rename to evmd/tests/eips/testdata/Counter.json diff --git a/evmd/eips/testdata/Counter.sol b/evmd/tests/eips/testdata/Counter.sol similarity index 100% rename from evmd/eips/testdata/Counter.sol rename to evmd/tests/eips/testdata/Counter.sol diff --git a/evmd/eips/testdata/CounterFactory.json b/evmd/tests/eips/testdata/CounterFactory.json similarity index 100% rename from evmd/eips/testdata/CounterFactory.json rename to evmd/tests/eips/testdata/CounterFactory.json diff --git a/evmd/eips/testdata/CounterFactory.sol b/evmd/tests/eips/testdata/CounterFactory.sol similarity index 100% rename from evmd/eips/testdata/CounterFactory.sol rename to evmd/tests/eips/testdata/CounterFactory.sol diff --git a/evmd/eips/testdata/contracts.go b/evmd/tests/eips/testdata/contracts.go similarity index 100% rename from evmd/eips/testdata/contracts.go rename to evmd/tests/eips/testdata/contracts.go diff --git a/evmd/tests/ibc/ibc_middleware_test.go b/evmd/tests/ibc/ibc_middleware_test.go index f704a3704..026b42c58 100644 --- a/evmd/tests/ibc/ibc_middleware_test.go +++ b/evmd/tests/ibc/ibc_middleware_test.go @@ -11,7 +11,7 @@ import ( testifysuite "github.com/stretchr/testify/suite" "github.com/cosmos/evm/contracts" - "github.com/cosmos/evm/evmd" + evmdapp "github.com/cosmos/evm/evmd/app" "github.com/cosmos/evm/evmd/tests/integration" "github.com/cosmos/evm/ibc" "github.com/cosmos/evm/testutil" @@ -381,7 +381,7 @@ func (suite *MiddlewareTestSuite) TestOnRecvPacketWithCallback() { ) // Validate successful callback - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) singleTokenRepresentation, err := types.NewTokenPairSTRv2(voucherDenom) suite.Require().NoError(err) erc20Contract := singleTokenRepresentation.GetERC20Contract() @@ -542,7 +542,7 @@ func (suite *MiddlewareTestSuite) TestOnRecvPacket() { voucherDenom := testutil.GetVoucherDenomFromPacketData(data, packet.GetDestPort(), packet.GetDestChannel()) - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) voucherCoin := evmApp.BankKeeper.GetBalance(ctxA, receiver, voucherDenom) suite.Require().Equal(sendAmt.String(), voucherCoin.Amount.String()) @@ -574,7 +574,7 @@ func (suite *MiddlewareTestSuite) TestOnRecvPacketNativeErc20() { nativeErc20 := SetupNativeErc20(suite.T(), suite.evmChainA, suite.evmChainA.SenderAccounts[0]) evmCtx := suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) // Scenario: Native ERC20 token transfer from evmChainA to chainB timeoutHeight := clienttypes.NewHeight(1, 110) @@ -998,7 +998,7 @@ func (suite *MiddlewareTestSuite) TestOnAcknowledgementPacketWithCallback() { suite.SetupTest() ctxA := suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) bondDenom, err := evmApp.StakingKeeper.BondDenom(ctxA) suite.Require().NoError(err) @@ -1226,7 +1226,7 @@ func (suite *MiddlewareTestSuite) TestOnAcknowledgementPacket() { suite.SetupTest() ctxA := suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) bondDenom, err := evmApp.StakingKeeper.BondDenom(ctxA) suite.Require().NoError(err) @@ -1378,7 +1378,7 @@ func (suite *MiddlewareTestSuite) TestOnAcknowledgementPacketNativeErc20() { nativeErc20 := SetupNativeErc20(suite.T(), suite.evmChainA, suite.evmChainA.SenderAccounts[0]) evmCtx := suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) timeoutHeight := clienttypes.NewHeight(1, 110) path := suite.path @@ -1507,7 +1507,7 @@ func (suite *MiddlewareTestSuite) TestOnTimeoutPacket() { suite.SetupTest() ctxA := suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) bondDenom, err := evmApp.StakingKeeper.BondDenom(ctxA) suite.Require().NoError(err) @@ -1825,7 +1825,7 @@ func (suite *MiddlewareTestSuite) TestOnTimeoutPacketWithCallback() { suite.SetupTest() ctxA := suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) bondDenom, err := evmApp.StakingKeeper.BondDenom(ctxA) suite.Require().NoError(err) @@ -2025,7 +2025,7 @@ func (suite *MiddlewareTestSuite) TestOnTimeoutPacketNativeErc20() { nativeErc20 := SetupNativeErc20(suite.T(), suite.evmChainA, suite.evmChainA.SenderAccounts[0]) evmCtx := suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) timeoutHeight := clienttypes.NewHeight(1, 110) path := suite.path diff --git a/evmd/tests/ibc/ics20_precompile_transfer_test.go b/evmd/tests/ibc/ics20_precompile_transfer_test.go index cae1ee3cb..85726f5b5 100644 --- a/evmd/tests/ibc/ics20_precompile_transfer_test.go +++ b/evmd/tests/ibc/ics20_precompile_transfer_test.go @@ -13,7 +13,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/stretchr/testify/suite" - "github.com/cosmos/evm/evmd" + evmdapp "github.com/cosmos/evm/evmd/app" "github.com/cosmos/evm/evmd/tests/integration" "github.com/cosmos/evm/precompiles/ics20" chainutil "github.com/cosmos/evm/testutil" @@ -45,14 +45,14 @@ func (suite *ICS20TransferTestSuite) SetupTest() { suite.chainA = suite.coordinator.GetChain(evmibctesting.GetEvmChainID(1)) suite.chainB = suite.coordinator.GetChain(evmibctesting.GetEvmChainID(2)) - evmAppA := suite.chainA.App.(*evmd.EVMD) + evmAppA := suite.chainA.App.(*evmdapp.EVMD) suite.chainAPrecompile, _ = ics20.NewPrecompile( evmAppA.BankKeeper, *evmAppA.StakingKeeper, evmAppA.TransferKeeper, evmAppA.IBCKeeper.ChannelKeeper, ) - evmAppB := suite.chainB.App.(*evmd.EVMD) + evmAppB := suite.chainB.App.(*evmdapp.EVMD) suite.chainBPrecompile, _ = ics20.NewPrecompile( evmAppB.BankKeeper, *evmAppB.StakingKeeper, @@ -81,7 +81,7 @@ func (suite *ICS20TransferTestSuite) TestHandleMsgTransfer() { { "transfer single denom", func(_ evmibctesting.SenderAccount) { - evmAppA := suite.chainA.App.(*evmd.EVMD) + evmAppA := suite.chainA.App.(*evmdapp.EVMD) sourceDenomToTransfer, err = evmAppA.StakingKeeper.BondDenom(suite.chainA.GetContext()) msgAmount = evmibctesting.DefaultCoinAmount }, @@ -90,7 +90,7 @@ func (suite *ICS20TransferTestSuite) TestHandleMsgTransfer() { "transfer amount larger than int64", func(_ evmibctesting.SenderAccount) { var ok bool - evmAppA := suite.chainA.App.(*evmd.EVMD) + evmAppA := suite.chainA.App.(*evmdapp.EVMD) sourceDenomToTransfer, err = evmAppA.StakingKeeper.BondDenom(suite.chainA.GetContext()) msgAmount, ok = sdkmath.NewIntFromString("9223372036854775808") // 2^63 (one above int64) suite.Require().True(ok) @@ -99,7 +99,7 @@ func (suite *ICS20TransferTestSuite) TestHandleMsgTransfer() { { "transfer entire balance", func(_ evmibctesting.SenderAccount) { - evmAppA := suite.chainA.App.(*evmd.EVMD) + evmAppA := suite.chainA.App.(*evmdapp.EVMD) sourceDenomToTransfer, err = evmAppA.StakingKeeper.BondDenom(suite.chainA.GetContext()) msgAmount = transfertypes.UnboundedSpendLimit() }, @@ -133,7 +133,7 @@ func (suite *ICS20TransferTestSuite) TestHandleMsgTransfer() { tc.malleate(senderAccount) - evmAppA := suite.chainA.App.(*evmd.EVMD) + evmAppA := suite.chainA.App.(*evmdapp.EVMD) GetBalance := func(addr sdk.AccAddress) sdk.Coin { ctx := suite.chainA.GetContext() @@ -214,7 +214,7 @@ func (suite *ICS20TransferTestSuite) TestHandleMsgTransfer() { suite.Require().Equal(transferAmount.String(), chainAEscrowBalance.Amount.String()) // check that voucher exists on chain B - evmAppB := suite.chainB.App.(*evmd.EVMD) + evmAppB := suite.chainB.App.(*evmdapp.EVMD) chainBDenom := transfertypes.NewDenom(originalCoin.Denom, traceAToB) chainBBalance := evmAppB.BankKeeper.GetBalance( suite.chainB.GetContext(), diff --git a/evmd/tests/ibc/transfer_test.go b/evmd/tests/ibc/transfer_test.go index a386e1e68..e868a0d05 100644 --- a/evmd/tests/ibc/transfer_test.go +++ b/evmd/tests/ibc/transfer_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/suite" - "github.com/cosmos/evm/evmd" + evmdapp "github.com/cosmos/evm/evmd/app" "github.com/cosmos/evm/evmd/tests/integration" evmibctesting "github.com/cosmos/evm/testutil/ibc" "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" @@ -95,7 +95,7 @@ func (suite *TransferTestSuite) TestHandleMsgTransfer() { senderAddr := senderAccount.SenderAccount.GetAddress() tc.malleate() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) sourceDenomToTransfer, err = evmApp.StakingKeeper.BondDenom(suite.evmChainA.GetContext()) suite.Require().NoError(err) senderBalance := evmApp.BankKeeper.GetBalance(suite.evmChainA.GetContext(), senderAddr, sourceDenomToTransfer) diff --git a/evmd/tests/ibc/v2_ibc_middleware_test.go b/evmd/tests/ibc/v2_ibc_middleware_test.go index 23f25c557..286741119 100644 --- a/evmd/tests/ibc/v2_ibc_middleware_test.go +++ b/evmd/tests/ibc/v2_ibc_middleware_test.go @@ -10,7 +10,7 @@ import ( "github.com/ethereum/go-ethereum/common" testifysuite "github.com/stretchr/testify/suite" - "github.com/cosmos/evm/evmd" + evmdapp "github.com/cosmos/evm/evmd/app" "github.com/cosmos/evm/evmd/tests/integration" "github.com/cosmos/evm/testutil" evmibctesting "github.com/cosmos/evm/testutil/ibc" @@ -144,7 +144,7 @@ func (suite *MiddlewareV2TestSuite) TestOnSendPacket() { suite.Run(tc.name, func() { suite.SetupTest() ctx = suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) bondDenom, err := evmApp.StakingKeeper.BondDenom(ctx) suite.Require().NoError(err) packetData = transfertypes.NewFungibleTokenPacketData( @@ -248,7 +248,7 @@ func (suite *MiddlewareV2TestSuite) TestOnRecvPacket() { tc.malleate() } - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) // erc20 module is routed as top level middleware transferStack := evmApp.GetIBCKeeper().ChannelKeeperV2.Router.Route(ibctesting.TransferPort) sourceClient := suite.pathBToA.EndpointB.ClientID @@ -323,7 +323,7 @@ func (suite *MiddlewareV2TestSuite) TestOnRecvPacketNativeERC20() { sendAmt := math.NewIntFromBigInt(nativeErc20.InitialBal) evmCtx := suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) // MOCK erc20 native coin transfer from chainA to chainB // 1: Convert erc20 tokens to native erc20 coins for sending through IBC. _, err := evmApp.Erc20Keeper.ConvertERC20( @@ -482,7 +482,7 @@ func (suite *MiddlewareV2TestSuite) TestOnAcknowledgementPacket() { suite.Run(tc.name, func() { suite.SetupTest() ctx = suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) bondDenom, err := evmApp.StakingKeeper.BondDenom(ctx) suite.Require().NoError(err) sendAmt := ibctesting.DefaultCoinAmount @@ -607,7 +607,7 @@ func (suite *MiddlewareV2TestSuite) TestOnAcknowledgementPacketNativeErc20() { sendAmt := math.NewIntFromBigInt(nativeErc20.InitialBal) evmCtx := suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) // MOCK erc20 native coin transfer from chainA to chainB // 1: Convert erc20 tokens to native erc20 coins for sending through IBC. @@ -744,7 +744,7 @@ func (suite *MiddlewareV2TestSuite) TestOnTimeoutPacket() { suite.Run(tc.name, func() { suite.SetupTest() ctx = suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) bondDenom, err := evmApp.StakingKeeper.BondDenom(ctx) suite.Require().NoError(err) packetData = transfertypes.NewFungibleTokenPacketData( @@ -841,7 +841,7 @@ func (suite *MiddlewareV2TestSuite) TestOnTimeoutPacketNativeErc20() { sendAmt := math.NewIntFromBigInt(nativeErc20.InitialBal) evmCtx := suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) // MOCK erc20 native coin transfer from chainA to chainB // 1: Convert erc20 tokens to native erc20 coins for sending through IBC. diff --git a/evmd/tests/ibc/v2_ics20_precompile_transfer_test.go b/evmd/tests/ibc/v2_ics20_precompile_transfer_test.go index 740f8c3d8..06220775c 100644 --- a/evmd/tests/ibc/v2_ics20_precompile_transfer_test.go +++ b/evmd/tests/ibc/v2_ics20_precompile_transfer_test.go @@ -14,7 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/stretchr/testify/suite" - "github.com/cosmos/evm/evmd" + evmdapp "github.com/cosmos/evm/evmd/app" "github.com/cosmos/evm/evmd/tests/integration" "github.com/cosmos/evm/precompiles/ics20" chainutil "github.com/cosmos/evm/testutil" @@ -46,14 +46,14 @@ func (suite *ICS20TransferV2TestSuite) SetupTest() { suite.chainA = suite.coordinator.GetChain(evmibctesting.GetEvmChainID(1)) suite.chainB = suite.coordinator.GetChain(evmibctesting.GetEvmChainID(2)) - evmAppA := suite.chainA.App.(*evmd.EVMD) + evmAppA := suite.chainA.App.(*evmdapp.EVMD) suite.chainAPrecompile, _ = ics20.NewPrecompile( evmAppA.BankKeeper, *evmAppA.StakingKeeper, evmAppA.TransferKeeper, evmAppA.IBCKeeper.ChannelKeeper, ) - evmAppB := suite.chainB.App.(*evmd.EVMD) + evmAppB := suite.chainB.App.(*evmdapp.EVMD) suite.chainBPrecompile, _ = ics20.NewPrecompile( evmAppB.BankKeeper, *evmAppB.StakingKeeper, @@ -81,7 +81,7 @@ func (suite *ICS20TransferV2TestSuite) TestHandleMsgTransfer() { { "transfer single denom", func(_ evmibctesting.SenderAccount) { - evmAppA := suite.chainA.App.(*evmd.EVMD) + evmAppA := suite.chainA.App.(*evmdapp.EVMD) sourceDenomToTransfer, err = evmAppA.StakingKeeper.BondDenom(suite.chainA.GetContext()) msgAmount = evmibctesting.DefaultCoinAmount }, @@ -90,7 +90,7 @@ func (suite *ICS20TransferV2TestSuite) TestHandleMsgTransfer() { "transfer amount larger than int64", func(_ evmibctesting.SenderAccount) { var ok bool - evmAppA := suite.chainA.App.(*evmd.EVMD) + evmAppA := suite.chainA.App.(*evmdapp.EVMD) sourceDenomToTransfer, err = evmAppA.StakingKeeper.BondDenom(suite.chainA.GetContext()) msgAmount, ok = sdkmath.NewIntFromString("9223372036854775808") // 2^63 (one above int64) suite.Require().True(ok) @@ -99,7 +99,7 @@ func (suite *ICS20TransferV2TestSuite) TestHandleMsgTransfer() { { "transfer entire balance", func(_ evmibctesting.SenderAccount) { - evmAppA := suite.chainA.App.(*evmd.EVMD) + evmAppA := suite.chainA.App.(*evmdapp.EVMD) sourceDenomToTransfer, err = evmAppA.StakingKeeper.BondDenom(suite.chainA.GetContext()) msgAmount = transfertypes.UnboundedSpendLimit() }, @@ -134,7 +134,7 @@ func (suite *ICS20TransferV2TestSuite) TestHandleMsgTransfer() { tc.malleate(senderAccount) - evmAppA := suite.chainA.App.(*evmd.EVMD) + evmAppA := suite.chainA.App.(*evmdapp.EVMD) GetBalance := func(addr sdk.AccAddress) sdk.Coin { ctx := suite.chainA.GetContext() @@ -220,7 +220,7 @@ func (suite *ICS20TransferV2TestSuite) TestHandleMsgTransfer() { suite.Require().True(transferAmount.Equal(chainAEscrowBalance.Amount)) // check that voucher exists on chain B - evmAppB := suite.chainB.App.(*evmd.EVMD) + evmAppB := suite.chainB.App.(*evmdapp.EVMD) chainBDenom := transfertypes.NewDenom(originalCoin.Denom, traceAToB) chainBBalance := evmAppB.BankKeeper.GetBalance( suite.chainB.GetContext(), diff --git a/evmd/tests/ibc/v2_transfer_test.go b/evmd/tests/ibc/v2_transfer_test.go index efcf5fc94..0da239db7 100644 --- a/evmd/tests/ibc/v2_transfer_test.go +++ b/evmd/tests/ibc/v2_transfer_test.go @@ -19,7 +19,7 @@ import ( testifysuite "github.com/stretchr/testify/suite" - "github.com/cosmos/evm/evmd" + evmdapp "github.com/cosmos/evm/evmd/app" "github.com/cosmos/evm/evmd/tests/integration" evmibctesting "github.com/cosmos/evm/testutil/ibc" "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" @@ -150,7 +150,7 @@ func (suite *TransferTestSuiteV2) TestOnSendPacket() { suite.Run(tc.name, func() { suite.SetupTest() // reset - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) originalBalance := evmApp.BankKeeper.GetBalance( suite.evmChainA.GetContext(), suite.evmChainA.SenderAccount.GetAddress(), @@ -312,7 +312,7 @@ func (suite *TransferTestSuiteV2) TestOnRecvPacket() { ) ctx := suite.evmChainA.GetContext() - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) cbs := evmApp.GetIBCKeeper().ChannelKeeperV2.Router.Route(evmibctesting.TransferPort) // malleate payload after it has been sent but before OnRecvPacket callback is called @@ -379,7 +379,7 @@ func (suite *TransferTestSuiteV2) TestOnAckPacket() { suite.Run(tc.name, func() { suite.SetupTest() // reset - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) originalBalance := evmApp.BankKeeper.GetBalance(suite.evmChainA.GetContext(), suite.evmChainA.SenderAccount.GetAddress(), tc.sourceDenomToTransfer) timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) //nolint:gosec // G115 @@ -486,7 +486,7 @@ func (suite *TransferTestSuiteV2) TestOnTimeoutPacket() { suite.Run(tc.name, func() { suite.SetupTest() // reset - evmApp := suite.evmChainA.App.(*evmd.EVMD) + evmApp := suite.evmChainA.App.(*evmdapp.EVMD) originalBalance := evmApp.BankKeeper.GetBalance(suite.evmChainA.GetContext(), suite.evmChainA.SenderAccount.GetAddress(), tc.sourceDenomToTransfer) timeoutTimestamp := uint64(suite.chainB.GetContext().BlockTime().Add(time.Hour).Unix()) //nolint:gosec // G115 diff --git a/evmd/tests/integration/create_app.go b/evmd/tests/integration/create_app.go index fd05c278f..4166b1fae 100644 --- a/evmd/tests/integration/create_app.go +++ b/evmd/tests/integration/create_app.go @@ -5,10 +5,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/evm" - "github.com/cosmos/evm/evmd" - "github.com/cosmos/evm/evmd/cmd/evmd/config" - testconfig "github.com/cosmos/evm/testutil/config" - "github.com/cosmos/evm/testutil/constants" + evmdapp "github.com/cosmos/evm/evmd/app" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" ibctesting "github.com/cosmos/ibc-go/v10/testing" @@ -19,6 +16,7 @@ import ( simutils "github.com/cosmos/cosmos-sdk/testutil/sims" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + testconfig "github.com/cosmos/evm/testutil/config" ) // CreateEvmd creates an evm app for regular integration tests (non-mempool) @@ -36,29 +34,19 @@ func CreateEvmd(chainID string, evmChainID uint64, customBaseAppOptions ...func( baseAppOptions := append(customBaseAppOptions, baseapp.SetChainID(chainID)) - return evmd.NewExampleApp( - logger, - db, - nil, - loadLatest, - appOptions, - evmChainID, - testconfig.EvmAppOptions, - baseAppOptions..., - ) + return evmdapp.NewExampleApp(logger, db, nil, loadLatest, appOptions, baseAppOptions...) } // SetupEvmd initializes a new evmd app with default genesis state. // It is used in IBC integration tests to create a new evmd app instance. func SetupEvmd() (ibctesting.TestingApp, map[string]json.RawMessage) { - app := evmd.NewExampleApp( + app := evmdapp.NewExampleApp( log.NewNopLogger(), dbm.NewMemDB(), nil, true, simutils.EmptyAppOptions{}, - constants.ExampleEIP155ChainID, - testconfig.EvmAppOptions, + nil, ) // disable base fee for testing genesisState := app.DefaultGenesis() @@ -66,10 +54,10 @@ func SetupEvmd() (ibctesting.TestingApp, map[string]json.RawMessage) { fmGen.Params.NoBaseFee = true genesisState[feemarkettypes.ModuleName] = app.AppCodec().MustMarshalJSON(fmGen) stakingGen := stakingtypes.DefaultGenesisState() - stakingGen.Params.BondDenom = config.ExampleChainDenom + stakingGen.Params.BondDenom = testconfig.ExampleAttoDenom genesisState[stakingtypes.ModuleName] = app.AppCodec().MustMarshalJSON(stakingGen) mintGen := minttypes.DefaultGenesisState() - mintGen.Params.MintDenom = config.ExampleChainDenom + mintGen.Params.MintDenom = testconfig.ExampleAttoDenom genesisState[minttypes.ModuleName] = app.AppCodec().MustMarshalJSON(mintGen) return app, genesisState diff --git a/evmd/tests/integration/x_vm_test.go b/evmd/tests/integration/x_vm_test.go index c1aec6e9f..2ef9a4e72 100644 --- a/evmd/tests/integration/x_vm_test.go +++ b/evmd/tests/integration/x_vm_test.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/evm/server/config" "github.com/cosmos/evm/tests/integration/x/vm" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/network" "github.com/cosmos/evm/testutil/keyring" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" @@ -32,25 +33,24 @@ func BenchmarkGasEstimation(b *testing.B) { // gh := grpc.NewIntegrationHandler(nw) // tf := factory.New(nw, gh) - chainConfig := types.DefaultChainConfig(nw.GetEIP155ChainID().Uint64()) + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + chainConfig := types.DefaultChainConfig(nw.GetEIP155ChainID().Uint64(), coinInfo) // get the denom and decimals set on chain initialization // because we'll need to set them again when resetting the chain config - denom := types.GetEVMCoinDenom() - extendedDenom := types.GetEVMCoinExtendedDenom() displayDenom := types.GetEVMCoinDisplayDenom() decimals := types.GetEVMCoinDecimals() + extendedDecimals := types.GetEVMCoinExtendedDecimals() - configurator := types.NewEVMConfigurator() - configurator.ResetTestConfig() - err := configurator. + evmConfig := types.NewEvmConfig() + evmConfig.ResetTestConfig() + err := evmConfig. WithChainConfig(chainConfig). WithEVMCoinInfo(types.EvmCoinInfo{ - Denom: denom, - ExtendedDenom: extendedDenom, - DisplayDenom: displayDenom, - Decimals: decimals, + DisplayDenom: displayDenom, + Decimals: decimals, + ExtendedDecimals: extendedDecimals, }). - Configure() + Apply() require.NoError(b, err) // Use simple transaction args for consistent benchmarking diff --git a/evmd/tests/ledger/evmosd_suite_test.go b/evmd/tests/ledger/evmosd_suite_test.go index 200a8a5da..fa8de7b07 100644 --- a/evmd/tests/ledger/evmosd_suite_test.go +++ b/evmd/tests/ledger/evmosd_suite_test.go @@ -27,9 +27,10 @@ import ( "github.com/cosmos/evm/crypto/hd" cosmosevmkeyring "github.com/cosmos/evm/crypto/keyring" "github.com/cosmos/evm/encoding" - "github.com/cosmos/evm/evmd" + evmdapp "github.com/cosmos/evm/evmd/app" "github.com/cosmos/evm/evmd/tests/ledger/mocks" - "github.com/cosmos/evm/testutil/constants" + testutil "github.com/cosmos/evm/evmd/testutil" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/cosmos-sdk/client" @@ -47,7 +48,7 @@ var s *LedgerTestSuite type LedgerTestSuite struct { suite.Suite - app *evmd.EVMD + app *evmdapp.EVMD ctx sdk.Context ledger *mocks.SECP256K1 @@ -87,8 +88,8 @@ func (suite *LedgerTestSuite) SetupEvmosApp() { consAddress := sdk.ConsAddress(utiltx.GenerateAddress().Bytes()) // init app - chainID := constants.ExampleChainID - suite.app = evmd.Setup(suite.T(), chainID.ChainID, chainID.EVMChainID) + chainID := testconfig.ExampleChainID + suite.app = testutil.Setup(suite.T(), chainID.ChainID, chainID.EVMChainID) suite.ctx = suite.app.NewContextLegacy(false, tmproto.Header{ Height: 1, ChainID: chainID.ChainID, @@ -136,7 +137,7 @@ func (suite *LedgerTestSuite) NewKeyringAndCtxs(krHome string, input io.Reader, WithUseLedger(true). WithKeyring(kr). WithClient(mocks.MockCometRPC{Client: rpcclientmock.Client{}}). - WithChainID(constants.ExampleChainIDPrefix + "-13"). + WithChainID(testconfig.ExampleChainIDPrefix + "-13"). WithSignModeStr(flags.SignModeLegacyAminoJSON) srvCtx := server.NewDefaultContext() diff --git a/evmd/tests/network/network.go b/evmd/tests/network/network.go index 51fb9133f..6fcee21a4 100644 --- a/evmd/tests/network/network.go +++ b/evmd/tests/network/network.go @@ -27,12 +27,11 @@ import ( cmtclient "github.com/cometbft/cometbft/rpc/client" dbm "github.com/cosmos/cosmos-db" + "github.com/cosmos/evm/config" "github.com/cosmos/evm/crypto/hd" - "github.com/cosmos/evm/evmd" - evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" - "github.com/cosmos/evm/server/config" + evmdapp "github.com/cosmos/evm/evmd/app" + serverconfig "github.com/cosmos/evm/server/config" testconfig "github.com/cosmos/evm/testutil/config" - testconstants "github.com/cosmos/evm/testutil/constants" cosmosevmtypes "github.com/cosmos/evm/types" "cosmossdk.io/log" @@ -110,7 +109,20 @@ func DefaultConfig() Config { panic(fmt.Sprintf("failed creating temporary directory: %v", err)) } defer os.RemoveAll(dir) - tempApp := evmd.NewExampleApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simutils.NewAppOptionsWithFlagHome(dir), evmChainID, testconfig.EvmAppOptions, baseapp.SetChainID(chainID)) + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + chainConfig := config.NewChainConfig( + chainID, + evmChainID, + nil, + nil, + nil, + coinInfo, + false, + ) + if err := chainConfig.ApplyChainConfig(); err != nil { + panic(err) + } + tempApp := evmdapp.NewExampleApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simutils.NewAppOptionsWithFlagHome(dir), baseapp.SetChainID(chainID)) cfg := Config{ Codec: tempApp.AppCodec(), @@ -123,8 +135,8 @@ func DefaultConfig() Config { TimeoutCommit: 3 * time.Second, ChainID: chainID, NumValidators: 4, - BondDenom: testconstants.ExampleAttoDenom, - MinGasPrices: fmt.Sprintf("0.000006%s", testconstants.ExampleAttoDenom), + BondDenom: testconfig.ExampleAttoDenom, + MinGasPrices: fmt.Sprintf("0.000006%s", testconfig.ExampleAttoDenom), AccountTokens: sdk.TokensFromConsensusPower(1000000000000000000, cosmosevmtypes.AttoPowerReduction), StakingTokens: sdk.TokensFromConsensusPower(500000000000000000, cosmosevmtypes.AttoPowerReduction), BondedTokens: sdk.TokensFromConsensusPower(100000000000000000, cosmosevmtypes.AttoPowerReduction), @@ -140,15 +152,20 @@ func DefaultConfig() Config { // NewAppConstructor returns a new Cosmos EVM AppConstructor func NewAppConstructor(chainID string, evmChainID uint64) AppConstructor { return func(val Validator) servertypes.Application { - return evmd.NewExampleApp( - val.Ctx.Logger, dbm.NewMemDB(), nil, true, - simutils.NewAppOptionsWithFlagHome(val.Ctx.Config.RootDir), + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + chainConfig := config.NewChainConfig( + chainID, evmChainID, - testconfig.EvmAppOptions, - baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), - baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), - baseapp.SetChainID(chainID), + nil, + nil, + nil, + coinInfo, + false, ) + if err := chainConfig.ApplyChainConfig(); err != nil { + panic(err) + } + return evmdapp.NewExampleApp(val.Ctx.Logger, dbm.NewMemDB(), nil, true, simutils.NewAppOptionsWithFlagHome(val.Ctx.Config.RootDir), baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), baseapp.SetChainID(chainID)) } } @@ -175,7 +192,7 @@ type ( // a client can make RPC and API calls and interact with any client command // or handler. Validator struct { - AppConfig *config.Config + AppConfig *serverconfig.Config ClientCtx client.Context Ctx *server.Context Dir string @@ -258,7 +275,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { // generate private keys, node IDs, and initial transactions for i := 0; i < cfg.NumValidators; i++ { - appCfg := config.DefaultConfig() + appCfg := serverconfig.DefaultConfig() appCfg.Pruning = cfg.PruningStrategy appCfg.MinGasPrices = cfg.MinGasPrices appCfg.API.Enable = true @@ -328,7 +345,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { appCfg.JSONRPC.Address = fmt.Sprintf("0.0.0.0:%s", port) } appCfg.JSONRPC.Enable = true - appCfg.JSONRPC.API = config.GetAPINamespaces() + appCfg.JSONRPC.API = serverconfig.GetAPINamespaces() } logger := log.NewNopLogger() @@ -476,7 +493,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { return nil, err } - customAppTemplate, _ := evmdconfig.InitAppConfig(testconstants.ExampleAttoDenom, testconstants.ExampleEIP155ChainID) + customAppTemplate, _ := config.InitAppConfig(testconfig.ExampleAttoDenom, testconfig.EighteenDecimalsChainID) srvconfig.SetConfigTemplate(customAppTemplate) srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), appCfg) diff --git a/evmd/test_helpers.go b/evmd/testutil/helpers.go similarity index 82% rename from evmd/test_helpers.go rename to evmd/testutil/helpers.go index b7e77d9b3..c7533a611 100644 --- a/evmd/test_helpers.go +++ b/evmd/testutil/helpers.go @@ -1,18 +1,18 @@ -package evmd +package testutil import ( "encoding/json" "fmt" "testing" - "github.com/cosmos/evm/evmd/cmd/evmd/config" - testconfig "github.com/cosmos/evm/testutil/config" "github.com/stretchr/testify/require" abci "github.com/cometbft/cometbft/abci/types" cmttypes "github.com/cometbft/cometbft/types" dbm "github.com/cosmos/cosmos-db" + evmconfig "github.com/cosmos/evm/config" + evmdapp "github.com/cosmos/evm/evmd/app" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" ibctesting "github.com/cosmos/ibc-go/v10/testing" @@ -44,27 +44,28 @@ func init() { // Set the global SDK config for the tests cfg := sdk.GetConfig() - config.SetBech32Prefixes(cfg) - config.SetBip44CoinType(cfg) + evmconfig.SetBech32Prefixes(cfg) + evmconfig.SetBip44CoinType(cfg) } -func setup(withGenesis bool, invCheckPeriod uint, chainID string, evmChainID uint64) (*EVMD, GenesisState) { +func setup(withGenesis bool, invCheckPeriod uint, chainID string, evmChainID uint64) (*evmdapp.EVMD, evmdapp.GenesisState) { db := dbm.NewMemDB() appOptions := make(simtestutil.AppOptionsMap, 0) - appOptions[flags.FlagHome] = defaultNodeHome + appOptions[flags.FlagHome] = evmdapp.DefaultNodeHome appOptions[server.FlagInvCheckPeriod] = invCheckPeriod - app := NewExampleApp(log.NewNopLogger(), db, nil, true, appOptions, evmChainID, testconfig.EvmAppOptions, baseapp.SetChainID(chainID)) + chainConfig := evmconfig.DefaultChainConfig + app := evmdapp.NewExampleApp(log.NewNopLogger(), db, nil, true, appOptions, baseapp.SetChainID(chainID)) if withGenesis { return app, app.DefaultGenesis() } - return app, GenesisState{} + return app, evmdapp.GenesisState{} } // Setup initializes a new EVMD. A Nop logger is set in EVMD. -func Setup(t *testing.T, chainID string, evmChainID uint64) *EVMD { +func Setup(t *testing.T, chainID string, evmChainID uint64) *evmdapp.EVMD { t.Helper() privVal := mock.NewPV() @@ -92,7 +93,7 @@ func Setup(t *testing.T, chainID string, evmChainID uint64) *EVMD { // that also act as delegators. For simplicity, each validator is bonded with a delegation // of one consensus engine unit in the default token of the simapp from first genesis // account. A Nop logger is set in EVMD. -func SetupWithGenesisValSet(t *testing.T, chainID string, evmChainID uint64, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *EVMD { +func SetupWithGenesisValSet(t *testing.T, chainID string, evmChainID uint64, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *evmdapp.EVMD { t.Helper() app, genesisState := setup(true, 5, chainID, evmChainID) @@ -124,17 +125,10 @@ func SetupWithGenesisValSet(t *testing.T, chainID string, evmChainID uint64, val // SetupTestingApp initializes the IBC-go testing application // need to keep this design to comply with the ibctesting SetupTestingApp func // and be able to set the chainID for the tests properly -func SetupTestingApp(chainID string, evmChainID uint64) func() (ibctesting.TestingApp, map[string]json.RawMessage) { +func SetupTestingApp(chainConfig evmconfig.ChainConfig) func() (ibctesting.TestingApp, map[string]json.RawMessage) { return func() (ibctesting.TestingApp, map[string]json.RawMessage) { db := dbm.NewMemDB() - app := NewExampleApp( - log.NewNopLogger(), - db, nil, true, - simtestutil.NewAppOptionsWithFlagHome(defaultNodeHome), - evmChainID, - testconfig.EvmAppOptions, - baseapp.SetChainID(chainID), - ) + app := evmdapp.NewExampleApp(log.NewNopLogger(), db, nil, true, simtestutil.NewAppOptionsWithFlagHome(evmdapp.DefaultNodeHome), baseapp.SetChainID(chainConfig.ChainID)) return app, app.DefaultGenesis() } } diff --git a/go.mod b/go.mod index 4166dd6d3..e3ea8d9b5 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.23.8 require ( cosmossdk.io/api v0.9.2 + cosmossdk.io/client/v2 v2.0.0-beta.7 cosmossdk.io/core v0.11.3 cosmossdk.io/errors v1.0.2 cosmossdk.io/log v1.6.1 @@ -38,7 +39,6 @@ require ( github.com/onsi/ginkgo/v2 v2.23.4 github.com/onsi/gomega v1.38.0 github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.22.0 github.com/rs/cors v1.11.1 github.com/spf13/cast v1.9.2 github.com/spf13/cobra v1.9.1 @@ -181,7 +181,6 @@ require ( github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect - github.com/kylelemons/godebug v1.1.0 // indirect github.com/lib/pq v1.10.9 // indirect github.com/manifoldco/promptui v0.9.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect @@ -207,6 +206,7 @@ require ( github.com/pion/transport/v3 v3.0.1 // indirect github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/prometheus/client_golang v1.22.0 // indirect github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.63.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect diff --git a/go.sum b/go.sum index b3f7089a2..fb1913581 100644 --- a/go.sum +++ b/go.sum @@ -616,6 +616,8 @@ cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT cloud.google.com/go/workflows v1.10.0/go.mod h1:fZ8LmRmZQWacon9UCX1r/g/DfAXx5VcPALq2CxzdePw= cosmossdk.io/api v0.9.2 h1:9i9ptOBdmoIEVEVWLtYYHjxZonlF/aOVODLFaxpmNtg= cosmossdk.io/api v0.9.2/go.mod h1:CWt31nVohvoPMTlPv+mMNCtC0a7BqRdESjCsstHcTkU= +cosmossdk.io/client/v2 v2.0.0-beta.7 h1:O0PfZL5kC3Sp54wZASLNihQ612Gd6duMp11aM9wawNg= +cosmossdk.io/client/v2 v2.0.0-beta.7/go.mod h1:TzwwrzeK+AfSVSESVEIOYO/9xuCh1fPv0HgeocmfVnM= cosmossdk.io/collections v1.2.1 h1:mAlNMs5vJwkda4TA+k5q/43p24RVAQ/qyDrjANu3BXE= cosmossdk.io/collections v1.2.1/go.mod h1:PSsEJ/fqny0VPsHLFT6gXDj/2C1tBOTS9eByK0+PBFU= cosmossdk.io/core v0.11.3 h1:mei+MVDJOwIjIniaKelE3jPDqShCc/F4LkNNHh+4yfo= diff --git a/ibc/utils_test.go b/ibc/utils_test.go index 586ecd259..fb52a0959 100644 --- a/ibc/utils_test.go +++ b/ibc/utils_test.go @@ -7,7 +7,7 @@ import ( cosmosevmibc "github.com/cosmos/evm/ibc" precompilestestutil "github.com/cosmos/evm/precompiles/testutil" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" transfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v10/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v10/testing" @@ -297,7 +297,7 @@ func TestGetReceivedCoin(t *testing.T) { } func TestGetSentCoin(t *testing.T) { - baseDenom := testconstants.ExampleAttoDenom + baseDenom := testconfig.ExampleAttoDenom testCases := []struct { name string diff --git a/local_node.sh b/local_node.sh index c04c16382..a7ffb3de2 100755 --- a/local_node.sh +++ b/local_node.sh @@ -14,6 +14,15 @@ CHAINDIR="$HOME/.evmd" BASEFEE=10000000 +# Coin info +DISPLAY_DENOM="atom" +DECIMALS=18 +EXTENDED_DECIMALS=18 + +# Extended denom +EXTENDED_DECIMALS_SI_PREFIX="a" # a = atto (18 decimals) +EXTENDED_DENOM="${EXTENDED_DECIMALS_SI_PREFIX}${DISPLAY_DENOM}" + # Path variables CONFIG_TOML=$CHAINDIR/config/config.toml APP_TOML=$CHAINDIR/config/app.toml @@ -44,6 +53,7 @@ Usage: $0 [options] Options: -y Overwrite existing chain data without prompt -n Do not overwrite existing chain data + -e CHAIN_ID Set custom chain ID (default: 9001) --no-install Skip 'make install' --remote-debugging Build with nooptimization,nostrip --additional-users N Create N extra users: dev4, dev5, ... @@ -63,6 +73,13 @@ while [[ $# -gt 0 ]]; do echo "Flag -n passed -> Not overwriting the previous chain data." overwrite="n"; shift ;; + -e) + if [[ -z "${2:-}" || "$2" =~ ^- ]]; then + echo "Error: -e requires a chain ID."; usage; exit 1 + fi + CHAINID="$2"; shift 2 + echo "Using custom chain ID: $CHAINID" + ;; --no-install) echo "Flag --no-install passed -> Skipping installation of the evmd binary." install=false; shift @@ -164,7 +181,7 @@ write_mnemonics_yaml() { # ---------- Add funded account ---------- add_genesis_funds() { local keyname="$1" - evmd genesis add-genesis-account "$keyname" 1000000000000000000000atest --keyring-backend "$KEYRING" --home "$CHAINDIR" + evmd genesis add-genesis-account "$keyname" "1000000000000000000000$EXTENDED_DENOM" --keyring-backend "$KEYRING" --home "$CHAINDIR" } # Setup local node if overwrite is set to Yes, otherwise skip setup @@ -231,21 +248,22 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then echo "$VAL_MNEMONIC" | evmd init $MONIKER -o --chain-id "$CHAINID" --home "$CHAINDIR" --recover # ---------- Genesis customizations ---------- - jq '.app_state["staking"]["params"]["bond_denom"]="atest"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="atest"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["gov"]["params"]["min_deposit"][0]["denom"]="atest"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["gov"]["params"]["expedited_min_deposit"][0]["denom"]="atest"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["evm"]["params"]["evm_denom"]="atest"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["mint"]["params"]["mint_denom"]="atest"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["staking"]["params"]["bond_denom"]="'$EXTENDED_DENOM'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="'$EXTENDED_DENOM'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["gov"]["params"]["min_deposit"][0]["denom"]="'$EXTENDED_DENOM'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["gov"]["params"]["expedited_min_deposit"][0]["denom"]="'$EXTENDED_DENOM'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["evm"]["params"]["evm_denom"]="'$EXTENDED_DENOM'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["evm"]["params"]["evm_chain_id"]="'4221'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["mint"]["params"]["mint_denom"]="'$EXTENDED_DENOM'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["bank"]["denom_metadata"]=[{"description":"The native staking token for evmd.","denom_units":[{"denom":"atest","exponent":0,"aliases":["attotest"]},{"denom":"test","exponent":18,"aliases":[]}],"base":"atest","display":"test","name":"Test Token","symbol":"TEST","uri":"","uri_hash":""}]' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["bank"]["denom_metadata"]=[{"description":"The native staking token for evmd.","denom_units":[{"denom":"'$EXTENDED_DENOM'","exponent":0,"aliases":["atto'$DISPLAY_DENOM'"]},{"denom":"'$DISPLAY_DENOM'","exponent":'$DECIMALS',"aliases":[]}],"base":"'$EXTENDED_DENOM'","display":"'$DISPLAY_DENOM'","name":"'$DISPLAY_DENOM'","symbol":"'$DISPLAY_DENOM'","uri":"","uri_hash":""}]' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state["evm"]["params"]["active_static_precompiles"]=["0x0000000000000000000000000000000000000100","0x0000000000000000000000000000000000000400","0x0000000000000000000000000000000000000800","0x0000000000000000000000000000000000000801","0x0000000000000000000000000000000000000802","0x0000000000000000000000000000000000000803","0x0000000000000000000000000000000000000804","0x0000000000000000000000000000000000000805", "0x0000000000000000000000000000000000000806", "0x0000000000000000000000000000000000000807"]' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state["evm"]["params"]["evm_denom"]="atest"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state["evm"]["params"]["evm_denom"]="'$EXTENDED_DENOM'"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.app_state.erc20.native_precompiles=["0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"]' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - jq '.app_state.erc20.token_pairs=[{contract_owner:1,erc20_address:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",denom:"atest",enabled:true}]' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq '.app_state.erc20.token_pairs=[{contract_owner:1,erc20_address:"0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",denom:"'$EXTENDED_DENOM'",enabled:true}]' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq '.consensus.params.block.max_gas="10000000"' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" @@ -288,7 +306,7 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then sed -i.bak 's/"expedited_voting_period": "86400s"/"expedited_voting_period": "15s"/g' "$GENESIS" # fund validator (devs already funded in the loop) - evmd genesis add-genesis-account "$VAL_KEY" 100000000000000000000000000atest --keyring-backend "$KEYRING" --home "$CHAINDIR" + evmd genesis add-genesis-account "$VAL_KEY" "100000000000000000000000000$EXTENDED_DENOM" --keyring-backend "$KEYRING" --home "$CHAINDIR" # --------- maybe generate additional users --------- # start with provided/default list @@ -340,7 +358,7 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then fi # --------- Finalize genesis --------- - evmd genesis gentx "$VAL_KEY" 1000000000000000000000atest --gas-prices ${BASEFEE}atest --keyring-backend "$KEYRING" --chain-id "$CHAINID" --home "$CHAINDIR" + evmd genesis gentx "$VAL_KEY" "1000000000000000000000$EXTENDED_DENOM" --gas-prices ${BASEFEE}$EXTENDED_DENOM --keyring-backend "$KEYRING" --chain-id "$CHAINID" --home "$CHAINDIR" evmd genesis collect-gentxs --home "$CHAINDIR" evmd genesis validate-genesis --home "$CHAINDIR" @@ -358,8 +376,9 @@ fi evmd start "$TRACE" \ --pruning nothing \ --log_level $LOGLEVEL \ - --minimum-gas-prices=0atest \ + --minimum-gas-prices=0$EXTENDED_DENOM \ --evm.min-tip=0 \ --home "$CHAINDIR" \ --json-rpc.api eth,txpool,personal,net,debug,web3 \ - --chain-id "$CHAINID" + --chain-id "$CHAINID" \ + --evm.evm-chain-id=$CHAINID diff --git a/mempool/mempool.go b/mempool/mempool.go index a3a7aa62c..1222d432b 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -15,7 +15,6 @@ import ( "github.com/cosmos/evm/mempool/txpool" "github.com/cosmos/evm/mempool/txpool/legacypool" "github.com/cosmos/evm/rpc/stream" - "github.com/cosmos/evm/x/precisebank/types" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/log" @@ -54,8 +53,6 @@ type ( logger log.Logger txConfig client.TxConfig blockchain *Blockchain - bondDenom string - evmDenom string blockGasLimit uint64 // Block gas limit from consensus parameters minTip *uint256.Int @@ -91,9 +88,6 @@ func NewExperimentalEVMMempool(getCtxCallback func(height int64, prove bool) (sd blockchain *Blockchain ) - bondDenom := evmtypes.GetEVMCoinDenom() - evmDenom := types.ExtendedCoinDenom() - // add the mempool name to the logger logger = logger.With(log.ModuleKey, "ExperimentalEVMMempool") @@ -154,7 +148,7 @@ func NewExperimentalEVMMempool(getCtxCallback func(height int64, prove bool) (sd if !ok { return math.ZeroInt() } - found, coin := cosmosTxFee.GetFee().Find(bondDenom) + found, coin := cosmosTxFee.GetFee().Find(evmtypes.GetEVMCoinDenom()) if !found { return math.ZeroInt() } @@ -181,8 +175,6 @@ func NewExperimentalEVMMempool(getCtxCallback func(height int64, prove bool) (sd logger: logger, txConfig: txConfig, blockchain: blockchain, - bondDenom: bondDenom, - evmDenom: evmDenom, blockGasLimit: config.BlockGasLimit, minTip: config.MinTip, anteHandler: config.AnteHandler, @@ -284,7 +276,7 @@ func (m *ExperimentalEVMMempool) Select(goCtx context.Context, i [][]byte) sdkme evmIterator, cosmosIterator := m.getIterators(goCtx, i) - combinedIterator := NewEVMMempoolIterator(evmIterator, cosmosIterator, m.logger, m.txConfig, m.bondDenom, m.blockchain.Config().ChainID, m.blockchain) + combinedIterator := NewEVMMempoolIterator(evmIterator, cosmosIterator, m.logger, m.txConfig, evmtypes.GetEVMCoinDenom(), m.blockchain.Config().ChainID, m.blockchain) return combinedIterator } @@ -377,7 +369,7 @@ func (m *ExperimentalEVMMempool) SelectBy(goCtx context.Context, i [][]byte, f f evmIterator, cosmosIterator := m.getIterators(goCtx, i) - combinedIterator := NewEVMMempoolIterator(evmIterator, cosmosIterator, m.logger, m.txConfig, m.bondDenom, m.blockchain.Config().ChainID, m.blockchain) + combinedIterator := NewEVMMempoolIterator(evmIterator, cosmosIterator, m.logger, m.txConfig, evmtypes.GetEVMCoinDenom(), m.blockchain.Config().ChainID, m.blockchain) for combinedIterator != nil && f(combinedIterator.Tx()) { combinedIterator = combinedIterator.Next() diff --git a/precompiles/common/balance_handler_test.go b/precompiles/common/balance_handler_test.go index c0ea5fe0b..03af304e5 100644 --- a/precompiles/common/balance_handler_test.go +++ b/precompiles/common/balance_handler_test.go @@ -12,7 +12,7 @@ import ( cmn "github.com/cosmos/evm/precompiles/common" cmnmocks "github.com/cosmos/evm/precompiles/common/mocks" testutil "github.com/cosmos/evm/testutil" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" precisebanktypes "github.com/cosmos/evm/x/precisebank/types" "github.com/cosmos/evm/x/vm/statedb" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -29,10 +29,10 @@ import ( func setupBalanceHandlerTest(t *testing.T) { t.Helper() - sdk.GetConfig().SetBech32PrefixForAccount(testconstants.ExampleBech32Prefix, "") - configurator := evmtypes.NewEVMConfigurator() + sdk.GetConfig().SetBech32PrefixForAccount(sdk.Bech32MainPrefix, "") + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]).Configure()) + require.NoError(t, configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]).Apply()) } func TestParseAddress(t *testing.T) { diff --git a/precompiles/common/types_test.go b/precompiles/common/types_test.go index 2ccbf868e..f824209a3 100644 --- a/precompiles/common/types_test.go +++ b/precompiles/common/types_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/evm/precompiles/common" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "cosmossdk.io/math" @@ -24,7 +24,7 @@ func TestNewCoinsResponse(t *testing.T) { } for _, tc := range testCases { - coin := sdk.NewCoin(constants.ExampleAttoDenom, tc.amount) + coin := sdk.NewCoin(testconfig.ExampleAttoDenom, tc.amount) coins := sdk.NewCoins(coin) res := common.NewCoinsResponse(coins) require.Equal(t, 1, len(res)) @@ -41,7 +41,7 @@ func TestNewDecCoinsResponse(t *testing.T) { } for _, tc := range testCases { - coin := sdk.NewDecCoin(constants.ExampleAttoDenom, tc.amount) + coin := sdk.NewDecCoin(testconfig.ExampleAttoDenom, tc.amount) coins := sdk.NewDecCoins(coin) res := common.NewDecCoinsResponse(coins) require.Equal(t, 1, len(res)) diff --git a/proto/cosmos/evm/vm/v1/evm.proto b/proto/cosmos/evm/vm/v1/evm.proto index dda6eade0..6099fb954 100644 --- a/proto/cosmos/evm/vm/v1/evm.proto +++ b/proto/cosmos/evm/vm/v1/evm.proto @@ -36,6 +36,7 @@ message Params { // precompiled contracts that are active repeated string active_static_precompiles = 9; uint64 history_serve_window = 10; + uint64 evm_chain_id = 11; } // AccessControl defines the permission policy of the EVM @@ -185,10 +186,12 @@ message ChainConfig { reserved 22, 23; // chain_id is the id of the chain (EIP-155) uint64 chain_id = 24; - // denom is the denomination used on the EVM - string denom = 25; - // decimals is the real decimal precision of the denomination used on the EVM - uint64 decimals = 26; +// // denom is the denomination used on the EVM +// string denom = 25; +// // decimals is the real decimal precision of the denomination used on the EVM +// uint64 decimals = 26; + + reserved 25, 26; // shanghai_time: Shanghai switch time (nil = no fork, 0 = already on // shanghai) diff --git a/rpc/backend/node_info.go b/rpc/backend/node_info.go index dcdf28a68..2a1d75c0a 100644 --- a/rpc/backend/node_info.go +++ b/rpc/backend/node_info.go @@ -14,7 +14,6 @@ import ( "github.com/cosmos/evm/crypto/ethsecp256k1" rpctypes "github.com/cosmos/evm/rpc/types" "github.com/cosmos/evm/server/config" - "github.com/cosmos/evm/testutil/constants" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" @@ -345,7 +344,7 @@ func (b *Backend) RPCMinGasPrice() *big.Int { minGasPrice := b.Cfg.GetMinGasPrices() amt := minGasPrice.AmountOf(baseDenom) if amt.IsNil() || amt.IsZero() { - return big.NewInt(constants.DefaultGasPrice) + return big.NewInt(evmtypes.DefaultGasPrice) } return evmtypes.ConvertAmountTo18DecimalsLegacy(amt).TruncateInt().BigInt() diff --git a/rpc/backend/tx_info_test.go b/rpc/backend/tx_info_test.go index 834b6f2ca..b6a9707ff 100644 --- a/rpc/backend/tx_info_test.go +++ b/rpc/backend/tx_info_test.go @@ -22,7 +22,7 @@ import ( "github.com/cosmos/evm/indexer" "github.com/cosmos/evm/rpc/backend/mocks" rpctypes "github.com/cosmos/evm/rpc/types" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -36,7 +36,7 @@ func setupMockBackend(t *testing.T) *Backend { t.Helper() ctx := server.NewDefaultContext() ctx.Viper.Set("telemetry.global-labels", []interface{}{}) - ctx.Viper.Set("evm.evm-chain-id", constants.ExampleChainID.EVMChainID) + ctx.Viper.Set("evm.evm-chain-id", testconfig.ExampleChainID.EVMChainID) baseDir := t.TempDir() nodeDirName := "node" @@ -52,8 +52,8 @@ func setupMockBackend(t *testing.T) *Backend { Seq: uint64(1), } - encodingConfig := encoding.MakeConfig(constants.ExampleChainID.EVMChainID) - clientCtx := client.Context{}.WithChainID(constants.ExampleChainID.ChainID). + encodingConfig := encoding.MakeConfig(testconfig.ExampleChainID.EVMChainID) + clientCtx := client.Context{}.WithChainID(testconfig.ExampleChainID.ChainID). WithHeight(1). WithTxConfig(encodingConfig.TxConfig). WithKeyringDir(clientDir). @@ -69,7 +69,7 @@ func setupMockBackend(t *testing.T) *Backend { backend.Cfg.JSONRPC.GasCap = 25000000 backend.Cfg.JSONRPC.EVMTimeout = 0 backend.Cfg.JSONRPC.AllowInsecureUnlock = true - backend.Cfg.EVM.EVMChainID = constants.ExampleChainID.EVMChainID + backend.Cfg.EVM.EVMChainID = testconfig.ExampleChainID.EVMChainID mockEVMQueryClient := mocks.NewEVMQueryClient(t) mockFeeMarketQueryClient := mocks.NewFeeMarketQueryClient(t) backend.QueryClient.QueryClient = mockEVMQueryClient @@ -86,7 +86,7 @@ func setupMockBackend(t *testing.T) *Backend { mockHeader := &tmtypes.Header{ Height: 1, Time: time.Now(), - ChainID: constants.ExampleChainID.ChainID, + ChainID: testconfig.ExampleChainID.ChainID, } mockBlock := &tmtypes.Block{ Header: *mockHeader, diff --git a/server/config/config.go b/server/config/config.go index cabd79181..2cf515c0b 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -10,6 +10,8 @@ import ( "github.com/cometbft/cometbft/libs/strings" + evmtypes "github.com/cosmos/evm/x/vm/types" + errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/server/config" @@ -63,8 +65,8 @@ const ( // DefaultMaxTxGasWanted is the default gas wanted for each eth tx returned in ante handler in check tx mode DefaultMaxTxGasWanted = 0 - // DefaultEVMChainID is the default EVM Chain ID if one is not provided - DefaultEVMChainID = 262144 + // DefaultEVMChainID is the default EVM Chain ID if one is not provided, should match the value in evmd config + DefaultEVMChainID = evmtypes.DefaultEvmChainID // DefaultEVMMinTip is the default minimum priority fee for the mempool DefaultEVMMinTip = 0 @@ -148,6 +150,8 @@ type EVMConfig struct { EVMChainID uint64 `mapstructure:"evm-chain-id"` // MinTip defines the minimum priority fee for the mempool MinTip uint64 `mapstructure:"min-tip"` + // CoinInfo defines the coin configuration for the chain + CoinInfo evmtypes.EvmCoinInfo `mapstructure:"coin-info"` } // JSONRPCConfig defines configuration for the EVM RPC server. diff --git a/server/config/config_test.go b/server/config/config_test.go index e5920a986..8ffd1224a 100644 --- a/server/config/config_test.go +++ b/server/config/config_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/require" serverconfig "github.com/cosmos/evm/server/config" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" ) func TestDefaultConfig(t *testing.T) { @@ -30,12 +30,12 @@ func TestGetConfig(t *testing.T) { "test unmarshal embedded structs", func() *viper.Viper { v := viper.New() - v.Set("minimum-gas-prices", fmt.Sprintf("100%s", constants.ExampleAttoDenom)) + v.Set("minimum-gas-prices", fmt.Sprintf("100%s", testconfig.ExampleAttoDenom)) return v }, func() serverconfig.Config { cfg := serverconfig.DefaultConfig() - cfg.MinGasPrices = fmt.Sprintf("100%s", constants.ExampleAttoDenom) + cfg.MinGasPrices = fmt.Sprintf("100%s", testconfig.ExampleAttoDenom) return *cfg }, false, diff --git a/server/start.go b/server/start.go index aa317693c..727afdbf6 100644 --- a/server/start.go +++ b/server/start.go @@ -271,7 +271,7 @@ func startStandAlone(svrCtx *server.Context, clientCtx client.Context, opts Star }() evmApp, ok := app.(Application) if !ok { - svrCtx.Logger.Error("failed to get server config", "error", err.Error()) + svrCtx.Logger.Error("failed to get server config") } evmApp.SetClientCtx(clientCtx) diff --git a/tests/integration/ante/ante_test_suite.go b/tests/integration/ante/ante_test_suite.go index d6a72cfa3..6b69355ad 100644 --- a/tests/integration/ante/ante_test_suite.go +++ b/tests/integration/ante/ante_test_suite.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/suite" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" @@ -99,7 +100,8 @@ func (s *AnteTestSuite) SetupTest() { s.Require().NotNil(s.network.App.AppCodec()) - chainConfig := evmtypes.DefaultChainConfig(s.network.GetEIP155ChainID().Uint64()) + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + chainConfig := evmtypes.DefaultChainConfig(s.network.GetEIP155ChainID().Uint64(), coinInfo) if !s.enableLondonHF { maxInt := sdkmath.NewInt(math.MaxInt64) chainConfig.LondonBlock = &maxInt @@ -114,22 +116,20 @@ func (s *AnteTestSuite) SetupTest() { // get the denom and decimals set when initialized the chain // to set them again // when resetting the chain config - denom := evmtypes.GetEVMCoinDenom() - extendedDenom := evmtypes.GetEVMCoinExtendedDenom() displayDenom := evmtypes.GetEVMCoinDisplayDenom() decimals := evmtypes.GetEVMCoinDecimals() + extendedDecimals := evmtypes.GetEVMCoinExtendedDecimals() - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() err := configurator. WithChainConfig(chainConfig). WithEVMCoinInfo(evmtypes.EvmCoinInfo{ - Denom: denom, - ExtendedDenom: extendedDenom, - DisplayDenom: displayDenom, - Decimals: decimals, + DisplayDenom: displayDenom, + Decimals: decimals, + ExtendedDecimals: extendedDecimals, }). - Configure() + Apply() s.Require().NoError(err) } diff --git a/tests/integration/ante/evm_ante_test_suite.go b/tests/integration/ante/evm_ante_test_suite.go index 361071447..30f92f2b1 100644 --- a/tests/integration/ante/evm_ante_test_suite.go +++ b/tests/integration/ante/evm_ante_test_suite.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/ethereum/eip712" "github.com/cosmos/evm/testutil" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/network" utiltx "github.com/cosmos/evm/testutil/tx" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -644,7 +644,7 @@ func PrepareAccountsForDelegationRewards(t *testing.T, ctx sdk.Context, app evm. // set distribution module account balance which pays out the rewards distrAcc := distrKeeper.GetDistributionAccount(ctx) - err := testutil.FundModuleAccount(ctx, bankKeeper, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(constants.ExampleAttoDenom, totalRewards))) + err := testutil.FundModuleAccount(ctx, bankKeeper, distrAcc.GetName(), sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, totalRewards))) if err != nil { return sdk.Context{}, fmt.Errorf("failed to fund distribution module account: %s", err.Error()) } @@ -668,14 +668,14 @@ func PrepareAccountsForDelegationRewards(t *testing.T, ctx sdk.Context, app evm. if err != nil { return sdk.Context{}, fmt.Errorf("failed to get staking params: %s", err.Error()) } - stakingParams.BondDenom = constants.ExampleAttoDenom + stakingParams.BondDenom = testconfig.ExampleAttoDenom stakingParams.MinCommissionRate = zeroDec err = stakingKeeper.SetParams(ctx, stakingParams) require.NoError(t, err) stakingHelper := teststaking.NewHelper(t, ctx, stakingKeeper) stakingHelper.Commission = stakingtypes.NewCommissionRates(zeroDec, zeroDec, zeroDec) - stakingHelper.Denom = constants.ExampleAttoDenom + stakingHelper.Denom = testconfig.ExampleAttoDenom valAddr := sdk.ValAddress(addr2.Bytes()) // self-delegate the same amount of tokens as the delegate address also stakes @@ -693,7 +693,7 @@ func PrepareAccountsForDelegationRewards(t *testing.T, ctx sdk.Context, app evm. if err != nil { return sdk.Context{}, fmt.Errorf("failed to get validator: %s", err.Error()) } - allocatedRewards := sdk.NewDecCoins(sdk.NewDecCoin(constants.ExampleAttoDenom, reward.Mul(sdkmath.NewInt(2)))) + allocatedRewards := sdk.NewDecCoins(sdk.NewDecCoin(testconfig.ExampleAttoDenom, reward.Mul(sdkmath.NewInt(2)))) if err = distrKeeper.AllocateTokensToValidator(ctx, validator, allocatedRewards); err != nil { return sdk.Context{}, fmt.Errorf("failed to allocate tokens to validator: %s", err.Error()) } diff --git a/tests/integration/ante/evm_unit_ante_test_suite.go b/tests/integration/ante/evm_unit_ante_test_suite.go index 3fd1597bb..b578506cf 100644 --- a/tests/integration/ante/evm_unit_ante_test_suite.go +++ b/tests/integration/ante/evm_unit_ante_test_suite.go @@ -3,7 +3,7 @@ package ante import ( "github.com/stretchr/testify/suite" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/network" ) @@ -26,7 +26,7 @@ func NewEvmUnitAnteTestSuite( ) *EvmUnitAnteTestSuite { return &EvmUnitAnteTestSuite{ create: create, - ChainID: constants.ExampleChainID.ChainID, - EvmChainID: constants.ExampleChainID.EVMChainID, + ChainID: testconfig.ExampleChainID.ChainID, + EvmChainID: testconfig.ExampleChainID.EVMChainID, } } diff --git a/tests/integration/ante/test_evm_ante.go b/tests/integration/ante/test_evm_ante.go index be0fec752..7b3e54178 100644 --- a/tests/integration/ante/test_evm_ante.go +++ b/tests/integration/ante/test_evm_ante.go @@ -13,7 +13,7 @@ import ( ethante "github.com/cosmos/evm/ante/evm" "github.com/cosmos/evm/testutil" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -289,7 +289,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) gas := uint64(200000) - amount := sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas)))) //#nosec G115 + amount := sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas)))) //#nosec G115 txBuilder, err := s.CreateTestEIP712TxBuilderMsgSend(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) s.Require().NoError(err) return txBuilder.GetTx() @@ -300,7 +300,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) gas := uint64(200000) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas))) //#nosec G115 + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas))) //#nosec G115 amount := sdk.NewCoins(coinAmount) txBuilder, err := s.CreateTestEIP712TxBuilderMsgDelegate(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) s.Require().NoError(err) @@ -311,7 +311,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 create validator", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712MsgCreateValidator(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -323,7 +323,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 create validator (with blank fields)", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712MsgCreateValidator2(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -335,7 +335,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 MsgSubmitProposal", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) gasAmount := sdk.NewCoins(coinAmount) gas := uint64(200000) // reusing the gasAmount for deposit @@ -350,7 +350,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) grantee := sdk.AccAddress("_______grantee______") - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) gasAmount := sdk.NewCoins(coinAmount) gas := uint64(200000) blockTime := time.Date(1, 1, 1, 1, 1, 1, 1, time.UTC) @@ -370,7 +370,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 MsgGrantAllowance", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) gasAmount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712GrantAllowance(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, gasAmount) @@ -383,7 +383,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 edit validator", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712MsgEditValidator(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -395,7 +395,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 submit evidence", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712MsgSubmitEvidence(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -407,7 +407,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 submit proposal v1", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712SubmitProposalV1(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -419,7 +419,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 MsgExec", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712MsgExec(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -431,7 +431,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 MsgVoteV1", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712MsgVoteV1(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -443,7 +443,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 Multiple MsgSend", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712MultipleMsgSend(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -455,7 +455,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 Multiple Different Msgs", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712MultipleDifferentMsgs(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -467,7 +467,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 Same Msgs, Different Schemas", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712SameMsgDifferentSchemas(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -479,7 +479,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 Zero Value Array (Should Not Omit Field)", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712ZeroValueArray(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -491,7 +491,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 Zero Value Number (Should Not Omit Field)", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712ZeroValueNumber(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -503,7 +503,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 MsgTransfer", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712MsgTransfer(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -515,7 +515,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "success- DeliverTx EIP712 MsgTransfer Without Memo", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712MsgTransferWithoutMemo(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -527,7 +527,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { "fails - DeliverTx EIP712 Multiple Signers", func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) - coinAmount := sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20)) + coinAmount := sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20)) amount := sdk.NewCoins(coinAmount) gas := uint64(200000) txBuilder, err := s.CreateTestEIP712MultipleSignerMsgs(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) @@ -540,7 +540,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) gas := uint64(200000) - amount := sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas)))) //#nosec G115 + amount := sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas)))) //#nosec G115 txBuilder, err := s.CreateTestEIP712TxBuilderMsgSend(from, privKey, "cosmos-1", 9002, gas, amount) s.Require().NoError(err) return txBuilder.GetTx() @@ -551,11 +551,11 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) gas := uint64(200000) - amount := sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas)))) //#nosec G115 + amount := sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas)))) //#nosec G115 txBuilder, err := s.CreateTestEIP712TxBuilderMsgSend(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) s.Require().NoError(err) txBuilder.SetGasLimit(uint64(300000)) - txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(30)))) + txBuilder.SetFeeAmount(sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(30)))) return txBuilder.GetTx() }, false, false, false, }, @@ -564,7 +564,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) gas := uint64(200000) - amount := sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas)))) //#nosec G115 + amount := sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas)))) //#nosec G115 txBuilder, err := s.CreateTestEIP712TxBuilderMsgSend(from, privKey, "cosmos-1", 9005, gas, amount) s.Require().NoError(err) return txBuilder.GetTx() @@ -575,7 +575,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) gas := uint64(200000) - amount := sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas)))) //#nosec G115 + amount := sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas)))) //#nosec G115 txBuilder, err := s.CreateTestEIP712TxBuilderMsgSend(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) s.Require().NoError(err) nonce, err := s.GetNetwork().App.GetAccountKeeper().GetSequence(ctx, s.GetKeyring().GetAccAddr(0)) @@ -598,7 +598,7 @@ func (s *EvmAnteTestSuite) TestAnteHandler() { func() sdk.Tx { from := s.GetKeyring().GetAccAddr(0) gas := uint64(200000) - amount := sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas)))) //#nosec G115 + amount := sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(100*int64(gas)))) //#nosec G115 txBuilder, err := s.CreateTestEIP712TxBuilderMsgSend(from, privKey, ctx.ChainID(), ethCfg.ChainID.Uint64(), gas, amount) s.Require().NoError(err) nonce, err := s.GetNetwork().App.GetAccountKeeper().GetSequence(ctx, s.GetKeyring().GetAccAddr(0)) diff --git a/tests/integration/ante/test_evm_fee_market.go b/tests/integration/ante/test_evm_fee_market.go index 5008f0c9d..8b916d03b 100644 --- a/tests/integration/ante/test_evm_fee_market.go +++ b/tests/integration/ante/test_evm_fee_market.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/evm/ante/evm" "github.com/cosmos/evm/server/config" "github.com/cosmos/evm/testutil" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -97,7 +97,7 @@ func (s *EvmAnteTestSuite) TestGasWantedDecorator() { "EIP712 message", 200000, func() sdk.Tx { - amount := sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(20))) + amount := sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(20))) gas := uint64(200000) acc := s.GetNetwork().App.GetAccountKeeper().NewAccountWithAddress(ctx, from.Bytes()) s.Require().NoError(acc.SetSequence(1)) @@ -112,13 +112,13 @@ func (s *EvmAnteTestSuite) TestGasWantedDecorator() { "Cosmos Tx - gasWanted > max block gas", TestGasLimit, func() sdk.Tx { - denom := testconstants.ExampleAttoDenom + denom := testconfig.ExampleAttoDenom testMsg := banktypes.MsgSend{ FromAddress: "cosmos1x8fhpj9nmhqk8z9kpgjt95ck2xwyue0ptzkucp", ToAddress: "cosmos1dx67l23hz9l0k9hcher8xz04uj7wf3yu26l2yn", Amount: sdk.Coins{sdk.Coin{Amount: sdkmath.NewInt(10), Denom: denom}}, } - txBuilder := s.CreateTestCosmosTxBuilder(sdkmath.NewInt(10), testconstants.ExampleAttoDenom, &testMsg) + txBuilder := s.CreateTestCosmosTxBuilder(sdkmath.NewInt(10), testconfig.ExampleAttoDenom, &testMsg) limit := types.BlockGasLimit(ctx) txBuilder.SetGasLimit(limit + 5) return txBuilder.GetTx() diff --git a/tests/integration/ante/test_evm_unit_04_validate.go b/tests/integration/ante/test_evm_unit_04_validate.go index 8e87308cd..a6fae294b 100644 --- a/tests/integration/ante/test_evm_unit_04_validate.go +++ b/tests/integration/ante/test_evm_unit_04_validate.go @@ -8,7 +8,7 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/cosmos/evm/ante/evm" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" testkeyring "github.com/cosmos/evm/testutil/keyring" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -236,17 +236,17 @@ func (s *EvmUnitAnteTestSuite) TestCheckTxFee() { }, } - for _, chainID := range []testconstants.ChainID{ - testconstants.ExampleChainID, - testconstants.SixDecimalsChainID, + for _, chainID := range []testconfig.ChainID{ + testconfig.ExampleChainID, + testconfig.ExampleSixDecimalsChainID, } { for _, tc := range testCases { s.Run(fmt.Sprintf("%s, %s", chainID.ChainID, tc.name), func() { // Call the configurator to set the EVM coin required for the // function to be tested. - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - s.Require().NoError(configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[chainID]).Configure()) + s.Require().NoError(configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[chainID]).Apply()) // If decimals is not 18 decimals, we have to convert txFeeInfo to original // decimals representation. diff --git a/tests/integration/ante/test_evm_unit_06_account_verification.go b/tests/integration/ante/test_evm_unit_06_account_verification.go index b9e248afd..88abfb587 100644 --- a/tests/integration/ante/test_evm_unit_06_account_verification.go +++ b/tests/integration/ante/test_evm_unit_06_account_verification.go @@ -7,7 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/cosmos/evm/ante/evm" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -30,7 +30,7 @@ func (s *EvmUnitAnteTestSuite) TestVerifyAccountBalance() { unitNetwork := network.NewUnitTestNetwork( s.create, network.WithPreFundedAccounts(keyring.GetAllAccAddrs()...), - network.WithChainID(testconstants.ChainID{ + network.WithChainID(testconfig.ChainID{ ChainID: s.ChainID, EVMChainID: s.EvmChainID, }), diff --git a/tests/integration/ante/test_evm_unit_08_gas_consume.go b/tests/integration/ante/test_evm_unit_08_gas_consume.go index 605221891..fae0cf0b3 100644 --- a/tests/integration/ante/test_evm_unit_08_gas_consume.go +++ b/tests/integration/ante/test_evm_unit_08_gas_consume.go @@ -4,7 +4,7 @@ import ( "fmt" evmante "github.com/cosmos/evm/ante/evm" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" commonfactory "github.com/cosmos/evm/testutil/integration/base/factory" testfactory "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" @@ -22,7 +22,7 @@ func (s *EvmUnitAnteTestSuite) TestUpdateCumulativeGasWanted() { keyring := testkeyring.New(1) unitNetwork := network.NewUnitTestNetwork( s.create, - network.WithChainID(testconstants.ChainID{ + network.WithChainID(testconfig.ChainID{ ChainID: s.ChainID, EVMChainID: s.EvmChainID, }), @@ -99,7 +99,7 @@ func (s *EvmUnitAnteTestSuite) TestConsumeGasAndEmitEvent() { keyring := testkeyring.New(1) unitNetwork := network.NewUnitTestNetwork( s.create, - network.WithChainID(testconstants.ChainID{ + network.WithChainID(testconfig.ChainID{ ChainID: s.ChainID, EVMChainID: s.EvmChainID, }), diff --git a/tests/integration/ante/test_evm_unit_09_increment_sequence.go b/tests/integration/ante/test_evm_unit_09_increment_sequence.go index d2b3e0b64..d1fde3185 100644 --- a/tests/integration/ante/test_evm_unit_09_increment_sequence.go +++ b/tests/integration/ante/test_evm_unit_09_increment_sequence.go @@ -3,7 +3,7 @@ package ante import ( "github.com/cosmos/evm/ante/evm" "github.com/cosmos/evm/mempool" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" testkeyring "github.com/cosmos/evm/testutil/keyring" @@ -16,7 +16,7 @@ func (s *EvmUnitAnteTestSuite) TestIncrementSequence() { keyring := testkeyring.New(1) unitNetwork := network.NewUnitTestNetwork( s.create, - network.WithChainID(testconstants.ChainID{ + network.WithChainID(testconfig.ChainID{ ChainID: s.ChainID, EVMChainID: s.EvmChainID, }), diff --git a/tests/integration/ante/test_evm_unit_10_gas_wanted.go b/tests/integration/ante/test_evm_unit_10_gas_wanted.go index 5c30816bc..7915bcbd2 100644 --- a/tests/integration/ante/test_evm_unit_10_gas_wanted.go +++ b/tests/integration/ante/test_evm_unit_10_gas_wanted.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/cosmos/evm/ante/evm" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -22,7 +22,7 @@ func (s *EvmUnitAnteTestSuite) TestCheckGasWanted() { keyring := testkeyring.New(1) unitNetwork := network.NewUnitTestNetwork( s.create, - network.WithChainID(testconstants.ChainID{ + network.WithChainID(testconfig.ChainID{ ChainID: s.ChainID, EVMChainID: s.EvmChainID, }), diff --git a/tests/integration/ante/test_integration.go b/tests/integration/ante/test_integration.go index 3bf348aff..03bdfc10e 100644 --- a/tests/integration/ante/test_integration.go +++ b/tests/integration/ante/test_integration.go @@ -10,7 +10,7 @@ import ( //nolint:revive // dot imports are fine for Ginkgo . "github.com/onsi/gomega" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" commonfactory "github.com/cosmos/evm/testutil/integration/base/factory" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" @@ -57,7 +57,7 @@ func (s *IntegrationTestSuite) SetupTest() { // set non-zero inflation for rewards to accrue (use defaults from SDK for values) mintGen := minttypes.DefaultGenesisState() - mintGen.Params.MintDenom = testconstants.ExampleAttoDenom + mintGen.Params.MintDenom = testconfig.ExampleAttoDenom customGen[minttypes.ModuleName] = mintGen operatorsAddr := make([]sdk.AccAddress, 3) diff --git a/tests/integration/ante/test_min_gas_price.go b/tests/integration/ante/test_min_gas_price.go index 2c06894d1..77a0682bc 100644 --- a/tests/integration/ante/test_min_gas_price.go +++ b/tests/integration/ante/test_min_gas_price.go @@ -5,7 +5,7 @@ import ( cosmosante "github.com/cosmos/evm/ante/cosmos" "github.com/cosmos/evm/testutil" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" testutiltx "github.com/cosmos/evm/testutil/tx" "cosmossdk.io/math" @@ -24,7 +24,7 @@ var execTypes = []struct { } func (s *AnteTestSuite) TestMinGasPriceDecorator() { - denom := constants.ExampleAttoDenom + denom := testconfig.ExampleAttoDenom testMsg := banktypes.MsgSend{ FromAddress: "cosmos1x8fhpj9nmhqk8z9kpgjt95ck2xwyue0ptzkucp", ToAddress: "cosmos1dx67l23hz9l0k9hcher8xz04uj7wf3yu26l2yn", diff --git a/tests/integration/eip712/test_eip712.go b/tests/integration/eip712/test_eip712.go index 92b498139..fc78c8038 100644 --- a/tests/integration/eip712/test_eip712.go +++ b/tests/integration/eip712/test_eip712.go @@ -12,8 +12,7 @@ import ( "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/ethereum/eip712" - "github.com/cosmos/evm/testutil/config" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/network" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -73,7 +72,7 @@ func (s *TestSuite) SetupTest() { s.clientCtx = client.Context{}.WithTxConfig(s.config.TxConfig) s.denom = evmtypes.GetEVMCoinDenom() - sdk.GetConfig().SetBech32PrefixForAccount(config.Bech32Prefix, "") + sdk.GetConfig().SetBech32PrefixForAccount(sdk.Bech32MainPrefix, "") } // createTestAddress creates random test addresses for messages @@ -333,7 +332,7 @@ func (s *TestSuite) TestEIP712() { err = txBuilder.SetSignatures([]signing.SignatureV2{txSig}...) s.Require().NoError(err) - chainID := constants.ExampleChainID.ChainID + chainID := testconfig.ExampleChainID.ChainID if tc.chainID != "" { chainID = tc.chainID } @@ -347,7 +346,7 @@ func (s *TestSuite) TestEIP712() { AccountNumber: params.accountNumber, Sequence: params.sequence, PubKey: pubKey, - Address: sdk.MustBech32ifyAddressBytes(constants.ExampleBech32Prefix, pubKey.Bytes()), + Address: sdk.MustBech32ifyAddressBytes(sdk.Bech32MainPrefix, pubKey.Bytes()), } bz, err := authsigning.GetSignBytesAdapter( diff --git a/tests/integration/indexer/test_kv_indexer.go b/tests/integration/indexer/test_kv_indexer.go index 93a62d8db..0fa0ddf97 100644 --- a/tests/integration/indexer/test_kv_indexer.go +++ b/tests/integration/indexer/test_kv_indexer.go @@ -14,7 +14,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/indexer" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/network" utiltx "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/evm/x/vm/types" @@ -48,7 +48,7 @@ func TestKVIndexer(t *testing.T, create network.CreateEvmApp, options ...network clientCtx := client.Context{}.WithTxConfig(encodingConfig.TxConfig).WithCodec(encodingConfig.Codec) // build cosmos-sdk wrapper tx - tmTx, err := tx.BuildTx(clientCtx.TxConfig.NewTxBuilder(), constants.ExampleAttoDenom) + tmTx, err := tx.BuildTx(clientCtx.TxConfig.NewTxBuilder(), testconfig.ExampleAttoDenom) require.NoError(t, err) txBz, err := clientCtx.TxConfig.TxEncoder()(tmTx) require.NoError(t, err) diff --git a/tests/integration/mempool/test_setup.go b/tests/integration/mempool/test_setup.go index ae80aaee4..de922bec0 100644 --- a/tests/integration/mempool/test_setup.go +++ b/tests/integration/mempool/test_setup.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/suite" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -39,11 +39,11 @@ func NewMempoolIntegrationTestSuite(create network.CreateEvmApp, options ...netw // SetupTest initializes the test environment with default settings. func (s *IntegrationTestSuite) SetupTest() { - s.SetupTestWithChainID(testconstants.ExampleChainID) + s.SetupTestWithChainID(testconfig.ExampleChainID) } // SetupTestWithChainID initializes the test environment with a specific chain ID. -func (s *IntegrationTestSuite) SetupTestWithChainID(chainID testconstants.ChainID) { +func (s *IntegrationTestSuite) SetupTestWithChainID(chainID testconfig.ChainID) { s.keyring = keyring.New(20) options := []network.ConfigOption{ diff --git a/tests/integration/precompiles/bech32/test_bech32.go b/tests/integration/precompiles/bech32/test_bech32.go index ef6f258b9..d023ba513 100644 --- a/tests/integration/precompiles/bech32/test_bech32.go +++ b/tests/integration/precompiles/bech32/test_bech32.go @@ -6,7 +6,6 @@ import ( "github.com/holiman/uint256" "github.com/cosmos/evm/precompiles/bech32" - "github.com/cosmos/evm/testutil/config" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -111,7 +110,7 @@ func (s *PrecompileTestSuite) TestRun() { input, err := s.precompile.Pack( bech32.HexToBech32Method, s.keyring.GetAddr(0), - config.Bech32Prefix, + sdk.Bech32MainPrefix, ) s.Require().NoError(err, "failed to pack input") contract.Input = input @@ -137,7 +136,7 @@ func (s *PrecompileTestSuite) TestRun() { input, err := s.precompile.Pack( bech32.HexToBech32Method, common.BytesToAddress(valAddrBz), - config.Bech32PrefixValAddr, + sdk.Bech32PrefixValAddr, ) s.Require().NoError(err, "failed to pack input") contract.Input = input @@ -160,7 +159,7 @@ func (s *PrecompileTestSuite) TestRun() { input, err := s.precompile.Pack( bech32.HexToBech32Method, s.keyring.GetAddr(0), - config.Bech32PrefixConsAddr, + sdk.Bech32PrefixConsAddr, ) s.Require().NoError(err, "failed to pack input") contract.Input = input diff --git a/tests/integration/precompiles/bech32/test_methods.go b/tests/integration/precompiles/bech32/test_methods.go index 592554cd6..f8539f352 100644 --- a/tests/integration/precompiles/bech32/test_methods.go +++ b/tests/integration/precompiles/bech32/test_methods.go @@ -7,7 +7,6 @@ import ( "github.com/cosmos/evm/precompiles/bech32" cmn "github.com/cosmos/evm/precompiles/common" - "github.com/cosmos/evm/testutil/config" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -63,7 +62,7 @@ func (s *PrecompileTestSuite) TestHexToBech32() { func() []interface{} { return []interface{}{ s.keyring.GetAddr(0), - config.Bech32Prefix, + sdk.Bech32MainPrefix, } }, func(data []byte) { @@ -135,18 +134,18 @@ func (s *PrecompileTestSuite) TestBech32ToHex() { "fail - invalid bech32 address", func() []interface{} { return []interface{}{ - config.Bech32Prefix, + sdk.Bech32MainPrefix, } }, func([]byte) {}, true, - fmt.Sprintf("invalid bech32 address: %s", config.Bech32Prefix), + fmt.Sprintf("invalid bech32 address: %s", sdk.Bech32MainPrefix), }, { "fail - decoding bech32 failed", func() []interface{} { return []interface{}{ - config.Bech32Prefix + "1", + sdk.Bech32MainPrefix + "1", } }, func([]byte) {}, diff --git a/tests/integration/precompiles/distribution/test_distribution.go b/tests/integration/precompiles/distribution/test_distribution.go index c749828b5..6dfd519fa 100644 --- a/tests/integration/precompiles/distribution/test_distribution.go +++ b/tests/integration/precompiles/distribution/test_distribution.go @@ -13,7 +13,7 @@ import ( "github.com/cosmos/evm/precompiles/distribution" "github.com/cosmos/evm/precompiles/testutil" chainutil "github.com/cosmos/evm/testutil" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/math" @@ -86,7 +86,7 @@ func (s *PrecompileTestSuite) TestRun() { valAddr, err := sdk.ValAddressFromBech32(s.network.GetValidators()[0].OperatorAddress) s.Require().NoError(err) val, _ := s.network.App.GetStakingKeeper().GetValidator(ctx, valAddr) - coins := sdk.NewCoins(sdk.NewCoin(constants.ExampleAttoDenom, math.NewInt(1e18))) + coins := sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(1e18))) s.Require().NoError(s.network.App.GetDistrKeeper().AllocateTokensToValidator(ctx, val, sdk.NewDecCoinsFromCoins(coins...))) input, err := s.precompile.Pack( @@ -109,7 +109,7 @@ func (s *PrecompileTestSuite) TestRun() { caller := common.BytesToAddress(valAddr) commAmt := math.LegacyNewDecWithPrec(1000000000000000000, 1) - valCommission := sdk.DecCoins{sdk.NewDecCoinFromDec(constants.ExampleAttoDenom, commAmt)} + valCommission := sdk.DecCoins{sdk.NewDecCoinFromDec(testconfig.ExampleAttoDenom, commAmt)} // set outstanding rewards s.Require().NoError(s.network.App.GetDistrKeeper().SetValidatorOutstandingRewards(ctx, valAddr, types.ValidatorOutstandingRewards{Rewards: valCommission})) // set commission @@ -189,7 +189,7 @@ func (s *PrecompileTestSuite) TestRun() { s.keyring.GetAddr(0), []cmn.Coin{ { - Denom: constants.ExampleAttoDenom, + Denom: testconfig.ExampleAttoDenom, Amount: big.NewInt(1e18), }, }, @@ -209,7 +209,7 @@ func (s *PrecompileTestSuite) TestRun() { s.keyring.GetAddr(0), []cmn.Coin{ { - Denom: constants.ExampleAttoDenom, + Denom: testconfig.ExampleAttoDenom, Amount: big.NewInt(1e18), }, { @@ -312,7 +312,7 @@ func (s *PrecompileTestSuite) TestCMS() { valAddr, err := sdk.ValAddressFromBech32(s.network.GetValidators()[0].OperatorAddress) s.Require().NoError(err) val, _ := s.network.App.GetStakingKeeper().GetValidator(ctx, valAddr) - coins := sdk.NewCoins(sdk.NewCoin(constants.ExampleAttoDenom, math.NewInt(1e18))) + coins := sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(1e18))) s.Require().NoError(s.network.App.GetDistrKeeper().AllocateTokensToValidator(ctx, val, sdk.NewDecCoinsFromCoins(coins...))) input, err := s.precompile.Pack( @@ -334,7 +334,7 @@ func (s *PrecompileTestSuite) TestCMS() { caller := common.BytesToAddress(valAddr) commAmt := math.LegacyNewDecWithPrec(1000000000000000000, 1) - valCommission := sdk.DecCoins{sdk.NewDecCoinFromDec(constants.ExampleAttoDenom, commAmt)} + valCommission := sdk.DecCoins{sdk.NewDecCoinFromDec(testconfig.ExampleAttoDenom, commAmt)} // set outstanding rewards s.Require().NoError(s.network.App.GetDistrKeeper().SetValidatorOutstandingRewards(ctx, valAddr, types.ValidatorOutstandingRewards{Rewards: valCommission})) // set commission @@ -411,7 +411,7 @@ func (s *PrecompileTestSuite) TestCMS() { s.keyring.GetAddr(0), []cmn.Coin{ { - Denom: constants.ExampleAttoDenom, + Denom: testconfig.ExampleAttoDenom, Amount: big.NewInt(1e18), }, }, @@ -430,7 +430,7 @@ func (s *PrecompileTestSuite) TestCMS() { s.keyring.GetAddr(0), []cmn.Coin{ { - Denom: constants.ExampleAttoDenom, + Denom: testconfig.ExampleAttoDenom, Amount: big.NewInt(1e18), }, { diff --git a/tests/integration/precompiles/distribution/test_event.go b/tests/integration/precompiles/distribution/test_event.go index c83178113..3b0c530ee 100644 --- a/tests/integration/precompiles/distribution/test_event.go +++ b/tests/integration/precompiles/distribution/test_event.go @@ -11,8 +11,7 @@ import ( cmn "github.com/cosmos/evm/precompiles/common" "github.com/cosmos/evm/precompiles/distribution" "github.com/cosmos/evm/precompiles/testutil" - "github.com/cosmos/evm/testutil/config" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/x/vm/statedb" "cosmossdk.io/math" @@ -59,7 +58,7 @@ func (s *PrecompileTestSuite) TestSetWithdrawAddressEvent() { err := cmn.UnpackLog(s.precompile.ABI, &setWithdrawerAddrEvent, distribution.EventTypeSetWithdrawAddress, *log) s.Require().NoError(err) s.Require().Equal(s.keyring.GetAddr(0), setWithdrawerAddrEvent.Caller) - s.Require().Equal(sdk.MustBech32ifyAddressBytes(config.Bech32Prefix, s.keyring.GetAddr(0).Bytes()), setWithdrawerAddrEvent.WithdrawerAddress) + s.Require().Equal(sdk.MustBech32ifyAddressBytes(sdk.Bech32MainPrefix, s.keyring.GetAddr(0).Bytes()), setWithdrawerAddrEvent.WithdrawerAddress) }, 20000, false, @@ -188,13 +187,13 @@ func (s *PrecompileTestSuite) TestWithdrawValidatorCommissionEvent() { func(operatorAddress string) []interface{} { valAddr, err := sdk.ValAddressFromBech32(operatorAddress) s.Require().NoError(err) - valCommission := sdk.DecCoins{sdk.NewDecCoinFromDec(constants.ExampleAttoDenom, math.LegacyNewDecFromInt(amt))} + valCommission := sdk.DecCoins{sdk.NewDecCoinFromDec(testconfig.ExampleAttoDenom, math.LegacyNewDecFromInt(amt))} // set outstanding rewards s.Require().NoError(s.network.App.GetDistrKeeper().SetValidatorOutstandingRewards(ctx, valAddr, types.ValidatorOutstandingRewards{Rewards: valCommission})) // set commission s.Require().NoError(s.network.App.GetDistrKeeper().SetValidatorAccumulatedCommission(ctx, valAddr, types.ValidatorAccumulatedCommission{Commission: valCommission})) // set funds to distr mod to pay for commission - coins := sdk.NewCoins(sdk.NewCoin(constants.ExampleAttoDenom, amt)) + coins := sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, amt)) err = s.mintCoinsForDistrMod(ctx, coins) s.Require().NoError(err) return []interface{}{ @@ -260,7 +259,7 @@ func (s *PrecompileTestSuite) TestClaimRewardsEvent() { }{ { "success", - sdk.NewCoins(sdk.NewCoin(constants.ExampleAttoDenom, math.NewInt(1e18))), + sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(1e18))), func() { log := stDB.Logs()[0] s.Require().Equal(log.Address, s.precompile.Address()) @@ -302,7 +301,7 @@ func (s *PrecompileTestSuite) TestFundCommunityPoolEvent() { }{ { "success - the correct event is emitted", - sdk.NewCoins(sdk.NewCoin(constants.ExampleAttoDenom, math.NewInt(1e18))), + sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(1e18))), func(coins sdk.Coins) { log := stDB.Logs()[0] s.Require().Equal(log.Address, s.precompile.Address()) @@ -315,7 +314,7 @@ func (s *PrecompileTestSuite) TestFundCommunityPoolEvent() { err := cmn.UnpackLog(s.precompile.ABI, &fundCommunityPoolEvent, distribution.EventTypeFundCommunityPool, *log) s.Require().NoError(err) s.Require().Equal(s.keyring.GetAddr(0), fundCommunityPoolEvent.Depositor) - s.Require().Equal(constants.ExampleAttoDenom, fundCommunityPoolEvent.Denom) + s.Require().Equal(testconfig.ExampleAttoDenom, fundCommunityPoolEvent.Denom) s.Require().Equal(big.NewInt(1e18), fundCommunityPoolEvent.Amount) }, }, @@ -323,9 +322,9 @@ func (s *PrecompileTestSuite) TestFundCommunityPoolEvent() { // New multi-coin deposit test case name: "success - multiple coins => multiple events emitted", coins: sdk.NewCoins( - sdk.NewCoin(constants.ExampleAttoDenom, math.NewInt(10)), // coin #1 - sdk.NewCoin(constants.OtherCoinDenoms[0], math.NewInt(20)), // coin #2 - sdk.NewCoin(constants.OtherCoinDenoms[1], math.NewInt(30)), // coin #3 + sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(10)), // coin #1 + sdk.NewCoin(testconfig.OtherCoinDenoms[0], math.NewInt(20)), // coin #2 + sdk.NewCoin(testconfig.OtherCoinDenoms[1], math.NewInt(30)), // coin #3 ).Sort(), postCheck: func(coins sdk.Coins) { logs := stDB.Logs() @@ -394,7 +393,7 @@ func (s *PrecompileTestSuite) TestDepositValidatorRewardsPoolEvent() { func(operatorAddress string) ([]interface{}, sdk.Coins) { coins := []cmn.Coin{ { - Denom: constants.ExampleAttoDenom, + Denom: testconfig.ExampleAttoDenom, Amount: big.NewInt(1e18), }, } @@ -425,7 +424,7 @@ func (s *PrecompileTestSuite) TestDepositValidatorRewardsPoolEvent() { s.Require().NoError(err) s.Require().Equal(depositValidatorRewardsPool.Depositor, s.keyring.GetAddr(0)) s.Require().Equal(depositValidatorRewardsPool.ValidatorAddress, common.BytesToAddress(valAddr.Bytes())) - s.Require().Equal(depositValidatorRewardsPool.Denom, constants.ExampleAttoDenom) + s.Require().Equal(depositValidatorRewardsPool.Denom, testconfig.ExampleAttoDenom) s.Require().Equal(depositValidatorRewardsPool.Amount, amt.BigInt()) }, 20000, @@ -437,7 +436,7 @@ func (s *PrecompileTestSuite) TestDepositValidatorRewardsPoolEvent() { func(operatorAddress string) ([]interface{}, sdk.Coins) { coins := []cmn.Coin{ { - Denom: constants.ExampleAttoDenom, + Denom: testconfig.ExampleAttoDenom, Amount: big.NewInt(1e18), }, { diff --git a/tests/integration/precompiles/distribution/test_integration.go b/tests/integration/precompiles/distribution/test_integration.go index 53500a6b6..86ce50fd5 100644 --- a/tests/integration/precompiles/distribution/test_integration.go +++ b/tests/integration/precompiles/distribution/test_integration.go @@ -18,7 +18,7 @@ import ( "github.com/cosmos/evm/precompiles/staking" "github.com/cosmos/evm/precompiles/testutil" "github.com/cosmos/evm/precompiles/testutil/contracts" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/network" "github.com/cosmos/evm/testutil/integration/evm/utils" testutiltx "github.com/cosmos/evm/testutil/tx" @@ -52,7 +52,7 @@ var ( txArgs evmtypes.EvmTxArgs // minExpRewardOrCommission is the minimun coins expected for validator's rewards or commission // required for the tests - minExpRewardOrCommission = sdk.NewDecCoins(sdk.NewDecCoin(testconstants.ExampleAttoDenom, testRewardsAmt)) + minExpRewardOrCommission = sdk.NewDecCoins(sdk.NewDecCoin(testconfig.ExampleAttoDenom, testRewardsAmt)) ) func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmApp, options ...network.ConfigOption) { @@ -905,8 +905,8 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmAp fundAmt := math.NewInt(10) sendAmt := []cmn.Coin{ {Denom: s.bondDenom, Amount: fundAmt.BigInt()}, - {Denom: testconstants.OtherCoinDenoms[0], Amount: fundAmt.BigInt()}, - {Denom: testconstants.OtherCoinDenoms[1], Amount: fundAmt.BigInt()}, + {Denom: testconfig.OtherCoinDenoms[0], Amount: fundAmt.BigInt()}, + {Denom: testconfig.OtherCoinDenoms[1], Amount: fundAmt.BigInt()}, } sendSdkCoins, err := cmn.NewSdkCoinsFromCoins(sendAmt) Expect(err).To(BeNil()) diff --git a/tests/integration/precompiles/distribution/test_setup.go b/tests/integration/precompiles/distribution/test_setup.go index 57b15cb85..08cfcce26 100644 --- a/tests/integration/precompiles/distribution/test_setup.go +++ b/tests/integration/precompiles/distribution/test_setup.go @@ -4,7 +4,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/evm/precompiles/distribution" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -57,7 +57,7 @@ func (s *PrecompileTestSuite) SetupTest() { customGen := network.CustomGenesisState{} // mint some coin to fee collector - coins := sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(1000000000000000000))) + coins := sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(1000000000000000000))) balances := []banktypes.Balance{ { Address: authtypes.NewModuleAddress(authtypes.FeeCollectorName).String(), @@ -90,7 +90,7 @@ func (s *PrecompileTestSuite) SetupTest() { // set non-zero inflation for rewards to accrue (use defaults from SDK for values) mintGen := minttypes.DefaultGenesisState() - mintGen.Params.MintDenom = testconstants.ExampleAttoDenom + mintGen.Params.MintDenom = testconfig.ExampleAttoDenom customGen[minttypes.ModuleName] = mintGen operatorsAddr := make([]sdk.AccAddress, 3) @@ -99,12 +99,12 @@ func (s *PrecompileTestSuite) SetupTest() { } s.otherDenoms = []string{ - testconstants.OtherCoinDenoms[0], - testconstants.OtherCoinDenoms[1], + testconfig.OtherCoinDenoms[0], + testconfig.OtherCoinDenoms[1], } options := []network.ConfigOption{ - network.WithOtherDenoms(testconstants.OtherCoinDenoms), + network.WithOtherDenoms(testconfig.OtherCoinDenoms), network.WithPreFundedAccounts(keyring.GetAllAccAddrs()...), network.WithOtherDenoms(s.otherDenoms), network.WithCustomGenesis(customGen), diff --git a/tests/integration/precompiles/distribution/test_tx.go b/tests/integration/precompiles/distribution/test_tx.go index 33db8c8b1..2acd9edfb 100644 --- a/tests/integration/precompiles/distribution/test_tx.go +++ b/tests/integration/precompiles/distribution/test_tx.go @@ -10,7 +10,7 @@ import ( cmn "github.com/cosmos/evm/precompiles/common" "github.com/cosmos/evm/precompiles/distribution" "github.com/cosmos/evm/precompiles/testutil" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/network" utiltx "github.com/cosmos/evm/testutil/tx" @@ -199,10 +199,10 @@ func (s *PrecompileTestSuite) TestWithdrawDelegatorReward() { var coins []cmn.Coin err := s.precompile.UnpackIntoInterface(&coins, distribution.WithdrawDelegatorRewardMethod, data) s.Require().NoError(err, "failed to unpack output") - s.Require().Equal(coins[0].Denom, testconstants.ExampleAttoDenom) + s.Require().Equal(coins[0].Denom, testconfig.ExampleAttoDenom) s.Require().Equal(coins[0].Amount.Int64(), expRewardsAmt.Int64()) // Check bank balance after the withdrawal of rewards - balance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), testconstants.ExampleAttoDenom) + balance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), testconfig.ExampleAttoDenom) s.Require().True(balance.Amount.GT(network.PrefundedAccountInitialBalance)) }, 20000, @@ -275,14 +275,14 @@ func (s *PrecompileTestSuite) TestWithdrawValidatorCommission() { valAddr, err := sdk.ValAddressFromBech32(operatorAddress) s.Require().NoError(err) amt := math.LegacyNewDecWithPrec(1000000000000000000, 1) - valCommission := sdk.DecCoins{sdk.NewDecCoinFromDec(testconstants.ExampleAttoDenom, amt)} + valCommission := sdk.DecCoins{sdk.NewDecCoinFromDec(testconfig.ExampleAttoDenom, amt)} // set outstanding rewards s.Require().NoError(s.network.App.GetDistrKeeper().SetValidatorOutstandingRewards(ctx, valAddr, types.ValidatorOutstandingRewards{Rewards: valCommission})) // set commission s.Require().NoError(s.network.App.GetDistrKeeper().SetValidatorAccumulatedCommission(ctx, valAddr, types.ValidatorAccumulatedCommission{Commission: valCommission})) // fund distr mod to pay for rewards + commission - coins := sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, amt.Mul(math.LegacyNewDec(2)).RoundInt())) + coins := sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, amt.Mul(math.LegacyNewDec(2)).RoundInt())) err = s.mintCoinsForDistrMod(ctx, coins) s.Require().NoError(err) return []interface{}{ @@ -294,15 +294,15 @@ func (s *PrecompileTestSuite) TestWithdrawValidatorCommission() { amt := math.NewInt(100000000000000000) err := s.precompile.UnpackIntoInterface(&coins, distribution.WithdrawValidatorCommissionMethod, data) s.Require().NoError(err, "failed to unpack output") - s.Require().Equal(coins[0].Denom, testconstants.ExampleAttoDenom) + s.Require().Equal(coins[0].Denom, testconfig.ExampleAttoDenom) s.Require().Equal(coins[0].Amount, amt.BigInt()) // Check bank balance after the withdrawal of commission valAddr, err := sdk.ValAddressFromBech32(s.network.GetValidators()[0].GetOperator()) s.Require().NoError(err) - balance := s.network.App.GetBankKeeper().GetBalance(ctx, valAddr.Bytes(), testconstants.ExampleAttoDenom) + balance := s.network.App.GetBankKeeper().GetBalance(ctx, valAddr.Bytes(), testconfig.ExampleAttoDenom) s.Require().Equal(balance.Amount, prevBalance.Amount.Add(amt)) - s.Require().Equal(balance.Denom, testconstants.ExampleAttoDenom) + s.Require().Equal(balance.Denom, testconfig.ExampleAttoDenom) }, 20000, false, @@ -318,7 +318,7 @@ func (s *PrecompileTestSuite) TestWithdrawValidatorCommission() { valAddr, err := sdk.ValAddressFromBech32(s.network.GetValidators()[0].GetOperator()) s.Require().NoError(err) - prevBalance = s.network.App.GetBankKeeper().GetBalance(ctx, valAddr.Bytes(), testconstants.ExampleAttoDenom) + prevBalance = s.network.App.GetBankKeeper().GetBalance(ctx, valAddr.Bytes(), testconfig.ExampleAttoDenom) validatorAddress := common.BytesToAddress(valAddr.Bytes()) var contract *vm.Contract @@ -409,7 +409,7 @@ func (s *PrecompileTestSuite) TestClaimRewards() { } }, func(_ []byte) { - balance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAccAddr(0), testconstants.ExampleAttoDenom) + balance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAccAddr(0), testconfig.ExampleAttoDenom) // rewards from 3 validators - 5% commission expRewards := expRewardsAmt.Mul(math.NewInt(3)) s.Require().Equal(balance.Amount, prevBalance.Amount.Add(expRewards)) @@ -427,7 +427,7 @@ func (s *PrecompileTestSuite) TestClaimRewards() { } }, func([]byte) { - balance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAccAddr(0), testconstants.ExampleAttoDenom) + balance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAccAddr(0), testconfig.ExampleAttoDenom) // rewards from 3 validators - 5% commission expRewards := expRewardsAmt.Mul(math.NewInt(3)) s.Require().Equal(balance.Amount, prevBalance.Amount.Add(expRewards)) @@ -445,7 +445,7 @@ func (s *PrecompileTestSuite) TestClaimRewards() { } }, func([]byte) { - balance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAccAddr(0), testconstants.ExampleAttoDenom) + balance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAccAddr(0), testconfig.ExampleAttoDenom) s.Require().Equal(balance.Amount, prevBalance.Amount.Add(expRewardsAmt)) }, 20000, @@ -480,7 +480,7 @@ func (s *PrecompileTestSuite) TestClaimRewards() { s.Require().NoError(err) // get previous balance to compare final balance in the postCheck func - prevBalance = s.network.App.GetBankKeeper().GetBalance(ctx, addr.Bytes(), testconstants.ExampleAttoDenom) + prevBalance = s.network.App.GetBankKeeper().GetBalance(ctx, addr.Bytes(), testconfig.ExampleAttoDenom) bz, err := s.precompile.ClaimRewards(ctx, contract, s.network.GetStateDB(), &method, tc.malleate()) @@ -536,7 +536,7 @@ func (s *PrecompileTestSuite) TestFundCommunityPool() { s.keyring.GetAddr(0), []cmn.Coin{ { - Denom: testconstants.ExampleAttoDenom, + Denom: testconfig.ExampleAttoDenom, Amount: big.NewInt(1e18), }, }, @@ -547,8 +547,8 @@ func (s *PrecompileTestSuite) TestFundCommunityPool() { s.Require().NoError(err) coins := pool.CommunityPool expectedAmount := new(big.Int).Mul(big.NewInt(1e18), new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(math.LegacyPrecision)), nil)) - s.Require().Equal(expectedAmount, coins.AmountOf(testconstants.ExampleAttoDenom).BigInt()) - userBalance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), testconstants.ExampleAttoDenom) + s.Require().Equal(expectedAmount, coins.AmountOf(testconfig.ExampleAttoDenom).BigInt()) + userBalance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), testconfig.ExampleAttoDenom) s.Require().Equal(network.PrefundedAccountInitialBalance.Sub(math.NewInt(1e18)), userBalance.Amount) }, 20000, @@ -566,7 +566,7 @@ func (s *PrecompileTestSuite) TestFundCommunityPool() { contract, ctx = testutil.NewPrecompileContract(s.T(), ctx, s.keyring.GetAddr(0), s.precompile.Address(), tc.gas) // Sanity check to make sure the starting balance is always 100k ATOM - balance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), testconstants.ExampleAttoDenom) + balance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), testconfig.ExampleAttoDenom) s.Require().Equal(balance.Amount, network.PrefundedAccountInitialBalance) bz, err := s.precompile.FundCommunityPool(ctx, contract, s.network.GetStateDB(), &method, tc.malleate()) @@ -611,7 +611,7 @@ func (s *PrecompileTestSuite) TestDepositValidatorRewardsPoolMethod() { val.OperatorAddress, []cmn.Coin{ { - Denom: testconstants.ExampleAttoDenom, + Denom: testconfig.ExampleAttoDenom, Amount: big.NewInt(1e18), }, }, @@ -630,7 +630,7 @@ func (s *PrecompileTestSuite) TestDepositValidatorRewardsPoolMethod() { "", []cmn.Coin{ { - Denom: testconstants.ExampleAttoDenom, + Denom: testconfig.ExampleAttoDenom, Amount: big.NewInt(1e18), }, }, @@ -663,7 +663,7 @@ func (s *PrecompileTestSuite) TestDepositValidatorRewardsPoolMethod() { val.OperatorAddress, []cmn.Coin{ { - Denom: testconstants.ExampleAttoDenom, + Denom: testconfig.ExampleAttoDenom, Amount: big.NewInt(1e18), }, }, @@ -682,7 +682,7 @@ func (s *PrecompileTestSuite) TestDepositValidatorRewardsPoolMethod() { s.Require().NoError(err) depositCoins := sdk.DecCoins{ - {Denom: testconstants.ExampleAttoDenom, Amount: math.LegacyNewDecFromBigInt(big.NewInt(1e18))}, + {Denom: testconfig.ExampleAttoDenom, Amount: math.LegacyNewDecFromBigInt(big.NewInt(1e18))}, } expectedValCommission := depositCoins.MulDec(val.GetCommission()) expectedCurrentRewards := depositCoins.Sub(expectedValCommission) @@ -704,9 +704,9 @@ func (s *PrecompileTestSuite) TestDepositValidatorRewardsPoolMethod() { s.Require().Equal(expectedOutstandingRewards, outstandingRewards.Rewards) // check bank balance after the deposit - balance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), testconstants.ExampleAttoDenom) + balance := s.network.App.GetBankKeeper().GetBalance(ctx, s.keyring.GetAddr(0).Bytes(), testconfig.ExampleAttoDenom) s.Require().Equal(balance.Amount, network.PrefundedAccountInitialBalance.Sub(math.NewInt(1e18))) - s.Require().Equal(balance.Denom, testconstants.ExampleAttoDenom) + s.Require().Equal(balance.Denom, testconfig.ExampleAttoDenom) }, 20000, false, diff --git a/tests/integration/precompiles/erc20/test_integration.go b/tests/integration/precompiles/erc20/test_integration.go index 20869e598..408065a11 100644 --- a/tests/integration/precompiles/erc20/test_integration.go +++ b/tests/integration/precompiles/erc20/test_integration.go @@ -19,7 +19,7 @@ import ( "github.com/cosmos/evm/precompiles/erc20" "github.com/cosmos/evm/precompiles/erc20/testdata" "github.com/cosmos/evm/precompiles/testutil" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -251,7 +251,7 @@ func TestIntegrationTestSuite(t *testing.T, create network.CreateEvmApp, options passCheck = failCheck.WithExpPass(true) erc20Keeper := is.network.App.GetErc20Keeper() - available := erc20Keeper.IsNativePrecompileAvailable(is.network.GetContext(), common.HexToAddress(testconstants.WEVMOSContractMainnet)) + available := erc20Keeper.IsNativePrecompileAvailable(is.network.GetContext(), common.HexToAddress(testconfig.WevmosContractMainnet)) Expect(available).To(BeTrue()) revertContractAddr, err = is.factory.DeployContract( @@ -261,7 +261,7 @@ func TestIntegrationTestSuite(t *testing.T, create network.CreateEvmApp, options Contract: revertCallerContract, // NOTE: we're passing the precompile address to the constructor because that initiates the contract // to make calls to the correct ERC20 precompile. - ConstructorArgs: []interface{}{common.HexToAddress(testconstants.WEVMOSContractMainnet)}, + ConstructorArgs: []interface{}{common.HexToAddress(testconfig.WevmosContractMainnet)}, }, ) Expect(err).ToNot(HaveOccurred(), "failed to deploy reverter contract") diff --git a/tests/integration/precompiles/gov/test_query.go b/tests/integration/precompiles/gov/test_query.go index 3e57f40a9..ae52fe162 100644 --- a/tests/integration/precompiles/gov/test_query.go +++ b/tests/integration/precompiles/gov/test_query.go @@ -10,7 +10,7 @@ import ( cmn "github.com/cosmos/evm/precompiles/common" "github.com/cosmos/evm/precompiles/gov" "github.com/cosmos/evm/precompiles/testutil" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "cosmossdk.io/math" @@ -29,7 +29,7 @@ var ( govAcct = authtypes.NewModuleAddress(govtypes.ModuleName) // TestProposalMsgs are msgs used on a proposal. TestProposalMsgs = []sdk.Msg{ - banktypes.NewMsgSend(govAcct, addr, sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(1000)))), + banktypes.NewMsgSend(govAcct, addr, sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(1000)))), } ) diff --git a/tests/integration/precompiles/gov/test_setup.go b/tests/integration/precompiles/gov/test_setup.go index 312f91b47..e8c9c6063 100644 --- a/tests/integration/precompiles/gov/test_setup.go +++ b/tests/integration/precompiles/gov/test_setup.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/evm/precompiles/gov" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -100,7 +100,7 @@ func (s *PrecompileTestSuite) SetupTest() { bankGen := banktypes.DefaultGenesisState() bankGen.Balances = []banktypes.Balance{{ Address: authtypes.NewModuleAddress(govtypes.ModuleName).String(), - Coins: sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(200))), + Coins: sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(200))), }} govGen := govv1.DefaultGenesisState() govGen.StartingProposalId = 3 @@ -108,15 +108,15 @@ func (s *PrecompileTestSuite) SetupTest() { { ProposalId: 1, Depositor: keyring.GetAccAddr(0).String(), - Amount: sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(100))), + Amount: sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(100))), }, { ProposalId: 2, Depositor: keyring.GetAccAddr(1).String(), - Amount: sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(100))), + Amount: sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(100))), }, } - govGen.Params.MinDeposit = sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(100))) + govGen.Params.MinDeposit = sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(100))) govGen.Params.ProposalCancelDest = keyring.GetAccAddr(2).String() govGen.Proposals = append(govGen.Proposals, prop) govGen.Proposals = append(govGen.Proposals, prop2) diff --git a/tests/integration/precompiles/staking/test_integration.go b/tests/integration/precompiles/staking/test_integration.go index 13e48e60c..fbd8064f5 100644 --- a/tests/integration/precompiles/staking/test_integration.go +++ b/tests/integration/precompiles/staking/test_integration.go @@ -21,7 +21,7 @@ import ( "github.com/cosmos/evm/precompiles/staking/testdata" "github.com/cosmos/evm/precompiles/testutil" "github.com/cosmos/evm/precompiles/testutil/contracts" - cosmosevmutil "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/network" "github.com/cosmos/evm/testutil/integration/evm/utils" testutiltx "github.com/cosmos/evm/testutil/tx" @@ -2673,7 +2673,7 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmAp err = s.precompile.UnpackIntoInterface(&delOut, staking.DelegationMethod, ethRes.Ret) Expect(err).To(BeNil(), "error while unpacking the delegation output: %v", err) Expect(delOut.Balance.Amount.Int64()).To(Equal(int64(0)), "expected a different delegation balance") - Expect(delOut.Balance.Denom).To(Equal(cosmosevmutil.ExampleAttoDenom), "expected a different delegation balance") + Expect(delOut.Balance.Denom).To(Equal(testconfig.ExampleAttoDenom), "expected a different delegation balance") }) It("which exists should return the delegation", func() { @@ -2694,7 +2694,7 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmAp err = s.precompile.UnpackIntoInterface(&delOut, staking.DelegationMethod, ethRes.Ret) Expect(err).To(BeNil(), "error while unpacking the delegation output: %v", err) Expect(delOut.Balance).To(Equal( - cmn.Coin{Denom: cosmosevmutil.ExampleAttoDenom, Amount: big.NewInt(1e18)}), + cmn.Coin{Denom: testconfig.ExampleAttoDenom, Amount: big.NewInt(1e18)}), "expected a different delegation balance", ) }) diff --git a/tests/integration/precompiles/staking/test_setup.go b/tests/integration/precompiles/staking/test_setup.go index cb4e04d63..2332dc1eb 100644 --- a/tests/integration/precompiles/staking/test_setup.go +++ b/tests/integration/precompiles/staking/test_setup.go @@ -4,7 +4,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/evm/precompiles/staking" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -47,7 +47,7 @@ func (s *PrecompileTestSuite) SetupTest() { keyring := testkeyring.New(2) customGenesis := network.CustomGenesisState{} // mint some coin to fee collector - coins := sdk.NewCoins(sdk.NewCoin(testconstants.ExampleAttoDenom, sdkmath.NewInt(InitialTestBalance))) + coins := sdk.NewCoins(sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(InitialTestBalance))) balances := []banktypes.Balance{ { Address: authtypes.NewModuleAddress(authtypes.FeeCollectorName).String(), diff --git a/tests/integration/precompiles/staking/test_staking.go b/tests/integration/precompiles/staking/test_staking.go index d8b5149dc..ba35a63b1 100644 --- a/tests/integration/precompiles/staking/test_staking.go +++ b/tests/integration/precompiles/staking/test_staking.go @@ -13,7 +13,7 @@ import ( "github.com/cosmos/evm/precompiles/staking" "github.com/cosmos/evm/precompiles/testutil" chainutil "github.com/cosmos/evm/testutil" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/keyring" "github.com/cosmos/evm/x/vm/statedb" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -224,7 +224,7 @@ func (s *PrecompileTestSuite) TestRun() { // Needs to be called after setting unbonding delegation // In order to mimic the coins being added to the unboding pool - coin := sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(1000)) + coin := sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(1000)) err = s.network.App.GetBankKeeper().SendCoinsFromModuleToModule(ctx, stakingtypes.BondedPoolName, stakingtypes.NotBondedPoolName, sdk.Coins{coin}) s.Require().NoError(err, "failed to send coins from module to module") @@ -352,7 +352,7 @@ func (s *PrecompileTestSuite) TestRun() { // Needs to be called after setting unbonding delegation // In order to mimic the coins being added to the unboding pool - coin := sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(1000)) + coin := sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(1000)) err = s.network.App.GetBankKeeper().SendCoinsFromModuleToModule(ctx, stakingtypes.BondedPoolName, stakingtypes.NotBondedPoolName, sdk.Coins{coin}) s.Require().NoError(err, "failed to send coins from module to module") @@ -572,7 +572,7 @@ func (s *PrecompileTestSuite) TestCMS() { // Needs to be called after setting unbonding delegation // In order to mimic the coins being added to the unboding pool - coin := sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(1000)) + coin := sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(1000)) err = s.network.App.GetBankKeeper().SendCoinsFromModuleToModule(ctx, stakingtypes.BondedPoolName, stakingtypes.NotBondedPoolName, sdk.Coins{coin}) s.Require().NoError(err, "failed to send coins from module to module") @@ -700,7 +700,7 @@ func (s *PrecompileTestSuite) TestCMS() { // Needs to be called after setting unbonding delegation // In order to mimic the coins being added to the unboding pool - coin := sdk.NewCoin(testconstants.ExampleAttoDenom, math.NewInt(1000)) + coin := sdk.NewCoin(testconfig.ExampleAttoDenom, math.NewInt(1000)) err = s.network.App.GetBankKeeper().SendCoinsFromModuleToModule(ctx, stakingtypes.BondedPoolName, stakingtypes.NotBondedPoolName, sdk.Coins{coin}) s.Require().NoError(err, "failed to send coins from module to module") diff --git a/tests/integration/precompiles/werc20/test_events.go b/tests/integration/precompiles/werc20/test_events.go index e4734754d..7dfff8b14 100644 --- a/tests/integration/precompiles/werc20/test_events.go +++ b/tests/integration/precompiles/werc20/test_events.go @@ -9,7 +9,7 @@ import ( cmn "github.com/cosmos/evm/precompiles/common" "github.com/cosmos/evm/precompiles/werc20" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -44,7 +44,7 @@ func NewPrecompileUnitTestSuite( // SetupTest allows to configure the testing suite embedding a network with a // custom chainID. This is important to check that the correct address is used // for the precompile. -func (s *PrecompileUnitTestSuite) SetupTest(chainID testconstants.ChainID) { +func (s *PrecompileUnitTestSuite) SetupTest(chainID testconfig.ChainID) { keyring := keyring.New(2) options := []network.ConfigOption{ @@ -97,14 +97,14 @@ type WithdrawalEvent struct { func (s *PrecompileUnitTestSuite) TestEmitDepositEvent() { testCases := []struct { name string - chainID testconstants.ChainID + chainID testconfig.ChainID }{ { name: "mainnet", - chainID: testconstants.ExampleChainID, + chainID: testconfig.ExampleChainID, }, { name: "six decimals", - chainID: testconstants.SixDecimalsChainID, + chainID: testconfig.ExampleSixDecimalsChainID, }, } @@ -156,14 +156,14 @@ func (s *PrecompileUnitTestSuite) TestEmitDepositEvent() { func (s *PrecompileUnitTestSuite) TestEmitWithdrawalEvent() { testCases := []struct { name string - chainID testconstants.ChainID + chainID testconfig.ChainID }{ { name: "mainnet", - chainID: testconstants.ExampleChainID, + chainID: testconfig.ExampleChainID, }, { name: "six decimals", - chainID: testconstants.SixDecimalsChainID, + chainID: testconfig.ExampleSixDecimalsChainID, }, } diff --git a/tests/integration/precompiles/werc20/test_integration.go b/tests/integration/precompiles/werc20/test_integration.go index 686bdb65f..36f4d28a6 100644 --- a/tests/integration/precompiles/werc20/test_integration.go +++ b/tests/integration/precompiles/werc20/test_integration.go @@ -15,7 +15,7 @@ import ( "github.com/cosmos/evm/precompiles/testutil" "github.com/cosmos/evm/precompiles/werc20" "github.com/cosmos/evm/precompiles/werc20/testdata" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -50,7 +50,7 @@ type PrecompileIntegrationTestSuite struct { } func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmApp, options ...network.ConfigOption) { - _ = DescribeTableSubtree("a user interact with the WEVMOS precompiled contract", func(chainId testconstants.ChainID) { + _ = DescribeTableSubtree("a user interact with the WEVMOS precompiled contract", func(chainId testconfig.ChainID) { var ( is *PrecompileIntegrationTestSuite passCheck, failCheck testutil.LogCheckArgs @@ -71,9 +71,9 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmAp // precise balance handling across different decimal configurations var conversionFactor *big.Int switch chainId { - case testconstants.SixDecimalsChainID: + case testconfig.ExampleSixDecimalsChainID: conversionFactor = big.NewInt(1e12) // For 6-decimal chains - case testconstants.TwelveDecimalsChainID: + case testconfig.ExampleTwelveDecimalsChainID: conversionFactor = big.NewInt(1e6) // For 12-decimal chains default: conversionFactor = big.NewInt(1) // For 18-decimal chains @@ -108,11 +108,11 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmAp customGenesis[feemarkettypes.ModuleName] = feemarketGenesis // Reset evm config here for the standard case - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() Expect(configurator. - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[chainId]). - Configure()).To(BeNil(), "expected no error setting the evm configurator") + WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[chainId]). + Apply()).To(BeNil(), "expected no error setting the evm configurator") opts := []network.ConfigOption{ network.WithChainID(chainId), @@ -130,7 +130,7 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmAp is.keyring = keyring is.wrappedCoinDenom = evmtypes.GetEVMCoinDenom() - is.precompileAddrHex = network.GetWEVMOSContractHex(testconstants.ChainID{ + is.precompileAddrHex = network.GetWEVMOSContractHex(testconfig.ChainID{ ChainID: is.network.GetChainID(), EVMChainID: is.network.GetEIP155ChainID().Uint64(), }) @@ -552,7 +552,7 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmAp err = is.precompile.UnpackIntoInterface(&decimals, erc20.DecimalsMethod, ethRes.Ret) Expect(err).ToNot(HaveOccurred(), "failed to unpack result") - coinInfo := testconstants.ExampleChainCoinInfo[testconstants.ChainID{ + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ChainID{ ChainID: is.network.GetChainID(), EVMChainID: is.network.GetEIP155ChainID().Uint64(), }] @@ -562,9 +562,9 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmAp }) }) }, - Entry("6 decimals chain", testconstants.SixDecimalsChainID), - Entry("12 decimals chain", testconstants.TwelveDecimalsChainID), - Entry("18 decimals chain", testconstants.ExampleChainID), + Entry("6 decimals chain", testconfig.ExampleSixDecimalsChainID), + Entry("12 decimals chain", testconfig.ExampleTwelveDecimalsChainID), + Entry("18 decimals chain", testconfig.ExampleChainID), ) // Run Ginkgo integration tests diff --git a/tests/integration/rpc/backend/test_backend_suite.go b/tests/integration/rpc/backend/test_backend_suite.go index c464d673b..10b4fd996 100644 --- a/tests/integration/rpc/backend/test_backend_suite.go +++ b/tests/integration/rpc/backend/test_backend_suite.go @@ -19,7 +19,7 @@ import ( rpcbackend "github.com/cosmos/evm/rpc/backend" "github.com/cosmos/evm/rpc/backend/mocks" rpctypes "github.com/cosmos/evm/rpc/types" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/network" utiltx "github.com/cosmos/evm/testutil/tx" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -48,7 +48,7 @@ func NewTestSuite(create network.CreateEvmApp, options ...network.ConfigOption) } } -var ChainID = constants.ExampleChainID +var ChainID = testconfig.ExampleChainID // SetupTest is executed before every TestSuite test func (s *TestSuite) SetupTest() { diff --git a/tests/integration/rpc/backend/test_call_tx.go b/tests/integration/rpc/backend/test_call_tx.go index a35eaba75..2b1aaaf2c 100644 --- a/tests/integration/rpc/backend/test_call_tx.go +++ b/tests/integration/rpc/backend/test_call_tx.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/evm/rpc/backend/mocks" rpctypes "github.com/cosmos/evm/rpc/types" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -337,7 +337,7 @@ func (s *TestSuite) TestSendRawTransaction() { return bytes }, common.Hash{}, - fmt.Errorf("incorrect chain-id; expected %d, got %d", constants.ExampleChainID.EVMChainID, invalidChainID).Error(), + fmt.Errorf("incorrect chain-id; expected %d, got %d", testconfig.ExampleChainID.EVMChainID, invalidChainID).Error(), false, }, { diff --git a/tests/integration/rpc/backend/test_chain_info.go b/tests/integration/rpc/backend/test_chain_info.go index 514132476..3fb2b0369 100644 --- a/tests/integration/rpc/backend/test_chain_info.go +++ b/tests/integration/rpc/backend/test_chain_info.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/evm/rpc/backend/mocks" rpc "github.com/cosmos/evm/rpc/types" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -156,7 +156,7 @@ func (s *TestSuite) TestBaseFee() { } func (s *TestSuite) TestChainID() { - expChainID := (*hexutil.Big)(big.NewInt(int64(constants.ExampleChainID.EVMChainID))) //nolint:gosec // G115 + expChainID := (*hexutil.Big)(big.NewInt(int64(testconfig.ExampleChainID.EVMChainID))) //nolint:gosec // G115 testCases := []struct { name string registerMock func() diff --git a/tests/integration/rpc/backend/test_evm_query_client.go b/tests/integration/rpc/backend/test_evm_query_client.go index cbeed91e9..7724f0ea9 100644 --- a/tests/integration/rpc/backend/test_evm_query_client.go +++ b/tests/integration/rpc/backend/test_evm_query_client.go @@ -18,7 +18,7 @@ import ( "github.com/cosmos/evm/rpc/backend/mocks" rpc "github.com/cosmos/evm/rpc/types" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" evmtypes "github.com/cosmos/evm/x/vm/types" proto "github.com/cosmos/gogoproto/proto" @@ -56,18 +56,18 @@ var _ evmtypes.QueryClient = &mocks.EVMQueryClient{} func RegisterTraceTransactionWithPredecessors(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx, predecessors []*evmtypes.MsgEthereumTx) { data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d} queryClient.On("TraceTx", rpc.ContextWithHeight(1), - MatchByProto(&evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, Predecessors: predecessors, ChainId: int64(constants.ExampleChainID.EVMChainID), BlockMaxGas: -1})). //nolint:gosec // G115 + MatchByProto(&evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, Predecessors: predecessors, ChainId: int64(testconfig.ExampleChainID.EVMChainID), BlockMaxGas: -1})). //nolint:gosec // G115 Return(&evmtypes.QueryTraceTxResponse{Data: data}, nil) } func RegisterTraceTransaction(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx) { data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d} - queryClient.On("TraceTx", rpc.ContextWithHeight(1), MatchByProto(&evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: int64(constants.ExampleChainID.EVMChainID), BlockMaxGas: -1})). //nolint:gosec // G115 + queryClient.On("TraceTx", rpc.ContextWithHeight(1), MatchByProto(&evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: int64(testconfig.ExampleChainID.EVMChainID), BlockMaxGas: -1})). //nolint:gosec // G115 Return(&evmtypes.QueryTraceTxResponse{Data: data}, nil) } func RegisterTraceTransactionError(queryClient *mocks.EVMQueryClient, msgEthTx *evmtypes.MsgEthereumTx) { - queryClient.On("TraceTx", rpc.ContextWithHeight(1), MatchByProto(&evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: int64(constants.ExampleChainID.EVMChainID)})). //nolint:gosec // G115 + queryClient.On("TraceTx", rpc.ContextWithHeight(1), MatchByProto(&evmtypes.QueryTraceTxRequest{Msg: msgEthTx, BlockNumber: 1, ChainId: int64(testconfig.ExampleChainID.EVMChainID)})). //nolint:gosec // G115 Return(nil, errortypes.ErrInvalidRequest) } @@ -75,7 +75,7 @@ func RegisterTraceTransactionError(queryClient *mocks.EVMQueryClient, msgEthTx * func RegisterTraceBlock(queryClient *mocks.EVMQueryClient, txs []*evmtypes.MsgEthereumTx) { data := []byte{0x7b, 0x22, 0x74, 0x65, 0x73, 0x74, 0x22, 0x3a, 0x20, 0x22, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x22, 0x7d} queryClient.On("TraceBlock", rpc.ContextWithHeight(1), - MatchByProto(&evmtypes.QueryTraceBlockRequest{Txs: txs, BlockNumber: 1, TraceConfig: &evmtypes.TraceConfig{}, ChainId: int64(constants.ExampleChainID.EVMChainID), BlockMaxGas: -1})). //nolint:gosec // G115 + MatchByProto(&evmtypes.QueryTraceBlockRequest{Txs: txs, BlockNumber: 1, TraceConfig: &evmtypes.TraceConfig{}, ChainId: int64(testconfig.ExampleChainID.EVMChainID), BlockMaxGas: -1})). //nolint:gosec // G115 Return(&evmtypes.QueryTraceBlockResponse{Data: data}, nil) } diff --git a/tests/integration/rpc/backend/test_node_info.go b/tests/integration/rpc/backend/test_node_info.go index 270a3c8a1..c81366691 100644 --- a/tests/integration/rpc/backend/test_node_info.go +++ b/tests/integration/rpc/backend/test_node_info.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/rpc/backend/mocks" "github.com/cosmos/evm/server/config" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/math" @@ -33,13 +33,13 @@ func (s *TestSuite) TestRPCMinGasPrice() { { "pass - default gas price", func() {}, - big.NewInt(constants.DefaultGasPrice), + big.NewInt(evmtypes.DefaultGasPrice), true, }, { "pass - min gas price is 0", func() {}, - big.NewInt(constants.DefaultGasPrice), + big.NewInt(evmtypes.DefaultGasPrice), true, }, } @@ -260,7 +260,7 @@ func (s *TestSuite) TestSetEtherbase() { RegisterStatus(client) RegisterValidatorAccount(QueryClient, s.acc) RegisterParams(QueryClient, &header, 1) - c := sdk.NewDecCoin(constants.ExampleAttoDenom, math.NewIntFromBigInt(big.NewInt(1))) + c := sdk.NewDecCoin(testconfig.ExampleAttoDenom, math.NewIntFromBigInt(big.NewInt(1))) s.backend.Cfg.SetMinGasPrices(sdk.DecCoins{c}) delAddr, _ := s.backend.GetCoinbase() // account, _ := s.backend.ClientCtx.AccountRetriever.GetAccount(s.backend.ClientCtx, delAddr) diff --git a/tests/integration/testutil/test_config.go b/tests/integration/testutil/test_config.go index dac835b44..da568adc0 100644 --- a/tests/integration/testutil/test_config.go +++ b/tests/integration/testutil/test_config.go @@ -3,7 +3,7 @@ package testutil import ( - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" grpchandler "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" testkeyring "github.com/cosmos/evm/testutil/keyring" @@ -16,12 +16,12 @@ import ( ) func (s *TestSuite) TestWithChainID() { - eighteenDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] - sixDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] + eighteenDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + sixDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID] testCases := []struct { name string - chainID testconstants.ChainID + chainID testconfig.ChainID evmChainID uint64 coinInfo evmtypes.EvmCoinInfo expBaseFee math.LegacyDec @@ -29,14 +29,14 @@ func (s *TestSuite) TestWithChainID() { }{ { name: "18 decimals", - chainID: testconstants.ExampleChainID, + chainID: testconfig.ExampleChainID, coinInfo: eighteenDecimalsCoinInfo, expBaseFee: math.LegacyNewDec(875_000_000), expCosmosAmount: network.GetInitialAmount(evmtypes.EighteenDecimals), }, { name: "6 decimals", - chainID: testconstants.SixDecimalsChainID, + chainID: testconfig.ExampleSixDecimalsChainID, coinInfo: sixDecimalsCoinInfo, expBaseFee: math.LegacyNewDecWithPrec(875, 6), expCosmosAmount: network.GetInitialAmount(evmtypes.SixDecimals), @@ -74,7 +74,7 @@ func (s *TestSuite) TestWithChainID() { ) // Bank balance should always be in the original amount. - cReq, err := handler.GetBalanceFromBank(keyring.GetAccAddr(0), tc.coinInfo.Denom) + cReq, err := handler.GetBalanceFromBank(keyring.GetAccAddr(0), tc.coinInfo.GetDenom()) s.NoError(err, "error getting balances") s.Equal( tc.expCosmosAmount.String(), @@ -98,9 +98,9 @@ func (s *TestSuite) TestWithChainID() { } func (s *TestSuite) TestWithBalances() { - key1Balance := sdk.NewCoins(sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 1e18)) + key1Balance := sdk.NewCoins(sdk.NewInt64Coin(testconfig.ExampleAttoDenom, 1e18)) key2Balance := sdk.NewCoins( - sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 2e18), + sdk.NewInt64Coin(testconfig.ExampleAttoDenom, 2e18), sdk.NewInt64Coin("other", 3e18), ) diff --git a/tests/integration/wallets/test_ledger_suite.go b/tests/integration/wallets/test_ledger_suite.go index a9f166c19..c8eadeecd 100644 --- a/tests/integration/wallets/test_ledger_suite.go +++ b/tests/integration/wallets/test_ledger_suite.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/suite" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/network" "github.com/cosmos/evm/wallets/ledger" "github.com/cosmos/evm/wallets/ledger/mocks" @@ -93,7 +93,7 @@ func (suite *LedgerTestSuite) getMockTxAmino() []byte { } }], "sequence":"6" - }`, constants.ExampleChainID.ChainID), + }`, testconfig.ExampleChainID.ChainID), "", ) @@ -157,7 +157,7 @@ func (suite *LedgerTestSuite) getMockTxProtobuf() []byte { signBytes, err := tx.DirectSignBytes( bodyBytes, authInfoBytes, - constants.ExampleChainID.ChainID, + testconfig.ExampleChainID.ChainID, 0, ) suite.Require().NoError(err) diff --git a/tests/integration/x/erc20/test_grpc_query.go b/tests/integration/x/erc20/test_grpc_query.go index 138614b4b..b337f9e06 100644 --- a/tests/integration/x/erc20/test_grpc_query.go +++ b/tests/integration/x/erc20/test_grpc_query.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/cosmos/evm/testutil/config" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/evm/x/erc20/types" @@ -32,7 +32,7 @@ func (s *KeeperTestSuite) TestTokenPairs() { Pagination: &query.PageResponse{ Total: 1, }, - TokenPairs: testconstants.ExampleTokenPairs, + TokenPairs: testconfig.ExampleTokenPairs, } }, true, @@ -43,7 +43,7 @@ func (s *KeeperTestSuite) TestTokenPairs() { req = &types.QueryTokenPairsRequest{ Pagination: &query.PageRequest{Limit: 10, CountTotal: true}, } - pairs := testconstants.ExampleTokenPairs + pairs := testconfig.ExampleTokenPairs pair := types.NewTokenPair(utiltx.GenerateAddress(), "coin", types.OWNER_MODULE) s.network.App.GetErc20Keeper().SetTokenPair(ctx, pair) pairs = append(pairs, pair) @@ -59,7 +59,7 @@ func (s *KeeperTestSuite) TestTokenPairs() { "2 pairs registered wo/pagination", func() { req = &types.QueryTokenPairsRequest{} - pairs := testconstants.ExampleTokenPairs + pairs := testconfig.ExampleTokenPairs pair := types.NewTokenPair(utiltx.GenerateAddress(), "coin", types.OWNER_MODULE) pair2 := types.NewTokenPair(utiltx.GenerateAddress(), "coin2", types.OWNER_MODULE) diff --git a/tests/integration/x/erc20/test_precompiles.go b/tests/integration/x/erc20/test_precompiles.go index 502fce96d..747598a63 100644 --- a/tests/integration/x/erc20/test_precompiles.go +++ b/tests/integration/x/erc20/test_precompiles.go @@ -7,7 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/evm/x/erc20/types" @@ -96,7 +96,7 @@ func (s *KeeperTestSuite) TestGetERC20PrecompileInstance() { func (s *KeeperTestSuite) TestGetNativePrecompiles() { var ctx sdk.Context testAddr := utiltx.GenerateAddress() - defaultWEVMOSAddr := common.HexToAddress(testconstants.WEVMOSContractMainnet) + defaultWEVMOSAddr := common.HexToAddress(testconfig.WevmosContractMainnet) testCases := []struct { name string @@ -139,7 +139,7 @@ func (s *KeeperTestSuite) TestGetNativePrecompiles() { func (s *KeeperTestSuite) TestSetNativePrecompile() { var ctx sdk.Context testAddr := utiltx.GenerateAddress() - defaultWEVMOSAddr := common.HexToAddress(testconstants.WEVMOSContractMainnet) + defaultWEVMOSAddr := common.HexToAddress(testconfig.WevmosContractMainnet) testCases := []struct { name string @@ -192,7 +192,7 @@ func (s *KeeperTestSuite) TestSetNativePrecompile() { func (s *KeeperTestSuite) TestDeleteNativePrecompile() { var ctx sdk.Context testAddr := utiltx.GenerateAddress() - defaultWEVMOSAddr := common.HexToAddress(testconstants.WEVMOSContractMainnet) + defaultWEVMOSAddr := common.HexToAddress(testconfig.WevmosContractMainnet) unavailableAddr := common.HexToAddress("unavailable") testCases := []struct { @@ -285,7 +285,7 @@ func (s *KeeperTestSuite) TestDeleteNativePrecompile() { func (s *KeeperTestSuite) TestIsNativePrecompileAvailable() { var ctx sdk.Context testAddr := utiltx.GenerateAddress() - defaultWEVMOSAddr := common.HexToAddress(testconstants.WEVMOSContractMainnet) + defaultWEVMOSAddr := common.HexToAddress(testconfig.WevmosContractMainnet) unavailableAddr := common.HexToAddress("unavailable") testCases := []struct { diff --git a/tests/integration/x/erc20/test_token_pairs.go b/tests/integration/x/erc20/test_token_pairs.go index fc63348e0..1b92e4480 100644 --- a/tests/integration/x/erc20/test_token_pairs.go +++ b/tests/integration/x/erc20/test_token_pairs.go @@ -5,7 +5,7 @@ import ( "github.com/ethereum/go-ethereum/common" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/evm/x/erc20/types" @@ -23,14 +23,14 @@ func (s *KeeperTestSuite) TestGetTokenPairs() { malleate func() }{ { - "no pair registered", func() { expRes = testconstants.ExampleTokenPairs }, + "no pair registered", func() { expRes = testconfig.ExampleTokenPairs }, }, { "1 pair registered", func() { pair := types.NewTokenPair(utiltx.GenerateAddress(), "coin", types.OWNER_MODULE) s.network.App.GetErc20Keeper().SetTokenPair(ctx, pair) - expRes = testconstants.ExampleTokenPairs + expRes = testconfig.ExampleTokenPairs expRes = append(expRes, pair) }, }, @@ -41,7 +41,7 @@ func (s *KeeperTestSuite) TestGetTokenPairs() { pair2 := types.NewTokenPair(utiltx.GenerateAddress(), "coin2", types.OWNER_MODULE) s.network.App.GetErc20Keeper().SetTokenPair(ctx, pair) s.network.App.GetErc20Keeper().SetTokenPair(ctx, pair2) - expRes = testconstants.ExampleTokenPairs + expRes = testconfig.ExampleTokenPairs expRes = append(expRes, []types.TokenPair{pair, pair2}...) }, }, diff --git a/tests/integration/x/precisebank/test_burn_integration.go b/tests/integration/x/precisebank/test_burn_integration.go index 65b57f5da..0204e5cb8 100644 --- a/tests/integration/x/precisebank/test_burn_integration.go +++ b/tests/integration/x/precisebank/test_burn_integration.go @@ -8,7 +8,8 @@ import ( "github.com/stretchr/testify/require" - testconstants "github.com/cosmos/evm/testutil/constants" + evmconfig "github.com/cosmos/evm/config" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/x/precisebank/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -417,19 +418,19 @@ func (s *KeeperIntegrationTestSuite) TestBurnCoinsSpreadRemainder() { func (s *KeeperIntegrationTestSuite) TestBurnCoinsRandomValueMultiDecimals() { tests := []struct { name string - chainID testconstants.ChainID + chainID testconfig.ChainID }{ { name: "6 decimals", - chainID: testconstants.SixDecimalsChainID, + chainID: testconfig.ExampleSixDecimalsChainID, }, { name: "12 decimals", - chainID: testconstants.TwelveDecimalsChainID, + chainID: testconfig.ExampleTwelveDecimalsChainID, }, { name: "2 decimals", - chainID: testconstants.TwoDecimalsChainID, + chainID: testconfig.ExampleTwoDecimalsChainID, }, } @@ -498,10 +499,11 @@ func (s *KeeperIntegrationTestSuite) TestBurnCoinsRandomValueMultiDecimals() { } func FuzzBurnCoins(f *testing.F) { - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) - err := configurator.Configure() + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + err := evmConfig.Apply() + require.NoError(f, err) + err = evmtypes.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) require.NoError(f, err) f.Add(int64(0)) diff --git a/tests/integration/x/precisebank/test_genesis.go b/tests/integration/x/precisebank/test_genesis.go index 02f01e130..594b0d487 100644 --- a/tests/integration/x/precisebank/test_genesis.go +++ b/tests/integration/x/precisebank/test_genesis.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/suite" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/network" "github.com/cosmos/evm/x/precisebank" "github.com/cosmos/evm/x/precisebank/types" @@ -31,10 +31,10 @@ func NewGenesisTestSuite(create network.CreateEvmApp, options ...network.ConfigO } func (s *GenesisTestSuite) SetupTest() { - s.SetupTestWithChainID(testconstants.SixDecimalsChainID) + s.SetupTestWithChainID(testconfig.ExampleSixDecimalsChainID) } -func (s *GenesisTestSuite) SetupTestWithChainID(chainID testconstants.ChainID) { +func (s *GenesisTestSuite) SetupTestWithChainID(chainID testconfig.ChainID) { options := []network.ConfigOption{ network.WithChainID(chainID), } diff --git a/tests/integration/x/precisebank/test_integration.go b/tests/integration/x/precisebank/test_integration.go index 9b568d2af..c6536d9ed 100644 --- a/tests/integration/x/precisebank/test_integration.go +++ b/tests/integration/x/precisebank/test_integration.go @@ -7,7 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/cosmos/evm/contracts" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/utils" testutiltypes "github.com/cosmos/evm/testutil/types" "github.com/cosmos/evm/x/precisebank/types" @@ -21,19 +21,19 @@ import ( func (s *KeeperIntegrationTestSuite) TestMintBurnSendCoinsRandomValueMultiDecimals() { tests := []struct { name string - chainID testconstants.ChainID + chainID testconfig.ChainID }{ { name: "6 decimals", - chainID: testconstants.SixDecimalsChainID, + chainID: testconfig.ExampleSixDecimalsChainID, }, { name: "2 decimals", - chainID: testconstants.TwoDecimalsChainID, + chainID: testconfig.ExampleTwoDecimalsChainID, }, { name: "12 decimals", - chainID: testconstants.TwelveDecimalsChainID, + chainID: testconfig.ExampleTwelveDecimalsChainID, }, } @@ -137,19 +137,19 @@ func (s *KeeperIntegrationTestSuite) TestSendEvmTxRandomValueMultiDecimals() { tests := []struct { name string - chainID testconstants.ChainID + chainID testconfig.ChainID }{ { name: "6 decimals", - chainID: testconstants.SixDecimalsChainID, + chainID: testconfig.ExampleSixDecimalsChainID, }, { name: "12 decimals", - chainID: testconstants.TwelveDecimalsChainID, + chainID: testconfig.ExampleTwelveDecimalsChainID, }, { name: "2 decimals", - chainID: testconstants.TwoDecimalsChainID, + chainID: testconfig.ExampleTwoDecimalsChainID, }, } @@ -250,19 +250,19 @@ func (s *KeeperIntegrationTestSuite) TestSendEvmTxRandomValueMultiDecimals() { func (s *KeeperIntegrationTestSuite) TestWATOMWrapUnwrapMultiDecimal() { tests := []struct { name string - chainID testconstants.ChainID + chainID testconfig.ChainID }{ { name: "6 decimals", - chainID: testconstants.SixDecimalsChainID, + chainID: testconfig.ExampleSixDecimalsChainID, }, { name: "12 decimals", - chainID: testconstants.TwelveDecimalsChainID, + chainID: testconfig.ExampleTwelveDecimalsChainID, }, { name: "2 decimals", - chainID: testconstants.TwoDecimalsChainID, + chainID: testconfig.ExampleTwoDecimalsChainID, }, } diff --git a/tests/integration/x/precisebank/test_mint_integration.go b/tests/integration/x/precisebank/test_mint_integration.go index 0458f1299..706056d99 100644 --- a/tests/integration/x/precisebank/test_mint_integration.go +++ b/tests/integration/x/precisebank/test_mint_integration.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/x/precisebank/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -341,19 +341,19 @@ func (s *KeeperIntegrationTestSuite) TestMintCoins() { func (s *KeeperIntegrationTestSuite) TestMintCoinsRandomValueMultiDecimals() { tests := []struct { name string - chainID testconstants.ChainID + chainID testconfig.ChainID }{ { name: "6 decimals", - chainID: testconstants.SixDecimalsChainID, + chainID: testconfig.ExampleSixDecimalsChainID, }, { name: "12 decimals", - chainID: testconstants.TwelveDecimalsChainID, + chainID: testconfig.ExampleTwelveDecimalsChainID, }, { name: "2 decimals", - chainID: testconstants.TwoDecimalsChainID, + chainID: testconfig.ExampleTwoDecimalsChainID, }, } @@ -415,10 +415,10 @@ func (s *KeeperIntegrationTestSuite) TestMintCoinsRandomValueMultiDecimals() { } func FuzzMintCoins(f *testing.F) { - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) - err := configurator.Configure() + configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) + err := configurator.Apply() require.NoError(f, err) f.Add(int64(0)) diff --git a/tests/integration/x/precisebank/test_send_integration.go b/tests/integration/x/precisebank/test_send_integration.go index d819bf650..2bf6c9c00 100644 --- a/tests/integration/x/precisebank/test_send_integration.go +++ b/tests/integration/x/precisebank/test_send_integration.go @@ -11,7 +11,7 @@ import ( corevm "github.com/ethereum/go-ethereum/core/vm" "github.com/stretchr/testify/require" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" cosmosevmutils "github.com/cosmos/evm/utils" erc20types "github.com/cosmos/evm/x/erc20/types" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" @@ -719,19 +719,19 @@ func (s *KeeperIntegrationTestSuite) TestSendCoinsFromModuleToAccount() { func (s *KeeperIntegrationTestSuite) TestSendCoinsRandomValueMultiDecimals() { tests := []struct { name string - chainID testconstants.ChainID + chainID testconfig.ChainID }{ { name: "6 decimals", - chainID: testconstants.SixDecimalsChainID, + chainID: testconfig.ExampleSixDecimalsChainID, }, { name: "12 decimals", - chainID: testconstants.TwelveDecimalsChainID, + chainID: testconfig.ExampleTwelveDecimalsChainID, }, { name: "2 decimals", - chainID: testconstants.TwoDecimalsChainID, + chainID: testconfig.ExampleTwoDecimalsChainID, }, } @@ -796,10 +796,10 @@ func (s *KeeperIntegrationTestSuite) TestSendCoinsRandomValueMultiDecimals() { } func FuzzSendCoins(f *testing.F) { - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) - err := configurator.Configure() + configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) + err := configurator.Apply() require.NoError(f, err) f.Add(uint64(100), uint64(0), uint64(2)) @@ -858,19 +858,19 @@ func FuzzSendCoins(f *testing.F) { func (s *KeeperIntegrationTestSuite) TestSendMsg_RandomValueMultiDecimals() { //nolint:revive // false positive due to file name tests := []struct { name string - chainID testconstants.ChainID + chainID testconfig.ChainID }{ { name: "6 decimals", - chainID: testconstants.SixDecimalsChainID, + chainID: testconfig.ExampleSixDecimalsChainID, }, { name: "12 decimals", - chainID: testconstants.TwelveDecimalsChainID, + chainID: testconfig.ExampleTwelveDecimalsChainID, }, { name: "2 decimals", - chainID: testconstants.TwoDecimalsChainID, + chainID: testconfig.ExampleTwoDecimalsChainID, }, } diff --git a/tests/integration/x/precisebank/test_setup.go b/tests/integration/x/precisebank/test_setup.go index bab55b5f2..7baacd527 100644 --- a/tests/integration/x/precisebank/test_setup.go +++ b/tests/integration/x/precisebank/test_setup.go @@ -3,7 +3,7 @@ package precisebank import ( "github.com/stretchr/testify/suite" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -34,10 +34,10 @@ func NewKeeperIntegrationTestSuite(create network.CreateEvmApp, options ...netwo } func (s *KeeperIntegrationTestSuite) SetupTest() { - s.SetupTestWithChainID(testconstants.SixDecimalsChainID) + s.SetupTestWithChainID(testconfig.ExampleSixDecimalsChainID) } -func (s *KeeperIntegrationTestSuite) SetupTestWithChainID(chainID testconstants.ChainID) { +func (s *KeeperIntegrationTestSuite) SetupTestWithChainID(chainID testconfig.ChainID) { s.keyring = keyring.New(2) options := []network.ConfigOption{ diff --git a/tests/integration/x/vm/keeper_test_suite.go b/tests/integration/x/vm/keeper_test_suite.go index 8f3f3b39a..da66a8745 100644 --- a/tests/integration/x/vm/keeper_test_suite.go +++ b/tests/integration/x/vm/keeper_test_suite.go @@ -6,6 +6,7 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/stretchr/testify/suite" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -88,7 +89,8 @@ func (s *KeeperTestSuite) SetupTest() { s.Handler = gh s.Keyring = keys - chainConfig := evmtypes.DefaultChainConfig(s.Network.GetEIP155ChainID().Uint64()) + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + chainConfig := evmtypes.DefaultChainConfig(s.Network.GetEIP155ChainID().Uint64(), coinInfo) if !s.EnableLondonHF { maxInt := sdkmath.NewInt(math.MaxInt64) chainConfig.LondonBlock = &maxInt @@ -101,21 +103,19 @@ func (s *KeeperTestSuite) SetupTest() { } // get the denom and decimals set on chain initialization // because we'll need to set them again when resetting the chain config - denom := evmtypes.GetEVMCoinDenom() - extendedDenom := evmtypes.GetEVMCoinExtendedDenom() displayDenom := evmtypes.GetEVMCoinDisplayDenom() decimals := evmtypes.GetEVMCoinDecimals() + extendedDecimals := evmtypes.GetEVMCoinExtendedDecimals() - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() err := configurator. WithChainConfig(chainConfig). WithEVMCoinInfo(evmtypes.EvmCoinInfo{ - Denom: denom, - ExtendedDenom: extendedDenom, - DisplayDenom: displayDenom, - Decimals: decimals, + DisplayDenom: displayDenom, + Decimals: decimals, + ExtendedDecimals: extendedDecimals, }). - Configure() + Apply() s.Require().NoError(err) } diff --git a/tests/integration/x/vm/test_benchmark.go b/tests/integration/x/vm/test_benchmark.go index 77847f070..c7d179c73 100644 --- a/tests/integration/x/vm/test_benchmark.go +++ b/tests/integration/x/vm/test_benchmark.go @@ -8,7 +8,7 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/require" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/evm/x/vm/keeper/testdata" "github.com/cosmos/evm/x/vm/types" @@ -24,7 +24,7 @@ func SetupContract(b *testing.B) (*KeeperTestSuite, common.Address) { suite := KeeperTestSuite{} suite.SetupTest() - amt := sdk.Coins{sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 1000000000000000000)} + amt := sdk.Coins{sdk.NewInt64Coin(testconfig.ExampleAttoDenom, 1000000000000000000)} err := suite.Network.App.GetBankKeeper().MintCoins(suite.Network.GetContext(), types.ModuleName, amt) require.NoError(b, err) err = suite.Network.App.GetBankKeeper().SendCoinsFromModuleToAccount(suite.Network.GetContext(), types.ModuleName, suite.Keyring.GetAddr(0).Bytes(), amt) @@ -42,7 +42,7 @@ func SetupTestMessageCall(b *testing.B) (*KeeperTestSuite, common.Address) { suite := KeeperTestSuite{} suite.SetupTest() - amt := sdk.Coins{sdk.NewInt64Coin(testconstants.ExampleAttoDenom, 1000000000000000000)} + amt := sdk.Coins{sdk.NewInt64Coin(testconfig.ExampleAttoDenom, 1000000000000000000)} err := suite.Network.App.GetBankKeeper().MintCoins(suite.Network.GetContext(), types.ModuleName, amt) require.NoError(b, err) err = suite.Network.App.GetBankKeeper().SendCoinsFromModuleToAccount(suite.Network.GetContext(), types.ModuleName, suite.Keyring.GetAddr(0).Bytes(), amt) diff --git a/tests/integration/x/vm/test_call_evm.go b/tests/integration/x/vm/test_call_evm.go index 013b200f2..2be995a15 100644 --- a/tests/integration/x/vm/test_call_evm.go +++ b/tests/integration/x/vm/test_call_evm.go @@ -6,14 +6,14 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/cosmos/evm/contracts" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/evm/x/erc20/types" evmtypes "github.com/cosmos/evm/x/vm/types" ) func (s *KeeperTestSuite) TestCallEVM() { - wcosmosEVMContract := common.HexToAddress(testconstants.WEVMOSContractMainnet) + wcosmosEVMContract := common.HexToAddress(testconfig.WevmosContractMainnet) testCases := []struct { name string method string @@ -47,7 +47,7 @@ func (s *KeeperTestSuite) TestCallEVM() { func (s *KeeperTestSuite) TestCallEVMWithData() { erc20 := contracts.ERC20MinterBurnerDecimalsContract.ABI - wcosmosEVMContract := common.HexToAddress(testconstants.WEVMOSContractMainnet) + wcosmosEVMContract := common.HexToAddress(testconfig.WevmosContractMainnet) testCases := []struct { name string from common.Address diff --git a/tests/integration/x/vm/test_grpc_query.go b/tests/integration/x/vm/test_grpc_query.go index f9b55fac3..3fec5c214 100644 --- a/tests/integration/x/vm/test_grpc_query.go +++ b/tests/integration/x/vm/test_grpc_query.go @@ -16,8 +16,9 @@ import ( "github.com/holiman/uint256" "github.com/stretchr/testify/require" + evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/server/config" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/network" "github.com/cosmos/evm/testutil/keyring" @@ -1592,7 +1593,8 @@ func (s *KeeperTestSuite) TestQueryBaseFee() { feemarketDefault := feemarkettypes.DefaultParams() s.Require().NoError(s.Network.App.GetFeeMarketKeeper().SetParams(s.Network.GetContext(), feemarketDefault)) - chainConfig := types.DefaultChainConfig(s.Network.GetEIP155ChainID().Uint64()) + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + chainConfig := types.DefaultChainConfig(s.Network.GetEIP155ChainID().Uint64(), coinInfo) maxInt := sdkmath.NewInt(math.MaxInt64) chainConfig.LondonBlock = &maxInt chainConfig.ArrowGlacierBlock = &maxInt @@ -1602,12 +1604,10 @@ func (s *KeeperTestSuite) TestQueryBaseFee() { chainConfig.CancunTime = &maxInt chainConfig.PragueTime = &maxInt - configurator := types.NewEVMConfigurator() - configurator.ResetTestConfig() - err := configurator. - WithChainConfig(chainConfig). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). - Configure() + evmConfig := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + s.Require().NoError(evmConfig.Apply()) + err := types.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) s.Require().NoError(err) }, true, @@ -1632,12 +1632,10 @@ func (s *KeeperTestSuite) TestQueryBaseFee() { // Save initial configure to restore it between tests coinInfo := types.EvmCoinInfo{ - Denom: types.GetEVMCoinDenom(), - ExtendedDenom: types.GetEVMCoinExtendedDenom(), - DisplayDenom: types.GetEVMCoinDisplayDenom(), - Decimals: types.GetEVMCoinDecimals(), + DisplayDenom: types.GetEVMCoinDisplayDenom(), + Decimals: types.GetEVMCoinDecimals(), + ExtendedDecimals: types.GetEVMCoinExtendedDecimals(), } - chainConfig := types.DefaultChainConfig(s.Network.GetEIP155ChainID().Uint64()) for _, tc := range testCases { s.Run(tc.name, func() { @@ -1658,12 +1656,11 @@ func (s *KeeperTestSuite) TestQueryBaseFee() { s.Require().Error(err) } s.Require().NoError(s.Network.NextBlock()) - configurator := types.NewEVMConfigurator() - configurator.ResetTestConfig() - err = configurator. - WithChainConfig(chainConfig). - WithEVMCoinInfo(coinInfo). - Configure() + evmConfig := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + err = types.SetEVMCoinInfo(coinInfo) + s.Require().NoError(err) + err = evmConfig.Apply() s.Require().NoError(err) }) } diff --git a/tests/integration/x/vm/test_iterate_contracts.go b/tests/integration/x/vm/test_iterate_contracts.go index 3c6cd5497..2c58318df 100644 --- a/tests/integration/x/vm/test_iterate_contracts.go +++ b/tests/integration/x/vm/test_iterate_contracts.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/evm/contracts" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" "github.com/cosmos/evm/testutil/integration/evm/network" @@ -57,7 +57,7 @@ func TestIterateContracts(t *testing.T, create network.CreateEvmApp, options ... network.App.GetEVMKeeper().IterateContracts(network.GetContext(), func(addr common.Address, codeHash common.Hash) bool { // NOTE: we only care about the 2 contracts deployed above, not the ERC20 native precompile for the aatom denomination - if bytes.Equal(addr.Bytes(), common.HexToAddress(testconstants.WEVMOSContractMainnet).Bytes()) { + if bytes.Equal(addr.Bytes(), common.HexToAddress(testconfig.WevmosContractMainnet).Bytes()) { return false } diff --git a/tests/integration/x/vm/test_statedb.go b/tests/integration/x/vm/test_statedb.go index b78480b90..eab92a1d9 100644 --- a/tests/integration/x/vm/test_statedb.go +++ b/tests/integration/x/vm/test_statedb.go @@ -12,7 +12,7 @@ import ( ethparams "github.com/ethereum/go-ethereum/params" "github.com/holiman/uint256" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/network" testkeyring "github.com/cosmos/evm/testutil/keyring" utiltx "github.com/cosmos/evm/testutil/tx" @@ -685,7 +685,7 @@ func (s *KeeperTestSuite) TestAddLog() { msg2.From = addr.Bytes() ethTx3Params := &types.EvmTxArgs{ - ChainID: big.NewInt(testconstants.ExampleEIP155ChainID), + ChainID: big.NewInt(testconfig.EighteenDecimalsChainID), Nonce: 0, To: &toAddr, Amount: common.Big1, diff --git a/tests/solidity/test-helper.js b/tests/solidity/test-helper.js index 01c129177..0154fdc4c 100644 --- a/tests/solidity/test-helper.js +++ b/tests/solidity/test-helper.js @@ -4,6 +4,9 @@ const { spawn } = require('child_process') const yargs = require('yargs/yargs') const { hideBin } = require('yargs/helpers') +// Chain ID constant for local test node +const TEST_CHAIN_ID = '262144' + const logger = { warn: (msg) => console.error(`WARN: ${msg}`), err: (msg) => console.error(`ERR: ${msg}`), @@ -15,33 +18,6 @@ function panic (errMsg) { process.exit(-1) } -// Function to extract EVMChainID from Go config file -function extractChainIDFromGo(goFilePath) { - try { - if (!fs.existsSync(goFilePath)) { - logger.warn(`Go config file not found at ${goFilePath}, using default chain ID: 262144`) - return 262144 - } - - const goFileContent = fs.readFileSync(goFilePath, 'utf8') - - // Look for DefaultEVMChainID = number - const chainIdMatch = goFileContent.match(/DefaultEVMChainID\s*=\s*(\d+)/) - - if (chainIdMatch) { - const chainId = parseInt(chainIdMatch[1], 10) - logger.info(`Extracted DefaultEVMChainID from Go config: ${chainId}`) - return chainId - } - - logger.warn('DefaultEVMChainID not found in Go file, using default: 262144') - return 262144 - } catch (error) { - logger.warn(`Error reading Go config file: ${error.message}, using default: 262144`) - return 262144 - } -} - // Function to update Hardhat config with the extracted chain ID function updateHardhatConfig(chainId, hardhatConfigPath) { try { @@ -123,9 +99,7 @@ function syncConfiguration() { // Create backup before modifying const backupPath = backupHardhatConfig(hardhatConfigPath) - - const chainId = extractChainIDFromGo(goConfigPath) - updateHardhatConfig(chainId, hardhatConfigPath) + updateHardhatConfig(TEST_CHAIN_ID, hardhatConfigPath) return { hardhatConfigPath, backupPath } } @@ -316,7 +290,7 @@ function setupNetwork ({ runConfig, timeout }) { const rootDir = path.resolve(__dirname, '..', '..'); // → ".../evm" const scriptPath = path.join(rootDir, 'local_node.sh'); // → ".../evm/local_node.sh" - const osdProc = spawn(scriptPath, ['-y'], { + const osdProc = spawn(scriptPath, ['-y', '-e', TEST_CHAIN_ID], { cwd: rootDir, stdio: ['ignore', 'pipe', 'pipe'], // <-- stdout/stderr streams }) diff --git a/testutil/config/config.go b/testutil/config/config.go deleted file mode 100644 index 7ea385bdb..000000000 --- a/testutil/config/config.go +++ /dev/null @@ -1,65 +0,0 @@ -package config - -import ( - "github.com/cosmos/evm/types" - evmtypes "github.com/cosmos/evm/x/vm/types" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// ChainsCoinInfo is a map of the chain id and its corresponding EvmCoinInfo -// that allows initializing the app with different coin info based on the -// chain id -var ChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ - EighteenDecimalsChainID: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, - }, - EVMChainID: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, - }, -} - -const ( - // Bech32Prefix defines the Bech32 prefix used for accounts on the exemplary Cosmos EVM blockchain. - Bech32Prefix = "cosmos" - // Bech32PrefixAccAddr defines the Bech32 prefix of an account's address. - Bech32PrefixAccAddr = Bech32Prefix - // Bech32PrefixAccPub defines the Bech32 prefix of an account's public key. - Bech32PrefixAccPub = Bech32Prefix + sdk.PrefixPublic - // Bech32PrefixValAddr defines the Bech32 prefix of a validator's operator address. - Bech32PrefixValAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator - // Bech32PrefixValPub defines the Bech32 prefix of a validator's operator public key. - Bech32PrefixValPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic - // Bech32PrefixConsAddr defines the Bech32 prefix of a consensus node address. - Bech32PrefixConsAddr = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus - // Bech32PrefixConsPub defines the Bech32 prefix of a consensus node public key. - Bech32PrefixConsPub = Bech32Prefix + sdk.PrefixValidator + sdk.PrefixConsensus + sdk.PrefixPublic - // DisplayDenom defines the denomination displayed to users in client applications. - DisplayDenom = "atom" - // BaseDenom defines to the default denomination used in the Cosmos EVM example chain. - BaseDenom = "aatom" - // BaseDenomUnit defines the precision of the base denomination. - BaseDenomUnit = 18 - // EVMChainID defines the EIP-155 replay-protection chain id for the current ethereum chain config. - EVMChainID = 262144 -) - -// SetBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings. -func SetBech32Prefixes(config *sdk.Config) { - config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub) - config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub) - config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub) -} - -// SetBip44CoinType sets the global coin type to be used in hierarchical deterministic wallets. -func SetBip44CoinType(config *sdk.Config) { - config.SetCoinType(types.Bip44CoinType) - config.SetPurpose(sdk.Purpose) // Shared - config.SetFullFundraiserPath(types.BIP44HDPath) //nolint: staticcheck -} diff --git a/testutil/config/config_testing.go b/testutil/config/config_testing.go deleted file mode 100644 index e37568c2b..000000000 --- a/testutil/config/config_testing.go +++ /dev/null @@ -1,63 +0,0 @@ -//go:build test -// +build test - -package config - -import ( - evmconfig "github.com/cosmos/evm/config" - evmtypes "github.com/cosmos/evm/x/vm/types" -) - -// TestChainsCoinInfo is a map of the chain id and its corresponding EvmCoinInfo -// that allows initializing the app with different coin info based on the -// chain id -var TestChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ - EighteenDecimalsChainID: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, - }, - SixDecimalsChainID: { - Denom: "utest", - ExtendedDenom: "atest", - DisplayDenom: "test", - Decimals: evmtypes.SixDecimals, - }, - TwelveDecimalsChainID: { - Denom: "ptest2", - ExtendedDenom: "atest2", - DisplayDenom: "test2", - Decimals: evmtypes.TwelveDecimals, - }, - TwoDecimalsChainID: { - Denom: "ctest3", - ExtendedDenom: "atest3", - DisplayDenom: "test3", - Decimals: evmtypes.TwoDecimals, - }, - TestChainID1: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleChainDenom, - Decimals: evmtypes.EighteenDecimals, - }, - TestChainID2: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleChainDenom, - Decimals: evmtypes.EighteenDecimals, - }, - EVMChainID: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, - }, -} - -// EvmAppOptions allows to setup the global configuration -// for the Cosmos EVM chain. -func EvmAppOptions(chainID uint64) error { - return evmconfig.EvmAppOptionsWithConfigWithReset(chainID, TestChainsCoinInfo, cosmosEVMActivators, true) -} diff --git a/testutil/config/constants.go b/testutil/config/constants.go index fb9bdbe4b..9596d0817 100644 --- a/testutil/config/constants.go +++ b/testutil/config/constants.go @@ -1,31 +1,133 @@ package config -const ( - // ExampleChainDenom is the denomination of the Cosmos EVM example chain's base coin. - ExampleChainDenom = "aatom" - - // ExampleDisplayDenom is the display denomination of the Cosmos EVM example chain's base coin. - ExampleDisplayDenom = "atom" +import ( + erc20types "github.com/cosmos/evm/x/erc20/types" + evmtypes "github.com/cosmos/evm/x/vm/types" - // EighteenDecimalsChainID is the chain ID for the 18 decimals chain. - EighteenDecimalsChainID = 9001 + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) +const ( + // TestChainID1 is test chain IDs for IBC E2E test + TestChainID1 = 9005 + // TestChainID2 is test chain IDs for IBC E2E test + TestChainID2 = 9006 + // TwoDecimalsChainID is the chain ID for the 2 decimals chain. + TwoDecimalsChainID = 9004 // SixDecimalsChainID is the chain ID for the 6 decimals chain. SixDecimalsChainID = 9002 - // TwelveDecimalsChainID is the chain ID for the 12 decimals chain. TwelveDecimalsChainID = 9003 + // EighteenDecimalsChainID is the chain ID for the 18 decimals chain. + EighteenDecimalsChainID = 9001 +) - // TwoDecimalsChainID is the chain ID for the 2 decimals chain. - TwoDecimalsChainID = 9004 +// TODO: update display denoms so that they less arbitrary (e.g. twodec, sixdec, twelvedec) +var ( + // TwoDecimalEvmCoinInfo is the EvmCoinInfo for the 2 decimals chain + TwoDecimalEvmCoinInfo = evmtypes.EvmCoinInfo{ + DisplayDenom: "test3", + Decimals: evmtypes.TwoDecimals, + BaseDenom: "ttest3", + ExtendedDenom: "atest3", + } + // SixDecimalEvmCoinInfo is the EvmCoinInfo for the 6 decimals chain + SixDecimalEvmCoinInfo = evmtypes.EvmCoinInfo{ + DisplayDenom: "test", + Decimals: evmtypes.SixDecimals, + BaseDenom: "utest", + ExtendedDenom: "atest", + } + // TwelveDecimalEvmCoinInfo is the EvmCoinInfo for a 12 decimals chain + TwelveDecimalEvmCoinInfo = evmtypes.EvmCoinInfo{ + DisplayDenom: "test2", + Decimals: evmtypes.TwelveDecimals, + BaseDenom: "twtest2", + ExtendedDenom: "atest2", + } + // ExampleAttoDenom provides an example denom for use in tests + ExampleAttoDenom = evmtypes.DefaultEvmCoinInfo.GetDenom() + // ExampleMicroDenom provides an example micro denom for use in tests + ExampleMicroDenom = SixDecimalEvmCoinInfo.GetDenom() + // WevmosContractMainnet is the WEVMOS contract address for mainnet + WevmosContractMainnet = evmtypes.DefaultWevmosContractMainnet + // WevmosContractTestnet is the WEVMOS contract address for testnet + WevmosContractTestnet = "0xcc491f589b45d4a3c679016195b3fb87d7848210" + // ExampleEvmAddress1 is the example EVM address + ExampleEvmAddressAlice = "0x1e0DE5DB1a39F99cBc67B00fA3415181b3509e42" + // ExampleEvmAddress2 is the example EVM address + ExampleEvmAddressBob = "0x0AFc8e15F0A74E98d0AEC6C67389D2231384D4B2" +) - CosmosChainID = 262144 +// TestChainsCoinInfo is a map of the chain id and its corresponding EvmCoinInfo +// used to initialize the app with different coin info based on the chain id +var TestChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ + TestChainID1: evmtypes.DefaultEvmCoinInfo, + TestChainID2: evmtypes.DefaultEvmCoinInfo, + TwoDecimalsChainID: TwoDecimalEvmCoinInfo, + SixDecimalsChainID: SixDecimalEvmCoinInfo, + TwelveDecimalsChainID: TwelveDecimalEvmCoinInfo, + EighteenDecimalsChainID: evmtypes.DefaultEvmCoinInfo, + evmtypes.DefaultEvmChainID: evmtypes.DefaultEvmCoinInfo, +} - // TestChainID1 is test chain IDs for IBC E2E test - TestChainID1 = 9005 - // TestChainID2 is test chain IDs for IBC E2E test - TestChainID2 = 9006 +// TODO: consolidate the ChainID and uint64 maps and update tests accordingly +type ChainID struct { + ChainID string `json:"chain_id"` + EVMChainID uint64 `json:"evm_chain_id"` +} - // WEVMOSContractMainnet is the WEVMOS contract address for mainnet - WEVMOSContractMainnet = "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517" +var ( + // ExampleChainID provides a chain ID that can be used in tests + ExampleChainID = ChainID{ + ChainID: sdk.Bech32MainPrefix + "-1", + EVMChainID: EighteenDecimalsChainID, + } + // TwoDecimalsChainID provides a chain ID which is being set up with 2 decimals + ExampleTwoDecimalsChainID = ChainID{ + ChainID: "ostwo-4", + EVMChainID: TwoDecimalsChainID, + } + // SixDecimalsChainID provides a chain ID which is being set up with 6 decimals + ExampleSixDecimalsChainID = ChainID{ + ChainID: "ossix-2", + EVMChainID: SixDecimalsChainID, + } + // TwelveDecimalsChainID provides a chain ID which is being set up with 12 decimals + ExampleTwelveDecimalsChainID = ChainID{ + ChainID: "ostwelve-3", + EVMChainID: TwelveDecimalsChainID, + } + // ExampleTokenPairs creates a slice of token pairs for the native denom of the example chain. + ExampleTokenPairs = []erc20types.TokenPair{ + { + Erc20Address: WevmosContractMainnet, + Denom: ExampleAttoDenom, + Enabled: true, + ContractOwner: erc20types.OWNER_MODULE, + }, + } + // ExampleAllowances creates a slice of allowances for the native denom of the example chain. + ExampleAllowances = []erc20types.Allowance{ + { + Erc20Address: WevmosContractMainnet, + Owner: ExampleEvmAddressAlice, + Spender: ExampleEvmAddressBob, + Value: math.NewInt(100), + }, + } + // OtherCoinDenoms provides a list of other coin denoms that can be used in tests + OtherCoinDenoms = []string{ + "foo", + "bar", + } ) + +// ExampleChainCoinInfo provides the coin info for the example chain +var ExampleChainCoinInfo = map[ChainID]evmtypes.EvmCoinInfo{ + ExampleChainID: evmtypes.DefaultEvmCoinInfo, + ExampleTwoDecimalsChainID: TwoDecimalEvmCoinInfo, + ExampleSixDecimalsChainID: SixDecimalEvmCoinInfo, + ExampleTwelveDecimalsChainID: TwelveDecimalEvmCoinInfo, +} diff --git a/testutil/config/eips.go b/testutil/config/eips.go deleted file mode 100644 index a1157805e..000000000 --- a/testutil/config/eips.go +++ /dev/null @@ -1,33 +0,0 @@ -package config - -import ( - "github.com/ethereum/go-ethereum/core/vm" -) - -var ( - Multiplier = uint64(10) - SstoreConstantGas = uint64(500) -) - -// enable0000 contains the logic to modify the CREATE and CREATE2 opcodes -// constant gas value. -func Enable0000(jt *vm.JumpTable) { - currentValCreate := jt[vm.CREATE].GetConstantGas() - jt[vm.CREATE].SetConstantGas(currentValCreate * Multiplier) - - currentValCreate2 := jt[vm.CREATE2].GetConstantGas() - jt[vm.CREATE2].SetConstantGas(currentValCreate2 * Multiplier) -} - -// enable0001 contains the logic to modify the CALL opcode -// constant gas value. -func Enable0001(jt *vm.JumpTable) { - currentVal := jt[vm.CALL].GetConstantGas() - jt[vm.CALL].SetConstantGas(currentVal * Multiplier) -} - -// enable0002 contains the logic to modify the SSTORE opcode -// constant gas value. -func Enable0002(jt *vm.JumpTable) { - jt[vm.SSTORE].SetConstantGas(SstoreConstantGas) -} diff --git a/testutil/config/evm_app_options.go b/testutil/config/evm_app_options.go deleted file mode 100644 index 07e73107d..000000000 --- a/testutil/config/evm_app_options.go +++ /dev/null @@ -1,14 +0,0 @@ -//go:build !test -// +build !test - -package config - -import ( - evmconfig "github.com/cosmos/evm/config" -) - -// EvmAppOptions allows to setup the global configuration -// for the Cosmos EVM chain. -func EvmAppOptions(chainID uint64) error { - return evmconfig.EvmAppOptionsWithConfig(chainID, ChainsCoinInfo, cosmosEVMActivators) -} diff --git a/testutil/config/genesis.go b/testutil/config/genesis.go index 4dc55d415..63b6edb0c 100644 --- a/testutil/config/genesis.go +++ b/testutil/config/genesis.go @@ -3,7 +3,6 @@ package config import ( "encoding/json" - testconstants "github.com/cosmos/evm/testutil/constants" erc20types "github.com/cosmos/evm/x/erc20/types" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -37,8 +36,8 @@ func NewEVMGenesisState() *evmtypes.GenesisState { // which is the base denomination of the chain (i.e. the WEVMOS contract). func NewErc20GenesisState() *erc20types.GenesisState { erc20GenState := erc20types.DefaultGenesisState() - erc20GenState.TokenPairs = testconstants.ExampleTokenPairs - erc20GenState.NativePrecompiles = []string{testconstants.WEVMOSContractMainnet} + erc20GenState.TokenPairs = ExampleTokenPairs + erc20GenState.NativePrecompiles = []string{WevmosContractMainnet} return erc20GenState } @@ -48,7 +47,7 @@ func NewErc20GenesisState() *erc20types.GenesisState { // NOTE: for the example chain implementation we are also adding a default minter. func NewMintGenesisState() *minttypes.GenesisState { mintGenState := minttypes.DefaultGenesisState() - mintGenState.Params.MintDenom = ExampleChainDenom + mintGenState.Params.MintDenom = ExampleAttoDenom return mintGenState } diff --git a/testutil/constants/constants.go b/testutil/constants/constants.go deleted file mode 100644 index 1b2cf732a..000000000 --- a/testutil/constants/constants.go +++ /dev/null @@ -1,131 +0,0 @@ -package constants - -import ( - erc20types "github.com/cosmos/evm/x/erc20/types" - evmtypes "github.com/cosmos/evm/x/vm/types" - - "cosmossdk.io/math" -) - -const ( - // DefaultGasPrice is used in testing as the default to use for transactions - DefaultGasPrice = 20 - - // ExampleAttoDenom provides an example denom for use in tests - ExampleAttoDenom = "aatom" - - // ExampleMicroDenom provides an example denom for use in tests - ExampleMicroDenom = "uatom" - - // ExampleDisplayDenom provides an example display denom for use in tests - ExampleDisplayDenom = "atom" - - // ExampleBech32Prefix provides an example Bech32 prefix for use in tests - ExampleBech32Prefix = "cosmos" - - // ExampleEIP155ChainID provides an example EIP-155 chain ID for use in tests - ExampleEIP155ChainID = 9001 - - // WEVMOSContractMainnet is the WEVMOS contract address for mainnet - WEVMOSContractMainnet = "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517" - // WEVMOSContractTestnet is the WEVMOS contract address for testnet - WEVMOSContractTestnet = "0xcc491f589b45d4a3c679016195b3fb87d7848210" - // ExampleEvmAddress1 is the example EVM address - ExampleEvmAddressAlice = "0x1e0DE5DB1a39F99cBc67B00fA3415181b3509e42" - // ExampleEvmAddress2 is the example EVM address - ExampleEvmAddressBob = "0x0AFc8e15F0A74E98d0AEC6C67389D2231384D4B2" -) - -type ChainID struct { - ChainID string `json:"chain_id"` - EVMChainID uint64 `json:"evm_chain_id"` -} - -var ( - // ExampleChainIDPrefix provides a chain ID prefix for EIP-155 that can be used in tests - ExampleChainIDPrefix = "cosmos" - - // ExampleChainID provides a chain ID that can be used in tests - ExampleChainID = ChainID{ - ChainID: ExampleChainIDPrefix + "-1", - EVMChainID: 9001, - } - - // SixDecimalsChainID provides a chain ID which is being set up with 6 decimals - SixDecimalsChainID = ChainID{ - ChainID: "ossix-2", - EVMChainID: 9002, - } - - // TwelveDecimalsChainID provides a chain ID which is being set up with 12 decimals - TwelveDecimalsChainID = ChainID{ - ChainID: "ostwelve-3", - EVMChainID: 9003, - } - - // TwoDecimalsChainID provides a chain ID which is being set up with 2 decimals - TwoDecimalsChainID = ChainID{ - ChainID: "ostwo-4", - EVMChainID: 9004, - } - - // ExampleChainCoinInfo provides the coin info for the example chain - // - // It is a map of the chain id and its corresponding EvmCoinInfo - // that allows initializing the app with different coin info based on the - // chain id - ExampleChainCoinInfo = map[ChainID]evmtypes.EvmCoinInfo{ - ExampleChainID: { - Denom: ExampleAttoDenom, - ExtendedDenom: ExampleAttoDenom, - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, - }, - SixDecimalsChainID: { - Denom: "utest", - ExtendedDenom: "atest", - DisplayDenom: "test", - Decimals: evmtypes.SixDecimals, - }, - TwelveDecimalsChainID: { - Denom: "ptest2", - ExtendedDenom: "atest2", - DisplayDenom: "test2", - Decimals: evmtypes.TwelveDecimals, - }, - TwoDecimalsChainID: { - Denom: "ctest3", - ExtendedDenom: "atest3", - DisplayDenom: "test3", - Decimals: evmtypes.TwoDecimals, - }, - } - - // OtherCoinDenoms provides a list of other coin denoms that can be used in tests - OtherCoinDenoms = []string{ - "foo", - "bar", - } - - // ExampleTokenPairs creates a slice of token pairs, that contains a pair for the native denom of the example chain - // implementation. - ExampleTokenPairs = []erc20types.TokenPair{ - { - Erc20Address: WEVMOSContractMainnet, - Denom: ExampleAttoDenom, - Enabled: true, - ContractOwner: erc20types.OWNER_MODULE, - }, - } - - // ExampleAllowances creates a slice of allowances, that contains an allowance for the native denom of the example chain - // implementation. - ExampleAllowances = []erc20types.Allowance{ - { - Erc20Address: WEVMOSContractMainnet, - Owner: ExampleEvmAddressAlice, - Spender: ExampleEvmAddressBob, - Value: math.NewInt(100), - }, - } -) diff --git a/testutil/constants/constants_test.go b/testutil/constants/constants_test.go deleted file mode 100644 index 30c951cd4..000000000 --- a/testutil/constants/constants_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package constants_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/evm/testutil/config" - "github.com/cosmos/evm/testutil/constants" -) - -func TestRequireSameTestDenom(t *testing.T) { - require.Equal(t, - constants.ExampleAttoDenom, - config.ExampleChainDenom, - "test denoms should be the same across the repo", - ) -} - -func TestRequireSameTestBech32Prefix(t *testing.T) { - require.Equal(t, - constants.ExampleBech32Prefix, - config.Bech32Prefix, - "bech32 prefixes should be the same across the repo", - ) -} - -func TestRequireSameWEVMOSMainnet(t *testing.T) { - require.Equal(t, - constants.WEVMOSContractMainnet, - config.WEVMOSContractMainnet, - "wevmos contract addresses should be the same across the repo", - ) -} diff --git a/testutil/ibc/chain.go b/testutil/ibc/chain.go index e78c82c4b..bdb6dcb0e 100644 --- a/testutil/ibc/chain.go +++ b/testutil/ibc/chain.go @@ -19,7 +19,6 @@ import ( "github.com/cosmos/evm" "github.com/cosmos/evm/crypto/ethsecp256k1" - "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/evm/x/vm/types" clienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types" @@ -135,7 +134,7 @@ func NewTestChainWithValSet(tb testing.TB, isEVM bool, coord *Coordinator, chain Address: acc.GetAddress().String(), Coins: sdk.NewCoins( sdk.NewCoin(sdk.DefaultBondDenom, amount), - sdk.NewCoin(config.ExampleChainDenom, amount), + sdk.NewCoin(testconfig.ExampleAttoDenom, amount), ), } diff --git a/testutil/ibc/coordinator.go b/testutil/ibc/coordinator.go index c4823df48..5360daf17 100644 --- a/testutil/ibc/coordinator.go +++ b/testutil/ibc/coordinator.go @@ -8,7 +8,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/cosmos/evm/testutil/config" + evmconfig "github.com/cosmos/evm/config" ibctesting "github.com/cosmos/ibc-go/v10/testing" ) @@ -41,8 +41,9 @@ func NewCoordinator(t *testing.T, nEVMChains, mCosmosChains int, evmAppCreator i for i := 1; i <= nEVMChains; i++ { chainID := GetChainID(i) evmChainID, err := strconv.ParseUint(GetEvmChainID(i), 10, 64) + chainConfig := evmconfig.NewDefaultEvmConfig(evmChainID, false) require.NoError(t, err) - require.NoError(t, config.EvmAppOptions(evmChainID)) + require.NoError(t, chainConfig.Apply()) // setup EVM chains chains[strconv.FormatUint(evmChainID, 10)] = NewTestChain(t, true, coord, chainID) } diff --git a/testutil/integration/evm/network/amounts.go b/testutil/integration/evm/network/amounts.go index a70b6d239..fd4d2de07 100644 --- a/testutil/integration/evm/network/amounts.go +++ b/testutil/integration/evm/network/amounts.go @@ -3,7 +3,7 @@ package network import ( "math/big" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -18,7 +18,7 @@ type InitialAmounts struct { } func DefaultInitialAmounts() InitialAmounts { - baseCoinInfo := testconstants.ExampleChainCoinInfo[defaultChain] + baseCoinInfo := testconfig.ExampleChainCoinInfo[defaultChain] return InitialAmounts{ Base: GetInitialAmount(baseCoinInfo.Decimals), @@ -27,7 +27,7 @@ func DefaultInitialAmounts() InitialAmounts { } func DefaultInitialBondedAmount() math.Int { - baseCoinInfo := testconstants.ExampleChainCoinInfo[defaultChain] + baseCoinInfo := testconfig.ExampleChainCoinInfo[defaultChain] return GetInitialBondedAmount(baseCoinInfo.Decimals) } diff --git a/testutil/integration/evm/network/chain_id_modifiers.go b/testutil/integration/evm/network/chain_id_modifiers.go index 736c14e5c..bbf269470 100644 --- a/testutil/integration/evm/network/chain_id_modifiers.go +++ b/testutil/integration/evm/network/chain_id_modifiers.go @@ -5,7 +5,7 @@ package network import ( - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" erc20types "github.com/cosmos/evm/x/erc20/types" "github.com/cosmos/evm/x/precisebank/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -72,7 +72,7 @@ func generateBankGenesisMetadata() []banktypes.Metadata { // updateErc20GenesisStateForChainID modify the default genesis state for the // erc20 module on the testing suite depending on the chainID. -func updateErc20GenesisStateForChainID(chainID testconstants.ChainID, erc20GenesisState erc20types.GenesisState) erc20types.GenesisState { +func updateErc20GenesisStateForChainID(chainID testconfig.ChainID, erc20GenesisState erc20types.GenesisState) erc20types.GenesisState { erc20GenesisState.TokenPairs = updateErc20TokenPairs(chainID, erc20GenesisState.TokenPairs) return erc20GenesisState @@ -80,18 +80,18 @@ func updateErc20GenesisStateForChainID(chainID testconstants.ChainID, erc20Genes // updateErc20TokenPairs modifies the erc20 token pairs to use the correct // WEVMOS depending on ChainID -func updateErc20TokenPairs(chainID testconstants.ChainID, tokenPairs []erc20types.TokenPair) []erc20types.TokenPair { +func updateErc20TokenPairs(chainID testconfig.ChainID, tokenPairs []erc20types.TokenPair) []erc20types.TokenPair { testnetAddress := GetWEVMOSContractHex(chainID) - coinInfo := testconstants.ExampleChainCoinInfo[chainID] + coinInfo := testconfig.ExampleChainCoinInfo[chainID] - mainnetAddress := GetWEVMOSContractHex(testconstants.ExampleChainID) + mainnetAddress := GetWEVMOSContractHex(testconfig.ExampleChainID) updatedTokenPairs := make([]erc20types.TokenPair, len(tokenPairs)) for i, tokenPair := range tokenPairs { if tokenPair.Erc20Address == mainnetAddress { updatedTokenPairs[i] = erc20types.TokenPair{ Erc20Address: testnetAddress, - Denom: coinInfo.Denom, + Denom: coinInfo.GetDenom(), Enabled: tokenPair.Enabled, ContractOwner: tokenPair.ContractOwner, } diff --git a/testutil/integration/evm/network/coins.go b/testutil/integration/evm/network/coins.go index 022a5d55f..dc497ab30 100644 --- a/testutil/integration/evm/network/coins.go +++ b/testutil/integration/evm/network/coins.go @@ -1,7 +1,7 @@ package network import ( - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" evmtypes "github.com/cosmos/evm/x/vm/types" ) @@ -25,7 +25,7 @@ type ChainCoins struct { // DefaultChainCoins returns the default values used for the ChainCoins in which // base and evm denom are the same. func DefaultChainCoins() ChainCoins { - baseCoinInfo := testconstants.ExampleChainCoinInfo[defaultChain] + baseCoinInfo := testconfig.ExampleChainCoinInfo[defaultChain] // baseCoin is used for both base and evm coin as default.. baseCoin := getCoinInfo(baseCoinInfo) @@ -39,7 +39,7 @@ func DefaultChainCoins() ChainCoins { func getCoinInfo(coinInfo evmtypes.EvmCoinInfo) CoinInfo { return CoinInfo{ - Denom: coinInfo.Denom, + Denom: coinInfo.GetDenom(), Decimals: coinInfo.Decimals, } } diff --git a/testutil/integration/evm/network/config.go b/testutil/integration/evm/network/config.go index ed612f75f..b90877c02 100644 --- a/testutil/integration/evm/network/config.go +++ b/testutil/integration/evm/network/config.go @@ -6,7 +6,7 @@ import ( cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" testtx "github.com/cosmos/evm/testutil/tx" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -20,7 +20,7 @@ import ( ) // defaultChain represents the default chain ID used in the suite setup. -var defaultChain = testconstants.ExampleChainID +var defaultChain = testconfig.ExampleChainID // Config defines the configuration for a chain. // It allows for customization of the network to adjust to @@ -54,8 +54,8 @@ func DefaultConfig() Config { account, _ := testtx.NewAccAddressAndKey() return Config{ - chainID: testconstants.ExampleChainID.ChainID, - eip155ChainID: big.NewInt(testconstants.ExampleEIP155ChainID), + chainID: testconfig.ExampleChainID.ChainID, + eip155ChainID: big.NewInt(testconfig.EighteenDecimalsChainID), chainCoins: DefaultChainCoins(), initialAmounts: DefaultInitialAmounts(), initialBondedAmount: DefaultInitialBondedAmount(), @@ -117,13 +117,13 @@ type ConfigOption func(*Config) // WithChainID sets a custom chainID for the network. Changing the chainID // change automatically also the EVM coin used. It panics if the chainID is invalid. -func WithChainID(chainID testconstants.ChainID) ConfigOption { - evmCoinInfo, found := testconstants.ExampleChainCoinInfo[chainID] +func WithChainID(chainID testconfig.ChainID) ConfigOption { + evmCoinInfo, found := testconfig.ExampleChainCoinInfo[chainID] if !found { panic(fmt.Sprintf( "chain id %q not found in chain coin info; available: %v", chainID, - testconstants.ExampleChainCoinInfo, + testconfig.ExampleChainCoinInfo, )) } @@ -132,10 +132,10 @@ func WithChainID(chainID testconstants.ChainID) ConfigOption { cfg.eip155ChainID = big.NewInt(int64(chainID.EVMChainID)) //nolint:gosec // G115 // won't exceed uint64 if cfg.chainCoins.IsBaseEqualToEVM() { - cfg.chainCoins.baseCoin.Denom = evmCoinInfo.Denom + cfg.chainCoins.baseCoin.Denom = evmCoinInfo.GetDenom() cfg.chainCoins.baseCoin.Decimals = evmCoinInfo.Decimals } - cfg.chainCoins.evmCoin.Denom = evmCoinInfo.Denom + cfg.chainCoins.evmCoin.Denom = evmCoinInfo.GetDenom() cfg.chainCoins.evmCoin.Decimals = evmCoinInfo.Decimals } } diff --git a/testutil/integration/evm/network/example_contracts.go b/testutil/integration/evm/network/example_contracts.go index ab3a3daba..1543a9ec6 100644 --- a/testutil/integration/evm/network/example_contracts.go +++ b/testutil/integration/evm/network/example_contracts.go @@ -1,26 +1,26 @@ package network import ( - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" ) // chainsWEVMOSHex is an utility map used to retrieve the WEVMOS contract // address in hex format from the chain ID. // // TODO: refactor to define this in the example chain initialization and pass as function argument -var chainsWEVMOSHex = map[testconstants.ChainID]string{ - testconstants.ExampleChainID: testconstants.WEVMOSContractMainnet, +var chainsWEVMOSHex = map[testconfig.ChainID]string{ + testconfig.ExampleChainID: testconfig.WevmosContractMainnet, } // GetWEVMOSContractHex returns the hex format of address for the WEVMOS contract // given the chainID. If the chainID is not found, it defaults to the mainnet // address. -func GetWEVMOSContractHex(chainID testconstants.ChainID) string { +func GetWEVMOSContractHex(chainID testconfig.ChainID) string { address, found := chainsWEVMOSHex[chainID] // default to mainnet address if !found { - address = chainsWEVMOSHex[testconstants.ExampleChainID] + address = chainsWEVMOSHex[testconfig.ExampleChainID] } return address diff --git a/testutil/integration/evm/network/setup.go b/testutil/integration/evm/network/setup.go index f352bd4af..1913bf3dd 100644 --- a/testutil/integration/evm/network/setup.go +++ b/testutil/integration/evm/network/setup.go @@ -9,7 +9,7 @@ import ( cmttypes "github.com/cometbft/cometbft/types" "github.com/cosmos/evm" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" cosmosevmtypes "github.com/cosmos/evm/types" erc20types "github.com/cosmos/evm/x/erc20/types" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" @@ -463,7 +463,7 @@ func setDefaultMintGenesisState(cosmosEVMApp evm.EvmApp, genesisState cosmosevmt func setDefaultErc20GenesisState(cosmosEVMApp evm.EvmApp, evmChainID uint64, genesisState cosmosevmtypes.GenesisState) cosmosevmtypes.GenesisState { // NOTE: here we are using the setup from the example chain erc20Gen := newErc20GenesisState() - updatedErc20Gen := updateErc20GenesisStateForChainID(testconstants.ChainID{ + updatedErc20Gen := updateErc20GenesisStateForChainID(testconfig.ChainID{ ChainID: cosmosEVMApp.ChainID(), EVMChainID: evmChainID, }, *erc20Gen) @@ -479,8 +479,8 @@ func setDefaultErc20GenesisState(cosmosEVMApp evm.EvmApp, evmChainID uint64, gen // which is the base denomination of the chain (i.e. the WEVMOS contract). func newErc20GenesisState() *erc20types.GenesisState { erc20GenState := erc20types.DefaultGenesisState() - erc20GenState.TokenPairs = testconstants.ExampleTokenPairs - erc20GenState.NativePrecompiles = []string{testconstants.WEVMOSContractMainnet} + erc20GenState.TokenPairs = testconfig.ExampleTokenPairs + erc20GenState.NativePrecompiles = []string{testconfig.WevmosContractMainnet} return erc20GenState } diff --git a/testutil/integration/evm/utils/genesis.go b/testutil/integration/evm/utils/genesis.go index 76c340fe5..6f28686fe 100644 --- a/testutil/integration/evm/utils/genesis.go +++ b/testutil/integration/evm/utils/genesis.go @@ -1,7 +1,7 @@ package utils import ( - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/network" testkeyring "github.com/cosmos/evm/testutil/keyring" utiltx "github.com/cosmos/evm/testutil/tx" @@ -50,7 +50,7 @@ func CreateGenesisWithTokenPairs(keyring testkeyring.Keyring, denoms ...string) tokenPairs := make([]erc20types.TokenPair, 0, len(denoms)+1) tokenPairs = append(tokenPairs, // NOTE: the example token pairs are being added in the integration test utils - testconstants.ExampleTokenPairs..., + testconfig.ExampleTokenPairs..., ) dynPrecAddr := make([]string, 0, len(denoms)) @@ -70,7 +70,7 @@ func CreateGenesisWithTokenPairs(keyring testkeyring.Keyring, denoms ...string) // with the WEVMOS (default is mainnet) and 'xmpl' tokens in the erc20 params erc20GenesisState := erc20types.DefaultGenesisState() erc20GenesisState.TokenPairs = tokenPairs - erc20GenesisState.NativePrecompiles = []string{testconstants.WEVMOSContractMainnet} + erc20GenesisState.NativePrecompiles = []string{testconfig.WevmosContractMainnet} erc20GenesisState.DynamicPrecompiles = dynPrecAddr // Combine module genesis states @@ -86,8 +86,8 @@ func CreateGenesisWithTokenPairs(keyring testkeyring.Keyring, denoms ...string) // which is the base denomination of the chain (i.e. the WEVMOS contract). func NewErc20GenesisState() *erc20types.GenesisState { erc20GenState := erc20types.DefaultGenesisState() - erc20GenState.TokenPairs = testconstants.ExampleTokenPairs - erc20GenState.NativePrecompiles = []string{testconstants.WEVMOSContractMainnet} + erc20GenState.TokenPairs = testconfig.ExampleTokenPairs + erc20GenState.NativePrecompiles = []string{testconfig.WevmosContractMainnet} return erc20GenState } diff --git a/testutil/tx/cosmos.go b/testutil/tx/cosmos.go index f130c360c..46e55f8db 100644 --- a/testutil/tx/cosmos.go +++ b/testutil/tx/cosmos.go @@ -4,7 +4,7 @@ import ( protov2 "google.golang.org/protobuf/proto" "github.com/cosmos/evm" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" sdkmath "cosmossdk.io/math" @@ -16,7 +16,7 @@ import ( authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" ) -var DefaultFee = sdk.NewCoin(constants.ExampleAttoDenom, sdkmath.NewInt(1e16)) // 0.01 AATOM +var DefaultFee = sdk.NewCoin(testconfig.ExampleAttoDenom, sdkmath.NewInt(1e16)) // 0.01 AATOM // CosmosTxArgs contains the params to create a cosmos tx type CosmosTxArgs struct { @@ -51,7 +51,7 @@ func PrepareCosmosTx( var fees sdk.Coins if args.GasPrice != nil { - fees = sdk.Coins{{Denom: constants.ExampleAttoDenom, Amount: args.GasPrice.MulRaw(int64(args.Gas))}} //#nosec G115 + fees = sdk.Coins{{Denom: testconfig.ExampleAttoDenom, Amount: args.GasPrice.MulRaw(int64(args.Gas))}} //#nosec G115 } else { fees = sdk.Coins{DefaultFee} } diff --git a/utils/utils_test.go b/utils/utils_test.go index c6d7d331f..7c2911621 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -14,7 +14,7 @@ import ( cryptocodec "github.com/cosmos/evm/crypto/codec" "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/crypto/hd" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/types" "github.com/cosmos/evm/utils" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" @@ -487,12 +487,12 @@ func TestAccountEquivalence(t *testing.T) { } func TestCalcBaseFee(t *testing.T) { - for _, chainID := range []constants.ChainID{constants.ExampleChainID, constants.TwelveDecimalsChainID, constants.SixDecimalsChainID} { + for _, chainID := range []testconfig.ChainID{testconfig.ExampleChainID, testconfig.ExampleTwelveDecimalsChainID, testconfig.ExampleSixDecimalsChainID} { t.Run(chainID.ChainID, func(t *testing.T) { - evmConfigurator := evmtypes.NewEVMConfigurator(). - WithEVMCoinInfo(constants.ExampleChainCoinInfo[chainID]) + evmConfigurator := evmtypes.NewEvmConfig(). + WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[chainID]) evmConfigurator.ResetTestConfig() - err := evmConfigurator.Configure() + err := evmConfigurator.Apply() require.NoError(t, err) config := ¶ms.ChainConfig{ diff --git a/x/erc20/types/genesis_test.go b/x/erc20/types/genesis_test.go index 10abb1373..c6de6d275 100644 --- a/x/erc20/types/genesis_test.go +++ b/x/erc20/types/genesis_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/suite" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/x/erc20/types" "cosmossdk.io/math" @@ -23,7 +23,7 @@ func TestGenesisTestSuite(t *testing.T) { } func (suite *GenesisTestSuite) TestValidateGenesis() { - newGen := types.NewGenesisState(types.DefaultParams(), testconstants.ExampleTokenPairs, testconstants.ExampleAllowances) + newGen := types.NewGenesisState(types.DefaultParams(), testconfig.ExampleTokenPairs, testconfig.ExampleAllowances) testCases := []struct { name string @@ -44,8 +44,8 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { name: "valid genesis", genState: &types.GenesisState{ Params: types.DefaultParams(), - TokenPairs: testconstants.ExampleTokenPairs, - Allowances: testconstants.ExampleAllowances, + TokenPairs: testconfig.ExampleTokenPairs, + Allowances: testconfig.ExampleAllowances, }, expPass: true, }, @@ -60,12 +60,12 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Enabled: true, }, { - Erc20Address: testconstants.WEVMOSContractMainnet, - Denom: testconstants.ExampleAttoDenom, + Erc20Address: testconfig.WevmosContractMainnet, + Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, - Allowances: testconstants.ExampleAllowances, + Allowances: testconfig.ExampleAllowances, }, expPass: true, }, @@ -85,12 +85,12 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Enabled: true, }, { - Erc20Address: testconstants.WEVMOSContractMainnet, - Denom: testconstants.ExampleAttoDenom, + Erc20Address: testconfig.WevmosContractMainnet, + Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, - Allowances: testconstants.ExampleAllowances, + Allowances: testconfig.ExampleAllowances, }, expPass: false, }, @@ -110,12 +110,12 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Enabled: true, }, { - Erc20Address: testconstants.WEVMOSContractMainnet, - Denom: testconstants.ExampleAttoDenom, + Erc20Address: testconfig.WevmosContractMainnet, + Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, - Allowances: testconstants.ExampleAllowances, + Allowances: testconfig.ExampleAllowances, }, expPass: false, }, @@ -135,12 +135,12 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Enabled: true, }, { - Erc20Address: testconstants.WEVMOSContractMainnet, - Denom: testconstants.ExampleAttoDenom, + Erc20Address: testconfig.WevmosContractMainnet, + Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, - Allowances: testconstants.ExampleAllowances, + Allowances: testconfig.ExampleAllowances, }, expPass: false, }, @@ -155,12 +155,12 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Enabled: true, }, { - Erc20Address: testconstants.WEVMOSContractMainnet, - Denom: testconstants.ExampleAttoDenom, + Erc20Address: testconfig.WevmosContractMainnet, + Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, - Allowances: testconstants.ExampleAllowances, + Allowances: testconfig.ExampleAllowances, }, expPass: false, }, @@ -175,7 +175,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Enabled: true, }, }, - Allowances: testconstants.ExampleAllowances, + Allowances: testconfig.ExampleAllowances, }, expPass: false, }, @@ -183,18 +183,18 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { name: "invalid genesis - duplicated allowances", genState: &types.GenesisState{ Params: types.DefaultParams(), - TokenPairs: testconstants.ExampleTokenPairs, + TokenPairs: testconfig.ExampleTokenPairs, Allowances: []types.Allowance{ { - Erc20Address: testconstants.WEVMOSContractMainnet, - Owner: testconstants.ExampleEvmAddressAlice, - Spender: testconstants.ExampleEvmAddressBob, + Erc20Address: testconfig.WevmosContractMainnet, + Owner: testconfig.ExampleEvmAddressAlice, + Spender: testconfig.ExampleEvmAddressBob, Value: math.NewInt(100), }, { - Erc20Address: testconstants.WEVMOSContractMainnet, - Owner: testconstants.ExampleEvmAddressAlice, - Spender: testconstants.ExampleEvmAddressBob, + Erc20Address: testconfig.WevmosContractMainnet, + Owner: testconfig.ExampleEvmAddressAlice, + Spender: testconfig.ExampleEvmAddressBob, Value: math.NewInt(100), }, }, @@ -207,16 +207,16 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: types.DefaultParams(), TokenPairs: []types.TokenPair{ { - Erc20Address: testconstants.WEVMOSContractMainnet, - Denom: testconstants.ExampleAttoDenom, + Erc20Address: testconfig.WevmosContractMainnet, + Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, Allowances: []types.Allowance{ { Erc20Address: "bad", - Owner: testconstants.ExampleEvmAddressAlice, - Spender: testconstants.ExampleEvmAddressBob, + Owner: testconfig.ExampleEvmAddressAlice, + Spender: testconfig.ExampleEvmAddressBob, Value: math.NewInt(-1), }, }, @@ -229,16 +229,16 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: types.DefaultParams(), TokenPairs: []types.TokenPair{ { - Erc20Address: testconstants.WEVMOSContractMainnet, - Denom: testconstants.ExampleAttoDenom, + Erc20Address: testconfig.WevmosContractMainnet, + Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, Allowances: []types.Allowance{ { - Erc20Address: testconstants.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Owner: "bad", - Spender: testconstants.ExampleEvmAddressBob, + Spender: testconfig.ExampleEvmAddressBob, Value: math.NewInt(-1), }, }, @@ -251,15 +251,15 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: types.DefaultParams(), TokenPairs: []types.TokenPair{ { - Erc20Address: testconstants.WEVMOSContractMainnet, - Denom: testconstants.ExampleAttoDenom, + Erc20Address: testconfig.WevmosContractMainnet, + Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, Allowances: []types.Allowance{ { - Erc20Address: testconstants.WEVMOSContractMainnet, - Owner: testconstants.ExampleEvmAddressAlice, + Erc20Address: testconfig.WevmosContractMainnet, + Owner: testconfig.ExampleEvmAddressAlice, Spender: "bad", Value: math.NewInt(-1), }, @@ -273,16 +273,16 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: types.DefaultParams(), TokenPairs: []types.TokenPair{ { - Erc20Address: testconstants.WEVMOSContractMainnet, - Denom: testconstants.ExampleAttoDenom, + Erc20Address: testconfig.WevmosContractMainnet, + Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, Allowances: []types.Allowance{ { - Erc20Address: testconstants.WEVMOSContractMainnet, - Owner: testconstants.ExampleEvmAddressAlice, - Spender: testconstants.ExampleEvmAddressBob, + Erc20Address: testconfig.WevmosContractMainnet, + Owner: testconfig.ExampleEvmAddressAlice, + Spender: testconfig.ExampleEvmAddressBob, Value: math.NewInt(0), }, }, @@ -295,16 +295,16 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: types.DefaultParams(), TokenPairs: []types.TokenPair{ { - Erc20Address: testconstants.WEVMOSContractMainnet, - Denom: testconstants.ExampleAttoDenom, + Erc20Address: testconfig.WevmosContractMainnet, + Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, Allowances: []types.Allowance{ { - Erc20Address: testconstants.WEVMOSContractMainnet, - Owner: testconstants.ExampleEvmAddressAlice, - Spender: testconstants.ExampleEvmAddressBob, + Erc20Address: testconfig.WevmosContractMainnet, + Owner: testconfig.ExampleEvmAddressAlice, + Spender: testconfig.ExampleEvmAddressBob, Value: math.NewInt(-1), }, }, diff --git a/x/precisebank/keeper/keeper_test.go b/x/precisebank/keeper/keeper_test.go index 75a4656ef..1a2280f95 100644 --- a/x/precisebank/keeper/keeper_test.go +++ b/x/precisebank/keeper/keeper_test.go @@ -3,9 +3,9 @@ package keeper_test import ( "testing" + evmconfig "github.com/cosmos/evm/config" evmosencoding "github.com/cosmos/evm/encoding" - "github.com/cosmos/evm/testutil/config" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/x/precisebank/keeper" "github.com/cosmos/evm/x/precisebank/types" "github.com/cosmos/evm/x/precisebank/types/mocks" @@ -40,11 +40,12 @@ func newMockedTestData(t *testing.T) testData { bk := mocks.NewBankKeeper(t) ak := mocks.NewAccountKeeper(t) - chainID := testconstants.SixDecimalsChainID.EVMChainID + chainID := testconfig.ExampleSixDecimalsChainID.EVMChainID cfg := evmosencoding.MakeConfig(chainID) cdc := cfg.Codec k := keeper.NewKeeper(cdc, storeKey, bk, ak) - err := config.EvmAppOptions(chainID) + chainConfig := evmconfig.NewTestChainConfig(chainID) + err := chainConfig.ApplyChainConfig() if err != nil { return testData{} } diff --git a/x/precisebank/module.go b/x/precisebank/module.go index 3008920e3..5da71ceb7 100644 --- a/x/precisebank/module.go +++ b/x/precisebank/module.go @@ -78,7 +78,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod if err != nil { return err } - return gs.Validate() + return nil } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for precisebank module. diff --git a/x/precisebank/types/extended_balance_test.go b/x/precisebank/types/extended_balance_test.go index d0a013f1b..bde284d03 100644 --- a/x/precisebank/types/extended_balance_test.go +++ b/x/precisebank/types/extended_balance_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/require" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/x/precisebank/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -15,11 +15,11 @@ import ( ) func TestSumExtendedCoin(t *testing.T) { - coinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] - configurator := evmtypes.NewEVMConfigurator() + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID] + configurator := evmtypes.NewEvmConfig() err := configurator. WithEVMCoinInfo(coinInfo). - Configure() + Apply() require.NoError(t, err) tests := []struct { diff --git a/x/precisebank/types/genesis_test.go b/x/precisebank/types/genesis_test.go index bd92f3e07..1d03e3e56 100644 --- a/x/precisebank/types/genesis_test.go +++ b/x/precisebank/types/genesis_test.go @@ -5,7 +5,8 @@ import ( "github.com/stretchr/testify/require" - testconstants "github.com/cosmos/evm/testutil/constants" + evmconfig "github.com/cosmos/evm/config" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/x/precisebank/testutil" "github.com/cosmos/evm/x/precisebank/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -256,10 +257,11 @@ func TestGenesisState_TotalAmountWithRemainder(t *testing.T) { } func FuzzGenesisStateValidate_NonZeroRemainder(f *testing.F) { - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) - err := configurator.Configure() + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + err := evmtypes.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) + require.NoError(f, err) + err = evmConfig.Apply() require.NoError(f, err) f.Add(5) @@ -283,10 +285,11 @@ func FuzzGenesisStateValidate_NonZeroRemainder(f *testing.F) { } func FuzzGenesisStateValidate_ZeroRemainder(f *testing.F) { - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) - err := configurator.Configure() + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + err := evmtypes.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) + require.NoError(f, err) + err = evmConfig.Apply() require.NoError(f, err) f.Add(5) diff --git a/x/vm/genesis.go b/x/vm/genesis.go index 987214423..6821d78c8 100644 --- a/x/vm/genesis.go +++ b/x/vm/genesis.go @@ -2,7 +2,6 @@ package vm import ( "fmt" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -26,6 +25,11 @@ func InitGenesis( panic(fmt.Errorf("error setting params %s", err)) } + // Derive and set evmCoinInfo from bank metadata and VM params + if err := deriveAndSetEvmCoinInfo(ctx, k, data.Params); err != nil { + panic(fmt.Errorf("error deriving EVM coin info from genesis: %w", err)) + } + // ensure evm module account is set if addr := accountKeeper.GetModuleAddress(types.ModuleName); addr == nil { panic("the EVM module account has not been set") @@ -85,3 +89,30 @@ func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) *types.GenesisState { Params: k.GetParams(ctx), } } + +// deriveAndSetEvmCoinInfo derives the EVM coin info from bank metadata and VM params and sets it +func deriveAndSetEvmCoinInfo(ctx sdk.Context, k *keeper.Keeper, params types.Params) error { + evmDenom := params.EvmDenom + if evmDenom == "" { + return fmt.Errorf("evm_denom parameter is empty") + } + + bankKeeper := k.GetBankKeeper() + metadata, found := bankKeeper.GetDenomMetaData(ctx, evmDenom) + if !found { + return fmt.Errorf("bank metadata not found for evm_denom: %s", evmDenom) + } + + coinInfo, err := types.DeriveCoinInfoFromMetadata(metadata, evmDenom) + fmt.Println(coinInfo) + if err != nil { + return fmt.Errorf("failed to derive coin info from bank metadata: %w", err) + } + + // Set the evmCoinInfo globally + if err := types.SetEVMCoinInfo(*coinInfo); err != nil { + return fmt.Errorf("failed to set EVM coin info: %w", err) + } + + return nil +} diff --git a/x/vm/genesis_test.go b/x/vm/genesis_test.go new file mode 100644 index 000000000..f994d81bb --- /dev/null +++ b/x/vm/genesis_test.go @@ -0,0 +1 @@ +package vm_test diff --git a/x/vm/keeper/grpc_query.go b/x/vm/keeper/grpc_query.go index a748d29d6..a868cbe85 100644 --- a/x/vm/keeper/grpc_query.go +++ b/x/vm/keeper/grpc_query.go @@ -773,8 +773,6 @@ func (k Keeper) GlobalMinGasPrice(c context.Context, _ *types.QueryGlobalMinGasP // Config implements the Query/Config gRPC method func (k Keeper) Config(_ context.Context, _ *types.QueryConfigRequest) (*types.QueryConfigResponse, error) { config := types.GetChainConfig() - config.Denom = types.GetEVMCoinDenom() - config.Decimals = uint64(types.GetEVMCoinDecimals()) return &types.QueryConfigResponse{Config: config}, nil } diff --git a/x/vm/keeper/keeper.go b/x/vm/keeper/keeper.go index 774598fb2..14ca7badd 100644 --- a/x/vm/keeper/keeper.go +++ b/x/vm/keeper/keeper.go @@ -2,6 +2,9 @@ package keeper import ( "encoding/binary" + "github.com/cosmos/evm/config/eips" + "github.com/cosmos/evm/encoding" + "github.com/cosmos/evm/ethereum/eip712" "math/big" "github.com/ethereum/go-ethereum/common" @@ -24,14 +27,12 @@ import ( "cosmossdk.io/store/prefix" storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" ) // Keeper grants access to the EVM module state and implements the go-ethereum StateDB interface. type Keeper struct { - // Protobuf codec - cdc codec.BinaryCodec + encodingConfig *encoding.Config // Store key required for the EVM Prefix KVStore. It is required by: // - storing account's Storage State // - storing account's Code @@ -85,7 +86,7 @@ type Keeper struct { // NewKeeper generates new evm module keeper func NewKeeper( - cdc codec.BinaryCodec, + encodingConfig *encoding.Config, storeKey, transientKey storetypes.StoreKey, keys map[string]*storetypes.KVStoreKey, authority sdk.AccAddress, @@ -96,6 +97,7 @@ func NewKeeper( consensusKeeper types.ConsensusParamsKeeper, erc20Keeper types.Erc20Keeper, tracer string, + evmChainID uint64, ) *Keeper { // ensure evm module account is set if addr := ak.GetModuleAddress(types.ModuleName); addr == nil { @@ -110,9 +112,27 @@ func NewKeeper( bankWrapper := wrappers.NewBankWrapper(bankKeeper) feeMarketWrapper := wrappers.NewFeeMarketWrapper(fmk) + eip712.SetEncodingConfig(encodingConfig.Amino, encodingConfig.InterfaceRegistry, evmChainID) + + chainConfig := types.DefaultChainConfig( + evmChainID, + ) + evmConfig := types.NewEvmConfig(). + WithChainConfig(chainConfig). + WithExtendedEips(eips.CosmosEVMActivators) + + // NOTE: the default chain id serves as a marker denoting that we're in our "temporary app" stage of the root command. + // Is there a better way to do this? + if chainConfig.ChainId != types.DefaultEvmChainID { + err := evmConfig.Apply() + if err != nil { + panic(err) + } + } + // NOTE: we pass in the parameter space to the CommitStateDB in order to use custom denominations for the EVM operations return &Keeper{ - cdc: cdc, + encodingConfig: encodingConfig, authority: authority, accountKeeper: ak, bankWrapper: bankWrapper, @@ -132,6 +152,11 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", types.ModuleName) } +// GetBankKeeper returns the underlying bank keeper for accessing bank metadata. +func (k Keeper) GetBankKeeper() types.BankKeeper { + return k.bankWrapper +} + // ---------------------------------------------------------------------------- // Block Bloom // Required by Web3 API. @@ -439,3 +464,8 @@ func (k Keeper) GetHeaderHash(ctx sdk.Context, height uint64) common.Hash { binary.BigEndian.PutUint64(key[24:], ringIndex) return k.GetState(ctx, ethparams.HistoryStorageAddress, key) } + +// GetEncodingConfig gets the encoding config for the VM module +func (k Keeper) GetEncodingConfig() *encoding.Config { + return k.encodingConfig +} diff --git a/x/vm/keeper/params.go b/x/vm/keeper/params.go index b5892ad4d..63e486331 100644 --- a/x/vm/keeper/params.go +++ b/x/vm/keeper/params.go @@ -20,7 +20,7 @@ func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { if bz == nil { return params } - k.cdc.MustUnmarshal(bz, ¶ms) + k.encodingConfig.Codec.MustUnmarshal(bz, ¶ms) return } @@ -35,7 +35,7 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { } store := ctx.KVStore(k.storeKey) - bz, err := k.cdc.Marshal(¶ms) + bz, err := k.encodingConfig.Codec.Marshal(¶ms) if err != nil { return err } diff --git a/x/vm/module.go b/x/vm/module.go index 9c51ae43a..7adf37850 100644 --- a/x/vm/module.go +++ b/x/vm/module.go @@ -104,16 +104,20 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { // AppModule implements an application module for the evm module. type AppModule struct { AppModuleBasic - keeper *keeper.Keeper - ak types.AccountKeeper + keeper *keeper.Keeper + ak types.AccountKeeper + stakingKeeper types.StakingKeeper + bankKeeper types.BankKeeper } // NewAppModule creates a new AppModule object -func NewAppModule(k *keeper.Keeper, ak types.AccountKeeper, ac address.Codec) AppModule { +func NewAppModule(k *keeper.Keeper, ak types.AccountKeeper, stakingKeeper types.StakingKeeper, bankKeeper types.BankKeeper, ac address.Codec) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{ac: ac}, keeper: k, ak: ak, + stakingKeeper: stakingKeeper, + bankKeeper: bankKeeper, } } diff --git a/x/vm/types/chain_config.go b/x/vm/types/chain_config.go index 6a9877340..1a16a9c4d 100644 --- a/x/vm/types/chain_config.go +++ b/x/vm/types/chain_config.go @@ -10,9 +10,6 @@ import ( sdkmath "cosmossdk.io/math" ) -// testChainID represents the ChainID used for the purpose of testing. -const testChainID uint64 = 262144 - // chainConfig is the chain configuration used in the EVM to defined which // opcodes are active based on Ethereum upgrades. var chainConfig *ChainConfig @@ -59,10 +56,6 @@ func (cc ChainConfig) EthereumConfig(chainID *big.Int) *gethparams.ChainConfig { } func DefaultChainConfig(evmChainID uint64) *ChainConfig { - if evmChainID == 0 { - evmChainID = testChainID - } - homesteadBlock := sdkmath.ZeroInt() daoForkBlock := sdkmath.ZeroInt() eip150Block := sdkmath.ZeroInt() @@ -84,8 +77,6 @@ func DefaultChainConfig(evmChainID uint64) *ChainConfig { cfg := &ChainConfig{ ChainId: evmChainID, - Denom: DefaultEVMDenom, - Decimals: DefaultEVMDecimals, HomesteadBlock: &homesteadBlock, DAOForkBlock: &daoForkBlock, DAOForkSupport: true, @@ -113,20 +104,19 @@ func DefaultChainConfig(evmChainID uint64) *ChainConfig { // setChainConfig allows to set the `chainConfig` variable modifying the // default values. The method is private because it should only be called once -// in the EVMConfigurator. +// in the EvmConfig. func setChainConfig(cc *ChainConfig) error { if chainConfig != nil { - return errors.New("chainConfig already set. Cannot set again the chainConfig") + return errors.New("chainConfig already set, cannot set again") } - config := DefaultChainConfig(0) - if cc != nil { - config = cc + if cc == nil { + return errors.New("chain config is nil") } - if err := config.Validate(); err != nil { + if err := cc.Validate(); err != nil { return err } - chainConfig = config + chainConfig = cc return nil } diff --git a/x/vm/types/chain_config_test.go b/x/vm/types/chain_config_test.go index 827fcd31d..18b106a5c 100644 --- a/x/vm/types/chain_config_test.go +++ b/x/vm/types/chain_config_test.go @@ -21,7 +21,7 @@ func TestChainConfigValidate(t *testing.T) { config types.ChainConfig expError bool }{ - {"default", *types.DefaultChainConfig(0), false}, + {"default", *types.DefaultChainConfig(0, types.EvmCoinInfo{DisplayDenom: "test", Decimals: types.EighteenDecimals, ExtendedDecimals: types.EighteenDecimals}), false}, { "valid", types.ChainConfig{ diff --git a/x/vm/types/coin_info.go b/x/vm/types/coin_info.go new file mode 100644 index 000000000..804f28705 --- /dev/null +++ b/x/vm/types/coin_info.go @@ -0,0 +1,30 @@ +package types + +// EvmCoinInfo struct holds the display name and decimal precisions of the EVM denom +type EvmCoinInfo struct { + // DisplayDenom defines the display denomination shown to users + DisplayDenom string + // ExtendedDenom defines the extended EVM denom used in the EVM + ExtendedDenom string + // BaseDenom defines the base (or bond) denom used in the chain. May be the same as the ExtendedDenom. + BaseDenom string + // Decimals defines the precision/decimals for the base denomination (1-18) + Decimals Decimals +} + +// GetDenom returns the base denomination used in the chain, derived by SI prefix +func (c EvmCoinInfo) GetDenom() string { + return c.BaseDenom +} + +func (c EvmCoinInfo) GetExtendedDenom() string { + return c.ExtendedDenom +} + +func (c EvmCoinInfo) GetDecimals() Decimals { + return c.Decimals +} + +func (c EvmCoinInfo) GetDisplayDenom() string { + return c.DisplayDenom +} diff --git a/x/vm/types/coin_info_config.go b/x/vm/types/coin_info_config.go new file mode 100644 index 000000000..26fde51b3 --- /dev/null +++ b/x/vm/types/coin_info_config.go @@ -0,0 +1,86 @@ +//go:build !test +// +build !test + +package types + +import ( + "errors" + "sync" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// evmCoinInfo hold the information of the coin used in the EVM as gas token. It +// can only be set via `EvmConfig.Apply` before starting the app. +var ( + evmCoinInfo *EvmCoinInfo + evmCoinInfoOnce sync.Once +) + +// GetEVMCoinDisplayDenom returns the display denom used for the EVM coin. +func GetEVMCoinDisplayDenom() string { + return evmCoinInfo.DisplayDenom +} + +// GetEVMCoinDecimals returns the decimals used in the representation of the EVM +// coin. +func GetEVMCoinDecimals() Decimals { + return evmCoinInfo.Decimals +} + +// GetEVMCoinExtendedDecimals returns the extended decimals used in the +// representation of the EVM coin. +func GetEVMCoinExtendedDecimals() Decimals { + return 18 +} + +// GetEVMCoinDenom returns the denom used for the EVM coin. +func GetEVMCoinDenom() string { + return evmCoinInfo.GetDenom() +} + +// GetEVMCoinExtendedDenom returns the extended denom used for the EVM coin. +func GetEVMCoinExtendedDenom() string { + return evmCoinInfo.GetExtendedDenom() +} + +// SetEVMCoinInfo allows to define denom and decimals of the coin used in the EVM. +func SetEVMCoinInfo(eci EvmCoinInfo) error { + if evmCoinInfo != nil { + return errors.New("EVM coin info already set") + } + + // prevent any external pointers or references to evmCoinInfoxx + evmCoinInfoOnce.Do(func() { + setBaseDenom(eci) + evmCoinInfo = &eci + }) + + return nil +} + +// SetEVMCoinInfo allows to define denom and decimals of the coin used in the EVM. +func GetEVMCoinInfo() *EvmCoinInfo { + return evmCoinInfo +} + +// setBaseDenom registers the display denom and base denom and sets the +// base denom for the chain. The function registered different values based on +// the EvmCoinInfo to allow different configurations in mainnet and testnet. +// TODO: look into deprecating this if it is not needed +func setBaseDenom(ci EvmCoinInfo) (err error) { + // defer setting the base denom, and capture any potential error from it. + // when failing because the denom was already registered, we ignore it and set + // the corresponding denom to be base denom + defer func() { + err = sdk.SetBaseDenom(ci.GetDenom()) + }() + if err := sdk.RegisterDenom(ci.DisplayDenom, math.LegacyOneDec()); err != nil { + return err + } + + // sdk.RegisterDenom will automatically overwrite the base denom when the + // new setBaseDenom() units are lower than the current base denom's units. + return sdk.RegisterDenom(ci.GetDenom(), math.LegacyNewDecWithPrec(1, int64(ci.Decimals))) +} diff --git a/x/vm/types/coin_info_config_testing.go b/x/vm/types/coin_info_config_testing.go new file mode 100644 index 000000000..a9487897e --- /dev/null +++ b/x/vm/types/coin_info_config_testing.go @@ -0,0 +1,76 @@ +//go:build test +// +build test + +package types + +import ( + "errors" + "fmt" + "sync" +) + +// testingEvmCoinInfo hold the information of the coin used in the EVM as gas token. It +// can only be set via `EvmConfig.Apply` before starting the app. +var ( + testingEvmCoinInfo *EvmCoinInfo + testingEvmCoinInfoOnce sync.Once +) + +// GetEVMCoinDisplayDenom returns the display denom used for the EVM coin. +func GetEVMCoinDisplayDenom() string { + return testingEvmCoinInfo.DisplayDenom +} + +// GetEVMCoinDecimals returns the decimals used in the representation of the EVM +// coin. +func GetEVMCoinDecimals() Decimals { + return testingEvmCoinInfo.Decimals +} + +// GetEVMCoinExtendedDecimals returns the extended decimals used in the +// representation of the EVM coin. +func GetEVMCoinExtendedDecimals() Decimals { + return testingEvmCoinInfo.ExtendedDecimals +} + +// GetEVMCoinDenom returns the denom used for the EVM coin. +func GetEVMCoinDenom() string { + return testingEvmCoinInfo.GetDenom() +} + +// GetEVMCoinExtendedDenom returns the extended denom used for the EVM coin. +func GetEVMCoinExtendedDenom() string { + return testingEvmCoinInfo.GetExtendedDenom() +} + +// SetTestingEVMCoinInfo allows to define denom and decimals of the coin used in the EVM. +func SetTestingEVMCoinInfo(eci EvmCoinInfo) error { + if testingEvmCoinInfo != nil { + return errors.New("testing EVM coin info already set. Make sure you run the configurator's ResetTestConfig before trying to set a new evm coin info") + } + + if eci.Decimals == EighteenDecimals { + if eci.Decimals != eci.ExtendedDecimals { + return errors.New("EVM coin decimals and extended decimals must be the same for 18 decimals") + } + } + + if err := eci.Validate(); err != nil { + return fmt.Errorf("validation failed for evm coin info: %w", err) + } + + testingEvmCoinInfoOnce.Do(func() { + testingEvmCoinInfo = new(EvmCoinInfo) + testingEvmCoinInfo.DisplayDenom = eci.DisplayDenom + testingEvmCoinInfo.Decimals = eci.Decimals + testingEvmCoinInfo.ExtendedDecimals = eci.ExtendedDecimals + }) + + return nil +} + +// resetEVMCoinInfo resets to nil the testingEVMCoinInfo +func resetEVMCoinInfo() { + testingEvmCoinInfo = nil + testingEvmCoinInfoOnce = sync.Once{} +} diff --git a/x/vm/types/coin_info_test.go b/x/vm/types/coin_info_test.go new file mode 100644 index 000000000..b4e8545a5 --- /dev/null +++ b/x/vm/types/coin_info_test.go @@ -0,0 +1,179 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestEvmCoinInfoValidate(t *testing.T) { + t.Parallel() + + testCases := []struct { + name string + coinInfo EvmCoinInfo + expPass bool + errContains string + }{ + { + name: "valid 18 decimals config", + coinInfo: EvmCoinInfo{ + DisplayDenom: "test", + Decimals: EighteenDecimals, + ExtendedDecimals: EighteenDecimals, + }, + expPass: true, + }, + { + name: "valid 6 decimals config", + coinInfo: EvmCoinInfo{ + DisplayDenom: "test", + Decimals: SixDecimals, + ExtendedDecimals: EighteenDecimals, + }, + expPass: true, + }, + { + name: "valid 12 decimals config", + coinInfo: EvmCoinInfo{ + DisplayDenom: "test", + Decimals: TwelveDecimals, + ExtendedDecimals: EighteenDecimals, + }, + expPass: true, + }, + { + name: "valid 1 decimal config", + coinInfo: EvmCoinInfo{ + DisplayDenom: "test", + Decimals: OneDecimals, + ExtendedDecimals: EighteenDecimals, + }, + expPass: true, + }, + { + name: "empty display denom", + coinInfo: EvmCoinInfo{ + DisplayDenom: "", + Decimals: EighteenDecimals, + ExtendedDecimals: EighteenDecimals, + }, + expPass: false, + errContains: "invalid denom: a", + }, + { + name: "invalid denom format - starts with number", + coinInfo: EvmCoinInfo{ + DisplayDenom: "1test", + Decimals: EighteenDecimals, + ExtendedDecimals: EighteenDecimals, + }, + expPass: false, + errContains: "invalid denom", + }, + { + name: "invalid extended denom format - too short", + coinInfo: EvmCoinInfo{ + DisplayDenom: "t", + Decimals: SixDecimals, + ExtendedDecimals: EighteenDecimals, + }, + expPass: false, + errContains: "invalid denom: ut", + }, + { + name: "invalid display denom character", + coinInfo: EvmCoinInfo{ + DisplayDenom: "test@", + Decimals: EighteenDecimals, + ExtendedDecimals: EighteenDecimals, + }, + expPass: false, + errContains: "invalid denom: atest@", + }, + { + name: "zero decimals is invalid", + coinInfo: EvmCoinInfo{ + DisplayDenom: "test", + Decimals: 0, + ExtendedDecimals: EighteenDecimals, + }, + expPass: false, + errContains: "decimals validation failed", + }, + { + name: "invalid si decimals", + coinInfo: EvmCoinInfo{ + DisplayDenom: "test", + Decimals: TenDecimals, + ExtendedDecimals: TenDecimals, + }, + expPass: false, + errContains: "received unsupported decimals: 10", + }, + { + name: "decimals out of valid range", + coinInfo: EvmCoinInfo{ + DisplayDenom: "test", + Decimals: Decimals(19), + ExtendedDecimals: Decimals(19), + }, + expPass: false, + errContains: "received unsupported decimals", + }, + { + name: "18 decimals with different extended decimals", + coinInfo: EvmCoinInfo{ + DisplayDenom: "test", + Decimals: EighteenDecimals, + ExtendedDecimals: TwelveDecimals, + }, + expPass: false, + errContains: "decimals and extended decimals must be the same for 18 decimals", + }, + { + name: "valid 6 decimals with different extended decimals", + coinInfo: EvmCoinInfo{ + DisplayDenom: "test", + Decimals: SixDecimals, + ExtendedDecimals: NineDecimals, + }, + expPass: true, + }, + { + name: "display denom with valid special characters", + coinInfo: EvmCoinInfo{ + DisplayDenom: "test-coin", + Decimals: SixDecimals, + ExtendedDecimals: EighteenDecimals, + }, + expPass: true, + }, + { + name: "display denom with valid numbers", + coinInfo: EvmCoinInfo{ + DisplayDenom: "test123", + Decimals: SixDecimals, + ExtendedDecimals: EighteenDecimals, + }, + expPass: true, + }, + } + + for _, tc := range testCases { + tc := tc //nolint:copyloopvar // Needed to work correctly with concurrent tests + + t.Run(tc.name, func(t *testing.T) { + t.Parallel() + + err := tc.coinInfo.Validate() + + if tc.expPass { + require.NoError(t, err, "expected validation to pass for %s", tc.name) + } else { + require.Error(t, err, "expected validation to fail for %s", tc.name) + require.Contains(t, err.Error(), tc.errContains, "error message should contain expected text") + } + }) + } +} diff --git a/x/vm/types/config.go b/x/vm/types/config.go index 34f87ffef..6aea3f571 100644 --- a/x/vm/types/config.go +++ b/x/vm/types/config.go @@ -1,7 +1,3 @@ -// -// The config package provides a convenient way to modify x/evm params and values. -// Its primary purpose is to be used during application initialization. - //go:build !test // +build !test @@ -9,27 +5,23 @@ package types import ( "fmt" - "github.com/ethereum/go-ethereum/core/vm" geth "github.com/ethereum/go-ethereum/params" ) -// Configure applies the changes to the virtual machine configuration. -func (ec *EVMConfigurator) Configure() error { - // If Configure method has been already used in the object, return - // an error to avoid overriding configuration. - if ec.sealed { - return fmt.Errorf("error configuring EVMConfigurator: already sealed and cannot be modified") +// Apply applies the changes to the virtual machine configuration. +func (ec *EvmConfig) Apply() error { + // If Apply method has been already used in the object, return nil and no not overwrite + // This retains the previous silent behavior + if IsSealed() { + fmt.Println("already sealed") + return nil } if err := setChainConfig(ec.chainConfig); err != nil { return err } - if err := setEVMCoinInfo(ec.evmCoinInfo); err != nil { - return err - } - if err := extendDefaultExtraEIPs(ec.extendedDefaultExtraEIPs); err != nil { return err } @@ -40,12 +32,12 @@ func (ec *EVMConfigurator) Configure() error { // After applying modifiers the configurator is sealed. This way, it is not possible // to call the configure method twice. - ec.sealed = true + Seal() return nil } -func (ec *EVMConfigurator) ResetTestConfig() { +func (ec *EvmConfig) ResetTestConfig() { panic("this is only implemented with the 'test' build flag. Make sure you're running your tests using the '-tags=test' flag.") } diff --git a/x/vm/types/config_testing.go b/x/vm/types/config_testing.go index 1440ccb86..2645f0b49 100644 --- a/x/vm/types/config_testing.go +++ b/x/vm/types/config_testing.go @@ -1,7 +1,3 @@ -// -// The config package provides a convenient way to modify x/evm params and values. -// Its primary purpose is to be used during application initialization. - //go:build test // +build test @@ -19,22 +15,18 @@ import ( // opcodes are active based on Ethereum upgrades. var testChainConfig *ChainConfig -// Configure applies the changes to the virtual machine configuration. -func (ec *EVMConfigurator) Configure() error { - // If Configure method has been already used in the object, return +// Apply applies the changes to the virtual machine configuration. +func (ec *EvmConfig) Apply() error { + // If Apply method has been already used in the object, return // an error to avoid overriding configuration. - if ec.sealed { - return fmt.Errorf("error configuring EVMConfigurator: already sealed and cannot be modified") + if IsSealed() { + return fmt.Errorf("error applying EvmConfig: already sealed and cannot be modified") } if err := setTestChainConfig(ec.chainConfig); err != nil { return err } - if err := setTestingEVMCoinInfo(ec.evmCoinInfo); err != nil { - return err - } - if err := extendDefaultExtraEIPs(ec.extendedDefaultExtraEIPs); err != nil { return err } @@ -45,29 +37,38 @@ func (ec *EVMConfigurator) Configure() error { // After applying modifications, the configurator is sealed. This way, it is not possible // to call the configure method twice. - ec.sealed = true + Seal() return nil } -func (ec *EVMConfigurator) ResetTestConfig() { +func (ec *EvmConfig) ResetTestConfig() { vm.ResetActivators() resetEVMCoinInfo() testChainConfig = nil + sealed = false } func setTestChainConfig(cc *ChainConfig) error { if testChainConfig != nil { return errors.New("chainConfig already set. Cannot set again the chainConfig. Call the configurators ResetTestConfig method before configuring a new chain.") } - config := DefaultChainConfig(0) - if cc != nil { - config = cc + + // If no chain config is provided, create a default one for testing + if cc == nil { + config := DefaultChainConfig(0, EvmCoinInfo{ + DisplayDenom: "test", + Decimals: EighteenDecimals, + ExtendedDecimals: EighteenDecimals, + }) + cc = config } - if err := config.Validate(); err != nil { + + if err := cc.Validate(); err != nil { return err } - testChainConfig = config + + testChainConfig = cc return nil } diff --git a/x/vm/types/configurator.go b/x/vm/types/configurator.go deleted file mode 100644 index 44c1fd8ed..000000000 --- a/x/vm/types/configurator.go +++ /dev/null @@ -1,67 +0,0 @@ -// -// The config package provides a convenient way to modify x/evm params and values. -// Its primary purpose is to be used during application initialization. - -package types - -import ( - "fmt" - "slices" - - "github.com/ethereum/go-ethereum/core/vm" -) - -// EVMConfigurator allows to extend x/evm module configurations. The configurator modifies -// the EVM before starting the node. This means that all init genesis validations will be -// applied to each change. -type EVMConfigurator struct { - sealed bool - extendedEIPs map[int]func(*vm.JumpTable) - extendedDefaultExtraEIPs []int64 - chainConfig *ChainConfig - evmCoinInfo EvmCoinInfo -} - -// NewEVMConfigurator returns a pointer to a new EVMConfigurator object. -func NewEVMConfigurator() *EVMConfigurator { - return &EVMConfigurator{} -} - -// WithExtendedEips allows to add to the go-ethereum activators map the provided -// EIP activators. -func (ec *EVMConfigurator) WithExtendedEips(extendedEIPs map[int]func(*vm.JumpTable)) *EVMConfigurator { - ec.extendedEIPs = extendedEIPs - return ec -} - -// WithExtendedDefaultExtraEIPs update the x/evm DefaultExtraEIPs params -// by adding provided EIP numbers. -func (ec *EVMConfigurator) WithExtendedDefaultExtraEIPs(eips ...int64) *EVMConfigurator { - ec.extendedDefaultExtraEIPs = eips - return ec -} - -// WithChainConfig allows to define a custom `chainConfig` to be used in the -// EVM. -func (ec *EVMConfigurator) WithChainConfig(cc *ChainConfig) *EVMConfigurator { - ec.chainConfig = cc - return ec -} - -// WithEVMCoinInfo allows to define the denom and decimals of the token used as the -// EVM token. -func (ec *EVMConfigurator) WithEVMCoinInfo(coinInfo EvmCoinInfo) *EVMConfigurator { - ec.evmCoinInfo = coinInfo - return ec -} - -func extendDefaultExtraEIPs(extraEIPs []int64) error { - for _, eip := range extraEIPs { - if slices.Contains(DefaultExtraEIPs, eip) { - return fmt.Errorf("error configuring EVMConfigurator: EIP %d is already present in the default list: %v", eip, DefaultExtraEIPs) - } - - DefaultExtraEIPs = append(DefaultExtraEIPs, eip) - } - return nil -} diff --git a/x/vm/types/constants.go b/x/vm/types/constants.go new file mode 100644 index 000000000..a2c58db2d --- /dev/null +++ b/x/vm/types/constants.go @@ -0,0 +1,27 @@ +package types + +const ( + // DefaultGasPrice is the default gas price used for setting gas-related calculations + DefaultGasPrice = 20 + // DefaultChainID is the default chain ID + DefaultChainID = "cosmos" + // DefaultEvmChainID defines the default EVM chain ID + DefaultEvmChainID = 262144 + // DefaultDisplayDenom defines the display denom for the default EVM coin info + DefaultDisplayDenom = "atom" + // DefaultExtendedDenom defines the extended denom for the default EVM coin info + DefaultExtendedDenom = "aatom" + // DefaultBaseDenom defines the base denom for the default EVM coin info + DefaultBaseDenom = "aatom" + // DefaultDecimals defines the decimals for the default EVM coin info + DefaultDecimals = EighteenDecimals + // DefaultWevmosContractMainnet is the default WEVMOS contract address for mainnet + DefaultWevmosContractMainnet = "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517" +) + +var DefaultEvmCoinInfo = EvmCoinInfo{ + DisplayDenom: DefaultDisplayDenom, + Decimals: DefaultDecimals, + BaseDenom: DefaultBaseDenom, + ExtendedDenom: DefaultExtendedDenom, +} diff --git a/x/vm/types/denom.go b/x/vm/types/denom.go index b4d5d68dc..aefce74c7 100644 --- a/x/vm/types/denom.go +++ b/x/vm/types/denom.go @@ -1,11 +1,8 @@ -// -// The config package provides a convenient way to modify x/evm params and values. -// Its primary purpose is to be used during application initialization. - package types import ( "fmt" + "slices" "cosmossdk.io/math" ) @@ -57,9 +54,19 @@ var ConversionFactor = map[Decimals]math.Int{ type Decimals uint8 // Validate checks if the Decimals instance represent a supported decimals value -// or not. func (d Decimals) Validate() error { - if 0 < d && d <= EighteenDecimals { + validDecimals := []Decimals{ + OneDecimals, + TwoDecimals, + ThreeDecimals, + SixDecimals, + NineDecimals, + TwelveDecimals, + FifteenDecimals, + EighteenDecimals, + } + + if slices.Contains(validDecimals, d) { return nil } @@ -77,13 +84,50 @@ func (d Decimals) ConversionFactor() math.Int { return ConversionFactor[d] } -// EvmCoinInfo struct holds the name and decimals of the EVM denom. The EVM denom -// is the token used to pay fees in the EVM. -// -// TODO: move to own file? at least rename file because it's unclear to use "denom" -type EvmCoinInfo struct { - Denom string - ExtendedDenom string - DisplayDenom string - Decimals Decimals +// GetSIPrefix returns the SI prefix for the decimals +func (d Decimals) GetSIPrefix() string { + switch d { + case OneDecimals: + return "d" + case TwoDecimals: + return "c" + case ThreeDecimals: + return "m" + case SixDecimals: + return "u" + case NineDecimals: + return "n" + case TwelveDecimals: + return "p" + case FifteenDecimals: + return "f" + case EighteenDecimals: + return "a" + default: + // decimals must be one of 1, 2, 3, 6, 9, 12, 15, 18 to have a valid prefix + return "invalid" + } +} + +func DecimalsFromSIPrefix(prefix string) (Decimals, error) { + switch prefix { + case "d": + return OneDecimals, nil + case "c": + return TwoDecimals, nil + case "m": + return ThreeDecimals, nil + case "u": + return SixDecimals, nil + case "n": + return NineDecimals, nil + case "p": + return TwelveDecimals, nil + case "f": + return FifteenDecimals, nil + case "a": + return EighteenDecimals, nil + default: + return 0, fmt.Errorf("invalid SI prefix: %s", prefix) + } } diff --git a/x/vm/types/denom_config.go b/x/vm/types/denom_config.go deleted file mode 100644 index 04ff3fe8b..000000000 --- a/x/vm/types/denom_config.go +++ /dev/null @@ -1,103 +0,0 @@ -// -// The config package provides a convenient way to modify x/evm params and values. -// Its primary purpose is to be used during application initialization. - -//go:build !test -// +build !test - -package types - -import ( - "errors" - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// evmCoinInfo hold the information of the coin used in the EVM as gas token. It -// can only be set via `EVMConfigurator` before starting the app. -var evmCoinInfo *EvmCoinInfo - -// setEVMCoinDecimals allows to define the decimals used in the representation -// of the EVM coin. -func setEVMCoinDecimals(d Decimals) error { - if err := d.Validate(); err != nil { - return fmt.Errorf("setting EVM coin decimals: %w", err) - } - - evmCoinInfo.Decimals = d - return nil -} - -// setEVMCoinDenom allows to define the denom of the coin used in the EVM. -func setEVMCoinDenom(denom string) error { - if err := sdk.ValidateDenom(denom); err != nil { - return fmt.Errorf("setting EVM coin denom: %w", err) - } - evmCoinInfo.Denom = denom - return nil -} - -// setEVMCoinExtendedDenom allows to define the extended denom of the coin used in the EVM. -func setEVMCoinExtendedDenom(extendedDenom string) error { - if err := sdk.ValidateDenom(extendedDenom); err != nil { - return err - } - evmCoinInfo.ExtendedDenom = extendedDenom - return nil -} - -func setDisplayDenom(displayDenom string) error { - if err := sdk.ValidateDenom(displayDenom); err != nil { - return fmt.Errorf("setting EVM coin display denom: %w", err) - } - evmCoinInfo.DisplayDenom = displayDenom - return nil -} - -// GetEVMCoinDecimals returns the decimals used in the representation of the EVM -// coin. -func GetEVMCoinDecimals() Decimals { - return evmCoinInfo.Decimals -} - -// GetEVMCoinDenom returns the denom used for the EVM coin. -func GetEVMCoinDenom() string { - return evmCoinInfo.Denom -} - -// GetEVMCoinExtendedDenom returns the extended denom used for the EVM coin. -func GetEVMCoinExtendedDenom() string { - return evmCoinInfo.ExtendedDenom -} - -// GetEVMCoinDisplayDenom returns the display denom used for the EVM coin. -func GetEVMCoinDisplayDenom() string { - return evmCoinInfo.DisplayDenom -} - -// setEVMCoinInfo allows to define denom and decimals of the coin used in the EVM. -func setEVMCoinInfo(eci EvmCoinInfo) error { - if evmCoinInfo != nil { - return errors.New("EVM coin info already set") - } - - if eci.Decimals == EighteenDecimals { - if eci.Denom != eci.ExtendedDenom { - return errors.New("EVM coin denom and extended denom must be the same for 18 decimals") - } - } - - evmCoinInfo = new(EvmCoinInfo) - - if err := setEVMCoinDenom(eci.Denom); err != nil { - return err - } - if err := setEVMCoinExtendedDenom(eci.ExtendedDenom); err != nil { - return err - } - if err := setDisplayDenom(eci.DisplayDenom); err != nil { - return err - } - return setEVMCoinDecimals(eci.Decimals) -} diff --git a/x/vm/types/denom_config_testing.go b/x/vm/types/denom_config_testing.go deleted file mode 100644 index 66b849c0c..000000000 --- a/x/vm/types/denom_config_testing.go +++ /dev/null @@ -1,108 +0,0 @@ -// -// The config package provides a convenient way to modify x/evm params and values. -// Its primary purpose is to be used during application initialization. - -//go:build test -// +build test - -package types - -import ( - "errors" - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// testingEvmCoinInfo hold the information of the coin used in the EVM as gas token. It -// can only be set via `EVMConfigurator` before starting the app. -var testingEvmCoinInfo *EvmCoinInfo - -// setEVMCoinDecimals allows to define the decimals used in the representation -// of the EVM coin. -func setEVMCoinDecimals(d Decimals) error { - if err := d.Validate(); err != nil { - return fmt.Errorf("setting EVM coin decimals: %w", err) - } - - testingEvmCoinInfo.Decimals = d - return nil -} - -// setEVMCoinDenom allows to define the denom of the coin used in the EVM. -func setEVMCoinDenom(denom string) error { - if err := sdk.ValidateDenom(denom); err != nil { - return err - } - testingEvmCoinInfo.Denom = denom - return nil -} - -// setEVMCoinExtendedDenom allows to define the extended denom of the coin used in the EVM. -func setEVMCoinExtendedDenom(extendedDenom string) error { - if err := sdk.ValidateDenom(extendedDenom); err != nil { - return err - } - testingEvmCoinInfo.ExtendedDenom = extendedDenom - return nil -} - -func setDisplayDenom(displayDenom string) error { - if err := sdk.ValidateDenom(displayDenom); err != nil { - return fmt.Errorf("setting EVM coin display denom: %w", err) - } - testingEvmCoinInfo.DisplayDenom = displayDenom - return nil -} - -// GetEVMCoinDecimals returns the decimals used in the representation of the EVM -// coin. -func GetEVMCoinDecimals() Decimals { - return testingEvmCoinInfo.Decimals -} - -// GetEVMCoinDenom returns the denom used for the EVM coin. -func GetEVMCoinDenom() string { - return testingEvmCoinInfo.Denom -} - -// GetEVMCoinExtendedDenom returns the extended denom used for the EVM coin. -func GetEVMCoinExtendedDenom() string { - return testingEvmCoinInfo.ExtendedDenom -} - -// GetEVMCoinDisplayDenom returns the display denom used for the EVM coin. -func GetEVMCoinDisplayDenom() string { - return testingEvmCoinInfo.DisplayDenom -} - -// setTestingEVMCoinInfo allows to define denom and decimals of the coin used in the EVM. -func setTestingEVMCoinInfo(eci EvmCoinInfo) error { - if testingEvmCoinInfo != nil { - return errors.New("testing EVM coin info already set. Make sure you run the configurator's ResetTestConfig before trying to set a new evm coin info") - } - - if eci.Decimals == EighteenDecimals { - if eci.Denom != eci.ExtendedDenom { - return errors.New("EVM coin denom and extended denom must be the same for 18 decimals") - } - } - - testingEvmCoinInfo = new(EvmCoinInfo) - - if err := setEVMCoinDenom(eci.Denom); err != nil { - return err - } - if err := setEVMCoinExtendedDenom(eci.ExtendedDenom); err != nil { - return err - } - if err := setDisplayDenom(eci.DisplayDenom); err != nil { - return err - } - return setEVMCoinDecimals(eci.Decimals) -} - -// resetEVMCoinInfo resets to nil the testingEVMCoinInfo -func resetEVMCoinInfo() { - testingEvmCoinInfo = nil -} diff --git a/x/vm/types/evm.pb.go b/x/vm/types/evm.pb.go index e472085c9..48c99337a 100644 --- a/x/vm/types/evm.pb.go +++ b/x/vm/types/evm.pb.go @@ -72,6 +72,7 @@ type Params struct { // precompiled contracts that are active ActiveStaticPrecompiles []string `protobuf:"bytes,9,rep,name=active_static_precompiles,json=activeStaticPrecompiles,proto3" json:"active_static_precompiles,omitempty"` HistoryServeWindow uint64 `protobuf:"varint,10,opt,name=history_serve_window,json=historyServeWindow,proto3" json:"history_serve_window,omitempty"` + EvmChainId uint64 `protobuf:"varint,11,opt,name=evm_chain_id,json=evmChainId,proto3" json:"evm_chain_id,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -149,6 +150,13 @@ func (m *Params) GetHistoryServeWindow() uint64 { return 0 } +func (m *Params) GetEvmChainId() uint64 { + if m != nil { + return m.EvmChainId + } + return 0 +} + // AccessControl defines the permission policy of the EVM // for creating and calling contracts type AccessControl struct { @@ -312,10 +320,6 @@ type ChainConfig struct { MergeNetsplitBlock *cosmossdk_io_math.Int `protobuf:"bytes,21,opt,name=merge_netsplit_block,json=mergeNetsplitBlock,proto3,customtype=cosmossdk.io/math.Int" json:"merge_netsplit_block,omitempty" yaml:"merge_netsplit_block"` // chain_id is the id of the chain (EIP-155) ChainId uint64 `protobuf:"varint,24,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - // denom is the denomination used on the EVM - Denom string `protobuf:"bytes,25,opt,name=denom,proto3" json:"denom,omitempty"` - // decimals is the real decimal precision of the denomination used on the EVM - Decimals uint64 `protobuf:"varint,26,opt,name=decimals,proto3" json:"decimals,omitempty"` // shanghai_time: Shanghai switch time (nil = no fork, 0 = already on // shanghai) ShanghaiTime *cosmossdk_io_math.Int `protobuf:"bytes,27,opt,name=shanghai_time,json=shanghaiTime,proto3,customtype=cosmossdk.io/math.Int" json:"shanghai_time,omitempty" yaml:"shanghai_time"` @@ -376,20 +380,6 @@ func (m *ChainConfig) GetChainId() uint64 { return 0 } -func (m *ChainConfig) GetDenom() string { - if m != nil { - return m.Denom - } - return "" -} - -func (m *ChainConfig) GetDecimals() uint64 { - if m != nil { - return m.Decimals - } - return 0 -} - // State represents a single Storage key value pair item. type State struct { // key is the stored key @@ -951,131 +941,131 @@ func init() { proto.RegisterFile("cosmos/evm/vm/v1/evm.proto", fileDescriptor_d1 var fileDescriptor_d1129b8db63d55c7 = []byte{ // 2007 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x58, 0x4d, 0x6f, 0x1b, 0xc7, - 0x19, 0x16, 0xc5, 0x95, 0xb4, 0x1c, 0x52, 0xd2, 0x7a, 0x44, 0xcb, 0x34, 0xed, 0x68, 0xd5, 0x6d, - 0x0f, 0xaa, 0x91, 0x4a, 0x96, 0x1c, 0xb5, 0x86, 0xd3, 0x0f, 0x88, 0x32, 0xd3, 0x4a, 0xb5, 0x1d, + 0x19, 0x16, 0xc5, 0x95, 0xb4, 0x1c, 0x52, 0xd2, 0x7a, 0x44, 0xcb, 0x34, 0xe5, 0x68, 0xd9, 0x6d, + 0x0f, 0xaa, 0x91, 0x4a, 0x96, 0x1c, 0xb5, 0x86, 0xd3, 0x0f, 0x88, 0x32, 0xd3, 0x4a, 0x95, 0x1d, 0x61, 0xa8, 0xc6, 0x48, 0xd1, 0x62, 0x31, 0xdc, 0x1d, 0x2f, 0x37, 0xda, 0xdd, 0x21, 0x66, 0x96, - 0xb4, 0xd8, 0x3f, 0xd0, 0xc0, 0xa7, 0xf4, 0x07, 0x18, 0x08, 0xd0, 0x4b, 0x8e, 0x39, 0xf4, 0x07, - 0xf4, 0x98, 0x63, 0x8e, 0x45, 0x81, 0x2e, 0x0a, 0xfa, 0x10, 0x40, 0x47, 0xfd, 0x82, 0x62, 0x3e, + 0xb4, 0xd4, 0x63, 0x2f, 0x0d, 0x7c, 0x4a, 0x7f, 0x80, 0x81, 0x00, 0xbd, 0xf4, 0x98, 0x9f, 0xd0, + 0x63, 0x8e, 0x39, 0x15, 0x45, 0x81, 0x2e, 0x0a, 0xf9, 0x10, 0x40, 0x47, 0xfd, 0x82, 0x62, 0x3e, 0xf8, 0x29, 0x85, 0x55, 0x00, 0xc1, 0x9e, 0xe7, 0xfd, 0x78, 0x9e, 0xf9, 0x78, 0x77, 0xe7, 0x5d, - 0x82, 0xaa, 0x47, 0x79, 0x4c, 0xf9, 0x0e, 0xe9, 0xc6, 0x3b, 0xe2, 0x6f, 0x57, 0x8c, 0xb6, 0xdb, - 0x8c, 0xa6, 0x14, 0x5a, 0xca, 0xb7, 0x2d, 0x2c, 0xe2, 0x6f, 0xb7, 0x7a, 0x0b, 0xc7, 0x61, 0x42, - 0x77, 0xe4, 0xbf, 0x2a, 0xa8, 0x5a, 0x0e, 0x68, 0x40, 0xe5, 0x70, 0x47, 0x8c, 0x94, 0xd5, 0xf9, - 0x47, 0x1e, 0x2c, 0x9e, 0x60, 0x86, 0x63, 0x0e, 0x77, 0x41, 0x81, 0x74, 0x63, 0xd7, 0x27, 0x09, - 0x8d, 0x2b, 0xb9, 0xcd, 0xdc, 0x56, 0xa1, 0x56, 0xbe, 0xcc, 0x6c, 0xab, 0x87, 0xe3, 0xe8, 0x89, - 0x33, 0x74, 0x39, 0xc8, 0x24, 0xdd, 0xf8, 0xa9, 0x18, 0xc2, 0x03, 0x00, 0xc8, 0x79, 0xca, 0xb0, - 0x4b, 0xc2, 0x36, 0xaf, 0x18, 0x9b, 0xf9, 0xad, 0x7c, 0xcd, 0xe9, 0x67, 0x76, 0xa1, 0x2e, 0xac, - 0xf5, 0xa3, 0x13, 0x7e, 0x99, 0xd9, 0xb7, 0x34, 0xc1, 0x30, 0xd0, 0x41, 0x05, 0x09, 0xea, 0x61, - 0x9b, 0xc3, 0x3d, 0x50, 0x12, 0xd4, 0x5e, 0x0b, 0x27, 0x09, 0x89, 0x78, 0x65, 0x69, 0x33, 0xbf, - 0x55, 0xa8, 0xad, 0xf6, 0x33, 0xbb, 0x58, 0xff, 0xe4, 0xf9, 0xa1, 0x36, 0xa3, 0x22, 0xe9, 0xc6, - 0x03, 0x00, 0xff, 0x0c, 0x56, 0xb0, 0xe7, 0x11, 0xce, 0x5d, 0x8f, 0x26, 0x29, 0xa3, 0x51, 0xc5, - 0xdc, 0xcc, 0x6d, 0x15, 0xf7, 0xec, 0xed, 0xe9, 0x8d, 0xd8, 0x3e, 0x90, 0x71, 0x87, 0x2a, 0xac, - 0x76, 0xfb, 0x9b, 0xcc, 0x9e, 0xeb, 0x67, 0xf6, 0xf2, 0x84, 0x19, 0x2d, 0xe3, 0x71, 0x08, 0x9f, - 0x80, 0xbb, 0xd8, 0x4b, 0xc3, 0x2e, 0x71, 0x79, 0x8a, 0xd3, 0xd0, 0x73, 0xdb, 0x8c, 0x78, 0x34, - 0x6e, 0x87, 0x11, 0xe1, 0x95, 0x82, 0x98, 0x1f, 0xba, 0xa3, 0x02, 0x1a, 0xd2, 0x7f, 0x32, 0x72, - 0xc3, 0x87, 0xa0, 0xdc, 0x0a, 0x79, 0x4a, 0x59, 0xcf, 0xe5, 0x84, 0x75, 0x89, 0xfb, 0x3a, 0x4c, - 0x7c, 0xfa, 0xba, 0x02, 0x36, 0x73, 0x5b, 0x06, 0x82, 0xda, 0xd7, 0x10, 0xae, 0x97, 0xd2, 0xf3, - 0xe4, 0xde, 0x9b, 0xef, 0xbe, 0x7e, 0xb0, 0x3e, 0x76, 0xba, 0xe7, 0xe2, 0x7c, 0xd5, 0x99, 0x1c, - 0x1b, 0xe6, 0xbc, 0x95, 0x3f, 0x36, 0xcc, 0xbc, 0x65, 0x1c, 0x1b, 0xe6, 0x82, 0xb5, 0x78, 0x6c, - 0x98, 0x8b, 0xd6, 0x92, 0xf3, 0xb7, 0x1c, 0x98, 0x5c, 0x03, 0x3c, 0x00, 0x8b, 0x1e, 0x23, 0x38, - 0x25, 0xf2, 0xe8, 0x8a, 0x7b, 0x3f, 0xfe, 0x3f, 0x7b, 0x71, 0xda, 0x6b, 0x93, 0x9a, 0x21, 0xf6, - 0x03, 0xe9, 0x44, 0xf8, 0x2b, 0x60, 0x78, 0x38, 0x8a, 0x2a, 0xf3, 0x3f, 0x94, 0x40, 0xa6, 0x39, - 0xff, 0xc9, 0x81, 0x5b, 0x57, 0x22, 0xa0, 0x07, 0x8a, 0xfa, 0xac, 0xd2, 0x5e, 0x5b, 0x4d, 0x6e, - 0x65, 0xef, 0xfe, 0xf7, 0x71, 0x4b, 0xd2, 0x9f, 0xf4, 0x33, 0x1b, 0x8c, 0xf0, 0x65, 0x66, 0x43, - 0x55, 0x42, 0x63, 0x44, 0x0e, 0x02, 0x78, 0x18, 0x01, 0x3d, 0xb0, 0x36, 0x59, 0x10, 0x6e, 0x14, - 0xf2, 0xb4, 0x32, 0x2f, 0x6b, 0xe9, 0x51, 0x3f, 0xb3, 0x27, 0x27, 0xf6, 0x2c, 0xe4, 0xe9, 0x65, - 0x66, 0x57, 0x27, 0x58, 0xc7, 0x33, 0x1d, 0x74, 0x0b, 0x4f, 0x27, 0x38, 0x5f, 0x59, 0xa0, 0x78, - 0xd8, 0xc2, 0x61, 0x72, 0x48, 0x93, 0x57, 0x61, 0x00, 0xff, 0x04, 0x56, 0x5b, 0x34, 0x26, 0x3c, - 0x25, 0xd8, 0x77, 0x9b, 0x11, 0xf5, 0xce, 0xf4, 0x53, 0xf3, 0xe8, 0xdf, 0x99, 0x7d, 0x5b, 0x2d, - 0x90, 0xfb, 0x67, 0xdb, 0x21, 0xdd, 0x89, 0x71, 0xda, 0xda, 0x3e, 0x4a, 0x84, 0xe8, 0xba, 0x12, - 0x9d, 0xca, 0x74, 0xd0, 0xca, 0xd0, 0x52, 0x13, 0x06, 0xd8, 0x02, 0x2b, 0x3e, 0xa6, 0xee, 0x2b, - 0xca, 0xce, 0x34, 0xf9, 0xbc, 0x24, 0xaf, 0x7d, 0x2f, 0x79, 0x3f, 0xb3, 0x4b, 0x4f, 0x0f, 0x3e, - 0xfe, 0x88, 0xb2, 0x33, 0x49, 0x71, 0x99, 0xd9, 0xb7, 0x95, 0xd8, 0x24, 0x91, 0x83, 0x4a, 0x3e, - 0xa6, 0xc3, 0x30, 0xf8, 0x12, 0x58, 0xc3, 0x00, 0xde, 0x69, 0xb7, 0x29, 0x4b, 0x2b, 0xf9, 0xcd, - 0xdc, 0x96, 0x59, 0xfb, 0x59, 0x3f, 0xb3, 0x57, 0x34, 0x65, 0x43, 0x79, 0x2e, 0x33, 0xfb, 0xce, - 0x14, 0xa9, 0xce, 0x71, 0xd0, 0x8a, 0xa6, 0xd5, 0xa1, 0xb0, 0x09, 0x4a, 0x24, 0x6c, 0xef, 0xee, - 0x3f, 0xd4, 0x0b, 0x30, 0xe4, 0x02, 0x7e, 0x33, 0x6b, 0x01, 0xc5, 0xfa, 0xd1, 0xc9, 0xee, 0xfe, - 0xc3, 0xc1, 0xfc, 0xd7, 0xf4, 0xab, 0x63, 0x8c, 0xc5, 0x41, 0x45, 0x05, 0xd5, 0xe4, 0x07, 0x1a, - 0xfb, 0x5a, 0x63, 0xf1, 0xa6, 0x1a, 0xfb, 0xd7, 0x69, 0xec, 0x4f, 0x6a, 0xec, 0x4f, 0x6a, 0x3c, - 0xd6, 0x1a, 0x4b, 0x37, 0xd5, 0x78, 0x7c, 0x9d, 0xc6, 0xe3, 0x49, 0x0d, 0x15, 0x23, 0x8a, 0xa9, - 0xd9, 0xfb, 0x0b, 0x4e, 0xd2, 0xb0, 0x13, 0x6b, 0x19, 0xf3, 0xc6, 0xc5, 0x34, 0x95, 0xe9, 0xa0, - 0x95, 0xa1, 0x45, 0xb1, 0x9f, 0x81, 0xb2, 0x47, 0x13, 0x9e, 0x0a, 0x5b, 0x42, 0xdb, 0x11, 0xd1, - 0x12, 0x05, 0x29, 0xf1, 0x78, 0x96, 0xc4, 0x3d, 0x25, 0x71, 0x5d, 0xba, 0x83, 0xd6, 0x26, 0xcd, - 0x4a, 0xcc, 0x05, 0x56, 0x9b, 0xa4, 0x84, 0xf1, 0x66, 0x87, 0x05, 0x5a, 0x08, 0x48, 0xa1, 0x0f, - 0x66, 0x09, 0xe9, 0xb2, 0x9a, 0x4e, 0x75, 0xd0, 0xea, 0xc8, 0xa4, 0x04, 0x3e, 0x05, 0x2b, 0xa1, - 0x50, 0x6d, 0x76, 0x22, 0x4d, 0x5f, 0x94, 0xf4, 0x7b, 0xb3, 0xe8, 0xf5, 0xa3, 0x30, 0x99, 0xe8, - 0xa0, 0xe5, 0x81, 0x41, 0x51, 0xfb, 0x00, 0xc6, 0x9d, 0x90, 0xb9, 0x41, 0x84, 0xbd, 0x90, 0x30, - 0x4d, 0x5f, 0x92, 0xf4, 0x3f, 0x9f, 0x45, 0x7f, 0x57, 0xd1, 0x5f, 0x4d, 0x76, 0x90, 0x25, 0x8c, - 0xbf, 0x55, 0x36, 0xa5, 0xd2, 0x00, 0xa5, 0x26, 0x61, 0x51, 0x98, 0x68, 0xfe, 0x65, 0xc9, 0xff, - 0x70, 0x16, 0xbf, 0xae, 0xa0, 0xf1, 0x34, 0x07, 0x15, 0x15, 0x1c, 0x92, 0x46, 0x34, 0xf1, 0xe9, - 0x80, 0xf4, 0xd6, 0x8d, 0x49, 0xc7, 0xd3, 0x1c, 0x54, 0x54, 0x50, 0x91, 0x06, 0x60, 0x0d, 0x33, - 0x46, 0x5f, 0x4f, 0x6d, 0x08, 0x94, 0xdc, 0xbf, 0x98, 0xc5, 0x3d, 0x78, 0xb9, 0x5e, 0xcd, 0x16, - 0x2f, 0x57, 0x61, 0x9d, 0xd8, 0x12, 0x1f, 0xc0, 0x80, 0xe1, 0xde, 0x94, 0x4e, 0xf9, 0xc6, 0x1b, - 0x7f, 0x35, 0xd9, 0x41, 0x96, 0x30, 0x4e, 0xa8, 0x7c, 0x06, 0xca, 0x31, 0x61, 0x01, 0x71, 0x13, - 0x92, 0xf2, 0x76, 0x14, 0xa6, 0x5a, 0xe7, 0xf6, 0x8d, 0x9f, 0x83, 0xeb, 0xd2, 0x1d, 0x04, 0xa5, - 0xf9, 0x85, 0xb6, 0x2a, 0xad, 0xbb, 0xc0, 0xf4, 0xc4, 0x6d, 0xe1, 0x86, 0x7e, 0xa5, 0x22, 0x6f, - 0xff, 0x25, 0x89, 0x8f, 0x7c, 0x58, 0x06, 0x0b, 0xaa, 0xcb, 0xba, 0x2b, 0x74, 0x91, 0x02, 0xb0, - 0x0a, 0x4c, 0x9f, 0x78, 0x61, 0x8c, 0x23, 0x5e, 0xa9, 0xca, 0x84, 0x21, 0x86, 0x9f, 0x80, 0x65, - 0xde, 0xc2, 0x49, 0xd0, 0xc2, 0xa1, 0x9b, 0x86, 0x31, 0xa9, 0xdc, 0x93, 0x33, 0xde, 0x9d, 0x35, - 0xe3, 0xb2, 0x9a, 0xf1, 0x44, 0x9e, 0x83, 0x4a, 0x03, 0x7c, 0x1a, 0xc6, 0x04, 0x9e, 0x80, 0xa2, - 0x87, 0x13, 0xaf, 0x93, 0x28, 0xd6, 0xfb, 0x92, 0x75, 0x67, 0x16, 0xab, 0xbe, 0x8a, 0xc7, 0xb2, - 0x1c, 0x04, 0x14, 0x1a, 0x30, 0xb6, 0x19, 0x0e, 0x3a, 0x44, 0x31, 0xbe, 0x77, 0x63, 0xc6, 0xb1, - 0x2c, 0x07, 0x01, 0x85, 0x06, 0x8c, 0x5d, 0xc2, 0xce, 0x22, 0xcd, 0xb8, 0x71, 0x63, 0xc6, 0xb1, - 0x2c, 0x07, 0x01, 0x85, 0x24, 0xe3, 0x73, 0x00, 0x28, 0xc7, 0x67, 0x58, 0x11, 0xda, 0x92, 0x70, - 0x7b, 0x16, 0xa1, 0x6e, 0x61, 0x47, 0x49, 0x0e, 0x2a, 0x48, 0x20, 0xe8, 0x86, 0x8d, 0xd9, 0xba, - 0x75, 0xe7, 0xd8, 0x30, 0xef, 0x58, 0x15, 0x67, 0x07, 0x2c, 0x88, 0xd6, 0x90, 0x40, 0x0b, 0xe4, - 0xcf, 0x48, 0x4f, 0xf5, 0x05, 0x48, 0x0c, 0xc5, 0xd9, 0x77, 0x71, 0xd4, 0x21, 0xea, 0x3a, 0x47, - 0x0a, 0x38, 0x27, 0x60, 0xf5, 0x94, 0xe1, 0x84, 0x8b, 0xb6, 0x92, 0x26, 0xcf, 0x68, 0xc0, 0x21, - 0x04, 0x46, 0x0b, 0xf3, 0x96, 0xce, 0x95, 0x63, 0xf8, 0x53, 0x60, 0x44, 0x34, 0xe0, 0xb2, 0xb1, - 0x29, 0xee, 0xdd, 0xbe, 0xda, 0x45, 0x3d, 0xa3, 0x01, 0x92, 0x21, 0xce, 0x5f, 0xf3, 0x20, 0xff, - 0x8c, 0x06, 0xb0, 0x02, 0x96, 0xb0, 0xef, 0x33, 0xc2, 0xb9, 0x66, 0x1a, 0x40, 0xb8, 0x0e, 0x16, - 0x53, 0xda, 0x0e, 0x3d, 0x45, 0x57, 0x40, 0x1a, 0x09, 0x61, 0x1f, 0xa7, 0x58, 0xf6, 0x00, 0x25, - 0x24, 0xc7, 0xa2, 0x4b, 0x97, 0xa5, 0xee, 0x26, 0x9d, 0xb8, 0x49, 0x98, 0xbc, 0xca, 0x8d, 0xda, - 0xea, 0x45, 0x66, 0x17, 0xa5, 0xfd, 0x85, 0x34, 0xa3, 0x71, 0x00, 0xdf, 0x07, 0x4b, 0xe9, 0xb9, - 0x2b, 0xd7, 0xb0, 0x20, 0xb7, 0x78, 0xed, 0x22, 0xb3, 0x57, 0xd3, 0xd1, 0x32, 0x7f, 0x87, 0x79, - 0x0b, 0x2d, 0xa6, 0xe7, 0xe2, 0x7f, 0xb8, 0x03, 0xcc, 0xf4, 0xdc, 0x0d, 0x13, 0x9f, 0x9c, 0xcb, - 0x4b, 0xdc, 0xa8, 0x95, 0x2f, 0x32, 0xdb, 0x1a, 0x0b, 0x3f, 0x12, 0x3e, 0xb4, 0x94, 0x9e, 0xcb, - 0x01, 0x7c, 0x1f, 0x00, 0x35, 0x25, 0xa9, 0xa0, 0xee, 0xe4, 0xe5, 0x8b, 0xcc, 0x2e, 0x48, 0xab, - 0xe4, 0x1e, 0x0d, 0xa1, 0x03, 0x16, 0x14, 0xb7, 0x29, 0xb9, 0x4b, 0x17, 0x99, 0x6d, 0x46, 0x34, - 0x50, 0x9c, 0xca, 0x25, 0xb6, 0x8a, 0x91, 0x98, 0x76, 0x89, 0x2f, 0x2f, 0x46, 0x13, 0x0d, 0x20, - 0xfc, 0x10, 0xac, 0x2a, 0x2d, 0x71, 0xf6, 0x3c, 0xc5, 0x71, 0x5b, 0x35, 0xf4, 0x35, 0x78, 0x91, - 0xd9, 0x2b, 0xd2, 0x75, 0x3a, 0xf0, 0xa0, 0x29, 0xec, 0x7c, 0x31, 0x0f, 0xcc, 0xd3, 0x73, 0x44, - 0x78, 0x27, 0x4a, 0xe1, 0x47, 0xc0, 0x92, 0x8d, 0x26, 0xf6, 0x52, 0x77, 0xe2, 0x5c, 0x6a, 0xf7, - 0x46, 0x77, 0xe0, 0x74, 0x84, 0x83, 0x56, 0x07, 0xa6, 0x03, 0x7d, 0x78, 0x65, 0xb0, 0xd0, 0x8c, - 0x28, 0x8d, 0x65, 0x19, 0x95, 0x90, 0x02, 0xf0, 0xa5, 0xdc, 0x72, 0x59, 0x22, 0x79, 0xd9, 0xc4, - 0xff, 0xe8, 0x6a, 0x89, 0x4c, 0xd5, 0x59, 0xed, 0x9e, 0x68, 0xe1, 0x2f, 0x33, 0x7b, 0x45, 0x69, - 0xeb, 0x7c, 0xe7, 0xab, 0xef, 0xbe, 0x7e, 0x90, 0x13, 0xa7, 0x23, 0x8b, 0xd1, 0x02, 0x79, 0x46, - 0x52, 0x79, 0xec, 0x25, 0x24, 0x86, 0xe2, 0x6d, 0xc5, 0x48, 0x97, 0xb0, 0x94, 0xf8, 0xf2, 0x78, - 0x4d, 0x34, 0xc4, 0xe2, 0xd5, 0x17, 0x60, 0xee, 0x76, 0x38, 0xf1, 0xd5, 0x59, 0xa2, 0xa5, 0x00, - 0xf3, 0x3f, 0x70, 0xe2, 0x3f, 0x31, 0x3e, 0xff, 0xd2, 0x9e, 0x73, 0x30, 0x28, 0xea, 0xfe, 0xbe, - 0xd3, 0x8e, 0xc8, 0x8c, 0x1a, 0xdd, 0x03, 0x25, 0xf1, 0xc1, 0x84, 0x03, 0xe2, 0x9e, 0x91, 0x9e, - 0xae, 0x54, 0x55, 0x77, 0xda, 0xfe, 0x7b, 0xd2, 0xe3, 0x68, 0x1c, 0x68, 0x89, 0x2f, 0x0d, 0x50, - 0x3c, 0x65, 0xd8, 0x23, 0xba, 0x5b, 0x17, 0xd5, 0x2e, 0x20, 0xd3, 0x12, 0x1a, 0x09, 0x6d, 0x71, - 0xa8, 0xb4, 0x93, 0xea, 0x27, 0x72, 0x00, 0x45, 0x06, 0x23, 0xe4, 0x9c, 0x78, 0x72, 0x2f, 0x0d, - 0xa4, 0x11, 0xdc, 0x07, 0xcb, 0x7e, 0xc8, 0x71, 0x33, 0x92, 0xdf, 0x87, 0xde, 0x99, 0x5a, 0x7e, - 0xcd, 0xba, 0xc8, 0xec, 0x92, 0x76, 0x34, 0x84, 0x1d, 0x4d, 0x20, 0x51, 0x43, 0xa3, 0x34, 0x39, - 0x5b, 0xb9, 0x37, 0xa6, 0xaa, 0xa1, 0x61, 0xa8, 0xf4, 0xa0, 0x29, 0xac, 0x6e, 0x8c, 0x66, 0x27, - 0x90, 0xe5, 0x6b, 0x22, 0x05, 0x84, 0x35, 0x0a, 0xe3, 0x30, 0x95, 0xe5, 0xba, 0x80, 0x14, 0x80, - 0x1f, 0x82, 0x02, 0xed, 0x12, 0xc6, 0x42, 0x9f, 0x70, 0x59, 0xa6, 0xc5, 0xbd, 0xf7, 0xae, 0x96, - 0xc1, 0xd8, 0x97, 0x0c, 0x1a, 0xc5, 0x8b, 0xc5, 0x91, 0x44, 0x4e, 0x32, 0x26, 0x31, 0x65, 0x3d, - 0xd9, 0x5a, 0xe9, 0xc5, 0x29, 0xc7, 0x73, 0x69, 0x47, 0x13, 0x08, 0xd6, 0x00, 0xd4, 0x69, 0x8c, - 0xa4, 0x1d, 0x96, 0xb8, 0xf2, 0x0d, 0x52, 0x92, 0xb9, 0xf2, 0x39, 0x56, 0x5e, 0x24, 0x9d, 0x4f, - 0x71, 0x8a, 0xd1, 0x15, 0x0b, 0xfc, 0x35, 0x80, 0xea, 0x4c, 0xdc, 0xcf, 0x38, 0x4d, 0xc4, 0xf7, - 0xd8, 0xab, 0x30, 0xd0, 0xbd, 0x91, 0xd4, 0x57, 0x5e, 0x3d, 0x67, 0x4b, 0xa1, 0x63, 0x4e, 0xf5, - 0x2a, 0x8e, 0x0d, 0xd3, 0xb0, 0x16, 0x8e, 0x0d, 0x73, 0xc9, 0x32, 0x87, 0xfb, 0xa7, 0x57, 0x81, - 0xd6, 0x06, 0x78, 0x6c, 0x7a, 0xce, 0x0b, 0x00, 0x4e, 0x18, 0x09, 0x45, 0x07, 0x1b, 0x45, 0xe2, - 0xb5, 0x97, 0xe0, 0x98, 0x0c, 0xde, 0xb7, 0x62, 0x3c, 0x5e, 0x98, 0xf3, 0x93, 0x85, 0x09, 0x81, - 0xe1, 0x51, 0x9f, 0xc8, 0xd2, 0x28, 0x20, 0x39, 0x7e, 0xf0, 0xcf, 0x1c, 0x18, 0xfb, 0x6c, 0x85, - 0xbf, 0x04, 0xd5, 0x83, 0xc3, 0xc3, 0x7a, 0xa3, 0xe1, 0x9e, 0x7e, 0x7a, 0x52, 0x77, 0x4f, 0xea, - 0xe8, 0xf9, 0x51, 0xa3, 0x71, 0xf4, 0xf1, 0x8b, 0x67, 0xf5, 0x46, 0xc3, 0x9a, 0xab, 0xde, 0x7f, - 0xf3, 0x76, 0xb3, 0x32, 0x8a, 0x3f, 0x21, 0x2c, 0x0e, 0x39, 0x0f, 0x69, 0x12, 0x09, 0x81, 0x0f, - 0xc0, 0xfa, 0x78, 0x36, 0xaa, 0x37, 0x4e, 0xd1, 0xd1, 0xe1, 0x69, 0xfd, 0xa9, 0x95, 0xab, 0x56, - 0xde, 0xbc, 0xdd, 0x2c, 0x8f, 0x32, 0x11, 0xe1, 0x29, 0x0b, 0x3d, 0xf1, 0xe4, 0x3d, 0x06, 0x95, - 0xeb, 0x35, 0xeb, 0x4f, 0xad, 0xf9, 0x6a, 0xf5, 0xcd, 0xdb, 0xcd, 0xf5, 0xeb, 0x14, 0x89, 0x5f, - 0x35, 0x3e, 0xff, 0xfb, 0xc6, 0x5c, 0xed, 0xc9, 0x37, 0xfd, 0x8d, 0xdc, 0xb7, 0xfd, 0x8d, 0xdc, - 0x7f, 0xfb, 0x1b, 0xb9, 0x2f, 0xde, 0x6d, 0xcc, 0x7d, 0xfb, 0x6e, 0x63, 0xee, 0x5f, 0xef, 0x36, - 0xe6, 0xfe, 0xb8, 0x19, 0x84, 0x69, 0xab, 0xd3, 0xdc, 0xf6, 0x68, 0xbc, 0x33, 0xfd, 0x63, 0x85, - 0xf8, 0x20, 0xe7, 0xcd, 0x45, 0xf9, 0x8b, 0xd2, 0xa3, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0xc6, - 0x17, 0xe6, 0x54, 0xaa, 0x12, 0x00, 0x00, + 0x82, 0xaa, 0x47, 0x79, 0x4c, 0xf9, 0x16, 0xe9, 0xc5, 0x5b, 0xe2, 0x6f, 0x5b, 0x8c, 0x36, 0x3b, + 0x8c, 0xa6, 0x14, 0x5a, 0xca, 0xb7, 0x29, 0x2c, 0xe2, 0x6f, 0xbb, 0x7a, 0x07, 0xc7, 0x61, 0x42, + 0xb7, 0xe4, 0xbf, 0x2a, 0xa8, 0x5a, 0x0e, 0x68, 0x40, 0xe5, 0x70, 0x4b, 0x8c, 0x94, 0xd5, 0xf9, + 0x67, 0x1e, 0xcc, 0x1f, 0x63, 0x86, 0x63, 0x0e, 0xb7, 0x41, 0x81, 0xf4, 0x62, 0xd7, 0x27, 0x09, + 0x8d, 0x2b, 0xb9, 0x5a, 0x6e, 0xa3, 0x50, 0x2f, 0x5f, 0x65, 0xb6, 0x75, 0x8e, 0xe3, 0xe8, 0xa9, + 0x33, 0x70, 0x39, 0xc8, 0x24, 0xbd, 0xf8, 0x99, 0x18, 0xc2, 0x3d, 0x00, 0xc8, 0x59, 0xca, 0xb0, + 0x4b, 0xc2, 0x0e, 0xaf, 0x18, 0xb5, 0xfc, 0x46, 0xbe, 0xee, 0x5c, 0x64, 0x76, 0xa1, 0x21, 0xac, + 0x8d, 0x83, 0x63, 0x7e, 0x95, 0xd9, 0x77, 0x34, 0xc1, 0x20, 0xd0, 0x41, 0x05, 0x09, 0x1a, 0x61, + 0x87, 0xc3, 0x1d, 0x50, 0x12, 0xd4, 0x5e, 0x1b, 0x27, 0x09, 0x89, 0x78, 0x65, 0xa1, 0x96, 0xdf, + 0x28, 0xd4, 0x97, 0x2f, 0x32, 0xbb, 0xd8, 0xf8, 0xe4, 0xf9, 0xbe, 0x36, 0xa3, 0x22, 0xe9, 0xc5, + 0x7d, 0x00, 0xff, 0x08, 0x96, 0xb0, 0xe7, 0x11, 0xce, 0x5d, 0x8f, 0x26, 0x29, 0xa3, 0x51, 0xc5, + 0xac, 0xe5, 0x36, 0x8a, 0x3b, 0xf6, 0xe6, 0xe4, 0x46, 0x6c, 0xee, 0xc9, 0xb8, 0x7d, 0x15, 0x56, + 0xbf, 0xfb, 0x75, 0x66, 0xcf, 0x5c, 0x64, 0xf6, 0xe2, 0x98, 0x19, 0x2d, 0xe2, 0x51, 0x08, 0x9f, + 0x82, 0xfb, 0xd8, 0x4b, 0xc3, 0x1e, 0x71, 0x79, 0x8a, 0xd3, 0xd0, 0x73, 0x3b, 0x8c, 0x78, 0x34, + 0xee, 0x84, 0x11, 0xe1, 0x95, 0x82, 0x98, 0x1f, 0xba, 0xa7, 0x02, 0x9a, 0xd2, 0x7f, 0x3c, 0x74, + 0xc3, 0x47, 0xa0, 0xdc, 0x0e, 0x79, 0x4a, 0xd9, 0xb9, 0xcb, 0x09, 0xeb, 0x11, 0xf7, 0x75, 0x98, + 0xf8, 0xf4, 0x75, 0x05, 0xd4, 0x72, 0x1b, 0x06, 0x82, 0xda, 0xd7, 0x14, 0xae, 0x97, 0xd2, 0x03, + 0x6b, 0x83, 0x0d, 0x08, 0x13, 0x37, 0xf4, 0x2b, 0x45, 0x19, 0x09, 0xd4, 0x7a, 0xc3, 0xe4, 0xc0, + 0x7f, 0xba, 0xf6, 0xe6, 0xdb, 0xaf, 0x1e, 0xae, 0x8e, 0x9c, 0xff, 0x99, 0xa8, 0x00, 0x75, 0x6a, + 0x87, 0x86, 0x39, 0x6b, 0xe5, 0x0f, 0x0d, 0x33, 0x6f, 0x19, 0x87, 0x86, 0x39, 0x67, 0xcd, 0x1f, + 0x1a, 0xe6, 0xbc, 0xb5, 0xe0, 0xfc, 0x35, 0x07, 0xc6, 0x57, 0x09, 0xf7, 0xc0, 0xbc, 0xc7, 0x08, + 0x4e, 0x89, 0x3c, 0xdc, 0xe2, 0xce, 0x0f, 0xff, 0xcf, 0x6e, 0x9d, 0x9c, 0x77, 0x48, 0xdd, 0x10, + 0x3b, 0x86, 0x74, 0x22, 0xfc, 0x05, 0x30, 0x3c, 0x1c, 0x45, 0x95, 0xd9, 0xef, 0x4b, 0x20, 0xd3, + 0x9c, 0xff, 0xe4, 0xc0, 0x9d, 0x6b, 0x11, 0xd0, 0x03, 0x45, 0x7d, 0x9a, 0xe9, 0x79, 0x47, 0x4d, + 0x6e, 0x69, 0xe7, 0xc1, 0x77, 0x71, 0x4b, 0xd2, 0x1f, 0x5d, 0x64, 0x36, 0x18, 0xe2, 0xab, 0xcc, + 0x86, 0xaa, 0xc8, 0x46, 0x88, 0x1c, 0x04, 0xf0, 0x20, 0x02, 0x7a, 0x60, 0x65, 0xbc, 0x64, 0xdc, + 0x28, 0xe4, 0x69, 0x65, 0x56, 0x56, 0xdb, 0xe3, 0x8b, 0xcc, 0x1e, 0x9f, 0xd8, 0x51, 0xc8, 0xd3, + 0xab, 0xcc, 0xae, 0x8e, 0xb1, 0x8e, 0x66, 0x3a, 0xe8, 0x0e, 0x9e, 0x4c, 0x70, 0xfe, 0x6c, 0x81, + 0xa2, 0x3c, 0xb4, 0x7d, 0x9a, 0xbc, 0x0a, 0x03, 0xf8, 0x07, 0xb0, 0xdc, 0xa6, 0x31, 0xe1, 0x29, + 0xc1, 0xbe, 0xdb, 0x8a, 0xa8, 0x77, 0xaa, 0x9f, 0xab, 0xc7, 0xff, 0xce, 0xec, 0xbb, 0x6a, 0x81, + 0xdc, 0x3f, 0xdd, 0x0c, 0xe9, 0x56, 0x8c, 0xd3, 0xf6, 0xe6, 0x41, 0x22, 0x44, 0x57, 0x95, 0xe8, + 0x44, 0xa6, 0x83, 0x96, 0x06, 0x96, 0xba, 0x30, 0xc0, 0x36, 0x58, 0xf2, 0x31, 0x75, 0x5f, 0x51, + 0x76, 0xaa, 0xc9, 0x67, 0x25, 0x79, 0xfd, 0x3b, 0xc9, 0x2f, 0x32, 0xbb, 0xf4, 0x6c, 0xef, 0xe3, + 0x8f, 0x28, 0x3b, 0x95, 0x14, 0x57, 0x99, 0x7d, 0x57, 0x89, 0x8d, 0x13, 0x39, 0xa8, 0xe4, 0x63, + 0x3a, 0x08, 0x83, 0x2f, 0x81, 0x35, 0x08, 0xe0, 0xdd, 0x4e, 0x87, 0xb2, 0xb4, 0x92, 0xaf, 0xe5, + 0x36, 0xcc, 0xfa, 0x4f, 0x2e, 0x32, 0x7b, 0x49, 0x53, 0x36, 0x95, 0xe7, 0x2a, 0xb3, 0xef, 0x4d, + 0x90, 0xea, 0x1c, 0x07, 0x2d, 0x69, 0x5a, 0x1d, 0x0a, 0x5b, 0xa0, 0x44, 0xc2, 0xce, 0xf6, 0xee, + 0x23, 0xbd, 0x00, 0x43, 0x2e, 0xe0, 0x57, 0xd3, 0x16, 0x50, 0x6c, 0x1c, 0x1c, 0x6f, 0xef, 0x3e, + 0xea, 0xcf, 0x7f, 0x45, 0xbf, 0x5c, 0x46, 0x58, 0x1c, 0x54, 0x54, 0x50, 0x4d, 0xbe, 0xaf, 0xb1, + 0xab, 0x35, 0xe6, 0x6f, 0xab, 0xb1, 0x7b, 0x93, 0xc6, 0xee, 0xb8, 0xc6, 0xee, 0xb8, 0xc6, 0x13, + 0xad, 0xb1, 0x70, 0x5b, 0x8d, 0x27, 0x37, 0x69, 0x3c, 0x19, 0xd7, 0x50, 0x31, 0xa2, 0x98, 0x5a, + 0xe7, 0x7f, 0xc2, 0x49, 0x1a, 0x76, 0x63, 0x2d, 0x63, 0xde, 0xba, 0x98, 0x26, 0x32, 0x1d, 0xb4, + 0x34, 0xb0, 0x28, 0xf6, 0x53, 0x50, 0xf6, 0x68, 0xc2, 0x53, 0x61, 0x4b, 0x68, 0x27, 0x22, 0x5a, + 0xa2, 0x20, 0x25, 0x9e, 0x4c, 0x93, 0x58, 0x53, 0x12, 0x37, 0xa5, 0x3b, 0x68, 0x65, 0xdc, 0xac, + 0xc4, 0x5c, 0x60, 0x75, 0x48, 0x4a, 0x18, 0x6f, 0x75, 0x59, 0xa0, 0x85, 0x80, 0x14, 0xfa, 0x60, + 0x9a, 0x90, 0x2e, 0xab, 0xc9, 0x54, 0x07, 0x2d, 0x0f, 0x4d, 0x4a, 0xe0, 0x53, 0xb0, 0x14, 0x0a, + 0xd5, 0x56, 0x37, 0xd2, 0xf4, 0x45, 0x49, 0xbf, 0x33, 0x8d, 0x5e, 0x3f, 0x0a, 0xe3, 0x89, 0x0e, + 0x5a, 0xec, 0x1b, 0x14, 0xb5, 0x0f, 0x60, 0xdc, 0x0d, 0x99, 0x1b, 0x44, 0xd8, 0x0b, 0x09, 0xd3, + 0xf4, 0x25, 0x49, 0xff, 0xd3, 0x69, 0xf4, 0xf7, 0x15, 0xfd, 0xf5, 0x64, 0x07, 0x59, 0xc2, 0xf8, + 0x6b, 0x65, 0x53, 0x2a, 0x4d, 0x50, 0x6a, 0x11, 0x16, 0x85, 0x89, 0xe6, 0x5f, 0x94, 0xfc, 0x8f, + 0xa6, 0xf1, 0xeb, 0x0a, 0x1a, 0x4d, 0x73, 0x50, 0x51, 0xc1, 0x01, 0x69, 0x44, 0x13, 0x9f, 0xf6, + 0x49, 0xef, 0xdc, 0x9a, 0x74, 0x34, 0xcd, 0x41, 0x45, 0x05, 0x15, 0x69, 0x00, 0x56, 0x30, 0x63, + 0xf4, 0xf5, 0xc4, 0x86, 0x40, 0xc9, 0xfd, 0xb3, 0x69, 0xdc, 0xfd, 0x97, 0xeb, 0xf5, 0x6c, 0xf1, + 0x72, 0x15, 0xd6, 0xb1, 0x2d, 0xf1, 0x01, 0x0c, 0x18, 0x3e, 0x9f, 0xd0, 0x29, 0xdf, 0x7a, 0xe3, + 0xaf, 0x27, 0x3b, 0xc8, 0x12, 0xc6, 0x31, 0x95, 0xcf, 0x40, 0x39, 0x26, 0x2c, 0x20, 0x6e, 0x42, + 0x52, 0xde, 0x89, 0xc2, 0x54, 0xeb, 0xdc, 0xbd, 0xf5, 0x73, 0x70, 0x53, 0xba, 0x83, 0xa0, 0x34, + 0xbf, 0xd0, 0x56, 0xa5, 0x75, 0x1f, 0x98, 0x83, 0x5b, 0xbf, 0x22, 0x6f, 0xfd, 0x05, 0x4f, 0x5d, + 0xf9, 0xf0, 0x13, 0xb0, 0xc8, 0xdb, 0x38, 0x09, 0xda, 0x38, 0x74, 0xd3, 0x30, 0x26, 0x95, 0x35, + 0xa9, 0xbf, 0x3d, 0x4d, 0xbf, 0xac, 0xf4, 0xc7, 0xf2, 0x1c, 0x54, 0xea, 0xe3, 0x93, 0x30, 0x26, + 0xf0, 0x18, 0x14, 0x3d, 0x9c, 0x78, 0xdd, 0x44, 0xb1, 0x3e, 0x90, 0xac, 0x5b, 0xd3, 0x58, 0xf5, + 0xc5, 0x3a, 0x92, 0xe5, 0x20, 0xa0, 0x50, 0x9f, 0xb1, 0xc3, 0x70, 0xd0, 0x25, 0x8a, 0xf1, 0xbd, + 0x5b, 0x33, 0x8e, 0x64, 0x39, 0x08, 0x28, 0xd4, 0x67, 0xec, 0x11, 0x76, 0x1a, 0x69, 0xc6, 0xf5, + 0x5b, 0x33, 0x8e, 0x64, 0x39, 0x08, 0x28, 0x24, 0x19, 0x9f, 0x03, 0x40, 0x39, 0x3e, 0xc5, 0x8a, + 0xd0, 0x96, 0x84, 0x9b, 0xd3, 0x08, 0x75, 0xcb, 0x3a, 0x4c, 0x72, 0x50, 0x41, 0x02, 0x41, 0x37, + 0x68, 0xb3, 0x56, 0xad, 0x7b, 0x87, 0x86, 0x79, 0xcf, 0xaa, 0x1c, 0x1a, 0xe6, 0x7d, 0xab, 0x7a, + 0x68, 0x98, 0x55, 0x6b, 0xcd, 0xd9, 0x02, 0x73, 0xa2, 0x2d, 0x24, 0xd0, 0x02, 0xf9, 0x53, 0x72, + 0xae, 0x6e, 0x7c, 0x24, 0x86, 0xb0, 0x0c, 0xe6, 0x7a, 0x38, 0xea, 0x12, 0x75, 0x51, 0x23, 0x05, + 0x9c, 0x63, 0xb0, 0x7c, 0xc2, 0x70, 0xc2, 0x45, 0x4b, 0x49, 0x93, 0x23, 0x1a, 0x70, 0x08, 0x81, + 0xd1, 0xc6, 0xbc, 0xad, 0x73, 0xe5, 0x18, 0xfe, 0x18, 0x18, 0x11, 0x0d, 0xb8, 0x6c, 0x59, 0x8a, + 0x3b, 0x77, 0xaf, 0xf7, 0x47, 0x47, 0x34, 0x40, 0x32, 0xc4, 0xf9, 0x4b, 0x1e, 0xe4, 0x8f, 0x68, + 0x00, 0x2b, 0x60, 0x01, 0xfb, 0x3e, 0x23, 0x9c, 0x6b, 0xa6, 0x3e, 0x84, 0xab, 0x60, 0x3e, 0xa5, + 0x9d, 0xd0, 0x53, 0x74, 0x05, 0xa4, 0x91, 0x10, 0xf6, 0x71, 0x8a, 0xe5, 0xed, 0x5e, 0x42, 0x72, + 0x2c, 0x3a, 0x74, 0x59, 0xc4, 0x6e, 0xd2, 0x8d, 0x5b, 0x84, 0xc9, 0x4b, 0xda, 0xa8, 0x2f, 0x5f, + 0x66, 0x76, 0x51, 0xda, 0x5f, 0x48, 0x33, 0x1a, 0x05, 0xf0, 0x7d, 0xb0, 0x90, 0x9e, 0xb9, 0x72, + 0x0d, 0x73, 0x72, 0xbb, 0x57, 0x2e, 0x33, 0x7b, 0x39, 0x1d, 0x2e, 0xf3, 0x37, 0x98, 0xb7, 0xd1, + 0x7c, 0x7a, 0x26, 0xfe, 0x87, 0x5b, 0xc0, 0x4c, 0xcf, 0xdc, 0x30, 0xf1, 0xc9, 0x99, 0xbc, 0x9e, + 0x8d, 0x7a, 0xf9, 0x32, 0xb3, 0xad, 0x91, 0xf0, 0x03, 0xe1, 0x43, 0x0b, 0xe9, 0x99, 0x1c, 0xc0, + 0xf7, 0x01, 0x50, 0x53, 0x92, 0x0a, 0xea, 0xb6, 0x5d, 0xbc, 0xcc, 0xec, 0x82, 0xb4, 0x4a, 0xee, + 0xe1, 0x10, 0x3a, 0x60, 0x4e, 0x71, 0x9b, 0x92, 0xbb, 0x74, 0x99, 0xd9, 0x66, 0x44, 0x03, 0xc5, + 0xa9, 0x5c, 0x62, 0xab, 0x18, 0x89, 0x69, 0x8f, 0xf8, 0xf2, 0xca, 0x33, 0x51, 0x1f, 0xc2, 0x0f, + 0xc1, 0xb2, 0xd2, 0x12, 0x75, 0xc0, 0x53, 0x1c, 0x77, 0x54, 0x33, 0x5f, 0x87, 0x97, 0x99, 0xbd, + 0x24, 0x5d, 0x27, 0x7d, 0x0f, 0x9a, 0xc0, 0xce, 0x17, 0xb3, 0xc0, 0x3c, 0x39, 0x43, 0x84, 0x77, + 0xa3, 0x14, 0x7e, 0x04, 0x2c, 0xd9, 0x42, 0x62, 0x2f, 0x75, 0xc7, 0xce, 0xa5, 0xbe, 0x36, 0xbc, + 0xdd, 0x26, 0x23, 0x1c, 0xb4, 0xdc, 0x37, 0xed, 0xe9, 0xc3, 0x2b, 0x83, 0xb9, 0x56, 0x44, 0x69, + 0x2c, 0xcb, 0xa8, 0x84, 0x14, 0x80, 0x2f, 0xe5, 0x96, 0xcb, 0x12, 0xc9, 0xcb, 0xf6, 0xfc, 0x07, + 0xd7, 0x4b, 0x64, 0xa2, 0xce, 0xea, 0x6b, 0xa2, 0x39, 0xbf, 0xca, 0xec, 0x25, 0xa5, 0xad, 0xf3, + 0x9d, 0xbf, 0x7f, 0xfb, 0xd5, 0xc3, 0x9c, 0x38, 0x1d, 0x59, 0x8c, 0x16, 0xc8, 0x33, 0x92, 0xca, + 0x63, 0x2f, 0x21, 0x31, 0x84, 0x55, 0x60, 0x32, 0xd2, 0x23, 0x2c, 0x25, 0xbe, 0x3c, 0x5e, 0x13, + 0x0d, 0xb0, 0x78, 0xa9, 0x05, 0x98, 0xbb, 0x5d, 0x4e, 0x7c, 0x75, 0x96, 0x68, 0x21, 0xc0, 0xfc, + 0x77, 0x9c, 0xf8, 0x4f, 0x8d, 0xcf, 0xbf, 0xb4, 0x67, 0x1c, 0x0c, 0x8a, 0xba, 0x73, 0xef, 0x76, + 0x22, 0x32, 0xa5, 0x46, 0x77, 0x40, 0x49, 0x7c, 0x2c, 0xe1, 0x80, 0xb8, 0xa7, 0xe4, 0x5c, 0x57, + 0xaa, 0xaa, 0x3b, 0x6d, 0xff, 0x2d, 0x39, 0xe7, 0x68, 0x14, 0x68, 0x89, 0x2f, 0x0d, 0x50, 0x3c, + 0x61, 0xd8, 0x23, 0xba, 0x0f, 0x17, 0xd5, 0x2e, 0x20, 0xd3, 0x12, 0x1a, 0x09, 0x6d, 0x71, 0xa8, + 0xb4, 0x9b, 0xea, 0x27, 0xb2, 0x0f, 0x45, 0x06, 0x23, 0xe4, 0x8c, 0x78, 0x72, 0x2f, 0x0d, 0xa4, + 0x11, 0xdc, 0x05, 0x8b, 0x7e, 0xc8, 0x71, 0x2b, 0x92, 0xdf, 0x86, 0xde, 0xa9, 0x5a, 0x7e, 0xdd, + 0xba, 0xcc, 0xec, 0x92, 0x76, 0x34, 0x85, 0x1d, 0x8d, 0x21, 0x51, 0x43, 0xc3, 0x34, 0x39, 0x5b, + 0xb9, 0x37, 0xa6, 0xaa, 0xa1, 0x41, 0xa8, 0xf4, 0xa0, 0x09, 0x2c, 0x8e, 0xdb, 0x27, 0xad, 0x6e, + 0x20, 0xcb, 0xd7, 0x44, 0x0a, 0x08, 0x6b, 0x14, 0xc6, 0x61, 0x2a, 0xcb, 0x75, 0x0e, 0x29, 0x00, + 0x3f, 0x04, 0x05, 0xda, 0x23, 0x8c, 0x85, 0x3e, 0xe1, 0xb2, 0x4c, 0x8b, 0x3b, 0xef, 0x5d, 0x2f, + 0x83, 0x91, 0x6f, 0x14, 0x34, 0x8c, 0x17, 0x8b, 0x23, 0x89, 0x9c, 0x64, 0x4c, 0x62, 0xca, 0xce, + 0x65, 0xd3, 0xa4, 0x17, 0xa7, 0x1c, 0xcf, 0xa5, 0x1d, 0x8d, 0x21, 0x58, 0x07, 0x50, 0xa7, 0x31, + 0x92, 0x76, 0x59, 0xe2, 0xca, 0x37, 0x48, 0x49, 0xe6, 0xca, 0xe7, 0x58, 0x79, 0x91, 0x74, 0x3e, + 0xc3, 0x29, 0x46, 0xd7, 0x2c, 0xf0, 0x97, 0x00, 0xaa, 0x33, 0x71, 0x3f, 0xe3, 0x34, 0x11, 0x5f, + 0x5a, 0xaf, 0xc2, 0x40, 0x77, 0x3d, 0x52, 0x5f, 0x79, 0xf5, 0x9c, 0x2d, 0x85, 0x0e, 0x39, 0xd5, + 0xab, 0x38, 0x34, 0x4c, 0xc3, 0x9a, 0x3b, 0x34, 0xcc, 0x05, 0xcb, 0x1c, 0xec, 0x9f, 0x5e, 0x05, + 0x5a, 0xe9, 0xe3, 0x91, 0xe9, 0x39, 0x2f, 0x00, 0x38, 0x66, 0x24, 0x14, 0xbd, 0x69, 0x14, 0x89, + 0xd7, 0x5e, 0x82, 0x63, 0xd2, 0x7f, 0xdf, 0x8a, 0xf1, 0x68, 0x61, 0xce, 0x8e, 0x17, 0x26, 0x04, + 0x86, 0x47, 0x7d, 0x22, 0x4b, 0xa3, 0x80, 0xe4, 0xf8, 0xe1, 0x3f, 0x72, 0x60, 0xe4, 0x83, 0x14, + 0xfe, 0x1c, 0x54, 0xf7, 0xf6, 0xf7, 0x1b, 0xcd, 0xa6, 0x7b, 0xf2, 0xe9, 0x71, 0xc3, 0x3d, 0x6e, + 0xa0, 0xe7, 0x07, 0xcd, 0xe6, 0xc1, 0xc7, 0x2f, 0x8e, 0x1a, 0xcd, 0xa6, 0x35, 0x53, 0x7d, 0xf0, + 0xe6, 0x6d, 0xad, 0x32, 0x8c, 0x3f, 0x26, 0x2c, 0x0e, 0x39, 0x0f, 0x69, 0x12, 0x09, 0x81, 0x0f, + 0xc0, 0xea, 0x68, 0x36, 0x6a, 0x34, 0x4f, 0xd0, 0xc1, 0xfe, 0x49, 0xe3, 0x99, 0x95, 0xab, 0x56, + 0xde, 0xbc, 0xad, 0x95, 0x87, 0x99, 0x88, 0xf0, 0x94, 0x85, 0x9e, 0x78, 0xf2, 0x9e, 0x80, 0xca, + 0xcd, 0x9a, 0x8d, 0x67, 0xd6, 0x6c, 0xb5, 0xfa, 0xe6, 0x6d, 0x6d, 0xf5, 0x26, 0x45, 0xe2, 0x57, + 0x8d, 0xcf, 0xff, 0xb6, 0x3e, 0x53, 0x7f, 0xfa, 0xf5, 0xc5, 0x7a, 0xee, 0x9b, 0x8b, 0xf5, 0xdc, + 0x7f, 0x2f, 0xd6, 0x73, 0x5f, 0xbc, 0x5b, 0x9f, 0xf9, 0xe6, 0xdd, 0xfa, 0xcc, 0xbf, 0xde, 0xad, + 0xcf, 0xfc, 0xbe, 0x16, 0x84, 0x69, 0xbb, 0xdb, 0xda, 0xf4, 0x68, 0xbc, 0x35, 0xf9, 0x33, 0x84, + 0xf8, 0xd4, 0xe6, 0xad, 0x79, 0xf9, 0x6b, 0xd2, 0xe3, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0xf2, + 0x28, 0x37, 0xbe, 0xa6, 0x12, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -1098,6 +1088,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.EvmChainId != 0 { + i = encodeVarintEvm(dAtA, i, uint64(m.EvmChainId)) + i-- + dAtA[i] = 0x58 + } if m.HistoryServeWindow != 0 { i = encodeVarintEvm(dAtA, i, uint64(m.HistoryServeWindow)) i-- @@ -1330,22 +1325,6 @@ func (m *ChainConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0xda } - if m.Decimals != 0 { - i = encodeVarintEvm(dAtA, i, uint64(m.Decimals)) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xd0 - } - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintEvm(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xca - } if m.ChainId != 0 { i = encodeVarintEvm(dAtA, i, uint64(m.ChainId)) i-- @@ -2038,6 +2017,9 @@ func (m *Params) Size() (n int) { if m.HistoryServeWindow != 0 { n += 1 + sovEvm(uint64(m.HistoryServeWindow)) } + if m.EvmChainId != 0 { + n += 1 + sovEvm(uint64(m.EvmChainId)) + } return n } @@ -2144,13 +2126,6 @@ func (m *ChainConfig) Size() (n int) { if m.ChainId != 0 { n += 2 + sovEvm(uint64(m.ChainId)) } - l = len(m.Denom) - if l > 0 { - n += 2 + l + sovEvm(uint64(l)) - } - if m.Decimals != 0 { - n += 2 + sovEvm(uint64(m.Decimals)) - } if m.ShanghaiTime != nil { l = m.ShanghaiTime.Size() n += 2 + l + sovEvm(uint64(l)) @@ -2630,6 +2605,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 11: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field EvmChainId", wireType) + } + m.EvmChainId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.EvmChainId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipEvm(dAtA[iNdEx:]) @@ -3476,57 +3470,6 @@ func (m *ChainConfig) Unmarshal(dAtA []byte) error { break } } - case 25: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 26: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Decimals", wireType) - } - m.Decimals = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvm - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Decimals |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } case 27: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ShanghaiTime", wireType) diff --git a/x/vm/types/evm_config.go b/x/vm/types/evm_config.go new file mode 100644 index 000000000..8a24ee75a --- /dev/null +++ b/x/vm/types/evm_config.go @@ -0,0 +1,69 @@ +package types + +import ( + "fmt" + "slices" + + "github.com/ethereum/go-ethereum/core/vm" +) + +// TOODO: remove singleton pattern and use a context instead +var sealed = false + +func Seal() { + sealed = true +} + +func IsSealed() bool { + return sealed +} + +// EvmConfig allows to extend x/evm module configurations. The configurator modifies +// the EVM before starting the node. This means that all init genesis validations will be +// applied to each change. +type EvmConfig struct { + extendedEIPs map[int]func(*vm.JumpTable) + extendedDefaultExtraEIPs []int64 + chainConfig *ChainConfig +} + +// NewEvmConfig returns a pointer to a new EvmConfig object. +func NewEvmConfig() *EvmConfig { + return &EvmConfig{} +} + +func (ec *EvmConfig) GetChainConfig() *ChainConfig { + return ec.chainConfig +} + +// WithChainConfig allows to define a custom `chainConfig` to be used in the +// EVM. +func (ec *EvmConfig) WithChainConfig(cc *ChainConfig) *EvmConfig { + ec.chainConfig = cc + return ec +} + +// WithExtendedEips allows to add to the go-ethereum activators map the provided +// EIP activators. +func (ec *EvmConfig) WithExtendedEips(extendedEIPs map[int]func(*vm.JumpTable)) *EvmConfig { + ec.extendedEIPs = extendedEIPs + return ec +} + +// WithExtendedDefaultExtraEIPs update the x/evm DefaultExtraEIPs params +// by adding provided EIP numbers. +func (ec *EvmConfig) WithExtendedDefaultExtraEIPs(eips ...int64) *EvmConfig { + ec.extendedDefaultExtraEIPs = eips + return ec +} + +func extendDefaultExtraEIPs(extraEIPs []int64) error { + for _, eip := range extraEIPs { + if slices.Contains(DefaultExtraEIPs, eip) { + return fmt.Errorf("error applying EvmConfig: EIP %d is already present in the default list: %v", eip, DefaultExtraEIPs) + } + + DefaultExtraEIPs = append(DefaultExtraEIPs, eip) + } + return nil +} diff --git a/x/vm/types/configurator_test.go b/x/vm/types/evm_config_test.go similarity index 69% rename from x/vm/types/configurator_test.go rename to x/vm/types/evm_config_test.go index 8ba74f536..eb1971271 100644 --- a/x/vm/types/configurator_test.go +++ b/x/vm/types/evm_config_test.go @@ -3,20 +3,21 @@ package types_test import ( "testing" + evmconfig "github.com/cosmos/evm/config" "github.com/ethereum/go-ethereum/core/vm" "github.com/stretchr/testify/require" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/x/vm/types" ) -func TestEVMConfigurator(t *testing.T) { - evmConfigurator := types.NewEVMConfigurator(). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]) - err := evmConfigurator.Configure() +func TestEvmConfigApply(t *testing.T) { + evmConfigurator := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true) + evmConfigurator.ResetTestConfig() + err := types.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) require.NoError(t, err) - err = evmConfigurator.Configure() + err = evmConfigurator.Apply() require.Error(t, err) require.Contains(t, err.Error(), "sealed", "expected different error") } @@ -24,18 +25,17 @@ func TestEVMConfigurator(t *testing.T) { func TestExtendedEips(t *testing.T) { testCases := []struct { name string - malleate func() *types.EVMConfigurator + malleate func() *types.EvmConfig expPass bool errContains string }{ { "fail - eip already present in activators return an error", - func() *types.EVMConfigurator { + func() *types.EvmConfig { extendedEIPs := map[int]func(*vm.JumpTable){ 3855: func(_ *vm.JumpTable) {}, } - ec := types.NewEVMConfigurator(). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). + ec := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true). WithExtendedEips(extendedEIPs) return ec }, @@ -44,12 +44,11 @@ func TestExtendedEips(t *testing.T) { }, { "success - new default extra eips without duplication added", - func() *types.EVMConfigurator { + func() *types.EvmConfig { extendedEIPs := map[int]func(*vm.JumpTable){ 0o000: func(_ *vm.JumpTable) {}, } - ec := types.NewEVMConfigurator(). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). + ec := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true). WithExtendedEips(extendedEIPs) return ec }, @@ -61,7 +60,7 @@ func TestExtendedEips(t *testing.T) { for _, tc := range testCases { ec := tc.malleate() ec.ResetTestConfig() - err := ec.Configure() + err := ec.Apply() if tc.expPass { require.NoError(t, err) @@ -76,18 +75,17 @@ func TestExtendedDefaultExtraEips(t *testing.T) { defaultExtraEIPsSnapshot := types.DefaultExtraEIPs testCases := []struct { name string - malleate func() *types.EVMConfigurator + malleate func() *types.EvmConfig postCheck func() expPass bool errContains string }{ { "fail - duplicate default EIP entiries", - func() *types.EVMConfigurator { + func() *types.EvmConfig { extendedDefaultExtraEIPs := []int64{1000} types.DefaultExtraEIPs = append(types.DefaultExtraEIPs, 1000) - ec := types.NewEVMConfigurator(). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). + ec := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec }, @@ -100,10 +98,9 @@ func TestExtendedDefaultExtraEips(t *testing.T) { }, { "success - empty default extra eip", - func() *types.EVMConfigurator { + func() *types.EvmConfig { var extendedDefaultExtraEIPs []int64 - ec := types.NewEVMConfigurator(). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). + ec := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec }, @@ -115,10 +112,9 @@ func TestExtendedDefaultExtraEips(t *testing.T) { }, { "success - extra default eip added", - func() *types.EVMConfigurator { + func() *types.EvmConfig { extendedDefaultExtraEIPs := []int64{1001} - ec := types.NewEVMConfigurator(). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). + ec := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec }, @@ -135,7 +131,7 @@ func TestExtendedDefaultExtraEips(t *testing.T) { t.Run(tc.name, func(t *testing.T) { ec := tc.malleate() ec.ResetTestConfig() - err := ec.Configure() + err := ec.Apply() if tc.expPass { require.NoError(t, err) diff --git a/x/vm/types/genesis.go b/x/vm/types/genesis.go index f7190d294..d25022b5e 100644 --- a/x/vm/types/genesis.go +++ b/x/vm/types/genesis.go @@ -4,6 +4,8 @@ import ( "fmt" "github.com/cosmos/evm/types" + + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) // Validate performs a basic validation of a GenesisAccount fields. @@ -68,3 +70,22 @@ func (gs GenesisState) Validate() error { return gs.Params.Validate() } + +// DeriveCoinInfoFromMetadata extracts EvmCoinInfo from bank metadata +func DeriveCoinInfoFromMetadata(metadata banktypes.Metadata, evmDenom string) (*EvmCoinInfo, error) { + var baseDecimals uint32 + for _, denomUnit := range metadata.DenomUnits { + if denomUnit.Denom == metadata.Display { + baseDecimals = denomUnit.Exponent + } + } + + fmt.Println(evmDenom) + + return &EvmCoinInfo{ + DisplayDenom: metadata.Display, + Decimals: Decimals(baseDecimals), + BaseDenom: metadata.Base, + ExtendedDenom: evmDenom, + }, nil +} diff --git a/x/vm/types/msg_test.go b/x/vm/types/msg_test.go index 2692b3edb..85f2959c4 100644 --- a/x/vm/types/msg_test.go +++ b/x/vm/types/msg_test.go @@ -13,9 +13,9 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/suite" + evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/encoding" - "github.com/cosmos/evm/testutil/config" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/evm/x/vm/types" @@ -54,7 +54,8 @@ func (suite *MsgsTestSuite) SetupTest() { encodingConfig := encoding.MakeConfig(suite.chainID.Uint64()) suite.clientCtx = client.Context{}.WithTxConfig(encodingConfig.TxConfig) - err := config.EvmAppOptions(9001) + chainConfig := evmconfig.NewTestChainConfig(9001) + err := chainConfig.ApplyChainConfig() suite.Require().NoError(err) } @@ -112,13 +113,13 @@ func (suite *MsgsTestSuite) TestMsgEthereumTx_BuildTx() { }, } for _, coinInfo := range []types.EvmCoinInfo{ - testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], - testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID], + testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], + testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID], } { for _, tc := range testCases { - configurator := types.NewEVMConfigurator() + configurator := types.NewEvmConfig() configurator.ResetTestConfig() - suite.Require().NoError(configurator.WithEVMCoinInfo(coinInfo).Configure()) + suite.Require().NoError(configurator.WithEVMCoinInfo(coinInfo).Apply()) baseDenom := types.GetEVMCoinDenom() extendedDenom := types.GetEVMCoinExtendedDenom() diff --git a/x/vm/types/scaling_test.go b/x/vm/types/scaling_test.go index 421914fe1..d7db64621 100644 --- a/x/vm/types/scaling_test.go +++ b/x/vm/types/scaling_test.go @@ -8,7 +8,8 @@ import ( "github.com/holiman/uint256" "github.com/stretchr/testify/require" - testconstants "github.com/cosmos/evm/testutil/constants" + evmconfig "github.com/cosmos/evm/config" + testconfig "github.com/cosmos/evm/testutil/config" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/math" @@ -17,11 +18,11 @@ import ( ) func TestConvertEvmCoinFrom18Decimals(t *testing.T) { - eighteenDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] - sixDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] + eighteenDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + sixDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID] - eighteenDecimalsBaseCoinZero := sdk.Coin{Denom: eighteenDecimalsCoinInfo.Denom, Amount: math.NewInt(0)} - sixDecimalsBaseCoinZero := sdk.Coin{Denom: sixDecimalsCoinInfo.Denom, Amount: math.NewInt(0)} + eighteenDecimalsBaseCoinZero := sdk.Coin{Denom: eighteenDecimalsCoinInfo.GetDenom(), Amount: math.NewInt(0)} + sixDecimalsBaseCoinZero := sdk.Coin{Denom: sixDecimalsCoinInfo.GetDenom(), Amount: math.NewInt(0)} testCases := []struct { name string @@ -42,28 +43,28 @@ func TestConvertEvmCoinFrom18Decimals(t *testing.T) { evmCoinInfo: sixDecimalsCoinInfo, coin: sixDecimalsBaseCoinZero, expErr: false, - expCoin: sdk.Coin{Denom: sixDecimalsCoinInfo.ExtendedDenom, Amount: math.NewInt(0)}, + expCoin: sdk.Coin{Denom: sixDecimalsCoinInfo.GetExtendedDenom(), Amount: math.NewInt(0)}, }, { name: "pass - no conversion with 18 decimals", evmCoinInfo: eighteenDecimalsCoinInfo, - coin: sdk.Coin{Denom: eighteenDecimalsCoinInfo.Denom, Amount: math.NewInt(10)}, + coin: sdk.Coin{Denom: eighteenDecimalsCoinInfo.GetDenom(), Amount: math.NewInt(10)}, expErr: false, - expCoin: sdk.Coin{Denom: eighteenDecimalsCoinInfo.Denom, Amount: math.NewInt(10)}, + expCoin: sdk.Coin{Denom: eighteenDecimalsCoinInfo.GetDenom(), Amount: math.NewInt(10)}, }, { name: "pass - conversion with 6 decimals", evmCoinInfo: sixDecimalsCoinInfo, - coin: sdk.Coin{Denom: sixDecimalsCoinInfo.Denom, Amount: math.NewInt(1e12)}, + coin: sdk.Coin{Denom: sixDecimalsCoinInfo.GetDenom(), Amount: math.NewInt(1e12)}, expErr: false, - expCoin: sdk.Coin{Denom: sixDecimalsCoinInfo.ExtendedDenom, Amount: math.NewInt(1e12)}, + expCoin: sdk.Coin{Denom: sixDecimalsCoinInfo.GetExtendedDenom(), Amount: math.NewInt(1e12)}, }, { name: "pass - conversion with amount less than conversion factor", evmCoinInfo: sixDecimalsCoinInfo, - coin: sdk.Coin{Denom: sixDecimalsCoinInfo.Denom, Amount: math.NewInt(1e11)}, + coin: sdk.Coin{Denom: sixDecimalsCoinInfo.GetDenom(), Amount: math.NewInt(1e11)}, expErr: false, - expCoin: sdk.Coin{Denom: sixDecimalsCoinInfo.ExtendedDenom, Amount: math.NewInt(1e11)}, + expCoin: sdk.Coin{Denom: sixDecimalsCoinInfo.GetExtendedDenom(), Amount: math.NewInt(1e11)}, }, { name: "fail - not evm denom", @@ -75,9 +76,10 @@ func TestConvertEvmCoinFrom18Decimals(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(tc.evmCoinInfo).Configure()) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + require.NoError(t, evmConfig.Apply()) + require.NoError(t, evmtypes.SetEVMCoinInfo(tc.evmCoinInfo)) coinConverted, err := evmtypes.ConvertEvmCoinDenomToExtendedDenom(tc.coin) @@ -92,12 +94,12 @@ func TestConvertEvmCoinFrom18Decimals(t *testing.T) { } func TestConvertCoinsFrom18Decimals(t *testing.T) { - eighteenDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] - sixDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] + eighteenDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + sixDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID] nonBaseCoin := sdk.Coin{Denom: "btc", Amount: math.NewInt(10)} - eighteenDecimalsBaseCoin := sdk.Coin{Denom: eighteenDecimalsCoinInfo.Denom, Amount: math.NewInt(10)} - sixDecimalsBaseCoin := sdk.Coin{Denom: sixDecimalsCoinInfo.Denom, Amount: math.NewInt(10)} + eighteenDecimalsBaseCoin := sdk.Coin{Denom: eighteenDecimalsCoinInfo.GetDenom(), Amount: math.NewInt(10)} + sixDecimalsBaseCoin := sdk.Coin{Denom: sixDecimalsCoinInfo.GetDenom(), Amount: math.NewInt(10)} testCases := []struct { name string @@ -121,7 +123,7 @@ func TestConvertCoinsFrom18Decimals(t *testing.T) { name: "pass - only base denom 6 decimals", evmCoinInfo: sixDecimalsCoinInfo, coins: sdk.Coins{sixDecimalsBaseCoin}, - expCoins: sdk.Coins{sdk.Coin{Denom: sixDecimalsCoinInfo.ExtendedDenom, Amount: math.NewInt(10)}}, + expCoins: sdk.Coins{sdk.Coin{Denom: sixDecimalsCoinInfo.GetExtendedDenom(), Amount: math.NewInt(10)}}, }, { name: "pass - multiple coins and base denom 18 decimals", @@ -133,15 +135,16 @@ func TestConvertCoinsFrom18Decimals(t *testing.T) { name: "pass - multiple coins and base denom 6 decimals", evmCoinInfo: sixDecimalsCoinInfo, coins: sdk.Coins{nonBaseCoin, sixDecimalsBaseCoin}.Sort(), - expCoins: sdk.Coins{nonBaseCoin, sdk.Coin{Denom: sixDecimalsCoinInfo.ExtendedDenom, Amount: math.NewInt(10)}}.Sort(), + expCoins: sdk.Coins{nonBaseCoin, sdk.Coin{Denom: sixDecimalsCoinInfo.GetExtendedDenom(), Amount: math.NewInt(10)}}.Sort(), }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(tc.evmCoinInfo).Configure()) + evmConfig := evmtypes.NewEvmConfig() + evmConfig.ResetTestConfig() + require.NoError(t, evmConfig.Apply()) + require.NoError(t, evmtypes.SetEVMCoinInfo(tc.evmCoinInfo)) coinConverted := evmtypes.ConvertCoinsDenomToExtendedDenom(tc.coins) require.Equal(t, tc.expCoins, coinConverted, "expected a different coin") @@ -183,14 +186,15 @@ func TestConvertAmountTo18DecimalsLegacy(t *testing.T) { } for _, coinInfo := range []evmtypes.EvmCoinInfo{ - testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], - testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID], + testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], + testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID], } { for _, tc := range testCases { t.Run(fmt.Sprintf("%d dec - %s", coinInfo.Decimals, tc.name), func(t *testing.T) { - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(coinInfo).Configure()) + evmConfig := evmtypes.NewEvmConfig() + evmConfig.ResetTestConfig() + require.NoError(t, evmConfig.Apply()) + require.NoError(t, evmtypes.SetEVMCoinInfo(coinInfo)) res := evmtypes.ConvertBigIntFrom18DecimalsToLegacyDec(tc.amt.ToBig()) exp := math.LegacyNewDecFromBigInt(tc.amt.ToBig()) if coinInfo.Decimals == evmtypes.SixDecimals { @@ -221,14 +225,15 @@ func TestConvertAmountTo18DecimalsBigInt(t *testing.T) { } for _, coinInfo := range []evmtypes.EvmCoinInfo{ - testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], - testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID], + testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], + testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID], } { for _, tc := range testCases { t.Run(fmt.Sprintf("%d dec - %s", coinInfo.Decimals, tc.name), func(t *testing.T) { - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(coinInfo).Configure()) + evmConfig := evmtypes.NewEvmConfig() + evmConfig.ResetTestConfig() + require.NoError(t, evmConfig.Apply()) + require.NoError(t, evmtypes.SetEVMCoinInfo(coinInfo)) res := evmtypes.ConvertAmountTo18DecimalsBigInt(tc.amt) exp := tc.amt if coinInfo.Decimals == evmtypes.SixDecimals { diff --git a/x/vm/wrappers/bank_test.go b/x/vm/wrappers/bank_test.go index 590da9908..c4d04d0ee 100644 --- a/x/vm/wrappers/bank_test.go +++ b/x/vm/wrappers/bank_test.go @@ -10,7 +10,8 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" - testconstants "github.com/cosmos/evm/testutil/constants" + evmconfig "github.com/cosmos/evm/config" + testconfig "github.com/cosmos/evm/testutil/config" evmtypes "github.com/cosmos/evm/x/vm/types" "github.com/cosmos/evm/x/vm/wrappers" "github.com/cosmos/evm/x/vm/wrappers/testutil" @@ -23,8 +24,8 @@ import ( // --------------------------------------TRANSACTIONS----------------------------------------------- func TestMintAmountToAccount(t *testing.T) { - eighteenDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] - sixDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] + eighteenDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + sixDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID] testCases := []struct { name string @@ -38,12 +39,12 @@ func TestMintAmountToAccount(t *testing.T) { { name: "success - convert evm coin denom to extended denom", coinInfo: sixDecimalsCoinInfo, - evmDenom: sixDecimalsCoinInfo.Denom, + evmDenom: sixDecimalsCoinInfo.GetDenom(), amount: big.NewInt(1e18), // 1 token in 18 decimals recipient: sdk.AccAddress([]byte("test_address")), expectErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - expectedCoin := sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e18)) // 1 token in 18 decimals + expectedCoin := sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e18)) // 1 token in 18 decimals expectedCoins := sdk.NewCoins(expectedCoin) mbk.EXPECT(). @@ -62,12 +63,12 @@ func TestMintAmountToAccount(t *testing.T) { { name: "success - 18 decimals amount not modified", coinInfo: eighteenDecimalsCoinInfo, - evmDenom: eighteenDecimalsCoinInfo.Denom, + evmDenom: eighteenDecimalsCoinInfo.GetDenom(), amount: big.NewInt(1e18), // 1 token in 18 decimals recipient: sdk.AccAddress([]byte("test_address")), expectErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - expectedCoin := sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)) + expectedCoin := sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)) expectedCoins := sdk.NewCoins(expectedCoin) mbk.EXPECT(). @@ -86,12 +87,12 @@ func TestMintAmountToAccount(t *testing.T) { { name: "fail - mint coins error", coinInfo: sixDecimalsCoinInfo, - evmDenom: sixDecimalsCoinInfo.Denom, + evmDenom: sixDecimalsCoinInfo.GetDenom(), amount: big.NewInt(1e18), recipient: sdk.AccAddress([]byte("test_address")), expectErr: "failed to mint coins to account in bank wrapper", mockSetup: func(mbk *testutil.MockBankWrapper) { - expectedCoin := sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e18)) + expectedCoin := sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e18)) expectedCoins := sdk.NewCoins(expectedCoin) mbk.EXPECT(). @@ -103,11 +104,12 @@ func TestMintAmountToAccount(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - // Setup EVM configurator to have access to the EVM coin info. - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + err := evmConfig.Apply() + require.NoError(t, err, "failed to apply EvmConfig") + err = evmtypes.SetEVMCoinInfo(tc.coinInfo) + require.NoError(t, err, "failed to set EvmCoinInfo") // Setup mock controller ctrl := gomock.NewController(t) @@ -128,8 +130,8 @@ func TestMintAmountToAccount(t *testing.T) { } func TestBurnAmountFromAccount(t *testing.T) { - eighteenDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] - sixDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] + eighteenDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + sixDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID] account := sdk.AccAddress([]byte("test_address")) @@ -146,7 +148,7 @@ func TestBurnAmountFromAccount(t *testing.T) { amount: big.NewInt(1e18), expectErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - expectedCoin := sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e18)) + expectedCoin := sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e18)) expectedCoins := sdk.NewCoins(expectedCoin) mbk.EXPECT(). @@ -168,7 +170,7 @@ func TestBurnAmountFromAccount(t *testing.T) { amount: big.NewInt(1e18), expectErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - expectedCoin := sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)) + expectedCoin := sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)) expectedCoins := sdk.NewCoins(expectedCoin) mbk.EXPECT(). @@ -190,7 +192,7 @@ func TestBurnAmountFromAccount(t *testing.T) { amount: big.NewInt(1e18), expectErr: "failed to burn coins from account in bank wrapper", mockSetup: func(mbk *testutil.MockBankWrapper) { - expectedCoin := sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e18)) + expectedCoin := sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e18)) expectedCoins := sdk.NewCoins(expectedCoin) mbk.EXPECT(). @@ -208,7 +210,7 @@ func TestBurnAmountFromAccount(t *testing.T) { amount: big.NewInt(1e18), expectErr: "burn error", mockSetup: func(mbk *testutil.MockBankWrapper) { - expectedCoin := sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e18)) + expectedCoin := sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e18)) expectedCoins := sdk.NewCoins(expectedCoin) mbk.EXPECT(). @@ -224,11 +226,12 @@ func TestBurnAmountFromAccount(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - // Setup EVM configurator to have access to the EVM coin info. - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + err := evmConfig.Apply() + require.NoError(t, err, "failed to apply EvmConfig") + err = evmtypes.SetEVMCoinInfo(tc.coinInfo) + require.NoError(t, err, "failed to set EvmCoinInfo") // Setup mock controller ctrl := gomock.NewController(t) @@ -249,8 +252,8 @@ func TestBurnAmountFromAccount(t *testing.T) { } func TestSendCoinsFromModuleToAccount(t *testing.T) { - eighteenDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] - sixDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] + eighteenDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + sixDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID] account := sdk.AccAddress([]byte("test_address")) @@ -266,14 +269,14 @@ func TestSendCoinsFromModuleToAccount(t *testing.T) { coinInfo: eighteenDecimalsCoinInfo, coins: func() sdk.Coins { coins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), }...) return coins }, expectErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { expectedCoins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), }...) mbk.EXPECT(). @@ -290,14 +293,14 @@ func TestSendCoinsFromModuleToAccount(t *testing.T) { coinInfo: sixDecimalsCoinInfo, coins: func() sdk.Coins { coins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(sixDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + sdk.NewCoin(sixDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), }...) return coins }, expectErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { expectedCoins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e18)), + sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e18)), }...) mbk.EXPECT(). @@ -314,7 +317,7 @@ func TestSendCoinsFromModuleToAccount(t *testing.T) { coinInfo: eighteenDecimalsCoinInfo, coins: func() sdk.Coins { coins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), sdk.NewCoin("something", sdkmath.NewInt(3e18)), }...) return coins @@ -322,7 +325,7 @@ func TestSendCoinsFromModuleToAccount(t *testing.T) { expectErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { expectedCoins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), sdk.NewCoin("something", sdkmath.NewInt(3e18)), }...) @@ -340,7 +343,7 @@ func TestSendCoinsFromModuleToAccount(t *testing.T) { coinInfo: sixDecimalsCoinInfo, coins: func() sdk.Coins { coins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(sixDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + sdk.NewCoin(sixDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), sdk.NewCoin("something", sdkmath.NewInt(3e18)), }...) return coins @@ -348,7 +351,7 @@ func TestSendCoinsFromModuleToAccount(t *testing.T) { expectErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { expectedCoins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e18)), + sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e18)), sdk.NewCoin("something", sdkmath.NewInt(3e18)), }...) @@ -366,7 +369,7 @@ func TestSendCoinsFromModuleToAccount(t *testing.T) { coinInfo: sixDecimalsCoinInfo, coins: func() sdk.Coins { coins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(sixDecimalsCoinInfo.Denom, sdkmath.ZeroInt()), + sdk.NewCoin(sixDecimalsCoinInfo.GetDenom(), sdkmath.ZeroInt()), }...) return coins }, @@ -385,11 +388,12 @@ func TestSendCoinsFromModuleToAccount(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - // Setup EVM configurator to have access to the EVM coin info. - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + err := evmConfig.Apply() + require.NoError(t, err, "failed to apply EvmConfig") + err = evmtypes.SetEVMCoinInfo(tc.coinInfo) + require.NoError(t, err, "failed to set EvmCoinInfo") // Setup mock controller ctrl := gomock.NewController(t) @@ -410,8 +414,8 @@ func TestSendCoinsFromModuleToAccount(t *testing.T) { } func TestSendCoinsFromAccountToModule(t *testing.T) { - eighteenDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] - sixDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] + eighteenDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + sixDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID] account := sdk.AccAddress([]byte("test_address")) @@ -427,14 +431,14 @@ func TestSendCoinsFromAccountToModule(t *testing.T) { coinInfo: eighteenDecimalsCoinInfo, coins: func() sdk.Coins { coins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), }...) return coins }, expectErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { expectedCoins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), }...) mbk.EXPECT(). @@ -451,14 +455,14 @@ func TestSendCoinsFromAccountToModule(t *testing.T) { coinInfo: sixDecimalsCoinInfo, coins: func() sdk.Coins { coins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(sixDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + sdk.NewCoin(sixDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), }...) return coins }, expectErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { expectedCoins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e18)), + sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e18)), }...) mbk.EXPECT(). @@ -475,7 +479,7 @@ func TestSendCoinsFromAccountToModule(t *testing.T) { coinInfo: eighteenDecimalsCoinInfo, coins: func() sdk.Coins { coins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), sdk.NewCoin("something", sdkmath.NewInt(3e18)), }...) return coins @@ -483,7 +487,7 @@ func TestSendCoinsFromAccountToModule(t *testing.T) { expectErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { expectedCoins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), sdk.NewCoin("something", sdkmath.NewInt(3e18)), }...) @@ -501,7 +505,7 @@ func TestSendCoinsFromAccountToModule(t *testing.T) { coinInfo: sixDecimalsCoinInfo, coins: func() sdk.Coins { coins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(sixDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + sdk.NewCoin(sixDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), sdk.NewCoin("something", sdkmath.NewInt(3e18)), }...) return coins @@ -509,7 +513,7 @@ func TestSendCoinsFromAccountToModule(t *testing.T) { expectErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { expectedCoins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e18)), + sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e18)), sdk.NewCoin("something", sdkmath.NewInt(3e18)), }...) @@ -527,7 +531,7 @@ func TestSendCoinsFromAccountToModule(t *testing.T) { coinInfo: sixDecimalsCoinInfo, coins: func() sdk.Coins { coins := sdk.NewCoins([]sdk.Coin{ - sdk.NewCoin(sixDecimalsCoinInfo.Denom, sdkmath.ZeroInt()), + sdk.NewCoin(sixDecimalsCoinInfo.GetDenom(), sdkmath.ZeroInt()), }...) return coins }, @@ -546,11 +550,12 @@ func TestSendCoinsFromAccountToModule(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - // Setup EVM configurator to have access to the EVM coin info. - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + err := evmConfig.Apply() + require.NoError(t, err, "failed to apply EvmConfig") + err = evmtypes.SetEVMCoinInfo(tc.coinInfo) + require.NoError(t, err, "failed to set EvmCoinInfo") // Setup mock controller ctrl := gomock.NewController(t) @@ -573,8 +578,8 @@ func TestSendCoinsFromAccountToModule(t *testing.T) { // ----------------------------------------QUERIES------------------------------------------------- func TestGetBalance(t *testing.T) { - eighteenDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] - sixDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] + eighteenDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + sixDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID] maxInt64 := int64(9223372036854775807) account := sdk.AccAddress([]byte("test_address")) @@ -591,85 +596,85 @@ func TestGetBalance(t *testing.T) { { name: "success - convert 6 decimals amount to 18 decimals", coinInfo: sixDecimalsCoinInfo, - evmDenom: sixDecimalsCoinInfo.Denom, - expCoin: sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e18)), + evmDenom: sixDecimalsCoinInfo.GetDenom(), + expCoin: sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e18)), expErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e18)) + returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e18)) mbk.EXPECT(). GetBalance( gomock.Any(), account, - sixDecimalsCoinInfo.ExtendedDenom, + sixDecimalsCoinInfo.GetExtendedDenom(), ).Return(returnedCoin) }, }, { name: "success - convert max int 6 decimals amount to 18 decimals", coinInfo: sixDecimalsCoinInfo, - evmDenom: sixDecimalsCoinInfo.Denom, - expCoin: sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e12).MulRaw(maxInt64)), + evmDenom: sixDecimalsCoinInfo.GetDenom(), + expCoin: sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e12).MulRaw(maxInt64)), expErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e12).MulRaw(maxInt64)) + returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e12).MulRaw(maxInt64)) mbk.EXPECT(). GetBalance( gomock.Any(), account, - sixDecimalsCoinInfo.ExtendedDenom, + sixDecimalsCoinInfo.GetExtendedDenom(), ).Return(returnedCoin) }, }, { name: "success - does not convert 18 decimals amount", coinInfo: eighteenDecimalsCoinInfo, - evmDenom: eighteenDecimalsCoinInfo.Denom, - expCoin: sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + evmDenom: eighteenDecimalsCoinInfo.GetDenom(), + expCoin: sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), expErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - returnedCoin := sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)) + returnedCoin := sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)) mbk.EXPECT(). GetBalance( gomock.Any(), account, - eighteenDecimalsCoinInfo.Denom, + eighteenDecimalsCoinInfo.GetDenom(), ).Return(returnedCoin) }, }, { name: "success - zero balance", coinInfo: sixDecimalsCoinInfo, - evmDenom: sixDecimalsCoinInfo.Denom, - expCoin: sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(0)), + evmDenom: sixDecimalsCoinInfo.GetDenom(), + expCoin: sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(0)), expErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(0)) + returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(0)) mbk.EXPECT(). GetBalance( gomock.Any(), account, - sixDecimalsCoinInfo.ExtendedDenom, + sixDecimalsCoinInfo.GetExtendedDenom(), ).Return(returnedCoin) }, }, { name: "success - small amount (less than 1 full token)", coinInfo: sixDecimalsCoinInfo, - evmDenom: sixDecimalsCoinInfo.Denom, - expCoin: sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e14)), // 0.0001 token in 18 decimals + evmDenom: sixDecimalsCoinInfo.GetDenom(), + expCoin: sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e14)), // 0.0001 token in 18 decimals expErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e14)) // 0.0001 token in 6 decimals + returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e14)) // 0.0001 token in 6 decimals mbk.EXPECT(). GetBalance( gomock.Any(), account, - sixDecimalsCoinInfo.ExtendedDenom, + sixDecimalsCoinInfo.GetExtendedDenom(), ).Return(returnedCoin) }, }, @@ -684,11 +689,12 @@ func TestGetBalance(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - // Setup EVM configurator to have access to the EVM coin info. - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + err := evmConfig.Apply() + require.NoError(t, err, "failed to apply EvmConfig") + err = evmtypes.SetEVMCoinInfo(tc.coinInfo) + require.NoError(t, err, "failed to set EvmCoinInfo") // Setup mock controller ctrl := gomock.NewController(t) @@ -720,8 +726,8 @@ func TestGetBalance(t *testing.T) { // ----------------------------------------QUERIES------------------------------------------------- func TestSppendableCoin(t *testing.T) { - eighteenDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] - sixDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] + eighteenDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] + sixDecimalsCoinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID] maxInt64 := int64(9223372036854775807) account := sdk.AccAddress([]byte("test_address")) @@ -738,85 +744,85 @@ func TestSppendableCoin(t *testing.T) { { name: "success - convert 6 decimals amount to 18 decimals", coinInfo: sixDecimalsCoinInfo, - evmDenom: sixDecimalsCoinInfo.Denom, - expCoin: sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e18)), + evmDenom: sixDecimalsCoinInfo.GetDenom(), + expCoin: sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e18)), expErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e18)) + returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e18)) mbk.EXPECT(). SpendableCoin( gomock.Any(), account, - sixDecimalsCoinInfo.ExtendedDenom, + sixDecimalsCoinInfo.GetExtendedDenom(), ).Return(returnedCoin) }, }, { name: "success - convert max int 6 decimals amount to 18 decimals", coinInfo: sixDecimalsCoinInfo, - evmDenom: sixDecimalsCoinInfo.Denom, - expCoin: sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e12).MulRaw(maxInt64)), + evmDenom: sixDecimalsCoinInfo.GetDenom(), + expCoin: sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e12).MulRaw(maxInt64)), expErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e12).MulRaw(maxInt64)) + returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e12).MulRaw(maxInt64)) mbk.EXPECT(). SpendableCoin( gomock.Any(), account, - sixDecimalsCoinInfo.ExtendedDenom, + sixDecimalsCoinInfo.GetExtendedDenom(), ).Return(returnedCoin) }, }, { name: "success - does not convert 18 decimals amount", coinInfo: eighteenDecimalsCoinInfo, - evmDenom: eighteenDecimalsCoinInfo.Denom, - expCoin: sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)), + evmDenom: eighteenDecimalsCoinInfo.GetDenom(), + expCoin: sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)), expErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - returnedCoin := sdk.NewCoin(eighteenDecimalsCoinInfo.Denom, sdkmath.NewInt(1e18)) + returnedCoin := sdk.NewCoin(eighteenDecimalsCoinInfo.GetDenom(), sdkmath.NewInt(1e18)) mbk.EXPECT(). SpendableCoin( gomock.Any(), account, - eighteenDecimalsCoinInfo.Denom, + eighteenDecimalsCoinInfo.GetDenom(), ).Return(returnedCoin) }, }, { name: "success - zero balance", coinInfo: sixDecimalsCoinInfo, - evmDenom: sixDecimalsCoinInfo.Denom, - expCoin: sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(0)), + evmDenom: sixDecimalsCoinInfo.GetDenom(), + expCoin: sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(0)), expErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(0)) + returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(0)) mbk.EXPECT(). SpendableCoin( gomock.Any(), account, - sixDecimalsCoinInfo.ExtendedDenom, + sixDecimalsCoinInfo.GetExtendedDenom(), ).Return(returnedCoin) }, }, { name: "success - small amount (less than 1 full token)", coinInfo: sixDecimalsCoinInfo, - evmDenom: sixDecimalsCoinInfo.Denom, - expCoin: sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e14)), // 0.0001 token in 18 decimals + evmDenom: sixDecimalsCoinInfo.GetDenom(), + expCoin: sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e14)), // 0.0001 token in 18 decimals expErr: "", mockSetup: func(mbk *testutil.MockBankWrapper) { - returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.ExtendedDenom, sdkmath.NewInt(1e14)) // 0.0001 token in 6 decimals + returnedCoin := sdk.NewCoin(sixDecimalsCoinInfo.GetExtendedDenom(), sdkmath.NewInt(1e14)) // 0.0001 token in 6 decimals mbk.EXPECT(). SpendableCoin( gomock.Any(), account, - sixDecimalsCoinInfo.ExtendedDenom, + sixDecimalsCoinInfo.GetExtendedDenom(), ).Return(returnedCoin) }, }, @@ -831,11 +837,12 @@ func TestSppendableCoin(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - // Setup EVM configurator to have access to the EVM coin info. - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + err := evmConfig.Apply() + require.NoError(t, err, "failed to apply EvmConfig") + err = evmtypes.SetEVMCoinInfo(tc.coinInfo) + require.NoError(t, err, "failed to set EvmCoinInfo") // Setup mock controller ctrl := gomock.NewController(t) diff --git a/x/vm/wrappers/feemarket_test.go b/x/vm/wrappers/feemarket_test.go index 710f905ff..7463b1fca 100644 --- a/x/vm/wrappers/feemarket_test.go +++ b/x/vm/wrappers/feemarket_test.go @@ -7,8 +7,10 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" - testconstants "github.com/cosmos/evm/testutil/constants" + evmconfig "github.com/cosmos/evm/config" + testconfig "github.com/cosmos/evm/testutil/config" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" + "github.com/cosmos/evm/x/vm/types" evmtypes "github.com/cosmos/evm/x/vm/types" "github.com/cosmos/evm/x/vm/wrappers" "github.com/cosmos/evm/x/vm/wrappers/testutil" @@ -27,7 +29,7 @@ func TestGetBaseFee(t *testing.T) { }{ { name: "success - does not convert 18 decimals", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID], expResult: big.NewInt(1e18), // 1 token in 18 decimals mockSetup: func(mfk *testutil.MockFeeMarketKeeper) { mfk.EXPECT(). @@ -37,7 +39,7 @@ func TestGetBaseFee(t *testing.T) { }, { name: "success - convert 6 decimals to 18 decimals", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], expResult: big.NewInt(1e18), // 1 token in 18 decimals mockSetup: func(mfk *testutil.MockFeeMarketKeeper) { mfk.EXPECT(). @@ -47,7 +49,7 @@ func TestGetBaseFee(t *testing.T) { }, { name: "success - nil base fee", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], expResult: nil, mockSetup: func(mfk *testutil.MockFeeMarketKeeper) { mfk.EXPECT(). @@ -57,7 +59,7 @@ func TestGetBaseFee(t *testing.T) { }, { name: "success - small amount 18 decimals", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], expResult: big.NewInt(1e12), // 0.000001 token in 18 decimals mockSetup: func(mfk *testutil.MockFeeMarketKeeper) { mfk.EXPECT(). @@ -67,7 +69,7 @@ func TestGetBaseFee(t *testing.T) { }, { name: "success - base fee is zero", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], expResult: big.NewInt(0), mockSetup: func(mfk *testutil.MockFeeMarketKeeper) { mfk.EXPECT(). @@ -77,7 +79,7 @@ func TestGetBaseFee(t *testing.T) { }, { name: "success - truncate decimals with number less than 1", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], expResult: big.NewInt(0), // 0.000001 token in 18 decimals mockSetup: func(mfk *testutil.MockFeeMarketKeeper) { mfk.EXPECT(). @@ -89,11 +91,11 @@ func TestGetBaseFee(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - // Setup EVM configurator to have access to the EVM coin info. - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + require.NoError(t, evmConfig.Apply(), "failed to apply EvmConfig") + err := types.SetEVMCoinInfo(tc.coinInfo) + require.NoError(t, err) ctrl := gomock.NewController(t) mockFeeMarketKeeper := testutil.NewMockFeeMarketKeeper(ctrl) @@ -117,7 +119,7 @@ func TestCalculateBaseFee(t *testing.T) { }{ { name: "success - does not convert 18 decimals", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID], expResult: big.NewInt(1e18), // 1 token in 18 decimals mockSetup: func(mfk *testutil.MockFeeMarketKeeper) { mfk.EXPECT(). @@ -127,7 +129,7 @@ func TestCalculateBaseFee(t *testing.T) { }, { name: "success - convert 6 decimals to 18 decimals", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], expResult: big.NewInt(1e18), // 1 token in 18 decimals mockSetup: func(mfk *testutil.MockFeeMarketKeeper) { mfk.EXPECT(). @@ -137,7 +139,7 @@ func TestCalculateBaseFee(t *testing.T) { }, { name: "success - nil base fee", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], expResult: nil, mockSetup: func(mfk *testutil.MockFeeMarketKeeper) { mfk.EXPECT(). @@ -147,7 +149,7 @@ func TestCalculateBaseFee(t *testing.T) { }, { name: "success - small amount 18 decimals", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], expResult: big.NewInt(1e12), // 0.000001 token in 18 decimals mockSetup: func(mfk *testutil.MockFeeMarketKeeper) { mfk.EXPECT(). @@ -157,7 +159,7 @@ func TestCalculateBaseFee(t *testing.T) { }, { name: "success - base fee is zero", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], expResult: big.NewInt(0), mockSetup: func(mfk *testutil.MockFeeMarketKeeper) { mfk.EXPECT(). @@ -167,7 +169,7 @@ func TestCalculateBaseFee(t *testing.T) { }, { name: "success - truncate decimals with number less than 1", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], expResult: big.NewInt(0), // 0.000001 token in 18 decimals mockSetup: func(mfk *testutil.MockFeeMarketKeeper) { mfk.EXPECT(). @@ -179,11 +181,13 @@ func TestCalculateBaseFee(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - // Setup EVM configurator to have access to the EVM coin info. - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + // Setup EVM evmConfig to have access to the EVM coin info. + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + err := evmConfig.Apply() + require.NoError(t, err, "failed to apply EvmConfig") + err = types.SetEVMCoinInfo(tc.coinInfo) + require.NoError(t, err) ctrl := gomock.NewController(t) mockFeeMarketKeeper := testutil.NewMockFeeMarketKeeper(ctrl) @@ -206,7 +210,7 @@ func TestGetParams(t *testing.T) { }{ { name: "success - convert 6 decimals to 18 decimals", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID], expParams: feemarkettypes.Params{ BaseFee: sdkmath.LegacyNewDec(1e18), MinGasPrice: sdkmath.LegacyNewDec(1e18), @@ -222,7 +226,7 @@ func TestGetParams(t *testing.T) { }, { name: "success - does not convert 18 decimals", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID], expParams: feemarkettypes.Params{ BaseFee: sdkmath.LegacyNewDec(1e18), MinGasPrice: sdkmath.LegacyNewDec(1e18), @@ -238,7 +242,7 @@ func TestGetParams(t *testing.T) { }, { name: "success - nil base fee", - coinInfo: testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID], + coinInfo: testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID], expParams: feemarkettypes.Params{ MinGasPrice: sdkmath.LegacyNewDec(1e18), }, @@ -254,11 +258,13 @@ func TestGetParams(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - // Setup EVM configurator to have access to the EVM coin info. - configurator := evmtypes.NewEVMConfigurator() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + // Setup EVM evmConfig to have access to the EVM coin info. + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + err := evmConfig.Apply() + require.NoError(t, err, "failed to apply EvmConfig") + err = types.SetEVMCoinInfo(tc.coinInfo) + require.NoError(t, err) ctrl := gomock.NewController(t) mockFeeMarketKeeper := testutil.NewMockFeeMarketKeeper(ctrl)