99 "path/filepath"
1010 "sort"
1111 "sync"
12+ "time"
1213
1314 autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
1415 reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
@@ -185,7 +186,8 @@ const (
185186 NodeDir = ".pchain"
186187 Bech32Prefix = "push"
187188
188- ChainID = "localchain_9000-1"
189+ ChainID = "localchain_9000-1"
190+ EVMChainID = uint64 (9000 )
189191)
190192
191193var (
@@ -198,6 +200,20 @@ var (
198200 }
199201)
200202
203+ // authKeeperEVMWrapper adapts cosmos-sdk v0.50.x AccountKeeper to satisfy the
204+ // cosmos/evm AccountKeeper interfaces, which require unordered-tx methods not
205+ // present in sdk v0.50. Stubs are safe no-ops because this chain does not
206+ // enable unordered transactions.
207+ type authKeeperEVMWrapper struct {
208+ authkeeper.AccountKeeper
209+ }
210+
211+ func (w authKeeperEVMWrapper ) UnorderedTransactionsEnabled () bool { return false }
212+ func (w authKeeperEVMWrapper ) RemoveExpiredUnorderedNonces (_ sdk.Context ) error { return nil }
213+ func (w authKeeperEVMWrapper ) TryAddUnorderedNonce (_ sdk.Context , _ []byte , _ time.Time ) error {
214+ return nil
215+ }
216+
201217func init () {
202218 // manually update the power reduction based on the base denom unit (10^18 [evm] or 10^6 [cosmos])
203219 sdk .DefaultPowerReduction = math .NewIntFromBigInt (new (big.Int ).Exp (big .NewInt (10 ), big .NewInt (BaseDenomUnit ), nil ))
@@ -345,7 +361,7 @@ func NewChainApp(
345361
346362 // TODO: verify
347363
348- encodingConfig := cosmosevmencoding .MakeConfig ()
364+ encodingConfig := cosmosevmencoding .MakeConfig (EVMChainID )
349365 interfaceRegistry := encodingConfig .InterfaceRegistry
350366 appCodec := encodingConfig .Codec
351367 legacyAmino := encodingConfig .Amino
@@ -686,11 +702,13 @@ func NewChainApp(
686702 appCodec ,
687703 keys [evmtypes .StoreKey ],
688704 tkeys [evmtypes .TransientKey ],
705+ keys ,
689706 authtypes .NewModuleAddress (govtypes .ModuleName ),
690- app .AccountKeeper ,
707+ authKeeperEVMWrapper { app .AccountKeeper } ,
691708 app .BankKeeper ,
692709 app .StakingKeeper ,
693710 app .FeeMarketKeeper ,
711+ app .ConsensusParamsKeeper ,
694712 & app .Erc20Keeper ,
695713 tracer ,
696714 )
@@ -776,6 +794,7 @@ func NewChainApp(
776794 app .GovKeeper ,
777795 app .SlashingKeeper ,
778796 app .EvidenceKeeper ,
797+ appCodec ,
779798 )
780799
781800 // Add the usigverifier precompile for Ed25519 verification (old address: 0xCA)
@@ -1027,7 +1046,7 @@ func NewChainApp(
10271046 packetforward .NewAppModule (app .PacketForwardKeeper , app .GetSubspace (packetforwardtypes .ModuleName )),
10281047 wasmlc .NewAppModule (app .WasmClientKeeper ),
10291048 ratelimit .NewAppModule (appCodec , app .RatelimitKeeper ),
1030- vm .NewAppModule (app .EVMKeeper , app .AccountKeeper ),
1049+ vm .NewAppModule (app .EVMKeeper , authKeeperEVMWrapper { app .AccountKeeper }, app . AccountKeeper . AddressCodec () ),
10311050 feemarket .NewAppModule (app .FeeMarketKeeper ),
10321051 erc20 .NewAppModule (app .Erc20Keeper , app .AccountKeeper ),
10331052 uexecutor .NewAppModule (appCodec , app .UexecutorKeeper , app .EVMKeeper , app .FeeMarketKeeper , app .BankKeeper , app .AccountKeeper , app .UregistryKeeper , app .UvalidatorKeeper ),
@@ -1437,7 +1456,7 @@ func (a *ChainApp) DefaultGenesis() map[string]json.RawMessage {
14371456 // which is the base denomination of the chain (i.e. the WTOKEN contract)
14381457 erc20GenState := erc20types .DefaultGenesisState ()
14391458 erc20GenState .TokenPairs = ExampleTokenPairs
1440- erc20GenState .Params . NativePrecompiles = append (erc20GenState . Params .NativePrecompiles , WTokenContractMainnet )
1459+ erc20GenState .NativePrecompiles = append (erc20GenState .NativePrecompiles , WTokenContractMainnet )
14411460 genesis [erc20types .ModuleName ] = a .appCodec .MustMarshalJSON (erc20GenState )
14421461
14431462 return genesis
@@ -1560,7 +1579,7 @@ func BlockedAddresses() map[string]bool {
15601579 }
15611580
15621581 for _ , precompile := range blockedPrecompilesHex {
1563- blockedAddrs [cosmosevmutils .EthHexToCosmosAddr (precompile ). String ( )] = true
1582+ blockedAddrs [cosmosevmutils .Bech32StringFromHexAddress (precompile )] = true
15641583 }
15651584
15661585 return blockedAddrs
0 commit comments