Skip to content

Commit

Permalink
v6-rc5 patches (#169)
Browse files Browse the repository at this point in the history
* prepare for v6-rc5 upgrade

* remove v5

* update mint token function

* comment out pstake minting for v6-rc5

* update

* temp: change tombstone hegith

* print error

* tester

* final fixes to app

* fix app for mainnet branch

* change upgrade name to v6
  • Loading branch information
Anmol1696 authored Dec 26, 2022
1 parent 41458eb commit 372bbed
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 31 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,3 @@ jobs:
.go
.mod
.sum
- uses: golangci/golangci-lint-action@v2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
args: -e SA1019 --timeout 10m
github-token: ${{ secrets.GITHUB_TOKEN }}
if: "env.GIT_DIFF != ''"
25 changes: 20 additions & 5 deletions app/upgrades/v6/testnet_records.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,42 @@ var testnetRecordsJsonString = `[
{
"address": "persistence1l73w6tufnqc8qz5j2xqnq0zxlnp9fj7lwu9twx",
"amount": "49995000000",
"validator_address": "persistencevaloper1mgd6a660ysram7a0m8ytmjvryneywgm8mg7lcs"
"validator_address": "persistencevaloper1we6rg5vk3rcucjfdls0lv34s0ta4yt3d6gavks"
},
{
"address": "persistence1ww7ce2p4cgeh4mu0wed87muc870ffplpywen3v",
"amount": "4",
"validator_address": "persistencevaloper1mgd6a660ysram7a0m8ytmjvryneywgm8mg7lcs"
"validator_address": "persistencevaloper1we6rg5vk3rcucjfdls0lv34s0ta4yt3d6gavks"
},
{
"address": "persistence1wgxw92gakmng7x05kujsy2er0djj3ywlwyvtr0",
"amount": "34963751573",
"validator_address": "persistencevaloper1mgd6a660ysram7a0m8ytmjvryneywgm8mg7lcs"
"validator_address": "persistencevaloper1we6rg5vk3rcucjfdls0lv34s0ta4yt3d6gavks"
},
{
"address": "persistence1ygqsx4r2u25um8jfmn04uzt7cpy30c453q5uxd",
"amount": "250000000",
"validator_address": "persistencevaloper1mgd6a660ysram7a0m8ytmjvryneywgm8mg7lcs"
"validator_address": "persistencevaloper1we6rg5vk3rcucjfdls0lv34s0ta4yt3d6gavks"
},
{
"address": "persistence1cq7ah0j7vwrdluwca0xctya92cu85fxknnalxh",
"amount": "12549500",
"validator_address": "persistencevaloper1mgd6a660ysram7a0m8ytmjvryneywgm8mg7lcs"
"validator_address": "persistencevaloper1we6rg5vk3rcucjfdls0lv34s0ta4yt3d6gavks"
},
{
"address": "persistence1wgxw92gakmng7x05kujsy2er0djj3ywlwyvtr0",
"amount": "34963751573",
"validator_address": "persistencevaloper1l6vm4v6gu7hk0uq70sc2drl36aypwlrkkhd54r"
},
{
"address": "persistence1ygqsx4r2u25um8jfmn04uzt7cpy30c453q5uxd",
"amount": "250000000",
"validator_address": "persistencevaloper1l6vm4v6gu7hk0uq70sc2drl36aypwlrkkhd54r"
},
{
"address": "persistence1cq7ah0j7vwrdluwca0xctya92cu85fxknnalxh",
"amount": "12549500",
"validator_address": "persistencevaloper1l6vm4v6gu7hk0uq70sc2drl36aypwlrkkhd54r"
}
]
`
25 changes: 13 additions & 12 deletions app/upgrades/v6/untombstoning.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package v6
import (
"encoding/json"
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
Expand All @@ -28,7 +27,8 @@ type Validator struct {

// Create new Validator vars for each validator that needs to be untombstoned
var (
mainnetVals = []Validator{
tombstoneHeight int64 = 8647536 // hegith at which chain was upgraded, which casued the tombstoned event
mainnetVals = []Validator{
{"HashQuark", "persistencevaloper1gydvxcnm95zwdz7h7whpmusy5d5c3ck0p9muc9", "persistencevalcons1dmjc55ve2pe537hu8h8rjrjhp4r536g5jlnlk8"},
{"fox99", "persistencevaloper1y2svn2zvc0puv3rx6w39aa4zlgj7qe0fz8sh6x", "persistencevalcons1ak5f5ywzmersz4z7e3nsqkem4uvf5jyya62w3c"},
{"Smart Stake", "persistencevaloper1qtggtsmexluvzulehxs7ypsfl82yk5aznrr2zd", "persistencevalcons1gnevun33uphh9cwkyzau5mcf0fxvuw6cyrf29g"},
Expand All @@ -37,7 +37,8 @@ var (
}
// testnetVals holds the validators to untombstone
testnetVals = []Validator{
{"TombRaider", "persistencevaloper1mgd6a660ysram7a0m8ytmjvryneywgm8mg7lcs", "persistence1mgd6a660ysram7a0m8ytmjvryneywgm8jv7z3f"},
{"Eternal", "persistencevaloper1we6rg5vk3rcucjfdls0lv34s0ta4yt3d6gavks", "persistencevalcons15q4w9plw8mke6jdzmvsnztwn9ulegwnzgs6zhw"},
{"Doom", "persistencevaloper1l6vm4v6gu7hk0uq70sc2drl36aypwlrkkhd54r", "persistencevalcons1jqdmg26psflpslj42afuq5ndalsyjv0wrh3ssm"},
}
)

Expand All @@ -48,18 +49,13 @@ func mintLostTokens(
mintKeeper *mintkeeper.Keeper,
mintRecord CosMints,
) error {
cosValAddress, err := sdk.ValAddressFromBech32(mintRecord.Delegatee)
if err != nil {
return fmt.Errorf("validator address is not valid bech32: %s", cosValAddress)
}

coinAmount, _ := sdk.NewIntFromString(mintRecord.AmountUxprt)

coin := sdk.NewCoin("uxprt", coinAmount)
coins := sdk.NewCoins(coin)

// due to huge amount of log lines generated, supress logger
err = mintKeeper.MintCoins(ctx.WithLogger(tmlog.NewNopLogger()), coins)
err := mintKeeper.MintCoins(ctx.WithLogger(tmlog.NewNopLogger()), coins)
if err != nil {
return fmt.Errorf("error minting %suxprt to %s: %+v", mintRecord.AmountUxprt, mintRecord.Address, err)
}
Expand All @@ -79,6 +75,11 @@ func mintLostTokens(
return fmt.Errorf("account address is not valid bech32: %s", mintRecord.Address)
}

cosValAddress, err := sdk.ValAddressFromBech32(mintRecord.Delegatee)
if err != nil {
return fmt.Errorf("validator address is not valid bech32: %s", cosValAddress)
}

cosValidator, found := stakingKeeper.GetValidator(ctx, cosValAddress)
if !found {
return fmt.Errorf("cos validator '%s' not found", cosValAddress)
Expand Down Expand Up @@ -106,7 +107,7 @@ func revertTombstone(ctx sdk.Context, slashingKeeper *slashingkeeper.Keeper, val
signInfo, ok := slashingKeeper.GetValidatorSigningInfo(ctx, cosConsAddress)

if !ok {
return fmt.Errorf("cannot tombstone validator that does not have any signing information: %s", cosConsAddress.String())
return fmt.Errorf("cannot untombstone validator that does not have any signing information: %s", cosConsAddress.String())
}
if !signInfo.Tombstoned {
return fmt.Errorf("cannut untombstone a validator that is not tombstoned: %s", cosConsAddress.String())
Expand Down Expand Up @@ -134,7 +135,7 @@ func RevertCosTombstoning(
if ctx.ChainID() == "core-1" || ctx.ChainID() == "test-core-1" {
var Mints []CosMints
var vals []Validator
if ctx.ChainID() == "core-1" || ctx.BlockHeight() > 88647536 {
if ctx.ChainID() == "core-1" || ctx.BlockHeight() > tombstoneHeight {
var cosMints []CosMints
err := json.Unmarshal([]byte(recordsJsonString), &cosMints)
if err != nil {
Expand All @@ -143,7 +144,7 @@ func RevertCosTombstoning(
Mints = append(Mints, cosMints...)
vals = append(vals, mainnetVals...)
}
if ctx.ChainID() == "test-core-1" || ctx.BlockHeight() > 8647536 {
if ctx.ChainID() == "test-core-1" || ctx.BlockHeight() > tombstoneHeight {
var cosMints []CosMints
err := json.Unmarshal([]byte(testnetRecordsJsonString), &cosMints)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions shuttle/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ delete:
###############################################################################
### Test commands ###
###############################################################################
OFFSET_HEIGHT = 80
UPGRADE_NAME = v6
OFFSET_HEIGHT = 50
UPGRADE_NAME = v6-rc5
CHAIN_ID = $(shell yq -r ".chains[0].name" $(FILE))

setup-client: clean-keys
Expand Down Expand Up @@ -93,4 +93,4 @@ port-forward-all-exposers:

.PHONY: stop-forward
stop-forward:
-pkill -f "port-forward"
-@pkill -f "port-forward"
7 changes: 3 additions & 4 deletions shuttle/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ chains:
upgrade:
enabled: true
type: build
genesis: v5.0.1
genesis: v6.0.0-rc4
upgrades:
- name: v6
version: anmol/v6-testing
- name: v6-rc5
version: anmol/v6-rc5
ports:
rpc: 26657
rest: 1317
p2p: 26656
exposer: 9080

explorer:
enabled: true

0 comments on commit 372bbed

Please sign in to comment.