Skip to content

Commit 19b57ca

Browse files
committed
Merged with main
2 parents 4d83085 + e232e65 commit 19b57ca

File tree

14 files changed

+729
-20
lines changed

14 files changed

+729
-20
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Generate Genesis Template
2+
on: ["push"]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
name: Generate Genesis Template
7+
steps:
8+
- uses: actions/checkout@v4
9+
- uses: actions/setup-go@v5
10+
with:
11+
go-version: "1.23.1"
12+
13+
- name: Install Dasel
14+
run: |
15+
curl -sSLf https://github.com/TomWright/dasel/releases/latest/download/dasel_linux_amd64 -o /usr/local/bin/dasel
16+
chmod +x /usr/local/bin/dasel
17+
18+
- name: Generate genesis template mainnet
19+
run: make generate-genesis env=mainnet
20+
env:
21+
BECH32_PREFIX: ethm
22+
23+
- name: Generate genesis template testnet
24+
run: make generate-genesis env=testnet
25+
env:
26+
BECH32_PREFIX: ethm

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ COMMIT := $(shell git log -1 --format='%H')
77
ifndef BECH32_PREFIX
88
$(error BECH32_PREFIX is not set)
99
endif
10-
DRS_VERSION = 2
10+
DRS_VERSION = 3
1111

1212
# don't override user values
1313
ifeq (,$(NAME))

app/app.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ import (
162162
// Upgrade handlers
163163
"github.com/dymensionxyz/rollapp-wasm/app/upgrades"
164164
drs2 "github.com/dymensionxyz/rollapp-wasm/app/upgrades/drs-2"
165+
drs3 "github.com/dymensionxyz/rollapp-wasm/app/upgrades/drs-3"
165166
)
166167

167168
const (
@@ -187,7 +188,7 @@ var (
187188
rollappparamstypes.StoreKey,
188189
}
189190
// Upgrades contains the upgrade handlers for the application
190-
Upgrades = []upgrades.Upgrade{drs2.Upgrade}
191+
Upgrades = []upgrades.Upgrade{drs2.Upgrade, drs3.Upgrade}
191192
)
192193

193194
func getGovProposalHandlers() []govclient.ProposalHandler {

app/test_helpers.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
2020
"github.com/dymensionxyz/dymension-rdk/testutil/utils"
2121
rollappparamstypes "github.com/dymensionxyz/dymension-rdk/x/rollappparams/types"
22+
"github.com/dymensionxyz/dymint/version"
2223
"github.com/tendermint/tendermint/crypto/encoding"
2324
"github.com/tendermint/tendermint/libs/log"
2425
"github.com/tendermint/tendermint/proto/tendermint/crypto"
@@ -92,6 +93,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *types2.ValidatorSet, genAccs [
9293
app, genesisState := setup(true, 5)
9394
genesisState = genesisStateWithValSet(t, app, genesisState, valSet, genAccs, balances...)
9495

96+
version.DRS = "1"
9597
genesisState = setRollappVersion(app.appCodec, genesisState, 1)
9698

9799
denomMD := banktypes.Metadata{
@@ -126,7 +128,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *types2.ValidatorSet, genAccs [
126128
ConsensusParams: utils.DefaultConsensusParams,
127129
AppStateBytes: stateBytes,
128130
ChainId: TestChainID,
129-
GenesisChecksum: "notwmpty",
131+
GenesisChecksum: "notempty",
130132
},
131133
)
132134

app/upgrades/drs-2/upgrade.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,19 @@ func CreateUpgradeHandler(
1414
configurator module.Configurator,
1515
) upgradetypes.UpgradeHandler {
1616
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
17-
da := rpKeeper.DA(ctx)
18-
version := uint32(2)
19-
params := rollappparamstypes.DefaultParams()
20-
params.Da = da
21-
params.DrsVersion = version
22-
23-
rpKeeper.SetParams(ctx, params)
17+
// upgrade drs to 2
18+
if err := rpKeeper.SetVersion(ctx, uint32(2)); err != nil {
19+
return nil, err
20+
}
2421

22+
if err := HandleUpgrade(ctx, rpKeeper); err != nil {
23+
return nil, err
24+
}
2525
return mm.RunMigrations(ctx, configurator, fromVM)
2626
}
2727
}
28+
29+
func HandleUpgrade(ctx sdk.Context, rpKeeper rollappparamskeeper.Keeper) error {
30+
// migrate rollapp params with missing min-gas-prices
31+
return rpKeeper.SetMinGasPrices(ctx, rollappparamstypes.DefaultParams().MinGasPrices)
32+
}

app/upgrades/drs-3/constants.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package drs3
2+
3+
import (
4+
storetypes "github.com/cosmos/cosmos-sdk/store/types"
5+
6+
"github.com/dymensionxyz/rollapp-wasm/app/upgrades"
7+
)
8+
9+
const (
10+
UpgradeName = "drs-3"
11+
)
12+
13+
var Upgrade = upgrades.Upgrade{
14+
Name: UpgradeName,
15+
CreateHandler: CreateUpgradeHandler,
16+
StoreUpgrades: storetypes.StoreUpgrades{},
17+
}

app/upgrades/drs-3/upgrade.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package drs3
2+
3+
import (
4+
sdk "github.com/cosmos/cosmos-sdk/types"
5+
"github.com/cosmos/cosmos-sdk/types/module"
6+
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
7+
rollappparamskeeper "github.com/dymensionxyz/dymension-rdk/x/rollappparams/keeper"
8+
9+
drs2 "github.com/dymensionxyz/rollapp-wasm/app/upgrades/drs-2"
10+
)
11+
12+
func CreateUpgradeHandler(
13+
rpKeeper rollappparamskeeper.Keeper,
14+
mm *module.Manager,
15+
configurator module.Configurator,
16+
) upgradetypes.UpgradeHandler {
17+
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
18+
if rpKeeper.GetParams(ctx).DrsVersion == 1 {
19+
// first run drs-2 migration
20+
if err := drs2.HandleUpgrade(ctx, rpKeeper); err != nil {
21+
return nil, err
22+
}
23+
}
24+
// upgrade drs to 3
25+
if err := rpKeeper.SetVersion(ctx, uint32(3)); err != nil {
26+
return nil, err
27+
}
28+
return mm.RunMigrations(ctx, configurator, fromVM)
29+
}
30+
}

e2e/testing/chain.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/cosmos/ibc-go/v6/testing/mock"
2929
rollappparamstypes "github.com/dymensionxyz/dymension-rdk/x/rollappparams/types"
3030
seqtypes "github.com/dymensionxyz/dymension-rdk/x/sequencers/types"
31+
"github.com/dymensionxyz/dymint/version"
3132
"github.com/golang/protobuf/proto" //nolint:staticcheck
3233
"github.com/stretchr/testify/require"
3334
abci "github.com/tendermint/tendermint/abci/types"
@@ -248,6 +249,7 @@ func NewTestChain(t *testing.T, chainIdx int, opts ...interface{}) *TestChain {
248249
}
249250
}
250251
genState[slashingTypes.ModuleName] = rollApp.AppCodec().MustMarshalJSON(slashingTypes.NewGenesisState(slashingTypes.DefaultParams(), signInfo, nil))
252+
version.DRS = "1"
251253

252254
rollappParamsState := rollappparamstypes.DefaultGenesisState()
253255
rollappParamsState.Params.DrsVersion = 1

0 commit comments

Comments
 (0)