Skip to content

Commit

Permalink
node-support: bootloader, docker: release: build & invoke event expor…
Browse files Browse the repository at this point in the history
…t sidecar in bootloader
  • Loading branch information
akirillo committed Dec 12, 2024
1 parent c61118c commit ea0ae46
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 10 deletions.
7 changes: 6 additions & 1 deletion docker/release/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ ARG CARGO_FEATURES="default"
# Build only the dependencies to cache them in this layer
RUN cargo chef cook --release --recipe-path recipe.json --features "$CARGO_FEATURES"

# Build the bootloader
COPY . .

# Build the bootloader
RUN cargo build --release --package bootloader

# Build the snapshot sidecar
RUN cargo build --release --package snapshot-sidecar

# Build the event export sidecar
RUN cargo build --release --package event-export-sidecar

# Build the relayer
RUN cargo build --release --bin renegade-relayer --features "$CARGO_FEATURES"

Expand All @@ -58,6 +62,7 @@ RUN apt-get update && \
# Copy the binaries from the build stage
COPY --from=builder /build/target/release/bootloader /bin/bootloader
COPY --from=builder /build/target/release/snapshot-sidecar /bin/snapshot-sidecar
COPY --from=builder /build/target/release/event-export-sidecar /bin/event-export-sidecar
COPY --from=builder /build/target/release/renegade-relayer /bin/renegade-relayer

# Set the bootloader as the entrypoint
Expand Down
40 changes: 32 additions & 8 deletions node-support/bootloader/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ const ENV_ADMIN_KEY: &str = "ADMIN_API_KEY";
const ENV_FUNDS_MANAGER_URL: &str = "FUNDS_MANAGER_URL";
/// The funds manager api key
const ENV_FUNDS_MANAGER_KEY: &str = "FUNDS_MANAGER_KEY";
/// The historical state engine URL
const ENV_HSE_URL: &str = "HSE_URL";
/// The historical state engine auth key
const ENV_HSE_KEY: &str = "HSE_KEY";

// --- Constants --- //

Expand Down Expand Up @@ -82,7 +86,9 @@ const WHITELIST_PATH: &str = "/whitelist.json";
const DEFAULT_AWS_REGION: &str = "us-east-2";

/// The location of the snapshot sidecar binary
const SIDECAR_BIN: &str = "/bin/snapshot-sidecar";
const SNAPSHOT_SIDECAR_BIN: &str = "/bin/snapshot-sidecar";
/// The location of the event export sidecar binary
const EVENT_EXPORT_SIDECAR_BIN: &str = "/bin/event-export-sidecar";
/// The location of the relayer binary
const RELAYER_BIN: &str = "/bin/renegade-relayer";

Expand All @@ -101,24 +107,42 @@ async fn main() -> Result<(), String> {
modify_config(whitelist).await?;
download_snapshot(&s3_client).await?;

// Start both the snapshot sidecar and the relayer
// Start the snapshot sidecar, event export sidecar, and the relayer
let bucket = read_env_var::<String>(ENV_SNAP_BUCKET)?;
let mut sidecar = Command::new(SIDECAR_BIN)
let mut snapshot_sidecar = Command::new(SNAPSHOT_SIDECAR_BIN)
.args(["--config-path", CONFIG_PATH])
.args(["--bucket", &bucket])
.spawn()
.expect("Failed to start snapshot sidecar process");

let hse_url = read_env_var::<String>(ENV_HSE_URL)?;
let hse_key = read_env_var::<String>(ENV_HSE_KEY)?;
let mut event_export_sidecar = Command::new(EVENT_EXPORT_SIDECAR_BIN)
.args(["--config-path", CONFIG_PATH])
.args(["--hse-url", &hse_url])
.args(["--hse-key", &hse_key])
.spawn()
.expect("Failed to start event export sidecar process");

let mut relayer = Command::new(RELAYER_BIN)
.args(["--config-file", CONFIG_PATH])
.spawn()
.expect("Failed to start relayer process");

let sidecar_result = sidecar.wait();
let snapshot_sidecar_result = snapshot_sidecar.wait();
let event_export_sidecar_result = event_export_sidecar.wait();
let relayer_result = relayer.wait();
let (sidecar_result, relayer_result) = tokio::try_join!(sidecar_result, relayer_result)
.expect("Either snapshot sidecar or relayer process encountered an error");

error!("sidecar exited with: {:?}", sidecar_result);
let (snapshot_sidecar_result, event_export_sidecar_result, relayer_result) = tokio::try_join!(
snapshot_sidecar_result,
event_export_sidecar_result,
relayer_result
)
.expect(
"Either snapshot sidecar, event export sidecar, or relayer process encountered an error",
);

error!("snapshot sidecar exited with: {:?}", snapshot_sidecar_result);
error!("event export sidecar exited with: {:?}", event_export_sidecar_result);
error!("relayer exited with: {:?}", relayer_result);
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion node-support/event-export-sidecar/src/hse_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl HseClient {
/// Submit an event to the historical state engine
pub async fn submit_event(&self, event: &RelayerEvent) -> Result<(), Error> {
send_authenticated_request(
&format!("{}{}", self.base_url, EVENT_SUBMISSION_PATH),
&self.base_url,
EVENT_SUBMISSION_PATH,
Method::POST,
event,
Expand Down
1 change: 1 addition & 0 deletions workers/job-types/src/event_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ pub struct MatchEvent {

/// A convenience type encapsulating the event data for a single party in a
/// match
#[derive(Clone, Copy)]
pub struct PartyMatchData {
/// The ID of the party's wallet
pub wallet_id: WalletIdentifier,
Expand Down

0 comments on commit ea0ae46

Please sign in to comment.