Skip to content

Commit

Permalink
fix: add amino register and change proto for ucdao module (#333)
Browse files Browse the repository at this point in the history
* fix: add amino register and change proto for ucdao module

* test: integration tests now run twice to test direct and legacy amino sing modes on txs

* chore: add upgrade handler, bump app version

* chore: update swagger

---------

Co-authored-by: Yuri Surbashev <yurist@insport.net>
  • Loading branch information
kioqq and Yurist-85 authored Aug 1, 2024
1 parent 31c96a3 commit 3058d8f
Show file tree
Hide file tree
Showing 42 changed files with 923 additions and 10,319 deletions.
2 changes: 1 addition & 1 deletion 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.7"
VERSION := "1.7.8"
CBFTVERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
Expand Down
3 changes: 2 additions & 1 deletion app/ante/cosmos/fees_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"cosmossdk.io/math"
sdktestutil "github.com/cosmos/cosmos-sdk/testutil/testdata"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/feegrant"

cosmosante "github.com/haqq-network/haqq/app/ante/cosmos"
Expand Down Expand Up @@ -311,7 +312,7 @@ func (suite *AnteTestSuite) TestDeductFeeDecorator() {
suite.ctx = suite.ctx.WithIsCheckTx(tc.checkTx)

// Create a transaction out of the message
tx, err := testutiltx.PrepareCosmosTx(suite.ctx, suite.app, args)
tx, err := testutiltx.PrepareCosmosTx(suite.ctx, suite.app, args, signing.SignMode_SIGN_MODE_DIRECT)
suite.Require().NoError(err, "failed to create transaction")

// run the ante handler
Expand Down
18 changes: 13 additions & 5 deletions app/ante/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

"github.com/haqq-network/haqq/crypto/ethsecp256k1"
Expand All @@ -16,13 +17,17 @@ import (
"github.com/haqq-network/haqq/utils"
)

var _ = Describe("when sending a Cosmos transaction", func() {
var _ = DescribeTableSubtree("when sending a Cosmos transaction", func(signMode signing.SignMode) {
var (
addr sdk.AccAddress
priv *ethsecp256k1.PrivKey
msg sdk.Msg
)

BeforeEach(func() {
s.SetupTest()
})

Context("and the sender account has enough balance to pay for the transaction cost", Ordered, func() {
var (
rewardsAmt = sdk.NewInt(1e5)
Expand All @@ -48,7 +53,7 @@ var _ = Describe("when sending a Cosmos transaction", func() {
})

It("should succeed & not withdraw any staking rewards", func() {
res, err := testutil.DeliverTx(s.ctx, s.app, priv, nil, msg)
res, err := testutil.DeliverTx(s.ctx, s.app, priv, nil, signMode, msg)
Expect(err).To(BeNil())
Expect(res.IsOK()).To(BeTrue())

Expand Down Expand Up @@ -83,7 +88,7 @@ var _ = Describe("when sending a Cosmos transaction", func() {
})

It("should fail", func() {
res, err := testutil.DeliverTx(s.ctx, s.app, priv, nil, msg)
res, err := testutil.DeliverTx(s.ctx, s.app, priv, nil, signMode, msg)
Expect(res.IsOK()).To(BeTrue())
Expect(err).To(HaveOccurred())
})
Expand Down Expand Up @@ -126,9 +131,12 @@ var _ = Describe("when sending a Cosmos transaction", func() {
balance := s.app.BankKeeper.GetBalance(s.ctx, addr, utils.BaseDenom)
Expect(balance.Amount).To(Equal(sdk.NewInt(0)))

res, err := testutil.DeliverTx(s.ctx, s.app, priv, nil, msg)
res, err := testutil.DeliverTx(s.ctx, s.app, priv, nil, signMode, msg)
Expect(res.IsOK()).To(BeTrue())
Expect(err).To(BeNil())
})
})
})
},
Entry("Direct sign mode", signing.SignMode_SIGN_MODE_DIRECT),
Entry("Legacy Amino JSON sign mode", signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON),
)
72 changes: 7 additions & 65 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,6 @@ import (
vestingkeeper "github.com/haqq-network/haqq/x/vesting/keeper"
vestingtypes "github.com/haqq-network/haqq/x/vesting/types"

v160 "github.com/haqq-network/haqq/app/upgrades/v1.6.0"
v161 "github.com/haqq-network/haqq/app/upgrades/v1.6.1"
v162 "github.com/haqq-network/haqq/app/upgrades/v1.6.2"
v163 "github.com/haqq-network/haqq/app/upgrades/v1.6.3"
v164 "github.com/haqq-network/haqq/app/upgrades/v1.6.4"
v170 "github.com/haqq-network/haqq/app/upgrades/v1.7.0"
v171 "github.com/haqq-network/haqq/app/upgrades/v1.7.1"
v172 "github.com/haqq-network/haqq/app/upgrades/v1.7.2"
Expand All @@ -173,6 +168,7 @@ import (
v175 "github.com/haqq-network/haqq/app/upgrades/v1.7.5"
v176 "github.com/haqq-network/haqq/app/upgrades/v1.7.6"
v177 "github.com/haqq-network/haqq/app/upgrades/v1.7.7"
v178 "github.com/haqq-network/haqq/app/upgrades/v1.7.8"

// NOTE: override ICS20 keeper to support IBC transfers of ERC20 tokens
"github.com/haqq-network/haqq/x/ibc/transfer"
Expand Down Expand Up @@ -1196,60 +1192,6 @@ func initParamsKeeper(
}

func (app *Haqq) setupUpgradeHandlers() {
// v1.6.0 Security upgrade
app.UpgradeKeeper.SetUpgradeHandler(
v160.UpgradeName,
v160.CreateUpgradeHandler(
app.mm,
app.configurator,
app.AccountKeeper,
app.StakingKeeper,
app.SlashingKeeper,
app.BankKeeper,
),
)

// v1.6.1 Security upgrade
app.UpgradeKeeper.SetUpgradeHandler(
v161.UpgradeName,
v161.CreateUpgradeHandler(
app.mm,
app.configurator,
app.AccountKeeper,
),
)

// v1.6.2 Evergreen fix
app.UpgradeKeeper.SetUpgradeHandler(
v162.UpgradeName,
v162.CreateUpgradeHandler(
app.mm,
app.configurator,
app.AccountKeeper,
app.BankKeeper,
app.DistrKeeper,
),
)

// v1.6.3 RPC Balances fix
app.UpgradeKeeper.SetUpgradeHandler(
v163.UpgradeName,
v163.CreateUpgradeHandler(app.mm, app.configurator),
)

// v1.6.4 Coinomics v2
app.UpgradeKeeper.SetUpgradeHandler(
v164.UpgradeName,
v164.CreateUpgradeHandler(
app.mm,
app.configurator,
app.GetKey(coinomicstypes.StoreKey),
app.GetKey(paramstypes.StoreKey),
app.DistrKeeper,
app.CoinomicsKeeper,
),
)

// v1.7.0 Upgrade SDK, CometBFT and IBC
app.UpgradeKeeper.SetUpgradeHandler(
v170.UpgradeName,
Expand Down Expand Up @@ -1305,6 +1247,12 @@ func (app *Haqq) setupUpgradeHandlers() {
v177.CreateUpgradeHandler(app.mm, app.configurator),
)

// v1.7.8 Fix Amino codec in United Contributors DAO module and improve integration tests
app.UpgradeKeeper.SetUpgradeHandler(
v178.UpgradeName,
v178.CreateUpgradeHandler(app.mm, app.configurator),
)

// 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 All @@ -1320,12 +1268,6 @@ func (app *Haqq) setupUpgradeHandlers() {
var storeUpgrades *storetypes.StoreUpgrades

switch upgradeInfo.Name {
case v160.UpgradeName:
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{
icahosttypes.SubModuleName,
},
}
case v170.UpgradeName:
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{
Expand Down
Loading

0 comments on commit 3058d8f

Please sign in to comment.