From 876961dbe454cb133da112af8b0b175839021a7f Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Tue, 7 Jan 2025 22:05:27 -0600 Subject: [PATCH 1/6] fix cron abci calls --- .github/workflows/interchaintest.yml | 1 - x/cron/abci.go | 10 ++++++---- x/cron/module.go | 16 +++++++++++----- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/interchaintest.yml b/.github/workflows/interchaintest.yml index 5dbe700f0..f718ff69b 100644 --- a/.github/workflows/interchaintest.yml +++ b/.github/workflows/interchaintest.yml @@ -121,7 +121,6 @@ jobs: run_chain_upgrade_interchaintest, run_ica_interchaintest, run_chain_conformance, - run_slinky_interchaintest, ] runs-on: ubuntu-latest diff --git a/x/cron/abci.go b/x/cron/abci.go index 1bc6fd120..85d5e6a1f 100644 --- a/x/cron/abci.go +++ b/x/cron/abci.go @@ -1,6 +1,7 @@ package cron import ( + "context" "encoding/json" "fmt" "runtime/debug" @@ -8,7 +9,6 @@ import ( "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" - abci "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/public-awesome/stargaze/v15/x/cron/contract" @@ -17,18 +17,20 @@ import ( ) // BeginBlocker sends a BeginBlock SudoMsg to all privileged contracts -func BeginBlocker(ctx sdk.Context, k keeper.Keeper, w types.WasmKeeper) { +func BeginBlocker(goCtx context.Context, k keeper.Keeper, w types.WasmKeeper) { + ctx := sdk.UnwrapSDKContext(goCtx) defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) sudoMsg := contract.SudoMsg{BeginBlock: &struct{}{}} k.IteratePrivileged(ctx, abciContractCallback(ctx, w, sudoMsg)) } // EndBlocker sends a EndBlock SudoMsg to all privileged contracts -func EndBlocker(ctx sdk.Context, k keeper.Keeper, w types.WasmKeeper) []abci.ValidatorUpdate { +func EndBlocker(goCtx context.Context, k keeper.Keeper, w types.WasmKeeper) { + ctx := sdk.UnwrapSDKContext(goCtx) defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) sudoMsg := contract.SudoMsg{EndBlock: &struct{}{}} k.IteratePrivileged(ctx, abciContractCallback(ctx, w, sudoMsg)) - return nil + } // returns safe method to send the message via sudo to the privileged contract diff --git a/x/cron/module.go b/x/cron/module.go index af12a19e4..c91a8702f 100644 --- a/x/cron/module.go +++ b/x/cron/module.go @@ -12,6 +12,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" + "cosmossdk.io/core/appmodule" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -23,8 +24,10 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ appmodule.HasBeginBlocker = AppModule{} + _ appmodule.HasEndBlocker = AppModule{} ) // ---------------------------------------------------------------------------- @@ -144,13 +147,16 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw func (AppModule) ConsensusVersion() uint64 { return 1 } // BeginBlock contains the logic that is automatically triggered at the beginning of each block -func (am AppModule) BeginBlock(ctx sdk.Context) { +func (am AppModule) BeginBlock(ctx context.Context) error { BeginBlocker(ctx, am.keeper, am.wasmKeeper) + return nil } // EndBlock contains the logic that is automatically triggered at the end of each block -func (am AppModule) EndBlock(ctx sdk.Context) []abci.ValidatorUpdate { - return EndBlocker(ctx, am.keeper, am.wasmKeeper) +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(ctx context.Context) error { + EndBlocker(ctx, am.keeper, am.wasmKeeper) + return nil } // IsOnePerModuleType implements the depinject.OnePerModuleType interface. From 5fc1d0872ffacb064f0d85e4c69db9290dc3439b Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Tue, 7 Jan 2025 22:08:21 -0600 Subject: [PATCH 2/6] fix libwasm version and linter --- Dockerfile | 2 +- x/cron/abci.go | 1 - x/cron/module.go | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 545f26bfb..a01ec166b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,7 +19,7 @@ COPY . /code/ ADD https://github.com/CosmWasm/wasmvm/releases/download/v2.1.4/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a ADD https://github.com/CosmWasm/wasmvm/releases/download/v2.1.4/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a RUN echo "a4a3d09b36fabb65b119d5ba23442c23694401fcbee4451fe6b7e22e325a4bac /lib/libwasmvm_muslc.x86_64.a" | sha256sum -c -RUN echo "faea4e15390e046d2ca8441c21a88dba56f9a0363f92c5d94015df0ac6da1f2d /lib/libwasmvm_muslc.aarch64.a" | sha256sum -c +RUN echo "090b97641157fae1ae45e7ed368a1a8c091f3fef67958d3bc7c2fa7e7c54b6b4 /lib/libwasmvm_muslc.aarch64.a" | sha256sum -c # force it to use static lib (from above) not standard libgo_cosmwasm.so file RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build diff --git a/x/cron/abci.go b/x/cron/abci.go index 85d5e6a1f..65c47f2fa 100644 --- a/x/cron/abci.go +++ b/x/cron/abci.go @@ -30,7 +30,6 @@ func EndBlocker(goCtx context.Context, k keeper.Keeper, w types.WasmKeeper) { defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) sudoMsg := contract.SudoMsg{EndBlock: &struct{}{}} k.IteratePrivileged(ctx, abciContractCallback(ctx, w, sudoMsg)) - } // returns safe method to send the message via sudo to the privileged contract diff --git a/x/cron/module.go b/x/cron/module.go index c91a8702f..f6f3ac2d0 100644 --- a/x/cron/module.go +++ b/x/cron/module.go @@ -152,7 +152,6 @@ func (am AppModule) BeginBlock(ctx context.Context) error { return nil } -// EndBlock contains the logic that is automatically triggered at the end of each block // EndBlock contains the logic that is automatically triggered at the end of each block func (am AppModule) EndBlock(ctx context.Context) error { EndBlocker(ctx, am.keeper, am.wasmKeeper) From dde70d65203e2ee060e8077107119a55ca94c435 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Tue, 7 Jan 2025 22:48:31 -0600 Subject: [PATCH 3/6] fix begin/end blockers --- x/alloc/abci.go | 4 +++- x/alloc/module.go | 6 ++++-- x/mint/abci.go | 4 +++- x/mint/module.go | 9 ++++++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/x/alloc/abci.go b/x/alloc/abci.go index 4c3d4779e..fa102d523 100644 --- a/x/alloc/abci.go +++ b/x/alloc/abci.go @@ -1,6 +1,7 @@ package alloc import ( + "context" "fmt" "time" @@ -11,7 +12,8 @@ import ( ) // BeginBlocker to distribute specific rewards on every begin block -func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { +func BeginBlocker(goCtx context.Context, k keeper.Keeper) { + ctx := sdk.UnwrapSDKContext(goCtx) defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) if err := k.DistributeInflation(ctx); err != nil { panic(fmt.Sprintf("Error distribute inflation: %s", err.Error())) diff --git a/x/alloc/module.go b/x/alloc/module.go index 6ffcb46ef..0bcab5215 100644 --- a/x/alloc/module.go +++ b/x/alloc/module.go @@ -7,6 +7,7 @@ import ( // this line is used by starport scaffolding # 1 + "cosmossdk.io/core/appmodule" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -23,8 +24,9 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ appmodule.HasBeginBlocker = AppModule{} ) // ---------------------------------------------------------------------------- diff --git a/x/mint/abci.go b/x/mint/abci.go index 48abeb37d..b8f15446d 100644 --- a/x/mint/abci.go +++ b/x/mint/abci.go @@ -1,6 +1,7 @@ package mint import ( + "context" "time" "github.com/cosmos/cosmos-sdk/telemetry" @@ -10,7 +11,8 @@ import ( ) // BeginBlocker mints new tokens for the previous block. -func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { +func BeginBlocker(goCtx context.Context, k keeper.Keeper) { + ctx := sdk.UnwrapSDKContext(goCtx) defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) // fetch stored minter & params diff --git a/x/mint/module.go b/x/mint/module.go index 0de9d6e2c..a3fc69e69 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" + "cosmossdk.io/core/appmodule" abci "github.com/cometbft/cometbft/abci/types" "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" @@ -21,8 +22,9 @@ import ( ) var ( - _ module.AppModule = AppModule{} - _ module.AppModuleBasic = AppModuleBasic{} + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} + _ appmodule.HasBeginBlocker = AppModule{} ) // AppModuleBasic defines the basic application module used by the mint module. @@ -145,8 +147,9 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw func (AppModule) ConsensusVersion() uint64 { return 2 } // BeginBlock returns the begin blocker for the mint module. -func (am AppModule) BeginBlock(ctx sdk.Context) { +func (am AppModule) BeginBlock(ctx context.Context) error { BeginBlocker(ctx, am.keeper) + return nil } // EndBlock returns the end blocker for the mint module. It returns no validator From 62cc68721e5c41ab87b5ff663929c617fcefd0e5 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Tue, 7 Jan 2025 22:50:55 -0600 Subject: [PATCH 4/6] include alloc changes --- x/alloc/module.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x/alloc/module.go b/x/alloc/module.go index 0bcab5215..03fcbde05 100644 --- a/x/alloc/module.go +++ b/x/alloc/module.go @@ -158,8 +158,9 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw func (AppModule) ConsensusVersion() uint64 { return 4 } // BeginBlock executes all ABCI BeginBlock logic respective to the alloc module. -func (am AppModule) BeginBlock(ctx sdk.Context) { +func (am AppModule) BeginBlock(ctx context.Context) error { BeginBlocker(ctx, am.keeper) + return nil } // EndBlock executes all ABCI EndBlock logic respective to the alloc module. It From 2894c1b3b52bf60a98325274182ef5811407968a Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Wed, 8 Jan 2025 12:12:32 -0600 Subject: [PATCH 5/6] add testnet upgrade --- .drone.yml | 6 ++--- app/upgrades.go | 2 ++ app/upgrades/testnet/v15b2/upgrade.go | 36 +++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 app/upgrades/testnet/v15b2/upgrade.go diff --git a/.drone.yml b/.drone.yml index 0ba6ec45c..2b595b60d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -82,7 +82,7 @@ steps: event: - push branch: - - jhernandezb/upgrade-params + - jhernandezb/fix-cron - main - name: docker_release image: plugins/docker @@ -411,7 +411,7 @@ steps: trigger: branch: - main - - jhernandezb/upgrade-params + - jhernandezb/fix-cron event: - pull_request - push @@ -424,6 +424,6 @@ volumes: --- kind: signature -hmac: 6fa113240c7eeed870eef11e63633911cae346e1b0286c8a4afc0c3677050b2b +hmac: 7f6a696633927ee7fcac8511be795df0f17c229369d245c4c7cb4ca83c09ac96 ... diff --git a/app/upgrades.go b/app/upgrades.go index 2801c3236..d9068d82d 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -7,10 +7,12 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" upgrades "github.com/public-awesome/stargaze/v15/app/upgrades" mainnetupgradesv15 "github.com/public-awesome/stargaze/v15/app/upgrades/mainnet/v15" + testnetupgradesv15b2 "github.com/public-awesome/stargaze/v15/app/upgrades/testnet/v15b2" ) var Upgrades = []upgrades.Upgrade{ mainnetupgradesv15.Upgrade, + testnetupgradesv15b2.Upgrade, } func (app App) RegisterUpgradeHandlers(configurator module.Configurator) { diff --git a/app/upgrades/testnet/v15b2/upgrade.go b/app/upgrades/testnet/v15b2/upgrade.go new file mode 100644 index 000000000..c5bdd3d0a --- /dev/null +++ b/app/upgrades/testnet/v15b2/upgrade.go @@ -0,0 +1,36 @@ +package v15 + +import ( + "context" + "time" + + storetypes "cosmossdk.io/store/types" + upgradetypes "cosmossdk.io/x/upgrade/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/public-awesome/stargaze/v15/app/keepers" + "github.com/public-awesome/stargaze/v15/app/upgrades" +) + +// next upgrade name +const UpgradeName = "v15b2" + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator, keepers keepers.StargazeKeepers) upgradetypes.UpgradeHandler { + return func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + startTime := time.Now() + wctx := sdk.UnwrapSDKContext(ctx) + wctx.Logger().Info("upgrade started", "upgrade_name", UpgradeName) + migrations, err := mm.RunMigrations(ctx, cfg, fromVM) + if err != nil { + return nil, err + } + wctx.Logger().Info("upgrade completed", "duration_ms", time.Since(startTime).Milliseconds()) + return migrations, nil + } + }, + StoreUpgrades: storetypes.StoreUpgrades{ + Added: []string{}, + }, +} From ce67a8d9454ffae97489451b924dc8774d227af7 Mon Sep 17 00:00:00 2001 From: jhernandezb Date: Wed, 8 Jan 2025 12:24:37 -0600 Subject: [PATCH 6/6] fix linter --- app/upgrades/testnet/v15b2/upgrade.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/upgrades/testnet/v15b2/upgrade.go b/app/upgrades/testnet/v15b2/upgrade.go index c5bdd3d0a..a66cc2e44 100644 --- a/app/upgrades/testnet/v15b2/upgrade.go +++ b/app/upgrades/testnet/v15b2/upgrade.go @@ -17,7 +17,7 @@ const UpgradeName = "v15b2" var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, - CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator, keepers keepers.StargazeKeepers) upgradetypes.UpgradeHandler { + CreateUpgradeHandler: func(mm *module.Manager, cfg module.Configurator, _ keepers.StargazeKeepers) upgradetypes.UpgradeHandler { return func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { startTime := time.Now() wctx := sdk.UnwrapSDKContext(ctx)