Skip to content

Commit

Permalink
Merge branch 'develop' into fix-migrate-buckets
Browse files Browse the repository at this point in the history
# Conflicts:
#	go.mod
#	go.sum
  • Loading branch information
BarryTong65 committed May 27, 2024
2 parents df3028c + e418737 commit 5c90fbc
Show file tree
Hide file tree
Showing 5 changed files with 352 additions and 134 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/docker-build-workflow-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Docker-Invisible

on: workflow_dispatch

env:
IMAGE_NAME: ghcr.io/bnb-chain/greenfield-invisible
IMAGE_SOURCE: https://github.com/bnb-chain/greenfield

jobs:
# Push image to GitHub Packages.
push:
strategy:
matrix:
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- name: Build image
run: |
docker build . \
--label "org.opencontainers.image.source=${IMAGE_SOURCE}" \
--label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \
--label "org.opencontainers.image.version=$(git describe --tags --abbrev=0)" \
--label "org.opencontainers.image.licenses=AGPL-3.0,GPL-3.0" \
-f ./Dockerfile -t "${IMAGE_NAME}"
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GH_ACCESS_SECRET }}

- name: Push image
run: |
VERSION=${GITHUB_SHA}
echo IMAGE_NAME=$IMAGE_NAME
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_NAME:$VERSION
docker tag $IMAGE_NAME $IMAGE_NAME:latest
docker push $IMAGE_NAME:$VERSION
docker push $IMAGE_NAME:latest
8 changes: 8 additions & 0 deletions proto/greenfield/storage/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ message EventMigrationBucket {
];
// The id of the destination primary sp
uint32 dst_primary_sp_id = 4;
// status define the status of the bucket.
BucketStatus status = 5;
}

message EventCancelMigrationBucket {
Expand All @@ -528,6 +530,8 @@ message EventCancelMigrationBucket {
(gogoproto.customtype) = "Uint",
(gogoproto.nullable) = false
];
// status define the status of the bucket.
BucketStatus status = 4;
}

message EventRejectMigrateBucket {
Expand All @@ -541,6 +545,8 @@ message EventRejectMigrateBucket {
(gogoproto.customtype) = "Uint",
(gogoproto.nullable) = false
];
// status define the status of the bucket.
BucketStatus status = 4;
}

message EventCompleteMigrationBucket {
Expand All @@ -559,6 +565,8 @@ message EventCompleteMigrationBucket {
uint32 global_virtual_group_family_id = 4;
// The src_primary_sp_id defines the primary sp id of the bucket before migrate.
uint32 src_primary_sp_id = 5;
// status define the status of the bucket.
BucketStatus status = 6;
}

message EventSetTag {
Expand Down
5 changes: 5 additions & 0 deletions x/storage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"cosmossdk.io/errors"
sdkmath "cosmossdk.io/math"

"github.com/cometbft/cometbft/libs/log"
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store/prefix"
Expand Down Expand Up @@ -2188,6 +2189,7 @@ func (k Keeper) MigrateBucket(ctx sdk.Context, operator sdk.AccAddress, bucketNa
BucketName: bucketName,
BucketId: bucketInfo.Id,
DstPrimarySpId: dstSP.Id,
Status: bucketInfo.BucketStatus,
}); err != nil {
return err
}
Expand Down Expand Up @@ -2270,6 +2272,7 @@ func (k Keeper) CompleteMigrateBucket(ctx sdk.Context, operator sdk.AccAddress,
BucketId: bucketInfo.Id,
GlobalVirtualGroupFamilyId: gvgFamilyID,
SrcPrimarySpId: srcGvgFamily.PrimarySpId,
Status: bucketInfo.BucketStatus,
}); err != nil {
return err
}
Expand Down Expand Up @@ -2316,6 +2319,7 @@ func (k Keeper) CancelBucketMigration(ctx sdk.Context, operator sdk.AccAddress,
Operator: operator.String(),
BucketName: bucketName,
BucketId: bucketInfo.Id,
Status: bucketInfo.BucketStatus,
}); err != nil {
return err
}
Expand Down Expand Up @@ -2350,6 +2354,7 @@ func (k Keeper) RejectBucketMigration(ctx sdk.Context, operator sdk.AccAddress,
Operator: operator.String(),
BucketName: bucketName,
BucketId: bucketInfo.Id,
Status: bucketInfo.BucketStatus,
}); err != nil {
return err
}
Expand Down
22 changes: 19 additions & 3 deletions x/storage/keeper/payment_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/bnb-chain/greenfield/x/storage/types"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/pkg/errors"
)

Expand Down Expand Up @@ -114,7 +115,7 @@ Exit:
u256Seq := sequence.Sequence[sdkmath.Uint]{}
objectInfo, found := k.GetObjectInfoById(ctx, u256Seq.DecodeSequence(it.Value()))
if found && (objectInfo.ObjectStatus == types.OBJECT_STATUS_CREATED || objectInfo.IsUpdating) {
priceTime := objectInfo.CreateAt
priceTime := objectInfo.GetLatestUpdatedTime()
payloadSize := objectInfo.PayloadSize
if objectInfo.IsUpdating {
shadowObject, found := k.GetShadowObjectInfo(ctx, bucket.BucketName, objectInfo.ObjectName)
Expand Down Expand Up @@ -165,7 +166,9 @@ Exit:

actualLockBalance := streamRecord.LockBalance
if !expectedLockBalance.Equal(actualLockBalance) {
result = errors.New("lock balance not equal")
if !k.isKnownLockBalanceIssue(ctx, address) {
result = errors.New("lock balance not equal")
}
ctx.Logger().Error("lock balance not equal", "address", address, "expected", expectedLockBalance, "actual", actualLockBalance)
details := lockBalanceDetailMap[address]
for _, detail := range details {
Expand Down Expand Up @@ -256,7 +259,9 @@ Exit:
if streamRecord.LockBalance.IsPositive() {
_, found := lockBalanceMap[streamRecord.Account]
if !found {
result = errors.New("the stream record has lock balance which is not expected")
if !k.isKnownLockBalanceIssue(ctx, streamRecord.Account) {
result = errors.New("the stream record has lock balance which is not expected")
}
ctx.Logger().Error("the stream record has lock balance which is not expected", "address", streamRecord.Account)
}
}
Expand All @@ -281,3 +286,14 @@ Exit:
ctx.Logger().Info("finish checking payment data")
return result
}

// isKnownLockBalanceIssue checks if the address is the known addresses of the lock balance issue on testnet.
func (k Keeper) isKnownLockBalanceIssue(ctx sdk.Context, address string) bool {
if ctx.ChainID() != upgradetypes.TestnetChainID {
return false
}
if address == "0x8E15D16d6432166372Fb1e6f4A41840D71edd41F" || address == "0x9b825492966508C587536bA71425d61E822545C3" {
return true
}
return false
}
Loading

0 comments on commit 5c90fbc

Please sign in to comment.