Skip to content

Commit

Permalink
feat: changed DRS to be int instead of commit hash (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
srene authored Nov 2, 2024
1 parent d815566 commit fd1f992
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 25 deletions.
1 change: 1 addition & 0 deletions .drs-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ COMMIT := $(shell git log -1 --format='%H')
ifndef BECH32_PREFIX
$(error BECH32_PREFIX is not set)
endif
DRS_VERSION = 1

# don't override user values
ifeq (,$(VERSION))
VERSION := $(shell git describe --tags)
ifeq (,$(NAME))
NAME := $(shell git describe --tags)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
ifeq (,$(NAME))
NAME := $(BRANCH)-$(COMMIT)
endif
endif

Expand All @@ -27,14 +28,13 @@ TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::
export GO111MODULE = on

# process linker flags
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=dymension-rdk \
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(NAME) \
-X github.com/cosmos/cosmos-sdk/version.AppName=rollapp-wasm \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Version=DRS-$(DRS_VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION) \
-X github.com/dymensionxyz/rollapp-wasm/app.AccountAddressPrefix=$(BECH32_PREFIX) \
-X github.com/dymensionxyz/dymension-rdk/x/rollappparams/types.Version=$(COMMIT) \
-X github.com/dymensionxyz/dymint/version.Commit=$(COMMIT)
-X github.com/dymensionxyz/dymint/version.DrsVersion=$(DRS_VERSION)
BUILD_FLAGS := -ldflags '$(ldflags)'


Expand Down
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,8 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
rollappparams := app.RollappParamsKeeper.GetParams(ctx)
abciEndBlockResponse := app.mm.EndBlock(ctx, req)
abciEndBlockResponse.RollappParamUpdates = &abci.RollappParams{
Da: rollappparams.Da,
Version: rollappparams.Version,
Da: rollappparams.Da,
DrsVersion: rollappparams.DrsVersion,
}
return abciEndBlockResponse
}
Expand Down
8 changes: 4 additions & 4 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *types2.ValidatorSet, genAccs [
app, genesisState := setup(true, 5)
genesisState = genesisStateWithValSet(t, app, genesisState, valSet, genAccs, balances...)

genesisState = setRollappVersion(app.appCodec, genesisState, "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0")
genesisState = setRollappVersion(app.appCodec, genesisState, 1)

denomMD := banktypes.Metadata{
Description: "Stake token",
Expand Down Expand Up @@ -204,19 +204,19 @@ func genesisStateWithValSet(t *testing.T,
return genesisState
}

func setRollappVersion(appCodec appcodec.Codec, genesisState GenesisState, version string) GenesisState {
func setRollappVersion(appCodec appcodec.Codec, genesisState GenesisState, version uint32) GenesisState {
var rollappParamsGenesis rollappparamstypes.GenesisState
if genesisState["rollappparams"] != nil {
appCodec.MustUnmarshalJSON(genesisState["rollappparams"], &rollappParamsGenesis)
} else {
rollappParamsGenesis = rollappparamstypes.GenesisState{
Params: rollappparamstypes.Params{
Version: version,
DrsVersion: version,
},
}
}

rollappParamsGenesis.Params.Version = version
rollappParamsGenesis.Params.DrsVersion = version

genesisState["rollappparams"] = appCodec.MustMarshalJSON(&rollappParamsGenesis)

Expand Down
3 changes: 1 addition & 2 deletions e2e/testing/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"math/rand"
"strconv"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -251,7 +250,7 @@ func NewTestChain(t *testing.T, chainIdx int, opts ...interface{}) *TestChain {
genState[slashingTypes.ModuleName] = rollApp.AppCodec().MustMarshalJSON(slashingTypes.NewGenesisState(slashingTypes.DefaultParams(), signInfo, nil))

rollappParamsState := rollappparamstypes.DefaultGenesisState()
rollappParamsState.Params.Version = strings.Repeat("x", 40)
rollappParamsState.Params.DrsVersion = 1
genState[rollappparamstypes.ModuleName] = rollApp.AppCodec().MustMarshalJSON(rollappParamsState)

// Apply genesis options
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ require (
github.com/cosmos/gogoproto v1.5.0
github.com/cosmos/ibc-go/v6 v6.3.0
github.com/dvsekhvalnov/jose2go v1.5.0
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241029165002-545051749bc0
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241024144934-db109b2859b4
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241030213845-88f668faab66
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241031114544-58b9cafae18c
github.com/ethereum/go-ethereum v1.12.0
github.com/evmos/evmos/v12 v12.1.6
github.com/gogo/protobuf v1.3.3
Expand Down Expand Up @@ -360,5 +360,5 @@ replace (
// replace broken goleveldb
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
// use cometbft
github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20241008141942-63af9d24107f
github.com/tendermint/tendermint => github.com/dymensionxyz/cometbft v0.34.29-0.20241030154748-3f9dfa21d17b
)
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -569,14 +569,14 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM=
github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
github.com/dymensionxyz/cometbft v0.34.29-0.20241008141942-63af9d24107f h1:CclWJWRydsd8D4/R1IegIkcWtL4wqTA3MWtXrx1a6y4=
github.com/dymensionxyz/cometbft v0.34.29-0.20241008141942-63af9d24107f/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw=
github.com/dymensionxyz/cometbft v0.34.29-0.20241030154748-3f9dfa21d17b h1:rxkH+9cBG2nnReMavb2FqQXwDLjKcz0/KB8/6SV5Xlo=
github.com/dymensionxyz/cometbft v0.34.29-0.20241030154748-3f9dfa21d17b/go.mod h1:L9shMfbkZ8B+7JlwANEr+NZbBcn+hBpwdbeYvA5rLCw=
github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13 h1:u5yeve5jZR6TdRjjR+vYT/8PWKbhwCZxUmAu+/Tnxyg=
github.com/dymensionxyz/cosmosclient v0.4.2-beta.0.20240821081230-b4018b2bac13/go.mod h1:jabDQYXrccscSE0fXkh7eQFYPWJCRiuWKonFGObVq6s=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241029165002-545051749bc0 h1:Pshmw95Ej/RBg+ZTgMxpdGB/Bpis2tKEjSmqwVHgaXo=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241029165002-545051749bc0/go.mod h1:HH7sGM/4MSI8OLces8axABf7K0ppXNok+G2nxC/l5YI=
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241024144934-db109b2859b4 h1:DpfHfiqNJ0QgnPNq/nx2fAUDWwLlWORQ605uQyPPODU=
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241024144934-db109b2859b4/go.mod h1:FNVdsvVhveAOeL0Mj9VIfGkAUKhGskEr0iRnoM+MAkU=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241030213845-88f668faab66 h1:6fcEO/tyf9bKsyCA/x0nSo5gMig7HDUme2xFqMorkpc=
github.com/dymensionxyz/dymension-rdk v1.6.1-0.20241030213845-88f668faab66/go.mod h1:HH7sGM/4MSI8OLces8axABf7K0ppXNok+G2nxC/l5YI=
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241031114544-58b9cafae18c h1:NiIwXgG8vbPh1a/mRqLK4wOf7W1jvc5Cm4aOCEvx7z8=
github.com/dymensionxyz/dymint v1.2.0-rc01.0.20241031114544-58b9cafae18c/go.mod h1:BTc0Br+c1YyBGeI1O1inU+pxeifDnyzz/Muu/dgDUKI=
github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.4.2 h1:aVP3off7u2vsvRH7lHAUPTLdf9/AfnzC/rvvi0wC/co=
github.com/dymensionxyz/evmos/v12 v12.1.6-dymension-v0.4.2/go.mod h1:CI6D89pkoiIm4BjoMFNnEaCLdKBEobLuwvhS0c1zh7Y=
github.com/dymensionxyz/gerr-cosmos v1.0.0 h1:oi91rgOkpJWr41oX9JOyjvvBnhGY54tj513x8VlDAEc=
Expand Down
8 changes: 8 additions & 0 deletions scripts/init.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash
ROLLAPP_HOME_DIR="$HOME/.rollapp-wasm"

if [ "$EXECUTABLE" = "" ]; then
echo "EXECUTABLE is not set" exit 1
fi

# ---------------------------- initial parameters ---------------------------- #
# Assuming 1,000,000 tokens
#half is staked
Expand Down Expand Up @@ -169,11 +173,15 @@ set_consensus_params() {
;;
esac

VERSION=$($EXECUTABLE version --long | grep DRS-)
DRS_VERSION="${VERSION#*-}"

dasel put -f "$GENESIS_FILE" '.consensus_params.block.max_gas' -v "400000000" || success=false
dasel put -f "$GENESIS_FILE" '.consensus_params.block.max_bytes' -v "$BLOCK_SIZE" || success=false
dasel put -f "$GENESIS_FILE" '.consensus_params.evidence.max_bytes' -v "$BLOCK_SIZE" || success=false
dasel put -f "$GENESIS_FILE" '.app_state.rollappparams.params.version' -v "$COMMIT" || success=false
dasel put -f "$GENESIS_FILE" '.app_state.rollappparams.params.da' -v "$DA" || success=false
dasel put -f "$GENESIS_FILE" '.app_state.rollappparams.params.drs_version' -v $DRS_VERSION -t int || success=false

if [ "$success" = false ]; then
echo "An error occurred. Please refer to README.md"
Expand Down

0 comments on commit fd1f992

Please sign in to comment.