Skip to content

Commit e03d5e0

Browse files
dylanlottanna-carroll
authored andcommitted
refactor: DRY up the env construction function
1 parent 31db020 commit e03d5e0

File tree

1 file changed

+5
-26
lines changed

1 file changed

+5
-26
lines changed

src/tasks/env.rs

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ impl EnvTask {
206206
Self { config, host_provider, ru_provider }
207207
}
208208

209-
/// Construct a [`BlockEnv`] by the previous host header.
210-
fn construct_host_env(&self, previous: Header) -> Environment {
209+
/// Construct a [`BlockEnv`] for the _next_ block from the previous block's [`Header`].
210+
fn construct_env(&self, previous: Header) -> Environment {
211211
let env = BlockEnv {
212212
number: U256::from(previous.number + 1),
213213
beneficiary: self.config.builder_rewards_address,
@@ -227,27 +227,6 @@ impl EnvTask {
227227
Environment::new(env, previous)
228228
}
229229

230-
/// Construct a [`BlockEnv`] for the next rollup block from the previous block header.
231-
fn construct_rollup_env(&self, previous: Header) -> Environment {
232-
let env = BlockEnv {
233-
number: U256::from(previous.number + 1),
234-
beneficiary: self.config.builder_rewards_address,
235-
// NB: EXACTLY the same as the previous block
236-
timestamp: U256::from(previous.timestamp + self.config.slot_calculator.slot_duration()),
237-
gas_limit: self.config.rollup_block_gas_limit,
238-
basefee: previous
239-
.next_block_base_fee(BaseFeeParams::ethereum())
240-
.expect("signet has no non-1559 headers"),
241-
difficulty: U256::ZERO,
242-
prevrandao: Some(B256::random()),
243-
blob_excess_gas_and_price: Some(BlobExcessGasAndPrice {
244-
excess_blob_gas: 0,
245-
blob_gasprice: 0,
246-
}),
247-
};
248-
Environment::new(env, previous)
249-
}
250-
251230
/// Returns a sender that sends [`SimEnv`] for communicating the next block environment.
252231
async fn task_fut(self, sender: watch::Sender<Option<SimEnv>>) {
253232
let span = info_span!("EnvTask::task_fut::init");
@@ -284,9 +263,9 @@ impl EnvTask {
284263
.header
285264
.inner;
286265

287-
// Construct the block env using the previous block header
288-
let rollup_env = self.construct_rollup_env(rollup_header.into());
289-
let host_env = self.construct_host_env(host_header);
266+
// Construct the block envs using the previous block headers for each.
267+
let rollup_env = self.construct_env(rollup_header.into());
268+
let host_env = self.construct_env(host_header);
290269

291270
span_debug!(
292271
span,

0 commit comments

Comments
 (0)