diff --git a/Cargo.lock b/Cargo.lock index 0c4bcf664..63852a601 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9664,6 +9664,7 @@ dependencies = [ "serde_with", "sha2 0.10.9", "ssz_types", + "strum 0.27.2", "thiserror 1.0.69", "time", "tree_hash 0.8.0", diff --git a/crates/rbuilder-primitives/Cargo.toml b/crates/rbuilder-primitives/Cargo.toml index 4fe5c906d..b972ec707 100644 --- a/crates/rbuilder-primitives/Cargo.toml +++ b/crates/rbuilder-primitives/Cargo.toml @@ -50,6 +50,7 @@ eyre.workspace = true serde.workspace = true derive_more.workspace = true serde_json.workspace = true +strum = { version = "0.27.2", features = ["derive"] } [dev-dependencies] alloy-primitives = { workspace = true, features = ["arbitrary"] } diff --git a/crates/rbuilder-primitives/src/ace.rs b/crates/rbuilder-primitives/src/ace.rs new file mode 100644 index 000000000..3f86ea84d --- /dev/null +++ b/crates/rbuilder-primitives/src/ace.rs @@ -0,0 +1,832 @@ +use crate::evm_inspector::{SlotKey, UsedStateTrace}; +use alloy_primitives::{Address, FixedBytes, B256}; +use serde::Deserialize; +use std::collections::HashSet; + +/// 4-byte function selector +pub type Selector = FixedBytes<4>; + +/// Configuration for an ACE (Application Controlled Execution) protocol +#[derive(Debug, Clone, Deserialize, PartialEq, Eq)] +pub struct AceConfig { + /// The primary contract address for this ACE protocol (used as unique identifier) + pub contract_address: Address, + /// Addresses that send ACE orders (used to identify force unlocks) + pub from_addresses: HashSet
, + /// Addresses that receive ACE orders (the ACE contract addresses) + pub to_addresses: HashSet, + /// Storage slots that must be read to detect ACE interaction (e.g., _lastBlockUpdated at slot 3) + pub detection_slots: HashSet(
ctx: BlockBuildingContext,
available_orders: Vec (
ctx: &BlockBuildingContext,
orders: &[Arc {
run_sparse_trie_prefetcher: bool,
order_flow_tracer_manager: Box ,
run_sparse_trie_prefetcher: bool,
order_flow_tracer_manager: Box (
let mut block_state = BlockState::new_arc(state_provider.clone());
let sim_result = simulate_order(
task.parents.clone(),
- task.order,
+ task.order.clone(),
¤t_sim_context.block_ctx,
&mut local_ctx,
&mut block_state,
+ ¤t_sim_context.ace_configs,
+ &task.ace_state,
);
let sim_ok = match sim_result {
Ok(sim_result) => {
let sim_ok = match sim_result.result {
OrderSimResult::Success(simulated_order, nonces_after) => {
- let result = SimulatedResult {
+ let mut dependencies_satisfied: Vec (
}
Err(err) => {
error!(?err, ?order_id, "Critical error while simulating order");
- // @Metric
break;
}
};
diff --git a/crates/rbuilder/src/live_builder/simulation/simulation_job.rs b/crates/rbuilder/src/live_builder/simulation/simulation_job.rs
index 22b2eca05..70a799430 100644
--- a/crates/rbuilder/src/live_builder/simulation/simulation_job.rs
+++ b/crates/rbuilder/src/live_builder/simulation/simulation_job.rs
@@ -1,7 +1,7 @@
use std::{fmt, sync::Arc};
use crate::{
- building::sim::{SimTree, SimulatedResult, SimulationRequest},
+ building::sim::{SimTree, SimulatedResult, SimulationFailure, SimulationRequest},
live_builder::{
order_input::order_sink::OrderPoolCommand,
simulation::simulation_job_tracer::SimulationJobTracer,
@@ -190,53 +190,77 @@ impl SimulationJob {
&mut self,
new_sim_results: &mut Vec