Skip to content

Commit 729aba4

Browse files
authored
chore: remove host fills (#133)
* chore: remove host fills * test: fix bundle tests * chore: clippy and version
1 parent 7f439ae commit 729aba4

File tree

9 files changed

+91
-182
lines changed

9 files changed

+91
-182
lines changed

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = ["crates/*"]
33
resolver = "2"
44

55
[workspace.package]
6-
version = "0.12.0"
6+
version = "0.13.0"
77
edition = "2021"
88
rust-version = "1.85"
99
authors = ["init4"]
@@ -34,18 +34,18 @@ debug = false
3434
incremental = false
3535

3636
[workspace.dependencies]
37-
signet-bundle = { version = "0.12", path = "crates/bundle" }
38-
signet-constants = { version = "0.12", path = "crates/constants" }
39-
signet-evm = { version = "0.12", path = "crates/evm" }
40-
signet-extract = { version = "0.12", path = "crates/extract" }
41-
signet-journal = { version = "0.12", path = "crates/journal" }
42-
signet-node = { version = "0.12", path = "crates/node" }
43-
signet-sim = { version = "0.12", path = "crates/sim" }
44-
signet-types = { version = "0.12", path = "crates/types" }
45-
signet-tx-cache = { version = "0.12", path = "crates/tx-cache" }
46-
signet-zenith = { version = "0.12", path = "crates/zenith" }
37+
signet-bundle = { version = "0.13", path = "crates/bundle" }
38+
signet-constants = { version = "0.13", path = "crates/constants" }
39+
signet-evm = { version = "0.13", path = "crates/evm" }
40+
signet-extract = { version = "0.13", path = "crates/extract" }
41+
signet-journal = { version = "0.13", path = "crates/journal" }
42+
signet-node = { version = "0.13", path = "crates/node" }
43+
signet-sim = { version = "0.13", path = "crates/sim" }
44+
signet-types = { version = "0.13", path = "crates/types" }
45+
signet-tx-cache = { version = "0.13", path = "crates/tx-cache" }
46+
signet-zenith = { version = "0.13", path = "crates/zenith" }
4747

48-
signet-test-utils = { version = "0.12", path = "crates/test-utils" }
48+
signet-test-utils = { version = "0.13", path = "crates/test-utils" }
4949

5050
# trevm
5151
trevm = { version = "0.30.0", features = ["full_env_cfg"] }

crates/bundle/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ signet-types.workspace = true
1414
signet-evm.workspace = true
1515

1616
trevm.workspace = true
17-
signet-zenith.workspace = true
1817

1918
alloy.workspace = true
2019

crates/bundle/src/send/bundle.rs

Lines changed: 13 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
//! Signet bundle types.
2-
use crate::send::SignetEthBundleError;
32
use alloy::{
43
consensus::TxEnvelope,
54
eips::Decodable2718,
6-
network::Network,
75
primitives::{Bytes, B256},
8-
providers::Provider,
96
rlp::Buf,
107
rpc::types::mev::EthSendBundle,
118
};
129
use serde::{Deserialize, Serialize};
13-
use signet_types::{SignedFill, SignedPermitError};
14-
use signet_zenith::HostOrders::HostOrdersInstance;
1510
use trevm::{
1611
inspectors::{Layered, TimeLimit},
1712
revm::{inspector::NoOpInspector, Database},
@@ -26,7 +21,7 @@ pub type BundleInspector<I = NoOpInspector> = Layered<TimeLimit, I>;
2621
/// The Signet bundle contains the following:
2722
///
2823
/// - A standard [`EthSendBundle`] with the transactions to simulate.
29-
/// - A signed permit2 fill to be applied on the Host chain with the bundle.
24+
/// - Host transactions to be included in the host bundle.
3025
///
3126
/// This is based on the flashbots `eth_sendBundle` bundle. See [their docs].
3227
///
@@ -37,10 +32,6 @@ pub struct SignetEthBundle {
3732
/// The bundle of transactions to simulate. Same structure as a Flashbots [`EthSendBundle`] bundle.
3833
#[serde(flatten)]
3934
pub bundle: EthSendBundle,
40-
/// Host fills to be applied with the bundle, represented as a signed
41-
/// permit2 fill.
42-
#[serde(default, skip_serializing_if = "Option::is_none")]
43-
pub host_fills: Option<SignedFill>,
4435

4536
/// Host transactions to be included in the host bundle.
4637
#[serde(default, skip_serializing_if = "Vec::is_empty")]
@@ -110,36 +101,19 @@ impl SignetEthBundle {
110101
Ok(txs)
111102
}
112103

113-
/// Check that this can be syntactically used as a fill.
114-
pub fn validate_fills_offchain(&self, timestamp: u64) -> Result<(), SignedPermitError> {
115-
if let Some(host_fills) = &self.host_fills {
116-
host_fills.validate(timestamp)
117-
} else {
118-
Ok(())
119-
}
120-
}
121-
122-
/// Check that this fill is valid on-chain as of the current block. This
123-
/// checks that the tokens can actually be transferred.
124-
///
125-
/// # WARNING:
126-
///
127-
/// This function will send an RPC request to the provider containing the
128-
/// fills. It MUST NOT be used with an untrusted provider.
129-
pub async fn alloy_validate_fills_onchain<Db, P, N>(
104+
/// Decode and validate the host transactions in the bundle.
105+
pub fn decode_and_validate_host_txs<Db: Database>(
130106
&self,
131-
orders: HostOrdersInstance<P, N>,
132-
) -> Result<(), SignetEthBundleError<Db>>
133-
where
134-
Db: Database,
135-
P: Provider<N>,
136-
N: Network,
137-
{
138-
if let Some(host_fills) = self.host_fills.clone() {
139-
orders.try_fill(host_fills.outputs, host_fills.permit).await.map_err(Into::into)
140-
} else {
141-
Ok(())
142-
}
107+
) -> Result<Vec<TxEnvelope>, BundleError<Db>> {
108+
// Decode and validate the host transactions in the bundle
109+
let txs = self
110+
.host_txs
111+
.iter()
112+
.map(|tx| TxEnvelope::decode_2718(&mut tx.chunk()))
113+
.collect::<Result<Vec<_>, _>>()
114+
.map_err(|err| BundleError::TransactionDecodingError(err))?;
115+
116+
Ok(txs)
143117
}
144118
}
145119

@@ -161,10 +135,6 @@ pub struct SignetEthBundleResponse {
161135
#[cfg(test)]
162136
mod test {
163137
use super::*;
164-
use alloy::primitives::{Address, U256};
165-
use signet_zenith::HostOrders::{
166-
Output, Permit2Batch, PermitBatchTransferFrom, TokenPermissions,
167-
};
168138

169139
#[test]
170140
fn send_bundle_ser_roundtrip() {
@@ -178,26 +148,6 @@ mod test {
178148
replacement_uuid: Some("uuid".to_owned()),
179149
..Default::default()
180150
},
181-
host_fills: Some(SignedFill {
182-
permit: Permit2Batch {
183-
permit: PermitBatchTransferFrom {
184-
permitted: vec![TokenPermissions {
185-
token: Address::repeat_byte(66),
186-
amount: U256::from(17),
187-
}],
188-
nonce: U256::from(18),
189-
deadline: U256::from(19),
190-
},
191-
owner: Address::repeat_byte(77),
192-
signature: Bytes::from(b"abcd"),
193-
},
194-
outputs: vec![Output {
195-
token: Address::repeat_byte(88),
196-
amount: U256::from(20),
197-
recipient: Address::repeat_byte(99),
198-
chainId: 100,
199-
}],
200-
}),
201151
host_txs: vec![b"host_tx1".into(), b"host_tx2".into()],
202152
};
203153

@@ -219,7 +169,6 @@ mod test {
219169
replacement_uuid: Some("uuid".to_owned()),
220170
..Default::default()
221171
},
222-
host_fills: None,
223172
host_txs: vec![],
224173
};
225174

@@ -236,7 +185,6 @@ mod test {
236185

237186
let deserialized: SignetEthBundle = serde_json::from_str(json).unwrap();
238187

239-
assert!(deserialized.host_fills.is_none());
240188
assert!(deserialized.host_txs.is_empty());
241189
}
242190

crates/bundle/src/send/driver.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,19 @@ pub struct SignetEthBundleDriver<'a> {
7878
impl<'a> SignetEthBundleDriver<'a> {
7979
/// Creates a new [`SignetEthBundleDriver`] with the given bundle and
8080
/// response.
81-
pub fn new(
81+
pub fn new(bundle: &'a SignetEthBundle, deadline: std::time::Instant) -> Self {
82+
Self::new_with_agg_fills(bundle, deadline, Default::default())
83+
}
84+
85+
/// Creates a new [`SignetEthBundleDriver`] with the given bundle,
86+
/// response, and aggregate fills.
87+
///
88+
/// This is useful for testing, and for combined host-rollup simulation.
89+
pub const fn new_with_agg_fills(
8290
bundle: &'a SignetEthBundle,
83-
host_chain_id: u64,
8491
deadline: std::time::Instant,
92+
agg_fills: AggregateFills,
8593
) -> Self {
86-
let mut agg_fills = AggregateFills::default();
87-
if let Some(host_fills) = &bundle.host_fills {
88-
agg_fills.add_signed_fill(host_chain_id, host_fills);
89-
}
90-
9194
Self {
9295
bundle,
9396
deadline,
@@ -125,6 +128,14 @@ impl<'a> SignetEthBundleDriver<'a> {
125128
&self.agg_fills
126129
}
127130

131+
/// Get a mutable reference to the aggregate fills for this driver.
132+
///
133+
/// Accessing this is not recommended outside of testing or advanced
134+
/// usage.
135+
pub const fn agg_fills_mut(&mut self) -> &mut AggregateFills {
136+
&mut self.agg_fills
137+
}
138+
128139
/// Check the [`AggregateFills`], discard if invalid, otherwise accumulate
129140
/// payable gas and call [`Self::accept_tx`].
130141
///
@@ -191,11 +202,6 @@ where
191202
BundleError::TimestampOutOfRange.into()
192203
);
193204

194-
// Check that the `SignedFill` is valid at the timestamp.
195-
if self.bundle().validate_fills_offchain(timestamp.to()).is_err() {
196-
return Err(trevm.errored(BundleError::BundleReverted.into()));
197-
}
198-
199205
// Decode and validate the transactions in the bundle
200206
let txs = trevm_try!(self.bundle.decode_and_validate_txs(), trevm);
201207

crates/sim/src/built.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ impl BuiltBlock {
138138
// As this builder does not provide bundles landing "top of block", its fine to just extend.
139139
self.transactions.extend(txs);
140140
self.host_txns.extend(bundle.host_txs);
141-
142-
if let Some(host_fills) = bundle.host_fills {
143-
self.host_fills.push(host_fills);
144-
}
145141
} else {
146142
error!("failed to decode bundle. dropping");
147143
}

crates/sim/src/cache.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,6 @@ mod test {
306306
replacement_uuid: Some(replacement_uuid),
307307
..Default::default()
308308
},
309-
host_fills: None,
310309
host_txs: vec![],
311310
}
312311
}

crates/sim/src/env/sim_env.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ where
190190
where
191191
RuInsp: Inspector<Ctx<SimDb<RuDb>>> + Default + Sync,
192192
{
193-
let mut driver =
194-
SignetEthBundleDriver::new(bundle, self.constants().host_chain_id(), self.finish_by);
193+
let mut driver = SignetEthBundleDriver::new(bundle, self.finish_by);
195194
let trevm = self.rollup_evm();
196195

197196
// Run the bundle

crates/test-utils/src/specs/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use alloy::{
1818
sol_types::SolCall,
1919
};
2020
use signet_bundle::SignetEthBundle;
21-
use signet_types::SignedFill;
2221

2322
/// Sign a transaction with a wallet.
2423
pub fn sign_tx_with_key_pair(wallet: &PrivateKeySigner, tx: TypedTransaction) -> TxEnvelope {
@@ -72,12 +71,13 @@ where
7271
}
7372

7473
/// Create a simple bundle from a list of transactions.
75-
pub fn simple_bundle<'a>(
76-
txs: impl IntoIterator<Item = &'a TxEnvelope>,
77-
host_fills: Option<SignedFill>,
74+
pub fn simple_bundle(
75+
txs: Vec<TxEnvelope>,
76+
host_txs: Vec<TxEnvelope>,
7877
block_number: u64,
7978
) -> SignetEthBundle {
8079
let txs = txs.into_iter().map(|tx| tx.encoded_2718().into()).collect();
80+
let host_txs = host_txs.into_iter().map(|tx| tx.encoded_2718().into()).collect();
8181

8282
SignetEthBundle {
8383
bundle: EthSendBundle {
@@ -93,7 +93,6 @@ pub fn simple_bundle<'a>(
9393
refund_tx_hashes: vec![],
9494
extra_fields: Default::default(),
9595
},
96-
host_fills,
97-
host_txs: vec![],
96+
host_txs,
9897
}
9998
}

0 commit comments

Comments
 (0)