Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fri-prover): In witness - panic if protocol version is not available #192

Merged
merged 1 commit into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions prover/witness_generator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,11 @@ async fn main() -> anyhow::Result<()> {
let started_at = Instant::now();
let use_push_gateway = opt.batch_size.is_some();

let store_factory = ObjectStoreFactory::prover_from_env()
.context("ObjectStoreFactor::prover_from_env()")?;
let config = FriWitnessGeneratorConfig::from_env()
.context("FriWitnessGeneratorConfig::from_env()")?;
let prometheus_config = PrometheusConfig::from_env()
.context("PrometheusConfig::from_env()")?;
let store_factory =
ObjectStoreFactory::prover_from_env().context("ObjectStoreFactor::prover_from_env()")?;
let config =
FriWitnessGeneratorConfig::from_env().context("FriWitnessGeneratorConfig::from_env()")?;
let prometheus_config = PrometheusConfig::from_env().context("PrometheusConfig::from_env()")?;
let connection_pool = ConnectionPool::builder(DbVariant::Master)
.build()
.await
Expand All @@ -88,7 +87,9 @@ async fn main() -> anyhow::Result<()> {
let (stop_sender, stop_receiver) = watch::channel(false);
let vk_commitments = get_cached_commitments();
let protocol_versions = prover_connection_pool
.access_storage().await.unwrap()
.access_storage()
.await
.unwrap()
.fri_protocol_versions_dal()
.protocol_version_for(&vk_commitments)
.await;
Expand All @@ -100,6 +101,17 @@ async fn main() -> anyhow::Result<()> {
protocol_versions
);

// If batch_size is none, it means that the job is 'looping forever' (this is the usual setup in local network).
// At the same time, we're reading the protocol_version only once at startup - so if there is no protocol version
// read (this is often due to the fact, that the gateway was started too late, and it didn't put the updated protocol
// versions into the database) - then the job will simply 'hang forever' and not pick any tasks.
if opt.batch_size.is_none() && protocol_versions.is_empty() {
panic!(
"Could not find a protocol version for my commitments. Is gateway running? Maybe you started this job before gateway updated the database? Commitments: {:?}",
vk_commitments
);
}

let prometheus_config = if use_push_gateway {
PrometheusExporterConfig::push(
prometheus_config.gateway_endpoint(),
Expand All @@ -117,10 +129,10 @@ async fn main() -> anyhow::Result<()> {
true => Some(
ObjectStoreFactory::new(
ObjectStoreConfig::public_from_env()
.context("ObjectStoreConfig::public_from_env()")?
.context("ObjectStoreConfig::public_from_env()")?,
)
.create_store()
.await,
.create_store()
.await,
),
};
let generator = BasicWitnessGenerator::new(
Expand Down