Skip to content

Commit

Permalink
feat(simulation): add timestamps in response
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfourzerofour committed May 23, 2024
1 parent ff91439 commit 0618e2f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
7 changes: 5 additions & 2 deletions crates/pool/proto/op_pool/op_pool.proto
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,6 @@ message SimulationViolationError {

message InvalidSignature {}

message InvalidTimeRange {}

message InvalidAccountSignature {}

message InvalidPaymasterSignature {}
Expand All @@ -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;
Expand Down
24 changes: 16 additions & 8 deletions crates/pool/src/server/remote/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use rundler_types::{
pool::{
MempoolError, NeedsStakeInformation, PoolError, PrecheckViolation, SimulationViolation,
},
StorageSlot, ValidationRevert, ViolationOpCode,
StorageSlot, Timestamp, ValidationRevert, ViolationOpCode,
};

use super::protos::{
Expand Down Expand Up @@ -612,11 +612,16 @@ impl From<SimulationViolation> 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(
Expand Down Expand Up @@ -648,8 +653,11 @@ impl TryFrom<ProtoSimulationViolationError> 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
Expand Down
5 changes: 4 additions & 1 deletion crates/sim/src/simulation/simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 6 additions & 3 deletions crates/types/src/pool/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 0618e2f

Please sign in to comment.