Skip to content

Commit

Permalink
add inplacetestnet (#2063)
Browse files Browse the repository at this point in the history
* add inplacetestnet

* rebase
  • Loading branch information
codchen authored Jan 31, 2025
1 parent c2bc99c commit f5e6716
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
27 changes: 27 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
Expand Down Expand Up @@ -370,6 +371,8 @@ type App struct {

stateStore seidb.StateStore
receiptStore seidb.StateStore

forkInitializer func(sdk.Context)
}

type AppOption func(*App)
Expand Down Expand Up @@ -927,6 +930,7 @@ func New(
app.SetPrepareProposalHandler(app.PrepareProposalHandler)
app.SetProcessProposalHandler(app.ProcessProposalHandler)
app.SetFinalizeBlocker(app.FinalizeBlocker)
app.SetInplaceTestnetInitializer(app.inplacetestnetInitializer)

// Register snapshot extensions to enable state-sync for wasm.
if manager := app.SnapshotManager(); manager != nil {
Expand Down Expand Up @@ -1070,6 +1074,10 @@ func (app App) GetStateStore() seidb.StateStore { return app.stateStore }
func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
metrics.GaugeSeidVersionAndCommit(app.versionInfo.Version, app.versionInfo.GitCommit)
// check if we've reached a target height, if so, execute any applicable handlers
if app.forkInitializer != nil {
app.forkInitializer(ctx)
app.forkInitializer = nil
}
if app.HardForkManager.TargetHeightReached(ctx) {
app.HardForkManager.ExecuteForTargetHeight(ctx)
}
Expand Down Expand Up @@ -1984,6 +1992,25 @@ func (app *App) SetTxDecoder(txDecoder sdk.TxDecoder) {
app.txDecoder = txDecoder
}

func (app *App) inplacetestnetInitializer(pk cryptotypes.PubKey) error {
app.forkInitializer = func(ctx sdk.Context) {
val, _ := stakingtypes.NewValidator(
sdk.ValAddress(pk.Address()), pk, stakingtypes.NewDescription("test", "test", "test", "test", "test"))
app.StakingKeeper.SetValidator(ctx, val)
_ = app.StakingKeeper.SetValidatorByConsAddr(ctx, val)
app.StakingKeeper.SetValidatorByPowerIndex(ctx, val)
_ = app.SlashingKeeper.AddPubkey(ctx, pk)
app.SlashingKeeper.SetValidatorSigningInfo(
ctx,
sdk.ConsAddress(pk.Address()),
slashingtypes.NewValidatorSigningInfo(
sdk.ConsAddress(pk.Address()), 0, 0, time.Unix(0, 0), false, 0,
),
)
}
return nil
}

func init() {
// override max wasm size to 2MB
wasmtypes.MaxWasmSize = 2 * 1024 * 1024
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,15 @@ replace (
github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.3.0
github.com/CosmWasm/wasmvm => github.com/sei-protocol/sei-wasmvm v1.5.4-sei.0.0.1
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.51
github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.52
github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.2.0
github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.5
github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20241224143343-21ee50facc96
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.46
// Latest goleveldb is broken, we have to stick to this version
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.4.6
github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.4.7
github.com/tendermint/tm-db => github.com/sei-protocol/tm-db v0.0.4
google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1348,16 +1348,16 @@ github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20241224143343-21ee50facc96
github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20241224143343-21ee50facc96/go.mod h1:kcRZmuzRn1lVejiFNTz4l4W7imnpq1bDAnuKS/RyhbQ=
github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA=
github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8=
github.com/sei-protocol/sei-cosmos v0.3.51 h1:Lw4L+pJXa0bvq48q4mH9Mmr378EZg1pUgiRzex55yk0=
github.com/sei-protocol/sei-cosmos v0.3.51/go.mod h1:zdKiFj5Cobfd30/cVz7CgQlxUtrK2Msjk6Gf6y/hl8g=
github.com/sei-protocol/sei-cosmos v0.3.52 h1:oEd4t9BqPxipiTqAYwgKcN1qVHZUUnOuQOzbLNrVA5Y=
github.com/sei-protocol/sei-cosmos v0.3.52/go.mod h1:X/Fhh/QNNBKIVvJJUT3IKz4nyJ8PhB5/iFD0LSlyB74=
github.com/sei-protocol/sei-db v0.0.46 h1:naXfSp1I3UgJJm/iSvXpdFzr9nofEOxp/EekcAVj7wY=
github.com/sei-protocol/sei-db v0.0.46/go.mod h1:m5g7p0QeAS3dNJHIl28zQpzOgxQmvYqPb7t4hwgIOCA=
github.com/sei-protocol/sei-iavl v0.2.0 h1:OisPjXiDT+oe+aeckzDEFgkZCYuUjHgs/PP8DPicN+I=
github.com/sei-protocol/sei-iavl v0.2.0/go.mod h1:qRf8QYUPfrAO7K6VDB2B2l/N7K5L76OorioGBcJBIbw=
github.com/sei-protocol/sei-ibc-go/v3 v3.3.5 h1:SQRzWi9KSMuGNGd3f5RWAmsGGk7yeY1zhnEnrr/nqug=
github.com/sei-protocol/sei-ibc-go/v3 v3.3.5/go.mod h1:VwB/vWu4ysT5DN2aF78d17LYmx3omSAdq6gpKvM7XRA=
github.com/sei-protocol/sei-tendermint v0.4.6 h1:Gmw4tjLSnghAdue54HJzDySDvxs2Hd5d0rrv3ajgRSA=
github.com/sei-protocol/sei-tendermint v0.4.6/go.mod h1:4LSlJdhl3nf3OmohliwRNUFLOB1XWlrmSodrIP7fLh4=
github.com/sei-protocol/sei-tendermint v0.4.7 h1:mQ9tnZE240a0lE+8CYDqbIfBEv13ud5vJMs0EV4FVLw=
github.com/sei-protocol/sei-tendermint v0.4.7/go.mod h1:4LSlJdhl3nf3OmohliwRNUFLOB1XWlrmSodrIP7fLh4=
github.com/sei-protocol/sei-tm-db v0.0.5 h1:3WONKdSXEqdZZeLuWYfK5hP37TJpfaUa13vAyAlvaQY=
github.com/sei-protocol/sei-tm-db v0.0.5/go.mod h1:Cpa6rGyczgthq7/0pI31jys2Fw0Nfrc+/jKdP1prVqY=
github.com/sei-protocol/sei-wasmd v0.3.0 h1:IJabKisvmsstAPsVAk37HxVyQwAe36g1CNYM/QcPisc=
Expand Down

0 comments on commit f5e6716

Please sign in to comment.