Skip to content

Commit

Permalink
Merge pull request #168 from bnb-chain/develop
Browse files Browse the repository at this point in the history
release: prepare for release v0.2.4
  • Loading branch information
unclezoro authored Aug 29, 2023
2 parents 016c3c9 + 8f4087f commit eb87889
Show file tree
Hide file tree
Showing 10 changed files with 288 additions and 116 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ on:
- develop

env:
GreenfieldTag: v0.2.4-alpha.2
GreenfieldStorageProviderTag: v0.2.4-alpha.10
GreenfieldTag: v0.2.4
GreenfieldStorageProviderTag: develop
GOPRIVATE: github.com/bnb-chain
GH_ACCESS_TOKEN: ${{ secrets.GH_TOKEN }}
MYSQL_USER: root
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ $ go get github.com/bnb-chain/greenfield-go-sdk
replace dependencies

```go.mod
cosmossdk.io/api => github.com/bnb-chain/greenfield-cosmos-sdk/api v0.0.0-20230425074444-eb5869b05fe9
cosmossdk.io/math => github.com/bnb-chain/greenfield-cosmos-sdk/math v0.0.0-20230425074444-eb5869b05fe9
github.com/cometbft/cometbft => github.com/bnb-chain/greenfield-cometbft v0.0.2
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/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/cosmos/cosmos-sdk => github.com/bnb-chain/greenfield-cosmos-sdk v0.2.3
github.com/cosmos/iavl => github.com/bnb-chain/greenfield-iavl v0.20.1-alpha.1
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
github.com/consensys/gnark-crypto => github.com/consensys/gnark-crypto v0.7.0
```

### Initialize Client
Expand Down
20 changes: 20 additions & 0 deletions client/api_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/xml"
"errors"
"fmt"
govTypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"io"
"math"
"net/http"
Expand Down Expand Up @@ -64,6 +65,7 @@ type Bucket interface {
ListBucketsByBucketID(ctx context.Context, bucketIds []uint64, opts types.EndPointOptions) (types.ListBucketsByBucketIDResponse, error)
GetMigrateBucketApproval(ctx context.Context, migrateBucketMsg *storageTypes.MsgMigrateBucket) (*storageTypes.MsgMigrateBucket, error)
MigrateBucket(ctx context.Context, bucketName string, opts types.MigrateBucketOptions) (string, error)
CancelMigrateBucket(ctx context.Context, bucketName string, opts types.CancelMigrateBucketOptions) (uint64, string, error)
}

// GetCreateBucketApproval returns the signature info for the approval of preCreating resources
Expand Down Expand Up @@ -741,3 +743,21 @@ func (c *client) MigrateBucket(ctx context.Context, bucketName string, opts type

return txnHash, nil
}

// CancelMigrateBucket get approval of migrating bucket and send migrateBucket txn to greenfield chain, it returns the transaction hash value and error
func (c *client) CancelMigrateBucket(ctx context.Context, bucketName string, opts types.CancelMigrateBucketOptions) (uint64, string, error) {
govModuleAddress, err := c.GetModuleAccountByName(ctx, govTypes.ModuleName)
if err != nil {
return 0, "", err
}
cancelBucketMsg := storageTypes.NewMsgCancelMigrateBucket(
govModuleAddress.GetAddress(), bucketName,
)

err = cancelBucketMsg.ValidateBasic()
if err != nil {
return 0, "", err
}

return c.SubmitProposal(ctx, []sdk.Msg{cancelBucketMsg}, opts.ProposalDepositAmount, opts.ProposalTitle, opts.ProposalSummary, types.SubmitProposalOptions{Metadata: opts.ProposalMetaData, TxOption: opts.TxOpts})
}
41 changes: 38 additions & 3 deletions e2e/basesuite/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"bufio"
"context"
"fmt"
storageTypes "github.com/bnb-chain/greenfield/x/storage/types"
"os"
"path/filepath"
"time"

"github.com/bnb-chain/greenfield-go-sdk/client"
"github.com/bnb-chain/greenfield-go-sdk/types"
Expand Down Expand Up @@ -43,16 +45,27 @@ func ParseMnemonicFromFile(fileName string) string {

type BaseSuite struct {
suite.Suite
DefaultAccount *types.Account
Client client.Client
ClientContext context.Context
DefaultAccount *types.Account
Client client.Client
ClientContext context.Context
ChallengeClient client.Client
}

// ParseValidatorMnemonic read the validator mnemonic from file
func ParseValidatorMnemonic(i int) string {
return ParseMnemonicFromFile(fmt.Sprintf("../../greenfield/deployment/localup/.local/validator%d/info", i))
}

func (s *BaseSuite) NewChallengeClient() {
mnemonic := ParseMnemonicFromFile(fmt.Sprintf("../../greenfield/deployment/localup/.local/challenger%d/challenger_info", 0))
challengeAcc, err := types.NewAccountFromMnemonic("challenge_account", mnemonic)
s.Require().NoError(err)
s.ChallengeClient, err = client.New(ChainID, Endpoint, client.Option{
DefaultAccount: challengeAcc,
})
s.Require().NoError(err)
}

func (s *BaseSuite) SetupSuite() {
mnemonic := ParseValidatorMnemonic(0)
account, err := types.NewAccountFromMnemonic("test", mnemonic)
Expand All @@ -63,4 +76,26 @@ func (s *BaseSuite) SetupSuite() {
s.Require().NoError(err)
s.ClientContext = context.Background()
s.DefaultAccount = account
s.NewChallengeClient()
}

func (s *BaseSuite) WaitSealObject(bucketName string, objectName string) {
startCheckTime := time.Now()
var (
objectDetail *types.ObjectDetail
err error
)

// wait 300s
for i := 0; i < 100; i++ {
objectDetail, err = s.Client.HeadObject(s.ClientContext, bucketName, objectName)
s.Require().NoError(err)
if objectDetail.ObjectInfo.GetObjectStatus() == storageTypes.OBJECT_STATUS_SEALED {
break
}
time.Sleep(3 * time.Second)
}

s.Require().Equal(objectDetail.ObjectInfo.GetObjectStatus().String(), "OBJECT_STATUS_SEALED")
s.T().Logf("---> Wait Seal Object cost %d ms, <---", time.Since(startCheckTime).Milliseconds())
}
Loading

0 comments on commit eb87889

Please sign in to comment.