Skip to content

Commit

Permalink
Unfork CosmosSDK, CometBFT, ibc-go (#539)
Browse files Browse the repository at this point in the history
Co-authored-by: Khanh Hoa <hoa@notional.ventures>
Co-authored-by: Tuan Tran <tropicaldog17@gmail.com>
Co-authored-by: Tuan Tran <tuan.ta204701@sis.hust.edu.vn>
Co-authored-by: tnv1 <tien@notional.ventures>
Co-authored-by: Tien Nguyen <htiennv@gmail.com>
Co-authored-by: Hoa Nguyen <hoank@protonmail.com>
  • Loading branch information
7 people authored Dec 16, 2024
1 parent 79f2a5e commit 70aad84
Show file tree
Hide file tree
Showing 37 changed files with 4,236 additions and 679 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ ictest-ibc-pfm: ictest-build
ictest-ibc-pfm-terra: ictest-build
@cd tests/interchaintest && go test -race -v -run TestTerraPFM .

ictest-oracle: ictest-build
@cd tests/interchaintest && go test -race -v -run TestOracle .

ictest-build:
@DOCKER_BUILDKIT=1 docker build -t core:local -f ictest.Dockerfile .

Expand Down
38 changes: 34 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"

appmempool "github.com/classic-terra/core/v3/app/mempool"
dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
Expand All @@ -33,7 +34,6 @@ import (
servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"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"
Expand All @@ -43,6 +43,7 @@ import (

"github.com/classic-terra/core/v3/app/keepers"
terraappparams "github.com/classic-terra/core/v3/app/params"
customserver "github.com/classic-terra/core/v3/server"

// upgrades
"github.com/classic-terra/core/v3/app/upgrades"
Expand All @@ -61,6 +62,7 @@ import (

// v9 had been used by tax2gas and has to be skipped
v10_1 "github.com/classic-terra/core/v3/app/upgrades/v10_1"
v11 "github.com/classic-terra/core/v3/app/upgrades/v11"

customante "github.com/classic-terra/core/v3/custom/auth/ante"
custompost "github.com/classic-terra/core/v3/custom/auth/post"
Expand Down Expand Up @@ -95,6 +97,7 @@ var (
v8_2.Upgrade,
v8_3.Upgrade,
v10_1.Upgrade,
v11.Upgrade,
}

// Forks defines forks to be applied to the network
Expand Down Expand Up @@ -142,7 +145,7 @@ func init() {

// NewTerraApp returns a reference to an initialized TerraApp.
func NewTerraApp(
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
logger log.Logger, db dbm.DB, _ io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
homePath string, encodingConfig terraappparams.EncodingConfig, appOpts servertypes.AppOptions,
wasmOpts []wasmkeeper.Option, baseAppOptions ...func(*baseapp.BaseApp),
) *TerraApp {
Expand All @@ -152,10 +155,29 @@ func NewTerraApp(
txConfig := encodingConfig.TxConfig

invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod))
iavlCacheSize := cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))
iavlDisableFastNode := cast.ToBool(appOpts.Get(server.FlagDisableIAVLFastNode))

// option for cosmos sdk
baseAppOptions = append(baseAppOptions, baseapp.SetIAVLCacheSize(iavlCacheSize))
baseAppOptions = append(baseAppOptions, baseapp.SetIAVLDisableFastNode(iavlDisableFastNode))

// option for mempool
baseAppOptions = append(baseAppOptions, func(app *baseapp.BaseApp) {
var mempool *appmempool.FifoMempool
if maxTxs := cast.ToInt(appOpts.Get(server.FlagMempoolMaxTxs)); maxTxs >= 0 {
mempool = appmempool.NewFifoMempool(appmempool.FifoMaxTxOpt(maxTxs))
} else {
mempool = appmempool.NewFifoMempool()
}
handler := baseapp.NewDefaultProposalHandler(mempool, app)
app.SetMempool(mempool)
app.SetTxEncoder(txConfig.TxEncoder())
app.SetPrepareProposal(handler.PrepareProposalHandler())
app.SetProcessProposal(handler.ProcessProposalHandler())
})

bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseAppOptions...)
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetVersion(version.Version)
bApp.SetInterfaceRegistry(interfaceRegistry)

app := &TerraApp{
Expand Down Expand Up @@ -406,6 +428,9 @@ func (app *TerraApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIC
if apiConfig.Swagger {
RegisterSwaggerAPI(apiSvr.Router)
}

// Apply custom middleware
apiSvr.Router.Use(customserver.BlockHeightMiddleware)
}

// RegisterTxService implements the Application.RegisterTxService method.
Expand Down Expand Up @@ -478,3 +503,8 @@ func (app *TerraApp) setupUpgradeHandlers() {
)
}
}

// GetTxConfig for testing
func (app *TerraApp) GetTxConfig() client.TxConfig {
return app.txConfig
}
24 changes: 24 additions & 0 deletions app/helper/helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package helper

import (
oracleexported "github.com/classic-terra/core/v3/x/oracle/exported"
sdk "github.com/cosmos/cosmos-sdk/types"
)

func IsOracleTx(msgs []sdk.Msg) bool {
if len(msgs) == 0 {
return false
}
for _, msg := range msgs {
switch msg.(type) {
case *oracleexported.MsgAggregateExchangeRatePrevote:
continue
case *oracleexported.MsgAggregateExchangeRateVote:
continue
default:
return false
}
}

return true
}
4 changes: 2 additions & 2 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ import (
"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
customstaking "github.com/classic-terra/core/v3/custom/staking"
customwasmkeeper "github.com/classic-terra/core/v3/custom/wasm/keeper"
terrawasm "github.com/classic-terra/core/v3/wasmbinding"

dyncommkeeper "github.com/classic-terra/core/v3/x/dyncomm/keeper"
dyncommtypes "github.com/classic-terra/core/v3/x/dyncomm/types"
marketkeeper "github.com/classic-terra/core/v3/x/market/keeper"
Expand Down Expand Up @@ -277,7 +277,7 @@ func NewAppKeepers(
// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
appKeepers.StakingKeeper.SetHooks(
stakingtypes.NewMultiStakingHooks(appKeepers.DistrKeeper.Hooks(), appKeepers.SlashingKeeper.Hooks()),
stakingtypes.NewMultiStakingHooks(customstaking.NewTerraStakingHooks(*appKeepers.StakingKeeper), appKeepers.DistrKeeper.Hooks(), appKeepers.SlashingKeeper.Hooks()),
)

// Create IBC Keeper
Expand Down
Loading

0 comments on commit 70aad84

Please sign in to comment.