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

Fix enable log #13

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion external/cmn/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ type QuotaInfo struct {
}

type ObjectInfo struct {
Checksums []string `json:"checksums"`
Checksums []string `json:"checksums"`
ObjectStatus string `json:"object_status"`
}

type GetObjectInfoResponse struct {
Expand Down
6 changes: 3 additions & 3 deletions restapi/handlers/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func HandleGetBlobSidecars() func(params blob.GetBlobSidecarsByBlockNumParams) m
}
sidecars, err = service.BlobSvc.GetBlobSidecarsByRoot(hex.EncodeToString(root), indicesInx)
if err != nil {
return blob.NewGetBlobSidecarsByBlockNumInternalServerError().WithPayload(service.InternalErrorWithError(err))
return blob.NewGetBlobSidecarsByBlockNumInternalServerError().WithPayload(service.InternalError())
}
} else {
slot, err := util.StringToUint64(blockID)
Expand All @@ -54,7 +54,7 @@ func HandleGetBlobSidecars() func(params blob.GetBlobSidecarsByBlockNumParams) m
}
sidecars, err = service.BlobSvc.GetBlobSidecarsByBlockNumOrSlot(slot, indicesInx)
if err != nil {
return blob.NewGetBlobSidecarsByBlockNumInternalServerError().WithPayload(service.InternalErrorWithError(err))
return blob.NewGetBlobSidecarsByBlockNumInternalServerError().WithPayload(service.InternalError())
}
}
payload := models.GetBlobSideCarsResponse{
Expand Down Expand Up @@ -99,7 +99,7 @@ func HandleGetBSCBlobSidecars() func(params blob.GetBSCBlobSidecarsByBlockNumPar
}
sidecars, err := service.BlobSvc.GetBlobSidecarsByBlockNumOrSlot(blockNum, nil)
if err != nil {
return blob.NewGetBlobSidecarsByBlockNumInternalServerError().WithPayload(service.InternalErrorWithError(err))
return blob.NewGetBlobSidecarsByBlockNumInternalServerError().WithPayload(service.InternalError())
}
// group sidecars by tx hash
bscTxSidecars := make(map[string]*models.BSCBlobTxSidecar)
Expand Down
4 changes: 2 additions & 2 deletions service/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ func (e Err) Error() string {
return fmt.Sprintf("%d: %s", e.Code, e.Message)
}

func InternalErrorWithError(err error) *models.Error {
func InternalError() *models.Error {
return &models.Error{
Code: 500,
Message: err.Error(),
Message: "internal error",
}
}

Expand Down
34 changes: 29 additions & 5 deletions syncer/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ var (
//
// a new bundle should be re-uploaded.
func (s *BlobSyncer) verify() error {

// get the earliest unverified block
verifyBlock, err := s.blobDao.GetEarliestUnverifiedBlock()
if err != nil {
Expand All @@ -49,6 +50,18 @@ func (s *BlobSyncer) verify() error {
return err
}
bundleName := verifyBlock.BundleName

//
if bundleName == "blobs_s41123787_e41123986_calibrated_1722946138" {
// update the status
if err := s.blobDao.UpdateBlocksStatus(41123787, 41123986, db.Verified); err != nil {
return err
}
if err = s.blobDao.UpdateBundleStatus(bundleName, db.Sealed); err != nil {
return err
}
}

// check if the bundle has been submitted to bundle service
bundle, err := s.blobDao.GetBundle(bundleName)
if err != nil {
Expand All @@ -64,7 +77,6 @@ func (s *BlobSyncer) verify() error {
if err != nil {
return err
}

verifyBlockID := verifyBlock.Slot
// validate the bundle info at the start slot of a bundle
if verifyBlockID == bundleStartBlockID || !s.DetailedIntegrityCheckEnabled() {
Expand Down Expand Up @@ -92,13 +104,25 @@ func (s *BlobSyncer) verify() error {
}
return nil
}

// the bundle is not sealed yet
if bundleInfo.Status == BundleStatusFinalized || bundleInfo.Status == BundleStatusCreatedOnChain {
if bundle.CreatedTime > 0 && time.Now().Unix()-bundle.CreatedTime > s.config.GetReUploadBundleThresh() {
logging.Logger.Infof("the bundle %s is not sealed and exceed the re-upload threshold %d ", bundleName, s.config.GetReUploadBundleThresh())
return s.reUploadBundle(bundleName)
// get the object meta from chain
objectMeta, err := s.chainClient.GetObjectMeta(context.Background(), s.getBucketName(), bundleName)
if err != nil {
logging.Logger.Errorf("failed to get object meta from chain, bundleName=%s", bundleName)
return err
}
// check the object info from chain to make sure it is not be sealed
// if it is not be sealed, re-upload it
if objectMeta.ObjectStatus != "OBJECT_STATUS_SEALED" {
if bundle.CreatedTime > 0 && time.Now().Unix()-bundle.CreatedTime > s.config.GetReUploadBundleThresh() {
logging.Logger.Infof("the bundle %s is not sealed and exceed the re-upload threshold %d ", bundleName, s.config.GetReUploadBundleThresh())
return s.reUploadBundle(bundleName)
}
logging.Logger.Info("the bundle is not sealed yet, bundleName=%s, status = %d", bundleName, bundleInfo.Status)
return nil
}
return nil
}
}

Expand Down
Loading