Skip to content

Commit 878c2b0

Browse files
authored
Move solver API paths to configuration (#1881)
Co-authored-by: tbro <[email protected]>
1 parent df26652 commit 878c2b0

File tree

5 files changed

+39
-14
lines changed

5 files changed

+39
-14
lines changed

builder/src/permissioned.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,7 @@ pub async fn init_hotshot<
391391
ConsensusMetricsValue::new(metrics),
392392
da_storage,
393393
MarketplaceConfig {
394-
auction_results_provider: Arc::new(SolverAuctionResultsProvider(
395-
Url::from_str("https://some.solver").unwrap(),
396-
)),
394+
auction_results_provider: Arc::new(SolverAuctionResultsProvider::default()),
397395
fallback_builder_url: Url::from_str("https://some.builder").unwrap(),
398396
},
399397
)

sequencer/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -762,9 +762,7 @@ pub mod testing {
762762
None, // The public API URL
763763
bind_version,
764764
MarketplaceConfig::<SeqTypes, Node<network::Memory, P::Persistence>> {
765-
auction_results_provider: Arc::new(SolverAuctionResultsProvider(
766-
Url::from_str("https://some.solver").unwrap(),
767-
)),
765+
auction_results_provider: Arc::new(SolverAuctionResultsProvider::default()),
768766
fallback_builder_url: Url::from_str("https://some.builder").unwrap(),
769767
},
770768
)

sequencer/src/main.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,11 @@ where
9999
};
100100

101101
let marketplace_config = MarketplaceConfig {
102-
auction_results_provider: Arc::new(SolverAuctionResultsProvider(
103-
opt.auction_results_solver_url,
104-
)),
102+
auction_results_provider: Arc::new(SolverAuctionResultsProvider {
103+
url: opt.auction_results_solver_url,
104+
marketplace_path: opt.marketplace_solver_path,
105+
results_path: opt.auction_results_path,
106+
}),
105107
fallback_builder_url: opt.fallback_builder_url,
106108
};
107109

sequencer/src/options.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,20 @@ pub struct Options {
112112
)]
113113
#[derivative(Debug(format_with = "Display::fmt"))]
114114
pub auction_results_solver_url: Url,
115-
115+
#[clap(
116+
long,
117+
env = "ESPRESSO_MARKETPLACE_SOLVER_PATH",
118+
default_value = "marketplace-solver/"
119+
)]
120+
/// API path of marketplace-solver
121+
pub marketplace_solver_path: String,
122+
#[clap(
123+
long,
124+
env = "ESPRESSO_AUCTION_RESULTS_PATH",
125+
default_value = "auction_results/"
126+
)]
127+
/// API path of marketplace-solver auction results
128+
pub auction_results_path: String,
116129
/// URL of generic builder
117130
#[clap(
118131
long,

types/src/v0/impls/auction.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,21 @@ type SurfClient = surf_disco::Client<ServerError, <SequencerVersions as Versions
283283

284284
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
285285
/// Auction Results provider holding the Url of the solver in order to fetch auction results.
286-
pub struct SolverAuctionResultsProvider(pub Url);
286+
pub struct SolverAuctionResultsProvider {
287+
pub url: Url,
288+
pub marketplace_path: String,
289+
pub results_path: String,
290+
}
291+
292+
impl Default for SolverAuctionResultsProvider {
293+
fn default() -> Self {
294+
Self {
295+
url: Url::from_str("http://localhost:25000").unwrap(),
296+
marketplace_path: "marketplace-solver/".into(),
297+
results_path: "auction_results/".into(),
298+
}
299+
}
300+
}
287301

288302
#[async_trait]
289303
impl<TYPES: NodeType> AuctionResultsProvider<TYPES> for SolverAuctionResultsProvider {
@@ -293,11 +307,11 @@ impl<TYPES: NodeType> AuctionResultsProvider<TYPES> for SolverAuctionResultsProv
293307
view_number: TYPES::Time,
294308
) -> anyhow::Result<TYPES::AuctionResult> {
295309
let resp = SurfClient::new(
296-
self.0
297-
.join("marketplace-solver/")
310+
self.url
311+
.join(&self.marketplace_path)
298312
.context("Malformed solver URL")?,
299313
)
300-
.get::<TYPES::AuctionResult>(&format!("auction_results/{}", *view_number))
314+
.get::<TYPES::AuctionResult>(&format!("{}{}", self.results_path, *view_number))
301315
.send()
302316
.await?;
303317
Ok(resp)

0 commit comments

Comments
 (0)