Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
fix: update default params after upgrade & add GOTOOLCHAIN env
Browse files Browse the repository at this point in the history
  • Loading branch information
ducphamle2 committed May 9, 2024
1 parent ee711cc commit 3efa47d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
7 changes: 4 additions & 3 deletions orai/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,8 +1110,8 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino

func (app *OraichainApp) upgradeHandler() {
app.upgradeKeeper.SetUpgradeHandler(BinaryVersion, func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("start to migrate modules...")
ctx.Logger().Info("vm module: %v\n", fromVM)
response, err := app.mm.RunMigrations(ctx, app.configurator, fromVM)
ctx.Logger().Info("Start updating evm and fee market params...")
defaultEvmParams := evmtypes.DefaultParams()
defaultEvmParams.EvmDenom = appconfig.EvmDenom // orai aka 10^-6
app.evmKeeper.SetParams(ctx, defaultEvmParams)
Expand All @@ -1122,7 +1122,8 @@ func (app *OraichainApp) upgradeHandler() {
defaultFeeMarketParams.NoBaseFee = true
defaultFeeMarketParams.BaseFeeChangeDenominator = 2
app.feeMarketKeeper.SetParams(ctx, defaultFeeMarketParams)
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
ctx.Logger().Info("Finished updating evm and fee market params...")
return response, err
})

upgradeInfo, err := app.upgradeKeeper.ReadUpgradeInfoFromDisk()
Expand Down
11 changes: 9 additions & 2 deletions orai/app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
staking "github.com/cosmos/cosmos-sdk/x/staking/types"
appconfig "github.com/oraichain/orai/cmd/config"
evm "github.com/tharsis/ethermint/x/evm/types"
feemarket "github.com/tharsis/ethermint/x/feemarket/types"
)

// GenesisState default state for the application
Expand All @@ -26,6 +27,7 @@ func NewDefaultGenesisState(cdc codec.Codec) GenesisState {
govGenesis := gov.DefaultGenesisState()
crisisGenesis := crisis.DefaultGenesisState()
evmGenesis := evm.DefaultGenesisState()
feemarketGenesis := feemarket.DefaultGenesisState()

stakingGenesis.Params.BondDenom = appconfig.Bech32Prefix
stakingGenesis.Params.HistoricalEntries = 1000
Expand All @@ -49,7 +51,12 @@ func NewDefaultGenesisState(cdc codec.Codec) GenesisState {

// update default evm denom of evm module
evmGenesis.Params.EvmDenom = appconfig.EvmDenom
genesisState[evm.ModuleName] = cdc.MustMarshalJSON((evmGenesis))
genesisState[evm.ModuleName] = cdc.MustMarshalJSON(evmGenesis)

feemarketGenesis.Params.BaseFee = sdk.NewInt(1)
feemarketGenesis.Params.BaseFeeChangeDenominator = 2
feemarketGenesis.Params.NoBaseFee = true
genesisState[feemarket.ModuleName] = cdc.MustMarshalJSON(feemarketGenesis)

// slashingGenesis.Params.SignedBlocksWindow = 30000 // approximately 1 day
// slashingGenesis.Params.MinSignedPerWindow = sdk.NewDecWithPrec(5, 2) // 5%
Expand All @@ -60,7 +67,7 @@ func NewDefaultGenesisState(cdc codec.Codec) GenesisState {

for _, b := range ModuleBasics {
name := b.Name()
if name == staking.ModuleName || name == mint.ModuleName || name == gov.ModuleName || name == crisis.ModuleName || name == evm.ModuleName {
if name == staking.ModuleName || name == mint.ModuleName || name == gov.ModuleName || name == crisis.ModuleName || name == evm.ModuleName || name == feemarket.ModuleName {
continue
}
genesisState[b.Name()] = b.DefaultGenesis(cdc)
Expand Down
8 changes: 4 additions & 4 deletions orai/scripts/e2e-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pkill oraid && sleep 2

# download current production binary
current_dir=$PWD
rm -rf ../../orai-old/ && git clone https://github.com/oraichain/orai.git ../../orai-old && cd ../../orai-old/orai && git checkout $OLD_VERSION && go mod tidy && make install
rm -rf ../../orai-old/ && git clone https://github.com/oraichain/orai.git ../../orai-old && cd ../../orai-old/orai && git checkout $OLD_VERSION && go mod tidy && GOTOOLCHAIN=go1.21.4 make install

cd $current_dir

Expand All @@ -31,7 +31,7 @@ contract_address=$(oraid query wasm list-contract-by-code $code_id --output json
echo "contract address: $contract_address"

# create new upgrade proposal
UPGRADE_HEIGHT=${UPGRADE_HEIGHT:-40}
UPGRADE_HEIGHT=${UPGRADE_HEIGHT:-35}
oraid tx gov submit-proposal software-upgrade $NEW_VERSION --title "foobar" --description "foobar" --from validator1 --upgrade-height $UPGRADE_HEIGHT --upgrade-info "x" --deposit 10000000orai $ARGS --home $VALIDATOR_HOME
oraid tx gov vote 1 yes --from validator1 --home "$HOME/.oraid/validator1" $ARGS && oraid tx gov vote 1 yes --from validator2 --home "$HOME/.oraid/validator2" $ARGS

Expand All @@ -52,7 +52,7 @@ pkill oraid

# install new binary for the upgrade
echo "install new binary"
make install
GOTOOLCHAIN=go1.21.4 make install

# re-run all validators. All should run
screen -S validator1 -d -m oraid start --home=$HOME/.oraid/validator1 --minimum-gas-prices=0.00001orai
Expand All @@ -61,7 +61,7 @@ screen -S validator3 -d -m oraid start --home=$HOME/.oraid/validator3 --minimum-

# sleep a bit for the network to start
echo "Sleep to wait for the network to start..."
sleep 5
sleep 3

# kill oraid again to modify json rpc address for each validator (only for the ethermint upgrade)
pkill oraid
Expand Down

0 comments on commit 3efa47d

Please sign in to comment.