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

[finalizer] Update confirmation block number in finalizer #600

Merged

Conversation

ian-shim
Copy link
Contributor

@ian-shim ian-shim commented Jun 5, 2024

Why are these changes needed?

The confirmationBlockNumber retrieved from the confirmation transaction may have been updated due to chain reorg.
This PR makes the finalizer update the confirmationBlockNumber to keep the metadata in sync.

Checks

  • I've made sure the lint is passing in this PR.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, in that case, please comment that they are not relevant.
  • Testing Strategy
    • Unit tests
    • Integration tests
    • This PR is not tested :(

@ian-shim ian-shim requested review from mooselumph and jianoaix June 5, 2024 22:35
@ian-shim ian-shim force-pushed the finalizer-update-confirmation-block branch from a3a2b85 to 2814241 Compare June 5, 2024 22:48
@ian-shim ian-shim marked this pull request as ready for review June 5, 2024 22:49
return &newMetadata, s.blobMetadataStore.UpdateBlobMetadata(ctx, existingMetadata.GetBlobKey(), &newMetadata)
}

func (s *SharedBlobStore) MarkBlobFinalized(ctx context.Context, metadataKey disperser.BlobKey) error {
return s.blobMetadataStore.SetBlobStatus(ctx, metadataKey, disperser.Finalized)
func (s *SharedBlobStore) MarkBlobFinalized(ctx context.Context, existingMetadata *disperser.BlobMetadata, confirmationBlockNumber uint64) (*disperser.BlobMetadata, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks a more robust and simpler interface if the entire read-validate-update status-write back flow is in one function, as these steps are all tightly coupled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean by read-validate-update status-write back flow?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of taking a "existingMetadata" from the caller, this method can just take the potentially new confirmation block number: and internally it reads the metadata, compare the confirmation number with the given one, and if they are different, update it and write back. It's cleaner as it doesn't need to assume a "existingMetadata".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reverted this method back so it just updates the blob status.
I added a separate method UpdateConfirmationBlockNumber and update the confirmation block number regardless of whether the block is finalized or not as we need to update the confirmation block even when it's in CONFIRMED state.

@ian-shim ian-shim force-pushed the finalizer-update-confirmation-block branch 2 times, most recently from 4d710d7 to e9cdadb Compare June 7, 2024 21:08
@ian-shim ian-shim changed the title [finalizer] Update confirmation block number on MarkFinalized [finalizer] Update confirmation block number in finalizer Jun 7, 2024
@ian-shim ian-shim requested a review from jianoaix June 14, 2024 14:26
func (s *BlobMetadataStore) UpdateConfirmationBlockNumber(ctx context.Context, existingMetadata *disperser.BlobMetadata, confirmationBlockNumber uint32) error {
updated := *existingMetadata
if updated.ConfirmationInfo == nil {
return fmt.Errorf("failed to update confirmation block number because confirmation info is missing for metadata %s", existingMetadata.GetBlobKey().String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "... is missing for blobkey ..."

@ian-shim ian-shim force-pushed the finalizer-update-confirmation-block branch from e9cdadb to 288d981 Compare June 17, 2024 15:56
@ian-shim ian-shim merged commit a88deff into Layr-Labs:master Jun 17, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants