Skip to content

Commit

Permalink
Merge pull request #446 from bnb-chain/develop
Browse files Browse the repository at this point in the history
release: prepare release for v0.2.4
  • Loading branch information
keefel authored Aug 29, 2023
2 parents f1183e5 + 548b8b5 commit dba6afc
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 59 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## v0.2.4
This release contains all the changes in the v0.2.4 alpha versions and 5 new bugfixes.

Bugfixes:
* [#433](https://github.com/bnb-chain/greenfield/pull/433) fix: add sp exit status check when craete gvg
* [#437](https://github.com/bnb-chain/greenfield/pull/437) fix: fix the last block time is empty issue
* [#443](https://github.com/bnb-chain/greenfield/pull/443) fix: fix some issues in payment module
* [#432](https://github.com/bnb-chain/greenfield/pull/432) fix: grant permission with wildcard objectname
* [#440](https://github.com/bnb-chain/greenfield/pull/440) fix: check secondary sp in gvg

Chores:
* [#431](https://github.com/bnb-chain/greenfield/pull/431) chore: fix sp e2e test sometimes fail issue
* [#442](https://github.com/bnb-chain/greenfield/pull/442) chore: switch the order of create sp event and update price event

## v0.2.4-alpha.3
This release contains 1 bugfix.

Expand Down
3 changes: 0 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,9 +763,6 @@ func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.R

// EndBlocker application updates every end block
func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
lastBlockTime := app.GetCheckState().Context().BlockHeader().Time.Unix()
ctx = ctx.WithValue(spmodule.LastBlockTimeKey, lastBlockTime)

resp := app.mm.EndBlock(ctx, req)
if app.IsIavlStore() {
bankIavl, _ := app.CommitMultiStore().GetCommitStore(sdk.NewKVStoreKey(banktypes.StoreKey)).(*iavl.Store)
Expand Down
28 changes: 28 additions & 0 deletions e2e/tests/permission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"math"
"strconv"
"strings"
"time"

sdkmath "cosmossdk.io/math"
Expand Down Expand Up @@ -1878,3 +1879,30 @@ func (s *StorageTestSuite) UpdateParams(newParams *storagetypes.Params) {
s.T().Logf("QueryParmas: %s", queryParamsResponse.Params.String())
s.Require().Equal(queryParamsResponse.Params, *newParams)
}

func (s *StorageTestSuite) TestGrantsPermissionToObjectWithWildcardInName() {
user := s.GenAndChargeAccounts(2, 1000000)

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

bucketName := storageutil.GenRandomBucketName()
objectName := "*.jpg"
s.CreateObject(user[0], sp, gvg.Id, bucketName, objectName)

// grant permission to *.jpg
objectStatement := &types.Statement{
Actions: []types.ActionType{types.ACTION_DELETE_OBJECT},
Effect: types.EFFECT_ALLOW,
}
msgPutObjectPolicy := storagetypes.NewMsgPutPolicy(user[0].GetAddr(), types2.NewObjectGRN(bucketName, objectName).String(), types.NewPrincipalWithAccount(user[1].GetAddr()), []*types.Statement{objectStatement}, nil)
s.SendTxBlock(user[0], msgPutObjectPolicy)

// Delete object
s.SendTxBlock(user[1], storagetypes.NewMsgDeleteObject(user[1].GetAddr(), bucketName, objectName))

// head object
_, err := s.Client.HeadObject(context.Background(), &storagetypes.QueryHeadObjectRequest{BucketName: bucketName, ObjectName: objectName})
s.Require().True(strings.Contains(err.Error(), "No such object"))
}
15 changes: 12 additions & 3 deletions e2e/tests/sp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (s *StorageProviderTestSuite) TestUpdateSpStoragePrice() {
globalPriceResAfter1, _ = s.Client.QueryGlobalSpStorePriceByTime(ctx, &sptypes.QueryGlobalSpStorePriceByTimeRequest{Timestamp: 0})
s.T().Log("globalPriceResAfter1", core.YamlString(globalPriceResAfter1))
if !globalPriceResAfter1.GlobalSpStorePrice.PrimaryStorePrice.Equal(globalPriceResBefore.GlobalSpStorePrice.PrimaryStorePrice) {
s.CheckGlobalSpStorePrice()
_ = s.CheckGlobalSpStorePrice()
priceChanged = true
break
}
Expand All @@ -219,7 +219,9 @@ func (s *StorageProviderTestSuite) TestUpdateSpStoragePrice() {
globalPriceResAfter2, _ := s.Client.QueryGlobalSpStorePriceByTime(ctx, &sptypes.QueryGlobalSpStorePriceByTimeRequest{Timestamp: 0})
s.T().Log("globalPriceResAfter2", core.YamlString(globalPriceResAfter2))

s.CheckGlobalSpStorePrice()
checked := s.CheckGlobalSpStorePrice()
s.Require().True(checked)

if !priceChanged { //if price not changed, then after 6 seconds, it should change
s.Require().NotEqual(globalPriceResAfter2.GlobalSpStorePrice.PrimaryStorePrice, globalPriceResBefore.GlobalSpStorePrice.PrimaryStorePrice)
s.Require().NotEqual(globalPriceResAfter2.GlobalSpStorePrice.SecondaryStorePrice, globalPriceResBefore.GlobalSpStorePrice.SecondaryStorePrice)
Expand Down Expand Up @@ -248,7 +250,7 @@ func (s *StorageProviderTestSuite) TestUpdateSpStoragePrice() {
s.SendTxBlockWithExpectErrorString(msgUpdateSpStoragePrice, sp.OperatorKey, "update price is disallowed")
}

func (s *StorageProviderTestSuite) CheckGlobalSpStorePrice() {
func (s *StorageProviderTestSuite) CheckGlobalSpStorePrice() bool {
ctx := context.Background()
queryGlobalSpStorePriceByTimeResp, err := s.Client.QueryGlobalSpStorePriceByTime(ctx, &sptypes.QueryGlobalSpStorePriceByTimeRequest{
Timestamp: 0,
Expand All @@ -269,6 +271,12 @@ func (s *StorageProviderTestSuite) CheckGlobalSpStorePrice() {
})
s.Require().NoError(err)
s.T().Logf("sp: %s, storage price: %s", sp.OperatorAddress, core.YamlString(spStoragePrice.SpStoragePrice))

if spStoragePrice.SpStoragePrice.UpdateTimeSec >= queryGlobalSpStorePriceByTimeResp.GlobalSpStorePrice.UpdateTimeSec {
s.T().Logf("cannot do the calculation for there is a new price update for %s", sp.OperatorAddress)
return false
}

storePrices = append(storePrices, spStoragePrice.SpStoragePrice.StorePrice)
readPrices = append(readPrices, spStoragePrice.SpStoragePrice.ReadPrice)
}
Expand Down Expand Up @@ -296,6 +304,7 @@ func (s *StorageProviderTestSuite) CheckGlobalSpStorePrice() {
expectedSecondarySpStorePrice := params.Params.SecondarySpStorePriceRatio.Mul(storeMedian)
s.Require().Equal(expectedSecondarySpStorePrice, queryGlobalSpStorePriceByTimeResp.GlobalSpStorePrice.SecondaryStorePrice)
s.Require().Equal(readMedian, queryGlobalSpStorePriceByTimeResp.GlobalSpStorePrice.ReadPrice)
return true
}

func TestStorageProviderTestSuite(t *testing.T) {
Expand Down
13 changes: 7 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/cosmos/cosmos-sdk v0.47.2
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.10
github.com/ethereum/go-ethereum v1.10.22
github.com/ethereum/go-ethereum v1.10.26
github.com/ghodss/yaml v1.0.0
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.3
Expand Down Expand Up @@ -49,6 +49,7 @@ require (
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/btcsuite/btcd/btcutil v1.1.2 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/bytedance/sonic v1.10.0 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand Down Expand Up @@ -113,7 +114,7 @@ require (
github.com/magiconair/properties v1.8.7 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.10 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
Expand All @@ -123,7 +124,7 @@ require (
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/onsi/gomega v1.20.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.15.0 // indirect
Expand All @@ -141,7 +142,7 @@ require (
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/thomaso-mirodin/intmath v0.0.0-20160323211736-5dc6d854e46e // indirect
Expand Down Expand Up @@ -174,10 +175,10 @@ replace (
cosmossdk.io/api => github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230816082903-b48770f5e210
cosmossdk.io/math => github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230816082903-b48770f5e210
github.com/btcsuite/btcd => github.com/btcsuite/btcd v0.23.0
github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.3-alpha.1
github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.3
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 v0.2.4-alpha.2
github.com/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.4
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
)
Loading

0 comments on commit dba6afc

Please sign in to comment.