diff --git a/Cargo.lock b/Cargo.lock index 9dca73c9..1d995224 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1513,7 +1513,7 @@ dependencies = [ [[package]] name = "diorama-anvil" -version = "0.2.10" +version = "0.2.11" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -1533,7 +1533,7 @@ dependencies = [ [[package]] name = "diorama-ast-scope" -version = "0.2.10" +version = "0.2.11" dependencies = [ "proc-macro2", "quote", @@ -1542,7 +1542,7 @@ dependencies = [ [[package]] name = "diorama-cctp" -version = "0.2.10" +version = "0.2.11" dependencies = [ "alloy-chains", "alloy-consensus", @@ -1568,7 +1568,7 @@ dependencies = [ [[package]] name = "diorama-cctp-bridge" -version = "0.2.10" +version = "0.2.11" dependencies = [ "diorama-cctp", "diorama-config", @@ -1576,7 +1576,7 @@ dependencies = [ [[package]] name = "diorama-config" -version = "0.2.10" +version = "0.2.11" dependencies = [ "alloy-primitives", "clap", @@ -1591,7 +1591,7 @@ dependencies = [ [[package]] name = "diorama-devnet" -version = "0.2.10" +version = "0.2.11" dependencies = [ "alloy-consensus", "alloy-eips", @@ -1613,7 +1613,7 @@ dependencies = [ [[package]] name = "diorama-mainnet" -version = "0.2.10" +version = "0.2.11" dependencies = [ "alloy-eips", "alloy-json-rpc", @@ -1640,7 +1640,7 @@ dependencies = [ [[package]] name = "diorama-mainnet-engine" -version = "0.2.10" +version = "0.2.11" dependencies = [ "diorama-config", "diorama-mainnet", @@ -1648,7 +1648,7 @@ dependencies = [ [[package]] name = "diorama-venue" -version = "0.2.10" +version = "0.2.11" dependencies = [ "alloy-consensus", "alloy-primitives", @@ -1676,7 +1676,7 @@ dependencies = [ [[package]] name = "diorama-venue-engine" -version = "0.2.10" +version = "0.2.11" dependencies = [ "diorama-config", "diorama-venue", @@ -1684,7 +1684,7 @@ dependencies = [ [[package]] name = "diorama-venue-sim" -version = "0.2.10" +version = "0.2.11" dependencies = [ "diorama-config", "diorama-venue", diff --git a/Cargo.toml b/Cargo.toml index 37ab2c5e..86e80040 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ resolver = "2" # The image tag the staging pipeline derives: ghcr.io/herodotusdev/-stg:. # 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" diff --git a/crates/anvil/src/client.rs b/crates/anvil/src/client.rs index 6a77f1f3..7fdb45df 100644 --- a/crates/anvil/src/client.rs +++ b/crates/anvil/src/client.rs @@ -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<()> { diff --git a/crates/venue/src/follow/mod.rs b/crates/venue/src/follow/mod.rs index d958005b..97b6d2a0 100644 --- a/crates/venue/src/follow/mod.rs +++ b/crates/venue/src/follow/mod.rs @@ -183,8 +183,8 @@ pub(crate) async fn step(ctx: &Ctx) -> Result> { 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)) @@ -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 { +/// 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 { let head_block = ctx .source_rpc .block_by_number(source_head, diorama_anvil::Txs::Hashes) @@ -430,7 +431,17 @@ async fn advance_source_cursor(ctx: &Ctx, source_head: u64) -> Result { .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, } /// Mine one empty block stamped with the window's source-end timestamp: the @@ -445,8 +456,12 @@ async fn advance_source_cursor(ctx: &Ctx, source_head: u64) -> Result { /// 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(()); } @@ -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"); }