From ee12a28c0e3d0610c826c72b0e99ca213aa43e58 Mon Sep 17 00:00:00 2001 From: Martin Beckmann Date: Wed, 20 Dec 2023 22:55:50 +0100 Subject: [PATCH] Simulate on user provided timestamp (#27) * Simulate on user provided timestamp * Allow tests to set the required config --- README.md | 1 + src/simulation.rs | 22 ++++++++++- tests/api.rs | 98 ++++++++++++++++++++++++++++++++++++----------- 3 files changed, 98 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 60fc87c..d5b8a31 100644 --- a/README.md +++ b/README.md @@ -234,6 +234,7 @@ export type SimulationRequest = { value: string; accessList?: AccessListItem[]; blockNumber?: number; // if not specified, latest used, + blockTimestamp?: number; // if not specified, timestamp of latest block is used, stateOverrides?: Record; formatTrace?: boolean; }; diff --git a/src/simulation.rs b/src/simulation.rs index 812d2ed..1595d5c 100644 --- a/src/simulation.rs +++ b/src/simulation.rs @@ -36,6 +36,7 @@ pub struct SimulationRequest { pub value: Option, pub access_list: Option, pub block_number: Option, + pub block_timestamp: Option, pub state_overrides: Option>, pub format_trace: Option, } @@ -60,6 +61,7 @@ pub struct StatefulSimulationRequest { pub chain_id: u64, pub gas_limit: u64, pub block_number: Option, + pub block_timestamp: Option, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] @@ -241,6 +243,12 @@ pub async fn simulate(transaction: SimulationRequest, config: Config) -> Result< return Err(warp::reject::custom(IncorrectChainIdError())); } + if let Some(timestamp) = transaction.block_timestamp { + evm.set_block_timestamp(timestamp) + .await + .expect("failed to set block timestamp"); + } + let response = run(&mut evm, transaction, false).await?; Ok(warp::reply::json(&response)) @@ -252,6 +260,7 @@ pub async fn simulate_bundle( ) -> Result { let first_chain_id = transactions[0].chain_id; let first_block_number = transactions[0].block_number; + let first_block_timestamp = transactions[0].block_timestamp; let fork_url = config .fork_url @@ -269,6 +278,12 @@ pub async fn simulate_bundle( return Err(warp::reject::custom(IncorrectChainIdError())); } + if let Some(timestamp) = first_block_timestamp { + evm.set_block_timestamp(timestamp) + .await + .expect("failed to set block timestamp"); + } + let mut response = Vec::with_capacity(transactions.len()); for transaction in transactions { if transaction.chain_id != first_chain_id { @@ -303,7 +318,7 @@ pub async fn simulate_stateful_new( let fork_url = config .fork_url .unwrap_or(chain_id_to_fork_url(stateful_simulation_request.chain_id)?); - let evm = Evm::new( + let mut evm = Evm::new( None, fork_url, stateful_simulation_request.block_number, @@ -311,6 +326,11 @@ pub async fn simulate_stateful_new( true, config.etherscan_key, ); + + if let Some(timestamp) = stateful_simulation_request.block_timestamp { + evm.set_block_timestamp(timestamp).await?; + } + let new_id = Uuid::new_v4(); state.evms.insert(new_id, Arc::new(Mutex::new(evm))); diff --git a/tests/api.rs b/tests/api.rs index ac94353..35796c8 100644 --- a/tests/api.rs +++ b/tests/api.rs @@ -2,7 +2,7 @@ use std::{fs::File, sync::Arc}; use dashmap::DashMap; use enso_temper::{ - config::config, + config::{config, Config}, errors::{handle_rejection, ErrorMessage}, simulate_routes, simulation::{ @@ -14,14 +14,15 @@ use enso_temper::{ use ethers::types::U256; use warp::Filter; -fn filter() -> impl Filter + Clone -{ +fn filter( + config: Config, +) -> impl Filter + Clone { let shared_state: Arc = Arc::new(SharedSimulationState { evms: Arc::new(DashMap::new()), }); warp::any() - .and(simulate_routes(config(), shared_state)) + .and(simulate_routes(config, shared_state)) .recover(handle_rejection) } @@ -32,7 +33,7 @@ async fn post_simulate_file() { return; } - let filter = filter(); + let filter = filter(config()); let file = File::open("tests/body.json").expect("file should open read only"); let json: SimulationRequest = @@ -70,7 +71,7 @@ async fn post_simulate_file_etherscan() { return; } - let filter = filter(); + let filter = filter(config()); let file = File::open("tests/body.json").expect("file should open read only"); let json: SimulationRequest = @@ -100,7 +101,7 @@ async fn post_simulate_file_etherscan() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_frax_tx() { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!({ "chainId": 1, @@ -128,7 +129,7 @@ async fn post_simulate_frax_tx() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_zerox_swap() { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!({ "chainId": 1, @@ -157,7 +158,7 @@ async fn post_simulate_zerox_swap() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_access_lists() { let simulate_gas_used = |access_list: serde_json::Value| async move { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!({ "chainId": 1, @@ -208,7 +209,7 @@ async fn post_simulate_access_lists() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_state_overrides() { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!({ "chainId": 1, @@ -243,7 +244,7 @@ async fn post_simulate_state_overrides() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_bundle_single_zerox_swap() { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!([{ "chainId": 1, @@ -272,7 +273,7 @@ async fn post_simulate_bundle_single_zerox_swap() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_bundle() { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!([{ "chainId": 1, @@ -308,7 +309,7 @@ async fn post_simulate_bundle() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_bundle_second_reverts() { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!([{ "chainId": 1, @@ -344,7 +345,7 @@ async fn post_simulate_bundle_second_reverts() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_no_data() { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!({ "chainId": 1, @@ -372,7 +373,7 @@ async fn post_simulate_no_data() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_incorrect_chain_id() { temp_env::async_with_vars([("FORK_URL", Some("https://eth.llamarpc.com"))], async { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!({ "chainId": 137, @@ -401,7 +402,7 @@ async fn post_simulate_incorrect_chain_id() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_not_enough_gas() { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!({ "chainId": 1, @@ -428,7 +429,7 @@ async fn post_simulate_not_enough_gas() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_invalid_from() { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!({ "chainId": 1, @@ -456,7 +457,7 @@ async fn post_simulate_invalid_from() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_invalid_to() { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!({ "chainId": 1, @@ -484,7 +485,7 @@ async fn post_simulate_invalid_to() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_invalid_data() { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!({ "chainId": 1, @@ -515,7 +516,7 @@ async fn post_simulate_invalid_data() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_bundle_multiple_block_numbers() { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!([{ "chainId": 1, @@ -583,7 +584,7 @@ async fn post_simulate_bundle_multiple_block_numbers() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_bundle_multiple_block_numbers_invalid_order() { - let filter = filter(); + let filter = filter(config()); let json = serde_json::json!([{ "chainId": 1, @@ -617,7 +618,7 @@ async fn post_simulate_bundle_multiple_block_numbers_invalid_order() { #[tokio::test(flavor = "multi_thread")] async fn post_simulate_stateful() { - let filter = filter(); + let filter = filter(config()); let new_simulation_req = serde_json::json!({ "chainId": 1, @@ -755,3 +756,56 @@ async fn post_simulate_stateful() { .await; assert_eq!(res.status(), 404); } + +#[tokio::test(flavor = "multi_thread")] +async fn post_simulate_time_sensitive_tx() { + let config = Config { + max_request_size: 64 * 1024, + ..config() + }; + let filter = filter(config); + + let mut json = serde_json::json!({ + "chainId": 1, + "from": "0x16c473448e770ff647c69cbe19e28528877fba1b", + "to": "0x9008d19f58aabd9ed0d60971565aa8510560ab41", + "data": "0x13d79a0b000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000f80000000000000000000000000000000000000000000000000000000000000000900000000000000000000000063b420fb3294ba1d300ce5d3ba4bbca0f4fe5e3b0000000000000000000000006602e9319f2c5ec0ba31ffcdc4301d7ef03b709e000000000000000000000000826180541412d574cf1336d22c0c0a287822678a000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000d7c1eb0fe4a30d3b2a846c04aa6300888f087a5f000000000000000000000000eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee000000000000000000000000826180541412d574cf1336d22c0c0a287822678a000000000000000000000000d7c1eb0fe4a30d3b2a846c04aa6300888f087a5f0000000000000000000000000000000000000000000000000000000000000009000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000b03be4f33de3117a20000000000000000000000000000000000000000000001dbdaf552b2e610f9620000000000000000000000000000000000004aaa0d413df15c88a41958d3500500000000000000000000000000000000000000000002d6d05933e23134fa4940000000000000000000000000000000000000000000000001a70d5fdd2071474f00000000000000000000000000000000000000000002d6d05933e23134fa4940000000000000000000000000000000000000000000003c97e632500fe652a7f400000000000000000000000000000000000000000000003635c9adc5dea0000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000008c00000000000000000000000000000000000000000000000000000000000000a8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000d0dfd95ccd6e070eda7e153a54fb67f0628ba26c00000000000000000000000000000000000000000000281af54148361a9400000000000000000000000000000000000000000000000000000c20964c235c076b00000000000000000000000000000000000000000000000000000000657c0368e9f29ae547955463ed535162aefee525d8d309571a2b18bc26086c8c35d781eb000000000000000000000000000000000000000000000020f66db0a5202c0000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000281af54148361a9400000000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000004176b5974825abcbf26f0e2312e950444ca46758a8e41df942369d5b1395c630b40e1b1e728d4589f16fff33287cfae3922c81e004bef6207d1a733f51a8da45741c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000000000000000000000000000000000000000000000000000000000000080000000000000000000000006aeef86bb8742c6739639634f64ec8d98d6b835800000000000000000000000000000000000000000000003635c9adc5dea00000000000000000000000000000000000000000000000003af311dd167044bb7b3800000000000000000000000000000000000000000000000000000000657bf182351173d8df3ae67ecd9202256c01a4ccbaf71234af377033ba8e9c53af6835460000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000003635c9adc5dea00000000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000004d86aeef86bb8742c6739639634f64ec8d98d6b83585fd7e97dc078f884a2676e1345748b1feace7b0abee5d00ecadb6e574dcdd109a63e8943d5a25ba2e97094ad7d83dc28a6572da797d6b3e7fc6663bd93efb789fc17e489000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000002200000000000000000000000000000000000000000000000000000000000000180000000000000000000000000826180541412d574cf1336d22c0c0a287822678a000000000000000000000000d7c1eb0fe4a30d3b2a846c04aa6300888f087a5f0000000000000000000000006aeef86bb8742c6739639634f64ec8d98d6b835800000000000000000000000000000000000000000000003635c9adc5dea00000000000000000000000000000000000000000000000003af311dd167044bb7b3800000000000000000000000000000000000000000000000000000000657bf182351173d8df3ae67ecd9202256c01a4ccbaf71234af377033ba8e9c53af6835460000000000000000000000000000000000000000000000000000000000000000f3b277728b3fee749481eb3e0b3b48980dbbab78658fc419025cb16eee34677500000000000000000000000000000000000000000000000000000000000000005a28e9363bb942b639270062aa6bb295f434bcdfc42c97267bf003f272060dc95a28e9363bb942b639270062aa6bb295f434bcdfc42c97267bf003f272060dc90000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006cf1e9ca41f7611def408122793c358a3d11e5a500000000000000000000000000000000000000000000000000000018c6c0264000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000140000000000000000000000000826180541412d574cf1336d22c0c0a287822678a000000000000000000000000d7c1eb0fe4a30d3b2a846c04aa6300888f087a5f0000000000000000000000006aeef86bb8742c6739639634f64ec8d98d6b835800000000000000000000000000000000000000000000003635c9adc5dea00000000000000000000000000000000000000000000000003af311dd167044bb7b380000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000004b00000000000000000000000000000000000000000000000000000000000000000351173d8df3ae67ecd9202256c01a4ccbaf71234af377033ba8e9c53af68354600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000030000000000000000000000002f45724d7e384b38d5c97206e78470544304887f000000000000000000000000000000000000000000000000989cd478134caef300000000000000000000000000000000000000000000000000000005b06a600d00000000000000000000000000000000000000000000000000000000ffffffff15f7794a143d0e5d3217190e3baeac63e6f76c816b10b9a6b89fcb915164d281000000000000000000000000000000000000000000000000000b05401dff510d0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000989cd478134caef30000000000000000000000000000000000000000000000000000000000000160000000000000000000000000000000000000000000000000000000000000002840a50cf069e992aa4536211b23f286ef8875218740a50cf069e992aa4536211b23f286ef88752187000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000030000000000000000000000009afd9f0c276b40411a4ca6a53dfa7e3d832cd66f0000000000000000000000000000000000000000000008f63ce03c890736f2a0000000000000000000000000000000000000000000000000000000013e4ab2da00000000000000000000000000000000000000000000000000000000657bf3f8db47033948acea8674bb2501bc6d2908d3cdf86eb9262a8585466e877e4ecd89000000000000000000000000000000000000000000000002ca36c150997d600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008f63ce03c890736f2a000000000000000000000000000000000000000000000000000000000000001600000000000000000000000000000000000000000000000000000000000000041da7fefd12133c5dd85ac4ca604a517de4dcf526d7fb9e363ad8eb4c9b4f2e57d0e5b72ca03e2e2ec68d7486060c42802e01d42b7366fc64c6bdbd751cae6624e1b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000022e00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000040a50cf069e992aa4536211b23f286ef887521870000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000044c84c1c8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000008a00000000000000000000000000000000000000000000000000000000000000a400000000000000000000000000000000000000000000000000000000000000ca00000000000000000000000000000000000000000000000000000000000000e400000000000000000000000000000000000000000000000000000000000000f60000000000000000000000000000000000000000000000000000000000000102000000000000000000000000000000000000000000000000000000000000014c00000000000000000000000000000000000000000000000000000000000001580000000000000000000000000000000000000000000000000000000000000164000000000000000000000000000000000000000000000000000000000000018a000000000000000000000000000000000000000000000000000000000000019600000000000000000000000000000000000000000000000000000000000001b200000000000000000000000000000000000000000000000000000000000001c800000000000000000000000000000000000000000000000000000000000001ee000000000000000000000000000000000000000000000000000000000000020c0000000000000000000000000beb09000fa59627dc02bb55448ac1893eaa501a500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000060424a305f20000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000046000000000000000000000000000000000000000000000000000000000000004c000000000000000000000000000000000000000000000000000000000657beebe0000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab410000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000018000000000000000000000000000000000000000000000000000000000000001c0000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000003400000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab4100000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000051c72848c68a965f66fa7a88855f9f7784502a7f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000003187e072c1b000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000989cd478134caef300000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000005cd98afdf0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000418fba48f1c1f9d272578cfc682e24d59bbbf341683dced64b5088822638e46a344dd1c2aa35d76c624fcd6720eeb1bb79bfe1a2b8e9838f31de532c438ed7d6461b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000104414bf3890000000000000000000000006602e9319f2c5ec0ba31ffcdc4301d7ef03b709e000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000000000000000000027100000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab4100000000000000000000000000000000000000000000000000000f00000000000000000000000000000000000000000000000000000008f63ce03c890736f27a00000000000000000000000000000000000000000000000022b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c452bbbe2900000000000000000000000000000000000000000000000000000000000000e00000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab4100000000000000000000000000000000000000000000000000000000000000000000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab4100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006e0000000000000000000000000000000000000000000000000000000000f0000000000af15e6cbe19e30be827f27069cf010b57ce9f3ae0002000000000000000004d30000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000b3cea2601d204400000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001b81d678ffb9c0263b24a97847620c99d213eb14000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000104414bf389000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000001f40000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab4100000000000000000000000000000000000000000000000000000f00000000000000000000000000000000000000000000000000000000000c65e538006d384d0000000000000000000000000000000000000000000000000000000078b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005426178799ee0a0181a89b4f57efddfab49941ec0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000845b41b90800000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000042daef9a502b9790000000000000000000000000000000000000000000000000000000028b000000000000000000000000000000000000000000000000000000000000000000000000000000000000008775ccb6674d6bdceb0797c364c2653ed84f38400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002438e9922e000000000000000000000000000000000000000000000000000221b262dd800000000000000000000000000000000000000000000000000000000000000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000404945bcec90000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000003000000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab4100000000000000000000000000000000000000000000000000000000000000000000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010008775ccb6674d6bdceb0797c364c2653ed84f3840002000000000000000004f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000bdf1d19bac30b5800000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000079c58f70905f734641735bc61e45c19dd9ad60bc0000000000000000000004e700000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000079c58f70905f734641735bc61e45c19dd9ad60bc000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000bdf1d19bac30b580000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff8bf000000000000000000000000000000000000000000000000000000000000000000000000000000000000008775ccb6674d6bdceb0797c364c2653ed84f38400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002438e9922e000000000000000000000000000000000000000000000000000aa87bee5380000000000000000000000000000000000000000000000000000000000000000000000000000000000096646936b91d6b9d7d0c47c496afbf3d6ec7b6f800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002438e9922e000000000000000000000000000000000000000000000000000221b262dd800000000000000000000000000000000000000000000000000000000000000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c452bbbe2900000000000000000000000000000000000000000000000000000000000000e00000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab4100000000000000000000000000000000000000000000000000000000000000000000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab410000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d70000000000000000000000000000000000000000000000000000000000f000000000096646936b91d6b9d7d0c47c496afbf3d6ec7b6f80002000000000000000000190000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000000000000000000000000000001618e2c8343630c00000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096646936b91d6b9d7d0c47c496afbf3d6ec7b6f800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000002438e9922e000000000000000000000000000000000000000000000000000aa87bee53800000000000000000000000000000000000000000000000000000000000000000000000000000000000bbf1ee38152e9d8e3470dc47947eaa65dca94913000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000124c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab4100000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000b14d25fe99ce1e0000000000000000000000000000000000000000000000000000000006b00000000000000000000000000000000000000000000000000000000000000000003cc02aaa39b223fe8d0a0e5c4f27ead9083c756cc211a653ddfbb61e0feff5484919f06d9d254bf65fa0b86991c6218b36c1d19d4a2e9eb0ce3606eb480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000831bf48183b999fde45294b14b55199072f0801b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c475d39ecb0000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab4100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000377936629f03f34000000000000000000000000fffd8963efd1fc6a506488495d951d5263988d250000000000000000000000000000000000000000000000000000000021c0000000000000000000000000000000000000000000000000000000000f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ba12222222228d8ba445958a75a0704d566bf2c80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001c452bbbe2900000000000000000000000000000000000000000000000000000000000000e00000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab4100000000000000000000000000000000000000000000000000000000000000000000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab4100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e2000000000000000000000000000000000000000000000000000000000000000000f000000000040f1cb91325dd8ef24dfac085c9ba46ea309e5e2000200000000000000000644000000000000000000000000000000000000000000000000000000000000000000000000000000000000000063b420fb3294ba1d300ce5d3ba4bbca0f4fe5e3b000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000000000000000000000000281af54148361a94000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e592427a0aece92de3edee1f18e0157c05861564000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000144c04b8d59000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000009008d19f58aabd9ed0d60971565aa8510560ab4100000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000035dea0e8d91c9800f9000000000000000000000000000000000000000000003c9000000000000000000000000000000000000000000000000000000000000000000000000000000042826180541412d574cf1336d22c0c0a287822678a000bb8c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000bb8d7c1eb0fe4a30d3b2a846c04aa6300888f087a5f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000242e1a7d4d0000000000000000000000000000000000000000000000000e204038c7e0f68e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007c70ae", + "gasLimit": 5000000, + "value": "0", + "blockNumber": 18789653, + // happened at timestamp 1702617167 + }); + + let res = warp::test::request() + .method("POST") + .path("/simulate") + .json(&json) + .reply(&filter) + .await; + + assert_eq!(res.status(), 200); + + let body: SimulationResponse = serde_json::from_slice(res.body()).unwrap(); + + assert!(body.success); + + // Now let's simulate as if we had the timestamp of the next block. + json.as_object_mut() + .unwrap() + .insert("blockTimestamp".into(), serde_json::json!(1702617179)); + + let res = warp::test::request() + .method("POST") + .path("/simulate") + .json(&json) + .reply(&filter) + .await; + + assert_eq!(res.status(), 200); + + let body: SimulationResponse = serde_json::from_slice(res.body()).unwrap(); + + // Due to smart contract logic dependent on the timestamp the same transaction fails + // when we use the timestamp of the next block. + assert!(!body.success); +}