@@ -24,7 +24,6 @@ import (
24
24
tmjson "github.com/cometbft/cometbft/libs/json"
25
25
"github.com/cometbft/cometbft/libs/log"
26
26
tmos "github.com/cometbft/cometbft/libs/os"
27
- tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
28
27
"github.com/cosmos/cosmos-sdk/client"
29
28
"github.com/cosmos/cosmos-sdk/codec/types"
30
29
"github.com/gorilla/mux"
@@ -328,6 +327,7 @@ type App struct {
328
327
interfaceRegistry types.InterfaceRegistry
329
328
330
329
invCheckPeriod uint
330
+ blockedMap map [string ]struct {}
331
331
332
332
// keys to access the substores
333
333
keys map [string ]* storetypes.KVStoreKey
@@ -385,8 +385,6 @@ type App struct {
385
385
configurator module.Configurator
386
386
387
387
qms storetypes.MultiStore
388
-
389
- blockProposalHandler * ProposalHandler
390
388
}
391
389
392
390
// New returns a reference to an initialized chain.
@@ -396,7 +394,7 @@ func New(
396
394
homePath string , invCheckPeriod uint , encodingConfig ethermint.EncodingConfig ,
397
395
// this line is used by starport scaffolding # stargate/app/newArgument
398
396
appOpts servertypes.AppOptions , baseAppOptions ... func (* baseapp.BaseApp ),
399
- ) * App {
397
+ ) ( app * App ) {
400
398
appCodec := encodingConfig .Codec
401
399
cdc := encodingConfig .Amino
402
400
interfaceRegistry := encodingConfig .InterfaceRegistry
@@ -423,34 +421,41 @@ func New(
423
421
424
422
baseAppOptions = memiavlstore .SetupMemIAVL (logger , homePath , appOpts , false , false , baseAppOptions )
425
423
426
- blockProposalHandler := NewProposalHandler (encodingConfig .TxConfig .TxDecoder (), identity )
424
+ keys , memKeys , tkeys := StoreKeys (skipGravity )
425
+ cronosKey := keys [cronostypes .StoreKey ]
427
426
427
+ txConfig := encodingConfig .TxConfig
428
+ maxTxGasWanted := cast .ToUint64 (appOpts .Get (srvflags .EVMMaxTxGasWanted ))
428
429
// NOTE we use custom transaction decoder that supports the sdk.Tx interface instead of sdk.StdTx
429
430
// Setup Mempool and Proposal Handlers
430
- baseAppOptions = append (baseAppOptions , func (app * baseapp.BaseApp ) {
431
+ baseAppOptions = append (baseAppOptions , func (bapp * baseapp.BaseApp ) {
431
432
mempool := mempool.NoOpMempool {}
432
- app .SetMempool (mempool )
433
- app .SetPrepareProposal (blockProposalHandler .PrepareProposalHandler ())
434
- app .SetProcessProposal (blockProposalHandler .ProcessProposalHandler ())
433
+ bapp .SetMempool (mempool )
434
+ blockProposalHandler := NewProposalHandler (
435
+ appCodec ,
436
+ cronosKey ,
437
+ txConfig .TxDecoder (),
438
+ identity ,
439
+ func (blacklist []string ) { app .setAnteHandler (txConfig , maxTxGasWanted , blacklist ) },
440
+ )
441
+ bapp .SetPrepareProposal (blockProposalHandler .PrepareProposalHandler ())
442
+ bapp .SetProcessProposal (blockProposalHandler .ProcessProposalHandler ())
435
443
})
436
444
bApp := baseapp .NewBaseApp (Name , logger , db , encodingConfig .TxConfig .TxDecoder (), baseAppOptions ... )
437
445
438
446
bApp .SetCommitMultiStoreTracer (traceStore )
439
447
bApp .SetVersion (version .Version )
440
448
bApp .SetInterfaceRegistry (interfaceRegistry )
441
449
442
- keys , memKeys , tkeys := StoreKeys (skipGravity )
443
-
444
- app := & App {
445
- BaseApp : bApp ,
446
- cdc : cdc ,
447
- appCodec : appCodec ,
448
- interfaceRegistry : interfaceRegistry ,
449
- invCheckPeriod : invCheckPeriod ,
450
- keys : keys ,
451
- tkeys : tkeys ,
452
- memKeys : memKeys ,
453
- blockProposalHandler : blockProposalHandler ,
450
+ app = & App {
451
+ BaseApp : bApp ,
452
+ cdc : cdc ,
453
+ appCodec : appCodec ,
454
+ interfaceRegistry : interfaceRegistry ,
455
+ invCheckPeriod : invCheckPeriod ,
456
+ keys : keys ,
457
+ tkeys : tkeys ,
458
+ memKeys : memKeys ,
454
459
}
455
460
456
461
// init params keeper and subspaces
@@ -606,7 +611,7 @@ func New(
606
611
607
612
app .CronosKeeper = * cronoskeeper .NewKeeper (
608
613
appCodec ,
609
- keys [ cronostypes . StoreKey ] ,
614
+ cronosKey ,
610
615
keys [cronostypes .MemStoreKey ],
611
616
app .BankKeeper ,
612
617
app .TransferKeeper ,
@@ -955,10 +960,6 @@ func New(
955
960
tmos .Exit (fmt .Sprintf ("versiondb version %d lag behind iavl version %d" , v1 , v2 ))
956
961
}
957
962
}
958
-
959
- if err := app .RefreshBlockList (app .NewUncachedContext (false , tmproto.Header {})); err != nil {
960
- panic (err )
961
- }
962
963
}
963
964
964
965
app .ScopedIBCKeeper = scopedIBCKeeper
@@ -970,8 +971,11 @@ func New(
970
971
return app
971
972
}
972
973
973
- // use Ethermint's custom AnteHandler
974
- func (app * App ) setAnteHandler (txConfig client.TxConfig , maxGasWanted uint64 , blacklist []string ) error {
974
+ func (app * App ) getBlockedMap () map [string ]struct {} {
975
+ return app .blockedMap
976
+ }
977
+
978
+ func (app * App ) setBlacklist (blacklist []string ) error {
975
979
if len (blacklist ) > 0 {
976
980
sort .Strings (blacklist )
977
981
// hash blacklist concatenated
@@ -991,14 +995,16 @@ func (app *App) setAnteHandler(txConfig client.TxConfig, maxGasWanted uint64, bl
991
995
}
992
996
blockedMap := make (map [string ]struct {}, len (blacklist ))
993
997
for _ , str := range blacklist {
994
- addr , err := sdk .AccAddressFromBech32 (str )
995
- if err != nil {
996
- return fmt .Errorf ("invalid bech32 address: %s, err: %w" , str , err )
997
- }
998
-
999
- blockedMap [string (addr )] = struct {}{}
998
+ blockedMap [str ] = struct {}{}
1000
999
}
1001
- blockAddressDecorator := NewBlockAddressesDecorator (blockedMap )
1000
+ app .blockedMap = blockedMap
1001
+ return nil
1002
+ }
1003
+
1004
+ // use Ethermint's custom AnteHandler
1005
+ func (app * App ) setAnteHandler (txConfig client.TxConfig , maxGasWanted uint64 , blacklist []string ) error {
1006
+ app .setBlacklist (blacklist )
1007
+ blockAddressDecorator := NewBlockAddressesDecorator (app .getBlockedMap )
1002
1008
options := evmante.HandlerOptions {
1003
1009
AccountKeeper : app .AccountKeeper ,
1004
1010
BankKeeper : app .BankKeeper ,
@@ -1053,22 +1059,7 @@ func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.R
1053
1059
1054
1060
// EndBlocker application updates every end block
1055
1061
func (app * App ) EndBlocker (ctx sdk.Context , req abci.RequestEndBlock ) abci.ResponseEndBlock {
1056
- rsp := app .mm .EndBlock (ctx , req )
1057
-
1058
- if err := app .RefreshBlockList (ctx ); err != nil {
1059
- app .Logger ().Error ("failed to update blocklist" , "error" , err )
1060
- }
1061
-
1062
- return rsp
1063
- }
1064
-
1065
- func (app * App ) RefreshBlockList (ctx sdk.Context ) error {
1066
- if app .blockProposalHandler .Identity == nil {
1067
- return nil
1068
- }
1069
-
1070
- // refresh blocklist
1071
- return app .blockProposalHandler .SetBlockList (app .CronosKeeper .GetBlockList (ctx ))
1062
+ return app .mm .EndBlock (ctx , req )
1072
1063
}
1073
1064
1074
1065
// InitChainer application update at chain initialization
0 commit comments