-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #292 from chainbound/nico/feat/sidecar-delegations
feat(sidecar): load delegations on startup and send them upon registration
- Loading branch information
Showing
32 changed files
with
739 additions
and
470 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# ports | ||
port = 8000 | ||
metrics_port = 3300 | ||
|
||
# node urls | ||
execution_api_url = "http://localhost:8545" | ||
beacon_api_url = "http://localhost:5052" | ||
engine_api_url = "http://localhost:8551" | ||
|
||
# constraints options | ||
constraints_url = "http://localhost:3030" | ||
constraints_proxy_port = 18551 | ||
|
||
# chain options | ||
chain = "kurtosis" | ||
slot_time = 2 | ||
|
||
# signing options | ||
private_key = "0x359c156600e1f5715a58c9e09f17c8d04e7ee3a9f88b39f6e489ffca0148fabe" | ||
delegations_path = "./delegations.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use tokio::sync::{mpsc, oneshot}; | ||
use tracing::error; | ||
|
||
use crate::primitives::{FetchPayloadRequest, PayloadAndBid}; | ||
|
||
/// A local payload fetcher that sends requests to a channel | ||
/// and waits for a response on a oneshot channel. | ||
#[derive(Debug, Clone)] | ||
pub struct LocalPayloadFetcher { | ||
tx: mpsc::Sender<FetchPayloadRequest>, | ||
} | ||
|
||
impl LocalPayloadFetcher { | ||
/// Create a new `LocalPayloadFetcher` with the given channel to send fetch requests. | ||
pub fn new(tx: mpsc::Sender<FetchPayloadRequest>) -> Self { | ||
Self { tx } | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl PayloadFetcher for LocalPayloadFetcher { | ||
async fn fetch_payload(&self, slot: u64) -> Option<PayloadAndBid> { | ||
let (response_tx, response_rx) = oneshot::channel(); | ||
|
||
let fetch_params = FetchPayloadRequest { response_tx, slot }; | ||
self.tx.send(fetch_params).await.ok()?; | ||
|
||
match response_rx.await { | ||
Ok(res) => res, | ||
Err(e) => { | ||
error!(err = ?e, "Failed to fetch payload"); | ||
None | ||
} | ||
} | ||
} | ||
} | ||
|
||
/// Interface for fetching payloads for the builder. | ||
#[async_trait::async_trait] | ||
pub trait PayloadFetcher { | ||
/// Fetch a payload for the given slot. | ||
async fn fetch_payload(&self, slot: u64) -> Option<PayloadAndBid>; | ||
} | ||
|
||
/// A payload fetcher that does nothing, used for testing. | ||
#[derive(Debug)] | ||
#[cfg(test)] | ||
pub struct NoopPayloadFetcher; | ||
|
||
#[cfg(test)] | ||
#[async_trait::async_trait] | ||
impl PayloadFetcher for NoopPayloadFetcher { | ||
async fn fetch_payload(&self, slot: u64) -> Option<PayloadAndBid> { | ||
tracing::info!(slot, "Fetch payload called"); | ||
None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.