Skip to content
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: v3 upgrade #471

Merged
merged 61 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
3d09202
add module ibc-hooks
DongLieu Mar 25, 2024
39c1dba
Using ibc-hooks module of classic terra
DongLieu Mar 25, 2024
74514a4
update go.mod
DongLieu Mar 25, 2024
196bda5
Bump to sdk47 and handle all compiler errors
phamminh0811 Mar 26, 2024
9b002fe
bump gogoproto and golang.org/x/exp
DongLieu Mar 26, 2024
b5abd82
updates
DongLieu Mar 26, 2024
cc7f54f
fix dyncomm ante and vesting tests
phamminh0811 Mar 27, 2024
9a266fb
fix all unit tests
phamminh0811 Mar 27, 2024
2243ade
upgrade handler for SDK47
expertdicer Mar 28, 2024
0490beb
e2e-test: fix updateGovGenesis
DongLieu Mar 28, 2024
0f66b60
using replace of classic
DongLieu Mar 28, 2024
77273b2
add SetChainID and fix DockerFile e2e dont use wasmvm fork
DongLieu Mar 29, 2024
72ff08d
update MessageValidator
DongLieu Mar 29, 2024
fb13503
add kvStore for crisis
DongLieu Mar 29, 2024
7330bb3
updates e2e
DongLieu Apr 2, 2024
8dca01e
fix ibc fail
phamminh0811 Apr 2, 2024
d3d6197
remove chain C, don't use fpm anymore
DongLieu Apr 2, 2024
4966a00
fix remove chain c
DongLieu Apr 2, 2024
8570b35
fix code id in e2e
phamminh0811 Apr 3, 2024
3b209c8
pass all test-e2e
DongLieu Apr 4, 2024
d4d578a
add crisistytes store into upgradehandlers
expertdicer Apr 7, 2024
af6d126
correct upgrade import
expertdicer Apr 7, 2024
48406ea
iterate Subspaces
expertdicer Apr 7, 2024
a36bcbe
remove ibchooks subspace
expertdicer Apr 7, 2024
e8a55e9
fix interchain test
phamminh0811 Apr 8, 2024
5754c27
updates scrips run node
DongLieu Apr 9, 2024
7d7b117
Change core version to v3
phamminh0811 Apr 19, 2024
7445624
add spamming memo test
phamminh0811 Apr 19, 2024
9563fd8
use ibc-go fork
phamminh0811 Apr 19, 2024
1208de6
backport v2.5.0
phamminh0811 Apr 29, 2024
5ed0a27
use wasmkeeper.Option instead of deprecated one
phamminh0811 May 6, 2024
c264e0d
set Localhost params in client
phamminh0811 May 6, 2024
febdbe8
fix ante_test in dyncom
phamminh0811 May 6, 2024
ca067e4
update go mod
phamminh0811 May 6, 2024
6261501
add NewGasRegisterDecorator
expertdicer May 8, 2024
534bdb1
add wasm snapshot support
expertdicer May 13, 2024
32deee3
merge main
phamminh0811 May 13, 2024
582f2cb
lint and change all deprecated types
phamminh0811 May 13, 2024
ad63865
fix make proto-format
phamminh0811 May 13, 2024
b65ec63
make proto-gen
phamminh0811 May 13, 2024
4d5f770
Fix tests (#472)
StrathCole May 13, 2024
6cb802e
fix prune command
phamminh0811 May 14, 2024
554d217
remove params table for gov
phamminh0811 May 14, 2024
df0f114
lint
phamminh0811 May 14, 2024
38f4910
fix ante test
phamminh0811 May 14, 2024
6ce7b9e
fix ictest-validator
phamminh0811 May 14, 2024
c2ce5fb
fix liveness test localnet
phamminh0811 May 14, 2024
a3bca0a
fix upgrade-test
phamminh0811 May 15, 2024
58054c9
copy Dockerfile.old to correct folder
phamminh0811 May 15, 2024
bd08c0a
copy Dockerfile.old to correct folder
phamminh0811 May 15, 2024
6dc194c
use correct old version dir
phamminh0811 May 15, 2024
cda8f55
use Dockerfile.old to build old version
phamminh0811 May 15, 2024
5e7be72
new tag wasmd
DongLieu May 17, 2024
3e02c52
replace all deprecated types
phamminh0811 May 17, 2024
bcd74bd
lint
phamminh0811 May 17, 2024
29f5fdc
revert commented test
phamminh0811 May 23, 2024
6d7571f
fix wrong doc
phamminh0811 May 23, 2024
e99e23c
revert commented dyncomm test
phamminh0811 May 23, 2024
3ce8be1
revert the verify contract length
phamminh0811 May 23, 2024
9abe9cc
update sdk:revert the option to use sequence and account number in on…
DongLieu May 23, 2024
93eab3a
remove register gas decorator
phamminh0811 May 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ RUN --mount=type=cache,target=/root/.cache/go-build \

# Cosmwasm - Download correct libwasmvm version and verify checksum
RUN set -eux &&\
WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 5) && \
WASMVM_DOWNLOADS="https://github.com/classic-terra/wasmvm/releases/download/${WASMVM_VERSION}"; \
WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm | cut -d ' ' -f 2) && \
WASMVM_DOWNLOADS="https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}"; \
phamminh0811 marked this conversation as resolved.
Show resolved Hide resolved
wget ${WASMVM_DOWNLOADS}/checksums.txt -O /tmp/checksums.txt; \
if [ ${BUILDPLATFORM} = "linux/amd64" ]; then \
WASMVM_URL="${WASMVM_DOWNLOADS}/libwasmvm_muslc.x86_64.a"; \
Expand Down
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,8 @@ format:
### Protobuf ###
###############################################################################

CONTAINER_PROTO_VER=v0.7
CONTAINER_PROTO_IMAGE=tendermintdev/sdk-proto-gen:$(CONTAINER_PROTO_VER)
CONTAINER_PROTO_FMT=cosmos-sdk-proto-fmt-$(CONTAINER_PROTO_VER)
CONTAINER_PROTO_VER=0.13.1
CONTAINER_PROTO_IMAGE=ghcr.io/cosmos/proto-builder:$(CONTAINER_PROTO_VER)

proto-all: proto-format proto-lint proto-gen

Expand All @@ -312,8 +311,7 @@ proto-gen:

proto-format:
@echo "Formatting Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${CONTAINER_PROTO_FMT}$$"; then docker start -a $(CONTAINER_PROTO_FMT); else docker run --name $(CONTAINER_PROTO_FMT) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \
find ./proto -name "*.proto" -exec clang-format -i {} \; ; fi
@$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(CONTAINER_PROTO_IMAGE) find ./proto -name "*.proto" -exec clang-format -i {} \;

proto-lint:
@$(DOCKER_BUF) lint --error-format=json
Expand Down
97 changes: 65 additions & 32 deletions app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
"encoding/json"
"fmt"
"io"
stdlog "log"
Expand All @@ -12,22 +13,24 @@ import (
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"

abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"
dbm "github.com/cometbft/cometbft-db"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
"github.com/cometbft/cometbft/libs/log"
tmos "github.com/cometbft/cometbft/libs/os"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/server"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
Expand All @@ -38,28 +41,31 @@ import (
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

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

// upgrades
"github.com/classic-terra/core/v2/app/upgrades"
v2 "github.com/classic-terra/core/v2/app/upgrades/v2"
v3 "github.com/classic-terra/core/v2/app/upgrades/v3"
v4 "github.com/classic-terra/core/v2/app/upgrades/v4"
v5 "github.com/classic-terra/core/v2/app/upgrades/v5"
v6 "github.com/classic-terra/core/v2/app/upgrades/v6"
v6_1 "github.com/classic-terra/core/v2/app/upgrades/v6_1"
v7 "github.com/classic-terra/core/v2/app/upgrades/v7"
v7_1 "github.com/classic-terra/core/v2/app/upgrades/v7_1"

customante "github.com/classic-terra/core/v2/custom/auth/ante"
custompost "github.com/classic-terra/core/v2/custom/auth/post"
customauthtx "github.com/classic-terra/core/v2/custom/auth/tx"
"github.com/classic-terra/core/v3/app/upgrades"
v2 "github.com/classic-terra/core/v3/app/upgrades/v2"
v3 "github.com/classic-terra/core/v3/app/upgrades/v3"
v4 "github.com/classic-terra/core/v3/app/upgrades/v4"
v5 "github.com/classic-terra/core/v3/app/upgrades/v5"
v6 "github.com/classic-terra/core/v3/app/upgrades/v6"
v6_1 "github.com/classic-terra/core/v3/app/upgrades/v6_1"
v7 "github.com/classic-terra/core/v3/app/upgrades/v7"
v7_1 "github.com/classic-terra/core/v3/app/upgrades/v7_1"
v8 "github.com/classic-terra/core/v3/app/upgrades/v8"

customante "github.com/classic-terra/core/v3/custom/auth/ante"
custompost "github.com/classic-terra/core/v3/custom/auth/post"
customauthtx "github.com/classic-terra/core/v3/custom/auth/tx"

"github.com/CosmWasm/wasmd/x/wasm"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

// unnamed import of statik for swagger UI support
_ "github.com/classic-terra/core/v2/client/docs/statik"
_ "github.com/classic-terra/core/v3/client/docs/statik"
)

const appName = "TerraApp"
Expand All @@ -69,15 +75,15 @@ var (
DefaultNodeHome string

// Upgrades defines upgrades to be applied to the network
Upgrades = []upgrades.Upgrade{v2.Upgrade, v3.Upgrade, v4.Upgrade, v5.Upgrade, v6.Upgrade, v6_1.Upgrade, v7.Upgrade, v7_1.Upgrade}
Upgrades = []upgrades.Upgrade{v2.Upgrade, v3.Upgrade, v4.Upgrade, v5.Upgrade, v6.Upgrade, v6_1.Upgrade, v7.Upgrade, v7_1.Upgrade, v8.Upgrade}

// Forks defines forks to be applied to the network
Forks = []upgrades.Fork{}
)

// Verify app interface at compile time
var (
_ simapp.App = (*TerraApp)(nil)
_ runtime.AppI = (*TerraApp)(nil)
_ servertypes.Application = (*TerraApp)(nil)
)

Expand All @@ -90,6 +96,7 @@ type TerraApp struct {

legacyAmino *codec.LegacyAmino
appCodec codec.Codec
txConfig client.TxConfig
interfaceRegistry codectypes.InterfaceRegistry

invCheckPeriod uint
Expand All @@ -116,14 +123,17 @@ 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,
homePath string, invCheckPeriod uint, encodingConfig terraappparams.EncodingConfig, appOpts servertypes.AppOptions,
wasmOpts []wasm.Option, baseAppOptions ...func(*baseapp.BaseApp),
homePath string, encodingConfig terraappparams.EncodingConfig, appOpts servertypes.AppOptions,
wasmOpts []wasmkeeper.Option, baseAppOptions ...func(*baseapp.BaseApp),
) *TerraApp {
appCodec := encodingConfig.Marshaler
legacyAmino := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
txConfig := encodingConfig.TxConfig

bApp := baseapp.NewBaseApp(appName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...)
invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod))

bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseAppOptions...)
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetVersion(version.Version)
bApp.SetInterfaceRegistry(interfaceRegistry)
Expand All @@ -133,6 +143,7 @@ func NewTerraApp(
legacyAmino: legacyAmino,
appCodec: appCodec,
interfaceRegistry: interfaceRegistry,
txConfig: txConfig,
invCheckPeriod: invCheckPeriod,
}

Expand Down Expand Up @@ -172,8 +183,7 @@ func NewTerraApp(
// NOTE: Treasury must occur after bank module so that initial supply is properly set
app.mm.SetOrderInitGenesis(orderInitGenesis()...)

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.mm.RegisterInvariants(app.CrisisKeeper)
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)
app.setupUpgradeHandlers()
Expand Down Expand Up @@ -211,10 +221,11 @@ func NewTerraApp(
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
IBCKeeper: *app.IBCKeeper,
WasmKeeper: &app.WasmKeeper,
DistributionKeeper: app.DistrKeeper,
GovKeeper: app.GovKeeper,
WasmConfig: &wasmConfig,
TXCounterStoreKey: app.GetKey(wasm.StoreKey),
TXCounterStoreKey: app.GetKey(wasmtypes.StoreKey),
DyncommKeeper: app.DyncommKeeper,
StakingKeeper: app.StakingKeeper,
Cdc: app.appCodec,
Expand All @@ -237,6 +248,18 @@ func NewTerraApp(
app.SetPostHandler(postHandler)
app.SetEndBlocker(app.EndBlocker)

// must be before Loading version
// requires the snapshot store to be created and registered as a BaseAppOption
// see cmd/wasmd/root.go: 206 - 214 approx
if manager := app.SnapshotManager(); manager != nil {
err := manager.RegisterExtensions(
wasmkeeper.NewWasmSnapshotter(app.CommitMultiStore(), &app.WasmKeeper),
)
if err != nil {
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
}
}

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
tmos.Exit(err.Error())
Expand All @@ -255,6 +278,11 @@ func NewTerraApp(
// Name returns the name of the App
func (app *TerraApp) Name() string { return app.BaseApp.Name() }

// DefaultGenesis returns a default genesis from the registered AppModuleBasic's.
func (app *TerraApp) DefaultGenesis() map[string]json.RawMessage {
return ModuleBasics.DefaultGenesis(app.appCodec)
}

// BeginBlocker application updates every begin block
func (app *TerraApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
BeginBlockForks(ctx, app)
Expand Down Expand Up @@ -371,6 +399,10 @@ func (app *TerraApp) RegisterTendermintService(clientCtx client.Context) {
)
}

func (app *TerraApp) RegisterNodeService(clientCtx client.Context) {
nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter())
}

// RegisterSwaggerAPI registers swagger route with API Server
func RegisterSwaggerAPI(rtr *mux.Router) {
statikFS, err := fs.New()
Expand Down Expand Up @@ -403,7 +435,8 @@ func (app *TerraApp) setupUpgradeStoreLoaders() {

for _, upgrade := range Upgrades {
if upgradeInfo.Name == upgrade.UpgradeName {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades))
storeUpgrades := upgrade.StoreUpgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/std"

"github.com/classic-terra/core/v2/app/params"
"github.com/classic-terra/core/v3/app/params"
)

var legacyCodecRegistered = false
Expand Down
8 changes: 4 additions & 4 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import (
"encoding/json"
"log"

tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

servertypes "github.com/cosmos/cosmos-sdk/server/types"
sdk "github.com/cosmos/cosmos-sdk/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"github.com/cosmos/cosmos-sdk/x/staking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

oracletypes "github.com/classic-terra/core/v2/x/oracle/types"
oracletypes "github.com/classic-terra/core/v3/x/oracle/types"
)

// ExportAppStateAndValidators exports the state of the application for a genesis
// file.
func (app *TerraApp) ExportAppStateAndValidators(
forZeroHeight bool, jailAllowedAddrs []string,
forZeroHeight bool, jailAllowedAddrs, modulesToExport []string,
) (servertypes.ExportedApp, error) {
// as if they could withdraw from the start of the next block
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})
Expand All @@ -31,7 +31,7 @@ func (app *TerraApp) ExportAppStateAndValidators(
app.prepForZeroHeightGenesis(ctx, jailAllowedAddrs)
}

genState := app.mm.ExportGenesis(ctx, app.appCodec)
genState := app.mm.ExportGenesisForModules(ctx, app.appCodec, modulesToExport)
appState, err := json.MarshalIndent(genState, "", " ")
if err != nil {
return servertypes.ExportedApp{}, err
Expand Down
Loading
Loading