MCPcopy Create free account
hub / github.com/cowprotocol/services / simulate_with_timeout

Method simulate_with_timeout

crates/shared/src/order_validation.rs:78–109  ·  view source on GitHub ↗
(
        &self,
        order: &Order,
        full_app_data: &str,
        full_balance_check: bool,
    )

Source from the content-addressed store, hash-verified

76
77impl OrderSimulator {
78 pub async fn simulate_with_timeout(
79 &self,
80 order: &Order,
81 full_app_data: &str,
82 full_balance_check: bool,
83 ) -> Result<SimulationSuccess, OrderSimulationError> {
84 let start = Instant::now();
85 let (outcome, result) = match tokio::time::timeout(
86 self.timeout,
87 self.simulator
88 .simulate(order, full_app_data, full_balance_check),
89 )
90 .await
91 {
92 Ok(Ok(r)) => ("ok", Ok(r)),
93 Ok(r @ Err(OrderSimulationError::Reverted { .. })) => ("reverted", r),
94 Ok(r @ Err(OrderSimulationError::Infra(_))) => ("infra", r),
95 Err(_) => (
96 "timeout",
97 Err(OrderSimulationError::Infra(anyhow!(
98 "order simulation timeout"
99 ))),
100 ),
101 };
102
103 Metrics::get()
104 .duration_seconds
105 .with_label_values(&[outcome])
106 .observe(start.elapsed().as_secs_f64());
107
108 result
109 }
110}
111
112/// Logs disagreements (signature pass + simulation revert, or vice versa)

Callers 1

Calls 5

nowFunction · 0.85
observeMethod · 0.80
elapsedMethod · 0.80
getFunction · 0.50
simulateMethod · 0.45

Tested by

no test coverage detected