Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into release/v3.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
omritoptix committed Dec 16, 2024
2 parents 6a27852 + 21acc35 commit 9c3650d
Show file tree
Hide file tree
Showing 18 changed files with 744 additions and 33 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/generate_genesis_template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Generate Genesis Template
on: ["push"]
jobs:
build:
runs-on: ubuntu-latest
name: Generate Genesis Template
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.23.1"

- name: Install Dasel
run: |
curl -sSLf https://github.com/TomWright/dasel/releases/latest/download/dasel_linux_amd64 -o /usr/local/bin/dasel
chmod +x /usr/local/bin/dasel
- name: Generate genesis template mainnet
run: make generate-genesis env=mainnet
env:
BECH32_PREFIX: ethm

- name: Generate genesis template testnet
run: make generate-genesis env=testnet
env:
BECH32_PREFIX: ethm
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ubuntu:latest as go-builder

# Install necessary dependencies
RUN apt-get update && apt-get install -y \
wget make git \
wget make git build-essential \
&& rm -rf /var/lib/apt/lists/*

# Download and install Go 1.21
Expand All @@ -17,8 +17,6 @@ ENV GOROOT=/usr/local/go
ENV GOPATH=$HOME/go
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH

RUN apt-get update -y
RUN apt-get install build-essential -y
# Set the working directory
WORKDIR /app

Expand All @@ -40,6 +38,8 @@ RUN ARCH=$(uname -m) && WASMVM_VERSION=$(go list -m github.com/CosmWasm/wasmvm |
wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm.aarch64.so \
-O /lib/libwasmvm.aarch64.so

RUN go install -v github.com/bcdevtools/devd/v2/cmd/devd@latest

# Copy the remaining files
COPY . .

Expand All @@ -48,7 +48,9 @@ RUN make build BECH32_PREFIX=ethm
FROM ubuntu:latest

RUN apt-get update -y
RUN apt-get install -y curl

COPY --from=go-builder /go/bin/devd /usr/local/bin/devd
COPY --from=go-builder /app/build/rollapp-evm /usr/local/bin/rollappd
COPY --from=go-builder /lib/libwasmvm.x86_64.so /lib/libwasmvm.x86_64.so
COPY --from=go-builder /lib/libwasmvm.aarch64.so /lib/libwasmvm.aarch64.so
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PROJECT_NAME=rollappd
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
DRS_VERSION = 2
DRS_VERSION = 3

#ifndef $(CELESTIA_NETWORK)
# CELESTIA_NETWORK=mock
Expand Down
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ import (

"github.com/dymensionxyz/rollapp-evm/app/upgrades"
drs2 "github.com/dymensionxyz/rollapp-evm/app/upgrades/drs-2"
drs3 "github.com/dymensionxyz/rollapp-evm/app/upgrades/drs-3"
)

const (
Expand All @@ -185,7 +186,7 @@ var (
erc20types.StoreKey,
}
// Upgrades contains the upgrade handlers for the application
Upgrades = []upgrades.Upgrade{drs2.Upgrade}
Upgrades = []upgrades.Upgrade{drs2.Upgrade, drs3.Upgrade}
)

func getGovProposalHandlers() []govclient.ProposalHandler {
Expand Down
38 changes: 25 additions & 13 deletions app/upgrades/drs-2/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,35 @@ func CreateUpgradeHandler(
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {

//migrate rollapp params with missing min-gas-prices and updating drs to 2
err := rpKeeper.SetVersion(ctx, uint32(2))
if err != nil {
return nil, err
}
err = rpKeeper.SetMinGasPrices(ctx, rollappparamstypes.DefaultParams().MinGasPrices)
if err != nil {
// upgrade drs to 2
if err := rpKeeper.SetVersion(ctx, uint32(2)); err != nil {
return nil, err
}
//migrate evm params with missing gasDenom
evmParams := evmKeeper.GetParams(ctx)
evmParams.GasDenom = evmParams.EvmDenom
err = evmKeeper.SetParams(ctx, evmParams)
if err != nil {

if err := HandleUpgrade(ctx, rpKeeper, evmKeeper); err != nil {
return nil, err
}
return mm.RunMigrations(ctx, configurator, fromVM)
}
}

func HandleUpgrade(
ctx sdk.Context,
rpKeeper rollappparamskeeper.Keeper,
evmKeeper *evmkeeper.Keeper,
) error {
// migrate rollapp params with missing min-gas-prices
if err := rpKeeper.SetMinGasPrices(ctx, rollappparamstypes.DefaultParams().MinGasPrices); err != nil {
return err
}

// migrate evm params with missing gasDenom
evmParams := evmKeeper.GetParams(ctx)
evmParams.GasDenom = evmParams.EvmDenom

if err := evmKeeper.SetParams(ctx, evmParams); err != nil {
return err
}

return nil
}
17 changes: 17 additions & 0 deletions app/upgrades/drs-3/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package drs3

import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"

"github.com/dymensionxyz/rollapp-evm/app/upgrades"
)

const (
UpgradeName = "drs-3"
)

var Upgrade = upgrades.Upgrade{
Name: UpgradeName,
CreateHandler: CreateUpgradeHandler,
StoreUpgrades: storetypes.StoreUpgrades{},
}
33 changes: 33 additions & 0 deletions app/upgrades/drs-3/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package drs3

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
rollappparamskeeper "github.com/dymensionxyz/dymension-rdk/x/rollappparams/keeper"
evmkeeper "github.com/evmos/evmos/v12/x/evm/keeper"

drs2 "github.com/dymensionxyz/rollapp-evm/app/upgrades/drs-2"
)

func CreateUpgradeHandler(
rpKeeper rollappparamskeeper.Keeper,
evmKeeper *evmkeeper.Keeper,
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
if rpKeeper.GetParams(ctx).DrsVersion == 1 {
// first run drs-2 migration
if err := drs2.HandleUpgrade(ctx, rpKeeper, evmKeeper); err != nil {
return nil, err
}
}
// upgrade drs to 3
err := rpKeeper.SetVersion(ctx, uint32(3))
if err != nil {
return nil, err
}
return mm.RunMigrations(ctx, configurator, fromVM)
}
}
7 changes: 6 additions & 1 deletion cmd/rollappd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ func initRootCmd(
) {
// Set config
sdkconfig := sdk.GetConfig()
rdk_utils.SetPrefixes(sdkconfig, app.AccountAddressPrefix)
// Add ability to override bech32 prefix from env variable
prefix := app.AccountAddressPrefix
if overridePrefix := os.Getenv("OVERRIDE_BECH32"); overridePrefix != "" {
prefix = overridePrefix
}
rdk_utils.SetPrefixes(sdkconfig, prefix)
utils.SetBip44CoinType(sdkconfig)
sdkconfig.Seal()

Expand Down
4 changes: 3 additions & 1 deletion genesis-templates/DRS/1/genesis-mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@
"evm_denom": "aevmos",
"enable_create": true,
"enable_call": true,
"extra_eips": "3855",
"extra_eips": [
"3855"
],
"chain_config": {
"homestead_block": "0",
"dao_fork_block": "0",
Expand Down
4 changes: 3 additions & 1 deletion genesis-templates/DRS/1/genesis-testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@
"evm_denom": "aevmos",
"enable_create": true,
"enable_call": true,
"extra_eips": "3855",
"extra_eips": [
"3855"
],
"chain_config": {
"homestead_block": "0",
"dao_fork_block": "0",
Expand Down
6 changes: 4 additions & 2 deletions genesis-templates/DRS/2/genesis-mainnet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"genesis_time": "2024-12-12T14:04:22.649885Z",
"genesis_time": "2024-12-12T17:19:38.388208Z",
"chain_id": "rollappevm_1234-1",
"initial_height": "1",
"consensus_params": {
Expand Down Expand Up @@ -130,7 +130,9 @@
"evm_denom": "aevmos",
"enable_create": true,
"enable_call": true,
"extra_eips": "3855",
"extra_eips": [
"3855"
],
"chain_config": {
"homestead_block": "0",
"dao_fork_block": "0",
Expand Down
6 changes: 4 additions & 2 deletions genesis-templates/DRS/2/genesis-testnet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"genesis_time": "2024-12-12T14:04:05.281694Z",
"genesis_time": "2024-12-12T17:19:55.783133Z",
"chain_id": "rollappevm_1234-1",
"initial_height": "1",
"consensus_params": {
Expand Down Expand Up @@ -130,7 +130,9 @@
"evm_denom": "aevmos",
"enable_create": true,
"enable_call": true,
"extra_eips": "3855",
"extra_eips": [
"3855"
],
"chain_config": {
"homestead_block": "0",
"dao_fork_block": "0",
Expand Down
Loading

0 comments on commit 9c3650d

Please sign in to comment.