Skip to content

core/txpool/blobpool: migrate billy to new slot size #31966

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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

MariusVanDerWijden
Copy link
Member

@MariusVanDerWijden MariusVanDerWijden commented Jun 4, 2025

Implements a migration path for the blobpool slotter

@fjl fjl changed the title WIP: Peerdas slotter core/txpool/blobpool: peerdas slotter Jun 17, 2025
@MariusVanDerWijden MariusVanDerWijden changed the title core/txpool/blobpool: peerdas slotter core/txpool/blobpool: migrate billy for new slot size Jul 7, 2025
@MariusVanDerWijden MariusVanDerWijden changed the title core/txpool/blobpool: migrate billy for new slot size core/txpool/blobpool: migrate billy to new slot size Jul 7, 2025
// txBlobOverhead is an approximation of the overhead that an additional blob
// has on transaction size. This is added to the slotter to avoid
// tiny overflows causing all txs to move a shelf higher, wasting disk space.
txBlobOverhead = 2048
Copy link
Member

Choose a reason for hiding this comment

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

Just curious, is this a cautious estimate or based on a specific computation?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is an estimation based on specific computation :D
I computed the size of a bunch of blob transactions and found that the overhead is ~1300 bytes iirc. So 2048 kinda gives us a round estimate over that

Copy link
Member

@rjl493456442 rjl493456442 Jul 25, 2025

Choose a reason for hiding this comment

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

I think we should update this value.

The size of original proof is 48 bytes, while the new version cell proof is 128 * 48 = 6144, already beyond this constant.

if p.chain.Config().IsOsaka(head.Number, head.Time) {
// Check if we need to migrate our blob db to the new slotter
oldSlotSize := 135168
if os.Stat(filepath.Join(queuedir, fmt.Sprintf("bkt_%08d.bag", oldSlotSize))); err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

These seems to be taking advantage of billy internals -- can we just open the db and use Infos() to get the current slot size?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could, but that would mean we need to open the DB. I agree that this is not a super clean solution...

@fjl fjl added the osaka label Jul 10, 2025
@lightclient
Copy link
Member

@MariusVanDerWijden let me know what you think about this last commit. I think the best thing to do is probably make a PR to billy to improve the migration flow, but given the current interface it seems like this is the best we can do downstream without hard coding any billy-specific behavior.

@rjl493456442 rjl493456442 self-assigned this Jul 22, 2025

return func() (size uint32, done bool) {
slotsize += blobSize + txBlobOverhead
finished := slotsize > uint32(maxBlobsPerTransaction)*blobSize+txMaxSize
Copy link
Member

Choose a reason for hiding this comment

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

The target should be uint32(maxBlobsPerTransaction)*(blobSize+txBlobOverhead)+txMaxSize

// perform a migration then write the updated version of the store.
if version < storeVersion {
newSlotter := newSlotterEIP7594(eip4844.LatestMaxBlobsPerBlock(p.chain.Config()))
if err := billy.Migrate(billy.Options{Path: queuedir, Repair: true}, slotter, newSlotter); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit awkward.

Before the migration, the blob transactions may still still carry the v0 sidecar. We should make the conversion first, and then migrate them to the new shelves respectively.

// Index all transactions on disk and delete anything unprocessable
var fails []uint64
index := func(id uint64, size uint32, blob []byte) {
if len(blob) == 1 {
Copy link
Member

Choose a reason for hiding this comment

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

It's actually unnecessary, we can probably keep it, but emit a big warning if it occurs.

the slotter won't contain the shelf for the metadata.

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

Successfully merging this pull request may close these issues.

4 participants