Skip to content

Comments

feat: introduce op-angstrom, genericize repo for OP#569

Open
mempirate wants to merge 142 commits intomainfrom
feat/rollup-compat
Open

feat: introduce op-angstrom, genericize repo for OP#569
mempirate wants to merge 142 commits intomainfrom
feat/rollup-compat

Conversation

@mempirate
Copy link
Collaborator

@mempirate mempirate commented Jul 25, 2025

Reasoning is documented in an ADR here: https://github.com/SorellaLabs/angstrom/blob/feat/rollup-compat/docs/adr/rollup.md

This will be a temporary feature branch until we get it all to compile. Related PRs will be based off of this branch.

@Will-Smith11 let me know if this looks good, otherwise we can brainstorm a different approach

@mempirate mempirate force-pushed the feat/rollup-compat branch from 32fc110 to 1d644e0 Compare July 28, 2025 08:00
mempirate and others added 12 commits July 28, 2025 10:33
- Remove default StromNetworkHandle parameter and angstrom-network dependency
- Fix unused mode field by using PhantomData<M> pattern
- Update call sites to use mode-specific constructors (new_consensus/new_rollup)
- Rename PoolStromMessage to PoolNetworkMessage for generic naming
- Simplify NetworkHandle trait to reduce tokio-stream dependency
- Reorder generic parameters (NH before M) to support defaults properly

This achieves clean extraction with proper decoupling while maintaining
the benefits of the type-state pattern and static dispatch.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit addresses all the key points from the PR review to improve
the pool-manager crate extraction and type-state pattern implementation:

## API Simplification
- Remove public `PoolManagerBuilder::new()` method that took unused `_mode` parameter
- Keep only mode-specific constructors (`new_consensus` and `new_rollup`)
- This enforces static dispatch by construction and prevents accidental usage

## Ergonomic Improvements
- Add convenient type aliases in `pool-manager/src/lib.rs`:
  - `ConsensusPoolManager<V, GS, NH>`
  - `RollupPoolManager<V, GS, NH>`
  - `ConsensusPoolManagerBuilder<V, GS, NH>`
  - `RollupPoolManagerBuilder<V, GS, NH>`
- Reduces verbosity at call sites and improves developer experience

## Type System Improvements
- Add `M: PoolManagerMode` bound directly on struct declarations
- Remove unnecessary `+ Unpin` bounds on `NH: NetworkHandle` where not needed
- Use `PhantomData<fn() -> M>` instead of `PhantomData<M>` for better dropck behavior
- Makes intent clearer and widens compatibility

## Dependency Cleanup
- Remove unused `tokio-stream` dependency from `crates/types/Cargo.toml`
- Reduces the dependency footprint of the types crate

## Documentation
- Update stale comments about type alias locations
- Improve inline documentation for clarity

All changes maintain backward compatibility while significantly improving
the API design and developer experience. The type-state pattern now
enforces correct usage through the type system more effectively.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@mempirate mempirate marked this pull request as ready for review September 15, 2025 12:51
Comment on lines +26 to +27
#[clap(short, long, num_args(1..=5), require_equals = true)]
pub normal_nodes: Option<Vec<String>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

why have we changed the type here from

#[clap(short, long, num_args(0..=5), require_equals = true, default_values = ETH_DEFAULT_RPC)]
    pub normal_nodes:              Vec<String>,

this was setup as it allows us to enable and disable sending from the mempool aswell have having overrides.

Comment on lines +29 to +35
// TODO(mempirate): Is this a good value?
/// The factor by which the block time is multiplied to get the bid aggregation
/// deadline. = 80% of the block time.
///
/// NOTE: On lower block times (like Flashblocks, we might have to decrease this
/// to account for transaction inclusion latency (network + processing)).
const BID_AGGREGATION_DEADLINE_FACTOR: f64 = 0.8;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you look on the main branch, we have a slot clock impl that we use to offset message time with slot clock. Ideally this is used instead of a constant mutliple because it doesn't account for sequencer lag

Comment on lines +159 to +172
fn on_blockchain_state(
&mut self,
notification: CanonStateNotification<OpPrimitives>,
waker: Waker
) {
let new_block = notification.tip();
let number = new_block.number();

tracing::info!(?number, "New blockchain state");
self.current_height = number;

// Reset the timeout.
self.state
.reset(self.block_time.mul_f64(BID_AGGREGATION_DEADLINE_FACTOR));
Copy link
Collaborator

Choose a reason for hiding this comment

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

needs to be updated to slot clock implimentation

Comment on lines +230 to +259
tracing::trace!(height = self.current_height, "Building bundle");
let bundle = match AngstromBundle::from_pool_solutions(
pool_solutions,
all_orders,
&pool_snapshots,
details
) {
Ok(bundle) => bundle,
Err(e) => {
tracing::error!(
?e,
height = self.current_height,
"Error building bundle! No bundle will be submitted"
);
return;
}
};

// Reset the state to waiting. State transition cycle is now complete, ready for
// the next block to start the next cycle.
self.state = DriverState::Waiting;

let target_block = self.current_height + 1;
let provider = self.provider.clone();
let signer = self.signer.clone();
let height = self.current_height;

// NOTE: We can just spawn the submission here. We don't need to store the
// result, since in rollup mode we don't do anything with it.
tokio::spawn(async move {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see anything here for unlock attestations

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let this = self.get_mut();

use crate::common::PoolManagerCommon;
Copy link
Collaborator

Choose a reason for hiding this comment

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

imports at top

let this = self.get_mut();

use crate::common::PoolManagerCommon;
PoolManagerCommon::poll_eth_and_pool(this, cx);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is it being invoked this way instead of just calling on this

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