Skip to content

refactor(fast-inbox): some cleanups - #25422

Open
LeilaWang wants to merge 7 commits into
spl/fi2-message-only-docsfrom
lw/fast-inbox-cleanup
Open

refactor(fast-inbox): some cleanups#25422
LeilaWang wants to merge 7 commits into
spl/fi2-message-only-docsfrom
lw/fast-inbox-cleanup

Conversation

@LeilaWang

Copy link
Copy Markdown
Contributor

Some small cleanups I did while reading the codebase. Details are left in the comments.

self.bundle_applied = true;

// Real messages occupy the leading lanes; everything past `num_msgs` is zero padding.
assert_trailing_zeros(bundle.messages, bundle.num_msgs);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removing this as the same check is also done in append_only_tree::append_leaves_to_snapshot below.


// Load sync point for blocks defaulting to start block
const { blocksSynchedTo = this.l1Constants.l1StartBlock } = await getArchiverSynchPoint(this.stores);
const blocksSynchedTo = (await this.stores.blocks.getSynchedL1BlockNumber()) ?? this.l1Constants.l1StartBlock;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I find it easier to see that blocksSynchedTo is the synched l1 block number by calling the block store api directly, and it also avoids another unnecessary async call in getArchiverSynchPoint.


// Accumulate the streaming bundle now that the block is fully built, so a mid-build throw above leaves the
// checkpoint's message list (and thus its rolling hash) consistent with the blocks actually built.
this.l1ToL2Messages.push(...l1ToL2Messages);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I didn't feel comfortable that it was changing the array passed to the constructor directly. And while changing it, I found that it also made sense to replace the array with a rolling hash instead, since it's what's been built for each block added.

const l1ToL2LeafCount = (header: BlockHeader) => header.state.l1ToL2MessageTree.nextAvailableLeafIndex;
const checkpointStartCount = l1ToL2LeafCount(this.previousBlockHeader);
const checkpointEndCount = l1ToL2LeafCount(this.checkpoint.blocks.at(-1)!.header);
if (this.l1ToL2Messages.length !== checkpointEndCount - checkpointStartCount) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added this simple check to throw an error early if the number of messages doesn't match, instead of waiting until later to find out when the hash doesn't match with the value in the built block's header.

@LeilaWang
LeilaWang force-pushed the lw/fast-inbox-cleanup branch from b3f5d87 to 48043e7 Compare September 7, 2026 20:30
blocksInCheckpoint: L2Block[];
/** The last block's proposal, held back to travel with the checkpoint proposal instead of being gossiped. */
blockPendingBroadcast: BlockProposal | undefined;
streamingState: StreamingCheckpointState;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changes made in this file around streamingState is so that it doesn't get modified under the hood when being passed around.

@spalladino
spalladino force-pushed the spl/fi2-message-only-docs branch from 145907b to f0d1f1b Compare September 8, 2026 00:55
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