Skip to content

Commit 6160bc0

Browse files
committed
wip
1 parent 3552307 commit 6160bc0

File tree

7 files changed

+68
-180
lines changed

7 files changed

+68
-180
lines changed

.tool-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
scarb 2.15.0
22
katana 1.7.0
3-
vrf 0.3.0
3+
vrf 0.3.1
44
paymaster 0.2.3

crates/cartridge/src/vrf/sidecar.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
12
use std::path::{Path, PathBuf};
23
use std::process::Stdio;
34
use std::time::{Duration, Instant};
@@ -7,6 +8,9 @@ use katana_primitives::{ContractAddress, Felt};
78
use tokio::process::{Child, Command};
89
use tokio::time::sleep;
910
use tracing::{debug, info, warn};
11+
use url::Url;
12+
13+
use super::client::VrfClient;
1014

1115
const LOG_TARGET: &str = "katana::cartridge::vrf::sidecar";
1216

@@ -78,11 +82,15 @@ impl VrfService {
7882
.kill_on_drop(true);
7983

8084
let process = command.spawn().map_err(Error::Spawn)?;
85+
let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::LOCALHOST), VRF_SERVER_PORT);
86+
87+
let url = Url::parse(&format!("http://{addr}")).expect("valid url");
88+
let client = VrfClient::new(url);
89+
wait_for_http_ok(&client, "vrf info", SIDECAR_TIMEOUT).await?;
8190

82-
let url = format!("http://127.0.0.1:{VRF_SERVER_PORT}/info",);
83-
wait_for_http_ok(&url, "vrf info", SIDECAR_TIMEOUT).await?;
91+
info!(%addr, "VRF service started.");
8492

85-
Ok(VrfServiceProcess { process, inner: self })
93+
Ok(VrfServiceProcess { process, addr, inner: self })
8694
}
8795
}
8896

@@ -91,9 +99,15 @@ impl VrfService {
9199
pub struct VrfServiceProcess {
92100
process: Child,
93101
inner: VrfService,
102+
addr: SocketAddr,
94103
}
95104

96105
impl VrfServiceProcess {
106+
/// Get the address of the VRF service.
107+
pub fn addr(&self) -> &SocketAddr {
108+
&self.addr
109+
}
110+
97111
pub fn process(&mut self) -> &mut Child {
98112
&mut self.process
99113
}
@@ -128,20 +142,16 @@ pub fn resolve_executable(path: &Path) -> Result<PathBuf> {
128142
Err(Error::BinaryNotInPath(path.to_path_buf()))
129143
}
130144

131-
/// Wait for an HTTP endpoint to return a successful response.
132-
pub async fn wait_for_http_ok(url: &str, name: &str, timeout: Duration) -> Result<()> {
133-
let client = reqwest::Client::new();
145+
/// Wait for the VRF sidecar to become ready by polling its `/info` endpoint.
146+
pub async fn wait_for_http_ok(client: &VrfClient, name: &str, timeout: Duration) -> Result<()> {
134147
let start = Instant::now();
135148

136149
loop {
137-
match client.get(url).send().await {
138-
Ok(resp) if resp.status().is_success() => {
150+
match client.info().await {
151+
Ok(_) => {
139152
info!(target: LOG_TARGET, %name, "sidecar ready");
140153
return Ok(());
141154
}
142-
Ok(resp) => {
143-
debug!(target: LOG_TARGET, %name, status = %resp.status(), "waiting for sidecar");
144-
}
145155
Err(err) => {
146156
debug!(target: LOG_TARGET, %name, error = %err, "waiting for sidecar");
147157
}

crates/cli/src/args.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,6 @@ impl SequencerNodeArgs {
416416
katana_slot_controller::add_vrf_provider_class(&mut chain_spec.genesis);
417417
}
418418

419-
#[cfg(feature = "paymaster")]
420-
if self.paymaster.enabled {
421-
katana_slot_controller::add_avnu_forwarder_class(&mut chain_spec.genesis);
422-
}
423-
424419
#[cfg(feature = "vrf")]
425420
if self.cartridge.vrf.enabled {
426421
katana_slot_controller::add_vrf_account_class(&mut chain_spec.genesis);

0 commit comments

Comments
 (0)