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

release: prepare for release v1.2.0 #538

Merged
merged 11 commits into from
Dec 14, 2023
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
# Changelog
## v1.2.0
This release introduces the Manchurian upgrade to the testnet.

Features:
* [#525](https://github.com/bnb-chain/greenfield/pull/525) feat: introduce the Eddystone upgrade
* [#526](https://github.com/bnb-chain/greenfield/pull/526) feat: add new msg MsgSetTag

Chore:
* [#527](https://github.com/bnb-chain/greenfield/pull/527) chore: cleanup legacy annotation
* [#535](https://github.com/bnb-chain/greenfield/pull/535) chore: update fields of EventSetTag
* [#536](https://github.com/bnb-chain/greenfield/pull/536) chore: change max length limit of resource tags key value

Bugfixes:
* [#532](https://github.com/bnb-chain/greenfield/pull/532) fix: restrict on creating GVG and allow empty family
* [#522](https://github.com/bnb-chain/greenfield/pull/522) fix: bucket status causing event emitted

## v1.1.1
This release introduces the Pampas upgrade to the mainnet.
Expand Down
9 changes: 9 additions & 0 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ func (suite *AnteTestSuite) TestAnteHandler() {
return txBuilder.GetTx()
}, true, false, true,
},
{
"success - DeliverTx EIP712 signed Cosmos Tx MsgCreateBucket",
func() sdk.Tx {
gas := uint64(16e3)
fee := sdk.NewCoins(sdk.NewCoin(test.TEST_TOKEN_NAME, sdk.NewIntFromUint64(gas)))
txBuilder := suite.CreateTestEIP712TxBuilderMsgCreateBucket(addr, privKey, test.TEST_CHAIN_ID, gas, fee)
return txBuilder.GetTx()
}, true, false, true,
},
{
"fails - DeliverTx legacy msg MsgSubmitProposal v1beta",
func() sdk.Tx {
Expand Down
19 changes: 19 additions & 0 deletions app/ante/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import (
"github.com/bnb-chain/greenfield/sdk/keys"
"github.com/bnb-chain/greenfield/testutil"
"github.com/bnb-chain/greenfield/testutil/sample"
"github.com/bnb-chain/greenfield/types/common"
storagetypes "github.com/bnb-chain/greenfield/x/storage/types"
)

type AnteTestSuite struct {
Expand Down Expand Up @@ -205,6 +207,23 @@ func (suite *AnteTestSuite) CreateTestEIP712TxBuilderMsgGrant(from sdk.AccAddres
return suite.CreateTestEIP712CosmosTxBuilder(from, priv, chainId, gas, gasAmount, msgGrant)
}

func (suite *AnteTestSuite) CreateTestEIP712TxBuilderMsgCreateBucket(from sdk.AccAddress, priv keys.KeyManager, chainId string, gas uint64, gasAmount sdk.Coins) client.TxBuilder {
msgCreateBucket := &storagetypes.MsgCreateBucket{
Creator: from.String(),
BucketName: "test",
Visibility: 0,
PaymentAddress: from.String(),
PrimarySpAddress: from.String(),
PrimarySpApproval: &common.Approval{
ExpiredHeight: 1,
GlobalVirtualGroupFamilyId: 1,
Sig: []byte("test"),
},
ChargedReadQuota: 0,
}
return suite.CreateTestEIP712CosmosTxBuilder(from, priv, chainId, gas, gasAmount, msgCreateBucket)
}

func (suite *AnteTestSuite) CreateTestEIP712CosmosTxBuilder(
from sdk.AccAddress, priv keys.KeyManager, chainId string, gas uint64, gasAmount sdk.Coins, msg sdk.Msg,
) client.TxBuilder {
Expand Down
24 changes: 24 additions & 0 deletions app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
gashubtypes "github.com/cosmos/cosmos-sdk/x/gashub/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

bridgemoduletypes "github.com/bnb-chain/greenfield/x/bridge/types"
Expand All @@ -22,6 +23,7 @@ func (app *App) RegisterUpgradeHandlers(chainID string, serverCfg *serverconfig.
// Register the upgrade handlers here
app.registerNagquUpgradeHandler()
app.registerPampasUpgradeHandler()
app.registerManchurianUpgradeHandler()
// app.register...()
// ...
return nil
Expand Down Expand Up @@ -104,3 +106,25 @@ func (app *App) registerPampasUpgradeHandler() {
return nil
})
}

func (app *App) registerManchurianUpgradeHandler() {
// Register the upgrade handler
app.UpgradeKeeper.SetUpgradeHandler(upgradetypes.Manchurian,
func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
app.Logger().Info("upgrade to ", plan.Name)

typeUrl := sdk.MsgTypeURL(&storagemoduletypes.MsgSetTag{})
msgSetTagGasParams := gashubtypes.NewMsgGasParamsWithFixedGas(typeUrl, 1.2e3)
app.GashubKeeper.SetMsgGasParams(ctx, *msgSetTagGasParams)

return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

// Register the upgrade initializer
app.UpgradeKeeper.SetUpgradeInitializer(upgradetypes.Manchurian,
func() error {
app.Logger().Info("Init Manchurian upgrade")

return nil
})
}
6 changes: 2 additions & 4 deletions cmd/gnfd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import (
)

var (
appConfig *app.AppConfig = app.NewDefaultAppConfig()
appConfig = app.NewDefaultAppConfig()
)

// NewRootCmd creates a new root command for a Cosmos SDK application
Expand All @@ -64,7 +64,7 @@ func NewRootCmd() (*cobra.Command, appparams.EncodingConfig) {

rootCmd := &cobra.Command{
Use: app.ShortName,
Short: "Stargate CosmosHub App",
Short: "Greenfield Daemon(server)",
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
// set the default command outputs
cmd.SetOut(cmd.OutOrStdout())
Expand Down Expand Up @@ -181,7 +181,6 @@ func initRootCmd(
tmcli.NewCompletionCmd(rootCmd, true),
debug.Cmd(),
config.Cmd(),
// this line is used by starport scaffolding # root/commands
)

a := appCreator{
Expand Down Expand Up @@ -287,7 +286,6 @@ func txCommand() *cobra.Command {

func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
// this line is used by starport scaffolding # root/arguments
}

func overwriteFlagDefaults(c *cobra.Command, defaults map[string]string) {
Expand Down
1 change: 1 addition & 0 deletions deployment/localup/localup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ function generate_genesis() {
sed -i -e "s/log_level = \"info\"/\log_level= \"debug\"/g" ${workspace}/.local/validator${i}/config/config.toml
echo -e '[[upgrade]]\nname = "Nagqu"\nheight = 20\ninfo = ""' >> ${workspace}/.local/validator${i}/config/app.toml
echo -e '[[upgrade]]\nname = "Pampas"\nheight = 20\ninfo = ""' >> ${workspace}/.local/validator${i}/config/app.toml
echo -e '[[upgrade]]\nname = "Manchurian"\nheight = 20\ninfo = ""' >> ${workspace}/.local/validator${i}/config/app.toml
done

# enable swagger API for validator0
Expand Down
35 changes: 35 additions & 0 deletions e2e/tests/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/bnb-chain/greenfield/sdk/keys"
"github.com/bnb-chain/greenfield/sdk/types"
storageutils "github.com/bnb-chain/greenfield/testutil/storage"
types2 "github.com/bnb-chain/greenfield/types"
sptypes "github.com/bnb-chain/greenfield/x/sp/types"
storagetypes "github.com/bnb-chain/greenfield/x/storage/types"
)
Expand Down Expand Up @@ -2073,3 +2074,37 @@ func (s *StorageTestSuite) TestMaintenanceSPCreateBucketAndObject() {
// s.Require().Error(err)
// s.Require().Equal(queryHeadBucketResponse.BucketInfo.BucketStatus, storagetypes.BUCKET_STATUS_CREATED)
//}

func (s *StorageTestSuite) TestSetTag() {
var err error
user := s.GenAndChargeAccounts(1, 1000000)

// CreateBucket
sp := s.BaseSuite.PickStorageProvider()
gvg, found := sp.GetFirstGlobalVirtualGroup()
s.Require().True(found)

bucketName := storageutils.GenRandomBucketName()
msgCreateBucket := storagetypes.NewMsgCreateBucket(
user[0].GetAddr(), bucketName, storagetypes.VISIBILITY_TYPE_PUBLIC_READ, sp.OperatorKey.GetAddr(),
nil, math.MaxUint, nil, 0)
msgCreateBucket.PrimarySpApproval.GlobalVirtualGroupFamilyId = gvg.FamilyId
msgCreateBucket.PrimarySpApproval.Sig, err = sp.ApprovalKey.Sign(msgCreateBucket.GetApprovalBytes())
s.Require().NoError(err)
s.SendTxBlock(user[0], msgCreateBucket)

// Set tag
grn := types2.NewBucketGRN(bucketName)
var tags storagetypes.ResourceTags
tags.Tags = append(tags.Tags, storagetypes.ResourceTags_Tag{Key: "key1", Value: "value1"})
msgSetTag := storagetypes.NewMsgSetTag(user[0].GetAddr(), grn.String(), &tags)
s.SendTxBlock(user[0], msgSetTag)

// Query
req := storagetypes.QueryHeadBucketRequest{
BucketName: bucketName,
}
resp, err := s.Client.HeadBucket(context.Background(), &req)
s.Require().NoError(err)
s.Require().Equal(tags, *resp.BucketInfo.Tags)
}
103 changes: 93 additions & 10 deletions e2e/tests/virtualgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ func TestVirtualGroupTestSuite(t *testing.T) {
suite.Run(t, new(VirtualGroupTestSuite))
}

func (s *VirtualGroupTestSuite) getSecondarySPIDs(primarySPID uint32) []uint32 {
var secondarySPIDs []uint32
for _, ssp := range s.StorageProviders {
if ssp.Info.Id != primarySPID {
secondarySPIDs = append(secondarySPIDs, ssp.Info.Id)
}
if len(secondarySPIDs) == 6 {
break
}
}
return secondarySPIDs
}

func (s *VirtualGroupTestSuite) queryGlobalVirtualGroup(gvgID uint32) *virtualgroupmoduletypes.GlobalVirtualGroup {
resp, err := s.Client.GlobalVirtualGroup(
context.Background(),
Expand All @@ -50,7 +63,7 @@ func (s *VirtualGroupTestSuite) queryGlobalVirtualGroup(gvgID uint32) *virtualgr
return resp.GlobalVirtualGroup
}

func (s *VirtualGroupTestSuite) queryGlobalVirtualGroupByFamily(familyID uint32) []*virtualgroupmoduletypes.GlobalVirtualGroup {
func (s *VirtualGroupTestSuite) queryGlobalVirtualGroupsByFamily(familyID uint32) []*virtualgroupmoduletypes.GlobalVirtualGroup {
s.T().Logf("familyID: %d", familyID)
resp, err := s.Client.GlobalVirtualGroupByFamilyID(
context.Background(),
Expand Down Expand Up @@ -93,17 +106,12 @@ func (s *VirtualGroupTestSuite) TestBasic() {
availableGvgFamilyIds := s.queryAvailableGlobalVirtualGroupFamilies([]uint32{gvg.FamilyId})
s.Require().Equal(availableGvgFamilyIds[0], gvg.FamilyId)

srcGVGs := s.queryGlobalVirtualGroupByFamily(gvg.FamilyId)
srcGVGs := s.queryGlobalVirtualGroupsByFamily(gvg.FamilyId)

var secondarySPIDs []uint32
for _, ssp := range s.StorageProviders {
if ssp.Info.Id != primarySP.Info.Id {
secondarySPIDs = append(secondarySPIDs, ssp.Info.Id)
}
}
secondarySPIDs := s.getSecondarySPIDs(primarySP.Info.Id)
s.BaseSuite.CreateGlobalVirtualGroup(primarySP, gvg.FamilyId, secondarySPIDs, 1)

gvgs = s.queryGlobalVirtualGroupByFamily(gvg.FamilyId)
gvgs = s.queryGlobalVirtualGroupsByFamily(gvg.FamilyId)
s.Require().Equal(len(gvgs), len(srcGVGs)+1)

oldGVGIDs := make(map[uint32]bool)
Expand Down Expand Up @@ -159,7 +167,7 @@ func (s *VirtualGroupTestSuite) TestBasic() {
}
s.SendTxBlock(primarySP.OperatorKey, &msgDeleteGVG)

newGVGs := s.queryGlobalVirtualGroupByFamily(newGVG.FamilyId)
newGVGs := s.queryGlobalVirtualGroupsByFamily(newGVG.FamilyId)

for _, gvg := range newGVGs {
if gvg.Id == newGVG.Id {
Expand Down Expand Up @@ -203,6 +211,26 @@ func (s *VirtualGroupTestSuite) TestBasic() {
}
s.SendTxBlockWithExpectErrorString(&msgCreateGVG, primarySP.OperatorKey, virtualgroupmoduletypes.ErrDuplicateSecondarySP.Error())

// test create a duplicated GVG in a family
secondarySPIDs = s.getSecondarySPIDs(primarySP.Info.Id)
gvgID, familyID := s.BaseSuite.CreateGlobalVirtualGroup(primarySP, 0, secondarySPIDs, 1)
gvgResp, err := s.Client.VirtualGroupQueryClient.GlobalVirtualGroup(context.Background(), &virtualgroupmoduletypes.QueryGlobalVirtualGroupRequest{
GlobalVirtualGroupId: gvgID,
})
s.Require().NoError(err)
s.Require().Equal(secondarySPIDs, gvgResp.GlobalVirtualGroup.SecondarySpIds)
s.Require().Equal(familyID, gvgResp.GlobalVirtualGroup.FamilyId)

msgCreateGVG = virtualgroupmoduletypes.MsgCreateGlobalVirtualGroup{
StorageProvider: primarySP.OperatorKey.GetAddr().String(),
FamilyId: familyID,
SecondarySpIds: secondarySPIDs,
Deposit: sdk.Coin{
Denom: s.Config.Denom,
Amount: types.NewIntFromInt64WithDecimal(1, types.DecimalBNB),
},
}
s.SendTxBlockWithExpectErrorString(&msgCreateGVG, primarySP.OperatorKey, virtualgroupmoduletypes.ErrDuplicateGVG.Error())
}

func (s *VirtualGroupTestSuite) TestSettle() {
Expand Down Expand Up @@ -679,3 +707,58 @@ CheckProposalStatus:
s.T().Errorf("update params failed")
}
}

func (s *VirtualGroupTestSuite) TestEmptyGlobalVirtualGroupFamily() {
primarySP := s.BaseSuite.PickStorageProvider()
user := s.GenAndChargeAccounts(1, 1000000)[0]

secondarySPIDs := s.getSecondarySPIDs(primarySP.Info.Id)

// The Sp creates a family which has 1 GVG.
gvgID, familyID := s.BaseSuite.CreateGlobalVirtualGroup(primarySP, 0, secondarySPIDs, 1)
gvgs := s.queryGlobalVirtualGroupsByFamily(familyID)
s.Require().Equal(1, len(gvgs))

// a User creates an object served by this GVG
bucketName := storagetestutil.GenRandomBucketName()
objectName := storagetestutil.GenRandomObjectName()
s.BaseSuite.CreateObject(user, primarySP, gvgID, bucketName, objectName)

// The User deletes the object
s.SendTxBlock(user, storagetypes.NewMsgDeleteObject(user.GetAddr(), bucketName, objectName))

// object isn't found onchain
_, err := s.Client.HeadObject(context.Background(), &storagetypes.QueryHeadObjectRequest{
BucketName: bucketName,
ObjectName: objectName,
})
s.Require().Error(err)

// The SP deletes the GVG
msgDeleteGVG := virtualgroupmoduletypes.MsgDeleteGlobalVirtualGroup{
StorageProvider: primarySP.OperatorKey.GetAddr().String(),
GlobalVirtualGroupId: gvgID,
}
s.SendTxBlock(primarySP.OperatorKey, &msgDeleteGVG)
_, err = s.Client.GlobalVirtualGroup(context.Background(), &virtualgroupmoduletypes.QueryGlobalVirtualGroupRequest{GlobalVirtualGroupId: gvgID})
s.Require().Error(err)

// The bucket onchain still shows the family info, and the family is indeed exist
bucket, err := s.Client.HeadBucket(context.Background(), &storagetypes.QueryHeadBucketRequest{
BucketName: bucketName,
})
s.Require().NoError(err)
s.Require().Equal(familyID, bucket.BucketInfo.GlobalVirtualGroupFamilyId)

family, err := s.Client.GlobalVirtualGroupFamily(context.Background(), &virtualgroupmoduletypes.QueryGlobalVirtualGroupFamilyRequest{
FamilyId: bucket.BucketInfo.GlobalVirtualGroupFamilyId,
})
s.Require().NoError(err)
s.Require().Equal(0, len(family.GlobalVirtualGroupFamily.GlobalVirtualGroupIds))

//the SP can create new GVG on this empty family
newGVGID, _ := s.BaseSuite.CreateGlobalVirtualGroup(primarySP, familyID, secondarySPIDs, 1)
gvgs = s.queryGlobalVirtualGroupsByFamily(familyID)
s.Require().Equal(1, len(gvgs))
s.Require().Equal(gvgs[0].Id, newGVGID)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ replace (
github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v1.1.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.1.1
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v1.2.0
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.1.0 h1:jqnkDWIZW6f/rUn5/pE26YZMT9xzp
github.com/bnb-chain/greenfield-cometbft v1.1.0/go.mod h1:NZ2/ZJK2HYe3++0CsPiw4LTG6UrC6pH7fQ3VOz6pqJw=
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.1.1 h1:wAg2caLOe2hjQVKZVWv5+tDwPox8irme82Eomc220oY=
github.com/bnb-chain/greenfield-cosmos-sdk v1.1.1/go.mod h1:Yrvq+J1Lsm7OHFX+M/AZWBTGt1TRHUTC4VYOMlvW3fs=
github.com/bnb-chain/greenfield-cosmos-sdk v1.2.0 h1:oxwxEiwF+Dani7vr9//nybjrTNLfk2rnO7PjpWSNrNI=
github.com/bnb-chain/greenfield-cosmos-sdk v1.2.0/go.mod h1:Yrvq+J1Lsm7OHFX+M/AZWBTGt1TRHUTC4VYOMlvW3fs=
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: 0 additions & 2 deletions proto/greenfield/bridge/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ package greenfield.bridge;
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";

// this line is used by starport scaffolding # proto/tx/import

option go_package = "github.com/bnb-chain/greenfield/x/bridge/types";

enum RefundReason {
Expand Down
3 changes: 0 additions & 3 deletions proto/greenfield/bridge/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import "greenfield/bridge/params.proto";

option go_package = "github.com/bnb-chain/greenfield/x/bridge/types";

// this line is used by starport scaffolding # genesis/proto/import

// GenesisState defines the bridge module's genesis state.
message GenesisState {
// Params defines all the paramaters of the module.
Params params = 1 [(gogoproto.nullable) = false];
// this line is used by starport scaffolding # genesis/proto/state
}
Loading
Loading