-
Notifications
You must be signed in to change notification settings - Fork 607
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
feat: top of block auction and block-sdk integration #8058
Changes from 15 commits
157b9ce
90495c6
fea6201
d35fe80
1712c49
e960398
dd692b0
a76fa2d
e783d28
05f91d1
6a86b88
5d9f985
8b7447c
51ca508
4a15e6b
5e2e457
b587b02
7bfed64
31d4eff
3200923
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 |
---|---|---|
|
@@ -10,6 +10,8 @@ import ( | |
"time" | ||
|
||
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" | ||
"github.com/skip-mev/block-sdk/block" | ||
"github.com/skip-mev/block-sdk/block/base" | ||
|
||
"github.com/cosmos/cosmos-sdk/x/auth" | ||
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" | ||
|
@@ -117,6 +119,9 @@ import ( | |
v9 "github.com/osmosis-labs/osmosis/v24/app/upgrades/v9" | ||
_ "github.com/osmosis-labs/osmosis/v24/client/docs/statik" | ||
"github.com/osmosis-labs/osmosis/v24/x/mint" | ||
|
||
blocksdkabci "github.com/skip-mev/block-sdk/abci" | ||
"github.com/skip-mev/block-sdk/abci/checktx" | ||
) | ||
|
||
const appName = "OsmosisApp" | ||
|
@@ -177,6 +182,8 @@ type OsmosisApp struct { | |
sm *module.SimulationManager | ||
configurator module.Configurator | ||
homePath string | ||
|
||
checkTxHandler checktx.CheckTx | ||
} | ||
|
||
// init sets DefaultNodeHome to default osmosisd install location. | ||
|
@@ -393,6 +400,20 @@ func NewOsmosisApp( | |
|
||
app.sm.RegisterStoreDecoders() | ||
|
||
// initialize lanes + mempool | ||
mevLane, defaultLane := CreateLanes(app, txConfig) | ||
|
||
// create the mempool | ||
lanedMempool, err := block.NewLanedMempool( | ||
app.Logger(), | ||
[]block.Lane{mevLane, defaultLane}, | ||
) | ||
if err != nil { | ||
panic(err) | ||
} | ||
// set the mempool | ||
app.SetMempool(lanedMempool) | ||
|
||
// initialize stores | ||
app.MountKVStores(app.GetKVStoreKey()) | ||
app.MountTransientStores(app.GetTransientStoreKey()) | ||
|
@@ -410,8 +431,57 @@ func NewOsmosisApp( | |
ante.DefaultSigVerificationGasConsumer, | ||
encodingConfig.TxConfig.SignModeHandler(), | ||
app.IBCKeeper, | ||
BlockSDKAnteHandlerParams{ | ||
mevLane: mevLane, | ||
auctionKeeper: *app.AppKeepers.AuctionKeeper, | ||
txConfig: txConfig, | ||
}, | ||
) | ||
|
||
// update ante-handlers on lanes | ||
opt := []base.LaneOption{ | ||
base.WithAnteHandler(anteHandler), | ||
} | ||
mevLane.WithOptions(opt...) | ||
defaultLane.WithOptions(opt...) | ||
|
||
// ABCI handlers | ||
// prepare proposal | ||
proposalHandler := blocksdkabci.NewProposalHandler( | ||
app.Logger(), | ||
txConfig.TxDecoder(), | ||
txConfig.TxEncoder(), | ||
lanedMempool, | ||
) | ||
|
||
// we use the block-sdk's PrepareProposal logic to build blocks | ||
app.SetPrepareProposal(proposalHandler.PrepareProposalHandler()) | ||
|
||
// we use a no-op ProcessProposal, this way, we accept all proposals in avoidance | ||
// of liveness failures due to Prepare / Process inconsistency. In other words, | ||
// this ProcessProposal always returns ACCEPT. | ||
app.SetProcessProposal(baseapp.NoOpProcessProposal()) | ||
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. just to be sure, we're no-op'ing process proposal along with block sdk integration correct? If so, what's the reason this is ok? 👀 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. Do any other chains utilize a noOpProcessPropisal? Just curious from a testing perspective what the overhead of this will need to be if we are the first to do so. 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. Neutron do: https://github.com/neutron-org/neutron/blob/main/app/app.go#L1039-L1050 Also notes on why this was chosen are in notion: 😄 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. Ah also from David: https://github.com/skip-mev/osmosis/pull/2/files#r1548522449 "Note: this is set to no-op because the upstream priority nonce mempool that the block SDK utilizes under the hood does not natively support multi-fee denoms. As such the ordering may not be deterministic between proposal creation and verificaiton. This would require an integration with osmosis prices / slinky to turn on the ProcessProposalHandler." |
||
|
||
// check-tx | ||
mevCheckTxHandler := checktx.NewMEVCheckTxHandler( | ||
app, | ||
txConfig.TxDecoder(), | ||
mevLane, | ||
anteHandler, | ||
app.BaseApp.CheckTx, | ||
app.ChainID(), | ||
) | ||
|
||
// wrap checkTxHandler with mempool parity handler | ||
parityCheckTx := checktx.NewMempoolParityCheckTx( | ||
app.Logger(), | ||
lanedMempool, | ||
txConfig.TxDecoder(), | ||
mevCheckTxHandler.CheckTx(), | ||
) | ||
|
||
app.SetCheckTx(parityCheckTx.CheckTx()) | ||
|
||
// initialize BaseApp | ||
app.SetInitChainer(app.InitChainer) | ||
app.SetBeginBlocker(app.BeginBlocker) | ||
|
@@ -732,6 +802,19 @@ func InitOsmosisAppForTestnet(app *OsmosisApp, newValAddr bytes.HexBytes, newVal | |
return app | ||
} | ||
|
||
// CheckTx will check the transaction with the provided checkTxHandler. We override the default | ||
// handler so that we can verify bid transactions before they are inserted into the mempool. | ||
// With the BlockSDK CheckTx, we can verify the bid transaction and all of the bundled transactions | ||
// before inserting the bid transaction into the mempool. | ||
func (app *OsmosisApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx { | ||
return app.checkTxHandler(req) | ||
} | ||
|
||
// SetCheckTx sets the checkTxHandler for the app. | ||
func (app *OsmosisApp) SetCheckTx(handler checktx.CheckTx) { | ||
app.checkTxHandler = handler | ||
} | ||
|
||
// MakeCodecs returns the application codec and a legacy Amino codec. | ||
func MakeCodecs() (codec.Codec, *codec.LegacyAmino) { | ||
config := MakeEncodingConfig() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,6 +114,9 @@ import ( | |
epochskeeper "github.com/osmosis-labs/osmosis/x/epochs/keeper" | ||
epochstypes "github.com/osmosis-labs/osmosis/x/epochs/types" | ||
|
||
auctionkeeper "github.com/skip-mev/block-sdk/x/auction/keeper" | ||
auctiontypes "github.com/skip-mev/block-sdk/x/auction/types" | ||
|
||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
) | ||
|
||
|
@@ -184,6 +187,9 @@ type AppKeepers struct { | |
HooksICS4Wrapper ibchooks.ICS4Middleware | ||
PacketForwardKeeper *packetforwardkeeper.Keeper | ||
|
||
// BlockSDK | ||
AuctionKeeper *auctionkeeper.Keeper | ||
|
||
// keys to access the substores | ||
keys map[string]*storetypes.KVStoreKey | ||
tkeys map[string]*storetypes.TransientStoreKey | ||
|
@@ -532,6 +538,18 @@ func (appKeepers *AppKeepers) InitNormalKeepers( | |
appKeepers.LockupKeeper, | ||
) | ||
|
||
// initialize the auction keeper | ||
auctionKeeper := auctionkeeper.NewKeeper( | ||
appCodec, | ||
appKeepers.keys[auctiontypes.StoreKey], | ||
appKeepers.AccountKeeper, | ||
appKeepers.BankKeeper, | ||
appKeepers.DistrKeeper, | ||
appKeepers.StakingKeeper, | ||
authtypes.NewModuleAddress(govtypes.ModuleName).String(), | ||
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. Rewards go to the gov module address 👀 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. My comment incorrect, it uses a function to send rewards to validators https://github.com/skip-mev/block-sdk/blob/main/x/auction/rewards/proposer_provider.go#L29-L41 |
||
) | ||
appKeepers.AuctionKeeper = &auctionKeeper | ||
|
||
appKeepers.ValidatorSetPreferenceKeeper = &validatorSetPreferenceKeeper | ||
|
||
appKeepers.SuperfluidKeeper = superfluidkeeper.NewKeeper( | ||
|
@@ -783,6 +801,7 @@ func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legac | |
paramsKeeper.Subspace(ibchookstypes.ModuleName) | ||
paramsKeeper.Subspace(smartaccounttypes.ModuleName).WithKeyTable(smartaccounttypes.ParamKeyTable()) | ||
paramsKeeper.Subspace(txfeestypes.ModuleName) | ||
paramsKeeper.Subspace(auctiontypes.ModuleName) | ||
|
||
return paramsKeeper | ||
} | ||
|
@@ -905,6 +924,7 @@ func KVStoreKeys() []string { | |
icqtypes.StoreKey, | ||
packetforwardtypes.StoreKey, | ||
cosmwasmpooltypes.StoreKey, | ||
auctiontypes.StoreKey, | ||
smartaccounttypes.StoreKey, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjust heading levels to increment by one level at a time.