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

chore: fix payment check for testnet #623

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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