Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce the Altai upgrade #645

Merged
merged 7 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## V1.9.1
This release introduces the Altai upgrade.

* [#645] https://github.com/bnb-chain/greenfield/pull/645 feat: fix the EIP712 signing issue and introduce a new hardfork Altai

## V1.9.0
This release introduces the Mongolian upgrade.

Expand Down
11 changes: 10 additions & 1 deletion app/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import (
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/signer/core/apitypes"
"github.com/stretchr/testify/suite"

"github.com/bnb-chain/greenfield/app"
Expand Down Expand Up @@ -251,7 +253,14 @@ func (suite *AnteTestSuite) CreateTestEIP712CosmosTxBuilder(
msgTypes, signDoc, err := tx.GetMsgTypes(signerData, txBuilder.GetTx(), big.NewInt(9000))
suite.Require().NoError(err)

typedData, err := tx.WrapTxToTypedData(9000, signDoc, msgTypes)
typedDataDomain := apitypes.TypedDataDomain{
Name: "Greenfield Tx",
Version: "1.0.0",
ChainId: math.NewHexOrDecimal256(int64(9000)),
VerifyingContract: "0x71e835aff094655dEF897fbc85534186DbeaB75d",
Salt: "0",
}
typedData, err := tx.WrapTxToTypedData(signDoc, msgTypes, typedDataDomain)
suite.Require().NoError(err)

typedDataJson, _ := json.MarshalIndent(typedData, "", " ")
Expand Down
17 changes: 17 additions & 0 deletions app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (app *App) RegisterUpgradeHandlers(chainID string, serverCfg *serverconfig.
app.registerErdosUpgradeHandler()
app.registerVeldUpgradeHandler()
app.registerMongolianUpgradeHandler()
app.registerAltaiUpgradeHandler()
// app.register...()
// ...
return nil
Expand Down Expand Up @@ -296,3 +297,19 @@ func (app *App) registerMongolianUpgradeHandler() {
return nil
})
}

func (app *App) registerAltaiUpgradeHandler() {
// Register the upgrade handler
app.UpgradeKeeper.SetUpgradeHandler(upgradetypes.Altai,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
app.Logger().Info("upgrade to ", plan.Name)
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

// Register the upgrade initializer
app.UpgradeKeeper.SetUpgradeInitializer(upgradetypes.Altai,
func() error {
app.Logger().Info("Init Altai upgrade")
return nil
})
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ replace (
github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v1.3.0
github.com/cometbft/cometbft-db => github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v1.9.0
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v1.9.2
github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1
github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/wercker/journalhook => github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ github.com/bnb-chain/greenfield-cometbft v1.3.0 h1:v3nZ16ledTZGF5Csys7fTQGZcEV78
github.com/bnb-chain/greenfield-cometbft v1.3.0/go.mod h1:0D+VPivZTeBldjtGGi9LKbBnKEO/RtMRJikie92LkYI=
github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1 h1:XcWulGacHVRiSCx90Q8Y//ajOrLNBQWR/KDB89dy3cU=
github.com/bnb-chain/greenfield-cometbft-db v0.8.1-alpha.1/go.mod h1:ey1CiK4bYo1RBNJLRiVbYr5CMdSxci9S/AZRINLtppI=
github.com/bnb-chain/greenfield-cosmos-sdk v1.9.0 h1:gYelZIgkLe0TEQeBSjuVAyzBvKKz5uAe1A1zhvF33Ws=
github.com/bnb-chain/greenfield-cosmos-sdk v1.9.0/go.mod h1:2bwmwdXYBISnQoMwgAcZTVGt21lMsHZSeeeMByTvDlQ=
github.com/bnb-chain/greenfield-cosmos-sdk v1.9.2 h1:hqZ4v4M3nkBNs1dXbAQkMBrNQuP9maQOSU+rBwzAemQ=
github.com/bnb-chain/greenfield-cosmos-sdk v1.9.2/go.mod h1:2bwmwdXYBISnQoMwgAcZTVGt21lMsHZSeeeMByTvDlQ=
github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230816082903-b48770f5e210 h1:GHPbV2bC+gmuO6/sG0Tm8oGal3KKSRlyE+zPscDjlA8=
github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230816082903-b48770f5e210/go.mod h1:vhsZxXE9tYJeYB5JR4hPhd6Pc/uPf7j1T8IJ7p9FdeM=
github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230816082903-b48770f5e210 h1:FLVOn4+OVbsKi2+YJX5kmD27/4dRu4FW7xCXFhzDO5s=
Expand Down
2 changes: 1 addition & 1 deletion x/bridge/types/message_transfer_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func (msg *MsgTransferOut) ValidateBasic() error {
}

if !msg.Amount.IsValid() {
return errors.Wrapf(sdkerrors.ErrInvalidCoins, msg.Amount.String())
return errors.Wrapf(sdkerrors.ErrInvalidCoins, "%v%s", msg.Amount.Amount, msg.Amount.Denom)
unclezoro marked this conversation as resolved.
Show resolved Hide resolved
}

if !msg.Amount.IsPositive() {
Expand Down
8 changes: 3 additions & 5 deletions x/challenge/keeper/bls_signed_msg.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package keeper

import (
"fmt"

"cosmossdk.io/errors"
"github.com/bits-and-blooms/bitset"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -41,18 +39,18 @@ func (k Keeper) verifySignature(ctx sdk.Context, signedMsg BlsSignedMsg, validat
signedChallengers = append(signedChallengers, val.ChallengerAddress)
votePubKey, err := bls.PublicKeyFromBytes(val.BlsKey)
if err != nil {
return nil, errors.Wrapf(types.ErrInvalidBlsPubKey, fmt.Sprintf("BLS public key converts failed: %v", err))
return nil, errors.Wrapf(types.ErrInvalidBlsPubKey, "BLS public key converts failed: %v", err)
unclezoro marked this conversation as resolved.
Show resolved Hide resolved
}
votedPubKeys = append(votedPubKeys, votePubKey)
}

if len(votedPubKeys) <= len(validators)*2/3 {
return nil, errors.Wrapf(types.ErrNotEnoughVotes, fmt.Sprintf("Not enough validators voted, need: %d, voted: %d", len(validators)*2/3, len(votedPubKeys)))
return nil, errors.Wrapf(types.ErrNotEnoughVotes, "Not enough validators voted, need: %d, voted: %d", len(validators)*2/3, len(votedPubKeys))
}

aggSig, err := bls.SignatureFromBytes(signedMsg.GetVoteAggSignature())
if err != nil {
return nil, errors.Wrapf(types.ErrInvalidVoteAggSignature, fmt.Sprintf("BLS signature converts failed: %v", err))
return nil, errors.Wrapf(types.ErrInvalidVoteAggSignature, "BLS signature converts failed: %v", err)
}

if !aggSig.FastAggregateVerify(votedPubKeys, signedMsg.GetBlsSignBytes(ctx.ChainID())) {
Expand Down
Loading