Skip to content

Commit

Permalink
upgrade before checking out to a different branch to migrate to
Browse files Browse the repository at this point in the history
  • Loading branch information
ranlavanet committed Aug 10, 2022
1 parent bcc8a51 commit 47637e6
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ func New(
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.mm.RegisterServices(module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()))

// setupUpgradeHandlers.
// setupUpgradeHandlers. must be called before LoadLatestVersion as storeloader is sealed after that
app.setupUpgradeHandlers()

// create the simulation manager and define the order of the modules for deterministic simulations
Expand Down Expand Up @@ -642,6 +642,7 @@ func New(
return app
}

// setupUpgradeStoreLoaders when intoducing new modules.
func (app *LavaApp) setupUpgradeStoreLoaders() {
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
Expand All @@ -659,6 +660,7 @@ func (app *LavaApp) setupUpgradeStoreLoaders() {
}
}

// setupUpgradeHandlers when modifing already existing modules
func (app *LavaApp) setupUpgradeHandlers() {
for _, upgrade := range Upgrades {
app.UpgradeKeeper.SetUpgradeHandler(
Expand Down
4 changes: 2 additions & 2 deletions app/upgrades/v3/constants.go → app/upgrades/v2/constants.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package v3
package v2

import (
store "github.com/cosmos/cosmos-sdk/store/types"
"github.com/lavanet/lava/app/upgrades"
)

// UpgradeName defines the on-chain upgrade name for the Osmosis v11 upgrade.
const UpgradeName = "v11"
const UpgradeName = "v2"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package v3
package v2

import (
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
7 changes: 7 additions & 0 deletions scripts/upgrade/env_vars_for_upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
export DAEMON_NAME=lavad
export CHAIN_ID=lava
export DAEMON_HOME=$HOME/.lava
export DAEMON_RESTART_AFTER_UPGRADE=true
export UPRADE_NAME=v2
echo "env vars set"
60 changes: 60 additions & 0 deletions scripts/upgrade/start_upgradeable_module_setup_and_run_node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
MYDIR="$(dirname "$(realpath "$0")")"
echo "$MYDIR"
source $MYDIR/env_vars_for_upgrade.sh

# maybe we need to
# rm -rf $DAEMON_HOME
ignite chain build
ignite chain init

echo "binary name: $DAEMON_NAME"
echo "cosmovisor path: $DAEMON_NAME"
echo "removing old cosmovisor dir $DAEMON_HOME/cosmovisor"
rm -rf $DAEMON_HOME/cosmovisor
echo "creating $DAEMON_HOME/cosmovisor/genesis/bin"
mkdir -p $DAEMON_HOME/cosmovisor/genesis/bin
echo "copying /home/user/go/bin/lavad to $DAEMON_HOME/cosmovisor/genesis/bin"
cp $HOME/go/bin/lavad $DAEMON_HOME/cosmovisor/genesis/bin

cosmovisor start start

# option 1. rebuild, put new binary into the cosmovisor directory of upgrades
# option 2. fetch the binary from a server.

# next step:
# run upgrade a running module from a different terminal.



















# an example for a proposal with upgrade binaries with remote path to binary file. (this requires that the wont be a binary file in
# the cosmovisor upgrade path)

# tx gov submit-proposal software-upgrade Vega \
# --title Vega \
# --deposit 100uatom \
# --upgrade-height 7368420 \
# --upgrade-info '{"binaries":{"linux/amd64":"https://github.com/cosmos/gaia/releases/download/v6.0.0-rc1/gaiad-v6.0.0-rc1-linux-amd64","linux/arm64":"https://github.com/cosmos/gaia/releases/download/v6.0.0-rc1/gaiad-v6.0.0-rc1-linux-arm64","darwin/amd64":"https://github.com/cosmos/gaia/releases/download/v6.0.0-rc1/gaiad-v6.0.0-rc1-darwin-amd64"}}' \
# --description "upgrade to Vega" \
# --gas 400000 \
# --from user \
# --chain-id test \
# --home test/val2 \
# --node tcp://localhost:36657 \
# --yes
28 changes: 28 additions & 0 deletions scripts/upgrade/upgrade_a_running_module.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
MYDIR="$(dirname "$(realpath "$0")")"
echo "$MYDIR"
source $MYDIR/env_vars_for_upgrade.sh
# git checkout some branch here
ignite chain build

echo "mkdir -p $DAEMON_HOME/cosmovisor/upgrades/$UPRADE_NAME/bin"
mkdir -p $DAEMON_HOME/cosmovisor/upgrades/$UPRADE_NAME/bin
cp $HOME/go/bin/lavad $DAEMON_HOME/cosmovisor/upgrades/$UPRADE_NAME/bin
echo "cp $HOME/go/bin/lavad $DAEMON_HOME/cosmovisor/upgrades/$UPRADE_NAME/bin"

for i in $(lavad q block | tr "," "\n");
do
if [[ "$i" == *"height"* ]]; then
BLOCK_HEIGHT=$(echo $i | sed 's/"//g' | sed 's/height://')
break
fi
done

BLOCK_HEIGHT_CHOSEN=$(echo "$((BLOCK_HEIGHT + 20))")

lavad tx gov submit-proposal software-upgrade $UPRADE_NAME --title upgrade --description upgrade --upgrade-height $BLOCK_HEIGHT_CHOSEN --from alice --yes --gas "auto"
lavad tx gov deposit 1 10000000ulava --from alice --yes --gas "auto"
lavad tx gov vote 1 yes --from alice --yes --gas "auto"
echo "chosen block for upgrade: $BLOCK_HEIGHT_CHOSEN"
lavad q upgrade plan
# wait for upgrade.
3 changes: 3 additions & 0 deletions x/epochstorage/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ func (AppModule) ConsensusVersion() uint64 { return 2 }
// BeginBlock executes all ABCI BeginBlock logic respective to the capability module.
func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {

details_test := map[string]string{"height": fmt.Sprintf("%d", ctx.BlockHeight())}
logger_test := am.keeper.Logger(ctx)
utils.LogLavaEvent(ctx, logger_test, "new_block", details_test, "New Block Stated: PRE_CHANGES")
if am.keeper.IsEpochStart(ctx) {

block := uint64(ctx.BlockHeight())
Expand Down

0 comments on commit 47637e6

Please sign in to comment.