Skip to content

Conversation

@akundaz
Copy link
Collaborator

@akundaz akundaz commented Nov 24, 2025

Add an associated type to Platform to hold state that is passed around with checkpoints. This makes it easier to write features like flashblocks, since multiple steps need to access the flashblock number and so we currently define state outside the pipeline and share it with those steps. This PR also makes it possible to access this state during bundle filtering, so we will can filter on flashblock numbers.

Checkpoint metadata can be accessed via checkpoint.metadata() and can be updated like checkpoint.execute(tx).metadata(new_metadata).apply(). If metadata isn't set for the next checkpoint then the current checkpoint's metadata is cloned to the next checkpoint.

I refactored the checkpoint construction api because we want to be able to optionally set tags and/or metadata. Instead of apply(tx) or barrier() returning the next checkpoint, the execute(tx) and barrier() methods now return CheckpointBuilder instances which has an apply() method to create the next checkpoint, along with tag and metadata setter functions. This results in more verbose code but it seems like the clearest way to enable metadata and tags.

@akundaz akundaz self-assigned this Nov 24, 2025
@akundaz akundaz force-pushed the ak-checkpoint-state branch from bf0e1ed to de7f40f Compare November 24, 2025 14:58
@karim-agha
Copy link
Collaborator

Looks great! Let's just tweak the public API a little bit.

Copy link
Collaborator

@julio4 julio4 left a comment

Choose a reason for hiding this comment

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

This is good!
I generally think that we should be careful about changing API and that moving to a builder pattern should be discussed separately.

Also, we should try to not overload too much method and try to extract metadata from within checkpoint when possible.

And lastly, we attach metadata to checkpoint but this is basically a state that is passed across checkpoint to give more context required by some platform. I think maybe metadata is not exactly the correct name, maybe something like BuildingContext could be more relevant if I understood this correctly.

What do you think?

@karim-agha
Copy link
Collaborator

Now that we will have Checkpoint::apply(tx) and Checkpoint::apply_with(tx, metadata) I think it make sense to have BlockContext::start() and BlockContext::start_with(metadata).

@akundaz akundaz force-pushed the ak-checkpoint-state branch from de7f40f to 67f3802 Compare November 26, 2025 16:08
Copy link
Collaborator

@julio4 julio4 left a comment

Choose a reason for hiding this comment

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

lgtm, be sure to rename all metadata to context

Self::Bundle(bundle) => {
Self::execute_bundle(bundle, block, db, checkpoint_context)
}
Self::Transaction(tx) => Self::execute_transaction(tx, block, db)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can also add context to execute_transaction even if it's not used yet

@julio4 julio4 merged commit 793d413 into main Dec 1, 2025
4 checks passed
@julio4 julio4 deleted the ak-checkpoint-state branch December 1, 2025 19:07
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.

3 participants