diff --git a/base/gfspapp/app_options.go b/base/gfspapp/app_options.go index 2b4a324d0..eb4a4e83d 100644 --- a/base/gfspapp/app_options.go +++ b/base/gfspapp/app_options.go @@ -154,6 +154,12 @@ const ( SignerSuccessRejectMigrateBucket = "signer_reject_migrate_bucket_success" SignerFailureRejectMigrateBucket = "signer_reject_migrate_bucket_failure" + SignerSuccessDeposit = "signer_deposit_success" + SignerFailureDeposit = "signer_deposit_failure" + + SignerSuccessDeleteGlobalVirtualGroup = "signer_delete_global_virtual_group_success" + SignerFailureDeleteGlobalVirtualGroup = "signer_delete_global_virtual_group_failure" + UploaderSuccessPutObject = "uploader_put_object_success" UploaderFailurePutObject = "uploader_put_object_failure" ) diff --git a/base/gfspapp/sign_server.go b/base/gfspapp/sign_server.go index 7c6a4c90b..518251a3a 100644 --- a/base/gfspapp/sign_server.go +++ b/base/gfspapp/sign_server.go @@ -291,6 +291,26 @@ func (g *GfSpBaseApp) GfSpSign(ctx context.Context, req *gfspserver.GfSpSignRequ metrics.ReqCounter.WithLabelValues(SignerSuccessRejectMigrateBucket).Inc() metrics.ReqTime.WithLabelValues(SignerSuccessRejectMigrateBucket).Observe(time.Since(startTime).Seconds()) } + case *gfspserver.GfSpSignRequest_Deposit: + txHash, err = g.signer.Deposit(ctx, t.Deposit) + if err != nil { + log.CtxErrorw(ctx, "failed to deposit", "error", err) + metrics.ReqCounter.WithLabelValues(SignerFailureDeposit).Inc() + metrics.ReqTime.WithLabelValues(SignerFailureDeposit).Observe(time.Since(startTime).Seconds()) + } else { + metrics.ReqCounter.WithLabelValues(SignerSuccessDeposit).Inc() + metrics.ReqTime.WithLabelValues(SignerSuccessDeposit).Observe(time.Since(startTime).Seconds()) + } + case *gfspserver.GfSpSignRequest_DeleteGlobalVirtualGroup: + txHash, err = g.signer.DeleteGlobalVirtualGroup(ctx, t.DeleteGlobalVirtualGroup) + if err != nil { + log.CtxErrorw(ctx, "failed to delete global virtual group", "error", err) + metrics.ReqCounter.WithLabelValues(SignerFailureDeleteGlobalVirtualGroup).Inc() + metrics.ReqTime.WithLabelValues(SignerFailureDeleteGlobalVirtualGroup).Observe(time.Since(startTime).Seconds()) + } else { + metrics.ReqCounter.WithLabelValues(SignerSuccessDeleteGlobalVirtualGroup).Inc() + metrics.ReqTime.WithLabelValues(SignerSuccessDeleteGlobalVirtualGroup).Observe(time.Since(startTime).Seconds()) + } default: log.CtxError(ctx, "unknown gfsp sign request type") return &gfspserver.GfSpSignResponse{ diff --git a/base/gfspclient/interface.go b/base/gfspclient/interface.go index 626939cdf..e4239d983 100644 --- a/base/gfspclient/interface.go +++ b/base/gfspclient/interface.go @@ -192,6 +192,8 @@ type SignerAPI interface { SignMigrateGVG(ctx context.Context, task *gfsptask.GfSpMigrateGVGTask) ([]byte, error) SignBucketMigrationInfo(ctx context.Context, task *gfsptask.GfSpBucketMigrationInfo) ([]byte, error) RejectMigrateBucket(ctx context.Context, rejectMigrateBucket *storagetypes.MsgRejectMigrateBucket) (string, error) + Deposit(ctx context.Context, deposit *virtualgrouptypes.MsgDeposit) (string, error) + DeleteGlobalVirtualGroup(ctx context.Context, deleteGVG *virtualgrouptypes.MsgDeleteGlobalVirtualGroup) (string, error) } // UploaderAPI for mock use diff --git a/base/gfspclient/interface_mock.go b/base/gfspclient/interface_mock.go index c2b408649..b0b3daf95 100644 --- a/base/gfspclient/interface_mock.go +++ b/base/gfspclient/interface_mock.go @@ -292,6 +292,36 @@ func (mr *MockGfSpClientAPIMockRecorder) DeductQuotaForBucketMigrate(ctx, bucket return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeductQuotaForBucketMigrate", reflect.TypeOf((*MockGfSpClientAPI)(nil).DeductQuotaForBucketMigrate), varargs...) } +// DeleteGlobalVirtualGroup mocks base method. +func (m *MockGfSpClientAPI) DeleteGlobalVirtualGroup(ctx context.Context, deleteGVG *types4.MsgDeleteGlobalVirtualGroup) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteGlobalVirtualGroup", ctx, deleteGVG) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeleteGlobalVirtualGroup indicates an expected call of DeleteGlobalVirtualGroup. +func (mr *MockGfSpClientAPIMockRecorder) DeleteGlobalVirtualGroup(ctx, deleteGVG any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteGlobalVirtualGroup", reflect.TypeOf((*MockGfSpClientAPI)(nil).DeleteGlobalVirtualGroup), ctx, deleteGVG) +} + +// Deposit mocks base method. +func (m *MockGfSpClientAPI) Deposit(ctx context.Context, deposit *types4.MsgDeposit) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Deposit", ctx, deposit) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Deposit indicates an expected call of Deposit. +func (mr *MockGfSpClientAPIMockRecorder) Deposit(ctx, deposit any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Deposit", reflect.TypeOf((*MockGfSpClientAPI)(nil).Deposit), ctx, deposit) +} + // DiscontinueBucket mocks base method. func (m *MockGfSpClientAPI) DiscontinueBucket(ctx context.Context, bucket *types3.MsgDiscontinueBucket) (string, error) { m.ctrl.T.Helper() @@ -4210,6 +4240,36 @@ func (mr *MockSignerAPIMockRecorder) CreateGlobalVirtualGroup(ctx, group interfa return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateGlobalVirtualGroup", reflect.TypeOf((*MockSignerAPI)(nil).CreateGlobalVirtualGroup), ctx, group) } +// DeleteGlobalVirtualGroup mocks base method. +func (m *MockSignerAPI) DeleteGlobalVirtualGroup(ctx context.Context, deleteGVG *types4.MsgDeleteGlobalVirtualGroup) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteGlobalVirtualGroup", ctx, deleteGVG) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// DeleteGlobalVirtualGroup indicates an expected call of DeleteGlobalVirtualGroup. +func (mr *MockSignerAPIMockRecorder) DeleteGlobalVirtualGroup(ctx, deleteGVG any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteGlobalVirtualGroup", reflect.TypeOf((*MockSignerAPI)(nil).DeleteGlobalVirtualGroup), ctx, deleteGVG) +} + +// Deposit mocks base method. +func (m *MockSignerAPI) Deposit(ctx context.Context, deposit *types4.MsgDeposit) (string, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Deposit", ctx, deposit) + ret0, _ := ret[0].(string) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Deposit indicates an expected call of Deposit. +func (mr *MockSignerAPIMockRecorder) Deposit(ctx, deposit any) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Deposit", reflect.TypeOf((*MockSignerAPI)(nil).Deposit), ctx, deposit) +} + // DiscontinueBucket mocks base method. func (m *MockSignerAPI) DiscontinueBucket(ctx context.Context, bucket *types3.MsgDiscontinueBucket) (string, error) { m.ctrl.T.Helper() diff --git a/base/gfspclient/signer.go b/base/gfspclient/signer.go index 1395ba2b6..156bc12dc 100644 --- a/base/gfspclient/signer.go +++ b/base/gfspclient/signer.go @@ -544,3 +544,47 @@ func (s *GfSpClient) RejectMigrateBucket(ctx context.Context, rejectMigrateBucke } return resp.GetTxHash(), nil } + +func (s *GfSpClient) Deposit(ctx context.Context, deposit *virtualgrouptypes.MsgDeposit) (string, error) { + conn, err := s.SignerConn(ctx) + if err != nil { + log.Errorw("failed to connect to signer", "error", err) + return "", ErrRPCUnknownWithDetail("client failed to connect to signer, error: ", err) + } + req := &gfspserver.GfSpSignRequest{ + Request: &gfspserver.GfSpSignRequest_Deposit{ + Deposit: deposit, + }, + } + resp, err := gfspserver.NewGfSpSignServiceClient(conn).GfSpSign(ctx, req) + if err != nil { + log.CtxErrorw(ctx, "client failed to sign deposit", "msg", deposit, "error", err) + return "", ErrRPCUnknownWithDetail("client failed to sign deposit, error: ", err) + } + if resp.GetErr() != nil { + return "", resp.GetErr() + } + return resp.GetTxHash(), nil +} + +func (s *GfSpClient) DeleteGlobalVirtualGroup(ctx context.Context, deleteGVG *virtualgrouptypes.MsgDeleteGlobalVirtualGroup) (string, error) { + conn, err := s.SignerConn(ctx) + if err != nil { + log.Errorw("failed to connect to signer", "error", err) + return "", ErrRPCUnknownWithDetail("client failed to connect to signer, error: ", err) + } + req := &gfspserver.GfSpSignRequest{ + Request: &gfspserver.GfSpSignRequest_DeleteGlobalVirtualGroup{ + DeleteGlobalVirtualGroup: deleteGVG, + }, + } + resp, err := gfspserver.NewGfSpSignServiceClient(conn).GfSpSign(ctx, req) + if err != nil { + log.CtxErrorw(ctx, "client failed to sign delete GVG", "msg", deleteGVG, "error", err) + return "", ErrRPCUnknownWithDetail("client failed to sign delete GVG, error: ", err) + } + if resp.GetErr() != nil { + return "", resp.GetErr() + } + return resp.GetTxHash(), nil +} diff --git a/base/gfspvgmgr/virtual_group_manager.go b/base/gfspvgmgr/virtual_group_manager.go index e02aacce2..cae3f7645 100644 --- a/base/gfspvgmgr/virtual_group_manager.go +++ b/base/gfspvgmgr/virtual_group_manager.go @@ -6,10 +6,15 @@ import ( "fmt" "math/rand" "net/http" + "sort" "strings" "sync" "time" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/bnb-chain/greenfield-storage-provider/base/gfspclient" "github.com/bnb-chain/greenfield-storage-provider/base/types/gfsperrors" "github.com/bnb-chain/greenfield-storage-provider/core/consensus" "github.com/bnb-chain/greenfield-storage-provider/core/vgmgr" @@ -23,12 +28,16 @@ var _ vgmgr.VirtualGroupManager = &virtualGroupManager{} const ( VirtualGroupManagerSpace = "VirtualGroupManager" - RefreshMetaInterval = 2 * time.Second + RefreshMetaInterval = 5 * time.Second MaxStorageUsageRatio = 0.95 - DefaultInitialGVGStakingStorageSize = uint64(8) * 1024 * 1024 * 1024 * 1024 // 8TB per GVG, chain side DefaultMaxStoreSizePerFamily is 64 TB - defaultSPCheckTimeout = 3 * time.Second - defaultSPHealthCheckerInterval = 5 * time.Second - httpStatusPath = "/status" + DefaultInitialGVGStakingStorageSize = uint64(2) * 1024 * 1024 * 1024 * 1024 // 2TB per GVG, chain side DefaultMaxStoreSizePerFamily is 64 TB + additionalGVGStakingStorageSize = uint64(1) * 1024 * 1024 * 1024 * 1024 // 1TB + + defaultSPCheckTimeout = 3 * time.Second + defaultSPHealthCheckerInterval = 5 * time.Second + httpStatusPath = "/status" + + emptyGVGSafeDeletePeriod = int64(60) * 60 * 24 ) var ( @@ -235,10 +244,10 @@ func (sm *spManager) querySPByID(spID uint32) (*sptypes.StorageProvider, error) return nil, ErrFailedPickDestSP } -// TODO: add metadata service client. type virtualGroupManager struct { selfOperatorAddress string chainClient consensus.Consensus // query VG params from chain + gfspClient gfspclient.GfSpClientAPI mutex sync.RWMutex selfSPID uint32 spManager *spManager // is used to generate a new gvg @@ -246,10 +255,11 @@ type virtualGroupManager struct { vgfManager *virtualGroupFamilyManager freezeSPPool *FreezeSPPool healthChecker *HealthChecker + gvgGCMap sync.Map // Keep track of empty GVG and the time for GC. Once a GVG is detected empty, it will be put into gvgGCMap, and delete it if it is still empty after 1 day } // NewVirtualGroupManager returns a virtual group manager interface. -func NewVirtualGroupManager(selfOperatorAddress string, chainClient consensus.Consensus, enableHealthyChecker bool) (vgmgr.VirtualGroupManager, error) { +func NewVirtualGroupManager(selfOperatorAddress string, chainClient consensus.Consensus, gfspClient gfspclient.GfSpClientAPI, enableHealthyChecker bool) (vgmgr.VirtualGroupManager, error) { var healthChecker *HealthChecker if enableHealthyChecker { healthChecker = NewHealthChecker(chainClient) @@ -259,15 +269,17 @@ func NewVirtualGroupManager(selfOperatorAddress string, chainClient consensus.Co vgm := &virtualGroupManager{ selfOperatorAddress: selfOperatorAddress, chainClient: chainClient, + gfspClient: gfspClient, freezeSPPool: NewFreezeSPPool(), healthChecker: healthChecker, + gvgGCMap: sync.Map{}, } - vgm.refreshMeta() + vgm.refreshGVGMeta(true) go func() { RefreshMetaTicker := time.NewTicker(RefreshMetaInterval) for range RefreshMetaTicker.C { // log.Info("start to refresh virtual group manager meta") - vgm.refreshMeta() + vgm.refreshGVGMeta(false) // log.Info("finish to refresh virtual group manager meta") } }() @@ -278,13 +290,8 @@ func NewVirtualGroupManager(selfOperatorAddress string, chainClient consensus.Co return vgm, nil } -// refreshMetadata is used to refresh virtual group manager metadata in background. -func (vgm *virtualGroupManager) refreshMeta() { - // TODO: support load from metadata. - vgm.refreshMetaByChain() -} - -func (vgm *virtualGroupManager) refreshMetaByChain() { +// refreshGVGMeta is used to refresh virtual group manager metadata in background. +func (vgm *virtualGroupManager) refreshGVGMeta(byChain bool) { var ( err error spList []*sptypes.StorageProvider @@ -311,6 +318,9 @@ func (vgm *virtualGroupManager) refreshMetaByChain() { log.Errorw("failed to list sps", "error", err) return } + sort.Slice(spList, func(i, j int) bool { + return spList[i].Id < spList[j].Id + }) for _, sp := range spList { spMap[sp.Id] = sp if vgm.healthChecker != nil { @@ -358,10 +368,33 @@ func (vgm *virtualGroupManager) refreshMetaByChain() { } for _, gvgID := range vgf.GlobalVirtualGroupIds { var gvg *virtualgrouptypes.GlobalVirtualGroup - if gvg, err = vgm.chainClient.QueryGlobalVirtualGroup(context.Background(), gvgID); err != nil { - log.Errorw("failed to query global virtual group", "error", err) + if byChain { + if gvg, err = vgm.chainClient.QueryGlobalVirtualGroup(context.Background(), gvgID); err != nil { + log.Errorw("failed to query global virtual group from chain", "error", err) + return + } + } else { + if gvg, err = vgm.gfspClient.GetGlobalVirtualGroupByGvgID(context.Background(), gvgID); err != nil { + log.Errorw("failed to query global virtual group from meta", "error", err) + return + } + } + deposited, deleted, err := vgm.monitorGVGUsage(gvg, vgParams, byChain) + if err != nil { + log.Errorw("failed to monitor global virtual group usage", "gvgID", gvg.Id, "error", err) return } + if deleted { + continue + } + if deposited { + time.Sleep(RefreshMetaInterval) + gvg, err = vgm.chainClient.QueryGlobalVirtualGroup(context.Background(), gvg.Id) + if err != nil { + log.Errorw("failed to query global virtual group", "error", err) + return + } + } gvgMeta := &vgmgr.GlobalVirtualGroupMeta{ ID: gvg.GetId(), FamilyID: vgf.Id, @@ -432,8 +465,8 @@ func (vgm *virtualGroupManager) PickMigrateDestGlobalVirtualGroup(vgfID uint32, // TODO: in the future background thread can pre-allocate gvg and reduce impact on foreground thread. func (vgm *virtualGroupManager) ForceRefreshMeta() error { // sleep 5 seconds for waiting a new block - time.Sleep(5 * time.Second) - vgm.refreshMeta() + time.Sleep(RefreshMetaInterval) + vgm.refreshGVGMeta(true) return nil } @@ -513,6 +546,100 @@ func (vgm *virtualGroupManager) releaseSPAndGVGLoop() { } } +func (vgm *virtualGroupManager) monitorGVGUsage(gvg *virtualgrouptypes.GlobalVirtualGroup, vgParams *virtualgrouptypes.Params, byChain bool) (deposited, deleted bool, err error) { + needDeposit := func(gvg *virtualgrouptypes.GlobalVirtualGroup, vgParams *virtualgrouptypes.Params) bool { + return float64(gvg.GetStoredSize()) >= MaxStorageUsageRatio*float64(util.TotalStakingStoreSizeOfGVG(gvg, vgParams.GvgStakingPerBytes)) + } + isEmpty := func(gvg *virtualgrouptypes.GlobalVirtualGroup) bool { + return gvg.StoredSize == 0 + } + + curTime := time.Now().Unix() + if isEmpty(gvg) { + // Remove any GVG from the gvgGCMap if it is no longer empty. + vgm.gvgGCMap.Range(func(k, v interface{}) bool { + safeDeleteTime := v.(int64) + if curTime > safeDeleteTime+int64(time.Minute.Seconds()) { + vgm.gvgGCMap.Delete(k) + } + return true + }) + + if !byChain { + gvgID := gvg.Id + gvg, err = vgm.chainClient.QueryGlobalVirtualGroup(context.Background(), gvgID) + if err != nil { + log.Errorw("failed to query global virtual group", "gvg_id", gvgID, "error", err) + return + } + if !isEmpty(gvg) { + log.Warnw("the gvg is not empty by querying from chain ", "gvg", gvg) + return + } + } + log.Infow("found GVG is empty", "GVG", gvg) + var safeDeleteTime int64 + val, found := vgm.gvgGCMap.Load(gvg.Id) + if !found { + safeDeleteTime = curTime + emptyGVGSafeDeletePeriod + vgm.gvgGCMap.Store(gvg.Id, safeDeleteTime) + return + } + safeDeleteTime = val.(int64) + if curTime < safeDeleteTime { + log.Infow("GVG will be deleted at", "safe_delete_time", safeDeleteTime) + return + } + log.Infow("start to delete GVG", "GVG", gvg) + var deleteGVGHash string + deleteGVGHash, err = vgm.gfspClient.DeleteGlobalVirtualGroup(context.Background(), &virtualgrouptypes.MsgDeleteGlobalVirtualGroup{ + GlobalVirtualGroupId: gvg.Id, + }) + if err != nil { + log.Errorw("failed to delete global virtual group", "gvg_id", gvg.Id, "tx_hash", deleteGVGHash, "error", err) + return + } + vgm.gvgGCMap.Delete(gvg.Id) + log.Infow("successfully delete GVG", "GVG", gvg, "tx_hash", deleteGVGHash) + deleted = true + return + } + + if !needDeposit(gvg, vgParams) { + return + } + + msgDeposit := &virtualgrouptypes.MsgDeposit{ + GlobalVirtualGroupId: gvg.Id, + Deposit: sdk.Coin{ + Denom: vgParams.GetDepositDenom(), + Amount: vgParams.GvgStakingPerBytes.Mul(math.NewIntFromUint64(additionalGVGStakingStorageSize)), + }, + } + if !byChain { + gvgID := gvg.Id + gvg, err = vgm.chainClient.QueryGlobalVirtualGroup(context.Background(), gvgID) + if err != nil { + log.Errorw("failed to query global virtual group", "gvg_id", gvgID, "error", err) + return + } + if !needDeposit(gvg, vgParams) { + log.Warnw("the gvg does not need deposit by querying from chain", gvg, gvg) + return + } + } + log.Infow("found GVG need to deposit", "GVG", gvg) + var depositTxHash string + depositTxHash, err = vgm.gfspClient.Deposit(context.Background(), msgDeposit) + if err != nil { + log.Errorw("failed to deposit global virtual group", "gvg_id", gvg.Id, "tx_hash", depositTxHash, "error", err) + return + } + log.Infow("successfully deposit GVG", "GVG", gvg, "tx_hash", depositTxHash) + deposited = true + return +} + type HealthChecker struct { mutex sync.RWMutex // The mutex is used to guard sps and unhealthySPs sps map[uint32]*sptypes.StorageProvider // all sps, id -> StorageProvider diff --git a/base/types/gfspserver/sign.pb.go b/base/types/gfspserver/sign.pb.go index 65d7997ce..501b0b9f0 100644 --- a/base/types/gfspserver/sign.pb.go +++ b/base/types/gfspserver/sign.pb.go @@ -190,6 +190,8 @@ type GfSpSignRequest struct { // *GfSpSignRequest_GfspMigrateGvgTask // *GfSpSignRequest_GfspBucketMigrateInfo // *GfSpSignRequest_RejectMigrateBucket + // *GfSpSignRequest_Deposit + // *GfSpSignRequest_DeleteGlobalVirtualGroup Request isGfSpSignRequest_Request `protobuf_oneof:"request"` } @@ -307,6 +309,12 @@ type GfSpSignRequest_GfspBucketMigrateInfo struct { type GfSpSignRequest_RejectMigrateBucket struct { RejectMigrateBucket *types1.MsgRejectMigrateBucket `protobuf:"bytes,25,opt,name=reject_migrate_bucket,json=rejectMigrateBucket,proto3,oneof" json:"reject_migrate_bucket,omitempty"` } +type GfSpSignRequest_Deposit struct { + Deposit *types2.MsgDeposit `protobuf:"bytes,26,opt,name=deposit,proto3,oneof" json:"deposit,omitempty"` +} +type GfSpSignRequest_DeleteGlobalVirtualGroup struct { + DeleteGlobalVirtualGroup *types2.MsgDeleteGlobalVirtualGroup `protobuf:"bytes,27,opt,name=delete_global_virtual_group,json=deleteGlobalVirtualGroup,proto3,oneof" json:"delete_global_virtual_group,omitempty"` +} func (*GfSpSignRequest_CreateBucketInfo) isGfSpSignRequest_Request() {} func (*GfSpSignRequest_MigrateBucketInfo) isGfSpSignRequest_Request() {} @@ -333,6 +341,8 @@ func (*GfSpSignRequest_SpStoragePrice) isGfSpSignRequest_Request() func (*GfSpSignRequest_GfspMigrateGvgTask) isGfSpSignRequest_Request() {} func (*GfSpSignRequest_GfspBucketMigrateInfo) isGfSpSignRequest_Request() {} func (*GfSpSignRequest_RejectMigrateBucket) isGfSpSignRequest_Request() {} +func (*GfSpSignRequest_Deposit) isGfSpSignRequest_Request() {} +func (*GfSpSignRequest_DeleteGlobalVirtualGroup) isGfSpSignRequest_Request() {} func (m *GfSpSignRequest) GetRequest() isGfSpSignRequest_Request { if m != nil { @@ -516,6 +526,20 @@ func (m *GfSpSignRequest) GetRejectMigrateBucket() *types1.MsgRejectMigrateBucke return nil } +func (m *GfSpSignRequest) GetDeposit() *types2.MsgDeposit { + if x, ok := m.GetRequest().(*GfSpSignRequest_Deposit); ok { + return x.Deposit + } + return nil +} + +func (m *GfSpSignRequest) GetDeleteGlobalVirtualGroup() *types2.MsgDeleteGlobalVirtualGroup { + if x, ok := m.GetRequest().(*GfSpSignRequest_DeleteGlobalVirtualGroup); ok { + return x.DeleteGlobalVirtualGroup + } + return nil +} + // XXX_OneofWrappers is for the internal use of the proto package. func (*GfSpSignRequest) XXX_OneofWrappers() []interface{} { return []interface{}{ @@ -544,6 +568,8 @@ func (*GfSpSignRequest) XXX_OneofWrappers() []interface{} { (*GfSpSignRequest_GfspMigrateGvgTask)(nil), (*GfSpSignRequest_GfspBucketMigrateInfo)(nil), (*GfSpSignRequest_RejectMigrateBucket)(nil), + (*GfSpSignRequest_Deposit)(nil), + (*GfSpSignRequest_DeleteGlobalVirtualGroup)(nil), } } @@ -617,86 +643,89 @@ func init() { func init() { proto.RegisterFile("base/types/gfspserver/sign.proto", fileDescriptor_16c5938400680494) } var fileDescriptor_16c5938400680494 = []byte{ - // 1263 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x57, 0xcb, 0x6e, 0xdb, 0x46, - 0x17, 0x96, 0xe2, 0xfc, 0x96, 0x3d, 0x8e, 0x1d, 0x65, 0x62, 0xc7, 0x8c, 0x63, 0xe8, 0x57, 0xd4, - 0x22, 0x71, 0xdb, 0x84, 0x44, 0x14, 0x04, 0x45, 0x77, 0x8d, 0x73, 0x91, 0x54, 0xc0, 0x48, 0x40, - 0xb5, 0x29, 0x5a, 0xb4, 0x60, 0xa8, 0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x5f, 0x8c, 0xd4, 0x85, 0x66, 0xdd, 0x5d, 0x4d, - 0x4e, 0xba, 0xbe, 0x18, 0xb5, 0x59, 0x76, 0x69, 0xeb, 0x63, 0x3e, 0x95, 0xa7, 0xf8, 0x23, 0x58, - 0x4b, 0x45, 0xf0, 0xde, 0x92, 0x4f, 0xbd, 0xb9, 0xe8, 0xed, 0xdd, 0x5f, 0x6a, 0xa7, 0x4b, 0x6b, - 0x55, 0x0e, 0xdf, 0xfe, 0x75, 0xd6, 0xa8, 0xbe, 0x3f, 0x6b, 0x54, 0xff, 0x39, 0x6b, 0x54, 0xff, - 0x38, 0x6f, 0x54, 0xde, 0x9f, 0x37, 0x2a, 0x7f, 0x9f, 0x37, 0x2a, 0xdf, 0xbf, 0x0c, 0x49, 0x32, - 0x9a, 0x0c, 0x6c, 0x44, 0xc7, 0xce, 0x20, 0x1e, 0x3c, 0x44, 0x23, 0x9f, 0xc4, 0x4e, 0xd6, 0xec, - 0x87, 0xa6, 0xd9, 0x0f, 0x99, 0x19, 0x6d, 0x67, 0xee, 0x0f, 0xa3, 0xc1, 0xaa, 0xfa, 0x11, 0xf0, - 0xf8, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7c, 0x0a, 0x01, 0x1d, 0x38, 0x0d, 0x00, 0x00, + // 1302 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x57, 0xcf, 0x73, 0xdb, 0xc4, + 0x17, 0xb7, 0x9b, 0x7e, 0xe3, 0x64, 0xd3, 0xa4, 0xee, 0x26, 0x69, 0xd4, 0x24, 0xe3, 0xaf, 0x6b, + 0x98, 0x36, 0x40, 0x6b, 0x4d, 0x53, 0x3a, 0x0c, 0x27, 0x68, 0xfa, 0x23, 0x31, 0x33, 0x99, 0x76, + 0x64, 0x28, 0x03, 0x03, 0xa3, 0xca, 0xab, 0xb5, 0xbc, 0xc4, 0xd6, 0x2e, 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 0x77, 0xf5, 0xe2, + 0x65, 0x98, 0xaf, 0x0f, 0xb8, 0x8e, 0x67, 0xfa, 0xa7, 0xa7, 0x8d, 0xf5, 0xe6, 0xac, 0x47, 0x34, + 0x48, 0x86, 0x92, 0xc2, 0x0e, 0x77, 0xcd, 0xcb, 0x04, 0x78, 0x0b, 0x55, 0x92, 0x53, 0xbf, 0x17, + 0xa8, 0x1e, 0x2c, 0x62, 0xcb, 0xde, 0x62, 0x72, 0x7a, 0x14, 0xa8, 0xde, 0xbe, 0xc8, 0x96, 0xcd, + 0x36, 0x95, 0x23, 0xdd, 0x7d, 0x3f, 0xa2, 0xa5, 0x54, 0x84, 0xef, 0xcc, 0x59, 0x51, 0xec, 0x82, + 0xba, 0x7d, 0x77, 0xae, 0x9d, 0x39, 0x5a, 0xa3, 0x74, 0xf0, 0xfa, 0xcf, 0xf3, 0x5a, 0xf9, 0xed, + 0x79, 0xad, 0xfc, 0xf7, 0x79, 0xad, 0xfc, 0xc7, 0xbb, 0x5a, 0xe9, 0xed, 0xbb, 0x5a, 0xe9, 0xaf, + 0x77, 0xb5, 0xd2, 0xf7, 0xcf, 0x23, 0x96, 0xf4, 0x86, 0x9d, 0x26, 0xe1, 0x03, 0xb7, 0x13, 0x77, + 0xee, 0x93, 0x5e, 0xc0, 0x62, 0x37, 0xab, 0xfd, 0x7d, 0xdb, 0x24, 0xf7, 0x85, 0x1d, 0x49, 0x77, + 0xea, 0x07, 0x5d, 0x67, 0x11, 0x3e, 0x5e, 0x1e, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xef, 0xf3, + 0x09, 0x7d, 0xf0, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1463,6 +1492,52 @@ func (m *GfSpSignRequest_RejectMigrateBucket) MarshalToSizedBuffer(dAtA []byte) } return len(dAtA) - i, nil } +func (m *GfSpSignRequest_Deposit) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GfSpSignRequest_Deposit) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Deposit != nil { + { + size, err := m.Deposit.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSign(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xd2 + } + return len(dAtA) - i, nil +} +func (m *GfSpSignRequest_DeleteGlobalVirtualGroup) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GfSpSignRequest_DeleteGlobalVirtualGroup) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.DeleteGlobalVirtualGroup != nil { + { + size, err := m.DeleteGlobalVirtualGroup.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSign(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xda + } + return len(dAtA) - i, nil +} func (m *GfSpSignResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1883,6 +1958,30 @@ func (m *GfSpSignRequest_RejectMigrateBucket) Size() (n int) { } return n } +func (m *GfSpSignRequest_Deposit) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Deposit != nil { + l = m.Deposit.Size() + n += 2 + l + sovSign(uint64(l)) + } + return n +} +func (m *GfSpSignRequest_DeleteGlobalVirtualGroup) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.DeleteGlobalVirtualGroup != nil { + l = m.DeleteGlobalVirtualGroup.Size() + n += 2 + l + sovSign(uint64(l)) + } + return n +} func (m *GfSpSignResponse) Size() (n int) { if m == nil { return 0 @@ -3147,6 +3246,76 @@ func (m *GfSpSignRequest) Unmarshal(dAtA []byte) error { } m.Request = &GfSpSignRequest_RejectMigrateBucket{v} iNdEx = postIndex + case 26: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Deposit", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSign + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSign + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSign + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types2.MsgDeposit{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Request = &GfSpSignRequest_Deposit{v} + iNdEx = postIndex + case 27: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DeleteGlobalVirtualGroup", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSign + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSign + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSign + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &types2.MsgDeleteGlobalVirtualGroup{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Request = &GfSpSignRequest_DeleteGlobalVirtualGroup{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipSign(dAtA[iNdEx:]) diff --git a/core/module/modular.go b/core/module/modular.go index 203c25829..acadc51fd 100644 --- a/core/module/modular.go +++ b/core/module/modular.go @@ -309,6 +309,10 @@ type Signer interface { SignBucketMigrationInfo(ctx context.Context, task *gfsptask.GfSpBucketMigrationInfo) ([]byte, error) // RejectMigrateBucket rejects the bucket migration by dest SP. RejectMigrateBucket(ctx context.Context, rejectMigrateBucket *storagetypes.MsgRejectMigrateBucket) (string, error) + // Deposit into a Global virtual group for more store size + Deposit(ctx context.Context, deposit *virtualgrouptypes.MsgDeposit) (string, error) + // DeleteGlobalVirtualGroup rejects the bucket migration by dest SP. + DeleteGlobalVirtualGroup(ctx context.Context, deleteGVG *virtualgrouptypes.MsgDeleteGlobalVirtualGroup) (string, error) } // Uploader is an abstract interface to handle putting object requests from users' account and store diff --git a/core/module/modular_mock.go b/core/module/modular_mock.go index 5c373228b..4046760f4 100644 --- a/core/module/modular_mock.go +++ b/core/module/modular_mock.go @@ -1668,6 +1668,16 @@ type MockSigner struct { recorder *MockSignerMockRecorder } +func (m *MockSigner) Deposit(ctx context.Context, deposit *types1.MsgDeposit) (string, error) { + //TODO implement me + panic("implement me") +} + +func (m *MockSigner) DeleteGlobalVirtualGroup(ctx context.Context, deleteGVG *types1.MsgDeleteGlobalVirtualGroup) (string, error) { + //TODO implement me + panic("implement me") +} + // MockSignerMockRecorder is the mock recorder for MockSigner. type MockSignerMockRecorder struct { mock *MockSigner diff --git a/core/module/null_modular.go b/core/module/null_modular.go index 51283fd39..c27fc9cbc 100644 --- a/core/module/null_modular.go +++ b/core/module/null_modular.go @@ -272,6 +272,12 @@ func (*NilModular) CompleteMigrateBucket(ctx context.Context, migrateBucket *sto func (m *NilModular) RejectMigrateBucket(ctx context.Context, rejectMigrateBucket *storagetypes.MsgRejectMigrateBucket) (string, error) { return "", ErrNilModular } +func (m *NilModular) Deposit(ctx context.Context, deposit *virtualgrouptypes.MsgDeposit) (string, error) { + return "", ErrNilModular +} +func (m *NilModular) DeleteGlobalVirtualGroup(ctx context.Context, deleteGVG *virtualgrouptypes.MsgDeleteGlobalVirtualGroup) (string, error) { + return "", ErrNilModular +} func (*NilModular) SignSecondarySPMigrationBucket(ctx context.Context, signDoc *storagetypes.SecondarySpMigrationBucketSignDoc) ([]byte, error) { return nil, ErrNilModular } diff --git a/core/vgmgr/virtual_group_manager.go b/core/vgmgr/virtual_group_manager.go index 65410b559..cbbc2f9dd 100644 --- a/core/vgmgr/virtual_group_manager.go +++ b/core/vgmgr/virtual_group_manager.go @@ -1,6 +1,7 @@ package vgmgr import ( + "github.com/bnb-chain/greenfield-storage-provider/base/gfspclient" "github.com/bnb-chain/greenfield-storage-provider/core/consensus" sptypes "github.com/bnb-chain/greenfield/x/sp/types" virtualgrouptypes "github.com/bnb-chain/greenfield/x/virtualgroup/types" @@ -146,6 +147,6 @@ type VirtualGroupManager interface { } // NewVirtualGroupManager is the virtual group manager init api. -type NewVirtualGroupManager = func(selfOperatorAddress string, chainClient consensus.Consensus, enableHealthyChecker bool) (VirtualGroupManager, error) +type NewVirtualGroupManager = func(selfOperatorAddress string, chainClient consensus.Consensus, gfspClient gfspclient.GfSpClientAPI, enableHealthyChecker bool) (VirtualGroupManager, error) type IDSet = map[uint32]struct{} diff --git a/modular/approver/approver.go b/modular/approver/approver.go index a60986414..9fe93b3ff 100644 --- a/modular/approver/approver.go +++ b/modular/approver/approver.go @@ -54,7 +54,7 @@ type ApprovalModular struct { // the maximum number of GVGs migrating to current SP concurrently is allowed migrateGVGLimit int - statsMutex sync.Mutex + statsMutex sync.RWMutex tasksStats *managerTasksStats spID uint32 @@ -166,13 +166,13 @@ func (a *ApprovalModular) getSPID() (uint32, error) { } func (a *ApprovalModular) exceedCreateObjectLimit() bool { - a.statsMutex.Lock() - defer a.statsMutex.Unlock() + a.statsMutex.RLock() + defer a.statsMutex.RUnlock() return a.tasksStats.totalUploadTasks() >= a.tasksStats.maxUploadingCount } func (a *ApprovalModular) exceedMigrateGVGLimit() bool { - a.statsMutex.Lock() - defer a.statsMutex.Unlock() + a.statsMutex.RLock() + defer a.statsMutex.RUnlock() return a.tasksStats.migrateGVGCount >= uint32(a.migrateGVGLimit) } diff --git a/modular/manager/manage_task.go b/modular/manager/manage_task.go index 61bafc6a5..5095565cd 100644 --- a/modular/manager/manage_task.go +++ b/modular/manager/manage_task.go @@ -373,11 +373,10 @@ func (m *ManageModular) handleFailedReplicatePieceTask(ctx context.Context, hand m.replicateQueue.PopByKey(handleTask.Key()) return nil } - gvgID := handleTask.GetGlobalVirtualGroupId() - gvg, err := m.baseApp.Consensus().QueryGlobalVirtualGroup(context.Background(), gvgID) + gvg, err := m.baseApp.GfSpClient().GetGlobalVirtualGroupByGvgID(ctx, gvgID) if err != nil { - log.Errorw("failed to query global virtual group from chain, ", "gvgID", gvgID, "error", err) + log.Errorw("failed to query global virtual group from Meta", "gvgID", gvgID, "error", err) return err } sspID := gvg.GetSecondarySpIds()[handleTask.GetNotAvailableSpIdx()] diff --git a/modular/manager/manager_options.go b/modular/manager/manager_options.go index f5b129fe5..084b5b23a 100644 --- a/modular/manager/manager_options.go +++ b/modular/manager/manager_options.go @@ -266,7 +266,7 @@ func DefaultManagerOptions(manager *ManageModular, cfg *gfspconfig.GfSpConfig) ( manager.challengeQueue = cfg.Customize.NewStrategyTQueueFunc( manager.Name()+"-cache-challenge-piece", cfg.Parallel.GlobalChallengePieceTaskCacheSize) - if manager.virtualGroupManager, err = cfg.Customize.NewVirtualGroupManagerFunc(manager.baseApp.OperatorAddress(), manager.baseApp.Consensus(), manager.enableHealthyChecker); err != nil { + if manager.virtualGroupManager, err = cfg.Customize.NewVirtualGroupManagerFunc(manager.baseApp.OperatorAddress(), manager.baseApp.Consensus(), manager.baseApp.GfSpClient(), manager.enableHealthyChecker); err != nil { return err } if cfg.Manager.SubscribeSPExitEventIntervalMillisecond == 0 { diff --git a/modular/signer/signer.go b/modular/signer/signer.go index 3949da726..a5d1668d1 100644 --- a/modular/signer/signer.go +++ b/modular/signer/signer.go @@ -34,6 +34,8 @@ var ( ErrCompleteSPExitOnChain = gfsperrors.Register(module.SignModularName, http.StatusBadRequest, 120011, "send complete sp exit failed") ErrUpdateSPPriceOnChain = gfsperrors.Register(module.SignModularName, http.StatusBadRequest, 120012, "send update sp price failed") ErrRejectMigrateBucketOnChain = gfsperrors.Register(module.SignModularName, http.StatusBadRequest, 120013, "send reject migrate bucket failed") + ErrDepositOnChain = gfsperrors.Register(module.SignModularName, http.StatusBadRequest, 120014, "send deposit failed") + ErrDeleteGVGOnChain = gfsperrors.Register(module.SignModularName, http.StatusBadRequest, 120015, "send delete GVG failed") ) var _ module.Signer = &SignModular{} @@ -226,3 +228,12 @@ func (s *SignModular) CompleteSPExit(ctx context.Context, completeSPExit *virtua func (s *SignModular) RejectMigrateBucket(ctx context.Context, rejectMigrateBucket *storagetypes.MsgRejectMigrateBucket) (string, error) { return s.client.RejectMigrateBucket(ctx, SignOperator, rejectMigrateBucket) } + +func (s *SignModular) Deposit(ctx context.Context, deposit *virtualgrouptypes.MsgDeposit) (string, error) { + return s.client.Deposit(ctx, SignOperator, deposit) +} + +func (s *SignModular) DeleteGlobalVirtualGroup(ctx context.Context, deleteGVG *virtualgrouptypes.MsgDeleteGlobalVirtualGroup) (string, error) { + return s.client.DeleteGlobalVirtualGroup(ctx, SignOperator, deleteGVG) + +} diff --git a/modular/signer/signer_client.go b/modular/signer/signer_client.go index a868ba5f0..32cc80836 100644 --- a/modular/signer/signer_client.go +++ b/modular/signer/signer_client.go @@ -829,6 +829,112 @@ func (client *GreenfieldChainSignClient) RejectMigrateBucket(ctx context.Context return "", ErrRejectMigrateBucketOnChain } +func (client *GreenfieldChainSignClient) Deposit(ctx context.Context, scope SignType, + msg *virtualgrouptypes.MsgDeposit) (string, error) { + log.Infow("signer starts to make deposit into GVG", "scope", scope) + if msg == nil { + log.CtxError(ctx, "deposit msg pointer dangling") + return "", ErrDanglingPointer + } + km, err := client.greenfieldClients[scope].GetKeyManager() + if err != nil { + log.CtxErrorw(ctx, "failed to get private key", "error", err) + return "", ErrSignMsg + } + + client.opLock.Lock() + defer client.opLock.Unlock() + + msgDeposit := virtualgrouptypes.NewMsgDeposit(km.GetAddr(), msg.GlobalVirtualGroupId, msg.Deposit) + + var ( + txHash string + nonce uint64 + nonceErr error + ) + for i := 0; i < BroadcastTxRetry; i++ { + nonce = client.operatorAccNonce + txOpt := &ctypes.TxOption{ + Nonce: nonce, + } + txHash, err = client.broadcastTx(ctx, client.greenfieldClients[scope], []sdk.Msg{msgDeposit}, txOpt) + if errors.IsOf(err, sdkErrors.ErrWrongSequence) { + // if nonce mismatches, waiting for next block, reset nonce by querying the nonce on chain + nonce, nonceErr = client.getNonceOnChain(ctx, client.greenfieldClients[scope]) + if nonceErr != nil { + log.CtxErrorw(ctx, "failed to get operator account nonce", "error", err) + ErrDepositOnChain.SetError(fmt.Errorf("failed to get operator account nonce, error: %v", err)) + return "", ErrDepositOnChain + } + client.operatorAccNonce = nonce + } + if err != nil { + log.CtxErrorw(ctx, "failed to broadcast deposit tx", "retry_number", i, "error", err) + continue + } + client.operatorAccNonce = nonce + 1 + log.CtxDebugw(ctx, "succeed to broadcast deposit tx", "tx_hash", txHash, "deposit_msg", msgDeposit) + return txHash, nil + } + + // failed to broadcast tx + ErrDepositOnChain.SetError(fmt.Errorf("failed to broadcast deposit, error: %v", err)) + return "", ErrDepositOnChain +} + +func (client *GreenfieldChainSignClient) DeleteGlobalVirtualGroup(ctx context.Context, scope SignType, + msg *virtualgrouptypes.MsgDeleteGlobalVirtualGroup) (string, error) { + log.Infow("signer starts to delete GVG", "scope", scope) + if msg == nil { + log.CtxError(ctx, "delete GVG msg pointer dangling") + return "", ErrDanglingPointer + } + km, err := client.greenfieldClients[scope].GetKeyManager() + if err != nil { + log.CtxErrorw(ctx, "failed to get private key", "error", err) + return "", ErrSignMsg + } + + client.opLock.Lock() + defer client.opLock.Unlock() + + msgDeleteGlobalVirtualGroup := virtualgrouptypes.NewMsgDeleteGlobalVirtualGroup(km.GetAddr(), msg.GetGlobalVirtualGroupId()) + + var ( + txHash string + nonce uint64 + nonceErr error + ) + for i := 0; i < BroadcastTxRetry; i++ { + nonce = client.operatorAccNonce + txOpt := &ctypes.TxOption{ + Nonce: nonce, + } + txHash, err = client.broadcastTx(ctx, client.greenfieldClients[scope], []sdk.Msg{msgDeleteGlobalVirtualGroup}, txOpt) + if errors.IsOf(err, sdkErrors.ErrWrongSequence) { + // if nonce mismatches, waiting for next block, reset nonce by querying the nonce on chain + nonce, nonceErr = client.getNonceOnChain(ctx, client.greenfieldClients[scope]) + if nonceErr != nil { + log.CtxErrorw(ctx, "failed to get operator account nonce", "error", err) + ErrDeleteGVGOnChain.SetError(fmt.Errorf("failed to get operator account nonce, error: %v", err)) + return "", ErrDeleteGVGOnChain + } + client.operatorAccNonce = nonce + } + if err != nil { + log.CtxErrorw(ctx, "failed to broadcast delete GVG tx", "retry_number", i, "error", err) + continue + } + client.operatorAccNonce = nonce + 1 + log.CtxDebugw(ctx, "succeed to broadcast delete GVG tx", "tx_hash", txHash, "reject_migrate_bucket_msg", msgDeleteGlobalVirtualGroup) + return txHash, nil + } + + // failed to broadcast tx + ErrDeleteGVGOnChain.SetError(fmt.Errorf("failed to broadcast delete GVG, error: %v", err)) + return "", ErrDeleteGVGOnChain +} + func (client *GreenfieldChainSignClient) getNonceOnChain(ctx context.Context, gnfdClient *client.GreenfieldClient) (uint64, error) { err := client.signer.baseApp.Consensus().WaitForNextBlock(ctx) if err != nil { diff --git a/modular/uploader/upload_task.go b/modular/uploader/upload_task.go index b92c46e3f..089bd7eb9 100644 --- a/modular/uploader/upload_task.go +++ b/modular/uploader/upload_task.go @@ -9,6 +9,7 @@ import ( "net/http" "time" + "github.com/avast/retry-go/v4" "github.com/bnb-chain/greenfield-common/go/hash" "github.com/bnb-chain/greenfield-storage-provider/base/types/gfsperrors" "github.com/bnb-chain/greenfield-storage-provider/core/module" @@ -21,6 +22,13 @@ import ( storagetypes "github.com/bnb-chain/greenfield/x/storage/types" ) +var ( + rtyAttNum = uint(3) + rtyAttem = retry.Attempts(rtyAttNum) + rtyDelay = retry.Delay(time.Millisecond * 500) + rtyErr = retry.LastErrorOnly(true) +) + var ( ErrDanglingUploadTask = gfsperrors.Register(module.UploadModularName, http.StatusBadRequest, 110001, "OoooH... request lost, try again later") ErrNotCreatedState = gfsperrors.Register(module.UploadModularName, http.StatusForbidden, 110002, "object not created state") @@ -95,7 +103,16 @@ func (u *UploadModular) HandleUploadObjectTask(ctx context.Context, uploadObject metrics.PerfPutObjectTime.WithLabelValues("uploader_put_object_end_from_task_create").Observe(time.Since(time.Unix(uploadObjectTask.GetCreateTime(), 0)).Seconds()) go func() { metrics.PerfPutObjectTime.WithLabelValues("uploader_put_object_before_report_manager_end").Observe(time.Since(time.Unix(uploadObjectTask.GetCreateTime(), 0)).Seconds()) - _ = u.baseApp.GfSpClient().ReportTask(context.Background(), uploadObjectTask) + if err = retry.Do(func() error { + return u.baseApp.GfSpClient().ReportTask(context.Background(), uploadObjectTask) + }, rtyAttem, + rtyDelay, + rtyErr, + retry.OnRetry(func(n uint, err error) { + log.CtxErrorw(ctx, "failed to report upload object task", "error", err, "attempt", n, "max_attempts", rtyAttNum) + })); err != nil { + log.CtxErrorw(ctx, "failed to report upload object task", "error", err) + } metrics.PerfPutObjectTime.WithLabelValues("uploader_put_object_after_report_manager_end").Observe(time.Since(time.Unix(uploadObjectTask.GetCreateTime(), 0)).Seconds()) }() }() @@ -224,7 +241,16 @@ func (u *UploadModular) HandleResumableUploadObjectTask(ctx context.Context, tas "read_size", readSize, "error", err) go func() { metrics.PerfPutObjectTime.WithLabelValues("uploader_put_object_before_report_manager_end").Observe(time.Since(time.Unix(task.GetCreateTime(), 0)).Seconds()) - _ = u.baseApp.GfSpClient().ReportTask(context.Background(), task) + if err = retry.Do(func() error { + return u.baseApp.GfSpClient().ReportTask(context.Background(), task) + }, rtyAttem, + rtyDelay, + rtyErr, + retry.OnRetry(func(n uint, err error) { + log.CtxErrorw(ctx, "failed to report upload object task", "error", err, "attempt", n, "max_attempts", rtyAttNum) + })); err != nil { + log.CtxErrorw(ctx, "failed to report upload object task", "error", err) + } metrics.PerfPutObjectTime.WithLabelValues("uploader_put_object_after_report_manager_end").Observe(time.Since(time.Unix(task.GetCreateTime(), 0)).Seconds()) }() }() diff --git a/proto/base/types/gfspserver/sign.proto b/proto/base/types/gfspserver/sign.proto index 3f1c51c02..2f96ec192 100644 --- a/proto/base/types/gfspserver/sign.proto +++ b/proto/base/types/gfspserver/sign.proto @@ -53,6 +53,8 @@ message GfSpSignRequest { base.types.gfsptask.GfSpMigrateGVGTask gfsp_migrate_gvg_task = 23; base.types.gfsptask.GfSpBucketMigrationInfo gfsp_bucket_migrate_info = 24; greenfield.storage.MsgRejectMigrateBucket reject_migrate_bucket = 25; + greenfield.virtualgroup.MsgDeposit deposit = 26; + greenfield.virtualgroup.MsgDeleteGlobalVirtualGroup delete_global_virtual_group = 27; } }