11//! Signet bundle types.
2- use crate :: send:: SignetEthBundleError ;
32use 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} ;
129use serde:: { Deserialize , Serialize } ;
13- use signet_types:: { SignedFill , SignedPermitError } ;
14- use signet_zenith:: HostOrders :: HostOrdersInstance ;
1510use 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) ]
162136mod 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
0 commit comments