From 0618e2f75bfc23256c29abe176ba946609c2f200 Mon Sep 17 00:00:00 2001 From: 0xfourzerofour Date: Thu, 23 May 2024 16:45:31 -0400 Subject: [PATCH] feat(simulation): add timestamps in response --- crates/pool/proto/op_pool/op_pool.proto | 7 +++++-- crates/pool/src/server/remote/error.rs | 24 ++++++++++++++++-------- crates/sim/src/simulation/simulator.rs | 5 ++++- crates/types/src/pool/error.rs | 9 ++++++--- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/crates/pool/proto/op_pool/op_pool.proto b/crates/pool/proto/op_pool/op_pool.proto index 3a5426004..d5cd68805 100644 --- a/crates/pool/proto/op_pool/op_pool.proto +++ b/crates/pool/proto/op_pool/op_pool.proto @@ -654,8 +654,6 @@ message SimulationViolationError { message InvalidSignature {} -message InvalidTimeRange {} - message InvalidAccountSignature {} message InvalidPaymasterSignature {} @@ -664,6 +662,11 @@ message UnstakedAggregator {} message UnstakedPaymasterContext {} +message InvalidTimeRange { + uint64 valid_until = 1; + uint64 valud_after = 2; +} + message UnintendedRevertWithMessage { Entity entity = 1; string reason = 2; diff --git a/crates/pool/src/server/remote/error.rs b/crates/pool/src/server/remote/error.rs index fc6e52d95..4d122cba2 100644 --- a/crates/pool/src/server/remote/error.rs +++ b/crates/pool/src/server/remote/error.rs @@ -18,7 +18,7 @@ use rundler_types::{ pool::{ MempoolError, NeedsStakeInformation, PoolError, PrecheckViolation, SimulationViolation, }, - StorageSlot, ValidationRevert, ViolationOpCode, + StorageSlot, Timestamp, ValidationRevert, ViolationOpCode, }; use super::protos::{ @@ -612,11 +612,16 @@ impl From for ProtoSimulationViolationError { CodeHashChanged {}, )), }, - SimulationViolation::InvalidTimeRange => ProtoSimulationViolationError { - violation: Some(simulation_violation_error::Violation::InvalidTimeRange( - InvalidTimeRange {}, - )), - }, + SimulationViolation::InvalidTimeRange(valid_until, valid_after) => { + ProtoSimulationViolationError { + violation: Some(simulation_violation_error::Violation::InvalidTimeRange( + InvalidTimeRange { + valid_until: valid_until.seconds_since_epoch(), + valud_after: valid_after.seconds_since_epoch(), + }, + )), + } + } SimulationViolation::AggregatorValidationFailed => ProtoSimulationViolationError { violation: Some( simulation_violation_error::Violation::AggregatorValidationFailed( @@ -648,8 +653,11 @@ impl TryFrom for SimulationViolation { Some(simulation_violation_error::Violation::InvalidSignature(_)) => { SimulationViolation::InvalidSignature } - Some(simulation_violation_error::Violation::InvalidTimeRange(_)) => { - SimulationViolation::InvalidTimeRange + Some(simulation_violation_error::Violation::InvalidTimeRange(e)) => { + SimulationViolation::InvalidTimeRange( + Timestamp::new(e.valid_until), + Timestamp::new(e.valud_after), + ) } Some(simulation_violation_error::Violation::InvalidAccountSignature(_)) => { SimulationViolation::InvalidAccountSignature diff --git a/crates/sim/src/simulation/simulator.rs b/crates/sim/src/simulation/simulator.rs index e43ed5a3a..36de3ce36 100644 --- a/crates/sim/src/simulation/simulator.rs +++ b/crates/sim/src/simulation/simulator.rs @@ -338,7 +338,10 @@ where } if !entry_point_out.return_info.is_valid_time_range() { - violations.push(SimulationViolation::InvalidTimeRange); + violations.push(SimulationViolation::InvalidTimeRange( + entry_point_out.return_info.valid_until, + entry_point_out.return_info.valid_after, + )); } if let Some(aggregator_info) = entry_point_out.aggregator_info { diff --git a/crates/types/src/pool/error.rs b/crates/types/src/pool/error.rs index b756018ff..752030d98 100644 --- a/crates/types/src/pool/error.rs +++ b/crates/types/src/pool/error.rs @@ -14,7 +14,8 @@ use ethers::types::{Address, U256}; use crate::{ - validation_results::ValidationRevert, Entity, EntityType, StorageSlot, ViolationOpCode, + validation_results::ValidationRevert, Entity, EntityType, StorageSlot, Timestamp, + ViolationOpCode, }; /// Pool server error type @@ -153,8 +154,10 @@ pub enum SimulationViolation { #[display("invalid account signature")] InvalidAccountSignature, /// The user operation has an invalid time range based on the `valid_until` and `valid_after` fields - #[display("User Operation expired or has an invalid time range")] - InvalidTimeRange, + #[display( + "User Operation expired or has an invalid time range. validUntil: {0}, validAfter: {1}" + )] + InvalidTimeRange(Timestamp, Timestamp), /// The signature is invalid for the paymaster #[display("invalid paymaster signature")] InvalidPaymasterSignature,