11//! Test utilities for testing builder tasks
22use crate :: config:: BuilderConfig ;
33use alloy:: {
4- consensus:: { SignableTransaction , TxEip1559 , TxEnvelope } , primitives:: { Address , TxKind , B256 , U256 } , rpc:: client:: BuiltInConnectionString , signers:: { local:: PrivateKeySigner , SignerSync }
4+ consensus:: { SignableTransaction , TxEip1559 , TxEnvelope } ,
5+ primitives:: { Address , B256 , TxKind , U256 } ,
6+ rpc:: client:: BuiltInConnectionString ,
7+ signers:: { SignerSync , local:: PrivateKeySigner } ,
58} ;
69use eyre:: Result ;
710use init4_bin_base:: {
@@ -11,13 +14,56 @@ use init4_bin_base::{
1114 perms:: OAuthConfig ,
1215 utils:: { calc:: SlotCalculator , provider:: ProviderConfig } ,
1316} ;
17+ use std:: env;
1418use std:: str:: FromStr ;
1519use trevm:: revm:: { context:: BlockEnv , context_interface:: block:: BlobExcessGasAndPrice } ;
1620
21+ /// Sets up a sepolia Flashbots-compatible builder config with test values
22+ pub fn setup_sepolia_config ( ) -> Result < BuilderConfig > {
23+ let config = BuilderConfig {
24+ host_chain_id : 11155111 , // Sepolia chain ID
25+ ru_chain_id : signet_constants:: pecorino:: RU_CHAIN_ID ,
26+ host_rpc : "https://ethereum-sepolia-rpc.publicnode.com"
27+ . parse :: < BuiltInConnectionString > ( )
28+ . map ( ProviderConfig :: new)
29+ . unwrap ( ) ,
30+ ru_rpc : "ws://rpc.pecorino.signet.sh"
31+ . parse :: < BuiltInConnectionString > ( )
32+ . unwrap ( )
33+ . try_into ( )
34+ . unwrap ( ) ,
35+ tx_broadcast_urls : vec ! [ "http://localhost:9000" . into( ) ] ,
36+ flashbots_endpoint : Some ( "https://relay-sepolia.flashbots.net:443" . parse ( ) . unwrap ( ) ) , // NB: Flashbots API default
37+ zenith_address : Address :: default ( ) ,
38+ quincey_url : "http://localhost:8080" . into ( ) ,
39+ sequencer_key : None ,
40+ builder_key : env:: var ( "SEPOLIA_ETH_PRIV_KEY" ) . expect ( "SEPOLIA_ETH_PRIV_KEY must be set" ) ,
41+ builder_port : 8080 ,
42+ builder_rewards_address : Address :: default ( ) ,
43+ rollup_block_gas_limit : 3_000_000_000 ,
44+ tx_pool_url : "http://localhost:9000/" . parse ( ) . unwrap ( ) ,
45+ oauth : OAuthConfig {
46+ oauth_client_id : "some_client_id" . into ( ) ,
47+ oauth_client_secret : "some_client_secret" . into ( ) ,
48+ oauth_authenticate_url : "http://localhost:8080" . parse ( ) . unwrap ( ) ,
49+ oauth_token_url : "http://localhost:8080" . parse ( ) . unwrap ( ) ,
50+ oauth_token_refresh_interval : 300 , // 5 minutes
51+ } ,
52+ builder_helper_address : Address :: default ( ) ,
53+ concurrency_limit : None , // NB: Defaults to available parallelism
54+ slot_calculator : SlotCalculator :: new (
55+ 1740681556 , // pecorino start timestamp as sane default
56+ 0 , 1 ,
57+ ) ,
58+ } ;
59+ Ok ( config)
60+ }
61+
1762/// Sets up a block builder with test values
1863pub fn setup_test_config ( ) -> Result < BuilderConfig > {
1964 let config = BuilderConfig {
20- host_chain_id : signet_constants:: pecorino:: HOST_CHAIN_ID ,
65+ // host_chain_id: signet_constants::pecorino::HOST_CHAIN_ID,
66+ host_chain_id : 11155111 , // Sepolia chain ID
2167 ru_chain_id : signet_constants:: pecorino:: RU_CHAIN_ID ,
2268 host_rpc : "ws://host-rpc.pecorino.signet.sh"
2369 . parse :: < BuiltInConnectionString > ( )
@@ -30,12 +76,14 @@ pub fn setup_test_config() -> Result<BuilderConfig> {
3076 . unwrap ( ) ,
3177 tx_broadcast_urls : vec ! [ "http://localhost:9000" . into( ) ] ,
3278 flashbots_endpoint : Some ( "https://relay-sepolia.flashbots.net:443" . parse ( ) . unwrap ( ) ) , // NB: Flashbots API default
33- // flashbots_endpoint: Some("https://relay.flashbots.net:443".parse().unwrap()), // NB: Flashbots API default
3479 zenith_address : Address :: default ( ) ,
3580 quincey_url : "http://localhost:8080" . into ( ) ,
36- builder_port : 8080 ,
3781 sequencer_key : None ,
38- builder_key : PrivateKeySigner :: random ( ) . to_bytes ( ) . to_string ( ) ,
82+ builder_key : env:: var ( "SEPOLIA_ETH_PRIV_KEY" ) . unwrap_or_else ( |_| {
83+ dbg ! ( "USING RANDOM BUILDER KEY, set SEPOLIA_ETH_PRIV_KEY to override" ) ;
84+ PrivateKeySigner :: random ( ) . to_bytes ( ) . to_string ( )
85+ } ) ,
86+ builder_port : 8080 ,
3987 builder_rewards_address : Address :: default ( ) ,
4088 rollup_block_gas_limit : 3_000_000_000 ,
4189 tx_pool_url : "http://localhost:9000/" . parse ( ) . unwrap ( ) ,
@@ -64,9 +112,9 @@ pub fn new_signed_tx(
64112 mpfpg : u128 ,
65113) -> Result < TxEnvelope > {
66114 let tx = TxEip1559 {
67- chain_id : signet_constants :: pecorino :: RU_CHAIN_ID ,
115+ chain_id : 11155111 ,
68116 nonce,
69- max_fee_per_gas : 50_000 ,
117+ max_fee_per_gas : 10_000_000 ,
70118 max_priority_fee_per_gas : mpfpg,
71119 to : TxKind :: Call ( Address :: from_str ( "0x0000000000000000000000000000000000000000" ) . unwrap ( ) ) ,
72120 value,
0 commit comments