Skip to content

Add BlockDatabase interface to database #4133

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

Draft
wants to merge 1 commit into
base: dl/blockdb
Choose a base branch
from

Conversation

DracoLi
Copy link
Contributor

@DracoLi DracoLi commented Jul 28, 2025

Why this should be merged

Add an BlockDatabase interface to database package. This will be used by the VMs to integrate x/blockdb.

How this works

How this was tested

Need to be documented in RELEASES.md?

No

// ReadBlock retrieves a block by its height.
ReadBlock(height uint64) ([]byte, error)

// ReadHeader retrieves only the header portion of a block by its height.
Copy link
Contributor

Choose a reason for hiding this comment

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

In avalanchego we also need to just read the block ID, which is used to service block dissemination.

I guess this header is only used for C-chain, but probably we should have yet another API call for the block ID...?

Copy link
Contributor Author

@DracoLi DracoLi Aug 1, 2025

Choose a reason for hiding this comment

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

I think we can keep this mapping data (id -> height) still stored in the key-value db. The blockdb can just store the bytes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah ReadHeader is specifically added for the c-chain since their interface allows reading header & body separately. However, I'm also exploring whether we can just not to support this, as the benefits appear to be minimal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants