diff --git a/.env b/.env index 8120b4c41..7d71dd5b0 100644 --- a/.env +++ b/.env @@ -102,6 +102,8 @@ ESPRESSO_BUILDER_PRIVATE_STAKING_KEY=BLS_SIGNING_KEY~tI9He_sCnEbfEajycUXz9Scfy6o ESPRESSO_BUILDER_PRIVATE_STATE_KEY=SCHNORR_SIGNING_KEY~IftHINvgzqcd9agX13HHY3Uhz8vsH46i8soKgV7ZUQV- ESPRESSO_BUILDER_CHANNEL_CAPACITY=1024 ESPRESSO_BUILDER_BOOTSTRAPPED_VIEW=0 +ESPRESSO_BUILDER_WEBSERVER_RESPONSE_TIMEOUT_DURATION=1s +ESPRESSO_BUILDER_BUFFER_VIEW_NUM_COUNT=15 # Load generator ESPRESSO_SUBMIT_TRANSACTIONS_DELAY=1s diff --git a/Cargo.lock b/Cargo.lock index 4b1b5eb11..022c7b665 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1509,36 +1509,13 @@ dependencies = [ "libc", ] -[[package]] -name = "cdn-broker" -version = "0.1.0" -source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.1.25#a506712f553b4800ce3a36e62341c839153aeab3" -dependencies = [ - "async-std", - "cdn-proto 0.1.0 (git+https://github.com/EspressoSystems/Push-CDN?tag=0.1.25)", - "clap", - "dashmap", - "derivative", - "derive_builder", - "jf-primitives 0.4.0-pre.0", - "lazy_static", - "local-ip-address", - "parking_lot", - "prometheus", - "rand 0.8.5", - "rkyv", - "tokio", - "tracing", - "tracing-subscriber 0.3.18", -] - [[package]] name = "cdn-broker" version = "0.1.0" source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.2.1#3a80e1839770062a2a6dc42914463e6cff1c9045" dependencies = [ "async-std", - "cdn-proto 0.1.0 (git+https://github.com/EspressoSystems/Push-CDN?tag=0.2.1)", + "cdn-proto", "clap", "dashmap", "derivative", @@ -1557,12 +1534,11 @@ dependencies = [ [[package]] name = "cdn-client" version = "0.1.0" -source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.1.25#a506712f553b4800ce3a36e62341c839153aeab3" +source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.2.1#3a80e1839770062a2a6dc42914463e6cff1c9045" dependencies = [ "async-std", - "cdn-proto 0.1.0 (git+https://github.com/EspressoSystems/Push-CDN?tag=0.1.25)", + "cdn-proto", "clap", - "derive_builder", "jf-primitives 0.4.0-pre.0", "rand 0.8.5", "tokio", @@ -1570,28 +1546,13 @@ dependencies = [ "tracing-subscriber 0.3.18", ] -[[package]] -name = "cdn-marshal" -version = "0.1.0" -source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.1.25#a506712f553b4800ce3a36e62341c839153aeab3" -dependencies = [ - "async-std", - "cdn-proto 0.1.0 (git+https://github.com/EspressoSystems/Push-CDN?tag=0.1.25)", - "clap", - "derive_builder", - "jf-primitives 0.4.0-pre.0", - "tokio", - "tracing", - "tracing-subscriber 0.3.18", -] - [[package]] name = "cdn-marshal" version = "0.1.0" source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.2.1#3a80e1839770062a2a6dc42914463e6cff1c9045" dependencies = [ "async-std", - "cdn-proto 0.1.0 (git+https://github.com/EspressoSystems/Push-CDN?tag=0.2.1)", + "cdn-proto", "clap", "jf-primitives 0.4.0-pre.0", "tokio", @@ -1599,38 +1560,6 @@ dependencies = [ "tracing-subscriber 0.3.18", ] -[[package]] -name = "cdn-proto" -version = "0.1.0" -source = "git+https://github.com/EspressoSystems/Push-CDN?tag=0.1.25#a506712f553b4800ce3a36e62341c839153aeab3" -dependencies = [ - "anyhow", - "ark-serialize", - "async-trait", - "capnp", - "derivative", - "jf-primitives 0.4.0-pre.0", - "kanal", - "lazy_static", - "mnemonic", - "mockall", - "parking_lot", - "pem 3.0.4", - "prometheus", - "quinn", - "rand 0.8.5", - "rcgen 0.12.1", - "redis", - "rkyv", - "rustls 0.21.10", - "sqlx", - "thiserror", - "tokio", - "tracing", - "url", - "warp", -] - [[package]] name = "cdn-proto" version = "0.1.0" @@ -4045,7 +3974,7 @@ dependencies = [ [[package]] name = "hotshot" version = "0.5.40" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.40#d0be8c828520f0f517d5336aa04690a68fea71bb" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.41#4f9c275421936c65c6943a305406aa4280f35a1c" dependencies = [ "anyhow", "async-broadcast", @@ -4056,9 +3985,9 @@ dependencies = [ "bimap", "bincode", "blake3", - "cdn-broker 0.1.0 (git+https://github.com/EspressoSystems/Push-CDN?tag=0.1.25)", + "cdn-broker", "cdn-client", - "cdn-marshal 0.1.0 (git+https://github.com/EspressoSystems/Push-CDN?tag=0.1.25)", + "cdn-marshal", "committable", "custom_debug 0.5.1", "dashmap", @@ -4090,7 +4019,7 @@ dependencies = [ [[package]] name = "hotshot-builder-api" version = "0.1.7" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.40#d0be8c828520f0f517d5336aa04690a68fea71bb" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.41#4f9c275421936c65c6943a305406aa4280f35a1c" dependencies = [ "async-trait", "clap", @@ -4108,8 +4037,8 @@ dependencies = [ [[package]] name = "hotshot-builder-core" -version = "0.1.7" -source = "git+https://github.com/EspressoSystems/hotshot-builder-core?tag=0.1.7#f9a23191973e63e616e27d9a2046e4a64cec8824" +version = "0.1.9" +source = "git+https://github.com/EspressoSystems/hotshot-builder-core?tag=0.1.9#fbe38808f8a97f968abce839cc1a4afaab29b067" dependencies = [ "async-broadcast", "async-compatibility-layer", @@ -4159,7 +4088,7 @@ dependencies = [ [[package]] name = "hotshot-events-service" version = "0.1.9" -source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?tag=0.1.9#5c55f7b1cb6a1926daa9abd7a31f2ccf3e097985" +source = "git+https://github.com/EspressoSystems/hotshot-events-service.git?tag=0.1.10#ecd750f36c8955871def4dfb66785585f59f1898" dependencies = [ "async-broadcast", "async-compatibility-layer", @@ -4184,7 +4113,7 @@ dependencies = [ [[package]] name = "hotshot-example-types" version = "0.5.40" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.40#d0be8c828520f0f517d5336aa04690a68fea71bb" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.41#4f9c275421936c65c6943a305406aa4280f35a1c" dependencies = [ "anyhow", "async-broadcast", @@ -4214,7 +4143,7 @@ dependencies = [ [[package]] name = "hotshot-macros" version = "0.5.40" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.40#d0be8c828520f0f517d5336aa04690a68fea71bb" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.41#4f9c275421936c65c6943a305406aa4280f35a1c" dependencies = [ "derive_builder", "proc-macro2", @@ -4225,7 +4154,7 @@ dependencies = [ [[package]] name = "hotshot-orchestrator" version = "0.5.40" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.40#d0be8c828520f0f517d5336aa04690a68fea71bb" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.41#4f9c275421936c65c6943a305406aa4280f35a1c" dependencies = [ "anyhow", "async-compatibility-layer", @@ -4254,7 +4183,7 @@ dependencies = [ [[package]] name = "hotshot-query-service" version = "0.1.9" -source = "git+https://github.com/EspressoSystems/hotshot-query-service?tag=0.1.9#ccc81549e8ad5139bce95371cf1ad2bf20e19ed8" +source = "git+https://github.com/EspressoSystems/hotshot-query-service?tag=0.1.10#2eb1faa7f9a200a0dbb5635be79971bda110c5fc" dependencies = [ "anyhow", "ark-serialize", @@ -4308,7 +4237,7 @@ dependencies = [ [[package]] name = "hotshot-stake-table" version = "0.5.40" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.40#d0be8c828520f0f517d5336aa04690a68fea71bb" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.41#4f9c275421936c65c6943a305406aa4280f35a1c" dependencies = [ "ark-bn254", "ark-ed-on-bn254", @@ -4375,7 +4304,7 @@ dependencies = [ [[package]] name = "hotshot-task" version = "0.5.40" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.40#d0be8c828520f0f517d5336aa04690a68fea71bb" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.41#4f9c275421936c65c6943a305406aa4280f35a1c" dependencies = [ "async-broadcast", "async-compatibility-layer", @@ -4388,7 +4317,7 @@ dependencies = [ [[package]] name = "hotshot-task-impls" version = "0.5.40" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.40#d0be8c828520f0f517d5336aa04690a68fea71bb" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.41#4f9c275421936c65c6943a305406aa4280f35a1c" dependencies = [ "anyhow", "async-broadcast", @@ -4421,7 +4350,7 @@ dependencies = [ [[package]] name = "hotshot-testing" version = "0.5.40" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.40#d0be8c828520f0f517d5336aa04690a68fea71bb" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.41#4f9c275421936c65c6943a305406aa4280f35a1c" dependencies = [ "async-broadcast", "async-compatibility-layer", @@ -4460,7 +4389,7 @@ dependencies = [ [[package]] name = "hotshot-types" version = "0.1.11" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.40#d0be8c828520f0f517d5336aa04690a68fea71bb" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.41#4f9c275421936c65c6943a305406aa4280f35a1c" dependencies = [ "anyhow", "ark-bls12-381", @@ -4511,7 +4440,7 @@ dependencies = [ [[package]] name = "hotshot-web-server" version = "0.5.40" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.40#d0be8c828520f0f517d5336aa04690a68fea71bb" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.41#4f9c275421936c65c6943a305406aa4280f35a1c" dependencies = [ "async-compatibility-layer", "async-lock 2.8.0", @@ -5707,7 +5636,7 @@ dependencies = [ [[package]] name = "libp2p-networking" version = "0.5.40" -source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.40#d0be8c828520f0f517d5336aa04690a68fea71bb" +source = "git+https://github.com/EspressoSystems/hotshot?tag=0.5.41#4f9c275421936c65c6943a305406aa4280f35a1c" dependencies = [ "anyhow", "async-compatibility-layer", @@ -8561,8 +8490,8 @@ dependencies = [ "bincode", "blake3", "bytesize", - "cdn-broker 0.1.0 (git+https://github.com/EspressoSystems/Push-CDN?tag=0.2.1)", - "cdn-marshal 0.1.0 (git+https://github.com/EspressoSystems/Push-CDN?tag=0.2.1)", + "cdn-broker", + "cdn-marshal", "clap", "cld", "committable", diff --git a/Cargo.toml b/Cargo.toml index d242ed3f4..e0d295744 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,18 +47,18 @@ ethers = { version = "2.0", features = ["solc"] } futures = "0.3" # Hotshot imports -hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.40" } -hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.40" } -hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", tag = "0.1.7" } -hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.40" } -hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "0.1.9" } -hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.40" } +hotshot = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.41" } +hotshot-builder-api = { git = "https://github.com/EspressoSystems/HotShot.git", tag = "0.5.41" } +hotshot-builder-core = { git = "https://github.com/EspressoSystems/hotshot-builder-core", tag = "0.1.9" } +hotshot-orchestrator = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.41" } +hotshot-query-service = { git = "https://github.com/EspressoSystems/hotshot-query-service", tag = "0.1.10" } +hotshot-stake-table = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.41" } hotshot-state-prover = { version = "0.1.0", path = "hotshot-state-prover" } -hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.40" } -hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.40" } -hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.40" } -hotshot-web-server = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.40" } -hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.9" } +hotshot-task = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.41" } +hotshot-testing = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.41" } +hotshot-types = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.41" } +hotshot-web-server = { git = "https://github.com/EspressoSystems/hotshot", tag = "0.5.41" } +hotshot-events-service = { git = "https://github.com/EspressoSystems/hotshot-events-service.git", tag = "0.1.10" } # Push CDN imports cdn-broker = { git = "https://github.com/EspressoSystems/Push-CDN", features = [ diff --git a/builder/src/bin/permissioned-builder.rs b/builder/src/bin/permissioned-builder.rs index c768c92ec..47cff967e 100644 --- a/builder/src/bin/permissioned-builder.rs +++ b/builder/src/bin/permissioned-builder.rs @@ -133,24 +133,43 @@ pub struct PermissionedBuilderOptions { pub state_peers: Vec, /// Port to run the builder server on. - #[clap(short, long, env = "BUILDER_SERVER_PORT")] + #[clap(short, long, env = "ESPRESSO_BUILDER_SERVER_PORT")] pub port: u16, /// Port to run the builder server on. - #[clap(short, long, env = "BUILDER_ADDRESS")] + #[clap(short, long, env = "ESPRESSO_BUILDER_ADDRESS")] pub address: Address, /// Bootstrapping View number - #[clap(short, long, env = "BUILDER_BOOTSTRAPPED_VIEW")] + #[clap(short, long, env = "ESPRESSO_BUILDER_BOOTSTRAPPED_VIEW")] pub view_number: u64, /// BUILDER CHANNEL CAPACITY - #[clap(long, env = "BUILDER_CHANNEL_CAPACITY")] + #[clap(long, env = "ESPRESSO_BUILDER_CHANNEL_CAPACITY")] pub channel_capacity: NonZeroUsize, - /// Url a builder can use to stream hotshot events + /// Url a sequencer can use to stream hotshot events #[clap(long, env = "ESPRESSO_SEQUENCER_HOTSHOT_EVENTS_PROVIDER")] pub hotshot_events_streaming_server_url: Url, + + /// The amount of time a builder can wait before timing out a request to the API. + #[clap( + short, + long, + env = "ESPRESSO_BUILDER_WEBSERVER_RESPONSE_TIMEOUT_DURATION", + default_value = "1s", + value_parser = parse_duration + )] + pub max_api_timeout_duration: Duration, + + /// The number of views to buffer before a builder garbage collects its state + #[clap( + short, + long, + env = "ESPRESSO_BUILDER_BUFFER_VIEW_NUM_COUNT", + default_value = "15" + )] + pub buffer_view_num_count: usize, } #[derive(Clone, Debug, Snafu)] @@ -242,6 +261,10 @@ async fn main() -> anyhow::Result<()> { let bootstrapped_view = ViewNumber::new(opt.view_number); + let max_response_timeout = opt.max_api_timeout_duration; + + let buffer_view_num_count = opt.buffer_view_num_count; + // it will internally spawn the builder web server let ctx = init_node( network_params, @@ -254,6 +277,8 @@ async fn main() -> anyhow::Result<()> { opt.channel_capacity, sequencer_version, NoStorage, + max_response_timeout, + buffer_view_num_count, ) .await?; diff --git a/builder/src/bin/permissionless-builder.rs b/builder/src/bin/permissionless-builder.rs index e8675b56f..c1ef722ab 100644 --- a/builder/src/bin/permissionless-builder.rs +++ b/builder/src/bin/permissionless-builder.rs @@ -17,10 +17,6 @@ use url::Url; #[derive(Parser, Clone, Debug)] pub struct NonPermissionedBuilderOptions { - /// Unique identifier for this instance of the sequencer network. - #[clap(long, env = "ESPRESSO_SEQUENCER_CHAIN_ID", default_value = "0")] - pub chain_id: u16, - /// URL of hotshot events API running on Espresso Sequencer DA committee node /// The builder will subscribe to this server to receive hotshot events #[clap( @@ -28,27 +24,7 @@ pub struct NonPermissionedBuilderOptions { env = "ESPRESSO_SEQUENCER_HOTSHOT_EVENT_STREAMING_API_URL", default_value = "http://localhost:8081" )] - pub sequencer_url: Url, - - /// URL of the Light Client State Relay Server - #[clap( - short, - long, - env = "ESPRESSO_STATE_RELAY_SERVER_URL", - default_value = "http://localhost:8083" - )] - pub state_relay_server_url: Url, - - /// The amount of time to wait between each request to the HotShot - /// consensus or DA web servers during polling. - #[clap( - short, - long, - env = "ESPRESSO_SEQUENCER_WEBSERVER_POLL_INTERVAL", - default_value = "100ms", - value_parser = parse_duration - )] - pub webserver_poll_interval: Duration, + pub hotshot_event_streaming_url: Url, /// Path to file containing private keys. /// @@ -110,6 +86,25 @@ pub struct NonPermissionedBuilderOptions { /// BUILDER CHANNEL CAPACITY #[clap(short, long, env = "ESPRESSO_BUILDER_CHANNEL_CAPACITY")] pub channel_capacity: NonZeroUsize, + + /// The amount of time a builder can wait before timing out a request to the API. + #[clap( + short, + long, + env = "ESPRESSO_BUILDER_WEBSERVER_RESPONSE_TIMEOUT_DURATION", + default_value = "1s", + value_parser = parse_duration + )] + pub max_api_timeout_duration: Duration, + + /// The number of views to buffer before a builder garbage collects its state + #[clap( + short, + long, + env = "ESPRESSO_BUILDER_BUFFER_VIEW_NUM_COUNT", + default_value = "15" + )] + pub buffer_view_num_count: usize, } #[derive(Clone, Debug, Snafu)] @@ -181,13 +176,19 @@ async fn main() -> anyhow::Result<()> { ) .unwrap(); + let api_response_timeout_duration = opt.max_api_timeout_duration; + + let buffer_view_num_count = opt.buffer_view_num_count; + let _builder_config = BuilderConfig::init( builder_key_pair, bootstrapped_view, opt.channel_capacity, instance_state, - opt.sequencer_url, + opt.hotshot_event_streaming_url, builder_server_url, + api_response_timeout_duration, + buffer_view_num_count, ) .await; diff --git a/builder/src/lib.rs b/builder/src/lib.rs index d487dff73..b81a71784 100644 --- a/builder/src/lib.rs +++ b/builder/src/lib.rs @@ -41,7 +41,7 @@ use async_compatibility_layer::art::{async_sleep, async_spawn}; use hotshot_builder_api::builder::{ BuildError, Error as BuilderApiError, Options as HotshotBuilderApiOptions, }; -use hotshot_builder_core::service::GlobalState; +use hotshot_builder_core::service::{GlobalState, ProxyGlobalState}; use jf_primitives::{ merkle_tree::{namespaced_merkle_tree::NamespacedMerkleTreeScheme, MerkleTreeScheme}, signatures::bls_over_bn254::VerKey, @@ -69,10 +69,10 @@ pub mod non_permissioned; pub mod permissioned; // It runs the api service for the builder -pub fn run_builder_api_service(url: Url, source: Arc>>) { +pub fn run_builder_api_service(url: Url, source: Arc>>) { // it is to serve hotshot let builder_api = hotshot_builder_api::builder::define_api::< - Arc>>, + Arc>>, SeqTypes, Version01, >(&HotshotBuilderApiOptions::default()) @@ -80,13 +80,14 @@ pub fn run_builder_api_service(url: Url, source: Arc>>, + Arc>>, SeqTypes, Version01, >(&HotshotBuilderApiOptions::default()) .expect("Failed to construct the builder API for private mempool txns"); - let mut app: App>>, BuilderApiError> = App::with_state(source); + let mut app: App>>, BuilderApiError> = + App::with_state(source); app.register_module("block_info", builder_api) .expect("Failed to register the builder API"); @@ -571,6 +572,8 @@ pub mod testing { node_state, hotshot_events_streaming_api_url, hotshot_builder_api_url, + Duration::from_millis(2000), + 15, ) .await .unwrap(); @@ -637,6 +640,8 @@ pub mod testing { channel_capacity, node_state, hotshot_builder_api_url, + Duration::from_millis(2000), + 15, ) .await .unwrap(); diff --git a/builder/src/non_permissioned.rs b/builder/src/non_permissioned.rs index 163148757..ea1024809 100644 --- a/builder/src/non_permissioned.rs +++ b/builder/src/non_permissioned.rs @@ -20,7 +20,7 @@ use hotshot_builder_core::{ BuildBlockInfo, BuilderProgress, BuilderState, BuiltFromProposedBlock, MessageType, ResponseMessage, }, - service::{run_non_permissioned_standalone_builder_service, GlobalState}, + service::{run_non_permissioned_standalone_builder_service, GlobalState, ProxyGlobalState}, }; use hotshot_types::{ @@ -80,6 +80,7 @@ pub fn build_instance_state( } impl BuilderConfig { + #[allow(clippy::too_many_arguments)] pub async fn init( builder_key_pair: EthKeyPair, bootstrapped_view: ViewNumber, @@ -87,6 +88,8 @@ impl BuilderConfig { instance_state: NodeState, hotshot_events_api_url: Url, hotshot_builder_apis_url: Url, + max_api_timeout_duration: Duration, + buffered_view_num_count: usize, ) -> anyhow::Result { // tx channel let (tx_sender, tx_receiver) = broadcast::>(channel_capacity.get()); @@ -120,12 +123,12 @@ impl BuilderConfig { // create the global state let global_state: GlobalState = GlobalState::::new( - (builder_key_pair.fee_account(), builder_key_pair), req_sender, res_receiver, tx_sender.clone(), instance_state.clone(), vid_commitment, + bootstrapped_view, ); let global_state = Arc::new(RwLock::new(global_state)); @@ -148,6 +151,7 @@ impl BuilderConfig { res_sender, NonZeroUsize::new(1).unwrap(), bootstrapped_view, + buffered_view_num_count, ); // spawn the builder event loop @@ -155,8 +159,16 @@ impl BuilderConfig { builder_state.event_loop(); }); + // create the proxy global state it will server the builder apis + let proxy_global_state = ProxyGlobalState::new( + global_state.clone(), + (builder_key_pair.fee_account(), builder_key_pair), + max_api_timeout_duration, + ); + + let proxy_global_api_state = Arc::new(RwLock::new(proxy_global_state)); // start the hotshot api service - run_builder_api_service(hotshot_builder_apis_url.clone(), global_state.clone()); + run_builder_api_service(hotshot_builder_apis_url.clone(), proxy_global_api_state); // create a client for it // Start Client for the event streaming api @@ -321,6 +333,9 @@ mod test { ) .expect("Claim block signing failed"); + // sleep and wait for builder service to startup + async_sleep(Duration::from_millis(3000)).await; + // test getting available blocks let available_block_info = match builder_client .get::>>(&format!( diff --git a/builder/src/permissioned.rs b/builder/src/permissioned.rs index a8e467383..12b64b9d1 100644 --- a/builder/src/permissioned.rs +++ b/builder/src/permissioned.rs @@ -59,7 +59,7 @@ use hotshot_builder_core::{ }, service::{ run_non_permissioned_standalone_builder_service, - run_permissioned_standalone_builder_service, GlobalState, + run_permissioned_standalone_builder_service, GlobalState, ProxyGlobalState, }, }; use hotshot_state_prover; @@ -140,6 +140,8 @@ pub async fn init_node anyhow::Result> { // Orchestrator client let validator_args = ValidatorArgs { @@ -284,6 +286,8 @@ pub async fn init_node anyhow::Result { // tx channel let (tx_sender, tx_receiver) = broadcast::>(channel_capacity.get()); @@ -412,12 +418,12 @@ impl = GlobalState::::new( - (eth_key_pair.fee_account(), eth_key_pair), req_sender, res_receiver, tx_sender.clone(), instance_state.clone(), vid_commitment, + bootstrapped_view, ); let global_state = Arc::new(RwLock::new(global_state)); @@ -440,6 +446,7 @@ impl>>(&format!( "block_info/availableblocks/{parent_commitment}/{hotshot_client_pub_key}/{encoded_signature}" diff --git a/docker-compose.yaml b/docker-compose.yaml index 2e62038c8..4170c9b65 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -427,6 +427,8 @@ services: - ESPRESSO_BUILDER_SERVER_PORT - ESPRESSO_BUILDER_CHANNEL_CAPACITY - ESPRESSO_BUILDER_BOOTSTRAPPED_VIEW + - ESPRESSO_BUILDER_WEBSERVER_RESPONSE_TIMEOUT_DURATION + - ESPRESSO_BUILDER_BUFFER_VIEW_NUM_COUNT - RUST_LOG - RUST_LOG_FORMAT - ASYNC_STD_THREAD_COUNT