Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ resolver = "2"
# The image tag the staging pipeline derives: ghcr.io/herodotusdev/<app>-stg:<version>.
# Bump per deploy-worthy change set; the pipeline also creates the matching
# git tag (plain `0.2.0`, distinct from the legacy `v0.1.0`).
version = "0.2.10"
version = "0.2.11"
edition = "2021"
rust-version = "1.99"
license = "MIT OR Apache-2.0"
Expand Down
9 changes: 9 additions & 0 deletions crates/anvil/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1649,6 +1649,15 @@ impl Rpc {
Ok(())
}

/// Set the next block's base fee (`anvil_setNextBlockBaseFeePerGas`).
pub async fn anvil_set_next_block_base_fee(&self, base_fee: u64) -> Result<()> {
self.ensure_write()?;

self.call_raw("anvil_setNextBlockBaseFeePerGas", (U256::from(base_fee),))
.await?;
Ok(())
}

/// Align the next block's context fields T owns (timestamp/coinbase/
/// prevRandao/baseFee); the gas limit stays the devnet's own.
pub async fn set_next_block_context(&self, timestamp: u64, header: &Header) -> Result<()> {
Expand Down
38 changes: 29 additions & 9 deletions crates/venue/src/follow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ pub(crate) async fn step(ctx: &Ctx) -> Result<Option<FollowOutcome>> {
pre_land_scan(ctx).await?;
let applied = apply_window(ctx, &plan).await?;
let (sampled, sampled_ok) = parity::parity_step(ctx, &plan.bal).await?;
let end_ts = advance_source_cursor(ctx, to).await?;
mine_window_block(ctx, end_ts).await?;
let end = advance_source_cursor(ctx, to).await?;
mine_window_block(ctx, end).await?;
let stats = outcome(&plan, applied, (sampled, sampled_ok), started);
report_applied(ctx, followed, to, source_head, &stats);
Ok(Some(stats))
Expand Down Expand Up @@ -419,9 +419,10 @@ fn record_window_metrics(
/// Advance the source cursor to `source_head` (recording the source's own
/// block hash — the continuity check's anchor) and persist the state. The
/// name says which cursor: the devnet cursor is the spine's `advance_cursor`.
/// Returns the fetched block's timestamp — the window end's source clock,
/// which the block-production rule stamps onto V's next block.
async fn advance_source_cursor(ctx: &Ctx, source_head: u64) -> Result<u64> {
/// Returns the fetched block's timestamp and base fee — the window end's
/// source clock and gas price, which the block-production rule stamps onto
/// V's next block.
async fn advance_source_cursor(ctx: &Ctx, source_head: u64) -> Result<WindowEnd> {
let head_block = ctx
.source_rpc
.block_by_number(source_head, diorama_anvil::Txs::Hashes)
Expand All @@ -430,7 +431,17 @@ async fn advance_source_cursor(ctx: &Ctx, source_head: u64) -> Result<u64> {
.state
.set_source_last(source_head, head_block.header.hash)?;
ctx.plane.save_state()?;
Ok(head_block.header.timestamp)
Ok(WindowEnd {
timestamp: head_block.header.timestamp,
base_fee: head_block.header.base_fee_per_gas,
})
}

/// The source block a window ends at: what V's next block takes from it.
#[derive(Clone, Copy)]
struct WindowEnd {
timestamp: u64,
base_fee: Option<u64>,
}

/// Mine one empty block stamped with the window's source-end timestamp: the
Expand All @@ -445,8 +456,12 @@ async fn advance_source_cursor(ctx: &Ctx, source_head: u64) -> Result<u64> {
/// non-monotonic block — anvil would refuse the set and mine with its own
/// default instead (the alignment rule, `align_context`'s clamp). Best
/// effort: a failed mine is a warn, never a window failure — the compose
/// already landed, and the next window mines the next block.
async fn mine_window_block(ctx: &Ctx, source_ts: u64) -> Result<()> {
/// already landed, and the next window mines the next block. The block also
/// carries the source's base fee: an idle fork's own fee decays to a few wei
/// (measured 7 wei on staging while HyperEVM's is ~0.1 gwei), and every gas
/// estimate a client makes from V's head (the frontend's Core to EVM bridge
/// reserve) would then undershoot what HyperCore charges.
async fn mine_window_block(ctx: &Ctx, end: WindowEnd) -> Result<()> {
if !ctx.engine.loops.mine_empty_blocks {
return Ok(());
}
Expand All @@ -457,10 +472,15 @@ async fn mine_window_block(ctx: &Ctx, source_ts: u64) -> Result<()> {
.await?
.header
.timestamp;
let ts = next_block_timestamp(source_ts, last_ts);
let ts = next_block_timestamp(end.timestamp, last_ts);
if let Err(e) = ctx.anvil_v.anvil_set_next_block_timestamp(ts).await {
tracing::warn!(error = %e, ts, "window block timestamp set failed; mining with anvil's own clock");
}
if let Some(base_fee) = end.base_fee {
if let Err(e) = ctx.anvil_v.anvil_set_next_block_base_fee(base_fee).await {
tracing::warn!(error = %e, base_fee, "window block base fee set failed; mining with anvil's own fee");
}
}
if let Err(e) = ctx.anvil_v.anvil_mine(1).await {
tracing::warn!(error = %e, "window block mine failed; the next window retries");
}
Expand Down
Loading