From feb4e7417e1ffebd660d764b5fe7297d0e6eb0e3 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 04:09:34 -0400 Subject: [PATCH 01/27] move sdk setup to root cmd from main --- evmd/cmd/evmd/cmd/root.go | 7 +++++++ evmd/cmd/evmd/main.go | 9 --------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/evmd/cmd/evmd/cmd/root.go b/evmd/cmd/evmd/cmd/root.go index 8a540cf0a..70460c752 100644 --- a/evmd/cmd/evmd/cmd/root.go +++ b/evmd/cmd/evmd/cmd/root.go @@ -51,6 +51,7 @@ import ( // NewRootCmd creates a new root command for evmd. It is called once in the // main function. func NewRootCmd() *cobra.Command { + 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 @@ -156,6 +157,12 @@ func NewRootCmd() *cobra.Command { return rootCmd } +func setupSDKConfig() { + config := sdk.GetConfig() + evmdconfig.SetBech32Prefixes(config) + config.Seal() +} + // initCometConfig helps to override default CometBFT Config values. // return cmtcfg.DefaultConfig if no custom configuration is required for the application. func initCometConfig() *cmtcfg.Config { diff --git a/evmd/cmd/evmd/main.go b/evmd/cmd/evmd/main.go index 0669a5891..cd63910e1 100644 --- a/evmd/cmd/evmd/main.go +++ b/evmd/cmd/evmd/main.go @@ -8,21 +8,12 @@ import ( 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() -} From ad897410356a15fcc3300e684aed0bd7a42a31c2 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 04:32:08 -0400 Subject: [PATCH 02/27] refactor evmcoininfo and evmconfigurator --- x/vm/types/chain_config.go | 2 +- x/vm/types/coin_info.go | 78 +++++++++++++ x/vm/types/coin_info_test.go | 179 +++++++++++++++++++++++++++++ x/vm/types/config.go | 14 +-- x/vm/types/config_testing.go | 14 +-- x/vm/types/configurator.go | 24 ++-- x/vm/types/configurator_test.go | 36 +++--- x/vm/types/denom.go | 51 +++++--- x/vm/types/denom_config.go | 46 +++----- x/vm/types/denom_config_testing.go | 46 +++----- x/vm/types/msg_test.go | 4 +- x/vm/types/scaling_test.go | 42 +++---- x/vm/wrappers/bank_test.go | 172 +++++++++++++-------------- x/vm/wrappers/feemarket_test.go | 18 +-- 14 files changed, 486 insertions(+), 240 deletions(-) create mode 100644 x/vm/types/coin_info.go create mode 100644 x/vm/types/coin_info_test.go diff --git a/x/vm/types/chain_config.go b/x/vm/types/chain_config.go index 6a9877340..f81f19942 100644 --- a/x/vm/types/chain_config.go +++ b/x/vm/types/chain_config.go @@ -113,7 +113,7 @@ 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") diff --git a/x/vm/types/coin_info.go b/x/vm/types/coin_info.go new file mode 100644 index 000000000..d03b53e23 --- /dev/null +++ b/x/vm/types/coin_info.go @@ -0,0 +1,78 @@ +package types + +import ( + "errors" + "fmt" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/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 `mapstructure:"display-denom"` + // Decimals defines the precision/decimals for the base denomination (1-18) + Decimals Decimals `mapstructure:"decimals"` + // ExtendedDecimals defines the precision/decimals for the extended denomination (typically 18 decimals for atto-denom) + ExtendedDecimals Decimals `mapstructure:"extended-decimals"` +} + +// Validate returns an error if the coin configuration fields are invalid. +func (c EvmCoinInfo) Validate() error { + if err := c.Decimals.Validate(); err != nil { + return fmt.Errorf("decimals validation failed: %w", err) + } + if err := c.ExtendedDecimals.Validate(); err != nil { + return fmt.Errorf("extended decimals validation failed: %w", err) + } + + denom := c.GetDenom() + if strings.HasPrefix(denom, "invalid") { + return errors.New("invalid denom, not a valid SI decimal, so denom cannot be derived") + } + if err := sdk.ValidateDenom(denom); err != nil { + return fmt.Errorf("invalid denom: %w", err) + } + + extendedDenom := c.GetExtendedDenom() + if strings.HasPrefix(extendedDenom, "invalid") { + return errors.New("invalid extended denom, not a valid SI decimal, so extended denom cannot be derived") + } + if err := sdk.ValidateDenom(extendedDenom); err != nil { + return fmt.Errorf("invalid extended denom: %w", err) + } + + if c.DisplayDenom == "" { + return errors.New("display-denom cannot be empty") + } + if err := sdk.ValidateDenom(c.DisplayDenom); err != nil { + return fmt.Errorf("invalid display denom: %w", err) + } + + // For 18 decimals, denom and extended denom should be the same, as higher decimals are not supported + if c.Decimals == EighteenDecimals { + if c.Decimals != c.ExtendedDecimals { + return errors.New("decimals and extended decimals must be the same for 18 decimals") + } + if c.GetDenom() != c.GetExtendedDenom() { + return errors.New("denom and extended denom must be the same for 18 decimals") + } + } + + return nil +} + +// GetDenom returns the base denomination used in the chain, derived by SI prefix +func (c EvmCoinInfo) GetDenom() string { + return CreateDenomStr(c.Decimals, c.DisplayDenom) +} + +// GetExtendedDenom returns the extended denomination used in the chain, derived by SI prefix +func (c EvmCoinInfo) GetExtendedDenom() string { + return CreateDenomStr(c.ExtendedDecimals, c.DisplayDenom) +} + +func CreateDenomStr(decimals Decimals, displayDenom string) string { + return decimals.GetSIPrefix() + displayDenom +} 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..928c27881 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 @@ -14,12 +10,12 @@ import ( 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 +// 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") + return fmt.Errorf("error applying EvmConfig: already sealed and cannot be modified") } if err := setChainConfig(ec.chainConfig); err != nil { @@ -45,7 +41,7 @@ func (ec *EVMConfigurator) Configure() error { 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..dc95ff1e7 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,12 +15,12 @@ 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") + return fmt.Errorf("error applying EvmConfig: already sealed and cannot be modified") } if err := setTestChainConfig(ec.chainConfig); err != nil { @@ -50,7 +46,7 @@ func (ec *EVMConfigurator) Configure() error { return nil } -func (ec *EVMConfigurator) ResetTestConfig() { +func (ec *EvmConfig) ResetTestConfig() { vm.ResetActivators() resetEVMCoinInfo() testChainConfig = nil diff --git a/x/vm/types/configurator.go b/x/vm/types/configurator.go index 44c1fd8ed..5c3c23a7f 100644 --- a/x/vm/types/configurator.go +++ b/x/vm/types/configurator.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. - package types import ( @@ -11,10 +7,10 @@ import ( "github.com/ethereum/go-ethereum/core/vm" ) -// EVMConfigurator allows to extend x/evm module configurations. The configurator modifies +// 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 EVMConfigurator struct { +type EvmConfig struct { sealed bool extendedEIPs map[int]func(*vm.JumpTable) extendedDefaultExtraEIPs []int64 @@ -22,35 +18,35 @@ type EVMConfigurator struct { evmCoinInfo EvmCoinInfo } -// NewEVMConfigurator returns a pointer to a new EVMConfigurator object. -func NewEVMConfigurator() *EVMConfigurator { - return &EVMConfigurator{} +// NewEvmConfig returns a pointer to a new EvmConfig object. +func NewEvmConfig() *EvmConfig { + return &EvmConfig{} } // 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 { +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 *EVMConfigurator) WithExtendedDefaultExtraEIPs(eips ...int64) *EVMConfigurator { +func (ec *EvmConfig) WithExtendedDefaultExtraEIPs(eips ...int64) *EvmConfig { 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 { +func (ec *EvmConfig) WithChainConfig(cc *ChainConfig) *EvmConfig { 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 { +func (ec *EvmConfig) WithEVMCoinInfo(coinInfo EvmCoinInfo) *EvmConfig { ec.evmCoinInfo = coinInfo return ec } @@ -58,7 +54,7 @@ func (ec *EVMConfigurator) WithEVMCoinInfo(coinInfo EvmCoinInfo) *EVMConfigurato 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) + return fmt.Errorf("error applying EvmConfig: EIP %d is already present in the default list: %v", eip, DefaultExtraEIPs) } DefaultExtraEIPs = append(DefaultExtraEIPs, eip) diff --git a/x/vm/types/configurator_test.go b/x/vm/types/configurator_test.go index 8ba74f536..16d621348 100644 --- a/x/vm/types/configurator_test.go +++ b/x/vm/types/configurator_test.go @@ -10,13 +10,13 @@ import ( "github.com/cosmos/evm/x/vm/types" ) -func TestEVMConfigurator(t *testing.T) { - evmConfigurator := types.NewEVMConfigurator(). +func TestEvmConfigApply(t *testing.T) { + evmConfigurator := types.NewEvmConfig(). WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]) - err := evmConfigurator.Configure() + err := evmConfigurator.Apply() require.NoError(t, err) - err = evmConfigurator.Configure() + err = evmConfigurator.Apply() require.Error(t, err) require.Contains(t, err.Error(), "sealed", "expected different error") } @@ -24,17 +24,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(). + ec := types.NewEvmConfig(). WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). WithExtendedEips(extendedEIPs) return ec @@ -44,11 +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(). + ec := types.NewEvmConfig(). WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). WithExtendedEips(extendedEIPs) return ec @@ -61,7 +61,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,17 +76,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(). + ec := types.NewEvmConfig(). WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec @@ -100,9 +100,9 @@ func TestExtendedDefaultExtraEips(t *testing.T) { }, { "success - empty default extra eip", - func() *types.EVMConfigurator { + func() *types.EvmConfig { var extendedDefaultExtraEIPs []int64 - ec := types.NewEVMConfigurator(). + ec := types.NewEvmConfig(). WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec @@ -115,9 +115,9 @@ func TestExtendedDefaultExtraEips(t *testing.T) { }, { "success - extra default eip added", - func() *types.EVMConfigurator { + func() *types.EvmConfig { extendedDefaultExtraEIPs := []int64{1001} - ec := types.NewEVMConfigurator(). + ec := types.NewEvmConfig(). WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec @@ -135,7 +135,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/denom.go b/x/vm/types/denom.go index b4d5d68dc..0119ce460 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,27 @@ 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" + } } diff --git a/x/vm/types/denom_config.go b/x/vm/types/denom_config.go index 04ff3fe8b..f32c29df6 100644 --- a/x/vm/types/denom_config.go +++ b/x/vm/types/denom_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 @@ -15,7 +11,7 @@ import ( ) // 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. +// can only be set via `EvmConfig.Apply` before starting the app. var evmCoinInfo *EvmCoinInfo // setEVMCoinDecimals allows to define the decimals used in the representation @@ -29,21 +25,12 @@ func setEVMCoinDecimals(d Decimals) error { 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 { +// setEVMCoinExtendedDecimals allows to define the extended denom of the coin used in the EVM. +func setEVMCoinExtendedDecimals(d Decimals) error { + if err := d.Validate(); err != nil { return err } - evmCoinInfo.ExtendedDenom = extendedDenom + evmCoinInfo.ExtendedDecimals = d return nil } @@ -61,14 +48,20 @@ func GetEVMCoinDecimals() Decimals { return evmCoinInfo.Decimals } +// GetEVMCoinExtendedDecimals returns the extended decimals used in the +// representation of the EVM coin. +func GetEVMCoinExtendedDecimals() Decimals { + return evmCoinInfo.ExtendedDecimals +} + // GetEVMCoinDenom returns the denom used for the EVM coin. func GetEVMCoinDenom() string { - return evmCoinInfo.Denom + return evmCoinInfo.GetDenom() } // GetEVMCoinExtendedDenom returns the extended denom used for the EVM coin. func GetEVMCoinExtendedDenom() string { - return evmCoinInfo.ExtendedDenom + return evmCoinInfo.GetExtendedDenom() } // GetEVMCoinDisplayDenom returns the display denom used for the EVM coin. @@ -83,21 +76,18 @@ func setEVMCoinInfo(eci EvmCoinInfo) error { } 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") + if eci.Decimals != eci.ExtendedDecimals { + return errors.New("EVM coin decimals and extended decimals 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 { + if err := setEVMCoinDecimals(eci.Decimals); err != nil { return err } - if err := setDisplayDenom(eci.DisplayDenom); err != nil { + if err := setEVMCoinExtendedDecimals(eci.ExtendedDecimals); err != nil { return err } - return setEVMCoinDecimals(eci.Decimals) + return setDisplayDenom(eci.DisplayDenom) } diff --git a/x/vm/types/denom_config_testing.go b/x/vm/types/denom_config_testing.go index 66b849c0c..8633fdaf2 100644 --- a/x/vm/types/denom_config_testing.go +++ b/x/vm/types/denom_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 @@ -15,7 +11,7 @@ import ( ) // 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. +// can only be set via `EvmConfig.Apply` before starting the app. var testingEvmCoinInfo *EvmCoinInfo // setEVMCoinDecimals allows to define the decimals used in the representation @@ -29,21 +25,12 @@ func setEVMCoinDecimals(d Decimals) error { 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 { +// setEVMCoinExtendedDecimals allows to define the extended denom of the coin used in the EVM. +func setEVMCoinExtendedDecimals(d Decimals) error { + if err := d.Validate(); err != nil { return err } - testingEvmCoinInfo.ExtendedDenom = extendedDenom + testingEvmCoinInfo.ExtendedDecimals = d return nil } @@ -61,14 +48,20 @@ 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.Denom + return testingEvmCoinInfo.GetDenom() } // GetEVMCoinExtendedDenom returns the extended denom used for the EVM coin. func GetEVMCoinExtendedDenom() string { - return testingEvmCoinInfo.ExtendedDenom + return testingEvmCoinInfo.GetExtendedDenom() } // GetEVMCoinDisplayDenom returns the display denom used for the EVM coin. @@ -83,23 +76,20 @@ func setTestingEVMCoinInfo(eci EvmCoinInfo) error { } 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") + if eci.Decimals != eci.ExtendedDecimals { + return errors.New("EVM coin decimals and extended decimals 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 { + if err := setEVMCoinDecimals(eci.Decimals); err != nil { return err } - if err := setDisplayDenom(eci.DisplayDenom); err != nil { + if err := setEVMCoinExtendedDecimals(eci.ExtendedDecimals); err != nil { return err } - return setEVMCoinDecimals(eci.Decimals) + return setDisplayDenom(eci.DisplayDenom) } // resetEVMCoinInfo resets to nil the testingEVMCoinInfo diff --git a/x/vm/types/msg_test.go b/x/vm/types/msg_test.go index 2692b3edb..a16dd0762 100644 --- a/x/vm/types/msg_test.go +++ b/x/vm/types/msg_test.go @@ -116,9 +116,9 @@ func (suite *MsgsTestSuite) TestMsgEthereumTx_BuildTx() { testconstants.ExampleChainCoinInfo[testconstants.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..7eb47cf76 100644 --- a/x/vm/types/scaling_test.go +++ b/x/vm/types/scaling_test.go @@ -20,8 +20,8 @@ func TestConvertEvmCoinFrom18Decimals(t *testing.T) { eighteenDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] sixDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] - 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 +42,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 +75,9 @@ func TestConvertEvmCoinFrom18Decimals(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(tc.evmCoinInfo).Configure()) + require.NoError(t, configurator.WithEVMCoinInfo(tc.evmCoinInfo).Apply()) coinConverted, err := evmtypes.ConvertEvmCoinDenomToExtendedDenom(tc.coin) @@ -96,8 +96,8 @@ func TestConvertCoinsFrom18Decimals(t *testing.T) { sixDecimalsCoinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] 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 +121,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 +133,15 @@ 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 := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(tc.evmCoinInfo).Configure()) + require.NoError(t, configurator.WithEVMCoinInfo(tc.evmCoinInfo).Apply()) coinConverted := evmtypes.ConvertCoinsDenomToExtendedDenom(tc.coins) require.Equal(t, tc.expCoins, coinConverted, "expected a different coin") @@ -188,9 +188,9 @@ func TestConvertAmountTo18DecimalsLegacy(t *testing.T) { } { for _, tc := range testCases { t.Run(fmt.Sprintf("%d dec - %s", coinInfo.Decimals, tc.name), func(t *testing.T) { - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(coinInfo).Configure()) + require.NoError(t, configurator.WithEVMCoinInfo(coinInfo).Apply()) res := evmtypes.ConvertBigIntFrom18DecimalsToLegacyDec(tc.amt.ToBig()) exp := math.LegacyNewDecFromBigInt(tc.amt.ToBig()) if coinInfo.Decimals == evmtypes.SixDecimals { @@ -226,9 +226,9 @@ func TestConvertAmountTo18DecimalsBigInt(t *testing.T) { } { for _, tc := range testCases { t.Run(fmt.Sprintf("%d dec - %s", coinInfo.Decimals, tc.name), func(t *testing.T) { - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(coinInfo).Configure()) + require.NoError(t, configurator.WithEVMCoinInfo(coinInfo).Apply()) 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..8a6ff4a0b 100644 --- a/x/vm/wrappers/bank_test.go +++ b/x/vm/wrappers/bank_test.go @@ -38,12 +38,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 +62,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 +86,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(). @@ -104,10 +104,10 @@ 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 := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + require.NoError(t, err, "failed to apply EvmConfig") // Setup mock controller ctrl := gomock.NewController(t) @@ -146,7 +146,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 +168,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 +190,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 +208,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(). @@ -225,10 +225,10 @@ 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 := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + require.NoError(t, err, "failed to apply EvmConfig") // Setup mock controller ctrl := gomock.NewController(t) @@ -266,14 +266,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 +290,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 +314,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 +322,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 +340,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 +348,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 +366,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 }, @@ -386,10 +386,10 @@ 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 := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + require.NoError(t, err, "failed to apply EvmConfig") // Setup mock controller ctrl := gomock.NewController(t) @@ -427,14 +427,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 +451,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 +475,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 +483,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 +501,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 +509,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 +527,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 }, @@ -547,10 +547,10 @@ 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 := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + require.NoError(t, err, "failed to apply EvmConfig") // Setup mock controller ctrl := gomock.NewController(t) @@ -591,85 +591,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) }, }, @@ -685,10 +685,10 @@ 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 := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + require.NoError(t, err, "failed to apply EvmConfig") // Setup mock controller ctrl := gomock.NewController(t) @@ -738,85 +738,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) }, }, @@ -832,10 +832,10 @@ 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 := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + require.NoError(t, err, "failed to apply EvmConfig") // 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..6486e51f2 100644 --- a/x/vm/wrappers/feemarket_test.go +++ b/x/vm/wrappers/feemarket_test.go @@ -90,10 +90,10 @@ 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 := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + require.NoError(t, err, "failed to apply EvmConfig") ctrl := gomock.NewController(t) mockFeeMarketKeeper := testutil.NewMockFeeMarketKeeper(ctrl) @@ -180,10 +180,10 @@ 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 := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + require.NoError(t, err, "failed to apply EvmConfig") ctrl := gomock.NewController(t) mockFeeMarketKeeper := testutil.NewMockFeeMarketKeeper(ctrl) @@ -255,10 +255,10 @@ 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 := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Configure() - require.NoError(t, err, "failed to configure EVMConfigurator") + err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + require.NoError(t, err, "failed to apply EvmConfig") ctrl := gomock.NewController(t) mockFeeMarketKeeper := testutil.NewMockFeeMarketKeeper(ctrl) From 4d0136cd6b10cbffd26a23cab411a4f7403c1967 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 04:32:31 -0400 Subject: [PATCH 03/27] update evmcoininfo usage --- ante/cosmos/authz_test.go | 4 +- config/evm_app_options.go | 8 +-- ethereum/eip712/preprocess_test.go | 4 +- evmd/cmd/evmd/config/config.go | 21 ++++---- evmd/eips/README.md | 10 ++-- evmd/tests/integration/x_vm_test.go | 14 +++--- precompiles/common/balance_handler_test.go | 4 +- tests/integration/ante/ante_test_suite.go | 14 +++--- .../ante/test_evm_unit_04_validate.go | 4 +- .../precompiles/werc20/test_integration.go | 4 +- .../x/precisebank/test_burn_integration.go | 4 +- .../x/precisebank/test_mint_integration.go | 4 +- .../x/precisebank/test_send_integration.go | 4 +- tests/integration/x/vm/keeper_test_suite.go | 14 +++--- tests/integration/x/vm/test_grpc_query.go | 15 +++--- testutil/config/config.go | 14 +++--- testutil/config/config_testing.go | 49 ++++++++----------- testutil/constants/constants.go | 28 +++++------ .../evm/network/chain_id_modifiers.go | 2 +- testutil/integration/evm/network/coins.go | 2 +- testutil/integration/evm/network/config.go | 4 +- utils/utils_test.go | 4 +- x/precisebank/types/extended_balance_test.go | 4 +- x/precisebank/types/genesis_test.go | 8 +-- 24 files changed, 110 insertions(+), 133 deletions(-) diff --git a/ante/cosmos/authz_test.go b/ante/cosmos/authz_test.go index aee72f910..1930f2077 100644 --- a/ante/cosmos/authz_test.go +++ b/ante/cosmos/authz_test.go @@ -21,9 +21,9 @@ import ( ) func TestAuthzLimiterDecorator(t *testing.T) { - evmConfigurator := evmtypes.NewEVMConfigurator(). + evmConfigurator := evmtypes.NewEvmConfig(). WithEVMCoinInfo(constants.ExampleChainCoinInfo[constants.ExampleChainID]) - err := evmConfigurator.Configure() + err := evmConfigurator.Apply() require.NoError(t, err) encodingCfg := encoding.MakeConfig(constants.ExampleChainID.EVMChainID) diff --git a/config/evm_app_options.go b/config/evm_app_options.go index 63b06dbc6..3c95e91db 100644 --- a/config/evm_app_options.go +++ b/config/evm_app_options.go @@ -53,7 +53,7 @@ func EvmAppOptionsWithConfigWithReset( } ethCfg := evmtypes.DefaultChainConfig(chainID) - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() if withReset { // reset configuration to set the new one configurator.ResetTestConfig() @@ -63,7 +63,7 @@ func EvmAppOptionsWithConfigWithReset( WithChainConfig(ethCfg). // NOTE: we're using the 18 decimals default for the example chain WithEVMCoinInfo(coinInfo). - Configure() + Apply() if err != nil { return err } @@ -79,7 +79,7 @@ func setBaseDenom(ci evmtypes.EvmCoinInfo) (err error) { // 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) + err = sdk.SetBaseDenom(ci.GetDenom()) }() if err := sdk.RegisterDenom(ci.DisplayDenom, math.LegacyOneDec()); err != nil { return err @@ -87,5 +87,5 @@ func setBaseDenom(ci evmtypes.EvmCoinInfo) (err error) { // 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))) + return sdk.RegisterDenom(ci.GetDenom(), math.LegacyNewDecWithPrec(1, int64(ci.Decimals))) } diff --git a/ethereum/eip712/preprocess_test.go b/ethereum/eip712/preprocess_test.go index c0376fda0..e355d6787 100644 --- a/ethereum/eip712/preprocess_test.go +++ b/ethereum/eip712/preprocess_test.go @@ -56,9 +56,9 @@ type TestCaseStruct struct { func TestLedgerPreprocessing(t *testing.T) { // Update bech32 prefix sdk.GetConfig().SetBech32PrefixForAccount(constants.ExampleBech32Prefix, "") - evmConfigurator := evmtypes.NewEVMConfigurator(). + evmConfigurator := evmtypes.NewEvmConfig(). WithEVMCoinInfo(constants.ExampleChainCoinInfo[constants.ExampleChainID]) - err := evmConfigurator.Configure() + err := evmConfigurator.Apply() require.NoError(t, err) testCases := []TestCaseStruct{ diff --git a/evmd/cmd/evmd/config/config.go b/evmd/cmd/evmd/config/config.go index 2699ca0b6..a5b042d07 100644 --- a/evmd/cmd/evmd/config/config.go +++ b/evmd/cmd/evmd/config/config.go @@ -12,24 +12,21 @@ import ( // chain id var ChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ EighteenDecimalsChainID: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, + DisplayDenom: ExampleDisplayDenom, + Decimals: evmtypes.EighteenDecimals, + ExtendedDecimals: 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, + DisplayDenom: "test", + Decimals: evmtypes.SixDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, // EVMChainID provides a chain ID used for internal testing EVMChainID: { - Denom: "atest", - ExtendedDenom: "atest", - DisplayDenom: "test", - Decimals: evmtypes.EighteenDecimals, + DisplayDenom: "test", + Decimals: evmtypes.EighteenDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, } diff --git a/evmd/eips/README.md b/evmd/eips/README.md index ac498503e..93f5572d8 100644 --- a/evmd/eips/README.md +++ b/evmd/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/evmd/tests/integration/x_vm_test.go b/evmd/tests/integration/x_vm_test.go index c1aec6e9f..a95c07391 100644 --- a/evmd/tests/integration/x_vm_test.go +++ b/evmd/tests/integration/x_vm_test.go @@ -35,22 +35,20 @@ func BenchmarkGasEstimation(b *testing.B) { chainConfig := types.DefaultChainConfig(nw.GetEIP155ChainID().Uint64()) // 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 := types.NewEvmConfig() configurator.ResetTestConfig() err := configurator. 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/precompiles/common/balance_handler_test.go b/precompiles/common/balance_handler_test.go index c0ea5fe0b..c00e74fb2 100644 --- a/precompiles/common/balance_handler_test.go +++ b/precompiles/common/balance_handler_test.go @@ -30,9 +30,9 @@ func setupBalanceHandlerTest(t *testing.T) { t.Helper() sdk.GetConfig().SetBech32PrefixForAccount(testconstants.ExampleBech32Prefix, "") - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]).Configure()) + require.NoError(t, configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]).Apply()) } func TestParseAddress(t *testing.T) { diff --git a/tests/integration/ante/ante_test_suite.go b/tests/integration/ante/ante_test_suite.go index d6a72cfa3..0fb9db71c 100644 --- a/tests/integration/ante/ante_test_suite.go +++ b/tests/integration/ante/ante_test_suite.go @@ -114,22 +114,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/test_evm_unit_04_validate.go b/tests/integration/ante/test_evm_unit_04_validate.go index 8e87308cd..81e06a937 100644 --- a/tests/integration/ante/test_evm_unit_04_validate.go +++ b/tests/integration/ante/test_evm_unit_04_validate.go @@ -244,9 +244,9 @@ func (s *EvmUnitAnteTestSuite) TestCheckTxFee() { 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(testconstants.ExampleChainCoinInfo[chainID]).Apply()) // If decimals is not 18 decimals, we have to convert txFeeInfo to original // decimals representation. diff --git a/tests/integration/precompiles/werc20/test_integration.go b/tests/integration/precompiles/werc20/test_integration.go index 686bdb65f..ebcd75f5a 100644 --- a/tests/integration/precompiles/werc20/test_integration.go +++ b/tests/integration/precompiles/werc20/test_integration.go @@ -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") + Apply()).To(BeNil(), "expected no error setting the evm configurator") opts := []network.ConfigOption{ network.WithChainID(chainId), diff --git a/tests/integration/x/precisebank/test_burn_integration.go b/tests/integration/x/precisebank/test_burn_integration.go index 65b57f5da..852b60f59 100644 --- a/tests/integration/x/precisebank/test_burn_integration.go +++ b/tests/integration/x/precisebank/test_burn_integration.go @@ -498,10 +498,10 @@ func (s *KeeperIntegrationTestSuite) TestBurnCoinsRandomValueMultiDecimals() { } func FuzzBurnCoins(f *testing.F) { - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) - err := configurator.Configure() + err := configurator.Apply() require.NoError(f, err) f.Add(int64(0)) diff --git a/tests/integration/x/precisebank/test_mint_integration.go b/tests/integration/x/precisebank/test_mint_integration.go index 0458f1299..de411877d 100644 --- a/tests/integration/x/precisebank/test_mint_integration.go +++ b/tests/integration/x/precisebank/test_mint_integration.go @@ -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() + 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..b09919497 100644 --- a/tests/integration/x/precisebank/test_send_integration.go +++ b/tests/integration/x/precisebank/test_send_integration.go @@ -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() + err := configurator.Apply() require.NoError(f, err) f.Add(uint64(100), uint64(0), uint64(2)) diff --git a/tests/integration/x/vm/keeper_test_suite.go b/tests/integration/x/vm/keeper_test_suite.go index 8f3f3b39a..5347cdf4f 100644 --- a/tests/integration/x/vm/keeper_test_suite.go +++ b/tests/integration/x/vm/keeper_test_suite.go @@ -101,21 +101,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_grpc_query.go b/tests/integration/x/vm/test_grpc_query.go index f9b55fac3..59f874d9b 100644 --- a/tests/integration/x/vm/test_grpc_query.go +++ b/tests/integration/x/vm/test_grpc_query.go @@ -1602,12 +1602,12 @@ func (s *KeeperTestSuite) TestQueryBaseFee() { chainConfig.CancunTime = &maxInt chainConfig.PragueTime = &maxInt - configurator := types.NewEVMConfigurator() + configurator := types.NewEvmConfig() configurator.ResetTestConfig() err := configurator. WithChainConfig(chainConfig). WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). - Configure() + Apply() s.Require().NoError(err) }, true, @@ -1632,10 +1632,9 @@ 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()) @@ -1658,12 +1657,12 @@ func (s *KeeperTestSuite) TestQueryBaseFee() { s.Require().Error(err) } s.Require().NoError(s.Network.NextBlock()) - configurator := types.NewEVMConfigurator() + configurator := types.NewEvmConfig() configurator.ResetTestConfig() err = configurator. WithChainConfig(chainConfig). WithEVMCoinInfo(coinInfo). - Configure() + Apply() s.Require().NoError(err) }) } diff --git a/testutil/config/config.go b/testutil/config/config.go index 7ea385bdb..54fcdd69b 100644 --- a/testutil/config/config.go +++ b/testutil/config/config.go @@ -12,16 +12,14 @@ import ( // chain id var ChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ EighteenDecimalsChainID: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, + DisplayDenom: ExampleDisplayDenom, + Decimals: evmtypes.EighteenDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, EVMChainID: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, + DisplayDenom: ExampleDisplayDenom, + Decimals: evmtypes.EighteenDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, } diff --git a/testutil/config/config_testing.go b/testutil/config/config_testing.go index e37568c2b..9781099fa 100644 --- a/testutil/config/config_testing.go +++ b/testutil/config/config_testing.go @@ -13,46 +13,39 @@ import ( // chain id var TestChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ EighteenDecimalsChainID: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, + DisplayDenom: ExampleDisplayDenom, + Decimals: evmtypes.EighteenDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, SixDecimalsChainID: { - Denom: "utest", - ExtendedDenom: "atest", - DisplayDenom: "test", - Decimals: evmtypes.SixDecimals, + DisplayDenom: "test", + Decimals: evmtypes.SixDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, TwelveDecimalsChainID: { - Denom: "ptest2", - ExtendedDenom: "atest2", - DisplayDenom: "test2", - Decimals: evmtypes.TwelveDecimals, + DisplayDenom: "test2", + Decimals: evmtypes.TwelveDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, TwoDecimalsChainID: { - Denom: "ctest3", - ExtendedDenom: "atest3", - DisplayDenom: "test3", - Decimals: evmtypes.TwoDecimals, + DisplayDenom: "test3", + Decimals: evmtypes.TwoDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, TestChainID1: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleChainDenom, - Decimals: evmtypes.EighteenDecimals, + DisplayDenom: ExampleChainDenom, + Decimals: evmtypes.EighteenDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, TestChainID2: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleChainDenom, - Decimals: evmtypes.EighteenDecimals, + DisplayDenom: ExampleChainDenom, + Decimals: evmtypes.EighteenDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, EVMChainID: { - Denom: ExampleChainDenom, - ExtendedDenom: ExampleChainDenom, - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, + DisplayDenom: ExampleChainDenom, + Decimals: evmtypes.EighteenDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, } diff --git a/testutil/constants/constants.go b/testutil/constants/constants.go index 1b2cf732a..caba3030c 100644 --- a/testutil/constants/constants.go +++ b/testutil/constants/constants.go @@ -76,28 +76,24 @@ var ( // chain id ExampleChainCoinInfo = map[ChainID]evmtypes.EvmCoinInfo{ ExampleChainID: { - Denom: ExampleAttoDenom, - ExtendedDenom: ExampleAttoDenom, - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, + DisplayDenom: ExampleDisplayDenom, + Decimals: evmtypes.EighteenDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, SixDecimalsChainID: { - Denom: "utest", - ExtendedDenom: "atest", - DisplayDenom: "test", - Decimals: evmtypes.SixDecimals, + DisplayDenom: "test", + Decimals: evmtypes.SixDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, TwelveDecimalsChainID: { - Denom: "ptest2", - ExtendedDenom: "atest2", - DisplayDenom: "test2", - Decimals: evmtypes.TwelveDecimals, + DisplayDenom: "test2", + Decimals: evmtypes.TwelveDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, TwoDecimalsChainID: { - Denom: "ctest3", - ExtendedDenom: "atest3", - DisplayDenom: "test3", - Decimals: evmtypes.TwoDecimals, + DisplayDenom: "test3", + Decimals: evmtypes.TwoDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, }, } diff --git a/testutil/integration/evm/network/chain_id_modifiers.go b/testutil/integration/evm/network/chain_id_modifiers.go index 736c14e5c..94b4714e4 100644 --- a/testutil/integration/evm/network/chain_id_modifiers.go +++ b/testutil/integration/evm/network/chain_id_modifiers.go @@ -91,7 +91,7 @@ func updateErc20TokenPairs(chainID testconstants.ChainID, tokenPairs []erc20type 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..363d21491 100644 --- a/testutil/integration/evm/network/coins.go +++ b/testutil/integration/evm/network/coins.go @@ -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..2ad976fb8 100644 --- a/testutil/integration/evm/network/config.go +++ b/testutil/integration/evm/network/config.go @@ -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/utils/utils_test.go b/utils/utils_test.go index c6d7d331f..a70b4ce63 100644 --- a/utils/utils_test.go +++ b/utils/utils_test.go @@ -489,10 +489,10 @@ func TestAccountEquivalence(t *testing.T) { func TestCalcBaseFee(t *testing.T) { for _, chainID := range []constants.ChainID{constants.ExampleChainID, constants.TwelveDecimalsChainID, constants.SixDecimalsChainID} { t.Run(chainID.ChainID, func(t *testing.T) { - evmConfigurator := evmtypes.NewEVMConfigurator(). + evmConfigurator := evmtypes.NewEvmConfig(). WithEVMCoinInfo(constants.ExampleChainCoinInfo[chainID]) evmConfigurator.ResetTestConfig() - err := evmConfigurator.Configure() + err := evmConfigurator.Apply() require.NoError(t, err) config := ¶ms.ChainConfig{ diff --git a/x/precisebank/types/extended_balance_test.go b/x/precisebank/types/extended_balance_test.go index d0a013f1b..8c92b5dea 100644 --- a/x/precisebank/types/extended_balance_test.go +++ b/x/precisebank/types/extended_balance_test.go @@ -16,10 +16,10 @@ import ( func TestSumExtendedCoin(t *testing.T) { coinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] - configurator := evmtypes.NewEVMConfigurator() + 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..41a5ee80e 100644 --- a/x/precisebank/types/genesis_test.go +++ b/x/precisebank/types/genesis_test.go @@ -256,10 +256,10 @@ func TestGenesisState_TotalAmountWithRemainder(t *testing.T) { } func FuzzGenesisStateValidate_NonZeroRemainder(f *testing.F) { - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) - err := configurator.Configure() + err := configurator.Apply() require.NoError(f, err) f.Add(5) @@ -283,10 +283,10 @@ func FuzzGenesisStateValidate_NonZeroRemainder(f *testing.F) { } func FuzzGenesisStateValidate_ZeroRemainder(f *testing.F) { - configurator := evmtypes.NewEVMConfigurator() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) - err := configurator.Configure() + err := configurator.Apply() require.NoError(f, err) f.Add(5) From 4c1b44f46c5dbc4435b8b45be5d25c1d4eed60d9 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 04:45:46 -0400 Subject: [PATCH 04/27] fix test --- config/chain_config.go | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 config/chain_config.go diff --git a/config/chain_config.go b/config/chain_config.go new file mode 100644 index 000000000..e0c06c0d1 --- /dev/null +++ b/config/chain_config.go @@ -0,0 +1,10 @@ +package config + +import ( + evmtypes "github.com/cosmos/evm/x/vm/types" +) + +type ChainConfig struct { + ChainID string + EvmConfig *evmtypes.EvmConfig +} From 5e5311ab7ae1db2e6578f999a6a33350d36c91ef Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 04:48:33 -0400 Subject: [PATCH 05/27] remove unnecessaty vars --- tests/integration/ante/ante_test_suite.go | 10 +++------- tests/integration/testutil/test_config.go | 2 +- tests/integration/x/vm/keeper_test_suite.go | 10 +++------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/tests/integration/ante/ante_test_suite.go b/tests/integration/ante/ante_test_suite.go index 0fb9db71c..b5d14131c 100644 --- a/tests/integration/ante/ante_test_suite.go +++ b/tests/integration/ante/ante_test_suite.go @@ -114,18 +114,14 @@ func (s *AnteTestSuite) SetupTest() { // get the denom and decimals set when initialized the chain // to set them again // when resetting the chain config - displayDenom := evmtypes.GetEVMCoinDisplayDenom() - decimals := evmtypes.GetEVMCoinDecimals() - extendedDecimals := evmtypes.GetEVMCoinExtendedDecimals() - configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() err := configurator. WithChainConfig(chainConfig). WithEVMCoinInfo(evmtypes.EvmCoinInfo{ - DisplayDenom: displayDenom, - Decimals: decimals, - ExtendedDecimals: extendedDecimals, + DisplayDenom: evmtypes.GetEVMCoinDisplayDenom(), + Decimals: evmtypes.GetEVMCoinDecimals(), + ExtendedDecimals: evmtypes.GetEVMCoinExtendedDecimals(), }). Apply() s.Require().NoError(err) diff --git a/tests/integration/testutil/test_config.go b/tests/integration/testutil/test_config.go index dac835b44..dc57266be 100644 --- a/tests/integration/testutil/test_config.go +++ b/tests/integration/testutil/test_config.go @@ -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(), diff --git a/tests/integration/x/vm/keeper_test_suite.go b/tests/integration/x/vm/keeper_test_suite.go index 5347cdf4f..2a68fef21 100644 --- a/tests/integration/x/vm/keeper_test_suite.go +++ b/tests/integration/x/vm/keeper_test_suite.go @@ -101,18 +101,14 @@ 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 - displayDenom := evmtypes.GetEVMCoinDisplayDenom() - decimals := evmtypes.GetEVMCoinDecimals() - extendedDecimals := evmtypes.GetEVMCoinExtendedDecimals() - configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() err := configurator. WithChainConfig(chainConfig). WithEVMCoinInfo(evmtypes.EvmCoinInfo{ - DisplayDenom: displayDenom, - Decimals: decimals, - ExtendedDecimals: extendedDecimals, + DisplayDenom: evmtypes.GetEVMCoinDisplayDenom(), + Decimals: evmtypes.GetEVMCoinDecimals(), + ExtendedDecimals: evmtypes.GetEVMCoinExtendedDecimals(), }). Apply() s.Require().NoError(err) From ec249498dc066e687bf6af7008c2cc95ceada476 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 04:59:25 -0400 Subject: [PATCH 06/27] var assignments are actually necessary --- tests/integration/ante/ante_test_suite.go | 10 +++++++--- tests/integration/x/vm/keeper_test_suite.go | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/integration/ante/ante_test_suite.go b/tests/integration/ante/ante_test_suite.go index b5d14131c..0fb9db71c 100644 --- a/tests/integration/ante/ante_test_suite.go +++ b/tests/integration/ante/ante_test_suite.go @@ -114,14 +114,18 @@ func (s *AnteTestSuite) SetupTest() { // get the denom and decimals set when initialized the chain // to set them again // when resetting the chain config + displayDenom := evmtypes.GetEVMCoinDisplayDenom() + decimals := evmtypes.GetEVMCoinDecimals() + extendedDecimals := evmtypes.GetEVMCoinExtendedDecimals() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() err := configurator. WithChainConfig(chainConfig). WithEVMCoinInfo(evmtypes.EvmCoinInfo{ - DisplayDenom: evmtypes.GetEVMCoinDisplayDenom(), - Decimals: evmtypes.GetEVMCoinDecimals(), - ExtendedDecimals: evmtypes.GetEVMCoinExtendedDecimals(), + DisplayDenom: displayDenom, + Decimals: decimals, + ExtendedDecimals: extendedDecimals, }). Apply() s.Require().NoError(err) diff --git a/tests/integration/x/vm/keeper_test_suite.go b/tests/integration/x/vm/keeper_test_suite.go index 2a68fef21..5347cdf4f 100644 --- a/tests/integration/x/vm/keeper_test_suite.go +++ b/tests/integration/x/vm/keeper_test_suite.go @@ -101,14 +101,18 @@ 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 + displayDenom := evmtypes.GetEVMCoinDisplayDenom() + decimals := evmtypes.GetEVMCoinDecimals() + extendedDecimals := evmtypes.GetEVMCoinExtendedDecimals() + configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() err := configurator. WithChainConfig(chainConfig). WithEVMCoinInfo(evmtypes.EvmCoinInfo{ - DisplayDenom: evmtypes.GetEVMCoinDisplayDenom(), - Decimals: evmtypes.GetEVMCoinDecimals(), - ExtendedDecimals: evmtypes.GetEVMCoinExtendedDecimals(), + DisplayDenom: displayDenom, + Decimals: decimals, + ExtendedDecimals: extendedDecimals, }). Apply() s.Require().NoError(err) From 5596af56f1dd8fc8a372962118135307e98d127d Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 06:59:00 -0400 Subject: [PATCH 07/27] add coin info to toml --- server/config/config.go | 20 ++++++++++++++++++- server/config/toml.go | 11 ++++++++++ server/flags/flags.go | 3 +++ server/start.go | 3 +++ x/vm/types/{configurator.go => evm_config.go} | 0 ...onfigurator_test.go => evm_config_test.go} | 0 6 files changed, 36 insertions(+), 1 deletion(-) rename x/vm/types/{configurator.go => evm_config.go} (100%) rename x/vm/types/{configurator_test.go => evm_config_test.go} (100%) diff --git a/server/config/config.go b/server/config/config.go index cabd79181..3abe522f1 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -6,6 +6,8 @@ import ( "path" "time" + evmtypes "github.com/cosmos/evm/x/vm/types" + "github.com/spf13/viper" "github.com/cometbft/cometbft/libs/strings" @@ -63,9 +65,18 @@ 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 is the default EVM Chain ID if one is not provided, should match the value in evmd config DefaultEVMChainID = 262144 + // DefaultEvmCoinInfoDisplayDenom is the default display denomination for the chain + DefaultEvmCoinInfoDisplayDenom = "atom" + + // DefaultEvmCoinInfoDecimals is the default decimals for the base denomination + DefaultEvmCoinInfoDecimals = evmtypes.EighteenDecimals + + // DefaultEvmCoinInfoExtendedDecimals is the default decimals for the extended denomination + DefaultEvmCoinInfoExtendedDecimals = evmtypes.EighteenDecimals + // DefaultEVMMinTip is the default minimum priority fee for the mempool DefaultEVMMinTip = 0 @@ -148,6 +159,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. @@ -218,6 +231,11 @@ func DefaultEVMConfig() *EVMConfig { EVMChainID: DefaultEVMChainID, EnablePreimageRecording: DefaultEnablePreimageRecording, MinTip: DefaultEVMMinTip, + CoinInfo: evmtypes.EvmCoinInfo{ + DisplayDenom: DefaultEvmCoinInfoDisplayDenom, + Decimals: DefaultEvmCoinInfoDecimals, + ExtendedDecimals: DefaultEvmCoinInfoExtendedDecimals, + }, } } diff --git a/server/config/toml.go b/server/config/toml.go index 1e9d4689a..52ce9c29c 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -25,6 +25,17 @@ evm-chain-id = {{ .EVM.EVMChainID }} # MinTip defines the minimum priority fee for the mempool. min-tip = {{ .EVM.MinTip }} +[evm.coin-info] + +# DisplayDenom defines the display denomination shown to users +display-denom = "{{ .EVM.CoinInfo.DisplayDenom }}" + +# Decimals defines the precision/decimals for the base denomination (1-18) +decimals = {{ .EVM.CoinInfo.Decimals }} + +# ExtendedDecimals defines the precision/decimals for the extended denomination (typically 18 decimals for atto-denom) +extended-decimals = {{ .EVM.CoinInfo.ExtendedDecimals }} + ############################################################################### ### JSON RPC Configuration ### ############################################################################### diff --git a/server/flags/flags.go b/server/flags/flags.go index 3844fc7df..704d6d2e0 100644 --- a/server/flags/flags.go +++ b/server/flags/flags.go @@ -71,6 +71,9 @@ const ( EVMEnablePreimageRecording = "evm.cache-preimage" EVMChainID = "evm.evm-chain-id" EVMMinTip = "evm.min-tip" + EVMDisplayDenom = "evm.coin-info.display-denom" + EVMDecimals = "evm.coin-info.decimals" + EVMExtendedDecimals = "evm.coin-info.extended-decimals" ) // TLS flags diff --git a/server/start.go b/server/start.go index 85ba9dad6..14742e17d 100644 --- a/server/start.go +++ b/server/start.go @@ -220,6 +220,9 @@ which accepts a path for the resulting pprof file. cmd.Flags().Bool(srvflags.EVMEnablePreimageRecording, cosmosevmserverconfig.DefaultEnablePreimageRecording, "Enables tracking of SHA3 preimages in the EVM (not implemented yet)") //nolint:lll cmd.Flags().Uint64(srvflags.EVMChainID, cosmosevmserverconfig.DefaultEVMChainID, "the EIP-155 compatible replay protection chain ID") cmd.Flags().Uint64(srvflags.EVMMinTip, cosmosevmserverconfig.DefaultEVMMinTip, "the minimum priority fee for the mempool") + cmd.Flags().String(srvflags.EVMDisplayDenom, cosmosevmserverconfig.DefaultEvmCoinInfoDisplayDenom, "the display denomination for the chain") + cmd.Flags().Uint8(srvflags.EVMDecimals, uint8(cosmosevmserverconfig.DefaultEvmCoinInfoDecimals), "the decimals for the base denomination") + cmd.Flags().Uint8(srvflags.EVMExtendedDecimals, uint8(cosmosevmserverconfig.DefaultEvmCoinInfoExtendedDecimals), "the decimals for the extended denomination") cmd.Flags().String(srvflags.TLSCertPath, "", "the cert.pem file path for the server TLS configuration") cmd.Flags().String(srvflags.TLSKeyPath, "", "the key.pem file path for the server TLS configuration") diff --git a/x/vm/types/configurator.go b/x/vm/types/evm_config.go similarity index 100% rename from x/vm/types/configurator.go rename to x/vm/types/evm_config.go diff --git a/x/vm/types/configurator_test.go b/x/vm/types/evm_config_test.go similarity index 100% rename from x/vm/types/configurator_test.go rename to x/vm/types/evm_config_test.go From 02d01f732214aac5691660b1d8786dc1cc25988d Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 07:30:05 -0400 Subject: [PATCH 08/27] add fallback for missing chain id in client.toml --- evmd/cmd/evmd/cmd/root.go | 15 +++++++++------ evmd/config/client.toml | 6 +++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/evmd/cmd/evmd/cmd/root.go b/evmd/cmd/evmd/cmd/root.go index 70460c752..5b899141d 100644 --- a/evmd/cmd/evmd/cmd/root.go +++ b/evmd/cmd/evmd/cmd/root.go @@ -4,6 +4,7 @@ import ( "errors" "io" "os" + "strconv" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/spf13/cast" @@ -140,18 +141,20 @@ func NewRootCmd() *cobra.Command { initRootCmd(rootCmd, tempApp) - autoCliOpts := tempApp.AutoCliOpts() + if initClientCtx.ChainID == "" { + // if the chain id is not set in client.toml, set it to the default chain id + initClientCtx = initClientCtx.WithChainID(strconv.FormatUint(evmdconfig.EVMChainID, 10)) + } initClientCtx, _ = clientcfg.ReadFromClientConfig(initClientCtx) - autoCliOpts.ClientCtx = initClientCtx + autoCliOpts := tempApp.AutoCliOpts() + 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) - } + if err := evmdconfig.EvmAppOptions(evmdconfig.EVMChainID); err != nil { + panic(err) } return rootCmd diff --git a/evmd/config/client.toml b/evmd/config/client.toml index 2a8569c81..02df72407 100644 --- a/evmd/config/client.toml +++ b/evmd/config/client.toml @@ -7,11 +7,15 @@ # 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" +broadcast-mode = "sync" \ No newline at end of file From 91edb754aa442ec9ed26e624ff8bd338c86e682f Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 08:38:48 -0400 Subject: [PATCH 09/27] refactor server options --- config/server_app_options.go | 94 --------- config/server_app_options_test.go | 332 ------------------------------ evmd/app.go | 10 +- evmd/cmd/evmd/cmd/root.go | 24 +-- evmd/cmd/evmd/config/chain_id.go | 29 --- evmd/cmd/evmd/config/config.go | 19 ++ evmd/cmd/evmd/config/constants.go | 31 --- 7 files changed, 27 insertions(+), 512 deletions(-) delete mode 100644 config/server_app_options.go delete mode 100644 config/server_app_options_test.go delete mode 100644 evmd/cmd/evmd/config/chain_id.go delete mode 100644 evmd/cmd/evmd/config/constants.go diff --git a/config/server_app_options.go b/config/server_app_options.go deleted file mode 100644 index cac9cc7a1..000000000 --- a/config/server_app_options.go +++ /dev/null @@ -1,94 +0,0 @@ -package config - -import ( - "math" - "path/filepath" - - "github.com/holiman/uint256" - "github.com/spf13/cast" - - srvflags "github.com/cosmos/evm/server/flags" - - "cosmossdk.io/log" - - "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" -) - -// GetBlockGasLimit reads the genesis json file using AppGenesisFromFile -// to extract the consensus block gas limit before InitChain is called. -func GetBlockGasLimit(appOpts servertypes.AppOptions, logger log.Logger) uint64 { - homeDir := cast.ToString(appOpts.Get(flags.FlagHome)) - if homeDir == "" { - logger.Error("home directory not found in app options, using zero block gas limit") - return math.MaxUint64 - } - genesisPath := filepath.Join(homeDir, "config", "genesis.json") - - appGenesis, err := genutiltypes.AppGenesisFromFile(genesisPath) - if err != nil { - logger.Error("failed to load genesis using SDK AppGenesisFromFile, using zero block gas limit", "path", genesisPath, "error", err) - return 0 - } - genDoc, err := appGenesis.ToGenesisDoc() - if err != nil { - logger.Error("failed to convert AppGenesis to GenesisDoc, using zero block gas limit", "path", genesisPath, "error", err) - return 0 - } - - if genDoc.ConsensusParams == nil { - logger.Error("consensus parameters not found in genesis (nil), using zero block gas limit") - return 0 - } - - maxGas := genDoc.ConsensusParams.Block.MaxGas - if maxGas == -1 { - logger.Warn("genesis max_gas is unlimited (-1), using max uint64") - return math.MaxUint64 - } - if maxGas < -1 { - logger.Error("invalid max_gas value in genesis, using zero block gas limit") - return 0 - } - blockGasLimit := uint64(maxGas) // #nosec G115 -- maxGas >= 0 checked above - - logger.Debug( - "extracted block gas limit from genesis using SDK AppGenesisFromFile", - "genesis_path", genesisPath, - "max_gas", maxGas, - "block_gas_limit", blockGasLimit, - ) - - return blockGasLimit -} - -// GetMinGasPrices reads the min gas prices from the app options, set from app.toml -// This is currently not used, but is kept in case this is useful for the mempool, -// in addition to the min tip flag -func GetMinGasPrices(appOpts servertypes.AppOptions, logger log.Logger) sdk.DecCoins { - minGasPricesStr := cast.ToString(appOpts.Get(sdkserver.FlagMinGasPrices)) - minGasPrices, err := sdk.ParseDecCoins(minGasPricesStr) - if err != nil { - logger.With("error", err).Info("failed to parse min gas prices, using empty DecCoins") - minGasPrices = sdk.DecCoins{} - } - - return minGasPrices -} - -// GetMinTip reads the min tip from the app options, set from app.toml -// This field is also known as the minimum priority fee -func GetMinTip(appOpts servertypes.AppOptions, logger log.Logger) *uint256.Int { - minTipUint64 := cast.ToUint64(appOpts.Get(srvflags.EVMMinTip)) - minTip := uint256.NewInt(minTipUint64) - - if minTip.Cmp(uint256.NewInt(0)) >= 0 { // zero or positive - return minTip - } - - logger.Error("invalid min tip value in app.toml or flag, falling back to nil", "min_tip", minTipUint64) - return nil -} diff --git a/config/server_app_options_test.go b/config/server_app_options_test.go deleted file mode 100644 index ee4ed2ff1..000000000 --- a/config/server_app_options_test.go +++ /dev/null @@ -1,332 +0,0 @@ -package config - -import ( - "encoding/json" - "fmt" - "math" - "os" - "path/filepath" - "testing" - - "github.com/stretchr/testify/require" - - "cosmossdk.io/log" - sdkmath "cosmossdk.io/math" - - "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" -) - -type mockAppOptions struct { - values map[string]interface{} -} - -func newMockAppOptions() *mockAppOptions { - return &mockAppOptions{ - values: make(map[string]interface{}), - } -} - -func (m *mockAppOptions) Get(key string) interface{} { - return m.values[key] -} - -func (m *mockAppOptions) Set(key string, value interface{}) { - m.values[key] = value -} - -func TestGetBlockGasLimit(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - setupFn func() servertypes.AppOptions - expected uint64 - }{ - { - name: "empty home directory returns max uint64", - setupFn: func() servertypes.AppOptions { - opts := newMockAppOptions() - return opts - }, - expected: math.MaxUint64, - }, - { - name: "genesis file not found returns 0", - setupFn: func() servertypes.AppOptions { - opts := newMockAppOptions() - opts.Set(flags.FlagHome, "/non/existent/directory") - return opts - }, - expected: 0, - }, - { - name: "valid genesis with max_gas = -1 returns max uint64", - setupFn: func() servertypes.AppOptions { - homeDir := createGenesisWithMaxGas(t, -1) - opts := newMockAppOptions() - opts.Set(flags.FlagHome, homeDir) - return opts - }, - expected: math.MaxUint64, - }, - { - name: "valid genesis with max_gas < -1 returns 0", - setupFn: func() servertypes.AppOptions { - homeDir := createGenesisWithMaxGas(t, -5) - opts := newMockAppOptions() - opts.Set(flags.FlagHome, homeDir) - return opts - }, - expected: 0, - }, - { - name: "valid genesis with max_gas = 0 returns 0", - setupFn: func() servertypes.AppOptions { - homeDir := createGenesisWithMaxGas(t, 0) - opts := newMockAppOptions() - opts.Set(flags.FlagHome, homeDir) - return opts - }, - expected: 0, - }, - { - name: "valid genesis with max_gas = 1000000 returns 1000000", - setupFn: func() servertypes.AppOptions { - homeDir := createGenesisWithMaxGas(t, 1000000) - opts := newMockAppOptions() - opts.Set(flags.FlagHome, homeDir) - return opts - }, - expected: 1000000, - }, - { - name: "genesis without consensus params returns 0", - setupFn: func() servertypes.AppOptions { - homeDir := createGenesisWithoutConsensusParams(t) - opts := newMockAppOptions() - opts.Set(flags.FlagHome, homeDir) - return opts - }, - expected: 0, - }, - { - name: "invalid genesis JSON returns 0", - setupFn: func() servertypes.AppOptions { - homeDir := createInvalidGenesis(t) - opts := newMockAppOptions() - opts.Set(flags.FlagHome, homeDir) - return opts - }, - expected: 0, - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(_ *testing.T) { - appOpts := tc.setupFn() - logger := log.NewNopLogger() - - result := GetBlockGasLimit(appOpts, logger) - require.Equal(t, tc.expected, result, "GetBlockGasLimit returned unexpected value") - }) - } -} - -func TestGetMinGasPrices(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - setupFn func() servertypes.AppOptions - expected sdk.DecCoins - }{ - { - name: "valid single gas price", - setupFn: func() servertypes.AppOptions { - opts := newMockAppOptions() - opts.Set(sdkserver.FlagMinGasPrices, "0.025uatom") - return opts - }, - expected: sdk.DecCoins{sdk.NewDecCoinFromDec("uatom", sdkmath.LegacyMustNewDecFromStr("0.025"))}, - }, - { - name: "valid multiple gas prices", - setupFn: func() servertypes.AppOptions { - opts := newMockAppOptions() - opts.Set(sdkserver.FlagMinGasPrices, "0.025uatom,0.001stake") - return opts - }, - expected: sdk.DecCoins{ - sdk.NewDecCoinFromDec("stake", sdkmath.LegacyMustNewDecFromStr("0.001")), - sdk.NewDecCoinFromDec("uatom", sdkmath.LegacyMustNewDecFromStr("0.025")), - }, - }, - { - name: "empty gas prices returns empty DecCoins", - setupFn: func() servertypes.AppOptions { - opts := newMockAppOptions() - opts.Set(sdkserver.FlagMinGasPrices, "") - return opts - }, - expected: nil, - }, - { - name: "missing gas prices flag returns empty DecCoins", - setupFn: func() servertypes.AppOptions { - opts := newMockAppOptions() - return opts - }, - expected: nil, - }, - { - name: "invalid gas price format returns empty DecCoins", - setupFn: func() servertypes.AppOptions { - opts := newMockAppOptions() - opts.Set(sdkserver.FlagMinGasPrices, "invalid-format") - return opts - }, - expected: sdk.DecCoins{}, - }, - { - name: "malformed coin denomination returns empty DecCoins", - setupFn: func() servertypes.AppOptions { - opts := newMockAppOptions() - opts.Set(sdkserver.FlagMinGasPrices, "0.025") - return opts - }, - expected: sdk.DecCoins{}, - }, - { - name: "zero amount gas price", - setupFn: func() servertypes.AppOptions { - opts := newMockAppOptions() - opts.Set(sdkserver.FlagMinGasPrices, "0uatom") - return opts - }, - expected: sdk.DecCoins{}, - }, - { - name: "large decimal precision gas price", - setupFn: func() servertypes.AppOptions { - opts := newMockAppOptions() - opts.Set(sdkserver.FlagMinGasPrices, "0.000000000000000001uatom") - return opts - }, - expected: sdk.DecCoins{sdk.NewDecCoinFromDec("uatom", sdkmath.LegacyMustNewDecFromStr("0.000000000000000001"))}, - }, - } - - for _, tc := range tests { - t.Run(tc.name, func(_ *testing.T) { - appOpts := tc.setupFn() - logger := log.NewNopLogger() - - result := GetMinGasPrices(appOpts, logger) - require.Equal(t, tc.expected, result, "GetMinGasPrices returned unexpected value") - }) - } -} - -func createGenesisWithMaxGas(t *testing.T, maxGas int64) string { - t.Helper() - tempDir := t.TempDir() - configDir := filepath.Join(tempDir, "config") - require.NoError(t, os.MkdirAll(configDir, 0o755)) - - genesis := map[string]interface{}{ - "app_name": "evmd", - "app_version": "test", - "chain_id": "test-chain", - "initial_height": 1, - "genesis_time": "2024-01-01T00:00:00Z", - "app_hash": nil, - "app_state": map[string]interface{}{ - "auth": map[string]interface{}{ - "params": map[string]interface{}{ - "max_memo_characters": "256", - "tx_sig_limit": "7", - "tx_size_cost_per_byte": "10", - "sig_verify_cost_ed25519": "590", - "sig_verify_cost_secp256k1": "1000", - }, - "accounts": []interface{}{}, - }, - }, - "consensus": map[string]interface{}{ - "params": map[string]interface{}{ - "block": map[string]interface{}{ - "max_bytes": "22020096", - "max_gas": fmt.Sprintf("%d", maxGas), - }, - "evidence": map[string]interface{}{ - "max_age_num_blocks": "100000", - "max_age_duration": "172800000000000", - "max_bytes": "1048576", - }, - "validator": map[string]interface{}{ - "pub_key_types": []string{"ed25519"}, - }, - "version": map[string]interface{}{ - "app": "0", - }, - }, - }, - } - - genesisBytes, err := json.MarshalIndent(genesis, "", " ") - require.NoError(t, err) - - genesisPath := filepath.Join(configDir, "genesis.json") - require.NoError(t, os.WriteFile(genesisPath, genesisBytes, 0o600)) - - return tempDir -} - -func createGenesisWithoutConsensusParams(t *testing.T) string { - t.Helper() - tempDir := t.TempDir() - configDir := filepath.Join(tempDir, "config") - require.NoError(t, os.MkdirAll(configDir, 0o755)) - - genesis := map[string]interface{}{ - "app_name": "evmd", - "app_version": "test", - "chain_id": "test-chain", - "initial_height": 1, - "genesis_time": "2024-01-01T00:00:00Z", - "app_hash": nil, - "app_state": map[string]interface{}{ - "auth": map[string]interface{}{ - "params": map[string]interface{}{}, - "accounts": []interface{}{}, - }, - }, - "consensus": map[string]interface{}{ - "params": nil, - }, - } - - genesisBytes, err := json.MarshalIndent(genesis, "", " ") - require.NoError(t, err) - - genesisPath := filepath.Join(configDir, "genesis.json") - require.NoError(t, os.WriteFile(genesisPath, genesisBytes, 0o600)) - - return tempDir -} - -func createInvalidGenesis(t *testing.T) string { - t.Helper() - tempDir := t.TempDir() - configDir := filepath.Join(tempDir, "config") - require.NoError(t, os.MkdirAll(configDir, 0o755)) - - invalidJSON := `{"invalid": json}` - genesisPath := filepath.Join(configDir, "genesis.json") - require.NoError(t, os.WriteFile(genesisPath, []byte(invalidJSON), 0o600)) - - return tempDir -} diff --git a/evmd/app.go b/evmd/app.go index d4ec9ebe3..6f9d41f45 100644 --- a/evmd/app.go +++ b/evmd/app.go @@ -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" @@ -755,9 +755,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 := evmdconfig.GetBlockGasLimit(appOpts, logger) // Get GetMinTip from app.toml or cli flag configuration - mipTip := evmconfig.GetMinTip(appOpts, logger) + mipTip := evmdconfig.GetMinTip(appOpts, logger) mempoolConfig := &evmmempool.EVMMempoolConfig{ AnteHandler: app.GetAnteHandler(), @@ -981,7 +981,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 +1016,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/root.go b/evmd/cmd/evmd/cmd/root.go index 5b899141d..ea3e33f34 100644 --- a/evmd/cmd/evmd/cmd/root.go +++ b/evmd/cmd/evmd/cmd/root.go @@ -142,7 +142,7 @@ func NewRootCmd() *cobra.Command { initRootCmd(rootCmd, tempApp) if initClientCtx.ChainID == "" { - // if the chain id is not set in client.toml, set it to the default chain id + // if the chain id is not set in client.toml, populate it with the default evm chain id initClientCtx = initClientCtx.WithChainID(strconv.FormatUint(evmdconfig.EVMChainID, 10)) } initClientCtx, _ = clientcfg.ReadFromClientConfig(initClientCtx) @@ -296,7 +296,7 @@ func newApp( } // get the chain id - chainID, err := getChainIDFromOpts(appOpts) + chainID, err := evmdconfig.GetEvmChainID(appOpts) if err != nil { panic(err) } @@ -365,7 +365,7 @@ func appExport( appOpts = viperAppOpts // get the chain id - chainID, err := getChainIDFromOpts(appOpts) + chainID, err := evmdconfig.GetEvmChainID(appOpts) if err != nil { return servertypes.ExportedApp{}, err } @@ -382,21 +382,3 @@ func appExport( 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/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 index a5b042d07..6c49bbcd9 100644 --- a/evmd/cmd/evmd/config/config.go +++ b/evmd/cmd/evmd/config/config.go @@ -53,6 +53,25 @@ const ( BaseDenomUnit = 18 // EVMChainID defines the EIP-155 replay-protection chain id for the current ethereum chain config. EVMChainID = 262144 + // 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" ) // SetBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings. 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" -) From 24c6f42876979b9f86cd9bd5458dc7eda61f0776 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 08:41:29 -0400 Subject: [PATCH 10/27] lint --- evmd/cmd/evmd/config/server_app_options.go | 112 ++++++ .../evmd/config/server_app_options_test.go | 332 ++++++++++++++++++ server/config/config.go | 4 +- 3 files changed, 446 insertions(+), 2 deletions(-) create mode 100644 evmd/cmd/evmd/config/server_app_options.go create mode 100644 evmd/cmd/evmd/config/server_app_options_test.go diff --git a/evmd/cmd/evmd/config/server_app_options.go b/evmd/cmd/evmd/config/server_app_options.go new file mode 100644 index 000000000..0ca0c3c47 --- /dev/null +++ b/evmd/cmd/evmd/config/server_app_options.go @@ -0,0 +1,112 @@ +package config + +import ( + "math" + "path/filepath" + + "github.com/holiman/uint256" + "github.com/spf13/cast" + + "cosmossdk.io/log" + srvflags "github.com/cosmos/evm/server/flags" + + "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" +) + +// GetBlockGasLimit reads the genesis json file using AppGenesisFromFile +// to extract the consensus block gas limit before InitChain is called. +func GetBlockGasLimit(appOpts servertypes.AppOptions, logger log.Logger) uint64 { + homeDir := cast.ToString(appOpts.Get(flags.FlagHome)) + if homeDir == "" { + logger.Error("home directory not found in app options, using zero block gas limit") + return math.MaxUint64 + } + genesisPath := filepath.Join(homeDir, "config", "genesis.json") + + appGenesis, err := genutiltypes.AppGenesisFromFile(genesisPath) + if err != nil { + logger.Error("failed to load genesis using SDK AppGenesisFromFile, using zero block gas limit", "path", genesisPath, "error", err) + return 0 + } + genDoc, err := appGenesis.ToGenesisDoc() + if err != nil { + logger.Error("failed to convert AppGenesis to GenesisDoc, using zero block gas limit", "path", genesisPath, "error", err) + return 0 + } + + if genDoc.ConsensusParams == nil { + logger.Error("consensus parameters not found in genesis (nil), using zero block gas limit") + return 0 + } + + maxGas := genDoc.ConsensusParams.Block.MaxGas + if maxGas == -1 { + logger.Warn("genesis max_gas is unlimited (-1), using max uint64") + return math.MaxUint64 + } + if maxGas < -1 { + logger.Error("invalid max_gas value in genesis, using zero block gas limit") + return 0 + } + blockGasLimit := uint64(maxGas) // #nosec G115 -- maxGas >= 0 checked above + + logger.Debug( + "extracted block gas limit from genesis using SDK AppGenesisFromFile", + "genesis_path", genesisPath, + "max_gas", maxGas, + "block_gas_limit", blockGasLimit, + ) + + return blockGasLimit +} + +// GetMinGasPrices reads the min gas prices from the app options, set from app.toml +// This is currently not used, but is kept in case this is useful for the mempool, +// in addition to the min tip flag +func GetMinGasPrices(appOpts servertypes.AppOptions, logger log.Logger) sdk.DecCoins { + minGasPricesStr := cast.ToString(appOpts.Get(sdkserver.FlagMinGasPrices)) + minGasPrices, err := sdk.ParseDecCoins(minGasPricesStr) + if err != nil { + logger.With("error", err).Info("failed to parse min gas prices, using empty DecCoins") + minGasPrices = sdk.DecCoins{} + } + + return minGasPrices +} + +// GetMinTip reads the min tip from the app options, set from app.toml +// This field is also known as the minimum priority fee +func GetMinTip(appOpts servertypes.AppOptions, logger log.Logger) *uint256.Int { + minTipUint64 := cast.ToUint64(appOpts.Get(srvflags.EVMMinTip)) + minTip := uint256.NewInt(minTipUint64) + + if minTip.Cmp(uint256.NewInt(0)) >= 0 { // zero or positive + return minTip + } + + logger.Error("invalid min tip value in app.toml or flag, falling back to nil", "min_tip", minTipUint64) + return nil +} + +// GetEvmChainID returns the EVM chain ID from the app options, set from +// If not available, it will load from client.toml +func GetEvmChainID(appOpts servertypes.AppOptions) (string, error) { + chainID := cast.ToString(appOpts.Get(flags.FlagChainID)) + if chainID == "" { + // if not available, load from client.toml + clientCtx := client.Context{}.WithHomeDir(MustGetDefaultNodeHome()) + clientCtx, err := config.ReadFromClientConfig(clientCtx) + if err != nil { + return "", err + } + chainID = clientCtx.ChainID + } + + return chainID, nil +} diff --git a/evmd/cmd/evmd/config/server_app_options_test.go b/evmd/cmd/evmd/config/server_app_options_test.go new file mode 100644 index 000000000..ee4ed2ff1 --- /dev/null +++ b/evmd/cmd/evmd/config/server_app_options_test.go @@ -0,0 +1,332 @@ +package config + +import ( + "encoding/json" + "fmt" + "math" + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + + "cosmossdk.io/log" + sdkmath "cosmossdk.io/math" + + "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" +) + +type mockAppOptions struct { + values map[string]interface{} +} + +func newMockAppOptions() *mockAppOptions { + return &mockAppOptions{ + values: make(map[string]interface{}), + } +} + +func (m *mockAppOptions) Get(key string) interface{} { + return m.values[key] +} + +func (m *mockAppOptions) Set(key string, value interface{}) { + m.values[key] = value +} + +func TestGetBlockGasLimit(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + setupFn func() servertypes.AppOptions + expected uint64 + }{ + { + name: "empty home directory returns max uint64", + setupFn: func() servertypes.AppOptions { + opts := newMockAppOptions() + return opts + }, + expected: math.MaxUint64, + }, + { + name: "genesis file not found returns 0", + setupFn: func() servertypes.AppOptions { + opts := newMockAppOptions() + opts.Set(flags.FlagHome, "/non/existent/directory") + return opts + }, + expected: 0, + }, + { + name: "valid genesis with max_gas = -1 returns max uint64", + setupFn: func() servertypes.AppOptions { + homeDir := createGenesisWithMaxGas(t, -1) + opts := newMockAppOptions() + opts.Set(flags.FlagHome, homeDir) + return opts + }, + expected: math.MaxUint64, + }, + { + name: "valid genesis with max_gas < -1 returns 0", + setupFn: func() servertypes.AppOptions { + homeDir := createGenesisWithMaxGas(t, -5) + opts := newMockAppOptions() + opts.Set(flags.FlagHome, homeDir) + return opts + }, + expected: 0, + }, + { + name: "valid genesis with max_gas = 0 returns 0", + setupFn: func() servertypes.AppOptions { + homeDir := createGenesisWithMaxGas(t, 0) + opts := newMockAppOptions() + opts.Set(flags.FlagHome, homeDir) + return opts + }, + expected: 0, + }, + { + name: "valid genesis with max_gas = 1000000 returns 1000000", + setupFn: func() servertypes.AppOptions { + homeDir := createGenesisWithMaxGas(t, 1000000) + opts := newMockAppOptions() + opts.Set(flags.FlagHome, homeDir) + return opts + }, + expected: 1000000, + }, + { + name: "genesis without consensus params returns 0", + setupFn: func() servertypes.AppOptions { + homeDir := createGenesisWithoutConsensusParams(t) + opts := newMockAppOptions() + opts.Set(flags.FlagHome, homeDir) + return opts + }, + expected: 0, + }, + { + name: "invalid genesis JSON returns 0", + setupFn: func() servertypes.AppOptions { + homeDir := createInvalidGenesis(t) + opts := newMockAppOptions() + opts.Set(flags.FlagHome, homeDir) + return opts + }, + expected: 0, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(_ *testing.T) { + appOpts := tc.setupFn() + logger := log.NewNopLogger() + + result := GetBlockGasLimit(appOpts, logger) + require.Equal(t, tc.expected, result, "GetBlockGasLimit returned unexpected value") + }) + } +} + +func TestGetMinGasPrices(t *testing.T) { + t.Parallel() + + tests := []struct { + name string + setupFn func() servertypes.AppOptions + expected sdk.DecCoins + }{ + { + name: "valid single gas price", + setupFn: func() servertypes.AppOptions { + opts := newMockAppOptions() + opts.Set(sdkserver.FlagMinGasPrices, "0.025uatom") + return opts + }, + expected: sdk.DecCoins{sdk.NewDecCoinFromDec("uatom", sdkmath.LegacyMustNewDecFromStr("0.025"))}, + }, + { + name: "valid multiple gas prices", + setupFn: func() servertypes.AppOptions { + opts := newMockAppOptions() + opts.Set(sdkserver.FlagMinGasPrices, "0.025uatom,0.001stake") + return opts + }, + expected: sdk.DecCoins{ + sdk.NewDecCoinFromDec("stake", sdkmath.LegacyMustNewDecFromStr("0.001")), + sdk.NewDecCoinFromDec("uatom", sdkmath.LegacyMustNewDecFromStr("0.025")), + }, + }, + { + name: "empty gas prices returns empty DecCoins", + setupFn: func() servertypes.AppOptions { + opts := newMockAppOptions() + opts.Set(sdkserver.FlagMinGasPrices, "") + return opts + }, + expected: nil, + }, + { + name: "missing gas prices flag returns empty DecCoins", + setupFn: func() servertypes.AppOptions { + opts := newMockAppOptions() + return opts + }, + expected: nil, + }, + { + name: "invalid gas price format returns empty DecCoins", + setupFn: func() servertypes.AppOptions { + opts := newMockAppOptions() + opts.Set(sdkserver.FlagMinGasPrices, "invalid-format") + return opts + }, + expected: sdk.DecCoins{}, + }, + { + name: "malformed coin denomination returns empty DecCoins", + setupFn: func() servertypes.AppOptions { + opts := newMockAppOptions() + opts.Set(sdkserver.FlagMinGasPrices, "0.025") + return opts + }, + expected: sdk.DecCoins{}, + }, + { + name: "zero amount gas price", + setupFn: func() servertypes.AppOptions { + opts := newMockAppOptions() + opts.Set(sdkserver.FlagMinGasPrices, "0uatom") + return opts + }, + expected: sdk.DecCoins{}, + }, + { + name: "large decimal precision gas price", + setupFn: func() servertypes.AppOptions { + opts := newMockAppOptions() + opts.Set(sdkserver.FlagMinGasPrices, "0.000000000000000001uatom") + return opts + }, + expected: sdk.DecCoins{sdk.NewDecCoinFromDec("uatom", sdkmath.LegacyMustNewDecFromStr("0.000000000000000001"))}, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(_ *testing.T) { + appOpts := tc.setupFn() + logger := log.NewNopLogger() + + result := GetMinGasPrices(appOpts, logger) + require.Equal(t, tc.expected, result, "GetMinGasPrices returned unexpected value") + }) + } +} + +func createGenesisWithMaxGas(t *testing.T, maxGas int64) string { + t.Helper() + tempDir := t.TempDir() + configDir := filepath.Join(tempDir, "config") + require.NoError(t, os.MkdirAll(configDir, 0o755)) + + genesis := map[string]interface{}{ + "app_name": "evmd", + "app_version": "test", + "chain_id": "test-chain", + "initial_height": 1, + "genesis_time": "2024-01-01T00:00:00Z", + "app_hash": nil, + "app_state": map[string]interface{}{ + "auth": map[string]interface{}{ + "params": map[string]interface{}{ + "max_memo_characters": "256", + "tx_sig_limit": "7", + "tx_size_cost_per_byte": "10", + "sig_verify_cost_ed25519": "590", + "sig_verify_cost_secp256k1": "1000", + }, + "accounts": []interface{}{}, + }, + }, + "consensus": map[string]interface{}{ + "params": map[string]interface{}{ + "block": map[string]interface{}{ + "max_bytes": "22020096", + "max_gas": fmt.Sprintf("%d", maxGas), + }, + "evidence": map[string]interface{}{ + "max_age_num_blocks": "100000", + "max_age_duration": "172800000000000", + "max_bytes": "1048576", + }, + "validator": map[string]interface{}{ + "pub_key_types": []string{"ed25519"}, + }, + "version": map[string]interface{}{ + "app": "0", + }, + }, + }, + } + + genesisBytes, err := json.MarshalIndent(genesis, "", " ") + require.NoError(t, err) + + genesisPath := filepath.Join(configDir, "genesis.json") + require.NoError(t, os.WriteFile(genesisPath, genesisBytes, 0o600)) + + return tempDir +} + +func createGenesisWithoutConsensusParams(t *testing.T) string { + t.Helper() + tempDir := t.TempDir() + configDir := filepath.Join(tempDir, "config") + require.NoError(t, os.MkdirAll(configDir, 0o755)) + + genesis := map[string]interface{}{ + "app_name": "evmd", + "app_version": "test", + "chain_id": "test-chain", + "initial_height": 1, + "genesis_time": "2024-01-01T00:00:00Z", + "app_hash": nil, + "app_state": map[string]interface{}{ + "auth": map[string]interface{}{ + "params": map[string]interface{}{}, + "accounts": []interface{}{}, + }, + }, + "consensus": map[string]interface{}{ + "params": nil, + }, + } + + genesisBytes, err := json.MarshalIndent(genesis, "", " ") + require.NoError(t, err) + + genesisPath := filepath.Join(configDir, "genesis.json") + require.NoError(t, os.WriteFile(genesisPath, genesisBytes, 0o600)) + + return tempDir +} + +func createInvalidGenesis(t *testing.T) string { + t.Helper() + tempDir := t.TempDir() + configDir := filepath.Join(tempDir, "config") + require.NoError(t, os.MkdirAll(configDir, 0o755)) + + invalidJSON := `{"invalid": json}` + genesisPath := filepath.Join(configDir, "genesis.json") + require.NoError(t, os.WriteFile(genesisPath, []byte(invalidJSON), 0o600)) + + return tempDir +} diff --git a/server/config/config.go b/server/config/config.go index 3abe522f1..9450a39c1 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -6,12 +6,12 @@ import ( "path" "time" - evmtypes "github.com/cosmos/evm/x/vm/types" - "github.com/spf13/viper" "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" From 517ae7d5808e51c84c4dd8adbd5fc43aa3f29ac8 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 12:06:44 -0400 Subject: [PATCH 11/27] add appOptions refactor --- ante/evm/mono_decorator_test.go | 8 +- config/chain_config.go | 10 --- config/evm_app_options.go | 91 --------------------- evmd/app.go | 9 +- evmd/cmd/evmd/cmd/creator.go | 16 +++- evmd/cmd/evmd/cmd/root.go | 38 +++++---- evmd/cmd/evmd/cmd/testnet.go | 6 +- evmd/cmd/evmd/config/chain_config.go | 84 +++++++++++++++++++ evmd/cmd/evmd/config/config.go | 29 +++++-- evmd/cmd/evmd/config/config_testing.go | 15 ---- evmd/cmd/evmd/config/server_app_options.go | 69 +++++++++++++++- tests/integration/x/vm/keeper_test_suite.go | 4 +- tests/integration/x/vm/test_grpc_query.go | 3 +- testutil/config/constants.go | 2 - testutil/config/evm_app_options.go | 14 ---- x/vm/types/chain_config.go | 24 ++---- x/vm/types/evm_config.go | 8 ++ 17 files changed, 243 insertions(+), 187 deletions(-) delete mode 100644 config/chain_config.go delete mode 100644 config/evm_app_options.go create mode 100644 evmd/cmd/evmd/config/chain_config.go delete mode 100644 evmd/cmd/evmd/config/config_testing.go delete mode 100644 testutil/config/evm_app_options.go diff --git a/ante/evm/mono_decorator_test.go b/ante/evm/mono_decorator_test.go index 295415734..0c1fed7ed 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) + chainConfig := evmconfig.DefaultChainConfig + require.NoError(t, chainConfig.ApplyChainConfig()) + cfg := encoding.MakeConfig(chainConfig.EvmChainID) testCases := []struct { name string diff --git a/config/chain_config.go b/config/chain_config.go deleted file mode 100644 index e0c06c0d1..000000000 --- a/config/chain_config.go +++ /dev/null @@ -1,10 +0,0 @@ -package config - -import ( - evmtypes "github.com/cosmos/evm/x/vm/types" -) - -type ChainConfig struct { - ChainID string - EvmConfig *evmtypes.EvmConfig -} diff --git a/config/evm_app_options.go b/config/evm_app_options.go deleted file mode 100644 index 3c95e91db..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.NewEvmConfig() - 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). - Apply() - 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.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/evmd/app.go b/evmd/app.go index 6f9d41f45..fb3fb790d 100644 --- a/evmd/app.go +++ b/evmd/app.go @@ -20,7 +20,7 @@ import ( dbm "github.com/cosmos/cosmos-db" 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" @@ -212,11 +212,10 @@ func NewExampleApp( traceStore io.Writer, loadLatest bool, appOpts servertypes.AppOptions, - evmChainID uint64, - evmAppOptions evmconfig.EVMOptionsFn, + chainConfig config.ChainConfig, baseAppOptions ...func(*baseapp.BaseApp), ) *EVMD { - encodingConfig := evmosencoding.MakeConfig(evmChainID) + encodingConfig := evmosencoding.MakeConfig(chainConfig.EvmChainID) appCodec := encodingConfig.Codec legacyAmino := encodingConfig.Amino @@ -263,7 +262,7 @@ func NewExampleApp( bApp.SetTxEncoder(txConfig.TxEncoder()) // initialize the Cosmos EVM application configuration - if err := evmAppOptions(evmChainID); err != nil { + if err := chainConfig.ApplyChainConfig(); err != nil { panic(err) } diff --git a/evmd/cmd/evmd/cmd/creator.go b/evmd/cmd/evmd/cmd/creator.go index c6238998d..77b067381 100644 --- a/evmd/cmd/evmd/cmd/creator.go +++ b/evmd/cmd/evmd/cmd/creator.go @@ -88,14 +88,18 @@ func (a appCreator) newApp( baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))), } + chainConfig, err := evmdconfig.CreateChainConfig(appOpts) + if err != nil { + panic(err) + } + return evmd.NewExampleApp( logger, db, traceStore, true, simtestutil.EmptyAppOptions{}, - evmdconfig.EVMChainID, - evmdconfig.EvmAppOptions, + *chainConfig, baseappOptions..., ) } @@ -131,14 +135,18 @@ func (a appCreator) appExport( loadLatest = true } + chainConfig, err := evmdconfig.CreateChainConfig(appOpts) + if err != nil { + return servertypes.ExportedApp{}, err + } + evmApp = evmd.NewExampleApp( logger, db, traceStore, loadLatest, appOpts, - evmdconfig.EVMChainID, - evmdconfig.EvmAppOptions, + *chainConfig, ) if height != -1 { diff --git a/evmd/cmd/evmd/cmd/root.go b/evmd/cmd/evmd/cmd/root.go index ea3e33f34..c42358a04 100644 --- a/evmd/cmd/evmd/cmd/root.go +++ b/evmd/cmd/evmd/cmd/root.go @@ -16,6 +16,7 @@ import ( dbm "github.com/cosmos/cosmos-db" cosmosevmcmd "github.com/cosmos/evm/client" + 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" @@ -56,17 +57,14 @@ func NewRootCmd() *cobra.Command { // 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( log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}, - evmdconfig.EVMChainID, - noOpEvmAppOptions, + evmconfig.ChainConfig{}, ) encodingConfig := sdktestutil.TestEncodingConfig{ @@ -132,7 +130,7 @@ func NewRootCmd() *cobra.Command { return err } - customAppTemplate, customAppConfig := evmdconfig.InitAppConfig(evmdconfig.BaseDenom, evmdconfig.EVMChainID) + customAppTemplate, customAppConfig := evmdconfig.InitAppConfig(evmdconfig.BaseDenom, evmdconfig.DefaultEvmChainID) customTMConfig := initCometConfig() return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig) @@ -143,7 +141,7 @@ func NewRootCmd() *cobra.Command { if initClientCtx.ChainID == "" { // if the chain id is not set in client.toml, populate it with the default evm chain id - initClientCtx = initClientCtx.WithChainID(strconv.FormatUint(evmdconfig.EVMChainID, 10)) + initClientCtx = initClientCtx.WithChainID(strconv.FormatUint(evmdconfig.DefaultEvmChainID, 10)) } initClientCtx, _ = clientcfg.ReadFromClientConfig(initClientCtx) @@ -153,7 +151,9 @@ func NewRootCmd() *cobra.Command { panic(err) } - if err := evmdconfig.EvmAppOptions(evmdconfig.EVMChainID); err != nil { + chainConfig := evmdconfig.DefaultChainConfig + + if err := chainConfig.ApplyChainConfig(); err != nil { panic(err) } @@ -296,7 +296,7 @@ func newApp( } // get the chain id - chainID, err := evmdconfig.GetEvmChainID(appOpts) + chainID, err := evmdconfig.GetChainID(appOpts) if err != nil { panic(err) } @@ -326,11 +326,15 @@ func newApp( baseapp.SetChainID(chainID), } + chainConfig, err := evmdconfig.CreateChainConfig(appOpts) + if err != nil { + panic(err) + } + return evmd.NewExampleApp( logger, db, traceStore, true, appOpts, - evmdconfig.EVMChainID, - evmdconfig.EvmAppOptions, + *chainConfig, baseappOptions..., ) } @@ -365,19 +369,25 @@ func appExport( appOpts = viperAppOpts // get the chain id - chainID, err := evmdconfig.GetEvmChainID(appOpts) + chainID, err := evmdconfig.GetChainID(appOpts) + if err != nil { + return servertypes.ExportedApp{}, err + } + + // create the chain config + chainConfig, err := evmdconfig.CreateChainConfig(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 = evmd.NewExampleApp(logger, db, traceStore, false, appOpts, *chainConfig, 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 = evmd.NewExampleApp(logger, db, traceStore, true, appOpts, *chainConfig, baseapp.SetChainID(chainID)) } return exampleApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) diff --git a/evmd/cmd/evmd/cmd/testnet.go b/evmd/cmd/evmd/cmd/testnet.go index c90690cb0..af5a66417 100644 --- a/evmd/cmd/evmd/cmd/testnet.go +++ b/evmd/cmd/evmd/cmd/testnet.go @@ -268,7 +268,7 @@ func initTestnetFiles( appConfig.Telemetry.EnableHostnameLabel = false appConfig.Telemetry.GlobalLabels = [][]string{{"chain_id", args.chainID}} evm := cosmosevmserverconfig.DefaultEVMConfig() - evm.EVMChainID = evmdconfig.EVMChainID + evm.EVMChainID = evmdconfig.DefaultEvmChainID evmCfg := evmdconfig.EVMAppConfig{ Config: *appConfig, EVM: *evm, @@ -683,7 +683,7 @@ func NewTestNetworkFixture() network.TestFixture { nil, true, simtestutil.EmptyAppOptions{}, - evmdconfig.EVMChainID, + evmdconfig.DefaultEvmChainID, evmdconfig.EvmAppOptions, ) @@ -694,7 +694,7 @@ func NewTestNetworkFixture() network.TestFixture { nil, true, simtestutil.EmptyAppOptions{}, - evmdconfig.EVMChainID, + evmdconfig.DefaultEvmChainID, evmdconfig.EvmAppOptions, ) } diff --git a/evmd/cmd/evmd/config/chain_config.go b/evmd/cmd/evmd/config/chain_config.go new file mode 100644 index 000000000..6827dc93c --- /dev/null +++ b/evmd/cmd/evmd/config/chain_config.go @@ -0,0 +1,84 @@ +package config + +import ( + "fmt" + + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/evm/x/vm/types" + "github.com/ethereum/go-ethereum/core/vm" +) + +type ChainConfig struct { + ChainID string + EvmChainID uint64 + EvmConfig *types.EvmConfig +} + +// NewChainConfig creates a chain config with custom parameters, using defaults if not provided +func NewChainConfig( + chainID string, + evmChainID uint64, + evmActivators map[int]func(*vm.JumpTable), + evmExtraEIPs []int64, + evmChainConfig *types.ChainConfig, + evmCoinInfo types.EvmCoinInfo, + reset bool, +) ChainConfig { + if evmChainConfig == nil { + evmChainConfig = types.DefaultChainConfig(evmChainID, evmCoinInfo) + } + + evmConfig := types.NewEvmConfig(). + WithChainConfig(evmChainConfig). + WithEVMCoinInfo(evmCoinInfo). + WithExtendedEips(evmActivators). + WithExtendedDefaultExtraEIPs(evmExtraEIPs...) + + if reset { + evmConfig.ResetTestConfig() + } + + return ChainConfig{ + ChainID: chainID, + EvmChainID: evmChainID, + EvmConfig: evmConfig, + } +} + +// ApplyEvmConfig applies the evm config to the global singleton chain config and coin info +func (cc *ChainConfig) ApplyChainConfig() error { + if cc.EvmConfig == nil { + return nil // no op if evm config is nil + } + if cc.EvmConfig == nil { + return fmt.Errorf("evm config is nil, cannot apply chain config") + } + if cc.EvmConfig.GetChainConfig() == nil { + return fmt.Errorf("chain config is nil, cannot apply chain config") + } + + if err := setBaseDenom(cc.EvmConfig.GetEVMCoinInfo()); err != nil { + return err + } + return cc.EvmConfig.Apply() +} + +// 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 types.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/evmd/cmd/evmd/config/config.go b/evmd/cmd/evmd/config/config.go index 6c49bbcd9..5f76b2c4d 100644 --- a/evmd/cmd/evmd/config/config.go +++ b/evmd/cmd/evmd/config/config.go @@ -7,6 +7,23 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +// DefaultChainConfig provides a standard 18-decimal cosmos/atom test configuration +var ( + DefaultChainConfig = NewChainConfig( + DefaultChainID, + DefaultEvmChainID, + cosmosEVMActivators, + nil, + nil, + evmtypes.EvmCoinInfo{ + DisplayDenom: DisplayDenom, + Decimals: Decimals, + ExtendedDecimals: ExtendedDecimals, + }, + false, + ) +) + // 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 @@ -23,7 +40,7 @@ var ChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ ExtendedDecimals: evmtypes.EighteenDecimals, }, // EVMChainID provides a chain ID used for internal testing - EVMChainID: { + DefaultEvmChainID: { DisplayDenom: "test", Decimals: evmtypes.EighteenDecimals, ExtendedDecimals: evmtypes.EighteenDecimals, @@ -49,10 +66,11 @@ const ( 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 + // Decimals defines the precision of the base denomination. + Decimals = evmtypes.EighteenDecimals + ExtendedDecimals = evmtypes.EighteenDecimals + // DefaultEvmChainID defines the EIP-155 replay-protection chain id for the current ethereum chain config. + DefaultEvmChainID = 262144 // 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. @@ -65,6 +83,7 @@ const ( TwelveDecimalsChainID = 9003 // TwoDecimalsChainID is the chain ID for the 2 decimals chain. TwoDecimalsChainID = 9004 + DefaultChainID = "cosmos" CosmosChainID = 262144 // TestChainID1 is test chain IDs for IBC E2E test TestChainID1 = 9005 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/server_app_options.go b/evmd/cmd/evmd/config/server_app_options.go index 0ca0c3c47..8731fa594 100644 --- a/evmd/cmd/evmd/config/server_app_options.go +++ b/evmd/cmd/evmd/config/server_app_options.go @@ -1,6 +1,7 @@ package config import ( + "errors" "math" "path/filepath" @@ -8,7 +9,9 @@ import ( "github.com/spf13/cast" "cosmossdk.io/log" + evmconfig "github.com/cosmos/evm/config" srvflags "github.com/cosmos/evm/server/flags" + evmtypes "github.com/cosmos/evm/x/vm/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" @@ -94,9 +97,9 @@ func GetMinTip(appOpts servertypes.AppOptions, logger log.Logger) *uint256.Int { return nil } -// GetEvmChainID returns the EVM chain ID from the app options, set from +// GetChainID returns the EVM chain ID from the app options, set from // If not available, it will load from client.toml -func GetEvmChainID(appOpts servertypes.AppOptions) (string, error) { +func GetChainID(appOpts servertypes.AppOptions) (string, error) { chainID := cast.ToString(appOpts.Get(flags.FlagChainID)) if chainID == "" { // if not available, load from client.toml @@ -110,3 +113,65 @@ func GetEvmChainID(appOpts servertypes.AppOptions) (string, error) { 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 GetEvmCoinInfo(appOpts servertypes.AppOptions) (*evmtypes.EvmCoinInfo, error) { + displayDenom := cast.ToString(appOpts.Get(srvflags.EVMDisplayDenom)) + if displayDenom == "" { + return nil, errors.New("display denom flag not found in app options") + } + decimals := cast.ToUint8(appOpts.Get(srvflags.EVMDecimals)) + if decimals == 0 { + return nil, errors.New("decimals flag not found in app options") + } + extendedDecimals := cast.ToUint8(appOpts.Get(srvflags.EVMExtendedDecimals)) + if extendedDecimals == 0 { + return nil, errors.New("extended decimals flag not found in app options") + } + + evmCoinInfo := evmtypes.EvmCoinInfo{ + DisplayDenom: displayDenom, + Decimals: evmtypes.Decimals(decimals), + ExtendedDecimals: evmtypes.Decimals(extendedDecimals), + } + if err := evmCoinInfo.Validate(); err != nil { + return nil, err + } + + return &evmCoinInfo, nil +} + +func CreateChainConfig(appOpts servertypes.AppOptions) (*evmconfig.ChainConfig, error) { + chainID, err := GetChainID(appOpts) + if err != nil { + return nil, err + } + evmChainID, err := GetEvmChainID(appOpts) + if err != nil { + return nil, err + } + evmCoinInfo, err := GetEvmCoinInfo(appOpts) + if err != nil { + return nil, err + } + + chainConfig := evmconfig.NewChainConfig( + chainID, + evmChainID, + cosmosEVMActivators, + nil, + nil, + *evmCoinInfo, + false, + ) + + return &chainConfig, nil +} diff --git a/tests/integration/x/vm/keeper_test_suite.go b/tests/integration/x/vm/keeper_test_suite.go index 5347cdf4f..60893608d 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" + testconstants "github.com/cosmos/evm/testutil/constants" "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 := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] + chainConfig := evmtypes.DefaultChainConfig(s.Network.GetEIP155ChainID().Uint64(), coinInfo) if !s.EnableLondonHF { maxInt := sdkmath.NewInt(math.MaxInt64) chainConfig.LondonBlock = &maxInt diff --git a/tests/integration/x/vm/test_grpc_query.go b/tests/integration/x/vm/test_grpc_query.go index 59f874d9b..f5c65f9c5 100644 --- a/tests/integration/x/vm/test_grpc_query.go +++ b/tests/integration/x/vm/test_grpc_query.go @@ -1592,7 +1592,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 := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] + chainConfig := types.DefaultChainConfig(s.Network.GetEIP155ChainID().Uint64(), coinInfo) maxInt := sdkmath.NewInt(math.MaxInt64) chainConfig.LondonBlock = &maxInt chainConfig.ArrowGlacierBlock = &maxInt diff --git a/testutil/config/constants.go b/testutil/config/constants.go index fb9bdbe4b..3a7354cd9 100644 --- a/testutil/config/constants.go +++ b/testutil/config/constants.go @@ -19,8 +19,6 @@ const ( // 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 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/x/vm/types/chain_config.go b/x/vm/types/chain_config.go index f81f19942..a674675dc 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 @@ -58,11 +55,7 @@ func (cc ChainConfig) EthereumConfig(chainID *big.Int) *gethparams.ChainConfig { } } -func DefaultChainConfig(evmChainID uint64) *ChainConfig { - if evmChainID == 0 { - evmChainID = testChainID - } - +func DefaultChainConfig(evmChainID uint64, coinInfo EvmCoinInfo) *ChainConfig { homesteadBlock := sdkmath.ZeroInt() daoForkBlock := sdkmath.ZeroInt() eip150Block := sdkmath.ZeroInt() @@ -84,8 +77,8 @@ func DefaultChainConfig(evmChainID uint64) *ChainConfig { cfg := &ChainConfig{ ChainId: evmChainID, - Denom: DefaultEVMDenom, - Decimals: DefaultEVMDecimals, + Denom: coinInfo.GetDenom(), + Decimals: uint64(coinInfo.Decimals), HomesteadBlock: &homesteadBlock, DAOForkBlock: &daoForkBlock, DAOForkSupport: true, @@ -116,17 +109,16 @@ func DefaultChainConfig(evmChainID uint64) *ChainConfig { // 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/evm_config.go b/x/vm/types/evm_config.go index 5c3c23a7f..d2d26c2bb 100644 --- a/x/vm/types/evm_config.go +++ b/x/vm/types/evm_config.go @@ -23,6 +23,14 @@ func NewEvmConfig() *EvmConfig { return &EvmConfig{} } +func (ec *EvmConfig) GetChainConfig() *ChainConfig { + return ec.chainConfig +} + +func (ec *EvmConfig) GetEVMCoinInfo() EvmCoinInfo { + return ec.evmCoinInfo +} + // 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 { From fc87a641be39cfc6f1b1c12eb7083221a2bffb38 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 14:49:29 -0400 Subject: [PATCH 12/27] add chainconfig replacement --- ante/evm/fee_checker_test.go | 9 ++--- ante/evm/mono_decorator_test.go | 2 +- .../evmd/config => config}/chain_config.go | 0 {evmd/cmd/evmd/config => config}/config.go | 23 +++++++++++- {evmd => config}/eips/README.md | 0 config/eips/activators.go | 15 ++++++++ {evmd => config}/eips/eips.go | 0 .../config => config}/server_app_options.go | 14 +++++--- .../server_app_options_test.go | 0 evmd/app.go | 5 +-- evmd/cmd/evmd/cmd/creator.go | 6 ++-- evmd/cmd/evmd/cmd/root.go | 16 ++++----- evmd/cmd/evmd/cmd/testnet.go | 11 +++--- evmd/cmd/evmd/config/activators.go | 15 -------- evmd/cmd/evmd/config/evm_app_options.go | 14 -------- evmd/cmd/evmd/main.go | 4 +-- evmd/genesis.go | 2 +- evmd/test_helpers.go | 17 +++++---- evmd/{ => tests}/eips/eips_test.go | 4 +-- evmd/{ => tests}/eips/testdata/Counter.json | 0 evmd/{ => tests}/eips/testdata/Counter.sol | 0 .../eips/testdata/CounterFactory.json | 0 .../eips/testdata/CounterFactory.sol | 0 evmd/{ => tests}/eips/testdata/contracts.go | 0 evmd/tests/integration/create_app.go | 35 +++++++++++++++---- evmd/tests/integration/x_vm_test.go | 4 ++- evmd/tests/network/network.go | 33 ++++++++++++++--- rpc/backend/call_tx.go | 7 +++- tests/integration/ante/ante_test_suite.go | 4 ++- tests/integration/x/vm/test_grpc_query.go | 2 +- testutil/config/config_testing.go | 19 +++++++++- testutil/ibc/coordinator.go | 5 +-- x/precisebank/keeper/keeper_test.go | 5 +-- x/vm/types/chain_config_test.go | 2 +- x/vm/types/config_testing.go | 18 +++++++--- x/vm/types/msg_test.go | 5 +-- 36 files changed, 196 insertions(+), 100 deletions(-) rename {evmd/cmd/evmd/config => config}/chain_config.go (100%) rename {evmd/cmd/evmd/config => config}/config.go (89%) rename {evmd => config}/eips/README.md (100%) create mode 100644 config/eips/activators.go rename {evmd => config}/eips/eips.go (100%) rename {evmd/cmd/evmd/config => config}/server_app_options.go (93%) rename {evmd/cmd/evmd/config => config}/server_app_options_test.go (100%) delete mode 100644 evmd/cmd/evmd/config/activators.go delete mode 100644 evmd/cmd/evmd/config/evm_app_options.go rename evmd/{ => tests}/eips/eips_test.go (99%) rename evmd/{ => tests}/eips/testdata/Counter.json (100%) rename evmd/{ => tests}/eips/testdata/Counter.sol (100%) rename evmd/{ => tests}/eips/testdata/CounterFactory.json (100%) rename evmd/{ => tests}/eips/testdata/CounterFactory.sol (100%) rename evmd/{ => tests}/eips/testdata/contracts.go (100%) diff --git a/ante/evm/fee_checker_test.go b/ante/evm/fee_checker_test.go index a5cbc3734..b75c0c1a9 100644 --- a/ante/evm/fee_checker_test.go +++ b/ante/evm/fee_checker_test.go @@ -10,8 +10,8 @@ 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" "github.com/cosmos/evm/types" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" @@ -57,9 +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) + + chainConfig := evmconfig.NewTestChainConfig(evmconfig.DefaultEvmChainID) + encodingConfig := encoding.MakeConfig(chainConfig.EvmChainID) + err := chainConfig.ApplyChainConfig() require.NoError(t, err) evmDenom := evmtypes.GetEVMCoinDenom() diff --git a/ante/evm/mono_decorator_test.go b/ante/evm/mono_decorator_test.go index 0c1fed7ed..bc0178fe3 100644 --- a/ante/evm/mono_decorator_test.go +++ b/ante/evm/mono_decorator_test.go @@ -144,7 +144,7 @@ func toMsgSlice(msgs []*evmsdktypes.MsgEthereumTx) []sdk.Msg { } func TestMonoDecorator(t *testing.T) { - chainConfig := evmconfig.DefaultChainConfig + chainConfig := evmconfig.NewTestChainConfig(evmconfig.DefaultEvmChainID) require.NoError(t, chainConfig.ApplyChainConfig()) cfg := encoding.MakeConfig(chainConfig.EvmChainID) diff --git a/evmd/cmd/evmd/config/chain_config.go b/config/chain_config.go similarity index 100% rename from evmd/cmd/evmd/config/chain_config.go rename to config/chain_config.go diff --git a/evmd/cmd/evmd/config/config.go b/config/config.go similarity index 89% rename from evmd/cmd/evmd/config/config.go rename to config/config.go index 5f76b2c4d..4f76b7a1a 100644 --- a/evmd/cmd/evmd/config/config.go +++ b/config/config.go @@ -1,6 +1,7 @@ package config import ( + "github.com/cosmos/evm/config/eips" "github.com/cosmos/evm/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -12,7 +13,7 @@ var ( DefaultChainConfig = NewChainConfig( DefaultChainID, DefaultEvmChainID, - cosmosEVMActivators, + eips.CosmosEVMActivators, nil, nil, evmtypes.EvmCoinInfo{ @@ -106,3 +107,23 @@ func SetBip44CoinType(config *sdk.Config) { config.SetPurpose(sdk.Purpose) // Shared config.SetFullFundraiserPath(types.BIP44HDPath) //nolint: staticcheck } + +// NewTestChainConfig creates a fresh chain config for testing purposes +// This avoids the issue of shared EvmConfig instances being sealed +func NewTestChainConfig(evmChainID uint64) ChainConfig { + coinInfo := evmtypes.EvmCoinInfo{ + DisplayDenom: DisplayDenom, + Decimals: Decimals, + ExtendedDecimals: ExtendedDecimals, + } + + return NewChainConfig( + DefaultChainID, + evmChainID, + eips.CosmosEVMActivators, + nil, + nil, + coinInfo, + true, // reset = true for testing + ) +} diff --git a/evmd/eips/README.md b/config/eips/README.md similarity index 100% rename from evmd/eips/README.md rename to config/eips/README.md diff --git a/config/eips/activators.go b/config/eips/activators.go new file mode 100644 index 000000000..6536179e4 --- /dev/null +++ b/config/eips/activators.go @@ -0,0 +1,15 @@ +package eips + +import ( + "github.com/ethereum/go-ethereum/core/vm" +) + +var ( + // CosmosEVMActivators defines a map of opcode modifiers associated + // with a key defining the corresponding EIP. + 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/evmd/cmd/evmd/config/server_app_options.go b/config/server_app_options.go similarity index 93% rename from evmd/cmd/evmd/config/server_app_options.go rename to config/server_app_options.go index 8731fa594..47551f902 100644 --- a/evmd/cmd/evmd/config/server_app_options.go +++ b/config/server_app_options.go @@ -9,7 +9,7 @@ import ( "github.com/spf13/cast" "cosmossdk.io/log" - evmconfig "github.com/cosmos/evm/config" + "github.com/cosmos/evm/config/eips" srvflags "github.com/cosmos/evm/server/flags" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -103,7 +103,11 @@ func GetChainID(appOpts servertypes.AppOptions) (string, error) { chainID := cast.ToString(appOpts.Get(flags.FlagChainID)) if chainID == "" { // if not available, load from client.toml - clientCtx := client.Context{}.WithHomeDir(MustGetDefaultNodeHome()) + 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 @@ -149,7 +153,7 @@ func GetEvmCoinInfo(appOpts servertypes.AppOptions) (*evmtypes.EvmCoinInfo, erro return &evmCoinInfo, nil } -func CreateChainConfig(appOpts servertypes.AppOptions) (*evmconfig.ChainConfig, error) { +func CreateChainConfig(appOpts servertypes.AppOptions) (*ChainConfig, error) { chainID, err := GetChainID(appOpts) if err != nil { return nil, err @@ -163,10 +167,10 @@ func CreateChainConfig(appOpts servertypes.AppOptions) (*evmconfig.ChainConfig, return nil, err } - chainConfig := evmconfig.NewChainConfig( + chainConfig := NewChainConfig( chainID, evmChainID, - cosmosEVMActivators, + eips.CosmosEVMActivators, nil, nil, *evmCoinInfo, diff --git a/evmd/cmd/evmd/config/server_app_options_test.go b/config/server_app_options_test.go similarity index 100% rename from evmd/cmd/evmd/config/server_app_options_test.go rename to config/server_app_options_test.go diff --git a/evmd/app.go b/evmd/app.go index fb3fb790d..54859ff43 100644 --- a/evmd/app.go +++ b/evmd/app.go @@ -21,6 +21,7 @@ import ( evmante "github.com/cosmos/evm/ante" cosmosevmante "github.com/cosmos/evm/ante/evm" "github.com/cosmos/evm/config" + evmconfig "github.com/cosmos/evm/config" evmosencoding "github.com/cosmos/evm/encoding" "github.com/cosmos/evm/evmd/ante" evmmempool "github.com/cosmos/evm/mempool" @@ -754,9 +755,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 := evmdconfig.GetBlockGasLimit(appOpts, logger) + blockGasLimit := evmconfig.GetBlockGasLimit(appOpts, logger) // Get GetMinTip from app.toml or cli flag configuration - mipTip := evmdconfig.GetMinTip(appOpts, logger) + mipTip := evmconfig.GetMinTip(appOpts, logger) mempoolConfig := &evmmempool.EVMMempoolConfig{ AnteHandler: app.GetAnteHandler(), diff --git a/evmd/cmd/evmd/cmd/creator.go b/evmd/cmd/evmd/cmd/creator.go index 77b067381..73aac47ad 100644 --- a/evmd/cmd/evmd/cmd/creator.go +++ b/evmd/cmd/evmd/cmd/creator.go @@ -12,8 +12,8 @@ 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" + evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/evmd" - evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" "github.com/spf13/cast" "github.com/spf13/viper" @@ -88,7 +88,7 @@ func (a appCreator) newApp( baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))), } - chainConfig, err := evmdconfig.CreateChainConfig(appOpts) + chainConfig, err := evmconfig.CreateChainConfig(appOpts) if err != nil { panic(err) } @@ -135,7 +135,7 @@ func (a appCreator) appExport( loadLatest = true } - chainConfig, err := evmdconfig.CreateChainConfig(appOpts) + chainConfig, err := evmconfig.CreateChainConfig(appOpts) if err != nil { return servertypes.ExportedApp{}, err } diff --git a/evmd/cmd/evmd/cmd/root.go b/evmd/cmd/evmd/cmd/root.go index c42358a04..da63597c3 100644 --- a/evmd/cmd/evmd/cmd/root.go +++ b/evmd/cmd/evmd/cmd/root.go @@ -130,7 +130,7 @@ func NewRootCmd() *cobra.Command { return err } - customAppTemplate, customAppConfig := evmdconfig.InitAppConfig(evmdconfig.BaseDenom, evmdconfig.DefaultEvmChainID) + customAppTemplate, customAppConfig := evmdconfig.InitAppConfig(evmconfig.BaseDenom, evmconfig.DefaultEvmChainID) customTMConfig := initCometConfig() return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig) @@ -141,7 +141,7 @@ func NewRootCmd() *cobra.Command { if initClientCtx.ChainID == "" { // if the chain id is not set in client.toml, populate it with the default evm chain id - initClientCtx = initClientCtx.WithChainID(strconv.FormatUint(evmdconfig.DefaultEvmChainID, 10)) + initClientCtx = initClientCtx.WithChainID(strconv.FormatUint(evmconfig.DefaultEvmChainID, 10)) } initClientCtx, _ = clientcfg.ReadFromClientConfig(initClientCtx) @@ -151,7 +151,7 @@ func NewRootCmd() *cobra.Command { panic(err) } - chainConfig := evmdconfig.DefaultChainConfig + chainConfig := evmconfig.NewTestChainConfig(evmconfig.DefaultEvmChainID) if err := chainConfig.ApplyChainConfig(); err != nil { panic(err) @@ -162,7 +162,7 @@ func NewRootCmd() *cobra.Command { func setupSDKConfig() { config := sdk.GetConfig() - evmdconfig.SetBech32Prefixes(config) + evmconfig.SetBech32Prefixes(config) config.Seal() } @@ -296,7 +296,7 @@ func newApp( } // get the chain id - chainID, err := evmdconfig.GetChainID(appOpts) + chainID, err := evmconfig.GetChainID(appOpts) if err != nil { panic(err) } @@ -326,7 +326,7 @@ func newApp( baseapp.SetChainID(chainID), } - chainConfig, err := evmdconfig.CreateChainConfig(appOpts) + chainConfig, err := evmconfig.CreateChainConfig(appOpts) if err != nil { panic(err) } @@ -369,13 +369,13 @@ func appExport( appOpts = viperAppOpts // get the chain id - chainID, err := evmdconfig.GetChainID(appOpts) + chainID, err := evmconfig.GetChainID(appOpts) if err != nil { return servertypes.ExportedApp{}, err } // create the chain config - chainConfig, err := evmdconfig.CreateChainConfig(appOpts) + chainConfig, err := evmconfig.CreateChainConfig(appOpts) if err != nil { return servertypes.ExportedApp{}, err } diff --git a/evmd/cmd/evmd/cmd/testnet.go b/evmd/cmd/evmd/cmd/testnet.go index af5a66417..8ee891b07 100644 --- a/evmd/cmd/evmd/cmd/testnet.go +++ b/evmd/cmd/evmd/cmd/testnet.go @@ -12,7 +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" + evmconfig "github.com/cosmos/evm/config" + evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" dbm "github.com/cosmos/cosmos-db" @@ -268,7 +269,7 @@ func initTestnetFiles( appConfig.Telemetry.EnableHostnameLabel = false appConfig.Telemetry.GlobalLabels = [][]string{{"chain_id", args.chainID}} evm := cosmosevmserverconfig.DefaultEVMConfig() - evm.EVMChainID = evmdconfig.DefaultEvmChainID + evm.EVMChainID = evmconfig.DefaultEvmChainID evmCfg := evmdconfig.EVMAppConfig{ Config: *appConfig, EVM: *evm, @@ -683,8 +684,7 @@ func NewTestNetworkFixture() network.TestFixture { nil, true, simtestutil.EmptyAppOptions{}, - evmdconfig.DefaultEvmChainID, - evmdconfig.EvmAppOptions, + evmconfig.DefaultChainConfig, ) appCtr := func(val network.ValidatorI) servertypes.Application { @@ -694,8 +694,7 @@ func NewTestNetworkFixture() network.TestFixture { nil, true, simtestutil.EmptyAppOptions{}, - evmdconfig.DefaultEvmChainID, - evmdconfig.EvmAppOptions, + evmconfig.DefaultChainConfig, ) } 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/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 index cd63910e1..3dad66a57 100644 --- a/evmd/cmd/evmd/main.go +++ b/evmd/cmd/evmd/main.go @@ -5,14 +5,14 @@ import ( "os" "github.com/cosmos/evm/evmd/cmd/evmd/cmd" - evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" + evmconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" ) func main() { rootCmd := cmd.NewRootCmd() - if err := svrcmd.Execute(rootCmd, "evmd", evmdconfig.MustGetDefaultNodeHome()); err != nil { + if err := svrcmd.Execute(rootCmd, "evmd", evmconfig.MustGetDefaultNodeHome()); err != nil { fmt.Fprintln(rootCmd.OutOrStderr(), err) os.Exit(1) } diff --git a/evmd/genesis.go b/evmd/genesis.go index 7d656730b..a21b03423 100644 --- a/evmd/genesis.go +++ b/evmd/genesis.go @@ -3,7 +3,7 @@ package evmd import ( "encoding/json" - "github.com/cosmos/evm/evmd/cmd/evmd/config" + "github.com/cosmos/evm/config" testconstants "github.com/cosmos/evm/testutil/constants" erc20types "github.com/cosmos/evm/x/erc20/types" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" diff --git a/evmd/test_helpers.go b/evmd/test_helpers.go index b7e77d9b3..54c08d721 100644 --- a/evmd/test_helpers.go +++ b/evmd/test_helpers.go @@ -5,14 +5,13 @@ import ( "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" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" ibctesting "github.com/cosmos/ibc-go/v10/testing" @@ -44,8 +43,8 @@ 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) { @@ -55,7 +54,8 @@ func setup(withGenesis bool, invCheckPeriod uint, chainID string, evmChainID uin appOptions[flags.FlagHome] = defaultNodeHome appOptions[server.FlagInvCheckPeriod] = invCheckPeriod - app := NewExampleApp(log.NewNopLogger(), db, nil, true, appOptions, evmChainID, testconfig.EvmAppOptions, baseapp.SetChainID(chainID)) + chainConfig := evmconfig.DefaultChainConfig + app := NewExampleApp(log.NewNopLogger(), db, nil, true, appOptions, chainConfig, baseapp.SetChainID(chainID)) if withGenesis { return app, app.DefaultGenesis() } @@ -124,16 +124,15 @@ 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), + chainConfig, + baseapp.SetChainID(chainConfig.ChainID), ) return app, app.DefaultGenesis() } diff --git a/evmd/eips/eips_test.go b/evmd/tests/eips/eips_test.go similarity index 99% rename from evmd/eips/eips_test.go rename to evmd/tests/eips/eips_test.go index 512881342..151853b17 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,7 +13,7 @@ import ( //nolint:revive // dot imports are fine for Ginkgo . "github.com/onsi/gomega" - "github.com/cosmos/evm/evmd/eips/testdata" + "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" 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/integration/create_app.go b/evmd/tests/integration/create_app.go index fd05c278f..d6b52c21c 100644 --- a/evmd/tests/integration/create_app.go +++ b/evmd/tests/integration/create_app.go @@ -5,9 +5,8 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/evm" + "github.com/cosmos/evm/config" "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" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" ibctesting "github.com/cosmos/ibc-go/v10/testing" @@ -36,14 +35,26 @@ func CreateEvmd(chainID string, evmChainID uint64, customBaseAppOptions ...func( baseAppOptions := append(customBaseAppOptions, baseapp.SetChainID(chainID)) + coinInfo := constants.ExampleChainCoinInfo[constants.ExampleChainID] + chainConfig := config.NewChainConfig( + constants.ExampleChainID.ChainID, + evmChainID, + nil, + nil, + nil, + coinInfo, + false, + ) + if err := chainConfig.ApplyChainConfig(); err != nil { + panic(err) + } return evmd.NewExampleApp( logger, db, nil, loadLatest, appOptions, - evmChainID, - testconfig.EvmAppOptions, + chainConfig, baseAppOptions..., ) } @@ -51,14 +62,26 @@ func CreateEvmd(chainID string, evmChainID uint64, customBaseAppOptions ...func( // 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) { + coinInfo := constants.ExampleChainCoinInfo[constants.ExampleChainID] + chainConfig := config.NewChainConfig( + constants.ExampleChainID.ChainID, + constants.ExampleEIP155ChainID, + nil, + nil, + nil, + coinInfo, + false, + ) + if err := chainConfig.ApplyChainConfig(); err != nil { + panic(err) + } app := evmd.NewExampleApp( log.NewNopLogger(), dbm.NewMemDB(), nil, true, simutils.EmptyAppOptions{}, - constants.ExampleEIP155ChainID, - testconfig.EvmAppOptions, + chainConfig, ) // disable base fee for testing genesisState := app.DefaultGenesis() diff --git a/evmd/tests/integration/x_vm_test.go b/evmd/tests/integration/x_vm_test.go index a95c07391..47a2de85e 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" + "github.com/cosmos/evm/testutil/constants" "github.com/cosmos/evm/testutil/integration/evm/network" "github.com/cosmos/evm/testutil/keyring" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" @@ -32,7 +33,8 @@ func BenchmarkGasEstimation(b *testing.B) { // gh := grpc.NewIntegrationHandler(nw) // tf := factory.New(nw, gh) - chainConfig := types.DefaultChainConfig(nw.GetEIP155ChainID().Uint64()) + coinInfo := constants.ExampleChainCoinInfo[constants.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 displayDenom := types.GetEVMCoinDisplayDenom() diff --git a/evmd/tests/network/network.go b/evmd/tests/network/network.go index 51fb9133f..11702ef65 100644 --- a/evmd/tests/network/network.go +++ b/evmd/tests/network/network.go @@ -27,11 +27,11 @@ import ( cmtclient "github.com/cometbft/cometbft/rpc/client" dbm "github.com/cosmos/cosmos-db" + evmconfig "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" - testconfig "github.com/cosmos/evm/testutil/config" testconstants "github.com/cosmos/evm/testutil/constants" cosmosevmtypes "github.com/cosmos/evm/types" @@ -110,7 +110,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 := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] + chainConfig := evmconfig.NewChainConfig( + chainID, + evmChainID, + nil, + nil, + nil, + coinInfo, + false, + ) + if err := chainConfig.ApplyChainConfig(); err != nil { + panic(err) + } + tempApp := evmd.NewExampleApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simutils.NewAppOptionsWithFlagHome(dir), chainConfig, baseapp.SetChainID(chainID)) cfg := Config{ Codec: tempApp.AppCodec(), @@ -140,11 +153,23 @@ func DefaultConfig() Config { // NewAppConstructor returns a new Cosmos EVM AppConstructor func NewAppConstructor(chainID string, evmChainID uint64) AppConstructor { return func(val Validator) servertypes.Application { + coinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] + chainConfig := evmconfig.NewChainConfig( + chainID, + evmChainID, + nil, + nil, + nil, + coinInfo, + false, + ) + if err := chainConfig.ApplyChainConfig(); err != nil { + panic(err) + } return evmd.NewExampleApp( val.Ctx.Logger, dbm.NewMemDB(), nil, true, simutils.NewAppOptionsWithFlagHome(val.Ctx.Config.RootDir), - evmChainID, - testconfig.EvmAppOptions, + chainConfig, baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), baseapp.SetChainID(chainID), diff --git a/rpc/backend/call_tx.go b/rpc/backend/call_tx.go index e444cc9b2..bb2d29b75 100644 --- a/rpc/backend/call_tx.go +++ b/rpc/backend/call_tx.go @@ -42,7 +42,12 @@ func (b *Backend) Resend(args evmtypes.TransactionArgs, gasPrice *hexutil.Big, g // signers to be backwards-compatible with old transactions. cfg := b.ChainConfig() if cfg == nil { - cfg = evmtypes.DefaultChainConfig(b.EvmChainID.Uint64()).EthereumConfig(nil) + coinInfo := evmtypes.EvmCoinInfo{ + DisplayDenom: evmtypes.GetEVMCoinDisplayDenom(), + Decimals: evmtypes.GetEVMCoinDecimals(), + ExtendedDecimals: evmtypes.GetEVMCoinExtendedDecimals(), + } + cfg = evmtypes.DefaultChainConfig(b.EvmChainID.Uint64(), coinInfo).EthereumConfig(nil) } signer := ethtypes.LatestSigner(cfg) diff --git a/tests/integration/ante/ante_test_suite.go b/tests/integration/ante/ante_test_suite.go index 0fb9db71c..03d5cf70d 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" + "github.com/cosmos/evm/testutil/constants" "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 := constants.ExampleChainCoinInfo[constants.ExampleChainID] + chainConfig := evmtypes.DefaultChainConfig(s.network.GetEIP155ChainID().Uint64(), coinInfo) if !s.enableLondonHF { maxInt := sdkmath.NewInt(math.MaxInt64) chainConfig.LondonBlock = &maxInt diff --git a/tests/integration/x/vm/test_grpc_query.go b/tests/integration/x/vm/test_grpc_query.go index f5c65f9c5..89aa28ff6 100644 --- a/tests/integration/x/vm/test_grpc_query.go +++ b/tests/integration/x/vm/test_grpc_query.go @@ -1637,7 +1637,7 @@ func (s *KeeperTestSuite) TestQueryBaseFee() { Decimals: types.GetEVMCoinDecimals(), ExtendedDecimals: types.GetEVMCoinExtendedDecimals(), } - chainConfig := types.DefaultChainConfig(s.Network.GetEIP155ChainID().Uint64()) + chainConfig := types.DefaultChainConfig(s.Network.GetEIP155ChainID().Uint64(), coinInfo) for _, tc := range testCases { s.Run(tc.name, func() { diff --git a/testutil/config/config_testing.go b/testutil/config/config_testing.go index 9781099fa..a0cd819e5 100644 --- a/testutil/config/config_testing.go +++ b/testutil/config/config_testing.go @@ -52,5 +52,22 @@ var TestChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ // EvmAppOptions allows to setup the global configuration // for the Cosmos EVM chain. func EvmAppOptions(chainID uint64) error { - return evmconfig.EvmAppOptionsWithConfigWithReset(chainID, TestChainsCoinInfo, cosmosEVMActivators, true) + coinInfo, exists := TestChainsCoinInfo[chainID] + if !exists { + coinInfo = evmtypes.EvmCoinInfo{ + DisplayDenom: "test", + Decimals: evmtypes.EighteenDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, + } + } + chainConfig := evmconfig.NewChainConfig( + "test", + chainID, + cosmosEVMActivators, + nil, + nil, + coinInfo, + true, + ) + return chainConfig.ApplyChainConfig() } diff --git a/testutil/ibc/coordinator.go b/testutil/ibc/coordinator.go index c4823df48..e424727bb 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.NewTestChainConfig(evmChainID) require.NoError(t, err) - require.NoError(t, config.EvmAppOptions(evmChainID)) + require.NoError(t, chainConfig.ApplyChainConfig()) // setup EVM chains chains[strconv.FormatUint(evmChainID, 10)] = NewTestChain(t, true, coord, chainID) } diff --git a/x/precisebank/keeper/keeper_test.go b/x/precisebank/keeper/keeper_test.go index 75a4656ef..f1ce34828 100644 --- a/x/precisebank/keeper/keeper_test.go +++ b/x/precisebank/keeper/keeper_test.go @@ -3,8 +3,8 @@ 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" "github.com/cosmos/evm/x/precisebank/keeper" "github.com/cosmos/evm/x/precisebank/types" @@ -44,7 +44,8 @@ func newMockedTestData(t *testing.T) testData { 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/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/config_testing.go b/x/vm/types/config_testing.go index dc95ff1e7..8ed238984 100644 --- a/x/vm/types/config_testing.go +++ b/x/vm/types/config_testing.go @@ -56,14 +56,22 @@ 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/msg_test.go b/x/vm/types/msg_test.go index a16dd0762..4684ef741 100644 --- a/x/vm/types/msg_test.go +++ b/x/vm/types/msg_test.go @@ -13,8 +13,8 @@ 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" 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) } From b80b4b7b9a1c47f2cd027c9bdb2128762c78436b Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 16:25:56 -0400 Subject: [PATCH 13/27] move constants to config --- config/chain_config.go | 7 +- config/server_app_options.go | 3 +- testutil/config/activators.go | 13 --- testutil/config/config.go | 21 +++++ testutil/config/config_testing.go | 24 ----- testutil/config/constants.go | 132 +++++++++++++++++++++++---- testutil/config/eips.go | 33 ------- testutil/constants/constants.go | 127 -------------------------- testutil/constants/constants_test.go | 34 ------- 9 files changed, 143 insertions(+), 251 deletions(-) delete mode 100644 testutil/config/activators.go delete mode 100644 testutil/config/eips.go delete mode 100644 testutil/constants/constants.go delete mode 100644 testutil/constants/constants_test.go diff --git a/config/chain_config.go b/config/chain_config.go index 6827dc93c..996e6ebb0 100644 --- a/config/chain_config.go +++ b/config/chain_config.go @@ -3,10 +3,13 @@ package config import ( "fmt" + "github.com/ethereum/go-ethereum/core/vm" + + "github.com/cosmos/evm/x/vm/types" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/evm/x/vm/types" - "github.com/ethereum/go-ethereum/core/vm" ) type ChainConfig struct { diff --git a/config/server_app_options.go b/config/server_app_options.go index 47551f902..89d4db633 100644 --- a/config/server_app_options.go +++ b/config/server_app_options.go @@ -8,11 +8,12 @@ import ( "github.com/holiman/uint256" "github.com/spf13/cast" - "cosmossdk.io/log" "github.com/cosmos/evm/config/eips" srvflags "github.com/cosmos/evm/server/flags" evmtypes "github.com/cosmos/evm/x/vm/types" + "cosmossdk.io/log" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/testutil/config/activators.go b/testutil/config/activators.go deleted file mode 100644 index a88b99e69..000000000 --- a/testutil/config/activators.go +++ /dev/null @@ -1,13 +0,0 @@ -package config - -import ( - "github.com/ethereum/go-ethereum/core/vm" -) - -// cosmosEVMActivators defines a map of opcode modifiers associated -// with a key defining the corresponding EIP. -var cosmosEVMActivators = map[int]func(*vm.JumpTable){ - 0o000: Enable0000, - 0o001: Enable0001, - 0o002: Enable0002, -} diff --git a/testutil/config/config.go b/testutil/config/config.go index 54fcdd69b..01d343669 100644 --- a/testutil/config/config.go +++ b/testutil/config/config.go @@ -48,6 +48,27 @@ const ( EVMChainID = 262144 ) +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 + // 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" +) + // 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) diff --git a/testutil/config/config_testing.go b/testutil/config/config_testing.go index a0cd819e5..408647968 100644 --- a/testutil/config/config_testing.go +++ b/testutil/config/config_testing.go @@ -4,7 +4,6 @@ package config import ( - evmconfig "github.com/cosmos/evm/config" evmtypes "github.com/cosmos/evm/x/vm/types" ) @@ -48,26 +47,3 @@ var TestChainsCoinInfo = map[uint64]evmtypes.EvmCoinInfo{ ExtendedDecimals: evmtypes.EighteenDecimals, }, } - -// EvmAppOptions allows to setup the global configuration -// for the Cosmos EVM chain. -func EvmAppOptions(chainID uint64) error { - coinInfo, exists := TestChainsCoinInfo[chainID] - if !exists { - coinInfo = evmtypes.EvmCoinInfo{ - DisplayDenom: "test", - Decimals: evmtypes.EighteenDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - } - } - chainConfig := evmconfig.NewChainConfig( - "test", - chainID, - cosmosEVMActivators, - nil, - nil, - coinInfo, - true, - ) - return chainConfig.ApplyChainConfig() -} diff --git a/testutil/config/constants.go b/testutil/config/constants.go index 3a7354cd9..c600c34f1 100644 --- a/testutil/config/constants.go +++ b/testutil/config/constants.go @@ -1,29 +1,127 @@ package config -const ( - // ExampleChainDenom is the denomination of the Cosmos EVM example chain's base coin. - ExampleChainDenom = "aatom" +import ( + erc20types "github.com/cosmos/evm/x/erc20/types" + evmtypes "github.com/cosmos/evm/x/vm/types" - // ExampleDisplayDenom is the display denomination of the Cosmos EVM example chain's base coin. - ExampleDisplayDenom = "atom" + "cosmossdk.io/math" +) - // EighteenDecimalsChainID is the chain ID for the 18 decimals chain. - EighteenDecimalsChainID = 9001 +const ( + // DefaultGasPrice is used in testing as the default to use for transactions + DefaultGasPrice = 20 - // SixDecimalsChainID is the chain ID for the 6 decimals chain. - SixDecimalsChainID = 9002 + // ExampleAttoDenom provides an example denom for use in tests + ExampleAttoDenom = "aatom" - // TwelveDecimalsChainID is the chain ID for the 12 decimals chain. - TwelveDecimalsChainID = 9003 + // ExampleMicroDenom provides an example denom for use in tests + ExampleMicroDenom = "uatom" - // TwoDecimalsChainID is the chain ID for the 2 decimals chain. - TwoDecimalsChainID = 9004 + // ExampleDisplayDenom provides an example display denom for use in tests + ExampleDisplayDenom = "atom" - // TestChainID1 is test chain IDs for IBC E2E test - TestChainID1 = 9005 - // TestChainID2 is test chain IDs for IBC E2E test - TestChainID2 = 9006 + // 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 + ExampleSixDecimalsChainID = ChainID{ + ChainID: "ossix-2", + EVMChainID: 9002, + } + + // TwelveDecimalsChainID provides a chain ID which is being set up with 12 decimals + ExampleTwelveDecimalsChainID = ChainID{ + ChainID: "ostwelve-3", + EVMChainID: 9003, + } + + // TwoDecimalsChainID provides a chain ID which is being set up with 2 decimals + ExampleTwoDecimalsChainID = 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: { + DisplayDenom: ExampleDisplayDenom, + Decimals: evmtypes.EighteenDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, + }, + ExampleSixDecimalsChainID: { + DisplayDenom: "test", + Decimals: evmtypes.SixDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, + }, + ExampleTwelveDecimalsChainID: { + DisplayDenom: "test2", + Decimals: evmtypes.TwelveDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, + }, + ExampleTwoDecimalsChainID: { + DisplayDenom: "test3", + Decimals: evmtypes.TwoDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, + }, + } + + // 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/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/constants/constants.go b/testutil/constants/constants.go deleted file mode 100644 index caba3030c..000000000 --- a/testutil/constants/constants.go +++ /dev/null @@ -1,127 +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: { - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - SixDecimalsChainID: { - DisplayDenom: "test", - Decimals: evmtypes.SixDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - TwelveDecimalsChainID: { - DisplayDenom: "test2", - Decimals: evmtypes.TwelveDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - TwoDecimalsChainID: { - DisplayDenom: "test3", - Decimals: evmtypes.TwoDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - } - - // 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", - ) -} From db26c466723a3ee93c254e09f3261cd1d3dba865 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 17:34:25 -0400 Subject: [PATCH 14/27] consolidate testutil constants package into config --- ante/cosmos/authz_test.go | 6 +- ante/evm/fee_checker_test.go | 14 +-- config/eips/activators.go | 16 ++- ethereum/eip712/preprocess_test.go | 10 +- evmd/genesis.go | 6 +- evmd/tests/eips/eips_test.go | 8 +- evmd/tests/integration/create_app.go | 12 +-- evmd/tests/integration/x_vm_test.go | 4 +- evmd/tests/ledger/evmosd_suite_test.go | 6 +- evmd/tests/network/network.go | 12 +-- ibc/utils_test.go | 4 +- precompiles/common/balance_handler_test.go | 6 +- precompiles/common/types_test.go | 6 +- rpc/backend/node_info.go | 4 +- rpc/backend/tx_info_test.go | 12 +-- server/config/config_test.go | 6 +- tests/integration/ante/ante_test_suite.go | 4 +- tests/integration/ante/evm_ante_test_suite.go | 10 +- .../ante/evm_unit_ante_test_suite.go | 6 +- tests/integration/ante/test_evm_ante.go | 54 +++++----- tests/integration/ante/test_evm_fee_market.go | 8 +- .../ante/test_evm_unit_04_validate.go | 10 +- .../test_evm_unit_06_account_verification.go | 4 +- .../ante/test_evm_unit_08_gas_consume.go | 6 +- .../test_evm_unit_09_increment_sequence.go | 4 +- .../ante/test_evm_unit_10_gas_wanted.go | 4 +- tests/integration/ante/test_integration.go | 4 +- tests/integration/ante/test_min_gas_price.go | 4 +- tests/integration/eip712/test_eip712.go | 6 +- tests/integration/indexer/test_kv_indexer.go | 4 +- tests/integration/mempool/test_setup.go | 6 +- .../distribution/test_distribution.go | 18 ++-- .../precompiles/distribution/test_event.go | 24 ++--- .../distribution/test_integration.go | 8 +- .../precompiles/distribution/test_setup.go | 12 +-- .../precompiles/distribution/test_tx.go | 46 ++++----- .../precompiles/erc20/test_integration.go | 6 +- .../integration/precompiles/gov/test_query.go | 4 +- .../integration/precompiles/gov/test_setup.go | 10 +- .../precompiles/staking/test_integration.go | 6 +- .../precompiles/staking/test_setup.go | 4 +- .../precompiles/staking/test_staking.go | 10 +- .../precompiles/werc20/test_events.go | 16 +-- .../precompiles/werc20/test_integration.go | 20 ++-- .../rpc/backend/test_backend_suite.go | 4 +- tests/integration/rpc/backend/test_call_tx.go | 4 +- .../rpc/backend/test_chain_info.go | 4 +- .../rpc/backend/test_evm_query_client.go | 10 +- .../integration/rpc/backend/test_node_info.go | 8 +- tests/integration/testutil/test_config.go | 16 +-- .../integration/wallets/test_ledger_suite.go | 6 +- tests/integration/x/erc20/test_grpc_query.go | 8 +- tests/integration/x/erc20/test_precompiles.go | 10 +- tests/integration/x/erc20/test_token_pairs.go | 8 +- .../x/precisebank/test_burn_integration.go | 12 +-- .../integration/x/precisebank/test_genesis.go | 6 +- .../x/precisebank/test_integration.go | 26 ++--- .../x/precisebank/test_mint_integration.go | 12 +-- .../x/precisebank/test_send_integration.go | 20 ++-- tests/integration/x/precisebank/test_setup.go | 6 +- tests/integration/x/vm/keeper_test_suite.go | 4 +- tests/integration/x/vm/test_benchmark.go | 6 +- tests/integration/x/vm/test_call_evm.go | 6 +- tests/integration/x/vm/test_grpc_query.go | 6 +- .../x/vm/test_iterate_contracts.go | 4 +- tests/integration/x/vm/test_statedb.go | 4 +- testutil/config/config.go | 2 - testutil/config/constants.go | 3 - testutil/config/genesis.go | 5 +- testutil/integration/evm/network/amounts.go | 6 +- .../evm/network/chain_id_modifiers.go | 10 +- testutil/integration/evm/network/coins.go | 4 +- testutil/integration/evm/network/config.go | 14 +-- .../evm/network/example_contracts.go | 10 +- testutil/integration/evm/network/setup.go | 8 +- testutil/integration/evm/utils/genesis.go | 10 +- testutil/tx/cosmos.go | 6 +- utils/utils_test.go | 6 +- x/erc20/types/genesis_test.go | 98 +++++++++---------- x/precisebank/keeper/keeper_test.go | 4 +- x/precisebank/types/extended_balance_test.go | 4 +- x/precisebank/types/genesis_test.go | 6 +- x/vm/types/evm_config_test.go | 14 +-- x/vm/types/msg_test.go | 6 +- x/vm/types/scaling_test.go | 18 ++-- x/vm/wrappers/bank_test.go | 26 ++--- x/vm/wrappers/feemarket_test.go | 32 +++--- 87 files changed, 462 insertions(+), 470 deletions(-) diff --git a/ante/cosmos/authz_test.go b/ante/cosmos/authz_test.go index 1930f2077..52e62a184 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" @@ -22,11 +22,11 @@ import ( func TestAuthzLimiterDecorator(t *testing.T) { evmConfigurator := evmtypes.NewEvmConfig(). - WithEVMCoinInfo(constants.ExampleChainCoinInfo[constants.ExampleChainID]) + WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) err := evmConfigurator.Apply() 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 b75c0c1a9..903f6e8cf 100644 --- a/ante/evm/fee_checker_test.go +++ b/ante/evm/fee_checker_test.go @@ -12,7 +12,7 @@ import ( anteinterfaces "github.com/cosmos/evm/ante/interfaces" evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/encoding" - 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" @@ -111,7 +111,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, @@ -156,7 +156,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, @@ -173,7 +173,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, @@ -190,7 +190,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) @@ -211,7 +211,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), @@ -234,7 +234,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/config/eips/activators.go b/config/eips/activators.go index 6536179e4..f349cddea 100644 --- a/config/eips/activators.go +++ b/config/eips/activators.go @@ -4,12 +4,10 @@ import ( "github.com/ethereum/go-ethereum/core/vm" ) -var ( - // CosmosEVMActivators defines a map of opcode modifiers associated - // with a key defining the corresponding EIP. - CosmosEVMActivators = map[int]func(*vm.JumpTable){ - 0o000: Enable0000, - 0o001: Enable0001, - 0o002: Enable0002, - } -) +// CosmosEVMActivators defines a map of opcode modifiers associated +// with a key defining the corresponding EIP. +var CosmosEVMActivators = map[int]func(*vm.JumpTable){ + 0o000: Enable0000, + 0o001: Enable0001, + 0o002: Enable0002, +} diff --git a/ethereum/eip712/preprocess_test.go b/ethereum/eip712/preprocess_test.go index e355d6787..1a9ffbdec 100644 --- a/ethereum/eip712/preprocess_test.go +++ b/ethereum/eip712/preprocess_test.go @@ -10,7 +10,7 @@ import ( "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 +30,7 @@ import ( // Testing Constants var ( // chainID is used in EIP-712 tests. - chainID = uint64(constants.ExampleEIP155ChainID) + chainID = uint64(testconfig.ExampleEIP155ChainID) ctx = client.Context{}.WithTxConfig( encoding.MakeConfig(chainID).TxConfig, @@ -39,7 +39,7 @@ var ( // feePayerAddress is the address of the fee payer used in EIP-712 tests. feePayerAddress = fmt.Sprintf( "%s17xpfvakm2amg962yls6f84z3kell8c5lserqta", - constants.ExampleBech32Prefix, + testconfig.ExampleBech32Prefix, ) ) @@ -55,9 +55,9 @@ type TestCaseStruct struct { func TestLedgerPreprocessing(t *testing.T) { // Update bech32 prefix - sdk.GetConfig().SetBech32PrefixForAccount(constants.ExampleBech32Prefix, "") + sdk.GetConfig().SetBech32PrefixForAccount(testconfig.ExampleBech32Prefix, "") evmConfigurator := evmtypes.NewEvmConfig(). - WithEVMCoinInfo(constants.ExampleChainCoinInfo[constants.ExampleChainID]) + WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) err := evmConfigurator.Apply() require.NoError(t, err) diff --git a/evmd/genesis.go b/evmd/genesis.go index a21b03423..01ef01b32 100644 --- a/evmd/genesis.go +++ b/evmd/genesis.go @@ -4,7 +4,7 @@ import ( "encoding/json" "github.com/cosmos/evm/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 +39,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{testconfig.WEVMOSContractMainnet} return erc20GenState } diff --git a/evmd/tests/eips/eips_test.go b/evmd/tests/eips/eips_test.go index 151853b17..8e0cc7ae4 100644 --- a/evmd/tests/eips/eips_test.go +++ b/evmd/tests/eips/eips_test.go @@ -13,9 +13,9 @@ import ( //nolint:revive // dot imports are fine for Ginkgo . "github.com/onsi/gomega" + "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/tests/integration/create_app.go b/evmd/tests/integration/create_app.go index d6b52c21c..0f8e501ce 100644 --- a/evmd/tests/integration/create_app.go +++ b/evmd/tests/integration/create_app.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/evm" "github.com/cosmos/evm/config" "github.com/cosmos/evm/evmd" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" ibctesting "github.com/cosmos/ibc-go/v10/testing" @@ -35,9 +35,9 @@ func CreateEvmd(chainID string, evmChainID uint64, customBaseAppOptions ...func( baseAppOptions := append(customBaseAppOptions, baseapp.SetChainID(chainID)) - coinInfo := constants.ExampleChainCoinInfo[constants.ExampleChainID] + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] chainConfig := config.NewChainConfig( - constants.ExampleChainID.ChainID, + testconfig.ExampleChainID.ChainID, evmChainID, nil, nil, @@ -62,10 +62,10 @@ func CreateEvmd(chainID string, evmChainID uint64, customBaseAppOptions ...func( // 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) { - coinInfo := constants.ExampleChainCoinInfo[constants.ExampleChainID] + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] chainConfig := config.NewChainConfig( - constants.ExampleChainID.ChainID, - constants.ExampleEIP155ChainID, + testconfig.ExampleChainID.ChainID, + testconfig.ExampleEIP155ChainID, nil, nil, nil, diff --git a/evmd/tests/integration/x_vm_test.go b/evmd/tests/integration/x_vm_test.go index 47a2de85e..228defde2 100644 --- a/evmd/tests/integration/x_vm_test.go +++ b/evmd/tests/integration/x_vm_test.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/evm/server/config" "github.com/cosmos/evm/tests/integration/x/vm" - "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/keyring" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" @@ -33,7 +33,7 @@ func BenchmarkGasEstimation(b *testing.B) { // gh := grpc.NewIntegrationHandler(nw) // tf := factory.New(nw, gh) - coinInfo := constants.ExampleChainCoinInfo[constants.ExampleChainID] + 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 diff --git a/evmd/tests/ledger/evmosd_suite_test.go b/evmd/tests/ledger/evmosd_suite_test.go index 200a8a5da..47c803257 100644 --- a/evmd/tests/ledger/evmosd_suite_test.go +++ b/evmd/tests/ledger/evmosd_suite_test.go @@ -29,7 +29,7 @@ import ( "github.com/cosmos/evm/encoding" "github.com/cosmos/evm/evmd" "github.com/cosmos/evm/evmd/tests/ledger/mocks" - "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" "github.com/cosmos/cosmos-sdk/client" @@ -87,7 +87,7 @@ func (suite *LedgerTestSuite) SetupEvmosApp() { consAddress := sdk.ConsAddress(utiltx.GenerateAddress().Bytes()) // init app - chainID := constants.ExampleChainID + chainID := testconfig.ExampleChainID suite.app = evmd.Setup(suite.T(), chainID.ChainID, chainID.EVMChainID) suite.ctx = suite.app.NewContextLegacy(false, tmproto.Header{ Height: 1, @@ -136,7 +136,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 11702ef65..50981c3fc 100644 --- a/evmd/tests/network/network.go +++ b/evmd/tests/network/network.go @@ -32,7 +32,7 @@ import ( "github.com/cosmos/evm/evmd" evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" "github.com/cosmos/evm/server/config" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" cosmosevmtypes "github.com/cosmos/evm/types" "cosmossdk.io/log" @@ -110,7 +110,7 @@ func DefaultConfig() Config { panic(fmt.Sprintf("failed creating temporary directory: %v", err)) } defer os.RemoveAll(dir) - coinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] chainConfig := evmconfig.NewChainConfig( chainID, evmChainID, @@ -136,8 +136,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), @@ -153,7 +153,7 @@ func DefaultConfig() Config { // NewAppConstructor returns a new Cosmos EVM AppConstructor func NewAppConstructor(chainID string, evmChainID uint64) AppConstructor { return func(val Validator) servertypes.Application { - coinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] chainConfig := evmconfig.NewChainConfig( chainID, evmChainID, @@ -501,7 +501,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { return nil, err } - customAppTemplate, _ := evmdconfig.InitAppConfig(testconstants.ExampleAttoDenom, testconstants.ExampleEIP155ChainID) + customAppTemplate, _ := evmdconfig.InitAppConfig(testconfig.ExampleAttoDenom, testconfig.ExampleEIP155ChainID) srvconfig.SetConfigTemplate(customAppTemplate) srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), appCfg) 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/precompiles/common/balance_handler_test.go b/precompiles/common/balance_handler_test.go index c00e74fb2..919c62eaa 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, "") + sdk.GetConfig().SetBech32PrefixForAccount(testconfig.ExampleBech32Prefix, "") configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]).Apply()) + 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/rpc/backend/node_info.go b/rpc/backend/node_info.go index dcdf28a68..5fb388bc5 100644 --- a/rpc/backend/node_info.go +++ b/rpc/backend/node_info.go @@ -14,7 +14,7 @@ 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" + testconfig "github.com/cosmos/evm/testutil/config" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" @@ -345,7 +345,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(testconfig.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_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/tests/integration/ante/ante_test_suite.go b/tests/integration/ante/ante_test_suite.go index 03d5cf70d..6b69355ad 100644 --- a/tests/integration/ante/ante_test_suite.go +++ b/tests/integration/ante/ante_test_suite.go @@ -5,7 +5,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" "github.com/cosmos/evm/testutil/integration/evm/factory" "github.com/cosmos/evm/testutil/integration/evm/grpc" @@ -100,7 +100,7 @@ func (s *AnteTestSuite) SetupTest() { s.Require().NotNil(s.network.App.AppCodec()) - coinInfo := constants.ExampleChainCoinInfo[constants.ExampleChainID] + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] chainConfig := evmtypes.DefaultChainConfig(s.network.GetEIP155ChainID().Uint64(), coinInfo) if !s.enableLondonHF { maxInt := sdkmath.NewInt(math.MaxInt64) 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 81e06a937..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,9 +236,9 @@ 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() { @@ -246,7 +246,7 @@ func (s *EvmUnitAnteTestSuite) TestCheckTxFee() { // function to be tested. configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - s.Require().NoError(configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[chainID]).Apply()) + 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..fd9d2860c 100644 --- a/tests/integration/eip712/test_eip712.go +++ b/tests/integration/eip712/test_eip712.go @@ -13,7 +13,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" @@ -333,7 +333,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 +347,7 @@ func (s *TestSuite) TestEIP712() { AccountNumber: params.accountNumber, Sequence: params.sequence, PubKey: pubKey, - Address: sdk.MustBech32ifyAddressBytes(constants.ExampleBech32Prefix, pubKey.Bytes()), + Address: sdk.MustBech32ifyAddressBytes(testconfig.ExampleBech32Prefix, 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/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..06223040c 100644 --- a/tests/integration/precompiles/distribution/test_event.go +++ b/tests/integration/precompiles/distribution/test_event.go @@ -12,7 +12,7 @@ import ( "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" @@ -188,13 +188,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 +260,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 +302,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 +315,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 +323,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 +394,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 +425,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 +437,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..e0160174b 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 ebcd75f5a..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 @@ -111,7 +111,7 @@ func TestPrecompileIntegrationTestSuite(t *testing.T, create network.CreateEvmAp configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() Expect(configurator. - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[chainId]). + WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[chainId]). Apply()).To(BeNil(), "expected no error setting the evm configurator") opts := []network.ConfigOption{ @@ -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..a09e8258d 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(testconfig.DefaultGasPrice), true, }, { "pass - min gas price is 0", func() {}, - big.NewInt(constants.DefaultGasPrice), + big.NewInt(testconfig.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 dc57266be..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), @@ -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..0db7f80de 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 852b60f59..520eb8fd8 100644 --- a/tests/integration/x/precisebank/test_burn_integration.go +++ b/tests/integration/x/precisebank/test_burn_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" @@ -417,19 +417,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, }, } @@ -500,7 +500,7 @@ func (s *KeeperIntegrationTestSuite) TestBurnCoinsRandomValueMultiDecimals() { func FuzzBurnCoins(f *testing.F) { configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) + configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) err := configurator.Apply() require.NoError(f, err) 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 de411877d..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, }, } @@ -417,7 +417,7 @@ func (s *KeeperIntegrationTestSuite) TestMintCoinsRandomValueMultiDecimals() { func FuzzMintCoins(f *testing.F) { configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) + configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) err := configurator.Apply() require.NoError(f, err) diff --git a/tests/integration/x/precisebank/test_send_integration.go b/tests/integration/x/precisebank/test_send_integration.go index b09919497..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, }, } @@ -798,7 +798,7 @@ func (s *KeeperIntegrationTestSuite) TestSendCoinsRandomValueMultiDecimals() { func FuzzSendCoins(f *testing.F) { configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) + configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) err := configurator.Apply() require.NoError(f, err) @@ -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 60893608d..da66a8745 100644 --- a/tests/integration/x/vm/keeper_test_suite.go +++ b/tests/integration/x/vm/keeper_test_suite.go @@ -6,7 +6,7 @@ import ( "github.com/ethereum/go-ethereum/params" "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" @@ -89,7 +89,7 @@ func (s *KeeperTestSuite) SetupTest() { s.Handler = gh s.Keyring = keys - coinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] chainConfig := evmtypes.DefaultChainConfig(s.Network.GetEIP155ChainID().Uint64(), coinInfo) if !s.EnableLondonHF { maxInt := sdkmath.NewInt(math.MaxInt64) 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..385514d8b 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 89aa28ff6..8d7ba7672 100644 --- a/tests/integration/x/vm/test_grpc_query.go +++ b/tests/integration/x/vm/test_grpc_query.go @@ -17,7 +17,7 @@ import ( "github.com/stretchr/testify/require" "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 +1592,7 @@ func (s *KeeperTestSuite) TestQueryBaseFee() { feemarketDefault := feemarkettypes.DefaultParams() s.Require().NoError(s.Network.App.GetFeeMarketKeeper().SetParams(s.Network.GetContext(), feemarketDefault)) - coinInfo := testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID] + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] chainConfig := types.DefaultChainConfig(s.Network.GetEIP155ChainID().Uint64(), coinInfo) maxInt := sdkmath.NewInt(math.MaxInt64) chainConfig.LondonBlock = &maxInt @@ -1607,7 +1607,7 @@ func (s *KeeperTestSuite) TestQueryBaseFee() { configurator.ResetTestConfig() err := configurator. WithChainConfig(chainConfig). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). + WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]). 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..78fc07ef9 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..80e1c5a00 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.ExampleEIP155ChainID), Nonce: 0, To: &toAddr, Amount: common.Big1, diff --git a/testutil/config/config.go b/testutil/config/config.go index 01d343669..d87864130 100644 --- a/testutil/config/config.go +++ b/testutil/config/config.go @@ -65,8 +65,6 @@ const ( TestChainID1 = 9005 // TestChainID2 is test chain IDs for IBC E2E test TestChainID2 = 9006 - // WEVMOSContractMainnet is the WEVMOS contract address for mainnet - WEVMOSContractMainnet = "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517" ) // SetBech32Prefixes sets the global prefixes to be used when serializing addresses and public keys to Bech32 strings. diff --git a/testutil/config/constants.go b/testutil/config/constants.go index c600c34f1..982740fc7 100644 --- a/testutil/config/constants.go +++ b/testutil/config/constants.go @@ -17,9 +17,6 @@ const ( // 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" diff --git a/testutil/config/genesis.go b/testutil/config/genesis.go index 4dc55d415..411e33968 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 } 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 94b4714e4..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,11 +80,11 @@ 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 { diff --git a/testutil/integration/evm/network/coins.go b/testutil/integration/evm/network/coins.go index 363d21491..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) diff --git a/testutil/integration/evm/network/config.go b/testutil/integration/evm/network/config.go index 2ad976fb8..7af545ec3 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.ExampleEIP155ChainID), 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, )) } diff --git a/testutil/integration/evm/network/example_contracts.go b/testutil/integration/evm/network/example_contracts.go index ab3a3daba..1f99e9022 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..9d4315e18 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..84a445d91 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 a70b4ce63..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,10 +487,10 @@ 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.NewEvmConfig(). - WithEVMCoinInfo(constants.ExampleChainCoinInfo[chainID]) + WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[chainID]) evmConfigurator.ResetTestConfig() err := evmConfigurator.Apply() require.NoError(t, err) diff --git a/x/erc20/types/genesis_test.go b/x/erc20/types/genesis_test.go index 10abb1373..69575a2bc 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 f1ce34828..1a2280f95 100644 --- a/x/precisebank/keeper/keeper_test.go +++ b/x/precisebank/keeper/keeper_test.go @@ -5,7 +5,7 @@ import ( evmconfig "github.com/cosmos/evm/config" evmosencoding "github.com/cosmos/evm/encoding" - 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,7 +40,7 @@ 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) diff --git a/x/precisebank/types/extended_balance_test.go b/x/precisebank/types/extended_balance_test.go index 8c92b5dea..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,7 +15,7 @@ import ( ) func TestSumExtendedCoin(t *testing.T) { - coinInfo := testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID] + coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID] configurator := evmtypes.NewEvmConfig() err := configurator. WithEVMCoinInfo(coinInfo). diff --git a/x/precisebank/types/genesis_test.go b/x/precisebank/types/genesis_test.go index 41a5ee80e..9908032e8 100644 --- a/x/precisebank/types/genesis_test.go +++ b/x/precisebank/types/genesis_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/testutil" "github.com/cosmos/evm/x/precisebank/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -258,7 +258,7 @@ func TestGenesisState_TotalAmountWithRemainder(t *testing.T) { func FuzzGenesisStateValidate_NonZeroRemainder(f *testing.F) { configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) + configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) err := configurator.Apply() require.NoError(f, err) @@ -285,7 +285,7 @@ func FuzzGenesisStateValidate_NonZeroRemainder(f *testing.F) { func FuzzGenesisStateValidate_ZeroRemainder(f *testing.F) { configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() - configurator.WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.SixDecimalsChainID]) + configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) err := configurator.Apply() require.NoError(f, err) diff --git a/x/vm/types/evm_config_test.go b/x/vm/types/evm_config_test.go index 16d621348..5e384791b 100644 --- a/x/vm/types/evm_config_test.go +++ b/x/vm/types/evm_config_test.go @@ -6,13 +6,13 @@ import ( "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 TestEvmConfigApply(t *testing.T) { evmConfigurator := types.NewEvmConfig(). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]) + WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) err := evmConfigurator.Apply() require.NoError(t, err) @@ -35,7 +35,7 @@ func TestExtendedEips(t *testing.T) { 3855: func(_ *vm.JumpTable) {}, } ec := types.NewEvmConfig(). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). + WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]). WithExtendedEips(extendedEIPs) return ec }, @@ -49,7 +49,7 @@ func TestExtendedEips(t *testing.T) { 0o000: func(_ *vm.JumpTable) {}, } ec := types.NewEvmConfig(). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). + WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]). WithExtendedEips(extendedEIPs) return ec }, @@ -87,7 +87,7 @@ func TestExtendedDefaultExtraEips(t *testing.T) { extendedDefaultExtraEIPs := []int64{1000} types.DefaultExtraEIPs = append(types.DefaultExtraEIPs, 1000) ec := types.NewEvmConfig(). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). + WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec }, @@ -103,7 +103,7 @@ func TestExtendedDefaultExtraEips(t *testing.T) { func() *types.EvmConfig { var extendedDefaultExtraEIPs []int64 ec := types.NewEvmConfig(). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). + WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec }, @@ -118,7 +118,7 @@ func TestExtendedDefaultExtraEips(t *testing.T) { func() *types.EvmConfig { extendedDefaultExtraEIPs := []int64{1001} ec := types.NewEvmConfig(). - WithEVMCoinInfo(testconstants.ExampleChainCoinInfo[testconstants.ExampleChainID]). + WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec }, diff --git a/x/vm/types/msg_test.go b/x/vm/types/msg_test.go index 4684ef741..85f2959c4 100644 --- a/x/vm/types/msg_test.go +++ b/x/vm/types/msg_test.go @@ -15,7 +15,7 @@ import ( evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/encoding" - 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" @@ -113,8 +113,8 @@ 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.NewEvmConfig() diff --git a/x/vm/types/scaling_test.go b/x/vm/types/scaling_test.go index 7eb47cf76..13a379c6e 100644 --- a/x/vm/types/scaling_test.go +++ b/x/vm/types/scaling_test.go @@ -8,7 +8,7 @@ import ( "github.com/holiman/uint256" "github.com/stretchr/testify/require" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/math" @@ -17,8 +17,8 @@ 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.GetDenom(), Amount: math.NewInt(0)} sixDecimalsBaseCoinZero := sdk.Coin{Denom: sixDecimalsCoinInfo.GetDenom(), Amount: math.NewInt(0)} @@ -92,8 +92,8 @@ 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.GetDenom(), Amount: math.NewInt(10)} @@ -183,8 +183,8 @@ 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) { @@ -221,8 +221,8 @@ 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) { diff --git a/x/vm/wrappers/bank_test.go b/x/vm/wrappers/bank_test.go index 8a6ff4a0b..989e4e755 100644 --- a/x/vm/wrappers/bank_test.go +++ b/x/vm/wrappers/bank_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" - testconstants "github.com/cosmos/evm/testutil/constants" + 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 +23,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 @@ -128,8 +128,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")) @@ -249,8 +249,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")) @@ -410,8 +410,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")) @@ -573,8 +573,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")) @@ -720,8 +720,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")) diff --git a/x/vm/wrappers/feemarket_test.go b/x/vm/wrappers/feemarket_test.go index 6486e51f2..bf9697883 100644 --- a/x/vm/wrappers/feemarket_test.go +++ b/x/vm/wrappers/feemarket_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" - testconstants "github.com/cosmos/evm/testutil/constants" + testconfig "github.com/cosmos/evm/testutil/config" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" evmtypes "github.com/cosmos/evm/x/vm/types" "github.com/cosmos/evm/x/vm/wrappers" @@ -27,7 +27,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 +37,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 +47,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 +57,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 +67,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 +77,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(). @@ -117,7 +117,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 +127,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 +137,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 +147,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 +157,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 +167,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(). @@ -206,7 +206,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 +222,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 +238,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), }, From 96530d5248c30ed8ae899f002511ca6895a6f486 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Tue, 16 Sep 2025 17:43:51 -0400 Subject: [PATCH 15/27] fix testcofig in root --- evmd/cmd/evmd/cmd/root.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/evmd/cmd/evmd/cmd/root.go b/evmd/cmd/evmd/cmd/root.go index da63597c3..764f1e74b 100644 --- a/evmd/cmd/evmd/cmd/root.go +++ b/evmd/cmd/evmd/cmd/root.go @@ -151,8 +151,7 @@ func NewRootCmd() *cobra.Command { panic(err) } - chainConfig := evmconfig.NewTestChainConfig(evmconfig.DefaultEvmChainID) - + chainConfig := evmconfig.DefaultChainConfig if err := chainConfig.ApplyChainConfig(); err != nil { panic(err) } From b9196e4590a7ad008b46ca5db7fc5e0463c57d67 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Wed, 17 Sep 2025 12:37:50 -0400 Subject: [PATCH 16/27] pass in coin info flags --- config/chain_config.go | 8 +++----- evmd/cmd/evmd/cmd/root.go | 11 +++++------ go.mod | 3 +-- local_node.sh | 14 +++++++++++++- x/vm/types/config.go | 12 +++++------- x/vm/types/config_testing.go | 5 +++-- x/vm/types/evm_config.go | 12 +++++++++++- 7 files changed, 41 insertions(+), 24 deletions(-) diff --git a/config/chain_config.go b/config/chain_config.go index 996e6ebb0..e17757121 100644 --- a/config/chain_config.go +++ b/config/chain_config.go @@ -51,11 +51,8 @@ func NewChainConfig( // ApplyEvmConfig applies the evm config to the global singleton chain config and coin info func (cc *ChainConfig) ApplyChainConfig() error { - if cc.EvmConfig == nil { - return nil // no op if evm config is nil - } - if cc.EvmConfig == nil { - return fmt.Errorf("evm config is nil, cannot apply chain config") + if cc.EvmConfig == nil || types.IsSealed() { + return nil // no op if evm config is nil or sealed } if cc.EvmConfig.GetChainConfig() == nil { return fmt.Errorf("chain config is nil, cannot apply chain config") @@ -70,6 +67,7 @@ func (cc *ChainConfig) ApplyChainConfig() error { // 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 types.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 diff --git a/evmd/cmd/evmd/cmd/root.go b/evmd/cmd/evmd/cmd/root.go index 764f1e74b..43e6e6126 100644 --- a/evmd/cmd/evmd/cmd/root.go +++ b/evmd/cmd/evmd/cmd/root.go @@ -4,7 +4,6 @@ import ( "errors" "io" "os" - "strconv" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/spf13/cast" @@ -141,7 +140,7 @@ func NewRootCmd() *cobra.Command { if initClientCtx.ChainID == "" { // if the chain id is not set in client.toml, populate it with the default evm chain id - initClientCtx = initClientCtx.WithChainID(strconv.FormatUint(evmconfig.DefaultEvmChainID, 10)) + initClientCtx = initClientCtx.WithChainID(evmconfig.DefaultChainID) } initClientCtx, _ = clientcfg.ReadFromClientConfig(initClientCtx) @@ -151,10 +150,10 @@ func NewRootCmd() *cobra.Command { panic(err) } - chainConfig := evmconfig.DefaultChainConfig - if err := chainConfig.ApplyChainConfig(); err != nil { - panic(err) - } + // chainConfig := evmconfig.DefaultChainConfig + // if err := chainConfig.ApplyChainConfig(); err != nil { + // panic(err) + // } return rootCmd } diff --git a/go.mod b/go.mod index 4166dd6d3..2e66b7626 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,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 +180,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 +205,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/local_node.sh b/local_node.sh index c04c16382..0bca43205 100755 --- a/local_node.sh +++ b/local_node.sh @@ -14,6 +14,15 @@ CHAINDIR="$HOME/.evmd" BASEFEE=10000000 +# Coin info +DISPLAY_DENOM="test" +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 @@ -358,7 +367,10 @@ fi evmd start "$TRACE" \ --pruning nothing \ --log_level $LOGLEVEL \ - --minimum-gas-prices=0atest \ + --minimum-gas-prices=0$EXTENDED_DENOM \ + --evm.coin-info.display-denom=$DISPLAY_DENOM \ + --evm.coin-info.decimals=$DECIMALS \ + --evm.coin-info.extended-decimals=$EXTENDED_DECIMALS \ --evm.min-tip=0 \ --home "$CHAINDIR" \ --json-rpc.api eth,txpool,personal,net,debug,web3 \ diff --git a/x/vm/types/config.go b/x/vm/types/config.go index 928c27881..8518cfc90 100644 --- a/x/vm/types/config.go +++ b/x/vm/types/config.go @@ -4,18 +4,16 @@ package types import ( - "fmt" - "github.com/ethereum/go-ethereum/core/vm" geth "github.com/ethereum/go-ethereum/params" ) // 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 applying EvmConfig: already sealed and cannot be modified") + // If Apply method has been already used in the object, return nil and no not overwrite + // This mirrors the silent behavior of the previous EvmAppOptions implementation + if IsSealed() { + return nil } if err := setChainConfig(ec.chainConfig); err != nil { @@ -36,7 +34,7 @@ func (ec *EvmConfig) Apply() 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 } diff --git a/x/vm/types/config_testing.go b/x/vm/types/config_testing.go index 8ed238984..221e5d825 100644 --- a/x/vm/types/config_testing.go +++ b/x/vm/types/config_testing.go @@ -19,7 +19,7 @@ var testChainConfig *ChainConfig 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 { + if IsSealed() { return fmt.Errorf("error applying EvmConfig: already sealed and cannot be modified") } @@ -41,7 +41,7 @@ func (ec *EvmConfig) Apply() 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 } @@ -50,6 +50,7 @@ func (ec *EvmConfig) ResetTestConfig() { vm.ResetActivators() resetEVMCoinInfo() testChainConfig = nil + sealed = false } func setTestChainConfig(cc *ChainConfig) error { diff --git a/x/vm/types/evm_config.go b/x/vm/types/evm_config.go index d2d26c2bb..9ccb5ff80 100644 --- a/x/vm/types/evm_config.go +++ b/x/vm/types/evm_config.go @@ -7,11 +7,21 @@ import ( "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 { - sealed bool extendedEIPs map[int]func(*vm.JumpTable) extendedDefaultExtraEIPs []int64 chainConfig *ChainConfig From 3c1f82925bb482c206c69af1381d686eae16bf58 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Wed, 17 Sep 2025 16:28:21 -0400 Subject: [PATCH 17/27] move around evmd files --- Makefile | 5 +- {evmd/config => client}/client.toml | 15 ++- client/flags/flags.go | 42 +++++++ .../cmd/evmd/config => config}/evmd_config.go | 0 config/server_app_options.go | 106 +++++++++--------- evmd/{ => app}/app.go | 20 ++-- evmd/{cmd/evmd/cmd => app}/creator.go | 15 ++- evmd/{ => app}/export.go | 2 +- evmd/{ => app}/genesis.go | 2 +- evmd/{ => app}/interfaces.go | 2 +- evmd/{ => app}/precompiles.go | 2 +- evmd/{ => app}/upgrades.go | 2 +- evmd/cmd/{evmd/cmd => }/root.go | 48 ++++---- evmd/cmd/{evmd/cmd => testnet}/testnet.go | 35 +++--- evmd/{cmd/evmd => }/main.go | 6 +- evmd/tests/ibc/ibc_middleware_test.go | 20 ++-- .../ibc/ics20_precompile_transfer_test.go | 16 +-- evmd/tests/ibc/transfer_test.go | 4 +- evmd/tests/ibc/v2_ibc_middleware_test.go | 16 +-- .../ibc/v2_ics20_precompile_transfer_test.go | 16 +-- evmd/tests/ibc/v2_transfer_test.go | 10 +- evmd/tests/integration/create_app.go | 6 +- evmd/tests/ledger/evmosd_suite_test.go | 7 +- evmd/tests/network/network.go | 23 ++-- evmd/{test_helpers.go => testutil/helpers.go} | 19 ++-- server/config/toml.go | 11 -- server/flags/flags.go | 3 - server/start.go | 3 - 28 files changed, 247 insertions(+), 209 deletions(-) rename {evmd/config => client}/client.toml (63%) create mode 100644 client/flags/flags.go rename {evmd/cmd/evmd/config => config}/evmd_config.go (100%) rename evmd/{ => app}/app.go (98%) rename evmd/{cmd/evmd/cmd => app}/creator.go (95%) rename evmd/{ => app}/export.go (99%) rename evmd/{ => app}/genesis.go (99%) rename evmd/{ => app}/interfaces.go (93%) rename evmd/{ => app}/precompiles.go (99%) rename evmd/{ => app}/upgrades.go (99%) rename evmd/cmd/{evmd/cmd => }/root.go (88%) rename evmd/cmd/{evmd/cmd => testnet}/testnet.go (96%) rename evmd/{cmd/evmd => }/main.go (50%) rename evmd/{test_helpers.go => testutil/helpers.go} (88%) 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/evmd/config/client.toml b/client/client.toml similarity index 63% rename from evmd/config/client.toml rename to client/client.toml index 02df72407..d27222bda 100644 --- a/evmd/config/client.toml +++ b/client/client.toml @@ -6,7 +6,7 @@ ############################################################################### # The network chain ID -chain-id = "" +chain-id = "cosmos" # The keyring's backend, where the keys are stored (os|file|kwallet|pass|test|memory) keyring-backend = "os" @@ -18,4 +18,15 @@ output = "text" node = "tcp://localhost:26657" # Transaction broadcasting mode (sync|async) -broadcast-mode = "sync" \ No newline at end of file +broadcast-mode = "sync" + +[coin-info] + +# DisplayDenom defines the display denomination shown to users +display-denom = "atom" + +# Decimals defines the precision/decimals for the base denomination (1-18) +decimals = 18 + +# ExtendedDecimals defines the precision/decimals for the extended denomination (typically 18 decimals for atto-denom) +extended-decimals = 18 \ No newline at end of file diff --git a/client/flags/flags.go b/client/flags/flags.go new file mode 100644 index 000000000..81cb60841 --- /dev/null +++ b/client/flags/flags.go @@ -0,0 +1,42 @@ +package flags + +import ( + "github.com/cosmos/evm/config" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +// Client configuration flags +const ( + // Custom client flags that will be added to client.toml + DisplayDenom = "coin-info.display-denom" + Decimals = "coin-info.decimals" + ExtendedDecimals = "coin-info.extended-decimals" +) + +// Default values for client flags +const ( + DefaultDisplayDenom = config.DisplayDenom + DefaultDecimals = config.Decimals + DefaultExtendedDecimals = config.ExtendedDecimals +) + +// AddClientFlags adds custom client flags to the command +func AddClientFlags(cmd *cobra.Command) error { + cmd.PersistentFlags().String(DisplayDenom, DefaultDisplayDenom, "the display denom used to derive the denom and extended denom") + cmd.PersistentFlags().Uint8(Decimals, uint8(DefaultDecimals), "the decimals for the base denomination") + cmd.PersistentFlags().Uint8(ExtendedDecimals, uint8(DefaultExtendedDecimals), "the decimals for the extended denomination") + + // Bind flags to viper for client.toml precedence + if err := viper.BindPFlag(DisplayDenom, cmd.PersistentFlags().Lookup(DisplayDenom)); err != nil { + return err + } + if err := viper.BindPFlag(Decimals, cmd.PersistentFlags().Lookup(Decimals)); err != nil { + return err + } + if err := viper.BindPFlag(ExtendedDecimals, cmd.PersistentFlags().Lookup(ExtendedDecimals)); err != nil { + return err + } + + return nil +} diff --git a/evmd/cmd/evmd/config/evmd_config.go b/config/evmd_config.go similarity index 100% rename from evmd/cmd/evmd/config/evmd_config.go rename to config/evmd_config.go diff --git a/config/server_app_options.go b/config/server_app_options.go index 89d4db633..99be07abf 100644 --- a/config/server_app_options.go +++ b/config/server_app_options.go @@ -8,9 +8,7 @@ import ( "github.com/holiman/uint256" "github.com/spf13/cast" - "github.com/cosmos/evm/config/eips" srvflags "github.com/cosmos/evm/server/flags" - evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/log" @@ -128,55 +126,55 @@ func GetEvmChainID(appOpts servertypes.AppOptions) (uint64, error) { return evmChainID, nil } -func GetEvmCoinInfo(appOpts servertypes.AppOptions) (*evmtypes.EvmCoinInfo, error) { - displayDenom := cast.ToString(appOpts.Get(srvflags.EVMDisplayDenom)) - if displayDenom == "" { - return nil, errors.New("display denom flag not found in app options") - } - decimals := cast.ToUint8(appOpts.Get(srvflags.EVMDecimals)) - if decimals == 0 { - return nil, errors.New("decimals flag not found in app options") - } - extendedDecimals := cast.ToUint8(appOpts.Get(srvflags.EVMExtendedDecimals)) - if extendedDecimals == 0 { - return nil, errors.New("extended decimals flag not found in app options") - } - - evmCoinInfo := evmtypes.EvmCoinInfo{ - DisplayDenom: displayDenom, - Decimals: evmtypes.Decimals(decimals), - ExtendedDecimals: evmtypes.Decimals(extendedDecimals), - } - if err := evmCoinInfo.Validate(); err != nil { - return nil, err - } - - return &evmCoinInfo, nil -} - -func CreateChainConfig(appOpts servertypes.AppOptions) (*ChainConfig, error) { - chainID, err := GetChainID(appOpts) - if err != nil { - return nil, err - } - evmChainID, err := GetEvmChainID(appOpts) - if err != nil { - return nil, err - } - evmCoinInfo, err := GetEvmCoinInfo(appOpts) - if err != nil { - return nil, err - } - - chainConfig := NewChainConfig( - chainID, - evmChainID, - eips.CosmosEVMActivators, - nil, - nil, - *evmCoinInfo, - false, - ) - - return &chainConfig, nil -} +// func GetEvmCoinInfo(appOpts servertypes.AppOptions) (*evmtypes.EvmCoinInfo, error) { +// displayDenom := cast.ToString(appOpts.Get(srvflags.EVMDisplayDenom)) +// if displayDenom == "" { +// return nil, errors.New("display denom flag not found in app options") +// } +// decimals := cast.ToUint8(appOpts.Get(srvflags.EVMDecimals)) +// if decimals == 0 { +// return nil, errors.New("decimals flag not found in app options") +// } +// extendedDecimals := cast.ToUint8(appOpts.Get(srvflags.EVMExtendedDecimals)) +// if extendedDecimals == 0 { +// return nil, errors.New("extended decimals flag not found in app options") +// } + +// evmCoinInfo := evmtypes.EvmCoinInfo{ +// DisplayDenom: displayDenom, +// Decimals: evmtypes.Decimals(decimals), +// ExtendedDecimals: evmtypes.Decimals(extendedDecimals), +// } +// if err := evmCoinInfo.Validate(); err != nil { +// return nil, err +// } + +// return &evmCoinInfo, nil +// } + +// func CreateChainConfig(appOpts servertypes.AppOptions) (*ChainConfig, error) { +// chainID, err := GetChainID(appOpts) +// if err != nil { +// return nil, err +// } +// evmChainID, err := GetEvmChainID(appOpts) +// if err != nil { +// return nil, err +// } +// evmCoinInfo, err := GetEvmCoinInfo(appOpts) +// if err != nil { +// return nil, err +// } + +// chainConfig := NewChainConfig( +// chainID, +// evmChainID, +// eips.CosmosEVMActivators, +// nil, +// nil, +// *evmCoinInfo, +// false, +// ) + +// return &chainConfig, nil +// } diff --git a/evmd/app.go b/evmd/app/app.go similarity index 98% rename from evmd/app.go rename to evmd/app/app.go index 54859ff43..281abc770 100644 --- a/evmd/app.go +++ b/evmd/app/app.go @@ -1,4 +1,4 @@ -package evmd +package app import ( "encoding/json" @@ -18,10 +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" "github.com/cosmos/evm/config" - evmconfig "github.com/cosmos/evm/config" evmosencoding "github.com/cosmos/evm/encoding" "github.com/cosmos/evm/evmd/ante" evmmempool "github.com/cosmos/evm/mempool" @@ -37,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" @@ -100,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" @@ -138,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) @@ -318,7 +316,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 +326,7 @@ func NewExampleApp( appCodec, runtime.NewKVStoreService(keys[banktypes.StoreKey]), app.AccountKeeper, - evmdconfig.BlockedAddresses(), + config.BlockedAddresses(), authAddr, logger, ) @@ -755,9 +753,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(), diff --git a/evmd/cmd/evmd/cmd/creator.go b/evmd/app/creator.go similarity index 95% rename from evmd/cmd/evmd/cmd/creator.go rename to evmd/app/creator.go index 73aac47ad..35d2a941f 100644 --- a/evmd/cmd/evmd/cmd/creator.go +++ b/evmd/app/creator.go @@ -1,4 +1,4 @@ -package cmd +package app import ( "errors" @@ -13,7 +13,6 @@ import ( simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" evmconfig "github.com/cosmos/evm/config" - "github.com/cosmos/evm/evmd" "github.com/spf13/cast" "github.com/spf13/viper" @@ -24,9 +23,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, @@ -93,7 +92,7 @@ func (a appCreator) newApp( panic(err) } - return evmd.NewExampleApp( + return NewExampleApp( logger, db, traceStore, @@ -104,7 +103,7 @@ func (a appCreator) newApp( ) } -func (a appCreator) appExport( +func (a AppCreator) appExport( logger log.Logger, db dbm.DB, traceStore io.Writer, @@ -114,7 +113,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 == "" { @@ -140,7 +139,7 @@ func (a appCreator) appExport( return servertypes.ExportedApp{}, err } - evmApp = evmd.NewExampleApp( + evmApp = NewExampleApp( logger, db, traceStore, 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 99% rename from evmd/genesis.go rename to evmd/app/genesis.go index 01ef01b32..51cbdf778 100644 --- a/evmd/genesis.go +++ b/evmd/app/genesis.go @@ -1,4 +1,4 @@ -package evmd +package app import ( "encoding/json" 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/cmd/root.go b/evmd/cmd/root.go similarity index 88% rename from evmd/cmd/evmd/cmd/root.go rename to evmd/cmd/root.go index 43e6e6126..71605717d 100644 --- a/evmd/cmd/evmd/cmd/root.go +++ b/evmd/cmd/root.go @@ -15,10 +15,11 @@ import ( dbm "github.com/cosmos/cosmos-db" cosmosevmcmd "github.com/cosmos/evm/client" + "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" @@ -30,7 +31,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" @@ -47,6 +48,7 @@ import ( txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" + clientflags "github.com/cosmos/evm/client/flags" ) // NewRootCmd creates a new root command for evmd. It is called once in the @@ -57,13 +59,13 @@ func NewRootCmd() *cobra.Command { // and the CLI options for the modules // add keyring to autocli opts - tempApp := evmd.NewExampleApp( + tempApp := evmdapp.NewExampleApp( log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}, - evmconfig.ChainConfig{}, + config.ChainConfig{}, ) encodingConfig := sdktestutil.TestEncodingConfig{ @@ -80,7 +82,7 @@ func NewRootCmd() *cobra.Command { WithInput(os.Stdin). WithAccountRetriever(authtypes.AccountRetriever{}). WithBroadcastMode(flags.FlagBroadcastMode). - WithHomeDir(evmdconfig.MustGetDefaultNodeHome()). + WithHomeDir(config.MustGetDefaultNodeHome()). WithViper(""). // In simapp, we don't use any prefix for env variables. // Cosmos EVM specific setup WithKeyringOptions(cosmosevmkeyring.Option()). @@ -100,7 +102,7 @@ func NewRootCmd() *cobra.Command { return err } - initClientCtx, err = clientcfg.ReadFromClientConfig(initClientCtx) + initClientCtx, err = sdkclientcfg.ReadFromClientConfig(initClientCtx) if err != nil { return err } @@ -129,7 +131,7 @@ func NewRootCmd() *cobra.Command { return err } - customAppTemplate, customAppConfig := evmdconfig.InitAppConfig(evmconfig.BaseDenom, evmconfig.DefaultEvmChainID) + customAppTemplate, customAppConfig := config.InitAppConfig(evmconfig.BaseDenom, evmconfig.DefaultEvmChainID) customTMConfig := initCometConfig() return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig) @@ -142,7 +144,7 @@ func NewRootCmd() *cobra.Command { // if the chain id is not set in client.toml, populate it with the default evm chain id initClientCtx = initClientCtx.WithChainID(evmconfig.DefaultChainID) } - initClientCtx, _ = clientcfg.ReadFromClientConfig(initClientCtx) + initClientCtx, _ = sdkclientcfg.ReadFromClientConfig(initClientCtx) autoCliOpts := tempApp.AutoCliOpts() autoCliOpts.ClientCtx = initClientCtx @@ -150,10 +152,10 @@ func NewRootCmd() *cobra.Command { panic(err) } - // chainConfig := evmconfig.DefaultChainConfig - // if err := chainConfig.ApplyChainConfig(); err != nil { - // panic(err) - // } + chainConfig := evmconfig.DefaultChainConfig + if err := chainConfig.ApplyChainConfig(); err != nil { + panic(err) + } return rootCmd } @@ -176,11 +178,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 := config.MustGetDefaultNodeHome() sdkAppCreator := func(l log.Logger, d dbm.DB, w io.Writer, ao servertypes.AppOptions) servertypes.Application { return newApp(l, d, w, ao) } @@ -192,7 +194,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. @@ -221,6 +223,12 @@ func initRootCmd(rootCmd *cobra.Command, evmApp *evmd.EVMD) { if err != nil { panic(err) } + + // add custom client flags to the root command + err = clientflags.AddClientFlags(rootCmd) + if err != nil { + panic(err) + } } func addModuleInitFlags(_ *cobra.Command) {} @@ -329,7 +337,7 @@ func newApp( panic(err) } - return evmd.NewExampleApp( + return evmdapp.NewExampleApp( logger, db, traceStore, true, appOpts, *chainConfig, @@ -348,7 +356,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. @@ -379,13 +387,13 @@ func appExport( } if height != -1 { - exampleApp = evmd.NewExampleApp(logger, db, traceStore, false, appOpts, *chainConfig, baseapp.SetChainID(chainID)) + exampleApp = evmdapp.NewExampleApp(logger, db, traceStore, false, appOpts, *chainConfig, baseapp.SetChainID(chainID)) if err := exampleApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } else { - exampleApp = evmd.NewExampleApp(logger, db, traceStore, true, appOpts, *chainConfig, baseapp.SetChainID(chainID)) + exampleApp = evmdapp.NewExampleApp(logger, db, traceStore, true, appOpts, *chainConfig, baseapp.SetChainID(chainID)) } return exampleApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) 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 8ee891b07..e338cfd9d 100644 --- a/evmd/cmd/evmd/cmd/testnet.go +++ b/evmd/cmd/testnet/testnet.go @@ -1,4 +1,4 @@ -package cmd +package testnet import ( "bufio" @@ -11,7 +11,6 @@ import ( cosmosevmhd "github.com/cosmos/evm/crypto/hd" cosmosevmkeyring "github.com/cosmos/evm/crypto/keyring" - "github.com/cosmos/evm/evmd" cosmosevmserverconfig "github.com/cosmos/evm/server/config" "github.com/spf13/cobra" "github.com/spf13/pflag" @@ -19,8 +18,8 @@ import ( cmtconfig "github.com/cometbft/cometbft/config" "github.com/cometbft/cometbft/types" tmtime "github.com/cometbft/cometbft/types/time" - evmconfig "github.com/cosmos/evm/config" - evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" + "github.com/cosmos/evm/config" + evmdapp "github.com/cosmos/evm/evmd/app" dbm "github.com/cosmos/cosmos-db" @@ -75,7 +74,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 @@ -126,7 +125,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", @@ -269,8 +268,8 @@ func initTestnetFiles( appConfig.Telemetry.EnableHostnameLabel = false appConfig.Telemetry.GlobalLabels = [][]string{{"chain_id", args.chainID}} evm := cosmosevmserverconfig.DefaultEVMConfig() - evm.EVMChainID = evmconfig.DefaultEvmChainID - evmCfg := evmdconfig.EVMAppConfig{ + evm.EVMChainID = config.DefaultEvmChainID + evmCfg := config.EVMAppConfig{ Config: *appConfig, EVM: *evm, JSONRPC: *cosmosevmserverconfig.DefaultJSONRPCConfig(), @@ -442,7 +441,7 @@ func initTestnetFiles( return err } - srvconfig.SetConfigTemplate(evmdconfig.EVMAppTemplate) + srvconfig.SetConfigTemplate(config.EVMAppTemplate) srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config", "app.toml"), evmCfg) } @@ -678,34 +677,34 @@ func NewTestNetworkFixture() network.TestFixture { } defer os.RemoveAll(dir) - app := evmd.NewExampleApp( + newApp := evmdapp.NewExampleApp( log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}, - evmconfig.DefaultChainConfig, + config.DefaultChainConfig, ) appCtr := func(val network.ValidatorI) servertypes.Application { - return evmd.NewExampleApp( + return evmdapp.NewExampleApp( log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}, - evmconfig.DefaultChainConfig, + config.DefaultChainConfig, ) } 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/cmd/evmd/main.go b/evmd/main.go similarity index 50% rename from evmd/cmd/evmd/main.go rename to evmd/main.go index 3dad66a57..8c38275e4 100644 --- a/evmd/cmd/evmd/main.go +++ b/evmd/main.go @@ -4,15 +4,15 @@ import ( "fmt" "os" - "github.com/cosmos/evm/evmd/cmd/evmd/cmd" - evmconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" + "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", evmconfig.MustGetDefaultNodeHome()); err != nil { + if err := svrcmd.Execute(rootCmd, "evmd", config.MustGetDefaultNodeHome()); err != nil { fmt.Fprintln(rootCmd.OutOrStderr(), err) os.Exit(1) } 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 0f8e501ce..2a28d602f 100644 --- a/evmd/tests/integration/create_app.go +++ b/evmd/tests/integration/create_app.go @@ -6,7 +6,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/evm" "github.com/cosmos/evm/config" - "github.com/cosmos/evm/evmd" + evmdapp "github.com/cosmos/evm/evmd/app" testconfig "github.com/cosmos/evm/testutil/config" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" ibctesting "github.com/cosmos/ibc-go/v10/testing" @@ -48,7 +48,7 @@ func CreateEvmd(chainID string, evmChainID uint64, customBaseAppOptions ...func( if err := chainConfig.ApplyChainConfig(); err != nil { panic(err) } - return evmd.NewExampleApp( + return evmdapp.NewExampleApp( logger, db, nil, @@ -75,7 +75,7 @@ func SetupEvmd() (ibctesting.TestingApp, map[string]json.RawMessage) { if err := chainConfig.ApplyChainConfig(); err != nil { panic(err) } - app := evmd.NewExampleApp( + app := evmdapp.NewExampleApp( log.NewNopLogger(), dbm.NewMemDB(), nil, diff --git a/evmd/tests/ledger/evmosd_suite_test.go b/evmd/tests/ledger/evmosd_suite_test.go index 47c803257..fa8de7b07 100644 --- a/evmd/tests/ledger/evmosd_suite_test.go +++ b/evmd/tests/ledger/evmosd_suite_test.go @@ -27,8 +27,9 @@ 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" + testutil "github.com/cosmos/evm/evmd/testutil" testconfig "github.com/cosmos/evm/testutil/config" utiltx "github.com/cosmos/evm/testutil/tx" @@ -47,7 +48,7 @@ var s *LedgerTestSuite type LedgerTestSuite struct { suite.Suite - app *evmd.EVMD + app *evmdapp.EVMD ctx sdk.Context ledger *mocks.SECP256K1 @@ -88,7 +89,7 @@ func (suite *LedgerTestSuite) SetupEvmosApp() { // init app chainID := testconfig.ExampleChainID - suite.app = evmd.Setup(suite.T(), chainID.ChainID, chainID.EVMChainID) + suite.app = testutil.Setup(suite.T(), chainID.ChainID, chainID.EVMChainID) suite.ctx = suite.app.NewContextLegacy(false, tmproto.Header{ Height: 1, ChainID: chainID.ChainID, diff --git a/evmd/tests/network/network.go b/evmd/tests/network/network.go index 50981c3fc..10d6c06e9 100644 --- a/evmd/tests/network/network.go +++ b/evmd/tests/network/network.go @@ -27,11 +27,10 @@ import ( cmtclient "github.com/cometbft/cometbft/rpc/client" dbm "github.com/cosmos/cosmos-db" - evmconfig "github.com/cosmos/evm/config" + "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" cosmosevmtypes "github.com/cosmos/evm/types" @@ -111,7 +110,7 @@ func DefaultConfig() Config { } defer os.RemoveAll(dir) coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] - chainConfig := evmconfig.NewChainConfig( + chainConfig := config.NewChainConfig( chainID, evmChainID, nil, @@ -123,7 +122,7 @@ func DefaultConfig() Config { if err := chainConfig.ApplyChainConfig(); err != nil { panic(err) } - tempApp := evmd.NewExampleApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simutils.NewAppOptionsWithFlagHome(dir), chainConfig, baseapp.SetChainID(chainID)) + tempApp := evmdapp.NewExampleApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simutils.NewAppOptionsWithFlagHome(dir), chainConfig, baseapp.SetChainID(chainID)) cfg := Config{ Codec: tempApp.AppCodec(), @@ -154,7 +153,7 @@ func DefaultConfig() Config { func NewAppConstructor(chainID string, evmChainID uint64) AppConstructor { return func(val Validator) servertypes.Application { coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] - chainConfig := evmconfig.NewChainConfig( + chainConfig := config.NewChainConfig( chainID, evmChainID, nil, @@ -166,7 +165,7 @@ func NewAppConstructor(chainID string, evmChainID uint64) AppConstructor { if err := chainConfig.ApplyChainConfig(); err != nil { panic(err) } - return evmd.NewExampleApp( + return evmdapp.NewExampleApp( val.Ctx.Logger, dbm.NewMemDB(), nil, true, simutils.NewAppOptionsWithFlagHome(val.Ctx.Config.RootDir), chainConfig, @@ -200,7 +199,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 @@ -283,7 +282,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 @@ -353,7 +352,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() @@ -501,7 +500,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { return nil, err } - customAppTemplate, _ := evmdconfig.InitAppConfig(testconfig.ExampleAttoDenom, testconfig.ExampleEIP155ChainID) + customAppTemplate, _ := config.InitAppConfig(testconfig.ExampleAttoDenom, testconfig.ExampleEIP155ChainID) 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 88% rename from evmd/test_helpers.go rename to evmd/testutil/helpers.go index 54c08d721..50ec2f6b9 100644 --- a/evmd/test_helpers.go +++ b/evmd/testutil/helpers.go @@ -1,4 +1,4 @@ -package evmd +package testutil import ( "encoding/json" @@ -12,6 +12,7 @@ import ( 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" @@ -47,24 +48,24 @@ func init() { 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 chainConfig := evmconfig.DefaultChainConfig - app := NewExampleApp(log.NewNopLogger(), db, nil, true, appOptions, chainConfig, baseapp.SetChainID(chainID)) + app := evmdapp.NewExampleApp(log.NewNopLogger(), db, nil, true, appOptions, chainConfig, 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) @@ -127,10 +128,10 @@ func SetupWithGenesisValSet(t *testing.T, chainID string, evmChainID uint64, val 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( + app := evmdapp.NewExampleApp( log.NewNopLogger(), db, nil, true, - simtestutil.NewAppOptionsWithFlagHome(defaultNodeHome), + simtestutil.NewAppOptionsWithFlagHome(evmdapp.DefaultNodeHome), chainConfig, baseapp.SetChainID(chainConfig.ChainID), ) diff --git a/server/config/toml.go b/server/config/toml.go index 52ce9c29c..1e9d4689a 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -25,17 +25,6 @@ evm-chain-id = {{ .EVM.EVMChainID }} # MinTip defines the minimum priority fee for the mempool. min-tip = {{ .EVM.MinTip }} -[evm.coin-info] - -# DisplayDenom defines the display denomination shown to users -display-denom = "{{ .EVM.CoinInfo.DisplayDenom }}" - -# Decimals defines the precision/decimals for the base denomination (1-18) -decimals = {{ .EVM.CoinInfo.Decimals }} - -# ExtendedDecimals defines the precision/decimals for the extended denomination (typically 18 decimals for atto-denom) -extended-decimals = {{ .EVM.CoinInfo.ExtendedDecimals }} - ############################################################################### ### JSON RPC Configuration ### ############################################################################### diff --git a/server/flags/flags.go b/server/flags/flags.go index 704d6d2e0..3844fc7df 100644 --- a/server/flags/flags.go +++ b/server/flags/flags.go @@ -71,9 +71,6 @@ const ( EVMEnablePreimageRecording = "evm.cache-preimage" EVMChainID = "evm.evm-chain-id" EVMMinTip = "evm.min-tip" - EVMDisplayDenom = "evm.coin-info.display-denom" - EVMDecimals = "evm.coin-info.decimals" - EVMExtendedDecimals = "evm.coin-info.extended-decimals" ) // TLS flags diff --git a/server/start.go b/server/start.go index 904e50edc..aa317693c 100644 --- a/server/start.go +++ b/server/start.go @@ -222,9 +222,6 @@ which accepts a path for the resulting pprof file. cmd.Flags().Bool(srvflags.EVMEnablePreimageRecording, cosmosevmserverconfig.DefaultEnablePreimageRecording, "Enables tracking of SHA3 preimages in the EVM (not implemented yet)") //nolint:lll cmd.Flags().Uint64(srvflags.EVMChainID, cosmosevmserverconfig.DefaultEVMChainID, "the EIP-155 compatible replay protection chain ID") cmd.Flags().Uint64(srvflags.EVMMinTip, cosmosevmserverconfig.DefaultEVMMinTip, "the minimum priority fee for the mempool") - cmd.Flags().String(srvflags.EVMDisplayDenom, cosmosevmserverconfig.DefaultEvmCoinInfoDisplayDenom, "the display denomination for the chain") - cmd.Flags().Uint8(srvflags.EVMDecimals, uint8(cosmosevmserverconfig.DefaultEvmCoinInfoDecimals), "the decimals for the base denomination") - cmd.Flags().Uint8(srvflags.EVMExtendedDecimals, uint8(cosmosevmserverconfig.DefaultEvmCoinInfoExtendedDecimals), "the decimals for the extended denomination") cmd.Flags().String(srvflags.TLSCertPath, "", "the cert.pem file path for the server TLS configuration") cmd.Flags().String(srvflags.TLSKeyPath, "", "the key.pem file path for the server TLS configuration") From ea492dd8aa65d67c46e5177b8cce6c911270cec0 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Wed, 17 Sep 2025 18:08:10 -0400 Subject: [PATCH 18/27] refactor keys package and clean up client dir --- client/config.go | 46 ---------------- client/config_test.go | 28 ---------- client/context.go | 18 ------- client/keys.go | 101 ------------------------------------ client/keys/add.go | 88 ++++++++++++++++++++++++++++++- client/{ => keys}/export.go | 2 +- client/{ => keys}/import.go | 2 +- evmd/app/creator.go | 18 ++++--- evmd/cmd/root.go | 31 +++++------ go.mod | 1 + go.sum | 2 + 11 files changed, 118 insertions(+), 219 deletions(-) delete mode 100644 client/config.go delete mode 100644 client/config_test.go delete mode 100644 client/context.go delete mode 100644 client/keys.go rename client/{ => keys}/export.go (99%) rename client/{ => keys}/import.go (98%) 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/app/creator.go b/evmd/app/creator.go index 35d2a941f..e901340a8 100644 --- a/evmd/app/creator.go +++ b/evmd/app/creator.go @@ -87,10 +87,11 @@ func (a AppCreator) newApp( baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))), } - chainConfig, err := evmconfig.CreateChainConfig(appOpts) - if err != nil { - panic(err) - } + chainConfig := &evmconfig.DefaultChainConfig + // chainConfig, err := evmconfig.CreateChainConfig(appOpts) + // if err != nil { + // panic(err) + // } return NewExampleApp( logger, @@ -134,10 +135,11 @@ func (a AppCreator) appExport( loadLatest = true } - chainConfig, err := evmconfig.CreateChainConfig(appOpts) - if err != nil { - return servertypes.ExportedApp{}, err - } + chainConfig := &evmconfig.DefaultChainConfig + // chainConfig, err := evmconfig.CreateChainConfig(appOpts) + // if err != nil { + // return servertypes.ExportedApp{}, err + // } evmApp = NewExampleApp( logger, diff --git a/evmd/cmd/root.go b/evmd/cmd/root.go index 71605717d..8f3e25520 100644 --- a/evmd/cmd/root.go +++ b/evmd/cmd/root.go @@ -14,8 +14,7 @@ import ( cmtcli "github.com/cometbft/cometbft/libs/cli" dbm "github.com/cosmos/cosmos-db" - cosmosevmcmd "github.com/cosmos/evm/client" - "github.com/cosmos/evm/config" + clientkeys "github.com/cosmos/evm/client/keys" evmconfig "github.com/cosmos/evm/config" cosmosevmkeyring "github.com/cosmos/evm/crypto/keyring" evmdapp "github.com/cosmos/evm/evmd/app" @@ -65,7 +64,7 @@ func NewRootCmd() *cobra.Command { nil, true, simtestutil.EmptyAppOptions{}, - config.ChainConfig{}, + evmconfig.DefaultChainConfig, ) encodingConfig := sdktestutil.TestEncodingConfig{ @@ -82,7 +81,7 @@ func NewRootCmd() *cobra.Command { WithInput(os.Stdin). WithAccountRetriever(authtypes.AccountRetriever{}). WithBroadcastMode(flags.FlagBroadcastMode). - WithHomeDir(config.MustGetDefaultNodeHome()). + WithHomeDir(evmconfig.MustGetDefaultNodeHome()). WithViper(""). // In simapp, we don't use any prefix for env variables. // Cosmos EVM specific setup WithKeyringOptions(cosmosevmkeyring.Option()). @@ -131,7 +130,7 @@ func NewRootCmd() *cobra.Command { return err } - customAppTemplate, customAppConfig := config.InitAppConfig(evmconfig.BaseDenom, evmconfig.DefaultEvmChainID) + customAppTemplate, customAppConfig := evmconfig.InitAppConfig(evmconfig.BaseDenom, evmconfig.DefaultEvmChainID) customTMConfig := initCometConfig() return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig) @@ -182,7 +181,7 @@ func initRootCmd(rootCmd *cobra.Command, evmApp *evmdapp.EVMD) { cfg := sdk.GetConfig() cfg.Seal() - defaultNodeHome := config.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) } @@ -207,7 +206,7 @@ func initRootCmd(rootCmd *cobra.Command, evmApp *evmdapp.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 @@ -332,10 +331,11 @@ func newApp( baseapp.SetChainID(chainID), } - chainConfig, err := evmconfig.CreateChainConfig(appOpts) - if err != nil { - panic(err) - } + chainConfig := &evmconfig.DefaultChainConfig + // chainConfig, err := evmconfig.CreateChainConfig(appOpts) + // if err != nil { + // panic(err) + // } return evmdapp.NewExampleApp( logger, db, traceStore, true, @@ -381,10 +381,11 @@ func appExport( } // create the chain config - chainConfig, err := evmconfig.CreateChainConfig(appOpts) - if err != nil { - return servertypes.ExportedApp{}, err - } + chainConfig := &evmconfig.DefaultChainConfig + // chainConfig, err := evmconfig.CreateChainConfig(appOpts) + // if err != nil { + // return servertypes.ExportedApp{}, err + // } if height != -1 { exampleApp = evmdapp.NewExampleApp(logger, db, traceStore, false, appOpts, *chainConfig, baseapp.SetChainID(chainID)) diff --git a/go.mod b/go.mod index 2e66b7626..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 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= From 2673aaa42e6e7956c225f1d240fdc7234c6a6dea Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Wed, 17 Sep 2025 18:09:56 -0400 Subject: [PATCH 19/27] remove err logging without nil check --- server/start.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 28b6677b201b920853c41fc445b439ca1b07a545 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Thu, 18 Sep 2025 11:06:51 -0400 Subject: [PATCH 20/27] add cmd extraction helper --- config/evmd_config.go | 4 +- config/server_app_options.go | 144 ++++++++++++++++++++++------------- evmd/app/app.go | 2 +- evmd/app/creator.go | 18 ++--- evmd/cmd/root.go | 40 +++++----- server/config/config.go | 2 +- server/config/toml.go | 11 +++ server/flags/flags.go | 3 + server/start.go | 4 + 9 files changed, 145 insertions(+), 83 deletions(-) diff --git a/config/evmd_config.go b/config/evmd_config.go index 2f9303699..641715e42 100644 --- a/config/evmd_config.go +++ b/config/evmd_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/server_app_options.go b/config/server_app_options.go index 99be07abf..cf583eb6c 100644 --- a/config/server_app_options.go +++ b/config/server_app_options.go @@ -2,12 +2,15 @@ package config import ( "errors" + "fmt" "math" "path/filepath" "github.com/holiman/uint256" "github.com/spf13/cast" + "github.com/spf13/cobra" + "github.com/cosmos/evm/config/eips" srvflags "github.com/cosmos/evm/server/flags" "cosmossdk.io/log" @@ -19,6 +22,7 @@ import ( 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 @@ -126,55 +130,91 @@ func GetEvmChainID(appOpts servertypes.AppOptions) (uint64, error) { return evmChainID, nil } -// func GetEvmCoinInfo(appOpts servertypes.AppOptions) (*evmtypes.EvmCoinInfo, error) { -// displayDenom := cast.ToString(appOpts.Get(srvflags.EVMDisplayDenom)) -// if displayDenom == "" { -// return nil, errors.New("display denom flag not found in app options") -// } -// decimals := cast.ToUint8(appOpts.Get(srvflags.EVMDecimals)) -// if decimals == 0 { -// return nil, errors.New("decimals flag not found in app options") -// } -// extendedDecimals := cast.ToUint8(appOpts.Get(srvflags.EVMExtendedDecimals)) -// if extendedDecimals == 0 { -// return nil, errors.New("extended decimals flag not found in app options") -// } - -// evmCoinInfo := evmtypes.EvmCoinInfo{ -// DisplayDenom: displayDenom, -// Decimals: evmtypes.Decimals(decimals), -// ExtendedDecimals: evmtypes.Decimals(extendedDecimals), -// } -// if err := evmCoinInfo.Validate(); err != nil { -// return nil, err -// } - -// return &evmCoinInfo, nil -// } - -// func CreateChainConfig(appOpts servertypes.AppOptions) (*ChainConfig, error) { -// chainID, err := GetChainID(appOpts) -// if err != nil { -// return nil, err -// } -// evmChainID, err := GetEvmChainID(appOpts) -// if err != nil { -// return nil, err -// } -// evmCoinInfo, err := GetEvmCoinInfo(appOpts) -// if err != nil { -// return nil, err -// } - -// chainConfig := NewChainConfig( -// chainID, -// evmChainID, -// eips.CosmosEVMActivators, -// nil, -// nil, -// *evmCoinInfo, -// false, -// ) - -// return &chainConfig, nil -// } +func GetEvmCoinInfo(appOpts servertypes.AppOptions) (*evmtypes.EvmCoinInfo, error) { + displayDenom := cast.ToString(appOpts.Get(srvflags.EVMDisplayDenom)) + if displayDenom == "" { + return nil, errors.New("display denom flag not found in app options") + } + decimals := cast.ToUint8(appOpts.Get(srvflags.EVMDecimals)) + if decimals == 0 { + return nil, errors.New("decimals flag not found in app options") + } + extendedDecimals := cast.ToUint8(appOpts.Get(srvflags.EVMExtendedDecimals)) + if extendedDecimals == 0 { + return nil, errors.New("extended decimals flag not found in app options") + } + + evmCoinInfo := evmtypes.EvmCoinInfo{ + DisplayDenom: displayDenom, + Decimals: evmtypes.Decimals(decimals), + ExtendedDecimals: evmtypes.Decimals(extendedDecimals), + } + if err := evmCoinInfo.Validate(); err != nil { + return nil, err + } + + return &evmCoinInfo, nil +} + +func CreateChainConfig(appOpts servertypes.AppOptions) (*ChainConfig, error) { + chainID, err := GetChainID(appOpts) + if err != nil { + return nil, err + } + evmChainID, err := GetEvmChainID(appOpts) + if err != nil { + return nil, err + } + evmCoinInfo, err := GetEvmCoinInfo(appOpts) + if err != nil { + return nil, err + } + + chainConfig := NewChainConfig( + chainID, + evmChainID, + eips.CosmosEVMActivators, + nil, + nil, + *evmCoinInfo, + false, + ) + + return &chainConfig, nil +} + +func CreateChainConfigFromCmd(chainID string, cmd *cobra.Command, reset bool) (*ChainConfig, error) { + evmChainID := cast.ToUint64(cmd.Flag(srvflags.EVMChainID).Value.String()) + displayDenom := cast.ToString(cmd.Flag(srvflags.EVMDisplayDenom).Value.String()) + decimals := cast.ToUint8(cmd.Flag(srvflags.EVMDecimals).Value.String()) + extendedDecimals := cast.ToUint8(cmd.Flag(srvflags.EVMExtendedDecimals).Value.String()) + + if chainID == "" || evmChainID == 0 || displayDenom == "" || decimals == 0 || extendedDecimals == 0 { + return nil, fmt.Errorf( + "cannot create chain config, missing one or more required config values: chain id: %s, evm chain id: %d, display denom: %s, decimals: %d, extended decimals: %d", + chainID, evmChainID, displayDenom, decimals, extendedDecimals, + ) + } + + evmCoinInfo := evmtypes.EvmCoinInfo{ + DisplayDenom: displayDenom, + Decimals: evmtypes.Decimals(decimals), + ExtendedDecimals: evmtypes.Decimals(extendedDecimals), + } + err := evmCoinInfo.Validate() + if err != nil { + return nil, fmt.Errorf("cannot create chain config, invalid evm coin info: %w", err) + } + + chainConfig := NewChainConfig( + chainID, + evmChainID, + eips.CosmosEVMActivators, + nil, + nil, + evmCoinInfo, + reset, + ) + + return &chainConfig, nil +} diff --git a/evmd/app/app.go b/evmd/app/app.go index 281abc770..78a926879 100644 --- a/evmd/app/app.go +++ b/evmd/app/app.go @@ -260,7 +260,7 @@ func NewExampleApp( bApp.SetInterfaceRegistry(interfaceRegistry) bApp.SetTxEncoder(txConfig.TxEncoder()) - // initialize the Cosmos EVM application configuration + // initialize the Cosmos EVM application configuration, if not already initialized if err := chainConfig.ApplyChainConfig(); err != nil { panic(err) } diff --git a/evmd/app/creator.go b/evmd/app/creator.go index e901340a8..35d2a941f 100644 --- a/evmd/app/creator.go +++ b/evmd/app/creator.go @@ -87,11 +87,10 @@ func (a AppCreator) newApp( baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))), } - chainConfig := &evmconfig.DefaultChainConfig - // chainConfig, err := evmconfig.CreateChainConfig(appOpts) - // if err != nil { - // panic(err) - // } + chainConfig, err := evmconfig.CreateChainConfig(appOpts) + if err != nil { + panic(err) + } return NewExampleApp( logger, @@ -135,11 +134,10 @@ func (a AppCreator) appExport( loadLatest = true } - chainConfig := &evmconfig.DefaultChainConfig - // chainConfig, err := evmconfig.CreateChainConfig(appOpts) - // if err != nil { - // return servertypes.ExportedApp{}, err - // } + chainConfig, err := evmconfig.CreateChainConfig(appOpts) + if err != nil { + return servertypes.ExportedApp{}, err + } evmApp = NewExampleApp( logger, diff --git a/evmd/cmd/root.go b/evmd/cmd/root.go index 8f3e25520..2dca40310 100644 --- a/evmd/cmd/root.go +++ b/evmd/cmd/root.go @@ -15,6 +15,7 @@ import ( dbm "github.com/cosmos/cosmos-db" 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" evmdapp "github.com/cosmos/evm/evmd/app" @@ -64,7 +65,7 @@ func NewRootCmd() *cobra.Command { nil, true, simtestutil.EmptyAppOptions{}, - evmconfig.DefaultChainConfig, + config.ChainConfig{}, ) encodingConfig := sdktestutil.TestEncodingConfig{ @@ -133,7 +134,19 @@ func NewRootCmd() *cobra.Command { customAppTemplate, customAppConfig := evmconfig.InitAppConfig(evmconfig.BaseDenom, evmconfig.DefaultEvmChainID) customTMConfig := initCometConfig() - return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, customTMConfig) + if err := sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, *customAppConfig, customTMConfig); err != nil { + return err + } + + chainConfig, err := config.CreateChainConfigFromCmd(initClientCtx.ChainID, cmd, false) + if err != nil { + return err + } + if err := chainConfig.ApplyChainConfig(); err != nil { + return err + } + + return nil }, } @@ -151,11 +164,6 @@ func NewRootCmd() *cobra.Command { panic(err) } - chainConfig := evmconfig.DefaultChainConfig - if err := chainConfig.ApplyChainConfig(); err != nil { - panic(err) - } - return rootCmd } @@ -331,11 +339,10 @@ func newApp( baseapp.SetChainID(chainID), } - chainConfig := &evmconfig.DefaultChainConfig - // chainConfig, err := evmconfig.CreateChainConfig(appOpts) - // if err != nil { - // panic(err) - // } + chainConfig, err := evmconfig.CreateChainConfig(appOpts) + if err != nil { + panic(err) + } return evmdapp.NewExampleApp( logger, db, traceStore, true, @@ -381,11 +388,10 @@ func appExport( } // create the chain config - chainConfig := &evmconfig.DefaultChainConfig - // chainConfig, err := evmconfig.CreateChainConfig(appOpts) - // if err != nil { - // return servertypes.ExportedApp{}, err - // } + chainConfig, err := evmconfig.CreateChainConfig(appOpts) + if err != nil { + return servertypes.ExportedApp{}, err + } if height != -1 { exampleApp = evmdapp.NewExampleApp(logger, db, traceStore, false, appOpts, *chainConfig, baseapp.SetChainID(chainID)) diff --git a/server/config/config.go b/server/config/config.go index 9450a39c1..2d9c70b8f 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -74,7 +74,7 @@ const ( // DefaultEvmCoinInfoDecimals is the default decimals for the base denomination DefaultEvmCoinInfoDecimals = evmtypes.EighteenDecimals - // DefaultEvmCoinInfoExtendedDecimals is the default decimals for the extended denomination + // DefaultEvmCoinInfoExtendedDecimals is the default decimals for the extended denomination, typically 18 decimals (atto-denom) DefaultEvmCoinInfoExtendedDecimals = evmtypes.EighteenDecimals // DefaultEVMMinTip is the default minimum priority fee for the mempool diff --git a/server/config/toml.go b/server/config/toml.go index 1e9d4689a..52ce9c29c 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -25,6 +25,17 @@ evm-chain-id = {{ .EVM.EVMChainID }} # MinTip defines the minimum priority fee for the mempool. min-tip = {{ .EVM.MinTip }} +[evm.coin-info] + +# DisplayDenom defines the display denomination shown to users +display-denom = "{{ .EVM.CoinInfo.DisplayDenom }}" + +# Decimals defines the precision/decimals for the base denomination (1-18) +decimals = {{ .EVM.CoinInfo.Decimals }} + +# ExtendedDecimals defines the precision/decimals for the extended denomination (typically 18 decimals for atto-denom) +extended-decimals = {{ .EVM.CoinInfo.ExtendedDecimals }} + ############################################################################### ### JSON RPC Configuration ### ############################################################################### diff --git a/server/flags/flags.go b/server/flags/flags.go index 3844fc7df..704d6d2e0 100644 --- a/server/flags/flags.go +++ b/server/flags/flags.go @@ -71,6 +71,9 @@ const ( EVMEnablePreimageRecording = "evm.cache-preimage" EVMChainID = "evm.evm-chain-id" EVMMinTip = "evm.min-tip" + EVMDisplayDenom = "evm.coin-info.display-denom" + EVMDecimals = "evm.coin-info.decimals" + EVMExtendedDecimals = "evm.coin-info.extended-decimals" ) // TLS flags diff --git a/server/start.go b/server/start.go index 727afdbf6..5aeba9fd8 100644 --- a/server/start.go +++ b/server/start.go @@ -223,6 +223,10 @@ which accepts a path for the resulting pprof file. cmd.Flags().Uint64(srvflags.EVMChainID, cosmosevmserverconfig.DefaultEVMChainID, "the EIP-155 compatible replay protection chain ID") cmd.Flags().Uint64(srvflags.EVMMinTip, cosmosevmserverconfig.DefaultEVMMinTip, "the minimum priority fee for the mempool") + cmd.PersistentFlags().String(srvflags.EVMDisplayDenom, cosmosevmserverconfig.DefaultEvmCoinInfoDisplayDenom, "the display denomination for the chain") + cmd.PersistentFlags().Uint8(srvflags.EVMDecimals, uint8(cosmosevmserverconfig.DefaultEvmCoinInfoDecimals), "the decimals for the base denomination") + cmd.PersistentFlags().Uint8(srvflags.EVMExtendedDecimals, uint8(cosmosevmserverconfig.DefaultEvmCoinInfoExtendedDecimals), "the decimals for the extended denomination") + cmd.Flags().String(srvflags.TLSCertPath, "", "the cert.pem file path for the server TLS configuration") cmd.Flags().String(srvflags.TLSKeyPath, "", "the key.pem file path for the server TLS configuration") From 54e765f04afedfa61a487c32b645db1ff04503ed Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Thu, 18 Sep 2025 12:28:17 -0400 Subject: [PATCH 21/27] fix local node vars --- local_node.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/local_node.sh b/local_node.sh index 0bca43205..b7089e585 100755 --- a/local_node.sh +++ b/local_node.sh @@ -15,7 +15,7 @@ CHAINDIR="$HOME/.evmd" BASEFEE=10000000 # Coin info -DISPLAY_DENOM="test" +DISPLAY_DENOM="atom" DECIMALS=18 EXTENDED_DECIMALS=18 @@ -173,7 +173,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 @@ -240,21 +240,21 @@ 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["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" @@ -297,7 +297,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 @@ -349,7 +349,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" From acf25cdacb9ef10ee75689bd122af59c04ff22c9 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Thu, 18 Sep 2025 12:28:53 -0400 Subject: [PATCH 22/27] remove duplicate toml --- client/client.toml | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 client/client.toml diff --git a/client/client.toml b/client/client.toml deleted file mode 100644 index d27222bda..000000000 --- a/client/client.toml +++ /dev/null @@ -1,32 +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 = "cosmos" - -# 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" - -[coin-info] - -# DisplayDenom defines the display denomination shown to users -display-denom = "atom" - -# Decimals defines the precision/decimals for the base denomination (1-18) -decimals = 18 - -# ExtendedDecimals defines the precision/decimals for the extended denomination (typically 18 decimals for atto-denom) -extended-decimals = 18 \ No newline at end of file From 5efe6f07acef90dcd5070dd58bf55cb6e87bcdaf Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Thu, 18 Sep 2025 12:29:56 -0400 Subject: [PATCH 23/27] remove cmd call --- evmd/cmd/root.go | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/evmd/cmd/root.go b/evmd/cmd/root.go index 2dca40310..daf3db362 100644 --- a/evmd/cmd/root.go +++ b/evmd/cmd/root.go @@ -138,14 +138,6 @@ func NewRootCmd() *cobra.Command { return err } - chainConfig, err := config.CreateChainConfigFromCmd(initClientCtx.ChainID, cmd, false) - if err != nil { - return err - } - if err := chainConfig.ApplyChainConfig(); err != nil { - return err - } - return nil }, } @@ -164,6 +156,11 @@ func NewRootCmd() *cobra.Command { panic(err) } + chainConfig := evmconfig.DefaultChainConfig + if err := chainConfig.ApplyChainConfig(); err != nil { + panic(err) + } + return rootCmd } From e67c60464ce437bf9cc88014e049053a686f6636 Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Mon, 22 Sep 2025 03:37:15 -0400 Subject: [PATCH 24/27] add genesis changes --- ante/cosmos/authz_test.go | 4 +- ante/evm/fee_checker_test.go | 5 +- ante/evm/mono_decorator_test.go | 6 +- client/flags/flags.go | 42 ----- config/{evmd_config.go => app_config.go} | 0 config/chain_config.go | 88 ++------- config/config.go | 129 ------------- config/constants.go | 31 ++++ config/sdk_config.go | 26 +++ config/server_app_options.go | 103 ++--------- ethereum/eip712/preprocess_test.go | 15 +- evmd/app/app.go | 65 ++++++- evmd/app/creator.go | 15 +- evmd/app/genesis.go | 4 +- evmd/cmd/root.go | 47 +---- evmd/cmd/testnet/testnet.go | 4 +- evmd/tests/integration/create_app.go | 37 +--- evmd/tests/integration/x_vm_test.go | 6 +- evmd/tests/network/network.go | 2 +- local_node.sh | 6 +- precompiles/common/balance_handler_test.go | 2 +- rpc/backend/node_info.go | 4 +- server/config/config.go | 14 -- server/flags/flags.go | 3 - server/start.go | 4 - tests/integration/eip712/test_eip712.go | 5 +- .../precompiles/bech32/test_bech32.go | 7 +- .../precompiles/bech32/test_methods.go | 9 +- .../precompiles/distribution/test_event.go | 3 +- .../precompiles/erc20/test_integration.go | 4 +- .../integration/rpc/backend/test_node_info.go | 5 +- tests/integration/x/erc20/test_precompiles.go | 8 +- .../x/precisebank/test_burn_integration.go | 10 +- tests/integration/x/vm/test_call_evm.go | 4 +- tests/integration/x/vm/test_grpc_query.go | 23 +-- .../x/vm/test_iterate_contracts.go | 2 +- tests/integration/x/vm/test_statedb.go | 2 +- testutil/config/config.go | 82 -------- testutil/config/config_testing.go | 49 ----- testutil/config/constants.go | 155 ++++++++-------- testutil/config/genesis.go | 4 +- testutil/ibc/chain.go | 3 +- testutil/ibc/coordinator.go | 4 +- testutil/integration/evm/network/config.go | 2 +- .../evm/network/example_contracts.go | 2 +- testutil/integration/evm/network/setup.go | 2 +- testutil/integration/evm/utils/genesis.go | 4 +- x/erc20/types/genesis_test.go | 32 ++-- x/precisebank/types/genesis_test.go | 19 +- x/vm/genesis.go | 81 ++++++++ x/vm/genesis_test.go | 175 ++++++++++++++++++ x/vm/keeper/keeper.go | 5 + x/vm/types/coin_info_config.go | 94 ++++++++++ ...testing.go => coin_info_config_testing.go} | 66 +++---- x/vm/types/config.go | 6 +- x/vm/types/config_testing.go | 4 - x/vm/types/denom_config.go | 93 ---------- x/vm/types/evm_config.go | 22 +-- x/vm/types/evm_config_test.go | 22 +-- x/vm/types/genesis.go | 129 +++++++++++++ x/vm/types/scaling_test.go | 29 +-- x/vm/wrappers/bank_test.go | 55 +++--- x/vm/wrappers/feemarket_test.go | 32 ++-- 63 files changed, 934 insertions(+), 981 deletions(-) delete mode 100644 client/flags/flags.go rename config/{evmd_config.go => app_config.go} (100%) delete mode 100644 config/config.go create mode 100644 config/constants.go create mode 100644 config/sdk_config.go delete mode 100644 testutil/config/config.go delete mode 100644 testutil/config/config_testing.go create mode 100644 x/vm/genesis_test.go create mode 100644 x/vm/types/coin_info_config.go rename x/vm/types/{denom_config_testing.go => coin_info_config_testing.go} (56%) delete mode 100644 x/vm/types/denom_config.go diff --git a/ante/cosmos/authz_test.go b/ante/cosmos/authz_test.go index 52e62a184..9208b3615 100644 --- a/ante/cosmos/authz_test.go +++ b/ante/cosmos/authz_test.go @@ -21,9 +21,7 @@ import ( ) func TestAuthzLimiterDecorator(t *testing.T) { - evmConfigurator := evmtypes.NewEvmConfig(). - WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) - err := evmConfigurator.Apply() + err := evmtypes.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) require.NoError(t, err) encodingCfg := encoding.MakeConfig(testconfig.ExampleChainID.EVMChainID) diff --git a/ante/evm/fee_checker_test.go b/ante/evm/fee_checker_test.go index 903f6e8cf..1255a07bd 100644 --- a/ante/evm/fee_checker_test.go +++ b/ante/evm/fee_checker_test.go @@ -58,10 +58,9 @@ func TestSDKTxFeeChecker(t *testing.T) { // without extension option // london hardfork enableness - chainConfig := evmconfig.NewTestChainConfig(evmconfig.DefaultEvmChainID) - encodingConfig := encoding.MakeConfig(chainConfig.EvmChainID) - err := chainConfig.ApplyChainConfig() + err := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, false).Apply() require.NoError(t, err) + encodingConfig := encoding.MakeConfig(evmconfig.DefaultEvmChainID) evmDenom := evmtypes.GetEVMCoinDenom() minGasPrices := sdk.NewDecCoins(sdk.NewDecCoin(evmDenom, math.NewInt(10))) diff --git a/ante/evm/mono_decorator_test.go b/ante/evm/mono_decorator_test.go index bc0178fe3..72af9771f 100644 --- a/ante/evm/mono_decorator_test.go +++ b/ante/evm/mono_decorator_test.go @@ -144,9 +144,9 @@ func toMsgSlice(msgs []*evmsdktypes.MsgEthereumTx) []sdk.Msg { } func TestMonoDecorator(t *testing.T) { - chainConfig := evmconfig.NewTestChainConfig(evmconfig.DefaultEvmChainID) - require.NoError(t, chainConfig.ApplyChainConfig()) - cfg := encoding.MakeConfig(chainConfig.EvmChainID) + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, false) + require.NoError(t, evmConfig.Apply()) + cfg := encoding.MakeConfig(evmconfig.DefaultEvmChainID) testCases := []struct { name string diff --git a/client/flags/flags.go b/client/flags/flags.go deleted file mode 100644 index 81cb60841..000000000 --- a/client/flags/flags.go +++ /dev/null @@ -1,42 +0,0 @@ -package flags - -import ( - "github.com/cosmos/evm/config" - "github.com/spf13/cobra" - "github.com/spf13/viper" -) - -// Client configuration flags -const ( - // Custom client flags that will be added to client.toml - DisplayDenom = "coin-info.display-denom" - Decimals = "coin-info.decimals" - ExtendedDecimals = "coin-info.extended-decimals" -) - -// Default values for client flags -const ( - DefaultDisplayDenom = config.DisplayDenom - DefaultDecimals = config.Decimals - DefaultExtendedDecimals = config.ExtendedDecimals -) - -// AddClientFlags adds custom client flags to the command -func AddClientFlags(cmd *cobra.Command) error { - cmd.PersistentFlags().String(DisplayDenom, DefaultDisplayDenom, "the display denom used to derive the denom and extended denom") - cmd.PersistentFlags().Uint8(Decimals, uint8(DefaultDecimals), "the decimals for the base denomination") - cmd.PersistentFlags().Uint8(ExtendedDecimals, uint8(DefaultExtendedDecimals), "the decimals for the extended denomination") - - // Bind flags to viper for client.toml precedence - if err := viper.BindPFlag(DisplayDenom, cmd.PersistentFlags().Lookup(DisplayDenom)); err != nil { - return err - } - if err := viper.BindPFlag(Decimals, cmd.PersistentFlags().Lookup(Decimals)); err != nil { - return err - } - if err := viper.BindPFlag(ExtendedDecimals, cmd.PersistentFlags().Lookup(ExtendedDecimals)); err != nil { - return err - } - - return nil -} diff --git a/config/evmd_config.go b/config/app_config.go similarity index 100% rename from config/evmd_config.go rename to config/app_config.go diff --git a/config/chain_config.go b/config/chain_config.go index e17757121..ffd107bf1 100644 --- a/config/chain_config.go +++ b/config/chain_config.go @@ -1,85 +1,19 @@ package config import ( - "fmt" - - "github.com/ethereum/go-ethereum/core/vm" - - "github.com/cosmos/evm/x/vm/types" - - "cosmossdk.io/math" - - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/evm/config/eips" + evmtypes "github.com/cosmos/evm/x/vm/types" ) -type ChainConfig struct { - ChainID string - EvmChainID uint64 - EvmConfig *types.EvmConfig -} - -// NewChainConfig creates a chain config with custom parameters, using defaults if not provided -func NewChainConfig( - chainID string, +func NewDefaultEvmConfig( evmChainID uint64, - evmActivators map[int]func(*vm.JumpTable), - evmExtraEIPs []int64, - evmChainConfig *types.ChainConfig, - evmCoinInfo types.EvmCoinInfo, reset bool, -) ChainConfig { - if evmChainConfig == nil { - evmChainConfig = types.DefaultChainConfig(evmChainID, evmCoinInfo) - } - - evmConfig := types.NewEvmConfig(). - WithChainConfig(evmChainConfig). - WithEVMCoinInfo(evmCoinInfo). - WithExtendedEips(evmActivators). - WithExtendedDefaultExtraEIPs(evmExtraEIPs...) - - if reset { - evmConfig.ResetTestConfig() - } - - return ChainConfig{ - ChainID: chainID, - EvmChainID: evmChainID, - EvmConfig: evmConfig, - } -} - -// ApplyEvmConfig applies the evm config to the global singleton chain config and coin info -func (cc *ChainConfig) ApplyChainConfig() error { - if cc.EvmConfig == nil || types.IsSealed() { - return nil // no op if evm config is nil or sealed - } - if cc.EvmConfig.GetChainConfig() == nil { - return fmt.Errorf("chain config is nil, cannot apply chain config") - } - - if err := setBaseDenom(cc.EvmConfig.GetEVMCoinInfo()); err != nil { - return err - } - return cc.EvmConfig.Apply() -} - -// 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 types.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))) +) *evmtypes.EvmConfig { + chainConfig := evmtypes.DefaultChainConfig( + DefaultEvmChainID, + DefaultEvmCoinInfo, + ) + return evmtypes.NewEvmConfig(). + WithChainConfig(chainConfig). + WithExtendedEips(eips.CosmosEVMActivators) } diff --git a/config/config.go b/config/config.go deleted file mode 100644 index 4f76b7a1a..000000000 --- a/config/config.go +++ /dev/null @@ -1,129 +0,0 @@ -package config - -import ( - "github.com/cosmos/evm/config/eips" - "github.com/cosmos/evm/types" - evmtypes "github.com/cosmos/evm/x/vm/types" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// DefaultChainConfig provides a standard 18-decimal cosmos/atom test configuration -var ( - DefaultChainConfig = NewChainConfig( - DefaultChainID, - DefaultEvmChainID, - eips.CosmosEVMActivators, - nil, - nil, - evmtypes.EvmCoinInfo{ - DisplayDenom: DisplayDenom, - Decimals: Decimals, - ExtendedDecimals: ExtendedDecimals, - }, - false, - ) -) - -// 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: { - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - // SixDecimalsChainID provides a chain ID which is being set up with 6 decimals - SixDecimalsChainID: { - DisplayDenom: "test", - Decimals: evmtypes.SixDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - // EVMChainID provides a chain ID used for internal testing - DefaultEvmChainID: { - DisplayDenom: "test", - Decimals: evmtypes.EighteenDecimals, - ExtendedDecimals: 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" - // Decimals defines the precision of the base denomination. - Decimals = evmtypes.EighteenDecimals - ExtendedDecimals = evmtypes.EighteenDecimals - // DefaultEvmChainID defines the EIP-155 replay-protection chain id for the current ethereum chain config. - DefaultEvmChainID = 262144 - // 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 - DefaultChainID = "cosmos" - 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" -) - -// 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 -} - -// NewTestChainConfig creates a fresh chain config for testing purposes -// This avoids the issue of shared EvmConfig instances being sealed -func NewTestChainConfig(evmChainID uint64) ChainConfig { - coinInfo := evmtypes.EvmCoinInfo{ - DisplayDenom: DisplayDenom, - Decimals: Decimals, - ExtendedDecimals: ExtendedDecimals, - } - - return NewChainConfig( - DefaultChainID, - evmChainID, - eips.CosmosEVMActivators, - nil, - nil, - coinInfo, - true, // reset = true for testing - ) -} diff --git a/config/constants.go b/config/constants.go new file mode 100644 index 000000000..eb5a2ac52 --- /dev/null +++ b/config/constants.go @@ -0,0 +1,31 @@ +package config + +import ( + serverflags "github.com/cosmos/evm/server/config" + evmtypes "github.com/cosmos/evm/x/vm/types" +) + +const () + +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 = serverflags.DefaultEVMChainID + // DefaultDisplayDenom defines the display denom for the default EVM coin info + DefaultDisplayDenom = "atom" + // DefaultDecimals defines the decimals for the default EVM coin info + DefaultDecimals = evmtypes.EighteenDecimals + // DefaultExtendedDecimals defines the extended decimals for the default EVM coin info + DefaultExtendedDecimals = evmtypes.EighteenDecimals + // DefaultWevmosContractMainnet is the default WEVMOS contract address for mainnet + DefaultWevmosContractMainnet = "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517" +) + +var DefaultEvmCoinInfo = evmtypes.EvmCoinInfo{ + DisplayDenom: DefaultDisplayDenom, + Decimals: DefaultDecimals, + ExtendedDecimals: DefaultExtendedDecimals, +} 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 cf583eb6c..3d85bf49f 100644 --- a/config/server_app_options.go +++ b/config/server_app_options.go @@ -2,15 +2,12 @@ package config import ( "errors" - "fmt" "math" "path/filepath" "github.com/holiman/uint256" "github.com/spf13/cast" - "github.com/spf13/cobra" - "github.com/cosmos/evm/config/eips" srvflags "github.com/cosmos/evm/server/flags" "cosmossdk.io/log" @@ -100,8 +97,7 @@ func GetMinTip(appOpts servertypes.AppOptions, logger log.Logger) *uint256.Int { return nil } -// GetChainID returns the EVM chain ID from the app options, set from -// If not available, it will load from client.toml +// 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 == "" { @@ -127,94 +123,29 @@ func GetEvmChainID(appOpts servertypes.AppOptions) (uint64, error) { if evmChainID == 0 { return 0, errors.New("evm chain id flag not found in app options") } - return evmChainID, nil -} -func GetEvmCoinInfo(appOpts servertypes.AppOptions) (*evmtypes.EvmCoinInfo, error) { - displayDenom := cast.ToString(appOpts.Get(srvflags.EVMDisplayDenom)) - if displayDenom == "" { - return nil, errors.New("display denom flag not found in app options") - } - decimals := cast.ToUint8(appOpts.Get(srvflags.EVMDecimals)) - if decimals == 0 { - return nil, errors.New("decimals flag not found in app options") - } - extendedDecimals := cast.ToUint8(appOpts.Get(srvflags.EVMExtendedDecimals)) - if extendedDecimals == 0 { - return nil, errors.New("extended decimals flag not found in app options") - } - - evmCoinInfo := evmtypes.EvmCoinInfo{ - DisplayDenom: displayDenom, - Decimals: evmtypes.Decimals(decimals), - ExtendedDecimals: evmtypes.Decimals(extendedDecimals), - } - if err := evmCoinInfo.Validate(); err != nil { - return nil, err - } - - return &evmCoinInfo, nil + return evmChainID, nil } -func CreateChainConfig(appOpts servertypes.AppOptions) (*ChainConfig, error) { - chainID, err := GetChainID(appOpts) - if err != nil { - return nil, err - } +func GetEvmChainIDWithDefault( + appOpts servertypes.AppOptions, + evmConfig *evmtypes.EvmConfig, + logger log.Logger) uint64 { evmChainID, err := GetEvmChainID(appOpts) - if err != nil { - return nil, err + if err == nil { + return evmChainID } - evmCoinInfo, err := GetEvmCoinInfo(appOpts) - if err != nil { - return nil, err - } - - chainConfig := NewChainConfig( - chainID, - evmChainID, - eips.CosmosEVMActivators, - nil, - nil, - *evmCoinInfo, - false, - ) - - return &chainConfig, nil -} + logger.Warn("failed to get evm chain id from app options", "error", err) -func CreateChainConfigFromCmd(chainID string, cmd *cobra.Command, reset bool) (*ChainConfig, error) { - evmChainID := cast.ToUint64(cmd.Flag(srvflags.EVMChainID).Value.String()) - displayDenom := cast.ToString(cmd.Flag(srvflags.EVMDisplayDenom).Value.String()) - decimals := cast.ToUint8(cmd.Flag(srvflags.EVMDecimals).Value.String()) - extendedDecimals := cast.ToUint8(cmd.Flag(srvflags.EVMExtendedDecimals).Value.String()) - - if chainID == "" || evmChainID == 0 || displayDenom == "" || decimals == 0 || extendedDecimals == 0 { - return nil, fmt.Errorf( - "cannot create chain config, missing one or more required config values: chain id: %s, evm chain id: %d, display denom: %s, decimals: %d, extended decimals: %d", - chainID, evmChainID, displayDenom, decimals, extendedDecimals, - ) - } - - evmCoinInfo := evmtypes.EvmCoinInfo{ - DisplayDenom: displayDenom, - Decimals: evmtypes.Decimals(decimals), - ExtendedDecimals: evmtypes.Decimals(extendedDecimals), - } - err := evmCoinInfo.Validate() - if err != nil { - return nil, fmt.Errorf("cannot create chain config, invalid evm coin info: %w", 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") } - chainConfig := NewChainConfig( - chainID, - evmChainID, - eips.CosmosEVMActivators, - nil, - nil, - evmCoinInfo, - reset, - ) + logger.Info("failed to get evm chain id, using default evm chain id", "default_evm_chain_id", DefaultEvmChainID) - return &chainConfig, nil + return DefaultEvmChainID } diff --git a/ethereum/eip712/preprocess_test.go b/ethereum/eip712/preprocess_test.go index 1a9ffbdec..adb050fb0 100644 --- a/ethereum/eip712/preprocess_test.go +++ b/ethereum/eip712/preprocess_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" + evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/encoding" "github.com/cosmos/evm/ethereum/eip712" testconfig "github.com/cosmos/evm/testutil/config" @@ -30,7 +31,7 @@ import ( // Testing Constants var ( // chainID is used in EIP-712 tests. - chainID = uint64(testconfig.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", - testconfig.ExampleBech32Prefix, + sdk.Bech32MainPrefix, ) ) @@ -55,10 +56,12 @@ type TestCaseStruct struct { func TestLedgerPreprocessing(t *testing.T) { // Update bech32 prefix - sdk.GetConfig().SetBech32PrefixForAccount(testconfig.ExampleBech32Prefix, "") - evmConfigurator := evmtypes.NewEvmConfig(). - WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) - err := evmConfigurator.Apply() + sdk.GetConfig().SetBech32PrefixForAccount(sdk.Bech32MainPrefix, "") + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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/app.go b/evmd/app/app.go index 78a926879..e16e09d9e 100644 --- a/evmd/app/app.go +++ b/evmd/app/app.go @@ -211,10 +211,11 @@ func NewExampleApp( traceStore io.Writer, loadLatest bool, appOpts servertypes.AppOptions, - chainConfig config.ChainConfig, + evmConfig *evmtypes.EvmConfig, baseAppOptions ...func(*baseapp.BaseApp), ) *EVMD { - encodingConfig := evmosencoding.MakeConfig(chainConfig.EvmChainID) + evmChainID := config.GetEvmChainIDWithDefault(appOpts, evmConfig, logger) + encodingConfig := evmosencoding.MakeConfig(evmChainID) appCodec := encodingConfig.Codec legacyAmino := encodingConfig.Amino @@ -261,7 +262,14 @@ func NewExampleApp( bApp.SetTxEncoder(txConfig.TxEncoder()) // initialize the Cosmos EVM application configuration, if not already initialized - if err := chainConfig.ApplyChainConfig(); err != nil { + if evmConfig == nil { + evmConfig = config.NewDefaultEvmConfig(evmChainID, false) + } + + if evmConfig == nil { + evmConfig = config.NewDefaultEvmConfig(evmChainID, false) + } + if err := evmConfig.Apply(); err != nil { panic(err) } @@ -884,6 +892,52 @@ func (app *EVMD) Configurator() module.Configurator { return app.configurator } +// validateCrossModuleGenesis performs cross-module genesis validation to ensure +// consistency between different modules' genesis states. +func (app *EVMD) validateCrossModuleGenesis(genesisState cosmosevmtypes.GenesisState) error { + // Unmarshal bank genesis state to get denomination metadata + var bankGenesis banktypes.GenesisState + if bankRaw, ok := genesisState[banktypes.ModuleName]; ok { + if err := app.appCodec.UnmarshalJSON(bankRaw, &bankGenesis); err != nil { + return fmt.Errorf("failed to unmarshal bank genesis: %w", err) + } + } else { + return fmt.Errorf("bank module genesis state not found") + } + + // Unmarshal VM genesis state + var vmGenesis evmtypes.GenesisState + if vmRaw, ok := genesisState[evmtypes.ModuleName]; ok { + if err := app.appCodec.UnmarshalJSON(vmRaw, &vmGenesis); err != nil { + return fmt.Errorf("failed to unmarshal vm genesis: %w", err) + } + } else { + return fmt.Errorf("vm module genesis state not found") + } + + // Validate EVM genesis against bank metadata + if err := evmtypes.ValidateGenesisWithBankMetadata(vmGenesis, bankGenesis.DenomMetadata); err != nil { + return fmt.Errorf("EVM genesis validation against bank metadata failed: %w", err) + } + + // Unmarshal staking genesis state to validate bond denom + var stakingGenesis stakingtypes.GenesisState + if stakingRaw, ok := genesisState[stakingtypes.ModuleName]; ok { + if err := app.appCodec.UnmarshalJSON(stakingRaw, &stakingGenesis); err != nil { + return fmt.Errorf("failed to unmarshal staking genesis: %w", err) + } + + // Validate that staking bond denom has proper bank metadata for EVM compatibility + if err := vm.ValidateStakingBondDenomWithBankMetadata(stakingGenesis.Params.BondDenom, bankGenesis.DenomMetadata); err != nil { + return fmt.Errorf("staking bond denom validation against bank metadata failed: %w", err) + } + } else { + return fmt.Errorf("staking module genesis state not found") + } + + return nil +} + // InitChainer application update at chain initialization func (app *EVMD) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { var genesisState cosmosevmtypes.GenesisState @@ -891,6 +945,11 @@ func (app *EVMD) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci panic(err) } + // Perform cross-module genesis validation before initialization + if err := app.validateCrossModuleGenesis(genesisState); err != nil { + panic(fmt.Errorf("cross-module genesis validation failed: %w", err)) + } + if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil { panic(err) } diff --git a/evmd/app/creator.go b/evmd/app/creator.go index 35d2a941f..8dc5c0b9a 100644 --- a/evmd/app/creator.go +++ b/evmd/app/creator.go @@ -12,7 +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" - evmconfig "github.com/cosmos/evm/config" "github.com/spf13/cast" "github.com/spf13/viper" @@ -87,18 +86,13 @@ func (a AppCreator) newApp( baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))), } - chainConfig, err := evmconfig.CreateChainConfig(appOpts) - if err != nil { - panic(err) - } - return NewExampleApp( logger, db, traceStore, true, simtestutil.EmptyAppOptions{}, - *chainConfig, + nil, baseappOptions..., ) } @@ -134,18 +128,13 @@ func (a AppCreator) appExport( loadLatest = true } - chainConfig, err := evmconfig.CreateChainConfig(appOpts) - if err != nil { - return servertypes.ExportedApp{}, err - } - evmApp = NewExampleApp( logger, db, traceStore, loadLatest, appOpts, - *chainConfig, + nil, ) if height != -1 { diff --git a/evmd/app/genesis.go b/evmd/app/genesis.go index 51cbdf778..8aad3dd6b 100644 --- a/evmd/app/genesis.go +++ b/evmd/app/genesis.go @@ -40,7 +40,7 @@ func NewEVMGenesisState() *evmtypes.GenesisState { func NewErc20GenesisState() *erc20types.GenesisState { erc20GenState := erc20types.DefaultGenesisState() erc20GenState.TokenPairs = testconfig.ExampleTokenPairs - erc20GenState.NativePrecompiles = []string{testconfig.WEVMOSContractMainnet} + erc20GenState.NativePrecompiles = []string{config.DefaultWevmosContractMainnet} return erc20GenState } @@ -50,7 +50,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 = config.DefaultEvmCoinInfo.GetDenom() return mintGenState } diff --git a/evmd/cmd/root.go b/evmd/cmd/root.go index daf3db362..de4480513 100644 --- a/evmd/cmd/root.go +++ b/evmd/cmd/root.go @@ -48,13 +48,12 @@ import ( txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" - clientflags "github.com/cosmos/evm/client/flags" ) // NewRootCmd creates a new root command for evmd. It is called once in the // main function. func NewRootCmd() *cobra.Command { - setupSDKConfig() + 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 @@ -65,7 +64,7 @@ func NewRootCmd() *cobra.Command { nil, true, simtestutil.EmptyAppOptions{}, - config.ChainConfig{}, + nil, ) encodingConfig := sdktestutil.TestEncodingConfig{ @@ -131,14 +130,10 @@ func NewRootCmd() *cobra.Command { return err } - customAppTemplate, customAppConfig := evmconfig.InitAppConfig(evmconfig.BaseDenom, evmconfig.DefaultEvmChainID) + customAppTemplate, customAppConfig := evmconfig.InitAppConfig(evmconfig.DefaultEvmCoinInfo.GetDenom(), evmconfig.DefaultEvmChainID) customTMConfig := initCometConfig() - if err := sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, *customAppConfig, customTMConfig); err != nil { - return err - } - - return nil + return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, *customAppConfig, customTMConfig) }, } @@ -156,20 +151,9 @@ func NewRootCmd() *cobra.Command { panic(err) } - chainConfig := evmconfig.DefaultChainConfig - if err := chainConfig.ApplyChainConfig(); err != nil { - panic(err) - } - return rootCmd } -func setupSDKConfig() { - config := sdk.GetConfig() - evmconfig.SetBech32Prefixes(config) - config.Seal() -} - // initCometConfig helps to override default CometBFT Config values. // return cmtcfg.DefaultConfig if no custom configuration is required for the application. func initCometConfig() *cmtcfg.Config { @@ -227,12 +211,6 @@ func initRootCmd(rootCmd *cobra.Command, evmApp *evmdapp.EVMD) { if err != nil { panic(err) } - - // add custom client flags to the root command - err = clientflags.AddClientFlags(rootCmd) - if err != nil { - panic(err) - } } func addModuleInitFlags(_ *cobra.Command) {} @@ -336,15 +314,10 @@ func newApp( baseapp.SetChainID(chainID), } - chainConfig, err := evmconfig.CreateChainConfig(appOpts) - if err != nil { - panic(err) - } - return evmdapp.NewExampleApp( logger, db, traceStore, true, appOpts, - *chainConfig, + nil, baseappOptions..., ) } @@ -384,20 +357,14 @@ func appExport( return servertypes.ExportedApp{}, err } - // create the chain config - chainConfig, err := evmconfig.CreateChainConfig(appOpts) - if err != nil { - return servertypes.ExportedApp{}, err - } - if height != -1 { - exampleApp = evmdapp.NewExampleApp(logger, db, traceStore, false, appOpts, *chainConfig, baseapp.SetChainID(chainID)) + exampleApp = evmdapp.NewExampleApp(logger, db, traceStore, false, appOpts, nil, baseapp.SetChainID(chainID)) if err := exampleApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } else { - exampleApp = evmdapp.NewExampleApp(logger, db, traceStore, true, appOpts, *chainConfig, baseapp.SetChainID(chainID)) + exampleApp = evmdapp.NewExampleApp(logger, db, traceStore, true, appOpts, nil, baseapp.SetChainID(chainID)) } return exampleApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) diff --git a/evmd/cmd/testnet/testnet.go b/evmd/cmd/testnet/testnet.go index e338cfd9d..7f1db41c2 100644 --- a/evmd/cmd/testnet/testnet.go +++ b/evmd/cmd/testnet/testnet.go @@ -683,7 +683,7 @@ func NewTestNetworkFixture() network.TestFixture { nil, true, simtestutil.EmptyAppOptions{}, - config.DefaultChainConfig, + nil, ) appCtr := func(val network.ValidatorI) servertypes.Application { @@ -693,7 +693,7 @@ func NewTestNetworkFixture() network.TestFixture { nil, true, simtestutil.EmptyAppOptions{}, - config.DefaultChainConfig, + nil, ) } diff --git a/evmd/tests/integration/create_app.go b/evmd/tests/integration/create_app.go index 2a28d602f..3bf97f94e 100644 --- a/evmd/tests/integration/create_app.go +++ b/evmd/tests/integration/create_app.go @@ -5,9 +5,7 @@ import ( dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/evm" - "github.com/cosmos/evm/config" evmdapp "github.com/cosmos/evm/evmd/app" - testconfig "github.com/cosmos/evm/testutil/config" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" ibctesting "github.com/cosmos/ibc-go/v10/testing" @@ -18,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) @@ -35,26 +34,13 @@ func CreateEvmd(chainID string, evmChainID uint64, customBaseAppOptions ...func( baseAppOptions := append(customBaseAppOptions, baseapp.SetChainID(chainID)) - coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] - chainConfig := config.NewChainConfig( - testconfig.ExampleChainID.ChainID, - evmChainID, - nil, - nil, - nil, - coinInfo, - false, - ) - if err := chainConfig.ApplyChainConfig(); err != nil { - panic(err) - } return evmdapp.NewExampleApp( logger, db, nil, loadLatest, appOptions, - chainConfig, + nil, baseAppOptions..., ) } @@ -62,26 +48,13 @@ func CreateEvmd(chainID string, evmChainID uint64, customBaseAppOptions ...func( // 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) { - coinInfo := testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID] - chainConfig := config.NewChainConfig( - testconfig.ExampleChainID.ChainID, - testconfig.ExampleEIP155ChainID, - nil, - nil, - nil, - coinInfo, - false, - ) - if err := chainConfig.ApplyChainConfig(); err != nil { - panic(err) - } app := evmdapp.NewExampleApp( log.NewNopLogger(), dbm.NewMemDB(), nil, true, simutils.EmptyAppOptions{}, - chainConfig, + nil, ) // disable base fee for testing genesisState := app.DefaultGenesis() @@ -89,10 +62,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 228defde2..2ef9a4e72 100644 --- a/evmd/tests/integration/x_vm_test.go +++ b/evmd/tests/integration/x_vm_test.go @@ -41,9 +41,9 @@ func BenchmarkGasEstimation(b *testing.B) { decimals := types.GetEVMCoinDecimals() extendedDecimals := types.GetEVMCoinExtendedDecimals() - configurator := types.NewEvmConfig() - configurator.ResetTestConfig() - err := configurator. + evmConfig := types.NewEvmConfig() + evmConfig.ResetTestConfig() + err := evmConfig. WithChainConfig(chainConfig). WithEVMCoinInfo(types.EvmCoinInfo{ DisplayDenom: displayDenom, diff --git a/evmd/tests/network/network.go b/evmd/tests/network/network.go index 10d6c06e9..197e75c4a 100644 --- a/evmd/tests/network/network.go +++ b/evmd/tests/network/network.go @@ -500,7 +500,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { return nil, err } - customAppTemplate, _ := config.InitAppConfig(testconfig.ExampleAttoDenom, testconfig.ExampleEIP155ChainID) + customAppTemplate, _ := config.InitAppConfig(testconfig.ExampleAttoDenom, testconfig.EighteenDecimalsChainID) srvconfig.SetConfigTemplate(customAppTemplate) srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), appCfg) diff --git a/local_node.sh b/local_node.sh index b7089e585..27f0268fb 100755 --- a/local_node.sh +++ b/local_node.sh @@ -368,10 +368,8 @@ evmd start "$TRACE" \ --pruning nothing \ --log_level $LOGLEVEL \ --minimum-gas-prices=0$EXTENDED_DENOM \ - --evm.coin-info.display-denom=$DISPLAY_DENOM \ - --evm.coin-info.decimals=$DECIMALS \ - --evm.coin-info.extended-decimals=$EXTENDED_DECIMALS \ --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/precompiles/common/balance_handler_test.go b/precompiles/common/balance_handler_test.go index 919c62eaa..03af304e5 100644 --- a/precompiles/common/balance_handler_test.go +++ b/precompiles/common/balance_handler_test.go @@ -29,7 +29,7 @@ import ( func setupBalanceHandlerTest(t *testing.T) { t.Helper() - sdk.GetConfig().SetBech32PrefixForAccount(testconfig.ExampleBech32Prefix, "") + sdk.GetConfig().SetBech32PrefixForAccount(sdk.Bech32MainPrefix, "") configurator := evmtypes.NewEvmConfig() configurator.ResetTestConfig() require.NoError(t, configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]).Apply()) diff --git a/rpc/backend/node_info.go b/rpc/backend/node_info.go index 5fb388bc5..8e35352bd 100644 --- a/rpc/backend/node_info.go +++ b/rpc/backend/node_info.go @@ -11,10 +11,10 @@ import ( cmttypes "github.com/cometbft/cometbft/types" + evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/crypto/ethsecp256k1" rpctypes "github.com/cosmos/evm/rpc/types" "github.com/cosmos/evm/server/config" - testconfig "github.com/cosmos/evm/testutil/config" evmtypes "github.com/cosmos/evm/x/vm/types" errorsmod "cosmossdk.io/errors" @@ -345,7 +345,7 @@ func (b *Backend) RPCMinGasPrice() *big.Int { minGasPrice := b.Cfg.GetMinGasPrices() amt := minGasPrice.AmountOf(baseDenom) if amt.IsNil() || amt.IsZero() { - return big.NewInt(testconfig.DefaultGasPrice) + return big.NewInt(evmconfig.DefaultGasPrice) } return evmtypes.ConvertAmountTo18DecimalsLegacy(amt).TruncateInt().BigInt() diff --git a/server/config/config.go b/server/config/config.go index 2d9c70b8f..e5d81e3f1 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -68,15 +68,6 @@ const ( // DefaultEVMChainID is the default EVM Chain ID if one is not provided, should match the value in evmd config DefaultEVMChainID = 262144 - // DefaultEvmCoinInfoDisplayDenom is the default display denomination for the chain - DefaultEvmCoinInfoDisplayDenom = "atom" - - // DefaultEvmCoinInfoDecimals is the default decimals for the base denomination - DefaultEvmCoinInfoDecimals = evmtypes.EighteenDecimals - - // DefaultEvmCoinInfoExtendedDecimals is the default decimals for the extended denomination, typically 18 decimals (atto-denom) - DefaultEvmCoinInfoExtendedDecimals = evmtypes.EighteenDecimals - // DefaultEVMMinTip is the default minimum priority fee for the mempool DefaultEVMMinTip = 0 @@ -231,11 +222,6 @@ func DefaultEVMConfig() *EVMConfig { EVMChainID: DefaultEVMChainID, EnablePreimageRecording: DefaultEnablePreimageRecording, MinTip: DefaultEVMMinTip, - CoinInfo: evmtypes.EvmCoinInfo{ - DisplayDenom: DefaultEvmCoinInfoDisplayDenom, - Decimals: DefaultEvmCoinInfoDecimals, - ExtendedDecimals: DefaultEvmCoinInfoExtendedDecimals, - }, } } diff --git a/server/flags/flags.go b/server/flags/flags.go index 704d6d2e0..3844fc7df 100644 --- a/server/flags/flags.go +++ b/server/flags/flags.go @@ -71,9 +71,6 @@ const ( EVMEnablePreimageRecording = "evm.cache-preimage" EVMChainID = "evm.evm-chain-id" EVMMinTip = "evm.min-tip" - EVMDisplayDenom = "evm.coin-info.display-denom" - EVMDecimals = "evm.coin-info.decimals" - EVMExtendedDecimals = "evm.coin-info.extended-decimals" ) // TLS flags diff --git a/server/start.go b/server/start.go index 5aeba9fd8..727afdbf6 100644 --- a/server/start.go +++ b/server/start.go @@ -223,10 +223,6 @@ which accepts a path for the resulting pprof file. cmd.Flags().Uint64(srvflags.EVMChainID, cosmosevmserverconfig.DefaultEVMChainID, "the EIP-155 compatible replay protection chain ID") cmd.Flags().Uint64(srvflags.EVMMinTip, cosmosevmserverconfig.DefaultEVMMinTip, "the minimum priority fee for the mempool") - cmd.PersistentFlags().String(srvflags.EVMDisplayDenom, cosmosevmserverconfig.DefaultEvmCoinInfoDisplayDenom, "the display denomination for the chain") - cmd.PersistentFlags().Uint8(srvflags.EVMDecimals, uint8(cosmosevmserverconfig.DefaultEvmCoinInfoDecimals), "the decimals for the base denomination") - cmd.PersistentFlags().Uint8(srvflags.EVMExtendedDecimals, uint8(cosmosevmserverconfig.DefaultEvmCoinInfoExtendedDecimals), "the decimals for the extended denomination") - cmd.Flags().String(srvflags.TLSCertPath, "", "the cert.pem file path for the server TLS configuration") cmd.Flags().String(srvflags.TLSKeyPath, "", "the key.pem file path for the server TLS configuration") diff --git a/tests/integration/eip712/test_eip712.go b/tests/integration/eip712/test_eip712.go index fd9d2860c..fc78c8038 100644 --- a/tests/integration/eip712/test_eip712.go +++ b/tests/integration/eip712/test_eip712.go @@ -12,7 +12,6 @@ import ( "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/ethereum/eip712" - "github.com/cosmos/evm/testutil/config" 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 @@ -347,7 +346,7 @@ func (s *TestSuite) TestEIP712() { AccountNumber: params.accountNumber, Sequence: params.sequence, PubKey: pubKey, - Address: sdk.MustBech32ifyAddressBytes(testconfig.ExampleBech32Prefix, pubKey.Bytes()), + Address: sdk.MustBech32ifyAddressBytes(sdk.Bech32MainPrefix, pubKey.Bytes()), } bz, err := authsigning.GetSignBytesAdapter( 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_event.go b/tests/integration/precompiles/distribution/test_event.go index 06223040c..3b0c530ee 100644 --- a/tests/integration/precompiles/distribution/test_event.go +++ b/tests/integration/precompiles/distribution/test_event.go @@ -11,7 +11,6 @@ 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" testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/x/vm/statedb" @@ -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, diff --git a/tests/integration/precompiles/erc20/test_integration.go b/tests/integration/precompiles/erc20/test_integration.go index e0160174b..408065a11 100644 --- a/tests/integration/precompiles/erc20/test_integration.go +++ b/tests/integration/precompiles/erc20/test_integration.go @@ -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(testconfig.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(testconfig.WEVMOSContractMainnet)}, + ConstructorArgs: []interface{}{common.HexToAddress(testconfig.WevmosContractMainnet)}, }, ) Expect(err).ToNot(HaveOccurred(), "failed to deploy reverter contract") diff --git a/tests/integration/rpc/backend/test_node_info.go b/tests/integration/rpc/backend/test_node_info.go index a09e8258d..590bbe4f5 100644 --- a/tests/integration/rpc/backend/test_node_info.go +++ b/tests/integration/rpc/backend/test_node_info.go @@ -11,6 +11,7 @@ import ( cmtrpcclient "github.com/cometbft/cometbft/rpc/client" + evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/rpc/backend/mocks" "github.com/cosmos/evm/server/config" @@ -33,13 +34,13 @@ func (s *TestSuite) TestRPCMinGasPrice() { { "pass - default gas price", func() {}, - big.NewInt(testconfig.DefaultGasPrice), + big.NewInt(evmconfig.DefaultGasPrice), true, }, { "pass - min gas price is 0", func() {}, - big.NewInt(testconfig.DefaultGasPrice), + big.NewInt(evmconfig.DefaultGasPrice), true, }, } diff --git a/tests/integration/x/erc20/test_precompiles.go b/tests/integration/x/erc20/test_precompiles.go index 0db7f80de..747598a63 100644 --- a/tests/integration/x/erc20/test_precompiles.go +++ b/tests/integration/x/erc20/test_precompiles.go @@ -96,7 +96,7 @@ func (s *KeeperTestSuite) TestGetERC20PrecompileInstance() { func (s *KeeperTestSuite) TestGetNativePrecompiles() { var ctx sdk.Context testAddr := utiltx.GenerateAddress() - defaultWEVMOSAddr := common.HexToAddress(testconfig.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(testconfig.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(testconfig.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(testconfig.WEVMOSContractMainnet) + defaultWEVMOSAddr := common.HexToAddress(testconfig.WevmosContractMainnet) unavailableAddr := common.HexToAddress("unavailable") testCases := []struct { diff --git a/tests/integration/x/precisebank/test_burn_integration.go b/tests/integration/x/precisebank/test_burn_integration.go index 520eb8fd8..720895a26 100644 --- a/tests/integration/x/precisebank/test_burn_integration.go +++ b/tests/integration/x/precisebank/test_burn_integration.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" + 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" @@ -498,10 +499,11 @@ func (s *KeeperIntegrationTestSuite) TestBurnCoinsRandomValueMultiDecimals() { } func FuzzBurnCoins(f *testing.F) { - configurator := evmtypes.NewEvmConfig() - configurator.ResetTestConfig() - configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) - err := configurator.Apply() + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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/vm/test_call_evm.go b/tests/integration/x/vm/test_call_evm.go index 385514d8b..2be995a15 100644 --- a/tests/integration/x/vm/test_call_evm.go +++ b/tests/integration/x/vm/test_call_evm.go @@ -13,7 +13,7 @@ import ( ) func (s *KeeperTestSuite) TestCallEVM() { - wcosmosEVMContract := common.HexToAddress(testconfig.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(testconfig.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 8d7ba7672..e2f06da71 100644 --- a/tests/integration/x/vm/test_grpc_query.go +++ b/tests/integration/x/vm/test_grpc_query.go @@ -16,6 +16,7 @@ import ( "github.com/holiman/uint256" "github.com/stretchr/testify/require" + evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/server/config" testconfig "github.com/cosmos/evm/testutil/config" "github.com/cosmos/evm/testutil/integration/evm/factory" @@ -1603,12 +1604,10 @@ func (s *KeeperTestSuite) TestQueryBaseFee() { chainConfig.CancunTime = &maxInt chainConfig.PragueTime = &maxInt - configurator := types.NewEvmConfig() - configurator.ResetTestConfig() - err := configurator. - WithChainConfig(chainConfig). - WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]). - Apply() + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + s.Require().NoError(evmConfig.Apply()) + err := types.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) s.Require().NoError(err) }, true, @@ -1637,7 +1636,6 @@ func (s *KeeperTestSuite) TestQueryBaseFee() { Decimals: types.GetEVMCoinDecimals(), ExtendedDecimals: types.GetEVMCoinExtendedDecimals(), } - chainConfig := types.DefaultChainConfig(s.Network.GetEIP155ChainID().Uint64(), coinInfo) 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.NewEvmConfig() - configurator.ResetTestConfig() - err = configurator. - WithChainConfig(chainConfig). - WithEVMCoinInfo(coinInfo). - Apply() + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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 78fc07ef9..2c58318df 100644 --- a/tests/integration/x/vm/test_iterate_contracts.go +++ b/tests/integration/x/vm/test_iterate_contracts.go @@ -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(testconfig.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 80e1c5a00..eab92a1d9 100644 --- a/tests/integration/x/vm/test_statedb.go +++ b/tests/integration/x/vm/test_statedb.go @@ -685,7 +685,7 @@ func (s *KeeperTestSuite) TestAddLog() { msg2.From = addr.Bytes() ethTx3Params := &types.EvmTxArgs{ - ChainID: big.NewInt(testconfig.ExampleEIP155ChainID), + ChainID: big.NewInt(testconfig.EighteenDecimalsChainID), Nonce: 0, To: &toAddr, Amount: common.Big1, diff --git a/testutil/config/config.go b/testutil/config/config.go deleted file mode 100644 index d87864130..000000000 --- a/testutil/config/config.go +++ /dev/null @@ -1,82 +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: { - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - EVMChainID: { - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, - ExtendedDecimals: 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 -) - -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 - // TestChainID1 is test chain IDs for IBC E2E test - TestChainID1 = 9005 - // TestChainID2 is test chain IDs for IBC E2E test - TestChainID2 = 9006 -) - -// 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 408647968..000000000 --- a/testutil/config/config_testing.go +++ /dev/null @@ -1,49 +0,0 @@ -//go:build test -// +build test - -package config - -import ( - 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: { - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - SixDecimalsChainID: { - DisplayDenom: "test", - Decimals: evmtypes.SixDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - TwelveDecimalsChainID: { - DisplayDenom: "test2", - Decimals: evmtypes.TwelveDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - TwoDecimalsChainID: { - DisplayDenom: "test3", - Decimals: evmtypes.TwoDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - TestChainID1: { - DisplayDenom: ExampleChainDenom, - Decimals: evmtypes.EighteenDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - TestChainID2: { - DisplayDenom: ExampleChainDenom, - Decimals: evmtypes.EighteenDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - EVMChainID: { - DisplayDenom: ExampleChainDenom, - Decimals: evmtypes.EighteenDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, -} diff --git a/testutil/config/constants.go b/testutil/config/constants.go index 982740fc7..6246b83a4 100644 --- a/testutil/config/constants.go +++ b/testutil/config/constants.go @@ -1,124 +1,131 @@ package config import ( + evmconfig "github.com/cosmos/evm/config" erc20types "github.com/cosmos/evm/x/erc20/types" evmtypes "github.com/cosmos/evm/x/vm/types" "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" ) const ( - // DefaultGasPrice is used in testing as the default to use for transactions - DefaultGasPrice = 20 + // 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 +) +// 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, + ExtendedDecimals: evmtypes.EighteenDecimals, + } + // SixDecimalEvmCoinInfo is the EvmCoinInfo for the 6 decimals chain + SixDecimalEvmCoinInfo = evmtypes.EvmCoinInfo{ + DisplayDenom: "test", + Decimals: evmtypes.SixDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, + } + // TwelveDecimalEvmCoinInfo is the EvmCoinInfo for a 12 decimals chain + TwelveDecimalEvmCoinInfo = evmtypes.EvmCoinInfo{ + DisplayDenom: "test2", + Decimals: evmtypes.TwelveDecimals, + ExtendedDecimals: evmtypes.EighteenDecimals, + } // ExampleAttoDenom provides an example denom for use in tests - ExampleAttoDenom = "aatom" - - // ExampleMicroDenom provides an example denom for use in tests - ExampleMicroDenom = "uatom" - - // 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" + ExampleAttoDenom = evmconfig.DefaultEvmCoinInfo.GetDenom() + // ExampleMicroDenom provides an example micro denom for use in tests + ExampleMicroDenom = SixDecimalEvmCoinInfo.GetDenom() + // WevmosContractMainnet is the WEVMOS contract address for mainnet + WevmosContractMainnet = evmconfig.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" ) +// 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: evmconfig.DefaultEvmCoinInfo, + TestChainID2: evmconfig.DefaultEvmCoinInfo, + TwoDecimalsChainID: TwoDecimalEvmCoinInfo, + SixDecimalsChainID: SixDecimalEvmCoinInfo, + TwelveDecimalsChainID: TwelveDecimalEvmCoinInfo, + EighteenDecimalsChainID: evmconfig.DefaultEvmCoinInfo, + evmconfig.DefaultEvmChainID: evmconfig.DefaultEvmCoinInfo, +} + +// 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"` } 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, + 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: 9002, + EVMChainID: SixDecimalsChainID, } - // TwelveDecimalsChainID provides a chain ID which is being set up with 12 decimals ExampleTwelveDecimalsChainID = ChainID{ ChainID: "ostwelve-3", - EVMChainID: 9003, - } - - // TwoDecimalsChainID provides a chain ID which is being set up with 2 decimals - ExampleTwoDecimalsChainID = 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: { - DisplayDenom: ExampleDisplayDenom, - Decimals: evmtypes.EighteenDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - ExampleSixDecimalsChainID: { - DisplayDenom: "test", - Decimals: evmtypes.SixDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - ExampleTwelveDecimalsChainID: { - DisplayDenom: "test2", - Decimals: evmtypes.TwelveDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - ExampleTwoDecimalsChainID: { - DisplayDenom: "test3", - Decimals: evmtypes.TwoDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, - }, - } - - // OtherCoinDenoms provides a list of other coin denoms that can be used in tests - OtherCoinDenoms = []string{ - "foo", - "bar", + EVMChainID: TwelveDecimalsChainID, } - - // ExampleTokenPairs creates a slice of token pairs, that contains a pair for the native denom of the example chain - // implementation. + // ExampleTokenPairs creates a slice of token pairs for the native denom of the example chain. ExampleTokenPairs = []erc20types.TokenPair{ { - Erc20Address: WEVMOSContractMainnet, + 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 creates a slice of allowances for the native denom of the example chain. ExampleAllowances = []erc20types.Allowance{ { - Erc20Address: WEVMOSContractMainnet, + 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: evmconfig.DefaultEvmCoinInfo, + ExampleTwoDecimalsChainID: TwoDecimalEvmCoinInfo, + ExampleSixDecimalsChainID: SixDecimalEvmCoinInfo, + ExampleTwelveDecimalsChainID: TwelveDecimalEvmCoinInfo, +} diff --git a/testutil/config/genesis.go b/testutil/config/genesis.go index 411e33968..63b6edb0c 100644 --- a/testutil/config/genesis.go +++ b/testutil/config/genesis.go @@ -37,7 +37,7 @@ func NewEVMGenesisState() *evmtypes.GenesisState { func NewErc20GenesisState() *erc20types.GenesisState { erc20GenState := erc20types.DefaultGenesisState() erc20GenState.TokenPairs = ExampleTokenPairs - erc20GenState.NativePrecompiles = []string{WEVMOSContractMainnet} + erc20GenState.NativePrecompiles = []string{WevmosContractMainnet} return erc20GenState } @@ -47,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/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 e424727bb..5360daf17 100644 --- a/testutil/ibc/coordinator.go +++ b/testutil/ibc/coordinator.go @@ -41,9 +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.NewTestChainConfig(evmChainID) + chainConfig := evmconfig.NewDefaultEvmConfig(evmChainID, false) require.NoError(t, err) - require.NoError(t, chainConfig.ApplyChainConfig()) + 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/config.go b/testutil/integration/evm/network/config.go index 7af545ec3..b90877c02 100644 --- a/testutil/integration/evm/network/config.go +++ b/testutil/integration/evm/network/config.go @@ -55,7 +55,7 @@ func DefaultConfig() Config { return Config{ chainID: testconfig.ExampleChainID.ChainID, - eip155ChainID: big.NewInt(testconfig.ExampleEIP155ChainID), + eip155ChainID: big.NewInt(testconfig.EighteenDecimalsChainID), chainCoins: DefaultChainCoins(), initialAmounts: DefaultInitialAmounts(), initialBondedAmount: DefaultInitialBondedAmount(), diff --git a/testutil/integration/evm/network/example_contracts.go b/testutil/integration/evm/network/example_contracts.go index 1f99e9022..1543a9ec6 100644 --- a/testutil/integration/evm/network/example_contracts.go +++ b/testutil/integration/evm/network/example_contracts.go @@ -9,7 +9,7 @@ import ( // // TODO: refactor to define this in the example chain initialization and pass as function argument var chainsWEVMOSHex = map[testconfig.ChainID]string{ - testconfig.ExampleChainID: testconfig.WEVMOSContractMainnet, + testconfig.ExampleChainID: testconfig.WevmosContractMainnet, } // GetWEVMOSContractHex returns the hex format of address for the WEVMOS contract diff --git a/testutil/integration/evm/network/setup.go b/testutil/integration/evm/network/setup.go index 9d4315e18..1913bf3dd 100644 --- a/testutil/integration/evm/network/setup.go +++ b/testutil/integration/evm/network/setup.go @@ -480,7 +480,7 @@ func setDefaultErc20GenesisState(cosmosEVMApp evm.EvmApp, evmChainID uint64, gen func newErc20GenesisState() *erc20types.GenesisState { erc20GenState := erc20types.DefaultGenesisState() erc20GenState.TokenPairs = testconfig.ExampleTokenPairs - erc20GenState.NativePrecompiles = []string{testconfig.WEVMOSContractMainnet} + erc20GenState.NativePrecompiles = []string{testconfig.WevmosContractMainnet} return erc20GenState } diff --git a/testutil/integration/evm/utils/genesis.go b/testutil/integration/evm/utils/genesis.go index 84a445d91..6f28686fe 100644 --- a/testutil/integration/evm/utils/genesis.go +++ b/testutil/integration/evm/utils/genesis.go @@ -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{testconfig.WEVMOSContractMainnet} + erc20GenesisState.NativePrecompiles = []string{testconfig.WevmosContractMainnet} erc20GenesisState.DynamicPrecompiles = dynPrecAddr // Combine module genesis states @@ -87,7 +87,7 @@ func CreateGenesisWithTokenPairs(keyring testkeyring.Keyring, denoms ...string) func NewErc20GenesisState() *erc20types.GenesisState { erc20GenState := erc20types.DefaultGenesisState() erc20GenState.TokenPairs = testconfig.ExampleTokenPairs - erc20GenState.NativePrecompiles = []string{testconfig.WEVMOSContractMainnet} + erc20GenState.NativePrecompiles = []string{testconfig.WevmosContractMainnet} return erc20GenState } diff --git a/x/erc20/types/genesis_test.go b/x/erc20/types/genesis_test.go index 69575a2bc..c6de6d275 100644 --- a/x/erc20/types/genesis_test.go +++ b/x/erc20/types/genesis_test.go @@ -60,7 +60,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Enabled: true, }, { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Denom: testconfig.ExampleAttoDenom, Enabled: true, }, @@ -85,7 +85,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Enabled: true, }, { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Denom: testconfig.ExampleAttoDenom, Enabled: true, }, @@ -110,7 +110,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Enabled: true, }, { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Denom: testconfig.ExampleAttoDenom, Enabled: true, }, @@ -135,7 +135,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Enabled: true, }, { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Denom: testconfig.ExampleAttoDenom, Enabled: true, }, @@ -155,7 +155,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Enabled: true, }, { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Denom: testconfig.ExampleAttoDenom, Enabled: true, }, @@ -186,13 +186,13 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { TokenPairs: testconfig.ExampleTokenPairs, Allowances: []types.Allowance{ { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Owner: testconfig.ExampleEvmAddressAlice, Spender: testconfig.ExampleEvmAddressBob, Value: math.NewInt(100), }, { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Owner: testconfig.ExampleEvmAddressAlice, Spender: testconfig.ExampleEvmAddressBob, Value: math.NewInt(100), @@ -207,7 +207,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: types.DefaultParams(), TokenPairs: []types.TokenPair{ { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Denom: testconfig.ExampleAttoDenom, Enabled: true, }, @@ -229,14 +229,14 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: types.DefaultParams(), TokenPairs: []types.TokenPair{ { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, Allowances: []types.Allowance{ { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Owner: "bad", Spender: testconfig.ExampleEvmAddressBob, Value: math.NewInt(-1), @@ -251,14 +251,14 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: types.DefaultParams(), TokenPairs: []types.TokenPair{ { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, Allowances: []types.Allowance{ { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Owner: testconfig.ExampleEvmAddressAlice, Spender: "bad", Value: math.NewInt(-1), @@ -273,14 +273,14 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: types.DefaultParams(), TokenPairs: []types.TokenPair{ { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, Allowances: []types.Allowance{ { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Owner: testconfig.ExampleEvmAddressAlice, Spender: testconfig.ExampleEvmAddressBob, Value: math.NewInt(0), @@ -295,14 +295,14 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Params: types.DefaultParams(), TokenPairs: []types.TokenPair{ { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Denom: testconfig.ExampleAttoDenom, Enabled: true, }, }, Allowances: []types.Allowance{ { - Erc20Address: testconfig.WEVMOSContractMainnet, + Erc20Address: testconfig.WevmosContractMainnet, Owner: testconfig.ExampleEvmAddressAlice, Spender: testconfig.ExampleEvmAddressBob, Value: math.NewInt(-1), diff --git a/x/precisebank/types/genesis_test.go b/x/precisebank/types/genesis_test.go index 9908032e8..c43fb0645 100644 --- a/x/precisebank/types/genesis_test.go +++ b/x/precisebank/types/genesis_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" + 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" @@ -256,10 +257,11 @@ func TestGenesisState_TotalAmountWithRemainder(t *testing.T) { } func FuzzGenesisStateValidate_NonZeroRemainder(f *testing.F) { - configurator := evmtypes.NewEvmConfig() - configurator.ResetTestConfig() - configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) - err := configurator.Apply() + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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.NewEvmConfig() - configurator.ResetTestConfig() - configurator.WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) - err := configurator.Apply() + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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..0726ba46d 100644 --- a/x/vm/genesis.go +++ b/x/vm/genesis.go @@ -2,6 +2,7 @@ package vm import ( "fmt" + "strings" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -12,6 +13,7 @@ import ( "github.com/cosmos/evm/x/vm/types" sdk "github.com/cosmos/cosmos-sdk/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) // InitGenesis initializes genesis state based on exported genesis @@ -26,6 +28,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 +92,77 @@ 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) + 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 +} + +// ValidateStakingBondDenomWithBankMetadata validates that the required staking bond denom +// is included in the bank metadata and has proper EVM compatibility. +// This function can be called at the app level to ensure proper configuration. +func ValidateStakingBondDenomWithBankMetadata(stakingBondDenom string, bankMetadata []banktypes.Metadata) error { + // Find the bank metadata for the staking bond denom + var bondMetadata *banktypes.Metadata + for _, metadata := range bankMetadata { + if metadata.Base == stakingBondDenom { + bondMetadata = &metadata + break + } + } + + if bondMetadata == nil { + return fmt.Errorf("bank metadata not found for staking bond denom: %s. "+ + "The bank module genesis must include metadata for the staking bond denomination", stakingBondDenom) + } + + // For staking bond denom, we need to ensure it has an 18-decimal variant for EVM compatibility + found18DecimalVariant := false + for _, unit := range bondMetadata.DenomUnits { + if unit.Exponent == 18 { + found18DecimalVariant = true + break + } + // Check aliases for 18-decimal variants (like "atto" prefix) + for _, alias := range unit.Aliases { + if strings.HasPrefix(alias, "atto") || strings.Contains(alias, "18") { + found18DecimalVariant = true + break + } + } + if found18DecimalVariant { + break + } + } + + if !found18DecimalVariant { + return fmt.Errorf( + "staking bond denom %s requires an 18-decimal variant in bank metadata for EVM compatibility, "+ + "but none found. This is required for proper EVM gas token handling", + stakingBondDenom, + ) + } + + return nil +} diff --git a/x/vm/genesis_test.go b/x/vm/genesis_test.go new file mode 100644 index 000000000..9e60e42b3 --- /dev/null +++ b/x/vm/genesis_test.go @@ -0,0 +1,175 @@ +package vm_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + "github.com/cosmos/evm/x/vm" + "github.com/cosmos/evm/x/vm/types" +) + +func TestDeriveEvmCoinInfoFromBankMetadata(t *testing.T) { + tests := []struct { + name string + metadata banktypes.Metadata + evmDenom string + expectError bool + expectedInfo types.EvmCoinInfo + }{ + { + name: "valid 18-decimal token", + metadata: banktypes.Metadata{ + Description: "Test token with 18 decimals", + Base: "atest", + Display: "test", + DenomUnits: []*banktypes.DenomUnit{ + {Denom: "atest", Exponent: 0}, + {Denom: "test", Exponent: 18}, + }, + }, + evmDenom: "atest", + expectError: false, + expectedInfo: types.EvmCoinInfo{ + DisplayDenom: "test", + Decimals: types.EighteenDecimals, + ExtendedDecimals: types.EighteenDecimals, + }, + }, + { + name: "valid 6-decimal token with atto alias", + metadata: banktypes.Metadata{ + Description: "Test token with 6 decimals and atto alias", + Base: "utest", + Display: "test", + DenomUnits: []*banktypes.DenomUnit{ + {Denom: "utest", Exponent: 0}, + {Denom: "test", Exponent: 6}, + {Denom: "atest", Exponent: 18, Aliases: []string{"attotest"}}, + }, + }, + evmDenom: "utest", + expectError: false, + expectedInfo: types.EvmCoinInfo{ + DisplayDenom: "test", + Decimals: types.SixDecimals, + ExtendedDecimals: types.EighteenDecimals, + }, + }, + { + name: "invalid - no 18-decimal variant", + metadata: banktypes.Metadata{ + Description: "Test token without 18-decimal variant", + Base: "utest", + Display: "test", + DenomUnits: []*banktypes.DenomUnit{ + {Denom: "utest", Exponent: 0}, + {Denom: "test", Exponent: 6}, + }, + }, + evmDenom: "utest", + expectError: true, + }, + { + name: "invalid - mismatched base denom", + metadata: banktypes.Metadata{ + Description: "Test token with mismatched base", + Base: "utest", + Display: "test", + DenomUnits: []*banktypes.DenomUnit{ + {Denom: "utest", Exponent: 0}, + {Denom: "test", Exponent: 18}, + }, + }, + evmDenom: "atest", // Different from metadata base + expectError: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + // Create VM params with the test evm_denom + params := types.Params{ + EvmDenom: tt.evmDenom, + } + + // Create genesis state + genesisState := types.GenesisState{ + Params: params, + } + + // Test ValidateGenesisWithBankMetadata + bankMetadata := []banktypes.Metadata{tt.metadata} + err := types.ValidateGenesisWithBankMetadata(genesisState, bankMetadata) + + if tt.expectError { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestValidateStakingBondDenomWithBankMetadata(t *testing.T) { + tests := []struct { + name string + stakingBondDenom string + bankMetadata []banktypes.Metadata + expectError bool + }{ + { + name: "valid staking bond denom with 18-decimal variant", + stakingBondDenom: "ustake", + bankMetadata: []banktypes.Metadata{ + { + Description: "Staking token", + Base: "ustake", + Display: "stake", + DenomUnits: []*banktypes.DenomUnit{ + {Denom: "ustake", Exponent: 0}, + {Denom: "stake", Exponent: 6}, + {Denom: "astake", Exponent: 18, Aliases: []string{"attostake"}}, + }, + }, + }, + expectError: false, + }, + { + name: "invalid - no metadata for staking bond denom", + stakingBondDenom: "ustake", + bankMetadata: []banktypes.Metadata{}, + expectError: true, + }, + { + name: "invalid - no 18-decimal variant", + stakingBondDenom: "ustake", + bankMetadata: []banktypes.Metadata{ + { + Description: "Staking token without 18-decimal variant", + Base: "ustake", + Display: "stake", + DenomUnits: []*banktypes.DenomUnit{ + {Denom: "ustake", Exponent: 0}, + {Denom: "stake", Exponent: 6}, + }, + }, + }, + expectError: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := vm.ValidateStakingBondDenomWithBankMetadata(tt.stakingBondDenom, tt.bankMetadata) + + if tt.expectError { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/vm/keeper/keeper.go b/x/vm/keeper/keeper.go index 774598fb2..9e03132c7 100644 --- a/x/vm/keeper/keeper.go +++ b/x/vm/keeper/keeper.go @@ -132,6 +132,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. diff --git a/x/vm/types/coin_info_config.go b/x/vm/types/coin_info_config.go new file mode 100644 index 000000000..03b16d265 --- /dev/null +++ b/x/vm/types/coin_info_config.go @@ -0,0 +1,94 @@ +//go:build !test +// +build !test + +package types + +import ( + "errors" + "fmt" + "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 evmCoinInfo.ExtendedDecimals +} + +// 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") + } + + 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) + } + + // prevent any external pointers or references to evmCoinInfoxx + evmCoinInfoOnce.Do(func() { + setBaseDenom(eci) + evmCoinInfo = new(EvmCoinInfo) + evmCoinInfo.DisplayDenom = eci.DisplayDenom + evmCoinInfo.Decimals = eci.Decimals + evmCoinInfo.ExtendedDecimals = eci.ExtendedDecimals + }) + + 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. +// 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/denom_config_testing.go b/x/vm/types/coin_info_config_testing.go similarity index 56% rename from x/vm/types/denom_config_testing.go rename to x/vm/types/coin_info_config_testing.go index 8633fdaf2..a9487897e 100644 --- a/x/vm/types/denom_config_testing.go +++ b/x/vm/types/coin_info_config_testing.go @@ -6,40 +6,19 @@ package types import ( "errors" "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" + "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 - -// 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 -} - -// setEVMCoinExtendedDecimals allows to define the extended denom of the coin used in the EVM. -func setEVMCoinExtendedDecimals(d Decimals) error { - if err := d.Validate(); err != nil { - return err - } - testingEvmCoinInfo.ExtendedDecimals = d - return nil -} +var ( + testingEvmCoinInfo *EvmCoinInfo + testingEvmCoinInfoOnce sync.Once +) -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 +// 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 @@ -64,13 +43,8 @@ func GetEVMCoinExtendedDenom() string { return testingEvmCoinInfo.GetExtendedDenom() } -// 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 { +// 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") } @@ -81,18 +55,22 @@ func setTestingEVMCoinInfo(eci EvmCoinInfo) error { } } - testingEvmCoinInfo = new(EvmCoinInfo) - - if err := setEVMCoinDecimals(eci.Decimals); err != nil { - return err - } - if err := setEVMCoinExtendedDecimals(eci.ExtendedDecimals); err != nil { - return err + if err := eci.Validate(); err != nil { + return fmt.Errorf("validation failed for evm coin info: %w", err) } - return setDisplayDenom(eci.DisplayDenom) + + 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/config.go b/x/vm/types/config.go index 8518cfc90..2d14768b6 100644 --- a/x/vm/types/config.go +++ b/x/vm/types/config.go @@ -11,7 +11,7 @@ import ( // 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 mirrors the silent behavior of the previous EvmAppOptions implementation + // This retains the previous silent behavior if IsSealed() { return nil } @@ -20,10 +20,6 @@ func (ec *EvmConfig) Apply() error { return err } - if err := setEVMCoinInfo(ec.evmCoinInfo); err != nil { - return err - } - if err := extendDefaultExtraEIPs(ec.extendedDefaultExtraEIPs); err != nil { return err } diff --git a/x/vm/types/config_testing.go b/x/vm/types/config_testing.go index 221e5d825..2645f0b49 100644 --- a/x/vm/types/config_testing.go +++ b/x/vm/types/config_testing.go @@ -27,10 +27,6 @@ func (ec *EvmConfig) Apply() error { return err } - if err := setTestingEVMCoinInfo(ec.evmCoinInfo); err != nil { - return err - } - if err := extendDefaultExtraEIPs(ec.extendedDefaultExtraEIPs); err != nil { return err } diff --git a/x/vm/types/denom_config.go b/x/vm/types/denom_config.go deleted file mode 100644 index f32c29df6..000000000 --- a/x/vm/types/denom_config.go +++ /dev/null @@ -1,93 +0,0 @@ -//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 `EvmConfig.Apply` 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 -} - -// setEVMCoinExtendedDecimals allows to define the extended denom of the coin used in the EVM. -func setEVMCoinExtendedDecimals(d Decimals) error { - if err := d.Validate(); err != nil { - return err - } - evmCoinInfo.ExtendedDecimals = d - 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 -} - -// GetEVMCoinExtendedDecimals returns the extended decimals used in the -// representation of the EVM coin. -func GetEVMCoinExtendedDecimals() Decimals { - return evmCoinInfo.ExtendedDecimals -} - -// 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() -} - -// 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.Decimals != eci.ExtendedDecimals { - return errors.New("EVM coin decimals and extended decimals must be the same for 18 decimals") - } - } - - evmCoinInfo = new(EvmCoinInfo) - - if err := setEVMCoinDecimals(eci.Decimals); err != nil { - return err - } - if err := setEVMCoinExtendedDecimals(eci.ExtendedDecimals); err != nil { - return err - } - return setDisplayDenom(eci.DisplayDenom) -} diff --git a/x/vm/types/evm_config.go b/x/vm/types/evm_config.go index 9ccb5ff80..8a24ee75a 100644 --- a/x/vm/types/evm_config.go +++ b/x/vm/types/evm_config.go @@ -25,7 +25,6 @@ type EvmConfig struct { extendedEIPs map[int]func(*vm.JumpTable) extendedDefaultExtraEIPs []int64 chainConfig *ChainConfig - evmCoinInfo EvmCoinInfo } // NewEvmConfig returns a pointer to a new EvmConfig object. @@ -37,8 +36,11 @@ func (ec *EvmConfig) GetChainConfig() *ChainConfig { return ec.chainConfig } -func (ec *EvmConfig) GetEVMCoinInfo() EvmCoinInfo { - return ec.evmCoinInfo +// 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 @@ -55,20 +57,6 @@ func (ec *EvmConfig) WithExtendedDefaultExtraEIPs(eips ...int64) *EvmConfig { return ec } -// 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 -} - -// WithEVMCoinInfo allows to define the denom and decimals of the token used as the -// EVM token. -func (ec *EvmConfig) WithEVMCoinInfo(coinInfo EvmCoinInfo) *EvmConfig { - ec.evmCoinInfo = coinInfo - return ec -} - func extendDefaultExtraEIPs(extraEIPs []int64) error { for _, eip := range extraEIPs { if slices.Contains(DefaultExtraEIPs, eip) { diff --git a/x/vm/types/evm_config_test.go b/x/vm/types/evm_config_test.go index 5e384791b..c394162c6 100644 --- a/x/vm/types/evm_config_test.go +++ b/x/vm/types/evm_config_test.go @@ -3,6 +3,7 @@ package types_test import ( "testing" + evmconfig "github.com/cosmos/evm/config" "github.com/ethereum/go-ethereum/core/vm" "github.com/stretchr/testify/require" @@ -11,9 +12,9 @@ import ( ) func TestEvmConfigApply(t *testing.T) { - evmConfigurator := types.NewEvmConfig(). - WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) - err := evmConfigurator.Apply() + evmConfigurator := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfigurator.ResetTestConfig() + err := types.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) require.NoError(t, err) err = evmConfigurator.Apply() @@ -34,8 +35,7 @@ func TestExtendedEips(t *testing.T) { extendedEIPs := map[int]func(*vm.JumpTable){ 3855: func(_ *vm.JumpTable) {}, } - ec := types.NewEvmConfig(). - WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]). + ec := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true). WithExtendedEips(extendedEIPs) return ec }, @@ -48,8 +48,7 @@ func TestExtendedEips(t *testing.T) { extendedEIPs := map[int]func(*vm.JumpTable){ 0o000: func(_ *vm.JumpTable) {}, } - ec := types.NewEvmConfig(). - WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]). + ec := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true). WithExtendedEips(extendedEIPs) return ec }, @@ -86,8 +85,7 @@ func TestExtendedDefaultExtraEips(t *testing.T) { func() *types.EvmConfig { extendedDefaultExtraEIPs := []int64{1000} types.DefaultExtraEIPs = append(types.DefaultExtraEIPs, 1000) - ec := types.NewEvmConfig(). - WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]). + ec := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec }, @@ -102,8 +100,7 @@ func TestExtendedDefaultExtraEips(t *testing.T) { "success - empty default extra eip", func() *types.EvmConfig { var extendedDefaultExtraEIPs []int64 - ec := types.NewEvmConfig(). - WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]). + ec := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec }, @@ -117,8 +114,7 @@ func TestExtendedDefaultExtraEips(t *testing.T) { "success - extra default eip added", func() *types.EvmConfig { extendedDefaultExtraEIPs := []int64{1001} - ec := types.NewEvmConfig(). - WithEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]). + ec := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec }, diff --git a/x/vm/types/genesis.go b/x/vm/types/genesis.go index f7190d294..2f945e121 100644 --- a/x/vm/types/genesis.go +++ b/x/vm/types/genesis.go @@ -2,8 +2,11 @@ package types import ( "fmt" + "strings" "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 +71,129 @@ func (gs GenesisState) Validate() error { return gs.Params.Validate() } + +// ValidateGenesisWithBankMetadata validates the EVM genesis state against bank metadata +// to ensure proper configuration for EVM coin derivation. This function should be called +// during genesis validation when both bank and EVM module genesis states are available. +func ValidateGenesisWithBankMetadata(evmGenesis GenesisState, bankMetadata []banktypes.Metadata) error { + // Basic validation first + if err := evmGenesis.Validate(); err != nil { + return err + } + + // Get the evm_denom from VM params + evmDenom := evmGenesis.Params.EvmDenom + if evmDenom == "" { + return fmt.Errorf("evm_denom parameter is empty") + } + + // Find the bank metadata for the evm_denom + var evmMetadata *banktypes.Metadata + for _, metadata := range bankMetadata { + if metadata.Base == evmDenom { + evmMetadata = &metadata + break + } + } + + if evmMetadata == nil { + return fmt.Errorf("bank metadata not found for evm_denom: %s. "+ + "The bank module genesis must include metadata for the EVM denomination", evmDenom) + } + + // Validate that the metadata can be used to derive valid coin info + _, err := DeriveCoinInfoFromMetadata(*evmMetadata, evmDenom) + if err != nil { + return fmt.Errorf("invalid bank metadata for evm_denom %s: %w", evmDenom, err) + } + + return nil +} + +// DeriveCoinInfoFromMetadata extracts EvmCoinInfo from bank metadata +func DeriveCoinInfoFromMetadata(metadata banktypes.Metadata, evmDenom string) (*EvmCoinInfo, error) { + // Validate that the base denom matches the evm_denom + if metadata.Base != evmDenom { + return nil, fmt.Errorf("metadata base denom (%s) does not match evm_denom (%s)", metadata.Base, evmDenom) + } + + // Find the base and display denominations + var baseDenomUnit *banktypes.DenomUnit + var displayDenomUnit *banktypes.DenomUnit + + for _, unit := range metadata.DenomUnits { + if unit.Denom == metadata.Base { + baseDenomUnit = unit + } + if unit.Denom == metadata.Display { + displayDenomUnit = unit + } + } + + if baseDenomUnit == nil { + return nil, fmt.Errorf("base denom unit not found in metadata for denom: %s", metadata.Base) + } + if displayDenomUnit == nil { + return nil, fmt.Errorf("display denom unit not found in metadata for denom: %s", metadata.Display) + } + + // Base denom should have exponent 0 + if baseDenomUnit.Exponent != 0 { + return nil, fmt.Errorf("base denom unit must have exponent 0, got: %d", baseDenomUnit.Exponent) + } + + // Calculate decimals from display unit exponent + decimals := Decimals(displayDenomUnit.Exponent) + if err := decimals.Validate(); err != nil { + return nil, fmt.Errorf("invalid decimals derived from metadata: %w", err) + } + + // For the extended decimals, we need to ensure we have an 18-decimal variant + extendedDecimals := EighteenDecimals + + // If the base decimals are already 18, use them as extended decimals + if decimals == EighteenDecimals { + extendedDecimals = decimals + } else { + // For non-18 decimal tokens, we require that there is an 18-decimal variant + // This would typically be handled by the precisebank module + // Check if there's an atto-variant or 18-decimal alias + found18DecimalVariant := false + for _, unit := range metadata.DenomUnits { + if unit.Exponent == 18 { + found18DecimalVariant = true + break + } + // Check aliases for 18-decimal variants (like "atto" prefix) + for _, alias := range unit.Aliases { + if strings.HasPrefix(alias, "atto") || strings.Contains(alias, "18") { + found18DecimalVariant = true + break + } + } + if found18DecimalVariant { + break + } + } + + if !found18DecimalVariant { + return nil, fmt.Errorf( + "evm_denom %s requires an 18-decimal variant in bank metadata for EVM compatibility, but none found", + evmDenom, + ) + } + } + + coinInfo := &EvmCoinInfo{ + DisplayDenom: metadata.Display, + Decimals: decimals, + ExtendedDecimals: extendedDecimals, + } + + // Validate the derived coin info + if err := coinInfo.Validate(); err != nil { + return nil, fmt.Errorf("derived coin info is invalid: %w", err) + } + + return coinInfo, nil +} diff --git a/x/vm/types/scaling_test.go b/x/vm/types/scaling_test.go index 13a379c6e..9d3fc942b 100644 --- a/x/vm/types/scaling_test.go +++ b/x/vm/types/scaling_test.go @@ -8,6 +8,7 @@ import ( "github.com/holiman/uint256" "github.com/stretchr/testify/require" + evmconfig "github.com/cosmos/evm/config" testconfig "github.com/cosmos/evm/testutil/config" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -75,9 +76,10 @@ func TestConvertEvmCoinFrom18Decimals(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - configurator := evmtypes.NewEvmConfig() - configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(tc.evmCoinInfo).Apply()) + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig.ResetTestConfig() + require.NoError(t, evmConfig.Apply()) + require.NoError(t, evmtypes.SetEVMCoinInfo(tc.evmCoinInfo)) coinConverted, err := evmtypes.ConvertEvmCoinDenomToExtendedDenom(tc.coin) @@ -139,9 +141,10 @@ func TestConvertCoinsFrom18Decimals(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - configurator := evmtypes.NewEvmConfig() - configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(tc.evmCoinInfo).Apply()) + 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") @@ -188,9 +191,10 @@ func TestConvertAmountTo18DecimalsLegacy(t *testing.T) { } { for _, tc := range testCases { t.Run(fmt.Sprintf("%d dec - %s", coinInfo.Decimals, tc.name), func(t *testing.T) { - configurator := evmtypes.NewEvmConfig() - configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(coinInfo).Apply()) + 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 { @@ -226,9 +230,10 @@ func TestConvertAmountTo18DecimalsBigInt(t *testing.T) { } { for _, tc := range testCases { t.Run(fmt.Sprintf("%d dec - %s", coinInfo.Decimals, tc.name), func(t *testing.T) { - configurator := evmtypes.NewEvmConfig() - configurator.ResetTestConfig() - require.NoError(t, configurator.WithEVMCoinInfo(coinInfo).Apply()) + 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 989e4e755..7b59805e1 100644 --- a/x/vm/wrappers/bank_test.go +++ b/x/vm/wrappers/bank_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" + 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" @@ -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.NewEvmConfig() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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) @@ -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.NewEvmConfig() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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) @@ -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.NewEvmConfig() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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) @@ -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.NewEvmConfig() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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) @@ -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.NewEvmConfig() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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) @@ -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.NewEvmConfig() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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 bf9697883..d70a11682 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" + 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" @@ -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.NewEvmConfig() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() - require.NoError(t, err, "failed to apply EvmConfig") + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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) @@ -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.NewEvmConfig() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + // Setup EVM evmConfig to have access to the EVM coin info. + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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) @@ -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.NewEvmConfig() - configurator.ResetTestConfig() - err := configurator.WithEVMCoinInfo(tc.coinInfo).Apply() + // Setup EVM evmConfig to have access to the EVM coin info. + evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.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) From 268df4ba8cf871d9fca0a5eebe6b94a3b13a282b Mon Sep 17 00:00:00 2001 From: Abdul Malek Date: Mon, 22 Sep 2025 04:38:51 -0400 Subject: [PATCH 25/27] update infer logic and tests --- local_node.sh | 8 +++ tests/solidity/test-helper.js | 36 ++---------- x/vm/genesis.go | 31 ++-------- x/vm/genesis_test.go | 64 +++++++++++++------- x/vm/types/denom.go | 23 ++++++++ x/vm/types/genesis.go | 108 ++++++++++++++-------------------- 6 files changed, 128 insertions(+), 142 deletions(-) diff --git a/local_node.sh b/local_node.sh index 27f0268fb..1aeddd6a8 100755 --- a/local_node.sh +++ b/local_node.sh @@ -53,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, ... @@ -72,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 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/x/vm/genesis.go b/x/vm/genesis.go index 0726ba46d..11c940bff 100644 --- a/x/vm/genesis.go +++ b/x/vm/genesis.go @@ -2,7 +2,6 @@ package vm import ( "fmt" - "strings" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -137,31 +136,11 @@ func ValidateStakingBondDenomWithBankMetadata(stakingBondDenom string, bankMetad "The bank module genesis must include metadata for the staking bond denomination", stakingBondDenom) } - // For staking bond denom, we need to ensure it has an 18-decimal variant for EVM compatibility - found18DecimalVariant := false - for _, unit := range bondMetadata.DenomUnits { - if unit.Exponent == 18 { - found18DecimalVariant = true - break - } - // Check aliases for 18-decimal variants (like "atto" prefix) - for _, alias := range unit.Aliases { - if strings.HasPrefix(alias, "atto") || strings.Contains(alias, "18") { - found18DecimalVariant = true - break - } - } - if found18DecimalVariant { - break - } - } - - if !found18DecimalVariant { - return fmt.Errorf( - "staking bond denom %s requires an 18-decimal variant in bank metadata for EVM compatibility, "+ - "but none found. This is required for proper EVM gas token handling", - stakingBondDenom, - ) + // Validate that the metadata can be used to derive valid coin info for EVM compatibility + _, err := types.DeriveCoinInfoFromMetadata(*bondMetadata, stakingBondDenom) + if err != nil { + return fmt.Errorf("invalid bank metadata for staking bond denom %s: %w. "+ + "The staking bond denomination requires proper EVM-compatible metadata", stakingBondDenom, err) } return nil diff --git a/x/vm/genesis_test.go b/x/vm/genesis_test.go index 9e60e42b3..8ddae0824 100644 --- a/x/vm/genesis_test.go +++ b/x/vm/genesis_test.go @@ -27,27 +27,21 @@ func TestDeriveEvmCoinInfoFromBankMetadata(t *testing.T) { Display: "test", DenomUnits: []*banktypes.DenomUnit{ {Denom: "atest", Exponent: 0}, - {Denom: "test", Exponent: 18}, + {Denom: "atest", Exponent: 0}, }, }, evmDenom: "atest", - expectError: false, - expectedInfo: types.EvmCoinInfo{ - DisplayDenom: "test", - Decimals: types.EighteenDecimals, - ExtendedDecimals: types.EighteenDecimals, - }, + expectError: true, }, { - name: "valid 6-decimal token with atto alias", + name: "valid 6-decimal token", metadata: banktypes.Metadata{ - Description: "Test token with 6 decimals and atto alias", + Description: "Test token with 6 decimals", Base: "utest", Display: "test", DenomUnits: []*banktypes.DenomUnit{ {Denom: "utest", Exponent: 0}, - {Denom: "test", Exponent: 6}, - {Denom: "atest", Exponent: 18, Aliases: []string{"attotest"}}, + {Denom: "utest", Exponent: 12}, }, }, evmDenom: "utest", @@ -59,14 +53,13 @@ func TestDeriveEvmCoinInfoFromBankMetadata(t *testing.T) { }, }, { - name: "invalid - no 18-decimal variant", + name: "invalid - not exactly 2 denom units", metadata: banktypes.Metadata{ - Description: "Test token without 18-decimal variant", + Description: "Test token with wrong number of units", Base: "utest", Display: "test", DenomUnits: []*banktypes.DenomUnit{ {Denom: "utest", Exponent: 0}, - {Denom: "test", Exponent: 6}, }, }, evmDenom: "utest", @@ -80,10 +73,38 @@ func TestDeriveEvmCoinInfoFromBankMetadata(t *testing.T) { Display: "test", DenomUnits: []*banktypes.DenomUnit{ {Denom: "utest", Exponent: 0}, - {Denom: "test", Exponent: 18}, + {Denom: "utest", Exponent: 12}, + }, + }, + evmDenom: "mtest", + expectError: true, + }, + { + name: "invalid - display denom mismatch", + metadata: banktypes.Metadata{ + Description: "Test token with display denom mismatch", + Base: "utest", + Display: "test", + DenomUnits: []*banktypes.DenomUnit{ + {Denom: "utest", Exponent: 0}, + {Denom: "uwrong", Exponent: 12}, + }, + }, + evmDenom: "utest", + expectError: true, + }, + { + name: "invalid - invalid SI prefix", + metadata: banktypes.Metadata{ + Description: "Test token with invalid SI prefix", + Base: "xtest", + Display: "test", + DenomUnits: []*banktypes.DenomUnit{ + {Denom: "xtest", Exponent: 0}, + {Denom: "xtest", Exponent: 12}, }, }, - evmDenom: "atest", // Different from metadata base + evmDenom: "xtest", expectError: true, }, } @@ -121,7 +142,7 @@ func TestValidateStakingBondDenomWithBankMetadata(t *testing.T) { expectError bool }{ { - name: "valid staking bond denom with 18-decimal variant", + name: "valid staking bond denom with 6-decimal", stakingBondDenom: "ustake", bankMetadata: []banktypes.Metadata{ { @@ -130,8 +151,7 @@ func TestValidateStakingBondDenomWithBankMetadata(t *testing.T) { Display: "stake", DenomUnits: []*banktypes.DenomUnit{ {Denom: "ustake", Exponent: 0}, - {Denom: "stake", Exponent: 6}, - {Denom: "astake", Exponent: 18, Aliases: []string{"attostake"}}, + {Denom: "ustake", Exponent: 12}, }, }, }, @@ -144,16 +164,16 @@ func TestValidateStakingBondDenomWithBankMetadata(t *testing.T) { expectError: true, }, { - name: "invalid - no 18-decimal variant", + name: "invalid - invalid metadata structure", stakingBondDenom: "ustake", bankMetadata: []banktypes.Metadata{ { - Description: "Staking token without 18-decimal variant", + Description: "Staking token with invalid structure", Base: "ustake", Display: "stake", DenomUnits: []*banktypes.DenomUnit{ {Denom: "ustake", Exponent: 0}, - {Denom: "stake", Exponent: 6}, + {Denom: "mstake", Exponent: 3}, }, }, }, diff --git a/x/vm/types/denom.go b/x/vm/types/denom.go index 0119ce460..aefce74c7 100644 --- a/x/vm/types/denom.go +++ b/x/vm/types/denom.go @@ -108,3 +108,26 @@ func (d Decimals) GetSIPrefix() string { 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/genesis.go b/x/vm/types/genesis.go index 2f945e121..dd5662917 100644 --- a/x/vm/types/genesis.go +++ b/x/vm/types/genesis.go @@ -2,10 +2,10 @@ package types import ( "fmt" - "strings" "github.com/cosmos/evm/types" + sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -112,85 +112,67 @@ func ValidateGenesisWithBankMetadata(evmGenesis GenesisState, bankMetadata []ban // DeriveCoinInfoFromMetadata extracts EvmCoinInfo from bank metadata func DeriveCoinInfoFromMetadata(metadata banktypes.Metadata, evmDenom string) (*EvmCoinInfo, error) { - // Validate that the base denom matches the evm_denom if metadata.Base != evmDenom { return nil, fmt.Errorf("metadata base denom (%s) does not match evm_denom (%s)", metadata.Base, evmDenom) } - - // Find the base and display denominations - var baseDenomUnit *banktypes.DenomUnit - var displayDenomUnit *banktypes.DenomUnit - - for _, unit := range metadata.DenomUnits { - if unit.Denom == metadata.Base { - baseDenomUnit = unit - } - if unit.Denom == metadata.Display { - displayDenomUnit = unit - } + if len(metadata.DenomUnits) != 2 { + return nil, fmt.Errorf("metadata must have exactly 2 denom units, got: %d", len(metadata.DenomUnits)) } - if baseDenomUnit == nil { - return nil, fmt.Errorf("base denom unit not found in metadata for denom: %s", metadata.Base) - } - if displayDenomUnit == nil { - return nil, fmt.Errorf("display denom unit not found in metadata for denom: %s", metadata.Display) - } - - // Base denom should have exponent 0 - if baseDenomUnit.Exponent != 0 { - return nil, fmt.Errorf("base denom unit must have exponent 0, got: %d", baseDenomUnit.Exponent) - } - - // Calculate decimals from display unit exponent - decimals := Decimals(displayDenomUnit.Exponent) - if err := decimals.Validate(); err != nil { - return nil, fmt.Errorf("invalid decimals derived from metadata: %w", err) - } - - // For the extended decimals, we need to ensure we have an 18-decimal variant + foundBase := false + displayDenom := "" + baseDecimals := Decimals(0) + baseDecimalsInferred := Decimals(0) extendedDecimals := EighteenDecimals - // If the base decimals are already 18, use them as extended decimals - if decimals == EighteenDecimals { - extendedDecimals = decimals - } else { - // For non-18 decimal tokens, we require that there is an 18-decimal variant - // This would typically be handled by the precisebank module - // Check if there's an atto-variant or 18-decimal alias - found18DecimalVariant := false - for _, unit := range metadata.DenomUnits { - if unit.Exponent == 18 { - found18DecimalVariant = true - break - } - // Check aliases for 18-decimal variants (like "atto" prefix) - for _, alias := range unit.Aliases { - if strings.HasPrefix(alias, "atto") || strings.Contains(alias, "18") { - found18DecimalVariant = true - break - } + for _, unit := range metadata.DenomUnits { + if unit.Denom == metadata.Base && unit.Exponent == 0 { + if sdk.ValidateDenom(unit.Denom) != nil { + return nil, fmt.Errorf("invalid base denom: %s", unit.Denom) } - if found18DecimalVariant { - break + displayDenom = unit.Denom[1:] + dec, err := DecimalsFromSIPrefix(unit.Denom[:1]) + if err != nil { + return nil, fmt.Errorf("invalid base denom: %s, %w", unit.Denom, err) } + baseDecimalsInferred = dec + foundBase = true + continue } - if !found18DecimalVariant { - return nil, fmt.Errorf( - "evm_denom %s requires an 18-decimal variant in bank metadata for EVM compatibility, but none found", - evmDenom, - ) + if sdk.ValidateDenom(unit.Denom) != nil { + return nil, fmt.Errorf("invalid extended denom: %s", unit.Denom) + } + dd := unit.Denom[1:] + if dd != displayDenom { + return nil, fmt.Errorf("display denom mismatch: %s != %s", dd, displayDenom) + } + decInferred, err := DecimalsFromSIPrefix(unit.Denom[:1]) + if err != nil { + return nil, fmt.Errorf("invalid extended denom: %s, %w", unit.Denom, err) + } + baseDecs := EighteenDecimals - Decimals(unit.Exponent) + if baseDecs != decInferred { + return nil, fmt.Errorf("extended decimals mismatch: %s != %s", extendedDecimals, decInferred) + } + baseDecimals = decInferred + if baseDecimalsInferred != baseDecimals { + return nil, fmt.Errorf("base decimals mismatch: %s != %s", baseDecimalsInferred, baseDecimals) } } + if baseDecimals == 0 || extendedDecimals == 0 || displayDenom == "" || !foundBase { + return nil, fmt.Errorf( + "invalid base or extended denom: %s, %s, %s, %t", + baseDecimals, extendedDecimals, displayDenom, foundBase, + ) + } + coinInfo := &EvmCoinInfo{ - DisplayDenom: metadata.Display, - Decimals: decimals, + DisplayDenom: displayDenom, + Decimals: baseDecimals, ExtendedDecimals: extendedDecimals, } - - // Validate the derived coin info if err := coinInfo.Validate(); err != nil { return nil, fmt.Errorf("derived coin info is invalid: %w", err) } From 77dc203635788db364e9eb3f25382094b04f7e01 Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 22 Sep 2025 15:56:34 -0400 Subject: [PATCH 26/27] fix and set evmcoininfo --- config/constants.go | 13 ++- evmd/app/app.go | 61 +---------- mempool/mempool.go | 14 +-- rpc/backend/call_tx.go | 7 +- server/config/toml.go | 11 -- testutil/config/constants.go | 21 ++-- x/precisebank/module.go | 2 +- x/vm/genesis.go | 32 +----- x/vm/genesis_test.go | 194 --------------------------------- x/vm/module.go | 12 +- x/vm/types/coin_info.go | 76 +++---------- x/vm/types/coin_info_config.go | 17 +-- x/vm/types/genesis.go | 112 ++----------------- 13 files changed, 72 insertions(+), 500 deletions(-) diff --git a/config/constants.go b/config/constants.go index eb5a2ac52..ffe1992b5 100644 --- a/config/constants.go +++ b/config/constants.go @@ -16,16 +16,19 @@ const ( DefaultEvmChainID = serverflags.DefaultEVMChainID // 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 = evmtypes.EighteenDecimals - // DefaultExtendedDecimals defines the extended decimals for the default EVM coin info - DefaultExtendedDecimals = evmtypes.EighteenDecimals // DefaultWevmosContractMainnet is the default WEVMOS contract address for mainnet DefaultWevmosContractMainnet = "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517" ) var DefaultEvmCoinInfo = evmtypes.EvmCoinInfo{ - DisplayDenom: DefaultDisplayDenom, - Decimals: DefaultDecimals, - ExtendedDecimals: DefaultExtendedDecimals, + DisplayDenom: DefaultDisplayDenom, + Decimals: DefaultDecimals, + BaseDenom: DefaultBaseDenom, + ExtendedDenom: DefaultExtendedDenom, } diff --git a/evmd/app/app.go b/evmd/app/app.go index e16e09d9e..46ad311ad 100644 --- a/evmd/app/app.go +++ b/evmd/app/app.go @@ -266,9 +266,6 @@ func NewExampleApp( evmConfig = config.NewDefaultEvmConfig(evmChainID, false) } - if evmConfig == nil { - evmConfig = config.NewDefaultEvmConfig(evmChainID, false) - } if err := evmConfig.Apply(); err != nil { panic(err) } @@ -611,7 +608,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), @@ -759,7 +756,7 @@ func NewExampleApp( // set the EVM priority nonce mempool // If you wish to use the noop mempool, remove this codeblock - if evmtypes.GetChainConfig() != nil { + if evmConfig != nil { // Get the block gas limit from genesis file blockGasLimit := config.GetBlockGasLimit(appOpts, logger) // Get GetMinTip from app.toml or cli flag configuration @@ -892,52 +889,6 @@ func (app *EVMD) Configurator() module.Configurator { return app.configurator } -// validateCrossModuleGenesis performs cross-module genesis validation to ensure -// consistency between different modules' genesis states. -func (app *EVMD) validateCrossModuleGenesis(genesisState cosmosevmtypes.GenesisState) error { - // Unmarshal bank genesis state to get denomination metadata - var bankGenesis banktypes.GenesisState - if bankRaw, ok := genesisState[banktypes.ModuleName]; ok { - if err := app.appCodec.UnmarshalJSON(bankRaw, &bankGenesis); err != nil { - return fmt.Errorf("failed to unmarshal bank genesis: %w", err) - } - } else { - return fmt.Errorf("bank module genesis state not found") - } - - // Unmarshal VM genesis state - var vmGenesis evmtypes.GenesisState - if vmRaw, ok := genesisState[evmtypes.ModuleName]; ok { - if err := app.appCodec.UnmarshalJSON(vmRaw, &vmGenesis); err != nil { - return fmt.Errorf("failed to unmarshal vm genesis: %w", err) - } - } else { - return fmt.Errorf("vm module genesis state not found") - } - - // Validate EVM genesis against bank metadata - if err := evmtypes.ValidateGenesisWithBankMetadata(vmGenesis, bankGenesis.DenomMetadata); err != nil { - return fmt.Errorf("EVM genesis validation against bank metadata failed: %w", err) - } - - // Unmarshal staking genesis state to validate bond denom - var stakingGenesis stakingtypes.GenesisState - if stakingRaw, ok := genesisState[stakingtypes.ModuleName]; ok { - if err := app.appCodec.UnmarshalJSON(stakingRaw, &stakingGenesis); err != nil { - return fmt.Errorf("failed to unmarshal staking genesis: %w", err) - } - - // Validate that staking bond denom has proper bank metadata for EVM compatibility - if err := vm.ValidateStakingBondDenomWithBankMetadata(stakingGenesis.Params.BondDenom, bankGenesis.DenomMetadata); err != nil { - return fmt.Errorf("staking bond denom validation against bank metadata failed: %w", err) - } - } else { - return fmt.Errorf("staking module genesis state not found") - } - - return nil -} - // InitChainer application update at chain initialization func (app *EVMD) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci.ResponseInitChain, error) { var genesisState cosmosevmtypes.GenesisState @@ -945,10 +896,10 @@ func (app *EVMD) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci panic(err) } - // Perform cross-module genesis validation before initialization - if err := app.validateCrossModuleGenesis(genesisState); err != nil { - panic(fmt.Errorf("cross-module genesis validation failed: %w", err)) - } + //// Perform cross-module genesis validation before initialization + //if err := app.validateCrossModuleGenesis(genesisState); err != nil { + // panic(fmt.Errorf("cross-module genesis validation failed: %w", err)) + //} if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil { panic(err) 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/rpc/backend/call_tx.go b/rpc/backend/call_tx.go index bb2d29b75..6b7544820 100644 --- a/rpc/backend/call_tx.go +++ b/rpc/backend/call_tx.go @@ -43,9 +43,10 @@ func (b *Backend) Resend(args evmtypes.TransactionArgs, gasPrice *hexutil.Big, g cfg := b.ChainConfig() if cfg == nil { coinInfo := evmtypes.EvmCoinInfo{ - DisplayDenom: evmtypes.GetEVMCoinDisplayDenom(), - Decimals: evmtypes.GetEVMCoinDecimals(), - ExtendedDecimals: evmtypes.GetEVMCoinExtendedDecimals(), + DisplayDenom: evmtypes.GetEVMCoinDisplayDenom(), + Decimals: evmtypes.GetEVMCoinDecimals(), + BaseDenom: evmtypes.GetEVMCoinDenom(), + ExtendedDenom: evmtypes.GetEVMCoinExtendedDenom(), } cfg = evmtypes.DefaultChainConfig(b.EvmChainID.Uint64(), coinInfo).EthereumConfig(nil) } diff --git a/server/config/toml.go b/server/config/toml.go index 52ce9c29c..1e9d4689a 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -25,17 +25,6 @@ evm-chain-id = {{ .EVM.EVMChainID }} # MinTip defines the minimum priority fee for the mempool. min-tip = {{ .EVM.MinTip }} -[evm.coin-info] - -# DisplayDenom defines the display denomination shown to users -display-denom = "{{ .EVM.CoinInfo.DisplayDenom }}" - -# Decimals defines the precision/decimals for the base denomination (1-18) -decimals = {{ .EVM.CoinInfo.Decimals }} - -# ExtendedDecimals defines the precision/decimals for the extended denomination (typically 18 decimals for atto-denom) -extended-decimals = {{ .EVM.CoinInfo.ExtendedDecimals }} - ############################################################################### ### JSON RPC Configuration ### ############################################################################### diff --git a/testutil/config/constants.go b/testutil/config/constants.go index 6246b83a4..b31300b5b 100644 --- a/testutil/config/constants.go +++ b/testutil/config/constants.go @@ -28,21 +28,24 @@ const ( var ( // TwoDecimalEvmCoinInfo is the EvmCoinInfo for the 2 decimals chain TwoDecimalEvmCoinInfo = evmtypes.EvmCoinInfo{ - DisplayDenom: "test3", - Decimals: evmtypes.TwoDecimals, - ExtendedDecimals: evmtypes.EighteenDecimals, + 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, - ExtendedDecimals: evmtypes.EighteenDecimals, + 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, - ExtendedDecimals: evmtypes.EighteenDecimals, + DisplayDenom: "test2", + Decimals: evmtypes.TwelveDecimals, + BaseDenom: "twtest2", + ExtendedDenom: "atest2", } // ExampleAttoDenom provides an example denom for use in tests ExampleAttoDenom = evmconfig.DefaultEvmCoinInfo.GetDenom() 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/vm/genesis.go b/x/vm/genesis.go index 11c940bff..b38d596e5 100644 --- a/x/vm/genesis.go +++ b/x/vm/genesis.go @@ -12,7 +12,6 @@ import ( "github.com/cosmos/evm/x/vm/types" sdk "github.com/cosmos/cosmos-sdk/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) // InitGenesis initializes genesis state based on exported genesis @@ -20,6 +19,8 @@ func InitGenesis( ctx sdk.Context, k *keeper.Keeper, accountKeeper types.AccountKeeper, + stakingKeeper types.StakingKeeper, + bankKeeper types.BankKeeper, data types.GenesisState, ) []abci.ValidatorUpdate { err := k.SetParams(ctx, data.Params) @@ -106,6 +107,7 @@ func deriveAndSetEvmCoinInfo(ctx sdk.Context, k *keeper.Keeper, params types.Par } 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) } @@ -117,31 +119,3 @@ func deriveAndSetEvmCoinInfo(ctx sdk.Context, k *keeper.Keeper, params types.Par return nil } - -// ValidateStakingBondDenomWithBankMetadata validates that the required staking bond denom -// is included in the bank metadata and has proper EVM compatibility. -// This function can be called at the app level to ensure proper configuration. -func ValidateStakingBondDenomWithBankMetadata(stakingBondDenom string, bankMetadata []banktypes.Metadata) error { - // Find the bank metadata for the staking bond denom - var bondMetadata *banktypes.Metadata - for _, metadata := range bankMetadata { - if metadata.Base == stakingBondDenom { - bondMetadata = &metadata - break - } - } - - if bondMetadata == nil { - return fmt.Errorf("bank metadata not found for staking bond denom: %s. "+ - "The bank module genesis must include metadata for the staking bond denomination", stakingBondDenom) - } - - // Validate that the metadata can be used to derive valid coin info for EVM compatibility - _, err := types.DeriveCoinInfoFromMetadata(*bondMetadata, stakingBondDenom) - if err != nil { - return fmt.Errorf("invalid bank metadata for staking bond denom %s: %w. "+ - "The staking bond denomination requires proper EVM-compatible metadata", stakingBondDenom, err) - } - - return nil -} diff --git a/x/vm/genesis_test.go b/x/vm/genesis_test.go index 8ddae0824..f994d81bb 100644 --- a/x/vm/genesis_test.go +++ b/x/vm/genesis_test.go @@ -1,195 +1 @@ package vm_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - - "github.com/cosmos/evm/x/vm" - "github.com/cosmos/evm/x/vm/types" -) - -func TestDeriveEvmCoinInfoFromBankMetadata(t *testing.T) { - tests := []struct { - name string - metadata banktypes.Metadata - evmDenom string - expectError bool - expectedInfo types.EvmCoinInfo - }{ - { - name: "valid 18-decimal token", - metadata: banktypes.Metadata{ - Description: "Test token with 18 decimals", - Base: "atest", - Display: "test", - DenomUnits: []*banktypes.DenomUnit{ - {Denom: "atest", Exponent: 0}, - {Denom: "atest", Exponent: 0}, - }, - }, - evmDenom: "atest", - expectError: true, - }, - { - name: "valid 6-decimal token", - metadata: banktypes.Metadata{ - Description: "Test token with 6 decimals", - Base: "utest", - Display: "test", - DenomUnits: []*banktypes.DenomUnit{ - {Denom: "utest", Exponent: 0}, - {Denom: "utest", Exponent: 12}, - }, - }, - evmDenom: "utest", - expectError: false, - expectedInfo: types.EvmCoinInfo{ - DisplayDenom: "test", - Decimals: types.SixDecimals, - ExtendedDecimals: types.EighteenDecimals, - }, - }, - { - name: "invalid - not exactly 2 denom units", - metadata: banktypes.Metadata{ - Description: "Test token with wrong number of units", - Base: "utest", - Display: "test", - DenomUnits: []*banktypes.DenomUnit{ - {Denom: "utest", Exponent: 0}, - }, - }, - evmDenom: "utest", - expectError: true, - }, - { - name: "invalid - mismatched base denom", - metadata: banktypes.Metadata{ - Description: "Test token with mismatched base", - Base: "utest", - Display: "test", - DenomUnits: []*banktypes.DenomUnit{ - {Denom: "utest", Exponent: 0}, - {Denom: "utest", Exponent: 12}, - }, - }, - evmDenom: "mtest", - expectError: true, - }, - { - name: "invalid - display denom mismatch", - metadata: banktypes.Metadata{ - Description: "Test token with display denom mismatch", - Base: "utest", - Display: "test", - DenomUnits: []*banktypes.DenomUnit{ - {Denom: "utest", Exponent: 0}, - {Denom: "uwrong", Exponent: 12}, - }, - }, - evmDenom: "utest", - expectError: true, - }, - { - name: "invalid - invalid SI prefix", - metadata: banktypes.Metadata{ - Description: "Test token with invalid SI prefix", - Base: "xtest", - Display: "test", - DenomUnits: []*banktypes.DenomUnit{ - {Denom: "xtest", Exponent: 0}, - {Denom: "xtest", Exponent: 12}, - }, - }, - evmDenom: "xtest", - expectError: true, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - // Create VM params with the test evm_denom - params := types.Params{ - EvmDenom: tt.evmDenom, - } - - // Create genesis state - genesisState := types.GenesisState{ - Params: params, - } - - // Test ValidateGenesisWithBankMetadata - bankMetadata := []banktypes.Metadata{tt.metadata} - err := types.ValidateGenesisWithBankMetadata(genesisState, bankMetadata) - - if tt.expectError { - require.Error(t, err) - } else { - require.NoError(t, err) - } - }) - } -} - -func TestValidateStakingBondDenomWithBankMetadata(t *testing.T) { - tests := []struct { - name string - stakingBondDenom string - bankMetadata []banktypes.Metadata - expectError bool - }{ - { - name: "valid staking bond denom with 6-decimal", - stakingBondDenom: "ustake", - bankMetadata: []banktypes.Metadata{ - { - Description: "Staking token", - Base: "ustake", - Display: "stake", - DenomUnits: []*banktypes.DenomUnit{ - {Denom: "ustake", Exponent: 0}, - {Denom: "ustake", Exponent: 12}, - }, - }, - }, - expectError: false, - }, - { - name: "invalid - no metadata for staking bond denom", - stakingBondDenom: "ustake", - bankMetadata: []banktypes.Metadata{}, - expectError: true, - }, - { - name: "invalid - invalid metadata structure", - stakingBondDenom: "ustake", - bankMetadata: []banktypes.Metadata{ - { - Description: "Staking token with invalid structure", - Base: "ustake", - Display: "stake", - DenomUnits: []*banktypes.DenomUnit{ - {Denom: "ustake", Exponent: 0}, - {Denom: "mstake", Exponent: 3}, - }, - }, - }, - expectError: true, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := vm.ValidateStakingBondDenomWithBankMetadata(tt.stakingBondDenom, tt.bankMetadata) - - if tt.expectError { - require.Error(t, err) - } else { - require.NoError(t, err) - } - }) - } -} diff --git a/x/vm/module.go b/x/vm/module.go index 9c51ae43a..6c979a633 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, } } @@ -147,7 +151,7 @@ func (am AppModule) EndBlock(ctx context.Context) error { func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - InitGenesis(ctx, am.keeper, am.ak, genesisState) + InitGenesis(ctx, am.keeper, am.ak, am.stakingKeeper, am.bankKeeper, genesisState) return []abci.ValidatorUpdate{} } diff --git a/x/vm/types/coin_info.go b/x/vm/types/coin_info.go index d03b53e23..804f28705 100644 --- a/x/vm/types/coin_info.go +++ b/x/vm/types/coin_info.go @@ -1,78 +1,30 @@ package types -import ( - "errors" - "fmt" - "strings" - - sdk "github.com/cosmos/cosmos-sdk/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 `mapstructure:"display-denom"` + 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 `mapstructure:"decimals"` - // ExtendedDecimals defines the precision/decimals for the extended denomination (typically 18 decimals for atto-denom) - ExtendedDecimals Decimals `mapstructure:"extended-decimals"` -} - -// Validate returns an error if the coin configuration fields are invalid. -func (c EvmCoinInfo) Validate() error { - if err := c.Decimals.Validate(); err != nil { - return fmt.Errorf("decimals validation failed: %w", err) - } - if err := c.ExtendedDecimals.Validate(); err != nil { - return fmt.Errorf("extended decimals validation failed: %w", err) - } - - denom := c.GetDenom() - if strings.HasPrefix(denom, "invalid") { - return errors.New("invalid denom, not a valid SI decimal, so denom cannot be derived") - } - if err := sdk.ValidateDenom(denom); err != nil { - return fmt.Errorf("invalid denom: %w", err) - } - - extendedDenom := c.GetExtendedDenom() - if strings.HasPrefix(extendedDenom, "invalid") { - return errors.New("invalid extended denom, not a valid SI decimal, so extended denom cannot be derived") - } - if err := sdk.ValidateDenom(extendedDenom); err != nil { - return fmt.Errorf("invalid extended denom: %w", err) - } - - if c.DisplayDenom == "" { - return errors.New("display-denom cannot be empty") - } - if err := sdk.ValidateDenom(c.DisplayDenom); err != nil { - return fmt.Errorf("invalid display denom: %w", err) - } - - // For 18 decimals, denom and extended denom should be the same, as higher decimals are not supported - if c.Decimals == EighteenDecimals { - if c.Decimals != c.ExtendedDecimals { - return errors.New("decimals and extended decimals must be the same for 18 decimals") - } - if c.GetDenom() != c.GetExtendedDenom() { - return errors.New("denom and extended denom must be the same for 18 decimals") - } - } - - return nil + Decimals Decimals } // GetDenom returns the base denomination used in the chain, derived by SI prefix func (c EvmCoinInfo) GetDenom() string { - return CreateDenomStr(c.Decimals, c.DisplayDenom) + return c.BaseDenom } -// GetExtendedDenom returns the extended denomination used in the chain, derived by SI prefix func (c EvmCoinInfo) GetExtendedDenom() string { - return CreateDenomStr(c.ExtendedDecimals, c.DisplayDenom) + return c.ExtendedDenom +} + +func (c EvmCoinInfo) GetDecimals() Decimals { + return c.Decimals } -func CreateDenomStr(decimals Decimals, displayDenom string) string { - return decimals.GetSIPrefix() + displayDenom +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 index 03b16d265..08011ab1d 100644 --- a/x/vm/types/coin_info_config.go +++ b/x/vm/types/coin_info_config.go @@ -5,7 +5,6 @@ package types import ( "errors" - "fmt" "sync" "cosmossdk.io/math" @@ -33,7 +32,7 @@ func GetEVMCoinDecimals() Decimals { // GetEVMCoinExtendedDecimals returns the extended decimals used in the // representation of the EVM coin. func GetEVMCoinExtendedDecimals() Decimals { - return evmCoinInfo.ExtendedDecimals + return 18 } // GetEVMCoinDenom returns the denom used for the EVM coin. @@ -52,22 +51,10 @@ func SetEVMCoinInfo(eci EvmCoinInfo) error { return errors.New("EVM coin info already set") } - 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) - } - // prevent any external pointers or references to evmCoinInfoxx evmCoinInfoOnce.Do(func() { setBaseDenom(eci) - evmCoinInfo = new(EvmCoinInfo) - evmCoinInfo.DisplayDenom = eci.DisplayDenom - evmCoinInfo.Decimals = eci.Decimals - evmCoinInfo.ExtendedDecimals = eci.ExtendedDecimals + evmCoinInfo = &eci }) return nil diff --git a/x/vm/types/genesis.go b/x/vm/types/genesis.go index dd5662917..d25022b5e 100644 --- a/x/vm/types/genesis.go +++ b/x/vm/types/genesis.go @@ -5,7 +5,6 @@ import ( "github.com/cosmos/evm/types" - sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -72,110 +71,21 @@ func (gs GenesisState) Validate() error { return gs.Params.Validate() } -// ValidateGenesisWithBankMetadata validates the EVM genesis state against bank metadata -// to ensure proper configuration for EVM coin derivation. This function should be called -// during genesis validation when both bank and EVM module genesis states are available. -func ValidateGenesisWithBankMetadata(evmGenesis GenesisState, bankMetadata []banktypes.Metadata) error { - // Basic validation first - if err := evmGenesis.Validate(); err != nil { - return err - } - - // Get the evm_denom from VM params - evmDenom := evmGenesis.Params.EvmDenom - if evmDenom == "" { - return fmt.Errorf("evm_denom parameter is empty") - } - - // Find the bank metadata for the evm_denom - var evmMetadata *banktypes.Metadata - for _, metadata := range bankMetadata { - if metadata.Base == evmDenom { - evmMetadata = &metadata - break - } - } - - if evmMetadata == nil { - return fmt.Errorf("bank metadata not found for evm_denom: %s. "+ - "The bank module genesis must include metadata for the EVM denomination", evmDenom) - } - - // Validate that the metadata can be used to derive valid coin info - _, err := DeriveCoinInfoFromMetadata(*evmMetadata, evmDenom) - if err != nil { - return fmt.Errorf("invalid bank metadata for evm_denom %s: %w", evmDenom, err) - } - - return nil -} - // DeriveCoinInfoFromMetadata extracts EvmCoinInfo from bank metadata func DeriveCoinInfoFromMetadata(metadata banktypes.Metadata, evmDenom string) (*EvmCoinInfo, error) { - if metadata.Base != evmDenom { - return nil, fmt.Errorf("metadata base denom (%s) does not match evm_denom (%s)", metadata.Base, evmDenom) - } - if len(metadata.DenomUnits) != 2 { - return nil, fmt.Errorf("metadata must have exactly 2 denom units, got: %d", len(metadata.DenomUnits)) - } - - foundBase := false - displayDenom := "" - baseDecimals := Decimals(0) - baseDecimalsInferred := Decimals(0) - extendedDecimals := EighteenDecimals - - for _, unit := range metadata.DenomUnits { - if unit.Denom == metadata.Base && unit.Exponent == 0 { - if sdk.ValidateDenom(unit.Denom) != nil { - return nil, fmt.Errorf("invalid base denom: %s", unit.Denom) - } - displayDenom = unit.Denom[1:] - dec, err := DecimalsFromSIPrefix(unit.Denom[:1]) - if err != nil { - return nil, fmt.Errorf("invalid base denom: %s, %w", unit.Denom, err) - } - baseDecimalsInferred = dec - foundBase = true - continue - } - - if sdk.ValidateDenom(unit.Denom) != nil { - return nil, fmt.Errorf("invalid extended denom: %s", unit.Denom) - } - dd := unit.Denom[1:] - if dd != displayDenom { - return nil, fmt.Errorf("display denom mismatch: %s != %s", dd, displayDenom) - } - decInferred, err := DecimalsFromSIPrefix(unit.Denom[:1]) - if err != nil { - return nil, fmt.Errorf("invalid extended denom: %s, %w", unit.Denom, err) - } - baseDecs := EighteenDecimals - Decimals(unit.Exponent) - if baseDecs != decInferred { - return nil, fmt.Errorf("extended decimals mismatch: %s != %s", extendedDecimals, decInferred) - } - baseDecimals = decInferred - if baseDecimalsInferred != baseDecimals { - return nil, fmt.Errorf("base decimals mismatch: %s != %s", baseDecimalsInferred, baseDecimals) + var baseDecimals uint32 + for _, denomUnit := range metadata.DenomUnits { + if denomUnit.Denom == metadata.Display { + baseDecimals = denomUnit.Exponent } } - if baseDecimals == 0 || extendedDecimals == 0 || displayDenom == "" || !foundBase { - return nil, fmt.Errorf( - "invalid base or extended denom: %s, %s, %s, %t", - baseDecimals, extendedDecimals, displayDenom, foundBase, - ) - } - - coinInfo := &EvmCoinInfo{ - DisplayDenom: displayDenom, - Decimals: baseDecimals, - ExtendedDecimals: extendedDecimals, - } - if err := coinInfo.Validate(); err != nil { - return nil, fmt.Errorf("derived coin info is invalid: %w", err) - } + fmt.Println(evmDenom) - return coinInfo, nil + return &EvmCoinInfo{ + DisplayDenom: metadata.Display, + Decimals: Decimals(baseDecimals), + BaseDenom: metadata.Base, + ExtendedDenom: evmDenom, + }, nil } From 72cdc05d46a1b7fcad531c6218f557d5582df7b4 Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 22 Sep 2025 17:28:49 -0400 Subject: [PATCH 27/27] move all options outside of app.go --- ante/evm/fee_checker_test.go | 4 +- ante/evm/mono_decorator_test.go | 4 +- api/cosmos/evm/vm/v1/evm.pulsar.go | 686 ++++++++---------- config/chain_config.go | 5 +- config/server_app_options.go | 4 +- encoding/config.go | 4 +- ethereum/eip712/preprocess_test.go | 2 +- evmd/app/app.go | 62 +- evmd/app/creator.go | 1 - evmd/app/genesis.go | 5 +- evmd/cmd/root.go | 17 +- evmd/cmd/testnet/testnet.go | 3 +- evmd/tests/integration/create_app.go | 10 +- evmd/tests/network/network.go | 11 +- evmd/testutil/helpers.go | 10 +- local_node.sh | 1 + proto/cosmos/evm/vm/v1/evm.proto | 11 +- rpc/backend/call_tx.go | 8 +- rpc/backend/node_info.go | 3 +- server/config/config.go | 2 +- .../integration/rpc/backend/test_node_info.go | 5 +- .../x/precisebank/test_burn_integration.go | 2 +- tests/integration/x/vm/test_grpc_query.go | 4 +- testutil/config/constants.go | 21 +- x/precisebank/types/genesis_test.go | 4 +- x/vm/genesis.go | 3 - x/vm/keeper/grpc_query.go | 2 - x/vm/keeper/keeper.go | 35 +- x/vm/keeper/params.go | 4 +- x/vm/module.go | 2 +- x/vm/types/chain_config.go | 4 +- x/vm/types/coin_info_config.go | 5 + x/vm/types/config.go | 2 + {config => x/vm/types}/constants.go | 15 +- x/vm/types/evm.pb.go | 373 ++++------ x/vm/types/evm_config_test.go | 12 +- x/vm/types/scaling_test.go | 2 +- x/vm/wrappers/bank_test.go | 12 +- x/vm/wrappers/feemarket_test.go | 6 +- 39 files changed, 584 insertions(+), 782 deletions(-) rename {config => x/vm/types}/constants.go (77%) diff --git a/ante/evm/fee_checker_test.go b/ante/evm/fee_checker_test.go index 1255a07bd..d864d8cb0 100644 --- a/ante/evm/fee_checker_test.go +++ b/ante/evm/fee_checker_test.go @@ -58,9 +58,9 @@ func TestSDKTxFeeChecker(t *testing.T) { // without extension option // london hardfork enableness - err := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, false).Apply() + err := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, false).Apply() require.NoError(t, err) - encodingConfig := encoding.MakeConfig(evmconfig.DefaultEvmChainID) + encodingConfig := encoding.MakeConfig(evmtypes.DefaultEvmChainID) evmDenom := evmtypes.GetEVMCoinDenom() minGasPrices := sdk.NewDecCoins(sdk.NewDecCoin(evmDenom, math.NewInt(10))) diff --git a/ante/evm/mono_decorator_test.go b/ante/evm/mono_decorator_test.go index 72af9771f..e09f9d017 100644 --- a/ante/evm/mono_decorator_test.go +++ b/ante/evm/mono_decorator_test.go @@ -144,9 +144,9 @@ func toMsgSlice(msgs []*evmsdktypes.MsgEthereumTx) []sdk.Msg { } func TestMonoDecorator(t *testing.T) { - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, false) + evmConfig := evmconfig.NewDefaultEvmConfig(evmsdktypes.DefaultEvmChainID, false) require.NoError(t, evmConfig.Apply()) - cfg := encoding.MakeConfig(evmconfig.DefaultEvmChainID) + 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/config/chain_config.go b/config/chain_config.go index ffd107bf1..154951efc 100644 --- a/config/chain_config.go +++ b/config/chain_config.go @@ -9,10 +9,7 @@ func NewDefaultEvmConfig( evmChainID uint64, reset bool, ) *evmtypes.EvmConfig { - chainConfig := evmtypes.DefaultChainConfig( - DefaultEvmChainID, - DefaultEvmCoinInfo, - ) + chainConfig := evmtypes.DefaultChainConfig(evmtypes.DefaultEvmChainID) return evmtypes.NewEvmConfig(). WithChainConfig(chainConfig). WithExtendedEips(eips.CosmosEVMActivators) diff --git a/config/server_app_options.go b/config/server_app_options.go index 3d85bf49f..68dd16933 100644 --- a/config/server_app_options.go +++ b/config/server_app_options.go @@ -145,7 +145,7 @@ func GetEvmChainIDWithDefault( 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", DefaultEvmChainID) + logger.Info("failed to get evm chain id, using default evm chain id", "default_evm_chain_id", evmtypes.DefaultEvmChainID) - return 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 adb050fb0..129d2e738 100644 --- a/ethereum/eip712/preprocess_test.go +++ b/ethereum/eip712/preprocess_test.go @@ -57,7 +57,7 @@ type TestCaseStruct struct { func TestLedgerPreprocessing(t *testing.T) { // Update bech32 prefix sdk.GetConfig().SetBech32PrefixForAccount(sdk.Bech32MainPrefix, "") - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() err := evmConfig.Apply() require.NoError(t, err) diff --git a/evmd/app/app.go b/evmd/app/app.go index 46ad311ad..cecc4b34a 100644 --- a/evmd/app/app.go +++ b/evmd/app/app.go @@ -205,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, - evmConfig *evmtypes.EvmConfig, - baseAppOptions ...func(*baseapp.BaseApp), -) *EVMD { - evmChainID := config.GetEvmChainIDWithDefault(appOpts, evmConfig, logger) - 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, @@ -261,15 +226,6 @@ func NewExampleApp( bApp.SetInterfaceRegistry(interfaceRegistry) bApp.SetTxEncoder(txConfig.TxEncoder()) - // initialize the Cosmos EVM application configuration, if not already initialized - if evmConfig == nil { - evmConfig = config.NewDefaultEvmConfig(evmChainID, false) - } - - if err := evmConfig.Apply(); err != nil { - panic(err) - } - keys := storetypes.NewKVStoreKeys( authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, @@ -476,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, @@ -489,6 +449,7 @@ func NewExampleApp( &app.ConsensusParamsKeeper, &app.Erc20Keeper, tracer, + evmChainID, ) app.Erc20Keeper = erc20keeper.NewKeeper( @@ -756,7 +717,7 @@ func NewExampleApp( // set the EVM priority nonce mempool // If you wish to use the noop mempool, remove this codeblock - if evmConfig != nil { + if evmtypes.GetChainConfig() != nil { // Get the block gas limit from genesis file blockGasLimit := config.GetBlockGasLimit(appOpts, logger) // Get GetMinTip from app.toml or cli flag configuration @@ -896,11 +857,6 @@ func (app *EVMD) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci panic(err) } - //// Perform cross-module genesis validation before initialization - //if err := app.validateCrossModuleGenesis(genesisState); err != nil { - // panic(fmt.Errorf("cross-module genesis validation failed: %w", err)) - //} - if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil { panic(err) } diff --git a/evmd/app/creator.go b/evmd/app/creator.go index 8dc5c0b9a..f75741457 100644 --- a/evmd/app/creator.go +++ b/evmd/app/creator.go @@ -92,7 +92,6 @@ func (a AppCreator) newApp( traceStore, true, simtestutil.EmptyAppOptions{}, - nil, baseappOptions..., ) } diff --git a/evmd/app/genesis.go b/evmd/app/genesis.go index 8aad3dd6b..b56f5899a 100644 --- a/evmd/app/genesis.go +++ b/evmd/app/genesis.go @@ -3,7 +3,6 @@ package app import ( "encoding/json" - "github.com/cosmos/evm/config" testconfig "github.com/cosmos/evm/testutil/config" erc20types "github.com/cosmos/evm/x/erc20/types" feemarkettypes "github.com/cosmos/evm/x/feemarket/types" @@ -40,7 +39,7 @@ func NewEVMGenesisState() *evmtypes.GenesisState { func NewErc20GenesisState() *erc20types.GenesisState { erc20GenState := erc20types.DefaultGenesisState() erc20GenState.TokenPairs = testconfig.ExampleTokenPairs - erc20GenState.NativePrecompiles = []string{config.DefaultWevmosContractMainnet} + 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.DefaultEvmCoinInfo.GetDenom() + mintGenState.Params.MintDenom = evmtypes.DefaultEvmCoinInfo.GetDenom() return mintGenState } diff --git a/evmd/cmd/root.go b/evmd/cmd/root.go index de4480513..fa3ca3427 100644 --- a/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" @@ -64,7 +65,6 @@ func NewRootCmd() *cobra.Command { nil, true, simtestutil.EmptyAppOptions{}, - nil, ) encodingConfig := sdktestutil.TestEncodingConfig{ @@ -130,7 +130,7 @@ func NewRootCmd() *cobra.Command { return err } - customAppTemplate, customAppConfig := evmconfig.InitAppConfig(evmconfig.DefaultEvmCoinInfo.GetDenom(), evmconfig.DefaultEvmChainID) + customAppTemplate, customAppConfig := evmconfig.InitAppConfig(types.DefaultEvmCoinInfo.GetDenom(), types.DefaultEvmChainID) customTMConfig := initCometConfig() return sdkserver.InterceptConfigsPreRunHandler(cmd, customAppTemplate, *customAppConfig, customTMConfig) @@ -141,7 +141,7 @@ func NewRootCmd() *cobra.Command { if initClientCtx.ChainID == "" { // if the chain id is not set in client.toml, populate it with the default evm chain id - initClientCtx = initClientCtx.WithChainID(evmconfig.DefaultChainID) + initClientCtx = initClientCtx.WithChainID(types.DefaultChainID) } initClientCtx, _ = sdkclientcfg.ReadFromClientConfig(initClientCtx) @@ -314,12 +314,7 @@ func newApp( baseapp.SetChainID(chainID), } - return evmdapp.NewExampleApp( - logger, db, traceStore, true, - appOpts, - nil, - baseappOptions..., - ) + return evmdapp.NewExampleApp(logger, db, traceStore, true, appOpts, baseappOptions...) } // appExport creates a new application (optionally at a given height) and exports state. @@ -358,13 +353,13 @@ func appExport( } if height != -1 { - exampleApp = evmdapp.NewExampleApp(logger, db, traceStore, false, appOpts, nil, 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 = evmdapp.NewExampleApp(logger, db, traceStore, true, appOpts, nil, baseapp.SetChainID(chainID)) + exampleApp = evmdapp.NewExampleApp(logger, db, traceStore, true, appOpts, baseapp.SetChainID(chainID)) } return exampleApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs, modulesToExport) diff --git a/evmd/cmd/testnet/testnet.go b/evmd/cmd/testnet/testnet.go index 7f1db41c2..5d6985943 100644 --- a/evmd/cmd/testnet/testnet.go +++ b/evmd/cmd/testnet/testnet.go @@ -4,6 +4,7 @@ import ( "bufio" "encoding/json" "fmt" + types2 "github.com/cosmos/evm/x/vm/types" "net" "os" "path/filepath" @@ -268,7 +269,7 @@ func initTestnetFiles( appConfig.Telemetry.EnableHostnameLabel = false appConfig.Telemetry.GlobalLabels = [][]string{{"chain_id", args.chainID}} evm := cosmosevmserverconfig.DefaultEVMConfig() - evm.EVMChainID = config.DefaultEvmChainID + evm.EVMChainID = types2.DefaultEvmChainID evmCfg := config.EVMAppConfig{ Config: *appConfig, EVM: *evm, diff --git a/evmd/tests/integration/create_app.go b/evmd/tests/integration/create_app.go index 3bf97f94e..4166b1fae 100644 --- a/evmd/tests/integration/create_app.go +++ b/evmd/tests/integration/create_app.go @@ -34,15 +34,7 @@ func CreateEvmd(chainID string, evmChainID uint64, customBaseAppOptions ...func( baseAppOptions := append(customBaseAppOptions, baseapp.SetChainID(chainID)) - return evmdapp.NewExampleApp( - logger, - db, - nil, - loadLatest, - appOptions, - nil, - baseAppOptions..., - ) + return evmdapp.NewExampleApp(logger, db, nil, loadLatest, appOptions, baseAppOptions...) } // SetupEvmd initializes a new evmd app with default genesis state. diff --git a/evmd/tests/network/network.go b/evmd/tests/network/network.go index 197e75c4a..6fcee21a4 100644 --- a/evmd/tests/network/network.go +++ b/evmd/tests/network/network.go @@ -122,7 +122,7 @@ func DefaultConfig() Config { if err := chainConfig.ApplyChainConfig(); err != nil { panic(err) } - tempApp := evmdapp.NewExampleApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simutils.NewAppOptionsWithFlagHome(dir), chainConfig, baseapp.SetChainID(chainID)) + tempApp := evmdapp.NewExampleApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simutils.NewAppOptionsWithFlagHome(dir), baseapp.SetChainID(chainID)) cfg := Config{ Codec: tempApp.AppCodec(), @@ -165,14 +165,7 @@ func NewAppConstructor(chainID string, evmChainID uint64) AppConstructor { if err := chainConfig.ApplyChainConfig(); err != nil { panic(err) } - return evmdapp.NewExampleApp( - val.Ctx.Logger, dbm.NewMemDB(), nil, true, - simutils.NewAppOptionsWithFlagHome(val.Ctx.Config.RootDir), - chainConfig, - baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), - baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), - baseapp.SetChainID(chainID), - ) + 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)) } } diff --git a/evmd/testutil/helpers.go b/evmd/testutil/helpers.go index 50ec2f6b9..c7533a611 100644 --- a/evmd/testutil/helpers.go +++ b/evmd/testutil/helpers.go @@ -56,7 +56,7 @@ func setup(withGenesis bool, invCheckPeriod uint, chainID string, evmChainID uin appOptions[server.FlagInvCheckPeriod] = invCheckPeriod chainConfig := evmconfig.DefaultChainConfig - app := evmdapp.NewExampleApp(log.NewNopLogger(), db, nil, true, appOptions, chainConfig, baseapp.SetChainID(chainID)) + app := evmdapp.NewExampleApp(log.NewNopLogger(), db, nil, true, appOptions, baseapp.SetChainID(chainID)) if withGenesis { return app, app.DefaultGenesis() } @@ -128,13 +128,7 @@ func SetupWithGenesisValSet(t *testing.T, chainID string, evmChainID uint64, val func SetupTestingApp(chainConfig evmconfig.ChainConfig) func() (ibctesting.TestingApp, map[string]json.RawMessage) { return func() (ibctesting.TestingApp, map[string]json.RawMessage) { db := dbm.NewMemDB() - app := evmdapp.NewExampleApp( - log.NewNopLogger(), - db, nil, true, - simtestutil.NewAppOptionsWithFlagHome(evmdapp.DefaultNodeHome), - chainConfig, - baseapp.SetChainID(chainConfig.ChainID), - ) + app := evmdapp.NewExampleApp(log.NewNopLogger(), db, nil, true, simtestutil.NewAppOptionsWithFlagHome(evmdapp.DefaultNodeHome), baseapp.SetChainID(chainConfig.ChainID)) return app, app.DefaultGenesis() } } diff --git a/local_node.sh b/local_node.sh index 1aeddd6a8..a7ffb3de2 100755 --- a/local_node.sh +++ b/local_node.sh @@ -253,6 +253,7 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then 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":"'$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" 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/call_tx.go b/rpc/backend/call_tx.go index 6b7544820..e444cc9b2 100644 --- a/rpc/backend/call_tx.go +++ b/rpc/backend/call_tx.go @@ -42,13 +42,7 @@ func (b *Backend) Resend(args evmtypes.TransactionArgs, gasPrice *hexutil.Big, g // signers to be backwards-compatible with old transactions. cfg := b.ChainConfig() if cfg == nil { - coinInfo := evmtypes.EvmCoinInfo{ - DisplayDenom: evmtypes.GetEVMCoinDisplayDenom(), - Decimals: evmtypes.GetEVMCoinDecimals(), - BaseDenom: evmtypes.GetEVMCoinDenom(), - ExtendedDenom: evmtypes.GetEVMCoinExtendedDenom(), - } - cfg = evmtypes.DefaultChainConfig(b.EvmChainID.Uint64(), coinInfo).EthereumConfig(nil) + cfg = evmtypes.DefaultChainConfig(b.EvmChainID.Uint64()).EthereumConfig(nil) } signer := ethtypes.LatestSigner(cfg) diff --git a/rpc/backend/node_info.go b/rpc/backend/node_info.go index 8e35352bd..2a1d75c0a 100644 --- a/rpc/backend/node_info.go +++ b/rpc/backend/node_info.go @@ -11,7 +11,6 @@ import ( cmttypes "github.com/cometbft/cometbft/types" - evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/crypto/ethsecp256k1" rpctypes "github.com/cosmos/evm/rpc/types" "github.com/cosmos/evm/server/config" @@ -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(evmconfig.DefaultGasPrice) + return big.NewInt(evmtypes.DefaultGasPrice) } return evmtypes.ConvertAmountTo18DecimalsLegacy(amt).TruncateInt().BigInt() diff --git a/server/config/config.go b/server/config/config.go index e5d81e3f1..2cf515c0b 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -66,7 +66,7 @@ const ( DefaultMaxTxGasWanted = 0 // DefaultEVMChainID is the default EVM Chain ID if one is not provided, should match the value in evmd config - DefaultEVMChainID = 262144 + DefaultEVMChainID = evmtypes.DefaultEvmChainID // DefaultEVMMinTip is the default minimum priority fee for the mempool DefaultEVMMinTip = 0 diff --git a/tests/integration/rpc/backend/test_node_info.go b/tests/integration/rpc/backend/test_node_info.go index 590bbe4f5..c81366691 100644 --- a/tests/integration/rpc/backend/test_node_info.go +++ b/tests/integration/rpc/backend/test_node_info.go @@ -11,7 +11,6 @@ import ( cmtrpcclient "github.com/cometbft/cometbft/rpc/client" - evmconfig "github.com/cosmos/evm/config" "github.com/cosmos/evm/crypto/ethsecp256k1" "github.com/cosmos/evm/rpc/backend/mocks" "github.com/cosmos/evm/server/config" @@ -34,13 +33,13 @@ func (s *TestSuite) TestRPCMinGasPrice() { { "pass - default gas price", func() {}, - big.NewInt(evmconfig.DefaultGasPrice), + big.NewInt(evmtypes.DefaultGasPrice), true, }, { "pass - min gas price is 0", func() {}, - big.NewInt(evmconfig.DefaultGasPrice), + big.NewInt(evmtypes.DefaultGasPrice), true, }, } diff --git a/tests/integration/x/precisebank/test_burn_integration.go b/tests/integration/x/precisebank/test_burn_integration.go index 720895a26..0204e5cb8 100644 --- a/tests/integration/x/precisebank/test_burn_integration.go +++ b/tests/integration/x/precisebank/test_burn_integration.go @@ -499,7 +499,7 @@ func (s *KeeperIntegrationTestSuite) TestBurnCoinsRandomValueMultiDecimals() { } func FuzzBurnCoins(f *testing.F) { - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() err := evmConfig.Apply() require.NoError(f, err) diff --git a/tests/integration/x/vm/test_grpc_query.go b/tests/integration/x/vm/test_grpc_query.go index e2f06da71..3fec5c214 100644 --- a/tests/integration/x/vm/test_grpc_query.go +++ b/tests/integration/x/vm/test_grpc_query.go @@ -1604,7 +1604,7 @@ func (s *KeeperTestSuite) TestQueryBaseFee() { chainConfig.CancunTime = &maxInt chainConfig.PragueTime = &maxInt - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true) evmConfig.ResetTestConfig() s.Require().NoError(evmConfig.Apply()) err := types.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) @@ -1656,7 +1656,7 @@ func (s *KeeperTestSuite) TestQueryBaseFee() { s.Require().Error(err) } s.Require().NoError(s.Network.NextBlock()) - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true) evmConfig.ResetTestConfig() err = types.SetEVMCoinInfo(coinInfo) s.Require().NoError(err) diff --git a/testutil/config/constants.go b/testutil/config/constants.go index b31300b5b..9596d0817 100644 --- a/testutil/config/constants.go +++ b/testutil/config/constants.go @@ -1,7 +1,6 @@ package config import ( - evmconfig "github.com/cosmos/evm/config" erc20types "github.com/cosmos/evm/x/erc20/types" evmtypes "github.com/cosmos/evm/x/vm/types" @@ -48,11 +47,11 @@ var ( ExtendedDenom: "atest2", } // ExampleAttoDenom provides an example denom for use in tests - ExampleAttoDenom = evmconfig.DefaultEvmCoinInfo.GetDenom() + 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 = evmconfig.DefaultWevmosContractMainnet + WevmosContractMainnet = evmtypes.DefaultWevmosContractMainnet // WevmosContractTestnet is the WEVMOS contract address for testnet WevmosContractTestnet = "0xcc491f589b45d4a3c679016195b3fb87d7848210" // ExampleEvmAddress1 is the example EVM address @@ -64,13 +63,13 @@ var ( // 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: evmconfig.DefaultEvmCoinInfo, - TestChainID2: evmconfig.DefaultEvmCoinInfo, - TwoDecimalsChainID: TwoDecimalEvmCoinInfo, - SixDecimalsChainID: SixDecimalEvmCoinInfo, - TwelveDecimalsChainID: TwelveDecimalEvmCoinInfo, - EighteenDecimalsChainID: evmconfig.DefaultEvmCoinInfo, - evmconfig.DefaultEvmChainID: evmconfig.DefaultEvmCoinInfo, + TestChainID1: evmtypes.DefaultEvmCoinInfo, + TestChainID2: evmtypes.DefaultEvmCoinInfo, + TwoDecimalsChainID: TwoDecimalEvmCoinInfo, + SixDecimalsChainID: SixDecimalEvmCoinInfo, + TwelveDecimalsChainID: TwelveDecimalEvmCoinInfo, + EighteenDecimalsChainID: evmtypes.DefaultEvmCoinInfo, + evmtypes.DefaultEvmChainID: evmtypes.DefaultEvmCoinInfo, } // TODO: consolidate the ChainID and uint64 maps and update tests accordingly @@ -127,7 +126,7 @@ var ( // ExampleChainCoinInfo provides the coin info for the example chain var ExampleChainCoinInfo = map[ChainID]evmtypes.EvmCoinInfo{ - ExampleChainID: evmconfig.DefaultEvmCoinInfo, + ExampleChainID: evmtypes.DefaultEvmCoinInfo, ExampleTwoDecimalsChainID: TwoDecimalEvmCoinInfo, ExampleSixDecimalsChainID: SixDecimalEvmCoinInfo, ExampleTwelveDecimalsChainID: TwelveDecimalEvmCoinInfo, diff --git a/x/precisebank/types/genesis_test.go b/x/precisebank/types/genesis_test.go index c43fb0645..1d03e3e56 100644 --- a/x/precisebank/types/genesis_test.go +++ b/x/precisebank/types/genesis_test.go @@ -257,7 +257,7 @@ func TestGenesisState_TotalAmountWithRemainder(t *testing.T) { } func FuzzGenesisStateValidate_NonZeroRemainder(f *testing.F) { - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() err := evmtypes.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) require.NoError(f, err) @@ -285,7 +285,7 @@ func FuzzGenesisStateValidate_NonZeroRemainder(f *testing.F) { } func FuzzGenesisStateValidate_ZeroRemainder(f *testing.F) { - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() err := evmtypes.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleSixDecimalsChainID]) require.NoError(f, err) diff --git a/x/vm/genesis.go b/x/vm/genesis.go index b38d596e5..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" @@ -19,8 +18,6 @@ func InitGenesis( ctx sdk.Context, k *keeper.Keeper, accountKeeper types.AccountKeeper, - stakingKeeper types.StakingKeeper, - bankKeeper types.BankKeeper, data types.GenesisState, ) []abci.ValidatorUpdate { err := k.SetParams(ctx, data.Params) 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 9e03132c7..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, @@ -444,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 6c979a633..7adf37850 100644 --- a/x/vm/module.go +++ b/x/vm/module.go @@ -151,7 +151,7 @@ func (am AppModule) EndBlock(ctx context.Context) error { func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - InitGenesis(ctx, am.keeper, am.ak, am.stakingKeeper, am.bankKeeper, genesisState) + InitGenesis(ctx, am.keeper, am.ak, genesisState) return []abci.ValidatorUpdate{} } diff --git a/x/vm/types/chain_config.go b/x/vm/types/chain_config.go index a674675dc..1a16a9c4d 100644 --- a/x/vm/types/chain_config.go +++ b/x/vm/types/chain_config.go @@ -55,7 +55,7 @@ func (cc ChainConfig) EthereumConfig(chainID *big.Int) *gethparams.ChainConfig { } } -func DefaultChainConfig(evmChainID uint64, coinInfo EvmCoinInfo) *ChainConfig { +func DefaultChainConfig(evmChainID uint64) *ChainConfig { homesteadBlock := sdkmath.ZeroInt() daoForkBlock := sdkmath.ZeroInt() eip150Block := sdkmath.ZeroInt() @@ -77,8 +77,6 @@ func DefaultChainConfig(evmChainID uint64, coinInfo EvmCoinInfo) *ChainConfig { cfg := &ChainConfig{ ChainId: evmChainID, - Denom: coinInfo.GetDenom(), - Decimals: uint64(coinInfo.Decimals), HomesteadBlock: &homesteadBlock, DAOForkBlock: &daoForkBlock, DAOForkSupport: true, diff --git a/x/vm/types/coin_info_config.go b/x/vm/types/coin_info_config.go index 08011ab1d..26fde51b3 100644 --- a/x/vm/types/coin_info_config.go +++ b/x/vm/types/coin_info_config.go @@ -60,6 +60,11 @@ func SetEVMCoinInfo(eci EvmCoinInfo) error { 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. diff --git a/x/vm/types/config.go b/x/vm/types/config.go index 2d14768b6..6aea3f571 100644 --- a/x/vm/types/config.go +++ b/x/vm/types/config.go @@ -4,6 +4,7 @@ package types import ( + "fmt" "github.com/ethereum/go-ethereum/core/vm" geth "github.com/ethereum/go-ethereum/params" ) @@ -13,6 +14,7 @@ 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 } diff --git a/config/constants.go b/x/vm/types/constants.go similarity index 77% rename from config/constants.go rename to x/vm/types/constants.go index ffe1992b5..a2c58db2d 100644 --- a/config/constants.go +++ b/x/vm/types/constants.go @@ -1,11 +1,4 @@ -package config - -import ( - serverflags "github.com/cosmos/evm/server/config" - evmtypes "github.com/cosmos/evm/x/vm/types" -) - -const () +package types const ( // DefaultGasPrice is the default gas price used for setting gas-related calculations @@ -13,7 +6,7 @@ const ( // DefaultChainID is the default chain ID DefaultChainID = "cosmos" // DefaultEvmChainID defines the default EVM chain ID - DefaultEvmChainID = serverflags.DefaultEVMChainID + 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 @@ -21,12 +14,12 @@ const ( // DefaultBaseDenom defines the base denom for the default EVM coin info DefaultBaseDenom = "aatom" // DefaultDecimals defines the decimals for the default EVM coin info - DefaultDecimals = evmtypes.EighteenDecimals + DefaultDecimals = EighteenDecimals // DefaultWevmosContractMainnet is the default WEVMOS contract address for mainnet DefaultWevmosContractMainnet = "0xD4949664cD82660AaE99bEdc034a0deA8A0bd517" ) -var DefaultEvmCoinInfo = evmtypes.EvmCoinInfo{ +var DefaultEvmCoinInfo = EvmCoinInfo{ DisplayDenom: DefaultDisplayDenom, Decimals: DefaultDecimals, BaseDenom: DefaultBaseDenom, 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_test.go b/x/vm/types/evm_config_test.go index c394162c6..eb1971271 100644 --- a/x/vm/types/evm_config_test.go +++ b/x/vm/types/evm_config_test.go @@ -12,7 +12,7 @@ import ( ) func TestEvmConfigApply(t *testing.T) { - evmConfigurator := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfigurator := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true) evmConfigurator.ResetTestConfig() err := types.SetEVMCoinInfo(testconfig.ExampleChainCoinInfo[testconfig.ExampleChainID]) require.NoError(t, err) @@ -35,7 +35,7 @@ func TestExtendedEips(t *testing.T) { extendedEIPs := map[int]func(*vm.JumpTable){ 3855: func(_ *vm.JumpTable) {}, } - ec := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true). + ec := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true). WithExtendedEips(extendedEIPs) return ec }, @@ -48,7 +48,7 @@ func TestExtendedEips(t *testing.T) { extendedEIPs := map[int]func(*vm.JumpTable){ 0o000: func(_ *vm.JumpTable) {}, } - ec := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true). + ec := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true). WithExtendedEips(extendedEIPs) return ec }, @@ -85,7 +85,7 @@ func TestExtendedDefaultExtraEips(t *testing.T) { func() *types.EvmConfig { extendedDefaultExtraEIPs := []int64{1000} types.DefaultExtraEIPs = append(types.DefaultExtraEIPs, 1000) - ec := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true). + ec := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec }, @@ -100,7 +100,7 @@ func TestExtendedDefaultExtraEips(t *testing.T) { "success - empty default extra eip", func() *types.EvmConfig { var extendedDefaultExtraEIPs []int64 - ec := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true). + ec := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec }, @@ -114,7 +114,7 @@ func TestExtendedDefaultExtraEips(t *testing.T) { "success - extra default eip added", func() *types.EvmConfig { extendedDefaultExtraEIPs := []int64{1001} - ec := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true). + ec := evmconfig.NewDefaultEvmConfig(types.DefaultEvmChainID, true). WithExtendedDefaultExtraEIPs(extendedDefaultExtraEIPs...) return ec }, diff --git a/x/vm/types/scaling_test.go b/x/vm/types/scaling_test.go index 9d3fc942b..d7db64621 100644 --- a/x/vm/types/scaling_test.go +++ b/x/vm/types/scaling_test.go @@ -76,7 +76,7 @@ func TestConvertEvmCoinFrom18Decimals(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() require.NoError(t, evmConfig.Apply()) require.NoError(t, evmtypes.SetEVMCoinInfo(tc.evmCoinInfo)) diff --git a/x/vm/wrappers/bank_test.go b/x/vm/wrappers/bank_test.go index 7b59805e1..c4d04d0ee 100644 --- a/x/vm/wrappers/bank_test.go +++ b/x/vm/wrappers/bank_test.go @@ -104,7 +104,7 @@ func TestMintAmountToAccount(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() err := evmConfig.Apply() require.NoError(t, err, "failed to apply EvmConfig") @@ -226,7 +226,7 @@ func TestBurnAmountFromAccount(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() err := evmConfig.Apply() require.NoError(t, err, "failed to apply EvmConfig") @@ -388,7 +388,7 @@ func TestSendCoinsFromModuleToAccount(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() err := evmConfig.Apply() require.NoError(t, err, "failed to apply EvmConfig") @@ -550,7 +550,7 @@ func TestSendCoinsFromAccountToModule(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() err := evmConfig.Apply() require.NoError(t, err, "failed to apply EvmConfig") @@ -689,7 +689,7 @@ func TestGetBalance(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() err := evmConfig.Apply() require.NoError(t, err, "failed to apply EvmConfig") @@ -837,7 +837,7 @@ func TestSppendableCoin(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() err := evmConfig.Apply() require.NoError(t, err, "failed to apply EvmConfig") diff --git a/x/vm/wrappers/feemarket_test.go b/x/vm/wrappers/feemarket_test.go index d70a11682..7463b1fca 100644 --- a/x/vm/wrappers/feemarket_test.go +++ b/x/vm/wrappers/feemarket_test.go @@ -91,7 +91,7 @@ func TestGetBaseFee(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() require.NoError(t, evmConfig.Apply(), "failed to apply EvmConfig") err := types.SetEVMCoinInfo(tc.coinInfo) @@ -182,7 +182,7 @@ func TestCalculateBaseFee(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { // Setup EVM evmConfig to have access to the EVM coin info. - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() err := evmConfig.Apply() require.NoError(t, err, "failed to apply EvmConfig") @@ -259,7 +259,7 @@ func TestGetParams(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { // Setup EVM evmConfig to have access to the EVM coin info. - evmConfig := evmconfig.NewDefaultEvmConfig(evmconfig.DefaultEvmChainID, true) + evmConfig := evmconfig.NewDefaultEvmConfig(evmtypes.DefaultEvmChainID, true) evmConfig.ResetTestConfig() err := evmConfig.Apply() require.NoError(t, err, "failed to apply EvmConfig")