-
Notifications
You must be signed in to change notification settings - Fork 94
refactor!: consolidate and clean up chain config #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
cda76f9
bcd494d
517d783
30cf3c6
f7183ee
fddffea
95b6b98
9ae30ee
89cacfd
d3dfc7f
21b5766
7c83c76
0ce0239
9dda87b
f74b4c1
5132d13
f122ab4
3ed2826
8dde9ed
29721f5
68f0ebd
5a5968f
9fb550c
ef8a61d
539c455
4a88554
f79e5fb
267a398
c03643f
bc9acbc
b81a780
444cacd
430deb7
e98bd4a
39cbb96
e2bc65d
e85f0f0
1fda943
608c530
2e7e401
3df3bd0
c2aaef8
8d10e73
43e86fd
05fa144
cc8ccac
676ef59
e7d1d28
9c85141
d4c5dd1
c1b1f6f
3a6d73c
8319f7b
6df3721
e391692
f885ee4
92674b9
a542c04
d1986fc
0f321c3
693beb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,7 @@ import ( | |
"github.com/cosmos/evm/ante/evm" | ||
anteinterfaces "github.com/cosmos/evm/ante/interfaces" | ||
"github.com/cosmos/evm/encoding" | ||
"github.com/cosmos/evm/testutil/config" | ||
testconstants "github.com/cosmos/evm/testutil/constants" | ||
testconfig "github.com/cosmos/evm/testutil/config" | ||
"github.com/cosmos/evm/types" | ||
feemarkettypes "github.com/cosmos/evm/x/feemarket/types" | ||
evmtypes "github.com/cosmos/evm/x/vm/types" | ||
|
@@ -57,9 +56,15 @@ func TestSDKTxFeeChecker(t *testing.T) { | |
// with extension option | ||
// without extension option | ||
// london hardfork enableness | ||
chainID := uint64(config.EighteenDecimalsChainID) | ||
chainConfig := testconfig.DefaultChainConfig | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto (#436 (comment)) |
||
chainID := chainConfig.EvmConfig.ChainConfig.EthereumConfig().ChainID | ||
chainDenomAtto := chainConfig.EvmConfig.CoinInfo.GetDenom() | ||
encodingConfig := encoding.MakeConfig(chainID) | ||
err := config.EvmAppOptions(chainID) | ||
|
||
// Configure EVM with test configuration | ||
configurator := typesutil.NewEVMConfigurator() | ||
configurator.ResetTestConfig() | ||
err := configurator.WithEVMCoinInfo(chainConfig.EvmConfig).Configure() | ||
require.NoError(t, err) | ||
|
||
evmDenom := evmtypes.GetEVMCoinDenom() | ||
|
@@ -110,7 +115,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(chainDenomAtto, math.NewInt(10)))) | ||
return txBuilder.GetTx() | ||
}, | ||
false, | ||
|
@@ -155,7 +160,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(chainDenomAtto, math.NewInt(10)))) | ||
return txBuilder.GetTx() | ||
}, | ||
true, | ||
|
@@ -172,7 +177,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(chainDenomAtto, math.NewInt(10).Mul(evmtypes.DefaultPriorityReduction).Add(math.NewInt(10))))) | ||
return txBuilder.GetTx() | ||
}, | ||
true, | ||
|
@@ -189,7 +194,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(chainDenomAtto, math.NewInt(10).Mul(evmtypes.DefaultPriorityReduction)))) | ||
|
||
option, err := codectypes.NewAnyWithValue(&types.ExtensionOptionDynamicFeeTx{}) | ||
require.NoError(t, err) | ||
|
@@ -210,7 +215,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(chainDenomAtto, math.NewInt(10).Mul(evmtypes.DefaultPriorityReduction).Add(math.NewInt(10))))) | ||
|
||
option, err := codectypes.NewAnyWithValue(&types.ExtensionOptionDynamicFeeTx{ | ||
MaxPriorityPrice: math.LegacyNewDec(5).MulInt(evmtypes.DefaultPriorityReduction), | ||
|
@@ -233,7 +238,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(chainDenomAtto, math.NewInt(10).Mul(evmtypes.DefaultPriorityReduction).Add(math.NewInt(10))))) | ||
|
||
// set negative priority fee | ||
option, err := codectypes.NewAnyWithValue(&types.ExtensionOptionDynamicFeeTx{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ import ( | |
"github.com/cosmos/evm/ante/evm" | ||
"github.com/cosmos/evm/crypto/ethsecp256k1" | ||
"github.com/cosmos/evm/encoding" | ||
"github.com/cosmos/evm/testutil/config" | ||
testconfig "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" | ||
|
@@ -119,7 +119,9 @@ func signMsgEthereumTx(t *testing.T, privKey *ethsecp256k1.PrivKey, args *evmsdk | |
msg := evmsdktypes.NewTx(args) | ||
fromAddr := common.BytesToAddress(privKey.PubKey().Address().Bytes()) | ||
msg.From = fromAddr.Bytes() | ||
ethSigner := ethtypes.LatestSignerForChainID(evmsdktypes.GetEthChainConfig().ChainID) | ||
// Use the configured chain ID instead of the default one | ||
chainID := new(big.Int).SetUint64(testconfig.DefaultChainConfig.EvmConfig.ChainConfig.ChainId) | ||
ethSigner := ethtypes.LatestSignerForChainID(chainID) | ||
require.NoError(t, msg.Sign(ethSigner, utiltx.NewSigner(privKey))) | ||
return msg | ||
} | ||
|
@@ -144,8 +146,9 @@ func toMsgSlice(msgs []*evmsdktypes.MsgEthereumTx) []sdk.Msg { | |
} | ||
|
||
func TestMonoDecorator(t *testing.T) { | ||
chainID := uint64(config.EighteenDecimalsChainID) | ||
require.NoError(t, config.EvmAppOptions(chainID)) | ||
chainConfig := testconfig.DefaultChainConfig | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [suggestion] I think we could commonize default setup code (L149-L156) in testutil/somewhere dir. |
||
chainID := chainConfig.EvmConfig.ChainConfig.ChainId | ||
|
||
cfg := encoding.MakeConfig(chainID) | ||
|
||
testCases := []struct { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package cmd | |
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io" | ||
"path/filepath" | ||
|
||
|
@@ -10,7 +11,6 @@ import ( | |
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/cosmos/cosmos-sdk/server" | ||
servertypes "github.com/cosmos/cosmos-sdk/server/types" | ||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" | ||
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" | ||
"github.com/cosmos/evm/evmd" | ||
evmdconfig "github.com/cosmos/evm/evmd/cmd/evmd/config" | ||
|
@@ -88,14 +88,20 @@ func (a appCreator) newApp( | |
baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))), | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is comment about These functions are not used. The two set of functions are functionally identical. I think we can remove this file entirely. |
||
// Load chain configuration from app options | ||
chainConfig, err := evmdconfig.LoadChainConfig(appOpts) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to load chain configuration: %w", err)) | ||
} | ||
|
||
return evmd.NewExampleApp( | ||
logger, | ||
db, | ||
traceStore, | ||
true, | ||
simtestutil.EmptyAppOptions{}, | ||
evmdconfig.EVMChainID, | ||
evmdconfig.EvmAppOptions, | ||
appOpts, | ||
chainConfig.ChainInfo.EVMChainID, | ||
evmdconfig.EvmAppOptionsFromConfig(chainConfig), | ||
baseappOptions..., | ||
) | ||
} | ||
|
@@ -131,14 +137,20 @@ func (a appCreator) appExport( | |
loadLatest = true | ||
} | ||
|
||
// Load chain configuration from app options | ||
chainConfig, err := evmdconfig.LoadChainConfig(appOpts) | ||
if err != nil { | ||
return servertypes.ExportedApp{}, fmt.Errorf("failed to load chain configuration: %w", err) | ||
} | ||
|
||
evmApp = evmd.NewExampleApp( | ||
logger, | ||
db, | ||
traceStore, | ||
loadLatest, | ||
appOpts, | ||
evmdconfig.EVMChainID, | ||
evmdconfig.EvmAppOptions, | ||
chainConfig.ChainInfo.EVMChainID, | ||
evmdconfig.EvmAppOptionsFromConfig(chainConfig), | ||
) | ||
|
||
if height != -1 { | ||
|
Uh oh!
There was an error while loading. Please reload this page.