Skip to content

Commit

Permalink
Merge branch 'main' into dev/test_out_read_cahce
Browse files Browse the repository at this point in the history
  • Loading branch information
ValarDragon authored Apr 26, 2024
2 parents e220918 + 473da26 commit a171092
Show file tree
Hide file tree
Showing 107 changed files with 3,401 additions and 919 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-broken-links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@v1.9.3
uses: lycheeverse/lychee-action@v1.10.0
with:
args: --exclude-loopback --verbose --no-progress './**/*.md' './**/*.html'
env:
Expand Down
31 changes: 27 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### State Breaking

* [#8106](https://github.com/osmosis-labs/osmosis/pull/8106) Enable ProtoRev distro on epoch.
* [#8053](https://github.com/osmosis-labs/osmosis/pull/8053) Reset validator signing info missed blocks counter.
* [#8030](https://github.com/osmosis-labs/osmosis/pull/8030) Delete legacy behavior where lockups could not unbond at very small block heights on a testnet.
* [#7935](https://github.com/osmosis-labs/osmosis/pull/7935) Add block sdk and top of block auction from skip-mev.
* [#7876](https://github.com/osmosis-labs/osmosis/pull/7876) Migrate subset of spread reward accumulators
* [#7005](https://github.com/osmosis-labs/osmosis/pull/7005) Adding deactivated smart account module.
* [#8106](https://github.com/osmosis-labs/osmosis/pull/8106) Enable ProtoRev distro on epoch
* [#8053](https://github.com/osmosis-labs/osmosis/pull/8053) Reset validator signing info missed blocks counter
* [#8073](https://github.com/osmosis-labs/osmosis/pull/8073) Speedup CL spread factor calculations, but mildly changes rounding behavior in the final decimal place.
* [#8125](https://github.com/osmosis-labs/osmosis/pull/8125) When using smart accounts, fees are deducted directly after the feePayer is authenticated. Regardless of the authentication of other signers
* [#8136](https://github.com/osmosis-labs/osmosis/pull/8136) Don't allow gauge creation/addition with rewards that have no protorev route (i.e. no way to determine if rewards meet minimum epoch value distribution requirements)
* [#8144](https://github.com/osmosis-labs/osmosis/pull/8144) IBC wasm clients can now make stargate queries and support abort.

### State Compatible

## Unreleased

* [#8128](https://github.com/osmosis-labs/osmosis/pull/8128) Cache the result for poolmanager.GetPoolModule

## v24.0.4

* [#8142](https://github.com/osmosis-labs/osmosis/pull/8142) Add query for getting single authenticator and add stargate whitelist for the query.
* [#8149](https://github.com/osmosis-labs/osmosis/pull/8149) Default timeoutCommit to 1.5s

## v24.0.3

* [#21](https://github.com/osmosis-labs/cometbft/pull/21) Move websocket logs to Debug
* [#22](https://github.com/osmosis-labs/cometbft/pull/22) Fix txSearch pagination performance issues
* [#25](https://github.com/osmosis-labs/cometbft/pull/25) Optimize merkle tree hashing

## v24.0.2

* [#8006](https://github.com/osmosis-labs/osmosis/pull/8006), [#8014](https://github.com/osmosis-labs/osmosis/pull/8014) Speedup many BigDec operations
* [#8030](https://github.com/osmosis-labs/osmosis/pull/8030) Delete legacy behavior where lockups could not unbond at very small block heights on a testnet
* [#8128](https://github.com/osmosis-labs/osmosis/pull/8128) Cache the result for poolmanager.GetPoolModule
* [#8118](https://github.com/osmosis-labs/osmosis/pull/8118) Config.toml and app.toml overwrite improvements
* [#8131](https://github.com/osmosis-labs/osmosis/pull/8131) Overwrite min-gas-prices to 0uosmo (defaulting to the EIP 1559 calculated value) to combat empty blocks

## v24.0.1

Expand Down
34 changes: 28 additions & 6 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"

"github.com/cosmos/cosmos-sdk/client"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
ante "github.com/cosmos/cosmos-sdk/x/auth/ante"
Expand All @@ -22,10 +23,21 @@ import (
smartaccountante "github.com/osmosis-labs/osmosis/v24/x/smart-account/ante"
smartaccountkeeper "github.com/osmosis-labs/osmosis/v24/x/smart-account/keeper"

auctionkeeper "github.com/skip-mev/block-sdk/x/auction/keeper"

txfeeskeeper "github.com/osmosis-labs/osmosis/v24/x/txfees/keeper"
txfeestypes "github.com/osmosis-labs/osmosis/v24/x/txfees/types"

auctionante "github.com/skip-mev/block-sdk/x/auction/ante"
)

// BlockSDKAnteHandlerParams are the parameters necessary to configure the block-sdk antehandlers
type BlockSDKAnteHandlerParams struct {
mevLane auctionante.MEVLane
auctionKeeper auctionkeeper.Keeper
txConfig client.TxConfig
}

// Link to default ante handler used by cosmos sdk:
// https://github.com/cosmos/cosmos-sdk/blob/v0.43.0/x/auth/ante/ante.go#L41
// N.B. There is a sister file called `ante_no_seq.go` that is used for e2e testing.
Expand All @@ -43,6 +55,7 @@ func NewAnteHandler(
sigGasConsumer ante.SignatureVerificationGasConsumer,
signModeHandler signing.SignModeHandler,
channelKeeper *ibckeeper.Keeper,
blockSDKParams BlockSDKAnteHandlerParams,
) sdk.AnteHandler {
mempoolFeeOptions := txfeestypes.NewMempoolFeeOptions(appOpts)
mempoolFeeDecorator := txfeeskeeper.NewMempoolFeeDecorator(*txFeesKeeper, mempoolFeeOptions)
Expand All @@ -62,19 +75,28 @@ func NewAnteHandler(
ante.NewSigVerificationDecorator(accountKeeper, signModeHandler),
ante.NewIncrementSequenceDecorator(accountKeeper),
ibcante.NewRedundantRelayDecorator(channelKeeper),
// auction module antehandler
auctionante.NewAuctionDecorator(
blockSDKParams.auctionKeeper,
blockSDKParams.txConfig.TxEncoder(),
blockSDKParams.mevLane,
),
)

// authenticatorVerificationDecorator is the new authenticator flow that's embedded into the circuit breaker ante
authenticatorVerificationDecorator := sdk.ChainAnteDecorators(
smartaccountante.NewSetPubKeyDecorator(accountKeeper),
smartaccountante.NewEmitPubKeyDecoratorEvents(accountKeeper),
ante.NewValidateSigCountDecorator(accountKeeper), // we can probably remove this as multisigs are not supported here
// Both the signature verification and gas consumption functionality
// Both the signature verification, fee deduction, and gas consumption functionality
// is embedded in the authenticator decorator
smartaccountante.NewAuthenticatorDecorator(smartAccountKeeper, accountKeeper, signModeHandler),
// deductFeeDecorator is called after the authenticator decorator to ensure the fees are not yet reflected as
// a state change.
deductFeeDecorator,
smartaccountante.NewAuthenticatorDecorator(smartAccountKeeper, accountKeeper, signModeHandler, deductFeeDecorator),
ante.NewIncrementSequenceDecorator(accountKeeper),
// auction module antehandler
auctionante.NewAuctionDecorator(
blockSDKParams.auctionKeeper,
blockSDKParams.txConfig.TxEncoder(),
blockSDKParams.mevLane,
),
)

return sdk.ChainAnteDecorators(
Expand Down
73 changes: 62 additions & 11 deletions app/ante_no_seq.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"

"github.com/cosmos/cosmos-sdk/client"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
ante "github.com/cosmos/cosmos-sdk/x/auth/ante"
Expand All @@ -19,10 +20,24 @@ import (

storetypes "github.com/cosmos/cosmos-sdk/store/types"

smartaccountante "github.com/osmosis-labs/osmosis/v24/x/smart-account/ante"
smartaccountkeeper "github.com/osmosis-labs/osmosis/v24/x/smart-account/keeper"

auctionkeeper "github.com/skip-mev/block-sdk/x/auction/keeper"

txfeeskeeper "github.com/osmosis-labs/osmosis/v24/x/txfees/keeper"
txfeestypes "github.com/osmosis-labs/osmosis/v24/x/txfees/types"

auctionante "github.com/skip-mev/block-sdk/x/auction/ante"
)

// BlockSDKAnteHandlerParams are the parameters necessary to configure the block-sdk antehandlers
type BlockSDKAnteHandlerParams struct {
mevLane auctionante.MEVLane
auctionKeeper auctionkeeper.Keeper
txConfig client.TxConfig
}

// Link to default ante handler used by cosmos sdk:
// https://github.com/cosmos/cosmos-sdk/blob/v0.43.0/x/auth/ante/ante.go#L41
// N.B. There is a sister file called `ante_eq.go` that is used for production.
Expand All @@ -32,19 +47,57 @@ func NewAnteHandler(
appOpts servertypes.AppOptions,
wasmConfig wasmtypes.WasmConfig,
txCounterStoreKey storetypes.StoreKey,
ak ante.AccountKeeper,
accountKeeper ante.AccountKeeper,
smartAccountKeeper *smartaccountkeeper.Keeper,
bankKeeper txfeestypes.BankKeeper,
txFeesKeeper *txfeeskeeper.Keeper,
spotPriceCalculator txfeestypes.SpotPriceCalculator,
sigGasConsumer ante.SignatureVerificationGasConsumer,
signModeHandler signing.SignModeHandler,
channelKeeper *ibckeeper.Keeper,
blockSDKParams BlockSDKAnteHandlerParams,
) sdk.AnteHandler {
mempoolFeeOptions := txfeestypes.NewMempoolFeeOptions(appOpts)
mempoolFeeDecorator := txfeeskeeper.NewMempoolFeeDecorator(*txFeesKeeper, mempoolFeeOptions)
sendblockOptions := osmoante.NewSendBlockOptions(appOpts)
sendblockDecorator := osmoante.NewSendBlockDecorator(sendblockOptions)
deductFeeDecorator := txfeeskeeper.NewDeductFeeDecorator(*txFeesKeeper, ak, bankKeeper, nil)
deductFeeDecorator := txfeeskeeper.NewDeductFeeDecorator(*txFeesKeeper, accountKeeper, bankKeeper, nil)

// classicSignatureVerificationDecorator is the old flow to enable a circuit breaker
classicSignatureVerificationDecorator := sdk.ChainAnteDecorators(
deductFeeDecorator,
// We use the old pubkey decorator here to ensure that accounts work as expected,
// in SetPubkeyDecorator we set a pubkey in the account store, for authenticators
// we avoid this code path completely.
ante.NewSetPubKeyDecorator(accountKeeper),
ante.NewValidateSigCountDecorator(accountKeeper),
ante.NewSigGasConsumeDecorator(accountKeeper, sigGasConsumer),
ante.NewSigVerificationDecorator(accountKeeper, signModeHandler),
// ante.NewIncrementSequenceDecorator(accountKeeper),
ibcante.NewRedundantRelayDecorator(channelKeeper),
auctionante.NewAuctionDecorator(
blockSDKParams.auctionKeeper,
blockSDKParams.txConfig.TxEncoder(),
blockSDKParams.mevLane,
),
)

// authenticatorVerificationDecorator is the new authenticator flow that's embedded into the circuit breaker ante
authenticatorVerificationDecorator := sdk.ChainAnteDecorators(
smartaccountante.NewEmitPubKeyDecoratorEvents(accountKeeper),
ante.NewValidateSigCountDecorator(accountKeeper), // we can probably remove this as multisigs are not supported here
// Both the signature verification, fee deduction, and gas consumption functionality
// is embedded in the authenticator decorator
smartaccountante.NewAuthenticatorDecorator(smartAccountKeeper, accountKeeper, signModeHandler, deductFeeDecorator),
// ante.NewIncrementSequenceDecorator(accountKeeper),
// auction module antehandler
auctionante.NewAuctionDecorator(
blockSDKParams.auctionKeeper,
blockSDKParams.txConfig.TxEncoder(),
blockSDKParams.mevLane,
),
)

return sdk.ChainAnteDecorators(
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
wasmkeeper.NewLimitSimulationGasDecorator(wasmConfig.SimulationGasLimit),
Expand All @@ -57,14 +110,12 @@ func NewAnteHandler(
sendblockDecorator,
ante.NewValidateBasicDecorator(),
ante.TxTimeoutHeightDecorator{},
ante.NewValidateMemoDecorator(ak),
ante.NewConsumeGasForTxSizeDecorator(ak),
deductFeeDecorator,
ante.NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(ak),
ante.NewSigGasConsumeDecorator(ak, sigGasConsumer),
ante.NewSigVerificationDecorator(ak, signModeHandler),
// ante.NewIncrementSequenceDecorator(ak),
ibcante.NewRedundantRelayDecorator(channelKeeper),
ante.NewValidateMemoDecorator(accountKeeper),
ante.NewConsumeGasForTxSizeDecorator(accountKeeper),
smartaccountante.NewCircuitBreakerDecorator(
smartAccountKeeper,
authenticatorVerificationDecorator,
classicSignatureVerificationDecorator,
),
)
}
85 changes: 84 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -248,7 +255,7 @@ func NewOsmosisApp(
ibcWasmConfig :=
ibcwasmtypes.WasmConfig{
DataDir: filepath.Join(homePath, "ibc_08-wasm"),
SupportedCapabilities: "iterator",
SupportedCapabilities: "iterator,stargate,abort",
ContractDebugMode: false,
}
wasmConfig, err := wasm.ReadWasmConfig(appOpts)
Expand Down Expand Up @@ -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())
Expand All @@ -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())

// 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)
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion app/apptesting/concentrated_liquidity.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ var (
curSqrtPrice, _ := osmomath.MonotonicSqrt(DefaultCurrPrice) // 70.710678118654752440
return osmomath.BigDecFromDec(curSqrtPrice)
}()
PerUnitLiqScalingFactor = osmomath.NewDec(1e15).MulMut(osmomath.NewDec(1e12))

DefaultSpreadRewardAccumCoins = sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(50)))
DefaultSpreadRewardAccumCoins = sdk.NewDecCoins(sdk.NewDecCoinFromDec("foo", osmomath.NewDec(50).MulTruncate(PerUnitLiqScalingFactor)))

DefaultCoinAmount = osmomath.NewInt(1000000000000000000)

Expand Down
Loading

0 comments on commit a171092

Please sign in to comment.