Skip to content

Commit

Permalink
fix(sim): update simulation for dencun opcodes
Browse files Browse the repository at this point in the history
  • Loading branch information
dancoombs committed May 23, 2024
1 parent 02af869 commit 6011381
Show file tree
Hide file tree
Showing 17 changed files with 462 additions and 80 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions crates/builder/src/bundle_proposer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ where
self.fee_estimator.required_bundle_fees(required_fees)
)?;

tracing::info!("Starting bundle proposal with {} ops", ops.len());
tracing::debug!("Starting bundle proposal with {} ops", ops.len());

// (0) Determine fees required for ops to be included in a bundle
// if replacing, just require bundle fees increase chances of unsticking
Expand All @@ -179,12 +179,12 @@ where
.flatten()
.collect::<Vec<_>>();

tracing::info!("Bundle proposal after fee limit had {} ops", ops.len());
tracing::debug!("Bundle proposal after fee limit had {} ops", ops.len());

// (2) Limit the amount of operations for simulation
let (ops, gas_limit) = self.limit_user_operations_for_simulation(ops);

tracing::info!(
tracing::debug!(
"Bundle proposal after gas limit had {} ops and {:?} gas limit",
ops.len(),
gas_limit
Expand Down
3 changes: 1 addition & 2 deletions crates/pool/src/server/remote/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
// If not, see https://www.gnu.org/licenses/.

use anyhow::{bail, Context};
use ethers::types::Opcode;
use rundler_task::grpc::protos::{from_bytes, ToProtoBytes};
use rundler_types::{
pool::{
MempoolError, NeedsStakeInformation, PoolError, PrecheckViolation, SimulationViolation,
},
StorageSlot, ValidationRevert, ViolationOpCode,
Opcode, StorageSlot, ValidationRevert, ViolationOpCode,
};

use super::protos::{
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/src/eth/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use std::fmt::Display;

use ethers::types::{Address, Bytes, Opcode, U256};
use ethers::types::{Address, Bytes, U256};
use jsonrpsee::types::{
error::{CALL_EXECUTION_FAILED_CODE, INTERNAL_ERROR_CODE, INVALID_PARAMS_CODE},
ErrorObjectOwned,
Expand All @@ -22,7 +22,7 @@ use rundler_provider::ProviderError;
use rundler_sim::GasEstimationError;
use rundler_types::{
pool::{MempoolError, PoolError, PrecheckViolation, SimulationViolation},
Entity, EntityType, Timestamp, ValidationRevert,
Entity, EntityType, Opcode, Timestamp, ValidationRevert,
};
use serde::Serialize;

Expand Down
5 changes: 3 additions & 2 deletions crates/sim/src/simulation/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
use std::collections::{BTreeSet, HashMap, HashSet};

use anyhow::Context;
use ethers::types::{Address, BlockId, Opcode, U256};
use ethers::types::{Address, BlockId, U256};
use rundler_types::{
pool::SimulationViolation, EntityInfos, EntityType, StakeInfo, UserOperation, ValidationOutput,
pool::SimulationViolation, EntityInfos, EntityType, Opcode, StakeInfo, UserOperation,
ValidationOutput,
};
use serde::{Deserialize, Serialize};

Expand Down
4 changes: 2 additions & 2 deletions crates/sim/src/simulation/mempool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

use std::{collections::HashMap, str::FromStr};

use ethers::types::{Address, Opcode, H256, U256};
use rundler_types::{Entity, EntityType};
use ethers::types::{Address, H256, U256};
use rundler_types::{Entity, EntityType, Opcode};
use serde::Deserialize;
use serde_with::{serde_as, DisplayFromStr};

Expand Down
10 changes: 5 additions & 5 deletions crates/sim/src/simulation/simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ use std::{
};

use async_trait::async_trait;
use ethers::types::{Address, Opcode, H256, U256};
use ethers::types::{Address, H256, U256};
use rundler_provider::{
AggregatorOut, AggregatorSimOut, EntryPoint, Provider, SignatureAggregator, SimulationProvider,
};
use rundler_types::{
pool::{NeedsStakeInformation, SimulationViolation},
v0_6::UserOperation as UserOperationV0_6,
v0_7::UserOperation as UserOperationV0_7,
Entity, EntityInfo, EntityInfos, EntityType, StorageSlot, UserOperation, ValidTimeRange,
ValidationOutput, ValidationReturnInfo, ViolationOpCode,
Entity, EntityInfo, EntityInfos, EntityType, Opcode, StorageSlot, UserOperation,
ValidTimeRange, ValidationOutput, ValidationReturnInfo, ViolationOpCode,
};

use super::context::{
Expand Down Expand Up @@ -661,10 +661,10 @@ fn override_infos_staked(eis: &mut EntityInfos, allow_unstaked_addresses: &HashS
mod tests {
use std::str::FromStr;

use ethers::types::{Address, BlockId, BlockNumber, Bytes, Opcode, U256, U64};
use ethers::types::{Address, BlockId, BlockNumber, Bytes, U256, U64};
use rundler_provider::{AggregatorOut, MockEntryPointV0_6, MockProvider};
use rundler_types::{
contracts::utils::get_code_hashes::CodeHashesResult, v0_6::UserOperation, StakeInfo,
contracts::utils::get_code_hashes::CodeHashesResult, v0_6::UserOperation, Opcode, StakeInfo,
};

use self::context::{Phase, TracerOutput};
Expand Down
6 changes: 4 additions & 2 deletions crates/sim/src/simulation/v0_7/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::{
use anyhow::{bail, Context};
use ethers::{
abi::AbiDecode,
types::{Address, BlockId, Bytes, Opcode, H160, U256},
types::{Address, BlockId, Bytes, H160, U256},
utils::{hex::FromHex, keccak256},
};
use rundler_provider::{EntryPoint, Provider, SimulationProvider};
Expand All @@ -30,7 +30,7 @@ use rundler_types::{
},
pool::SimulationViolation,
v0_7::UserOperation,
EntityInfos, EntityType, UserOperation as UserOperationTrait, ValidationOutput,
EntityInfos, EntityType, Opcode, UserOperation as UserOperationTrait, ValidationOutput,
ValidationRevert,
};
use rundler_utils::eth::ContractRevertError;
Expand Down Expand Up @@ -59,6 +59,8 @@ const BANNED_OPCODES: &[Opcode] = &[
Opcode::TIMESTAMP,
Opcode::BASEFEE,
Opcode::BLOCKHASH,
Opcode::BLOBBASEFEE,
Opcode::BLOBHASH,
Opcode::NUMBER,
Opcode::SELFBALANCE,
Opcode::BALANCE,
Expand Down
4 changes: 2 additions & 2 deletions crates/sim/src/simulation/v0_7/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ use anyhow::bail;
use async_trait::async_trait;
use ethers::types::{
Address, BlockId, GethDebugTracerType, GethDebugTracingCallOptions, GethDebugTracingOptions,
GethTrace, Opcode, U256,
GethTrace, U256,
};
use rundler_provider::{Provider, SimulationProvider};
use rundler_types::v0_7::UserOperation;
use rundler_types::{v0_7::UserOperation, Opcode};
use serde::Deserialize;

use crate::ExpectedStorage;
Expand Down
4 changes: 3 additions & 1 deletion crates/sim/tracer/src/validationTracerV0_6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ type StringSet = Record<string, boolean | undefined>;
"TIMESTAMP",
"BASEFEE",
"BLOCKHASH",
"BLOBBASEFEE",
"BLOBHASH",
"NUMBER",
"SELFBALANCE",
"BALANCE",
Expand All @@ -104,7 +106,7 @@ type StringSet = Record<string, boolean | undefined>;
// address as their *first* argument, or modify the handling below.
const EXT_OPCODES = stringSet(["EXTCODECOPY", "EXTCODEHASH", "EXTCODESIZE"]);

const READ_WRITE_OPCODES = stringSet(["SSTORE", "SLOAD"]);
const READ_WRITE_OPCODES = stringSet(["SSTORE", "SLOAD", "TSTORE", "TLOAD"]);
// Whitelisted precompile addresses.
const PRECOMPILE_WHITELIST = stringSet([
"0x0000000000000000000000000000000000000001", // ecRecover
Expand Down
1 change: 1 addition & 0 deletions crates/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ constcat = "0.4.1"
const-hex = "1.11.3"
ethers.workspace = true
futures-util.workspace = true
num_enum = "0.7.2"
parse-display.workspace = true
rand.workspace = true
serde.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mod entity;
pub use entity::{Entity, EntityInfo, EntityInfos, EntityType, EntityUpdate, EntityUpdateType};

mod opcode;
pub use opcode::ViolationOpCode;
pub use opcode::{Opcode, ViolationOpCode};

mod gas;
pub use gas::GasFees;
Expand Down
Loading

0 comments on commit 6011381

Please sign in to comment.