Skip to content

[feat] adds simulation to block loop #71

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

Merged
merged 53 commits into from
May 6, 2025
Merged

[feat] adds simulation to block loop #71

merged 53 commits into from
May 6, 2025

Conversation

dylanlott
Copy link
Contributor

@dylanlott dylanlott commented Apr 15, 2025

[feat] adds simulation to block loop

This PR adds simulation to the block builder loop.

  • Updates the builder to use a SlotCalculator for managing slot timings.
  • Removes the tx and bundle poller from the block builder and instead leans into the actor model and feeds them in via channels to the simulation process.
  • This PR relies on the signet-sdk Sim Crate PR

Configuration

Deploying this PR will require additional environment variables to be set

  • CONCURRENCY_LIMIT to limit how many concurrent simulations the block builder runs.
  • START_TIMESTAMP to set the starting timestamp of the chain for anchoring slot calculation.

Testing

This code is still being tested before final merge.

The current test plan is to

  • Build a Docker image of the builder with this branch
  • Update environment variables to include the above values
  • Deploy the test image to Pecorino
  • Add a bundle to the cache and see if it is picked up
  • See what, if any, errors spring up
  • Land blocks and see that the block building rate is not decreased with new timing updates

dylanlott and others added 15 commits April 3, 2025 09:45
- shifts the tx-poller to a more actor oriented approach by streaming transactions out of the cache.
- transaction deduplication and validation is intended to be carried out by the simulator.
- improves poll interval handling
- removes arcs
- updates comments
- adds file level comment
* fix: break loop on closure and improve tracing

* refactor: break out the task future
- improves poll interval handling
- cleans up and updates comments
- removes arc usage
- adds init4 metrics
- updates provider types to account for alloy changes
- align to alloy @ 0.12.6
- transfer off of zenith-rs and use signet-sdk instead
@dylanlott dylanlott self-assigned this Apr 15, 2025
Copy link
Contributor Author

dylanlott commented Apr 15, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

///
/// An `Instant` representing the deadline.
pub fn calculate_deadline(&self) -> Instant {
let now = SystemTime::now();
Copy link
Member

Choose a reason for hiding this comment

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

i don't like that we're constantly mixing timestamps and Duration/Instant. it makes it very hard to reason about the logic. cc @anna-carroll can we add more convenience functions to SlotCalculator to make these easier? what are the common actions we want to take using a calculator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created ENG-1019 to capture this.

BASEFEE_DEFAULT
}
};
tracing::debug!(basefee = basefee, "setting basefee");
Copy link
Member

Choose a reason for hiding this comment

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

nit don't need the = unless you're modifying something:
debug!(basefee, "setting basefee");

}
/// Different error types that the Simulator handles
#[derive(Debug, Error)]
pub enum SimulatorError {
Copy link
Member

Choose a reason for hiding this comment

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

type seems unnecessary for now?

Copy link
Member

@prestwich prestwich left a comment

Choose a reason for hiding this comment

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

i think we should merge this today and then iterate

@dylanlott dylanlott merged commit 177f538 into main May 6, 2025
5 checks passed
@dylanlott dylanlott deleted the dylan/sim-impl branch May 6, 2025 21:18
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.

4 participants