Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move mev.rs from reth to rpc-types-mev #970

Merged
merged 11 commits into from Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/rpc-types-mev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rustdoc-args = ["--cfg", "docsrs"]
[dependencies]
alloy-eips = { workspace = true, features = ["serde"] }
alloy-primitives.workspace = true
alloy-rpc-types.workspace = true
alloy-serde.workspace = true

serde.workspace = true
serde_json.workspace = true
Expand Down
48 changes: 24 additions & 24 deletions crates/rpc-types-mev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ pub struct SendBundleRequest {
#[serde(rename_all = "camelCase")]
pub struct Inclusion {
/// The first block the bundle is valid for.
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub block: u64,
/// The last block the bundle is valid for.
#[serde(
default,
with = "alloy_rpc_types::serde_helpers::quantity::opt",
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)]
pub max_block: Option<u64>,
Expand Down Expand Up @@ -111,10 +111,10 @@ pub struct Validity {
#[serde(rename_all = "camelCase")]
pub struct Refund {
/// The index of the transaction in the bundle.
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub body_idx: u64,
/// The minimum percent of the bundle's earnings to redistribute.
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub percent: u64,
}

Expand All @@ -126,7 +126,7 @@ pub struct RefundConfig {
/// The address to refund.
pub address: Address,
/// The minimum percent of the bundle's earnings to redistribute.
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub percent: u64,
}

Expand Down Expand Up @@ -329,36 +329,36 @@ pub struct SimBundleOverrides {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub parent_block: Option<BlockId>,
/// Block number used for simulation, defaults to parentBlock.number + 1
#[serde(default, with = "alloy_rpc_types::serde_helpers::quantity::opt")]
#[serde(default, with = "alloy_serde::quantity::opt")]
pub block_number: Option<u64>,
/// Coinbase used for simulation, defaults to parentBlock.coinbase
#[serde(default, skip_serializing_if = "Option::is_none")]
pub coinbase: Option<Address>,
/// Timestamp used for simulation, defaults to parentBlock.timestamp + 12
#[serde(
default,
with = "alloy_rpc_types::serde_helpers::quantity::opt",
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)]
pub timestamp: Option<u64>,
/// Gas limit used for simulation, defaults to parentBlock.gasLimit
#[serde(
default,
with = "alloy_rpc_types::serde_helpers::quantity::opt",
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)]
pub gas_limit: Option<u64>,
/// Base fee used for simulation, defaults to parentBlock.baseFeePerGas
#[serde(
default,
with = "alloy_rpc_types::serde_helpers::quantity::opt",
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)]
pub base_fee: Option<u64>,
/// Timeout in seconds, defaults to 5
#[serde(
default,
with = "alloy_rpc_types::serde_helpers::quantity::opt",
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)]
pub timeout: Option<u64>,
Expand All @@ -374,19 +374,19 @@ pub struct SimBundleResponse {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub error: Option<String>,
/// The block number of the simulated block.
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub state_block: u64,
/// The gas price of the simulated block.
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub mev_gas_price: u64,
/// The profit of the simulated block.
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub profit: u64,
/// The refundable value of the simulated block.
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub refundable_value: u64,
/// The gas used by the simulated block.
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub gas_used: u64,
/// Logs returned by `mev_simBundle`.
#[serde(default, skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -441,7 +441,7 @@ pub struct PrivateTransactionRequest {
/// be included.
#[serde(
default,
with = "alloy_rpc_types::serde_helpers::quantity::opt",
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)]
pub max_block_number: Option<u64>,
Expand Down Expand Up @@ -632,19 +632,19 @@ pub struct EthSendBundle {
/// A list of hex-encoded signed transactions
pub txs: Vec<Bytes>,
/// hex-encoded block number for which this bundle is valid
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub block_number: u64,
/// unix timestamp when this bundle becomes active
#[serde(
default,
with = "alloy_rpc_types::serde_helpers::quantity::opt",
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)]
pub min_timestamp: Option<u64>,
/// unix timestamp how long this bundle stays valid
#[serde(
default,
with = "alloy_rpc_types::serde_helpers::quantity::opt",
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)]
pub max_timestamp: Option<u64>,
Expand Down Expand Up @@ -673,14 +673,14 @@ pub struct EthCallBundle {
/// A list of hex-encoded signed transactions
pub txs: Vec<Bytes>,
/// hex encoded block number for which this bundle is valid on
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub block_number: u64,
/// Either a hex encoded number or a block tag for which state to base this simulation on
pub state_block_number: BlockNumberOrTag,
/// the timestamp to use for this bundle simulation, in seconds since the unix epoch
#[serde(
default,
with = "alloy_rpc_types::serde_helpers::quantity::opt",
with = "alloy_serde::quantity::opt",
skip_serializing_if = "Option::is_none"
)]
pub timestamp: Option<u64>,
Expand All @@ -707,10 +707,10 @@ pub struct EthCallBundleResponse {
/// Results of individual transactions within the bundle
pub results: Vec<EthCallBundleTransactionResult>,
/// The block number used as a base for this simulation
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub state_block_number: u64,
/// The total gas used by all transactions in the bundle
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub total_gas_used: u64,
}

Expand All @@ -733,7 +733,7 @@ pub struct EthCallBundleTransactionResult {
#[serde(with = "u256_numeric_string")]
pub gas_price: U256,
/// The amount of gas used by the transaction
#[serde(with = "alloy_rpc_types::serde_helpers::quantity")]
#[serde(with = "alloy_serde::quantity")]
pub gas_used: u64,
/// The address to which the transaction is sent (optional)
pub to_address: Option<Address>,
Expand Down
1 change: 1 addition & 0 deletions crates/rpc-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ alloy-rpc-types-anvil = { workspace = true, optional = true }
alloy-rpc-types-beacon = { workspace = true, optional = true }
alloy-rpc-types-engine = { workspace = true, optional = true }
alloy-rpc-types-eth = { workspace = true, optional = true }
alloy-rpc-types-mev = { workspace = true, optional = true }
This conversation was marked as resolved.
Show resolved Hide resolved
alloy-rpc-types-trace = { workspace = true, optional = true }
alloy-rpc-types-txpool = { workspace = true, optional = true }

Expand Down
Loading