From 3efa47d0e4ac9e70f54d7ca774b90ae805eefdd8 Mon Sep 17 00:00:00 2001 From: ducphamle2 Date: Wed, 8 May 2024 23:32:33 -0700 Subject: [PATCH] fix: update default params after upgrade & add GOTOOLCHAIN env --- orai/app/app.go | 7 ++++--- orai/app/genesis.go | 11 +++++++++-- orai/scripts/e2e-upgrade.sh | 8 ++++---- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/orai/app/app.go b/orai/app/app.go index 36a55775..aac69d38 100755 --- a/orai/app/app.go +++ b/orai/app/app.go @@ -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) @@ -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() diff --git a/orai/app/genesis.go b/orai/app/genesis.go index d2de8974..351c2f19 100755 --- a/orai/app/genesis.go +++ b/orai/app/genesis.go @@ -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 @@ -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 @@ -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% @@ -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) diff --git a/orai/scripts/e2e-upgrade.sh b/orai/scripts/e2e-upgrade.sh index ea129f5c..5476a1e0 100755 --- a/orai/scripts/e2e-upgrade.sh +++ b/orai/scripts/e2e-upgrade.sh @@ -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 @@ -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 @@ -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 @@ -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