-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
1,725 additions
and
1,245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
package app | ||
|
||
import ( | ||
"cosmossdk.io/math" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/mempool" | ||
cosmosante "github.com/cosmos/cosmos-sdk/x/auth/ante" | ||
|
||
opchildlanes "github.com/initia-labs/OPinit/x/opchild/lanes" | ||
initialanes "github.com/initia-labs/initia/app/lanes" | ||
|
||
blockabci "github.com/skip-mev/block-sdk/v2/abci" | ||
blockchecktx "github.com/skip-mev/block-sdk/v2/abci/checktx" | ||
signer_extraction "github.com/skip-mev/block-sdk/v2/adapters/signer_extraction_adapter" | ||
"github.com/skip-mev/block-sdk/v2/block" | ||
blockbase "github.com/skip-mev/block-sdk/v2/block/base" | ||
mevlane "github.com/skip-mev/block-sdk/v2/lanes/mev" | ||
|
||
appante "github.com/initia-labs/minievm/app/ante" | ||
) | ||
|
||
func setupBlockSDK( | ||
app *MinitiaApp, | ||
mempoolMaxTxs int, | ||
) ( | ||
mempool.Mempool, | ||
sdk.AnteHandler, | ||
blockchecktx.CheckTx, | ||
sdk.PrepareProposalHandler, | ||
sdk.ProcessProposalHandler, | ||
error, | ||
) { | ||
|
||
// initialize and set the InitiaApp mempool. The current mempool will be the | ||
// x/auction module's mempool which will extract the top bid from the current block's auction | ||
// and insert the txs at the top of the block spots. | ||
signerExtractor := signer_extraction.NewDefaultAdapter() | ||
|
||
systemLane := initialanes.NewSystemLane(blockbase.LaneConfig{ | ||
Logger: app.Logger(), | ||
TxEncoder: app.txConfig.TxEncoder(), | ||
TxDecoder: app.txConfig.TxDecoder(), | ||
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.01"), | ||
MaxTxs: 1, | ||
SignerExtractor: signerExtractor, | ||
}, opchildlanes.SystemLaneMatchHandler()) | ||
|
||
factory := mevlane.NewDefaultAuctionFactory(app.txConfig.TxDecoder(), signerExtractor) | ||
mevLane := mevlane.NewMEVLane(blockbase.LaneConfig{ | ||
Logger: app.Logger(), | ||
TxEncoder: app.txConfig.TxEncoder(), | ||
TxDecoder: app.txConfig.TxDecoder(), | ||
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.09"), | ||
MaxTxs: 100, | ||
SignerExtractor: signerExtractor, | ||
}, factory, factory.MatchHandler()) | ||
|
||
freeLane := initialanes.NewFreeLane(blockbase.LaneConfig{ | ||
Logger: app.Logger(), | ||
TxEncoder: app.txConfig.TxEncoder(), | ||
TxDecoder: app.txConfig.TxDecoder(), | ||
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.1"), | ||
MaxTxs: 100, | ||
SignerExtractor: signerExtractor, | ||
}, opchildlanes.NewFreeLaneMatchHandler(app.ac, app.OPChildKeeper).MatchHandler()) | ||
|
||
defaultLane := initialanes.NewDefaultLane(blockbase.LaneConfig{ | ||
Logger: app.Logger(), | ||
TxEncoder: app.txConfig.TxEncoder(), | ||
TxDecoder: app.txConfig.TxDecoder(), | ||
MaxBlockSpace: math.LegacyMustNewDecFromStr("0.8"), | ||
MaxTxs: mempoolMaxTxs, | ||
SignerExtractor: signerExtractor, | ||
}) | ||
|
||
lanes := []block.Lane{systemLane, mevLane, freeLane, defaultLane} | ||
mempool, err := block.NewLanedMempool(app.Logger(), lanes) | ||
if err != nil { | ||
return nil, nil, nil, nil, nil, err | ||
} | ||
|
||
anteHandler, err := appante.NewAnteHandler( | ||
appante.HandlerOptions{ | ||
HandlerOptions: cosmosante.HandlerOptions{ | ||
AccountKeeper: app.AccountKeeper, | ||
BankKeeper: app.BankKeeper, | ||
FeegrantKeeper: app.FeeGrantKeeper, | ||
SignModeHandler: app.txConfig.SignModeHandler(), | ||
}, | ||
IBCkeeper: app.IBCKeeper, | ||
Codec: app.appCodec, | ||
OPChildKeeper: app.OPChildKeeper, | ||
TxEncoder: app.txConfig.TxEncoder(), | ||
AuctionKeeper: *app.AuctionKeeper, | ||
MevLane: mevLane, | ||
FreeLane: freeLane, | ||
EVMKeeper: app.EVMKeeper, | ||
}, | ||
) | ||
if err != nil { | ||
return nil, nil, nil, nil, nil, err | ||
} | ||
|
||
// set ante handler to lanes | ||
opt := []blockbase.LaneOption{ | ||
blockbase.WithAnteHandler(anteHandler), | ||
} | ||
systemLane.(*blockbase.BaseLane).WithOptions( | ||
opt..., | ||
) | ||
mevLane.WithOptions( | ||
opt..., | ||
) | ||
freeLane.(*blockbase.BaseLane).WithOptions( | ||
opt..., | ||
) | ||
defaultLane.(*blockbase.BaseLane).WithOptions( | ||
opt..., | ||
) | ||
|
||
mevCheckTx := blockchecktx.NewMEVCheckTxHandler( | ||
app.BaseApp, | ||
app.txConfig.TxDecoder(), | ||
mevLane, | ||
anteHandler, | ||
app.BaseApp.CheckTx, | ||
) | ||
checkTxHandler := blockchecktx.NewMempoolParityCheckTx( | ||
app.Logger(), mempool, | ||
app.txConfig.TxDecoder(), mevCheckTx.CheckTx(), | ||
) | ||
checkTx := checkTxHandler.CheckTx() | ||
|
||
proposalHandler := blockabci.NewProposalHandler( | ||
app.Logger(), | ||
app.txConfig.TxDecoder(), | ||
app.txConfig.TxEncoder(), | ||
mempool, | ||
) | ||
|
||
prepareProposalHandler := proposalHandler.PrepareProposalHandler() | ||
processProposalHandler := proposalHandler.ProcessProposalHandler() | ||
|
||
return mempool, anteHandler, checkTx, prepareProposalHandler, processProposalHandler, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package app | ||
|
||
// Executor change plans | ||
|
||
func (app *MinitiaApp) RegisterExecutorChangePlans() error { | ||
// err := app.OPChildKeeper.RegisterExecutorChangePlan( | ||
// 1, | ||
// 361, | ||
// "initvaloper158x0dpu5f4x703fhtseg5kpytsj02hw04qyw0t", | ||
// "init158x0dpu5f4x703fhtseg5kpytsj02hw0p9ahpm", | ||
// "op2", | ||
// "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"GTJEksmVK7gkzPXdj+YIJxipfJ+yYUlc6jzIuh9s2t0=\"}", | ||
// "testestestestsetsetestsetest", | ||
// ) | ||
|
||
// if err != nil { | ||
// return err | ||
// } | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package app | ||
|
||
import ( | ||
storetypes "cosmossdk.io/store/types" | ||
|
||
dbm "github.com/cosmos/cosmos-db" | ||
servertypes "github.com/cosmos/cosmos-sdk/server/types" | ||
|
||
// ibc imports | ||
|
||
// initia imports | ||
|
||
// OPinit imports | ||
|
||
// skip imports | ||
|
||
// local imports | ||
|
||
evmindexer "github.com/initia-labs/minievm/indexer" | ||
|
||
// noble forwarding keeper | ||
|
||
// kvindexer | ||
kvindexer "github.com/initia-labs/kvindexer" | ||
kvindexerconfig "github.com/initia-labs/kvindexer/config" | ||
blocksubmodule "github.com/initia-labs/kvindexer/submodules/block" | ||
"github.com/initia-labs/kvindexer/submodules/pair" | ||
tx "github.com/initia-labs/kvindexer/submodules/tx" | ||
kvindexermodule "github.com/initia-labs/kvindexer/x/kvindexer" | ||
kvindexerkeeper "github.com/initia-labs/kvindexer/x/kvindexer/keeper" | ||
) | ||
|
||
func setupIndexer( | ||
app *MinitiaApp, | ||
appOpts servertypes.AppOptions, | ||
indexerDB, kvindexerDB dbm.DB, | ||
) (evmindexer.EVMIndexer, *kvindexerkeeper.Keeper, *kvindexermodule.AppModuleBasic, *storetypes.StreamingManager, error) { | ||
// setup evm indexer | ||
evmIndexer, err := evmindexer.NewEVMIndexer(indexerDB, app.appCodec, app.Logger(), app.txConfig, app.EVMKeeper, app.OPChildKeeper) | ||
if err != nil { | ||
return nil, nil, nil, nil, err | ||
} | ||
|
||
// initialize the indexer keeper | ||
kvindexerConfig, err := kvindexerconfig.NewConfig(appOpts) | ||
if err != nil { | ||
return nil, nil, nil, nil, err | ||
} | ||
kvIndexerKeeper := kvindexerkeeper.NewKeeper( | ||
app.appCodec, | ||
"evm", | ||
kvindexerDB, | ||
kvindexerConfig, | ||
app.ac, | ||
app.vc, | ||
) | ||
|
||
smBlock, err := blocksubmodule.NewBlockSubmodule(app.appCodec, kvIndexerKeeper, app.OPChildKeeper) | ||
if err != nil { | ||
return nil, nil, nil, nil, err | ||
} | ||
smTx, err := tx.NewTxSubmodule(app.appCodec, kvIndexerKeeper) | ||
if err != nil { | ||
return nil, nil, nil, nil, err | ||
} | ||
smPair, err := pair.NewPairSubmodule(app.appCodec, kvIndexerKeeper, app.IBCKeeper.ChannelKeeper, app.TransferKeeper) | ||
if err != nil { | ||
return nil, nil, nil, nil, err | ||
} | ||
err = kvIndexerKeeper.RegisterSubmodules(smBlock, smTx, smPair) | ||
if err != nil { | ||
return nil, nil, nil, nil, err | ||
} | ||
|
||
// Add your implementation here | ||
|
||
kvIndexer, err := kvindexer.NewIndexer(app.GetBaseApp().Logger(), kvIndexerKeeper) | ||
if err != nil { | ||
return nil, nil, nil, nil, err | ||
} | ||
|
||
listeners := []storetypes.ABCIListener{evmIndexer} | ||
|
||
var kvIndexerModule *kvindexermodule.AppModuleBasic | ||
if kvIndexer != nil { | ||
if err = kvIndexer.Validate(); err != nil { | ||
return nil, nil, nil, nil, err | ||
} | ||
|
||
if err = kvIndexer.Prepare(nil); err != nil { | ||
return nil, nil, nil, nil, err | ||
} | ||
|
||
if err = kvIndexerKeeper.Seal(); err != nil { | ||
return nil, nil, nil, nil, err | ||
} | ||
|
||
if err = kvIndexer.Start(nil); err != nil { | ||
return nil, nil, nil, nil, err | ||
} | ||
|
||
listeners = append(listeners, kvIndexer) | ||
|
||
// set kvindexer module | ||
m := kvindexermodule.NewAppModuleBasic(kvIndexerKeeper) | ||
kvIndexerModule = &m | ||
} | ||
|
||
streamingManager := storetypes.StreamingManager{ | ||
ABCIListeners: listeners, | ||
StopNodeOnErr: true, | ||
} | ||
|
||
return evmIndexer, kvIndexerKeeper, kvIndexerModule, &streamingManager, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.