MCPcopy Create free account
hub / github.com/base/base / open_window

Method open_window

acceptance/src/runner.rs:277–353  ·  view source on GitHub ↗

Waits until a check's fork window opens. Returns `None` when the check may run, otherwise the status and message to record. Builder RPC failures are retried at the poll interval until `deadline`. An unreached `after_fork` activation is `Failed` when the builder answered after its last failure and `Error` when it was unavailable; a missed `before_fork` window is `Error`.

(
        observer: &RpcObserver,
        config: &ScenarioConfig,
        endpoints: &EndpointMap,
        window: &CheckStart,
        result: &mut ScenarioResult,
        origin: Instant,
        d

Source from the content-addressed store, hash-verified

275 /// `after_fork` activation is `Failed` when the builder answered after its last failure
276 /// and `Error` when it was unavailable; a missed `before_fork` window is `Error`.
277 pub async fn open_window(
278 observer: &RpcObserver,
279 config: &ScenarioConfig,
280 endpoints: &EndpointMap,
281 window: &CheckStart,
282 result: &mut ScenarioResult,
283 origin: Instant,
284 deadline: Instant,
285 ) -> Result<Option<(Status, String)>> {
286 let name = window
287 .before_fork
288 .as_ref()
289 .or(window.after_fork.as_ref())
290 .ok_or_else(|| eyre::eyre!("missing fork window"))?;
291 let fork = result
292 .forks
293 .iter()
294 .position(|fork| &fork.name == name)
295 .ok_or_else(|| eyre::eyre!("fork {name} not present in verified schedule"))?;
296 let boundary = result.forks[fork].activation_timestamp;
297 let builder = RpcObserver::endpoint(endpoints, "builder")?;
298 let mut last_head = None;
299 let mut last_error = None;
300 loop {
301 match observer.block(builder, "latest", deadline).await {
302 Ok(block) => {
303 ObservationState::new(json!({}), &mut result.samples, origin)
304 .sample("builder", Some(&block));
305 let active = block.timestamp >= boundary;
306 if active && result.forks[fork].observed_block.is_none() {
307 result.forks[fork].observed_block = Some(block.number);
308 result.forks[fork].observed_elapsed_ms =
309 Some(origin.elapsed().as_millis() as u64);
310 }
311 if window.before_fork.is_some() {
312 return Ok(active.then(|| {
313 (Status::Error, format!("missed pre-activation window for {name}"))
314 }));
315 }
316 if active {
317 return Ok(None);
318 }
319 last_head = Some(block.number);
320 }
321 Err(error) => {
322 ObservationState::new(json!({}), &mut result.samples, origin)
323 .sample("builder", None);
324 // A request cut short by the deadline does not erase the last observed head.
325 if Instant::now() < deadline {
326 last_head = None;
327 }
328 last_error = Some(error);
329 }
330 }
331 if Instant::now() >= deadline {
332 return Ok(Some(match (last_head, last_error) {
333 (Some(head), _) => (
334 Status::Failed,

Callers

nothing calls this directly

Calls 8

positionMethod · 0.80
sampleMethod · 0.80
is_someMethod · 0.80
minMethod · 0.80
newFunction · 0.50
as_refMethod · 0.45
iterMethod · 0.45
blockMethod · 0.45

Tested by

no test coverage detected