Simulating Signet Bundles

Signet Bundles

Signet bundles extend flashbots's EthCallBundle type with an additional field called host_fills. This is a mapping of assets, to mappings of users and amounts. The Signet EVM will apply these host fills for simulation. This allows simulating properly Signet transactions containing Orders.

Instantiating the Signet EVM

The signet_evm crate contains the signet_evm function to help instantiate the EVM.

// The DB is a revm `Database`
// - `orders_address` is the address of the Orders system contract. This is a constant.
// - `host_chain_id` is the EIP155 chain ID of the host. This is a constant 
//    and will usually be 1 (Ethereum) or 17000 (holesky).
let trevm = signet_evm::signet_evm(db, orders_address, host_chain_id);

// Coming soon!
let trevm = signet_evm::testnet(db);
let trevm = signet_evm::mainnet(db);

When testnet and mainnet have been deployed, the crate will be updated with shortcut functions to instantiate EVMs for each network without providing the orders address and chain id.

Simulating Signet Bundles with trevm

Bundles are easy to simulate using the signet-evm crate. The crate provides shortcuts for instantiating the Signet EVM, as well as implementations of trevm drivers for transactions and bundle types. This will return either an error string or the EthCallBundle, exactly as if simulated via RPC.

You can also run bundles over RPC endpoints on a Signet node. SeeSimulating Bundles via RPC

fn simulate_bundle<Db: Database + DatabaseCommit>(
    trevm: signet_evm::EvmNeedsTx<'static, Db>,
    bundle: SignetCallBundle,
    host_chain_id: u64,
) -> Result<SignetCallBundleResponse, String> {
    let mut driver = SignetBundleDriver::new(bundle, host_chain_id);

    match trevm.drive_bundle(&mut driver) {
        Ok(trevm) => Ok(driver.into_response()),
        Err(e) => Err(format!("Error driving bundle: {:?}", e)),
    }
}

Simulating host_fills

The host_fills section of a bundle transfers tokens on Ethereum. In order to simulate it, perform the following

  • Check the full permit2 signature.

  • Check each transfer to see the sender has the appropriate balance.

  • Check that the sender has approved the permit2 contract.

Last updated