Skip to content

Commit

Permalink
Merge pull request #8 from oraidex/add-event-ibc-auto-forward
Browse files Browse the repository at this point in the history
dang/Add upgrade handler
  • Loading branch information
GNaD13 authored Jan 13, 2025
2 parents 1272964 + 53017e8 commit c8b3fcd
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 16 deletions.
8 changes: 8 additions & 0 deletions module/app/upgrades/monitorevent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# monitorevent UPGRADE

The _Monitor Event_ upgrade contains the following changes.

## Summary of Changes

- Add event for tracking packet receive from EVM chain

3 changes: 3 additions & 0 deletions module/app/upgrades/monitorevent/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package monitorevent

var UpgradeName = "monitorevent"
16 changes: 16 additions & 0 deletions module/app/upgrades/monitorevent/handler.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package monitorevent

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func GetUpgradeHandler(
mm *module.Manager,
configurator *module.Configurator,
) func(ctx sdk.Context, plan upgradetypes.Plan, vmap module.VersionMap) (module.VersionMap, error) {
return func(ctx sdk.Context, plan upgradetypes.Plan, vmap module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, *configurator, vmap)
}
}
6 changes: 6 additions & 0 deletions module/app/upgrades/register.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package upgrades

import (
"github.com/Gravity-Bridge/Gravity-Bridge/module/app/upgrades/monitorevent"
"github.com/Gravity-Bridge/Gravity-Bridge/module/app/upgrades/singlestep"
gravitykeeper "github.com/Gravity-Bridge/Gravity-Bridge/module/x/gravity/keeper"
"github.com/cosmos/cosmos-sdk/types/module"
Expand Down Expand Up @@ -71,4 +72,9 @@ func RegisterUpgradeHandlers(
singlestep.PlanName,
singlestep.GetUpgradeHandler(mm, configurator, crisisKeeper),
)

upgradeKeeper.SetUpgradeHandler(
monitorevent.UpgradeName,
monitorevent.GetUpgradeHandler(mm, configurator),
)
}
32 changes: 16 additions & 16 deletions module/scripts/e2e/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ set -ux

# setup the network using the old binary

OLD_VERSION=${OLD_VERSION:-"v1.0.3"}
OLD_VERSION=${OLD_VERSION:-"v1.0.7"}
ARGS="--chain-id testing -y --keyring-backend test --fees 200uoraib --gas auto --gas-adjustment 1.5 -b block"
NEW_VERSION=${NEW_VERSION:-"txidevent"}
NEW_VERSION=${NEW_VERSION:-"monitorevent"}
VALIDATOR_HOME=${VALIDATOR_HOME:-"$HOME/.gravity/validator1"}

# kill all running binaries
Expand All @@ -21,29 +21,29 @@ cd $current_dir
sh $PWD/scripts/multi_local_node.sh

# test send from cosmos to eth
gravity tx gravity send-to-eth 0x0000000000000000000000000000000000071001 12500000000000000000oraib0x0000000000000000000000000000000000C0FFEE 1000000000000000000oraib0x0000000000000000000000000000000000C0FFEE 2500000000000000oraib0x0000000000000000000000000000000000C0FFEE oraib --fees 10uoraib --from orchestrator1 --chain-id testing --home $HOME/.gravity/validator1 --keyring-backend test -y -b block
#gravity tx gravity send-to-eth 0x0000000000000000000000000000000000071001 12500000000000000000oraib0x0000000000000000000000000000000000C0FFEE 1000000000000000000oraib0x0000000000000000000000000000000000C0FFEE 2500000000000000oraib0x0000000000000000000000000000000000C0FFEE oraib --fees 10uoraib --from orchestrator1 --chain-id testing --home $HOME/.gravity/validator1 --keyring-backend test -y -b block

# test send request batch, can not set this on because client cli of this request-batch
# at v1.0.3 version is wrong format
# gravity tx gravity request-batch oraib0x0000000000000000000000000000000000C0FFEE oraib --fees 10uoraib --from orchestrator1 --chain-id testing --home $HOME/.gravity/validator1 --keyring-backend test -y

# create new upgrade proposal, turn this on when we need real proposal
# UPGRADE_HEIGHT=${UPGRADE_HEIGHT:-19}
# gravity tx gov submit-proposal software-upgrade $NEW_VERSION --title "foobar" --description "foobar" --from validator1 --upgrade-height $UPGRADE_HEIGHT --upgrade-info "x" --deposit 10000000uoraib $ARGS --home $VALIDATOR_HOME
# gravity tx gov vote 1 yes --from validator1 --home "$HOME/.gravity/validator1" $ARGS && gravity tx gov vote 1 yes --from validator2 --home "$HOME/.gravity/validator2" $ARGS
UPGRADE_HEIGHT=${UPGRADE_HEIGHT:-19}
gravity tx gov submit-proposal software-upgrade $NEW_VERSION --title "foobar" --description "foobar" --from validator1 --upgrade-height $UPGRADE_HEIGHT --upgrade-info "x" --deposit 10000000uoraib $ARGS --home $VALIDATOR_HOME
gravity tx gov vote 1 yes --from validator1 --home "$HOME/.gravity/validator1" $ARGS && gravity tx gov vote 1 yes --from validator2 --home "$HOME/.gravity/validator2" $ARGS

# # sleep to wait til the proposal passes
# echo "Sleep til the proposal passes..."
# sleep 12
echo "Sleep til the proposal passes..."
sleep 12

# # Check if latest height is less than the upgrade height
# latest_height=$(curl --no-progress-meter http://localhost:1317/blocks/latest | jq '.block.header.height | tonumber')
# while [ $latest_height -lt $UPGRADE_HEIGHT ];
# do
# sleep 5
# ((latest_height=$(curl --no-progress-meter http://localhost:1317/blocks/latest | jq '.block.header.height | tonumber')))
# echo $latest_height
# done
latest_height=$(curl --no-progress-meter http://localhost:1317/blocks/latest | jq '.block.header.height | tonumber')
while [ $latest_height -lt $UPGRADE_HEIGHT ];
do
sleep 5
((latest_height=$(curl --no-progress-meter http://localhost:1317/blocks/latest | jq '.block.header.height | tonumber')))
echo $latest_height
done

# kill all processes
pkill gravity
Expand Down Expand Up @@ -109,4 +109,4 @@ inflation=$(curl --no-progress-meter http://localhost:1317/cosmos/mint/v1beta1/i
if ! [[ $inflation =~ $re ]] ; then
echo "Error: Cannot query inflation => Potentially missing Go GRPC backport" >&2;
echo "Tests Failed"; exit 1
fi
fi

0 comments on commit c8b3fcd

Please sign in to comment.