Skip to content

Commit

Permalink
Merge pull request #524 from bnb-chain/develop
Browse files Browse the repository at this point in the history
release: prepare release for v1.1.0
  • Loading branch information
j75689 committed Nov 13, 2023
2 parents 23e0d01 + 47463b5 commit d220814
Show file tree
Hide file tree
Showing 21 changed files with 1,928 additions and 1,327 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/buf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: bufbuild/buf-setup-action@v1
- uses: bufbuild/buf-setup-action@v1.28.0
- run: buf format --diff --exit-code
- name: Install Go
uses: actions/setup-go@v3
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
# Changelog

## v1.1.0
This release contains 2 new features, 3 bugfixes and 6 chores.
This release contains 4 new features, 5 bugfixes and 6 chores.

Features:
* [#493](https://github.com/bnb-chain/greenfield/pull/493) feat: support reject bucket migration
* [#504](https://github.com/bnb-chain/greenfield/pull/504) feat: add a hardfork for the link to opBNB
* [#520](https://github.com/bnb-chain/greenfield/pull/520) feat: shuffle the result of StorageProviders query method
* [#521](https://github.com/bnb-chain/greenfield/pull/521) feat: disable sp exit and bucket migration msg

Bugfixes:
* [#506](https://github.com/bnb-chain/greenfield/pull/506) fix: add GlobalVirtualGroupFamilyId to createBucketPackage
* [#509](https://github.com/bnb-chain/greenfield/pull/509) fix: make handleCreateBucketSynPackage forward compatible
* [#511](https://github.com/bnb-chain/greenfield/pull/511) fix: policy key is not GC while a expired policy is GC
* [#518](https://github.com/bnb-chain/greenfield/pull/518) fix: emit event when sp status is forced updated
* [#519](https://github.com/bnb-chain/greenfield/pull/519) fix: enforce validation on SSP when creating GVG

Chores:
* [#484](https://github.com/bnb-chain/greenfield/pull/484) chore: improve the validations of messages
Expand Down
4 changes: 3 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ func New(
app.BankKeeper,
app.PaymentKeeper,
)
virtualgroupModule := virtualgroupmodule.NewAppModule(appCodec, app.VirtualgroupKeeper, app.SpKeeper)

app.PermissionmoduleKeeper = *permissionmodulekeeper.NewKeeper(
appCodec,
Expand All @@ -497,6 +496,9 @@ func New(
)
storageModule := storagemodule.NewAppModule(appCodec, app.StorageKeeper, app.AccountKeeper, app.BankKeeper, app.SpKeeper)

app.VirtualgroupKeeper.SetStorageKeeper(&app.StorageKeeper)
virtualgroupModule := virtualgroupmodule.NewAppModule(appCodec, app.VirtualgroupKeeper, app.SpKeeper)

app.ChallengeKeeper = *challengemodulekeeper.NewKeeper(
appCodec,
keys[challengemoduletypes.StoreKey],
Expand Down
14 changes: 11 additions & 3 deletions app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
serverconfig "github.com/cosmos/cosmos-sdk/server/config"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"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 Down Expand Up @@ -80,8 +79,17 @@ func (app *App) registerPampasUpgradeHandler() {
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestOpChainId), storagemoduletypes.ObjectChannelId, sdk.ChannelAllow)
app.CrossChainKeeper.SetChannelSendPermission(ctx, sdk.ChainID(app.appConfig.CrossChain.DestOpChainId), storagemoduletypes.GroupChannelId, sdk.ChannelAllow)

// register MsgRejectMigrateBucket Gas param
app.GashubKeeper.SetMsgGasParams(ctx, *types.NewMsgGasParamsWithFixedGas("/greenfield.storage.MsgRejectMigrateBucket", 1.2e3))
// disable sp exit
app.GashubKeeper.DeleteMsgGasParams(ctx, "/greenfield.virtualgroup.MsgSwapOut")
app.GashubKeeper.DeleteMsgGasParams(ctx, "/greenfield.virtualgroup.MsgCompleteSwapOut")
app.GashubKeeper.DeleteMsgGasParams(ctx, "/greenfield.virtualgroup.MsgCancelSwapOut")
app.GashubKeeper.DeleteMsgGasParams(ctx, "/greenfield.virtualgroup.MsgStorageProviderExit")
app.GashubKeeper.DeleteMsgGasParams(ctx, "/greenfield.virtualgroup.MsgCompleteStorageProviderExit")

// disable bucket migration.
app.GashubKeeper.DeleteMsgGasParams(ctx, "/greenfield.storage.MsgMigrateBucket")
app.GashubKeeper.DeleteMsgGasParams(ctx, "/greenfield.storage.MsgCancelMigrateBucket")
app.GashubKeeper.DeleteMsgGasParams(ctx, "/greenfield.storage.MsgCompleteMigrateBucket")

return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})
Expand Down
200 changes: 100 additions & 100 deletions e2e/tests/payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1169,106 +1169,106 @@ func (s *PaymentTestSuite) TestVirtualGroup_Settle() {
s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0))
}

func (s *PaymentTestSuite) TestVirtualGroup_SwapOut() {
ctx := context.Background()
user := s.GenAndChargeAccounts(1, 1000000)[0]
successorSp := s.PickStorageProvider()

// create a new storage provider
sp := s.BaseSuite.CreateNewStorageProvider()
s.T().Logf("new SP Info: %s", sp.Info.String())

// create a new gvg group for this storage provider
var secondarySPIDs []uint32
for _, ssp := range s.StorageProviders {
if ssp.Info.Id != successorSp.Info.Id {
secondarySPIDs = append(secondarySPIDs, ssp.Info.Id)
}
if len(secondarySPIDs) == 6 {
break
}
}

gvgID, familyID := s.BaseSuite.CreateGlobalVirtualGroup(sp, 0, secondarySPIDs, 1)

// create object
s.BaseSuite.CreateObject(user, sp, gvgID, storagetestutils.GenRandomBucketName(), storagetestutils.GenRandomObjectName())

// Create another gvg contains this new sp
anotherSP := s.PickDifferentStorageProvider(successorSp.Info.Id)
var anotherSecondarySPIDs []uint32
for _, ssp := range s.StorageProviders {
if ssp.Info.Id != successorSp.Info.Id && ssp.Info.Id != anotherSP.Info.Id {
anotherSecondarySPIDs = append(anotherSecondarySPIDs, ssp.Info.Id)
}
if len(anotherSecondarySPIDs) == 5 {
break
}
}
anotherSecondarySPIDs = append(anotherSecondarySPIDs, sp.Info.Id)

anotherGVGID, _ := s.BaseSuite.CreateGlobalVirtualGroup(anotherSP, 0, anotherSecondarySPIDs, 1)

familyResp, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{FamilyId: familyID})
s.Require().NoError(err)
gvgResp, err := s.Client.GlobalVirtualGroup(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupRequest{GlobalVirtualGroupId: anotherGVGID})
s.Require().NoError(err)

streamAddresses := []string{
user.GetAddr().String(),
familyResp.GlobalVirtualGroupFamily.VirtualPaymentAddress,
gvgResp.GlobalVirtualGroup.VirtualPaymentAddress,
paymenttypes.ValidatorTaxPoolAddress.String(),
}
streamRecordsBefore := s.getStreamRecords(streamAddresses)

// sp exit
s.SendTxBlock(sp.OperatorKey, &virtualgrouptypes.MsgStorageProviderExit{
StorageProvider: sp.OperatorKey.GetAddr().String(),
})

resp, err := s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: sp.Info.Id})
s.Require().NoError(err)
s.Require().Equal(resp.StorageProvider.Status, sptypes.STATUS_GRACEFUL_EXITING)

// swap out, as secondary sp
msgSwapOut2 := virtualgrouptypes.NewMsgSwapOut(sp.OperatorKey.GetAddr(), 0, []uint32{anotherGVGID}, successorSp.Info.Id)
msgSwapOut2.SuccessorSpApproval = &common.Approval{ExpiredHeight: math.MaxUint}
msgSwapOut2.SuccessorSpApproval.Sig, err = successorSp.ApprovalKey.Sign(msgSwapOut2.GetApprovalBytes())
s.Require().NoError(err)
s.SendTxBlock(sp.OperatorKey, msgSwapOut2)

// complete swap out
msgCompleteSwapOut2 := virtualgrouptypes.NewMsgCompleteSwapOut(successorSp.OperatorKey.GetAddr(), 0, []uint32{anotherGVGID})
s.Require().NoError(err)
s.SendTxBlock(successorSp.OperatorKey, msgCompleteSwapOut2)

// swap out, as primary sp
msgSwapOut := virtualgrouptypes.NewMsgSwapOut(sp.OperatorKey.GetAddr(), familyID, nil, successorSp.Info.Id)
msgSwapOut.SuccessorSpApproval = &common.Approval{ExpiredHeight: math.MaxUint}
msgSwapOut.SuccessorSpApproval.Sig, err = successorSp.ApprovalKey.Sign(msgSwapOut.GetApprovalBytes())
s.Require().NoError(err)
s.SendTxBlock(sp.OperatorKey, msgSwapOut)

// complete swap out, as primary sp
msgCompleteSwapOut := virtualgrouptypes.NewMsgCompleteSwapOut(successorSp.OperatorKey.GetAddr(), familyID, nil)
s.Require().NoError(err)
s.SendTxBlock(successorSp.OperatorKey, msgCompleteSwapOut)

// sp complete exit success
s.SendTxBlock(
sp.OperatorKey,
&virtualgrouptypes.MsgCompleteStorageProviderExit{StorageProvider: sp.OperatorKey.GetAddr().String()},
)

// assertions
streamRecordsAfter := s.getStreamRecords(streamAddresses)

s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0))
s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0))
s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0))
s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0))
}
//func (s *PaymentTestSuite) TestVirtualGroup_SwapOut() {
// ctx := context.Background()
// user := s.GenAndChargeAccounts(1, 1000000)[0]
// successorSp := s.PickStorageProvider()
//
// // create a new storage provider
// sp := s.BaseSuite.CreateNewStorageProvider()
// s.T().Logf("new SP Info: %s", sp.Info.String())
//
// // create a new gvg group for this storage provider
// var secondarySPIDs []uint32
// for _, ssp := range s.StorageProviders {
// if ssp.Info.Id != successorSp.Info.Id {
// secondarySPIDs = append(secondarySPIDs, ssp.Info.Id)
// }
// if len(secondarySPIDs) == 6 {
// break
// }
// }
//
// gvgID, familyID := s.BaseSuite.CreateGlobalVirtualGroup(sp, 0, secondarySPIDs, 1)
//
// // create object
// s.BaseSuite.CreateObject(user, sp, gvgID, storagetestutils.GenRandomBucketName(), storagetestutils.GenRandomObjectName())
//
// // Create another gvg contains this new sp
// anotherSP := s.PickDifferentStorageProvider(successorSp.Info.Id)
// var anotherSecondarySPIDs []uint32
// for _, ssp := range s.StorageProviders {
// if ssp.Info.Id != successorSp.Info.Id && ssp.Info.Id != anotherSP.Info.Id {
// anotherSecondarySPIDs = append(anotherSecondarySPIDs, ssp.Info.Id)
// }
// if len(anotherSecondarySPIDs) == 5 {
// break
// }
// }
// anotherSecondarySPIDs = append(anotherSecondarySPIDs, sp.Info.Id)
//
// anotherGVGID, _ := s.BaseSuite.CreateGlobalVirtualGroup(anotherSP, 0, anotherSecondarySPIDs, 1)
//
// familyResp, err := s.Client.GlobalVirtualGroupFamily(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupFamilyRequest{FamilyId: familyID})
// s.Require().NoError(err)
// gvgResp, err := s.Client.GlobalVirtualGroup(ctx, &virtualgrouptypes.QueryGlobalVirtualGroupRequest{GlobalVirtualGroupId: anotherGVGID})
// s.Require().NoError(err)
//
// streamAddresses := []string{
// user.GetAddr().String(),
// familyResp.GlobalVirtualGroupFamily.VirtualPaymentAddress,
// gvgResp.GlobalVirtualGroup.VirtualPaymentAddress,
// paymenttypes.ValidatorTaxPoolAddress.String(),
// }
// streamRecordsBefore := s.getStreamRecords(streamAddresses)
//
// // sp exit
// s.SendTxBlock(sp.OperatorKey, &virtualgrouptypes.MsgStorageProviderExit{
// StorageProvider: sp.OperatorKey.GetAddr().String(),
// })
//
// resp, err := s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: sp.Info.Id})
// s.Require().NoError(err)
// s.Require().Equal(resp.StorageProvider.Status, sptypes.STATUS_GRACEFUL_EXITING)
//
// // swap out, as secondary sp
// msgSwapOut2 := virtualgrouptypes.NewMsgSwapOut(sp.OperatorKey.GetAddr(), 0, []uint32{anotherGVGID}, successorSp.Info.Id)
// msgSwapOut2.SuccessorSpApproval = &common.Approval{ExpiredHeight: math.MaxUint}
// msgSwapOut2.SuccessorSpApproval.Sig, err = successorSp.ApprovalKey.Sign(msgSwapOut2.GetApprovalBytes())
// s.Require().NoError(err)
// s.SendTxBlock(sp.OperatorKey, msgSwapOut2)
//
// // complete swap out
// msgCompleteSwapOut2 := virtualgrouptypes.NewMsgCompleteSwapOut(successorSp.OperatorKey.GetAddr(), 0, []uint32{anotherGVGID})
// s.Require().NoError(err)
// s.SendTxBlock(successorSp.OperatorKey, msgCompleteSwapOut2)
//
// // swap out, as primary sp
// msgSwapOut := virtualgrouptypes.NewMsgSwapOut(sp.OperatorKey.GetAddr(), familyID, nil, successorSp.Info.Id)
// msgSwapOut.SuccessorSpApproval = &common.Approval{ExpiredHeight: math.MaxUint}
// msgSwapOut.SuccessorSpApproval.Sig, err = successorSp.ApprovalKey.Sign(msgSwapOut.GetApprovalBytes())
// s.Require().NoError(err)
// s.SendTxBlock(sp.OperatorKey, msgSwapOut)
//
// // complete swap out, as primary sp
// msgCompleteSwapOut := virtualgrouptypes.NewMsgCompleteSwapOut(successorSp.OperatorKey.GetAddr(), familyID, nil)
// s.Require().NoError(err)
// s.SendTxBlock(successorSp.OperatorKey, msgCompleteSwapOut)
//
// // sp complete exit success
// s.SendTxBlock(
// sp.OperatorKey,
// &virtualgrouptypes.MsgCompleteStorageProviderExit{StorageProvider: sp.OperatorKey.GetAddr().String()},
// )
//
// // assertions
// streamRecordsAfter := s.getStreamRecords(streamAddresses)
//
// s.Require().Equal(streamRecordsAfter.User.NetflowRate.Sub(streamRecordsBefore.User.NetflowRate).Int64(), int64(0))
// s.Require().Equal(streamRecordsAfter.GVGFamily.NetflowRate.Sub(streamRecordsBefore.GVGFamily.NetflowRate).Int64(), int64(0))
// s.Require().Equal(streamRecordsAfter.GVG.NetflowRate.Sub(streamRecordsBefore.GVG.NetflowRate).Int64(), int64(0))
// s.Require().Equal(streamRecordsAfter.Tax.NetflowRate.Sub(streamRecordsBefore.Tax.NetflowRate).Int64(), int64(0))
//}

func (s *PaymentTestSuite) TestDiscontinue_InOneBlock_WithoutPriceChange() {
ctx := context.Background()
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/permission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,7 @@ func (s *StorageTestSuite) TestExpiredAccountPolicyGCAndRePut() {
Actions: []types.ActionType{types.ACTION_DELETE_BUCKET},
Effect: types.EFFECT_ALLOW,
}
expirationTime := time.Now().Add(5 * time.Second)
expirationTime := time.Now().Add(3 * time.Second)

msgPutBucketPolicy := storagetypes.NewMsgPutPolicy(owner.GetAddr(), types2.NewBucketGRN(bucketName).String(),
principal, []*types.Statement{bucketStatement}, &expirationTime)
Expand Down Expand Up @@ -1990,7 +1990,7 @@ func (s *StorageTestSuite) TestExpiredGroupPolicyGCAndRePut() {

principal := types.NewPrincipalWithGroupId(headGroupResponse.GroupInfo.Id)
// Put bucket policy for group
expirationTime := time.Now().Add(5 * time.Second)
expirationTime := time.Now().Add(3 * time.Second)

bucketStatement := &types.Statement{
Actions: []types.ActionType{types.ACTION_DELETE_BUCKET},
Expand Down
67 changes: 33 additions & 34 deletions e2e/tests/sp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/bnb-chain/greenfield/sdk/types"
"github.com/bnb-chain/greenfield/testutil/sample"
sptypes "github.com/bnb-chain/greenfield/x/sp/types"
virtualgroupmoduletypes "github.com/bnb-chain/greenfield/x/virtualgroup/types"
)

type StorageProviderTestSuite struct {
Expand All @@ -38,39 +37,39 @@ func (s *StorageProviderTestSuite) SetupSuite() {
func (s *StorageProviderTestSuite) SetupTest() {
}

func (s *StorageProviderTestSuite) TestCreateStorageProvider() {
// Create a New SP
sp := s.BaseSuite.CreateNewStorageProvider()

// query sp by id
querySPResp, err := s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{
Id: sp.Info.Id,
})
s.Require().NoError(err)
s.Require().Equal(querySPResp.StorageProvider, querySPResp.StorageProvider)

// sp exit
msgSPExit := virtualgroupmoduletypes.MsgStorageProviderExit{
StorageProvider: sp.OperatorKey.GetAddr().String(),
}
s.SendTxBlock(sp.OperatorKey, &msgSPExit)

// 9 query sp status
querySPResp2, err := s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: sp.Info.Id})
s.Require().NoError(err)
s.Require().Equal(querySPResp2.StorageProvider.Status, sptypes.STATUS_GRACEFUL_EXITING)

// 10 complete sp exit
msgCompleteSPExit := virtualgroupmoduletypes.MsgCompleteStorageProviderExit{
StorageProvider: sp.OperatorKey.GetAddr().String(),
}

s.SendTxBlock(sp.OperatorKey, &msgCompleteSPExit)

// 10 query sp
_, err = s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: sp.Info.Id})
s.Require().Error(err)
}
//func (s *StorageProviderTestSuite) TestCreateStorageProvider() {
// // Create a New SP
// sp := s.BaseSuite.CreateNewStorageProvider()
//
// // query sp by id
// querySPResp, err := s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{
// Id: sp.Info.Id,
// })
// s.Require().NoError(err)
// s.Require().Equal(querySPResp.StorageProvider, querySPResp.StorageProvider)
//
// // sp exit
// msgSPExit := virtualgroupmoduletypes.MsgStorageProviderExit{
// StorageProvider: sp.OperatorKey.GetAddr().String(),
// }
// s.SendTxBlock(sp.OperatorKey, &msgSPExit)
//
// // 9 query sp status
// querySPResp2, err := s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: sp.Info.Id})
// s.Require().NoError(err)
// s.Require().Equal(querySPResp2.StorageProvider.Status, sptypes.STATUS_GRACEFUL_EXITING)
//
// // 10 complete sp exit
// msgCompleteSPExit := virtualgroupmoduletypes.MsgCompleteStorageProviderExit{
// StorageProvider: sp.OperatorKey.GetAddr().String(),
// }
//
// s.SendTxBlock(sp.OperatorKey, &msgCompleteSPExit)
//
// // 10 query sp
// _, err = s.Client.StorageProvider(context.Background(), &sptypes.QueryStorageProviderRequest{Id: sp.Info.Id})
// s.Require().Error(err)
//}

func (s *StorageProviderTestSuite) TestEditStorageProvider() {
ctx := context.Background()
Expand Down
Loading

0 comments on commit d220814

Please sign in to comment.