Skip to content

Commit

Permalink
Upgrade 1.7.5 // Turn off liquid vesting module (#317)
Browse files Browse the repository at this point in the history
* feat+chore: upgrade for disable liquid vesting module + clean lint + spellcheck

* fix(ci): proto action

* chore: try fix proto

* chore: bump version in Makefile

* chore: finalize upgrade handler

* chore(ci): fix proto action

* chore: move evm storage utils to utils package + tests

* chore: add fix broken liquid denom periods

* chore: add update vesting priods

* chore: change notes in proto file
  • Loading branch information
kioqq authored May 16, 2024
1 parent c1d86ea commit 9f7b1fd
Show file tree
Hide file tree
Showing 95 changed files with 825 additions and 268 deletions.
29 changes: 13 additions & 16 deletions .github/workflows/proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ name: Protobuf
# Protobuf runs buf (https://buf.build/) lint and check-breakage
# This workflow is only run when a .proto file has been changed
on:
branches-ignore:
- 'coinomics_v2' # NOTE: breaking changes are not really breaking as they are introduced in a module which was never deployed on chain
workflow_dispatch:
pull_request:
# paths:
# - "proto/**"

jobs:
proto-pass:
Expand All @@ -16,12 +12,12 @@ jobs:
needs:
- build
- lint
- break-check
# - break-check
steps:
- run: exit 0

build:
name: Check that proto builds and commited
name: Check that proto builds and committed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -42,13 +38,14 @@ jobs:
with:
input: "proto"

break-check:
name: Proto break-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/[email protected]
- uses: bufbuild/buf-breaking-action@v1
with:
input: "proto"
against: "https://github.com/${{ github.repository }}.git#branch=${{ github.event.pull_request.base.ref }},ref=HEAD~1,subdir=proto"
# NOTE: This is disabled only for this merge request, it will be enabled in master branch
# break-check:
# name: Proto break-check
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: bufbuild/[email protected]
# - uses: bufbuild/buf-breaking-action@v1
# with:
# input: "proto"
# against: "https://github.com/${{ github.repository }}.git#branch=${{ github.event.pull_request.base.ref }},ref=HEAD~1,subdir=proto"
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DIFF_TAG=$(shell git rev-list --tags="v*" --max-count=1 --not $(shell git rev-li
DEFAULT_TAG=$(shell git rev-list --tags="v*" --max-count=1)
# VERSION ?= $(shell echo $(shell git describe --tags $(or $(DIFF_TAG), $(DEFAULT_TAG))) | sed 's/^v//')

VERSION := "1.7.4"
VERSION := "1.7.5"
CBFTVERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
Expand Down Expand Up @@ -437,10 +437,11 @@ lint-fix-contracts:

.PHONY: lint lint-fix

format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs goimports -w -local github.com/haqq-network/haqq
format:
find . -name '*.go' -type f -not -path "./.devenv/*" -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./.devenv/*" -not -path "./vendor*" -not -path "*.git*" -not -path "./.direnv/*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs codespell -w
find . -name '*.go' -type f -not -path "./.devenv/*" -not -path "./vendor*" -not -path "*.git*" -not -path "./.direnv/*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs goimports -w -local github.com/haqq-network/haqq

.PHONY: format

###############################################################################
Expand Down Expand Up @@ -477,7 +478,7 @@ proto-swagger-gen:

proto-format:
@echo "Formatting Protobuf files"
find ./ -not -path ".//.devenv/*" -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \;
find ./ -not -path "./.devenv/*" -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \;

proto-lint:
@$(DOCKER_BUF) lint --error-format=json
Expand Down
2 changes: 1 addition & 1 deletion app/ante/cosmos/authz.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (ald AuthzLimiterDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
// maxNestedMsgs threshold. If there are more than that limit, it returns an error
func (ald AuthzLimiterDecorator) checkDisabledMsgs(msgs []sdk.Msg, isAuthzInnerMsg bool, nestedLvl int) error {
if nestedLvl >= maxNestedMsgs {
return fmt.Errorf("found more nested msgs than permited. Limit is : %d", maxNestedMsgs)
return fmt.Errorf("found more nested msgs than permitted. Limit is : %d", maxNestedMsgs)
}
for _, msg := range msgs {
switch msg := msg.(type) {
Expand Down
4 changes: 2 additions & 2 deletions app/ante/cosmos/eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ func VerifySignature(

txWithExtensions, ok := tx.(authante.HasExtensionOptionsTx)
if !ok {
return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "tx doesnt contain any extensions")
return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "tx does not contain any extensions")
}
opts := txWithExtensions.GetExtensionOptions()
if len(opts) != 1 {
return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "tx doesnt contain expected amount of extension options")
return errorsmod.Wrap(errortypes.ErrUnknownExtensionOptions, "tx does not contain expected amount of extension options")
}

extOpt, ok := opts[0].GetCachedValue().(*types.ExtensionOptionsWeb3Tx)
Expand Down
2 changes: 1 addition & 1 deletion app/ante/cosmos/min_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (mpd MinGasPriceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
// Fees not provided (or flag "auto"). Then use the base fee to make the check pass
if feeCoins == nil {
return ctx, errorsmod.Wrapf(errortypes.ErrInsufficientFee,
"fee not provided. Please use the --fees flag or the --gas-price flag along with the --gas flag to estimate the fee. The minimun global fee for this tx is: %s",
"fee not provided. Please use the --fees flag or the --gas-price flag along with the --gas flag to estimate the fee. The minimum global fee for this tx is: %s",
requiredFees)
}

Expand Down
6 changes: 3 additions & 3 deletions app/ante/cosmos/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ func createNestedMsgExec(a sdk.AccAddress, nestedLvl int, lastLvlMsgs []sdk.Msg)
return msgs[nestedLvl-1]
}

func generatePrivKeyAddressPairs(accCount int) ([]*ethsecp256k1.PrivKey, []sdk.AccAddress, error) {
func generatePrivKeyAddressPairs(account int) ([]*ethsecp256k1.PrivKey, []sdk.AccAddress, error) {
var (
err error
testPrivKeys = make([]*ethsecp256k1.PrivKey, accCount)
testAddresses = make([]sdk.AccAddress, accCount)
testPrivKeys = make([]*ethsecp256k1.PrivKey, account)
testAddresses = make([]sdk.AccAddress, account)
)

for i := range testPrivKeys {
Expand Down
2 changes: 1 addition & 1 deletion app/ante/evm/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula
if ctx.IsReCheckTx() {
// Use new context with gasWanted = 0
// Otherwise, there's an error on txmempool.postCheck (tendermint)
// that is not bubbled up. Thus, the Tx never runs on DeliverMode
// that is not bubbled up. Thus, the Tx never runs on deliverymode
// Error: "gas wanted -1 is negative"
// For more information, see issue #1554
// https://github.com/evmos/ethermint/issues/1554
Expand Down
2 changes: 1 addition & 1 deletion app/ante/evm/eth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (suite *AnteTestSuite) TestEthNonceVerificationDecorator() {
{"invalid transaction type", &testutiltx.InvalidTx{}, func() {}, false, false},
{"sender account not found", tx, func() {}, false, false},
{
"sender nonce missmatch",
"sender nonce mismatch",
tx,
func() {
acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr.Bytes())
Expand Down
4 changes: 2 additions & 2 deletions app/ante/evm/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (suite *AnteTestSuite) CreateTestEIP712MsgCreateValidator(from sdk.AccAddre
valAddr,
privEd.PubKey(),
sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)),
stakingtypes.NewDescription("moniker", "indentity", "website", "security_contract", "details"),
stakingtypes.NewDescription("moniker", "identity", "website", "security_contract", "details"),
stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()),
sdk.OneInt(),
)
Expand All @@ -227,7 +227,7 @@ func (suite *AnteTestSuite) CreateTestEIP712MsgCreateValidator2(from sdk.AccAddr
privEd.PubKey(),
sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20)),
// Ensure optional fields can be left blank
stakingtypes.NewDescription("moniker", "indentity", "", "", ""),
stakingtypes.NewDescription("moniker", "identity", "", "", ""),
stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()),
sdk.OneInt(),
)
Expand Down
7 changes: 7 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ import (
v172 "github.com/haqq-network/haqq/app/upgrades/v1.7.2"
v173 "github.com/haqq-network/haqq/app/upgrades/v1.7.3"
v174 "github.com/haqq-network/haqq/app/upgrades/v1.7.4"
v175 "github.com/haqq-network/haqq/app/upgrades/v1.7.5"

// NOTE: override ICS20 keeper to support IBC transfers of ERC20 tokens
"github.com/haqq-network/haqq/x/ibc/transfer"
Expand Down Expand Up @@ -1268,6 +1269,12 @@ func (app *Haqq) setupUpgradeHandlers() {
v174.CreateUpgradeHandler(app.mm, app.configurator, app.AccountKeeper, app.LiquidVestingKeeper),
)

// v1.7.5 Turn off liquid vesting
app.UpgradeKeeper.SetUpgradeHandler(
v175.UpgradeName,
v175.CreateUpgradeHandler(app.mm, app.configurator, app.BankKeeper, app.LiquidVestingKeeper, app.Erc20Keeper, *app.EvmKeeper, app.AccountKeeper),
)

// When a planned update height is reached, the old binary will panic
// writing on disk the height and name of the update that triggered it
// This will read that value, and execute the preparations for the upgrade.
Expand Down
1 change: 1 addition & 0 deletions app/forks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package app

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/haqq-network/haqq/utils"
)

Expand Down
1 change: 1 addition & 0 deletions app/haqq_ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

// distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
// govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
Expand Down
1 change: 1 addition & 0 deletions app/upgrades/v1.6.0/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/haqq-network/haqq/utils"

banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand Down
2 changes: 2 additions & 0 deletions app/upgrades/v1.6.4/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

"github.com/haqq-network/haqq/utils"

distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

coinomicskeeper "github.com/haqq-network/haqq/x/coinomics/keeper"
coinomicstypes "github.com/haqq-network/haqq/x/coinomics/types"
)
Expand Down
1 change: 1 addition & 0 deletions app/upgrades/v1.7.0/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibctmmigrations "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint/migrations"

coinomicstypes "github.com/haqq-network/haqq/x/coinomics/types"
evmtypes "github.com/haqq-network/haqq/x/evm/types"
feemarkettypes "github.com/haqq-network/haqq/x/feemarket/types"
Expand Down
4 changes: 2 additions & 2 deletions app/upgrades/v1.7.4/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func StretchLockupScheduleForAccounts(ctx sdk.Context, ak authkeeper.AccountKeep
upcomingPeriods := liquidvestingtypes.ExtractUpcomingPeriods(vacc.GetStartTime(), vacc.GetEndTime(), vacc.LockupPeriods, ctx.BlockTime().Unix())
pastPeriods := liquidvestingtypes.ExtractPastPeriods(vacc.GetStartTime(), vacc.GetEndTime(), vacc.LockupPeriods, ctx.BlockTime().Unix())

// streched upcoming periods
// stretched upcoming periods
stretchedUpcomingPeriods := stretchPeriods(ctx, upcomingPeriods, stretchLength, "account", vacc.GetAddress().String())

// add 1095 days (three years to the end time)
Expand Down Expand Up @@ -67,7 +67,7 @@ func StretchLockupScheduleForLiquidVestingTokens(ctx sdk.Context, lk liquidvesti
upcomingPeriods := liquidvestingtypes.ExtractUpcomingPeriods(denom.StartTime.Unix(), denom.EndTime.Unix(), denom.LockupPeriods, ctx.BlockTime().Unix())
pastPeriods := liquidvestingtypes.ExtractPastPeriods(denom.StartTime.Unix(), denom.EndTime.Unix(), denom.LockupPeriods, ctx.BlockTime().Unix())

// streched upcoming periods
// stretched upcoming periods
stretchedUpcomingPeriods := stretchPeriods(ctx, upcomingPeriods, stretchLength, "liquid", denom.DisplayDenom)

// add 1095 days (three years to the end time)
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/v1.7.4/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
liquidvestingkeeper "github.com/haqq-network/haqq/x/liquidvesting/keeper"
)

// CreateUpgradeHandler creates an SDK upgrade handler for v1.7.3
// CreateUpgradeHandler creates an SDK upgrade handler for v1.7.4
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
Expand Down
6 changes: 6 additions & 0 deletions app/upgrades/v1.7.5/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package v175

const (
// UpgradeName is the shared upgrade plan name for network
UpgradeName = "v1.7.5"
)
Loading

0 comments on commit 9f7b1fd

Please sign in to comment.