diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index d3f0cc228..bb42a4351 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -780,7 +780,7 @@ func (k Keeper) SealObject( } // validate seal object bls aggregated sig from secondary sps secondarySpsSealObjectBlsSignHash := types.NewSecondarySpSealObjectSignDoc(ctx.ChainID(), gvg.Id, objectInfo.Id, types.GenerateHash(objectInfo.Checksums[:])).GetBlsSignHash() - err := k.VerifyGVGSecondarySPsBlsSignature(ctx, gvg, secondarySpsSealObjectBlsSignHash, opts.SecondarySpBlsSignatures) + err := k.VerifyGVGSecondarySPsBlsSignatureAndStatus(ctx, gvg, secondarySpsSealObjectBlsSignHash, opts.SecondarySpBlsSignatures) if err != nil { return err } diff --git a/x/storage/keeper/msg_server.go b/x/storage/keeper/msg_server.go index 407bd8113..c03861237 100644 --- a/x/storage/keeper/msg_server.go +++ b/x/storage/keeper/msg_server.go @@ -718,7 +718,7 @@ func (k Keeper) verifyGVGSignatures(ctx sdk.Context, bucketID math.Uint, dstSP * } // validate the aggregated bls signature migrationBucketSignDocBlsSignHash := storagetypes.NewSecondarySpMigrationBucketSignDoc(ctx.ChainID(), bucketID, dstSP.Id, newLvg2gvg.SrcGlobalVirtualGroupId, dstGVG.Id).GetBlsSignHash() - err := k.VerifyGVGSecondarySPsBlsSignature(ctx, dstGVG, migrationBucketSignDocBlsSignHash, newLvg2gvg.SecondarySpBlsSignature) + err := k.VerifyGVGSecondarySPsBlsSignatureAndStatus(ctx, dstGVG, migrationBucketSignDocBlsSignHash, newLvg2gvg.SecondarySpBlsSignature) if err != nil { return err } diff --git a/x/storage/keeper/virtualgroup.go b/x/storage/keeper/virtualgroup.go index 7353322fd..bb7964b0f 100644 --- a/x/storage/keeper/virtualgroup.go +++ b/x/storage/keeper/virtualgroup.go @@ -3,9 +3,11 @@ package keeper import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/prysmaticlabs/prysm/crypto/bls" gnfdtypes "github.com/bnb-chain/greenfield/types" + sptypes "github.com/bnb-chain/greenfield/x/sp/types" "github.com/bnb-chain/greenfield/x/storage/types" vgtypes "github.com/bnb-chain/greenfield/x/virtualgroup/types" ) @@ -115,13 +117,18 @@ func (k Keeper) RebindingVirtualGroup(ctx sdk.Context, bucketInfo *types.BucketI return nil } -func (k Keeper) VerifyGVGSecondarySPsBlsSignature(ctx sdk.Context, gvg *vgtypes.GlobalVirtualGroup, signHash [32]byte, signature []byte) error { +func (k Keeper) VerifyGVGSecondarySPsBlsSignatureAndStatus(ctx sdk.Context, gvg *vgtypes.GlobalVirtualGroup, signHash [32]byte, signature []byte) error { secondarySpBlsPubKeys := make([]bls.PublicKey, 0, len(gvg.SecondarySpIds)) for _, spId := range gvg.GetSecondarySpIds() { secondarySp, found := k.spKeeper.GetStorageProvider(ctx, spId) if !found { panic("should not happen") } + if ctx.IsUpgraded(upgradetypes.HulunbeierPatch) { + if secondarySp.Status != sptypes.STATUS_IN_SERVICE { + return sptypes.ErrStorageProviderNotInService + } + } spBlsPubKey, err := bls.PublicKeyFromBytes(secondarySp.BlsKey) if err != nil { return types.ErrInvalidBlsPubKey.Wrapf("BLS public key converts failed: %v", err)