Skip to content

Commit

Permalink
Merge pull request #233 from terra-money/feat/v2.9/remove/pob
Browse files Browse the repository at this point in the history
feat(v2.9): remove pob
  • Loading branch information
javiersuweijie authored Dec 31, 2023
2 parents 93b2cd0 + f22348d commit e95834e
Show file tree
Hide file tree
Showing 30 changed files with 331 additions and 706 deletions.
1 change: 0 additions & 1 deletion .github/workflows/interchaine2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:
matrix:
# names of `make` commands to run tests
test:
- "test-e2e-pob"
- "test-e2e-pmf"
fail-fast: false

Expand Down
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,11 @@ benchmark:
simulate:
@go test -bench BenchmarkSimulation ./app -NumBlocks=200 -BlockSize 50 -Commit=true -Verbose=true -Enabled=true -Seed 1

test-e2e-pob:
cd interchaintest && go test -race -v -run TestPOB .

test-e2e-pmf:
cd interchaintest && go test -race -v -run TestPMF .

.PHONY: test test-all test-cover test-unit test-race simulate test-e2e-pob test-e2e-pmf
.PHONY: test test-all test-cover test-unit test-race simulate test-e2e-pmf

###############################################################################
### Linting ###
Expand Down
12 changes: 0 additions & 12 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package ante
import (
ibcante "github.com/cosmos/ibc-go/v7/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
"github.com/skip-mev/pob/mempool"
pobante "github.com/skip-mev/pob/x/builder/ante"
pobkeeper "github.com/skip-mev/pob/x/builder/keeper"
feesharekeeper "github.com/terra-money/core/v2/x/feeshare/keeper"

"github.com/cosmos/cosmos-sdk/client"
Expand All @@ -29,9 +26,7 @@ type HandlerOptions struct {
BankKeeper bankKeeper.Keeper
TxCounterStoreKey storetypes.StoreKey
WasmConfig wasmTypes.WasmConfig
PobBuilderKeeper pobkeeper.Keeper
TxConfig client.TxConfig
PobMempool mempool.Mempool
}

// NewAnteHandler returns an AnteHandler that checks and increments sequence
Expand All @@ -55,14 +50,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
sigGasConsumer = ante.DefaultSigVerificationGasConsumer
}

auctionDecorator := pobante.NewBuilderDecorator(
options.PobBuilderKeeper,
options.TxConfig.TxEncoder(),
options.PobMempool,
)

anteDecorators := []sdk.AnteDecorator{
auctionDecorator,
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit),
wasmkeeper.NewCountTXDecorator(options.TxCounterStoreKey),
Expand Down
68 changes: 9 additions & 59 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package app

import (
"encoding/json"
"fmt"
"io"
"net/http"
"os"
"path/filepath"
"reflect" // #nosec G702

// #nosec G702
"github.com/prometheus/client_golang/prometheus"

authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
Expand Down Expand Up @@ -47,7 +48,7 @@ import (
cosmosante "github.com/cosmos/cosmos-sdk/x/auth/ante"
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
"github.com/cosmos/cosmos-sdk/x/capability"
Expand Down Expand Up @@ -89,9 +90,6 @@ import (
feeshare "github.com/terra-money/core/v2/x/feeshare"
feesharetypes "github.com/terra-money/core/v2/x/feeshare/types"

pobabci "github.com/skip-mev/pob/abci"
pobmempool "github.com/skip-mev/pob/mempool"

tmjson "github.com/cometbft/cometbft/libs/json"

"github.com/terra-money/core/v2/app/ante"
Expand Down Expand Up @@ -156,9 +154,6 @@ type TerraApp struct {

invCheckPeriod uint

// Custom checkTx handler
checkTxHandler pobabci.CheckTx

// the module manager
mm *module.Manager
basicManager module.BasicManager
Expand Down Expand Up @@ -256,10 +251,6 @@ func NewTerraApp(
app.RegisterUpgradeHandlers()
app.RegisterUpgradeStores()

config := pobmempool.NewDefaultAuctionFactory(encodingConfig.TxConfig.TxDecoder())
// when maxTx is set as 0, there won't be a limit on the number of txs in this mempool
pobMempool := pobmempool.NewAuctionMempool(encodingConfig.TxConfig.TxDecoder(), encodingConfig.TxConfig.TxEncoder(), 0, config)

anteHandler, err := ante.NewAnteHandler(
ante.HandlerOptions{
HandlerOptions: cosmosante.HandlerOptions{
Expand All @@ -274,9 +265,6 @@ func NewTerraApp(
IBCkeeper: app.Keepers.IBCKeeper,
TxCounterStoreKey: app.keys[wasmtypes.StoreKey],
WasmConfig: wasmConfig,
PobBuilderKeeper: app.Keepers.BuilderKeeper,
TxConfig: encodingConfig.TxConfig,
PobMempool: pobMempool,
},
)
if err != nil {
Expand All @@ -290,34 +278,12 @@ func NewTerraApp(
},
)

// Create the proposal handler that will be used to build and validate blocks.
handler := pobabci.NewProposalHandler(
pobMempool,
bApp.Logger(),
anteHandler,
encodingConfig.TxConfig.TxEncoder(),
encodingConfig.TxConfig.TxDecoder(),
)
app.SetPrepareProposal(handler.PrepareProposalHandler())
app.SetProcessProposal(handler.ProcessProposalHandler())

// Set the custom CheckTx handler on BaseApp.
checkTxHandler := pobabci.NewCheckTxHandler(
app.BaseApp,
encodingConfig.TxConfig.TxDecoder(),
pobMempool,
anteHandler,
app.ChainID(),
)

// initialize BaseApp
app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker)
app.SetAnteHandler(anteHandler)
app.SetPostHandler(postHandler)
app.SetEndBlocker(app.EndBlocker)
app.SetMempool(pobMempool)
app.SetCheckTx(checkTxHandler.CheckTx())

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
Expand Down Expand Up @@ -505,8 +471,10 @@ func (app *TerraApp) enforceStakingForVestingTokens(ctx sdk.Context, genesisStat
panic(err)
}

if vestingAcc, ok := account.(vestingexported.VestingAccount); ok {
amt := vestingAcc.GetOriginalVesting().AmountOf(app.Keepers.StakingKeeper.BondDenom(ctx))
bondDenom := app.Keepers.StakingKeeper.BondDenom(ctx)

if vestingAcc, ok := account.(*vestingtypes.BaseVestingAccount); ok {
amt := vestingAcc.GetOriginalVesting().AmountOf(bondDenom)

// to prevent staking multiple times over the same validator
// adjust split amount for the whale account
Expand All @@ -523,6 +491,8 @@ func (app *TerraApp) enforceStakingForVestingTokens(ctx sdk.Context, genesisStat
// stake 200_000_000_000 to val3
for ; amt.GTE(powerReduction); amt = amt.Sub(splitAmt) {
validator := validators[i%validatorLen]
address := vestingAcc.GetAddress().String()
fmt.Print(address)
if _, err := app.Keepers.StakingKeeper.Delegate(
ctx,
vestingAcc.GetAddress(),
Expand Down Expand Up @@ -585,26 +555,6 @@ func (app *TerraApp) RegisterNodeService(clientCtx client.Context) {
nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter())
}

// ChainID gets chainID from private fields of BaseApp
// Should be removed once SDK 0.50.x will be adopted
func (app *TerraApp) ChainID() string {
field := reflect.ValueOf(app.BaseApp).Elem().FieldByName("chainID")
return field.String()
}

// 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 POB CheckTx, we can verify the bid transaction and all of the bundled transactions
// before inserting the bid transaction into the mempool.
func (app *TerraApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx {
return app.checkTxHandler(req)
}

// SetCheckTx sets the checkTxHandler for the app.
func (app *TerraApp) SetCheckTx(handler pobabci.CheckTx) {
app.checkTxHandler = handler
}

func (app *TerraApp) GetWasmOpts(appOpts servertypes.AppOptions) []wasmkeeper.Option {
var wasmOpts []wasmkeeper.Option
if cast.ToBool(appOpts.Get("telemetry.enabled")) {
Expand Down
Loading

0 comments on commit e95834e

Please sign in to comment.