New endpoints buildEthBlock[FromBundles]
are now merged in suavex-foundry. One thing I didn’t notice before was that the simulateBundle precompile uses suavex_buildEthBlock
on the backend. So now with the addition of this endpoint, you can simulate bundles from suave locally!
Now that this is working, I thought it would be helpful to post some info so others can start using it, too!
Instructions to run a local suave dev environment with suavex-anvil:
First you need to run the suave-geth devnet with the --suave.eth.remote_endpoint
flag set to point to our anvil node (which we’ll run next):
if you haven’t installed suave, you can do so by running this:
curl -L https://suaveup.flashbots.net | bash
This will install suave-geth into /usr/local/bin/suave-geth
, so you should be able to use it in your terminal immediately.
# if you built from source, replace `suave-geth` with `./build/bin/suave`
suave-geth \
--dev \
--dev.gaslimit=30000000 \
--http \
--http.port=8545 \
--http.vhosts='*' \
--http.corsdomain='*' \
--ws \
--ws.origins='*' \
--keystore=./suave/devenv/suave-ex-node/keystore \
--unlock=0xB5fEAfbDD752ad52Afb7e1bD2E40432A485bBB7F \
--password=./suave/devenv/suave-ex-node/password.txt \
--suave.eth.remote_endpoint=http://localhost:8555 \
--suave.eth.external-whitelist='*'
Also note the --suave.eth.external-whitelist
flag. This setting lets precompiles that make HTTP requests (like DO_HTTPREQUEST
or SUBMIT_ETH_BLOCK_TO_RELAY
) target any URL.
Now that suave-geth is running, open a new terminal, and run the following to spin up suavex-anvil with a mainnet fork. Note: you’ll need the Rust toolchain installed.
# clone the repo & go into its directory
git clone https://github.com/flashbots/suavex-foundry
cd suavex-foundry
# run anvil with cargo
export RPC_URL=https://REPLACE_WITH_YOUR_MAINNET_RPC_URL
cargo run --bin anvil -- -p 8555 --chain-id 1 -f $RPC_URL
All done. Now when you send a CCR to suave-geth, it will use anvil as its eth provider for any precompiles that call suavex_
endpoints. This includes simulateBundle
, ethCall
, submitEthBlockToRelay
, buildEthBlock
, and probably more that I haven’t tested.
You can test it out with an example like Unisuapp:
Note: you’ll want to install bun and foundry if you haven’t already.
# clone repo if you haven't already, and enter its directory
git clone https://github.com/zeroXbrock/unisuapp
cd unisuapp
# populate .env, uses pre-funded default accounts
echo "L1_CHAIN_ID=1
L1_KEY=ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
L1_RPC_URL=http://localhost:8555
SUAVE_KEY=91ab9a7e53c220e6210460b65a7a3bb2ca181412a8a7b43ff336b3df1737ce12
SUAVE_RPC_URL=http://localhost:8545" > .env
# install solidity dependencies & build contracts
forge install
forge build
# install NPM dependencies
bun install
# first run the script with DEPLOY set to deploy the contracts
# deployed contract address will be saved to `addresses.json`
DEPLOY=true bun run index.ts
# now you can run again without deploying
bun run index.ts