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

fix: add mp2 version as a path to the download params URL #140

Merged
merged 8 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
fi
public-push:
name: Push Docker Images to Docker hub
if: contains('main holesky mainnet hack-merge-table v1_base 129/merge', github.ref_name) || startsWith(github.ref, 'refs/tags/')
if: contains('main holesky mainnet hack-merge-table v1_base 140/merge', github.ref_name) || startsWith(github.ref, 'refs/tags/')
runs-on: ${{needs.base.outputs.RUNNER}}
needs:
- build
Expand Down
58 changes: 40 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ resolver = "2"
members = ["lgn-auth", "lgn-messages", "lgn-provers", "lgn-worker"]

[workspace.dependencies]
groth16_framework_v1 = { git = "https://github.com/Lagrange-Labs/mapreduce-plonky2.git", rev = "v1.1.3", package = "groth16_framework" }
mp2_common = { git = "https://github.com/Lagrange-Labs/mapreduce-plonky2.git", rev = "v1.1.3" }
mp2_v1 = { git = "https://github.com/Lagrange-Labs/mapreduce-plonky2.git", rev = "v1.1.3" }
parsil = { git = "https://github.com/Lagrange-Labs/mapreduce-plonky2.git", rev = "v1.1.3" }
verifiable-db = { git = "https://github.com/Lagrange-Labs/mapreduce-plonky2.git", rev = "v1.1.3" }
groth16_framework_v1 = { git = "https://github.com/Lagrange-Labs/mapreduce-plonky2.git", rev = "1.2.1", package = "groth16_framework" }
mp2_common = { git = "https://github.com/Lagrange-Labs/mapreduce-plonky2.git", rev = "1.2.1" }
mp2_v1 = { git = "https://github.com/Lagrange-Labs/mapreduce-plonky2.git", rev = "1.2.1" }
parsil = { git = "https://github.com/Lagrange-Labs/mapreduce-plonky2.git", rev = "1.2.1" }
verifiable-db = { git = "https://github.com/Lagrange-Labs/mapreduce-plonky2.git", rev = "1.2.1" }

anyhow = { version = "1.0" }
bincode = { version = "1.0" }
Expand Down
3 changes: 3 additions & 0 deletions lgn-provers/src/params/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ use tracing::error;
use tracing::info;
use tracing::warn;

/// The filename of params checksum hashes
pub const PARAMS_CHECKSUM_FILENAME: &str = "public_params.hash";

pub struct ParamsLoader;

// Could make configurable but 3600 should be enough
Expand Down
23 changes: 19 additions & 4 deletions lgn-worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,30 @@ serde_json = { workspace = true }
checksums = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true, features = ["env-filter", "json"] }
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
rand = { workspace = true, default-features = false, features = [ "std", "std_rng", "getrandom", "min_const_gen" ] }
tokio = { workspace = true, features = ["rt-multi-thread", "macros"] }
rand = { workspace = true, default-features = false, features = [
"std",
"std_rng",
"getrandom",
"min_const_gen",
] }
reqwest = { workspace = true, features = ["blocking"] }

# The ethers macro `abigen` needs to import ethers as a crate.
backtrace = { workspace = true }
clap = { workspace = true, features = ["derive", "env", "help", "std", "suggestions"] }
clap = { workspace = true, features = [
"derive",
"env",
"help",
"std",
"suggestions",
] }
config = { workspace = true, features = ["toml"] }
elliptic-curve = { workspace = true }
# The ethers macro `abigen` needs to import ethers as a crate.
ethers = { git = "https://github.com/Lagrange-Labs/ethers-rs", default-features = false, features = [ "rustls" ], branch = "get-proof-0x" }
ethers = { git = "https://github.com/Lagrange-Labs/ethers-rs", default-features = false, features = [
"rustls",
], branch = "get-proof-0x" }
jwt = { workspace = true }
k256 = { workspace = true, features = ["ecdsa", "std"] }
lazy-static-include = { workspace = true }
Expand All @@ -44,6 +57,8 @@ tonic = { workspace = true }
prost = { workspace = true }
tokio-stream = { workspace = true }

mp2_common = { workspace = true }

lgn-auth = { path = "../lgn-auth" }
lgn-messages = { path = "../lgn-messages" }
lgn-provers = { path = "../lgn-provers" }
Expand Down
3 changes: 1 addition & 2 deletions lgn-worker/src/config/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ dir = "./zkmr_params"
checksum_expected_local_path = "/tmp/expected_checksums.txt"
# Parameters common directory
# v1.1.x PPs
url = "https://pub-fbb5db8dc9ee4e8da9daf13e07d27c24.r2.dev"
checksum_url = "https://pub-fbb5db8dc9ee4e8da9daf13e07d27c24.r2.dev/public_params.hash"
params_root_url = "https://pub-a894572689a54c008859f232868fc67d.r2.dev"
skip_checksum = false
skip_store = false

Expand Down
35 changes: 26 additions & 9 deletions lgn-worker/src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use config::FileFormat;
use lazy_static_include::*;
use lgn_messages::types::TaskDifficulty;
use lgn_provers::params::PARAMS_CHECKSUM_FILENAME;
use redact::Secret;
use serde_derive::Deserialize;
use tracing::debug;
Expand All @@ -21,8 +22,9 @@ pub(crate) struct Config
#[derive(Deserialize, Debug, Clone, PartialEq)]
pub(crate) struct PublicParamsConfig
{
pub(crate) url: String,
pub(crate) checksum_url: String,
/// the root URL over which we should fetch params.
/// The FULL url is constructed from this one and the mp2 version
pub(crate) params_root_url: String,
pub(crate) checksum_expected_local_path: String,
pub(crate) skip_checksum: bool,
pub(crate) dir: String,
Expand All @@ -39,16 +41,10 @@ impl PublicParamsConfig
{
assert!(
!self
.url
.params_root_url
.is_empty(),
"URL is required"
);
assert!(
!self
.checksum_url
.is_empty(),
"Checksum URL is required"
);
assert!(
!self
.checksum_expected_local_path
Expand All @@ -68,6 +64,19 @@ impl PublicParamsConfig
self.groth16_assets
.validate();
}

/// Build the base URL with path of mp2 version for downloading param files.
pub fn params_base_url(&self) -> String
{
add_mp2_version_path_to_url(&self.params_root_url)
}

/// Build the URL for downloading the checksum file.
pub fn checksum_file_url(&self) -> String
{
let url = self.params_base_url();
format!("{url}/{PARAMS_CHECKSUM_FILENAME}")
}
}

#[derive(Deserialize, Debug, Clone, PartialEq)]
Expand Down Expand Up @@ -264,3 +273,11 @@ impl Config
.validate();
}
}

/// Add mp2 version as a path to the base URL.
/// e.g. https://base.com/MP2_VERSION
fn add_mp2_version_path_to_url(url: &str) -> String
{
let mp2_ver = mp2_common::git::short_git_version();
format!("{url}/{mp2_ver}")
}
4 changes: 2 additions & 2 deletions lgn-worker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ async fn maybe_verify_checksums(config: &Config) -> Result<()>

let checksum_url = &config
.public_params
.checksum_url;
.checksum_file_url();
let expected_checksums_file = &config
.public_params
.checksum_expected_local_path;
Expand Down Expand Up @@ -729,7 +729,7 @@ fn run_with_websocket(config: &Config) -> Result<()>
// Always download the checksum files, this is needed by the prover constructor
let checksum_url = &config
.public_params
.checksum_url;
.checksum_file_url();
let expected_checksums_file = &config
.public_params
.checksum_expected_local_path;
Expand Down
9 changes: 6 additions & 3 deletions lgn-worker/src/manager/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ fn register_v1_preprocessor(
) -> Result<()>
{
let params_config = &config.public_params;
let params_base_url = &params_config.params_base_url();
let preprocessing_prover = lgn_provers::provers::v1::preprocessing::create_prover(
&params_config.url,
params_base_url,
&params_config.dir,
&params_config
.preprocessing_params
Expand All @@ -81,8 +82,9 @@ fn register_v1_query(
) -> Result<()>
{
let params_config = &config.public_params;
let params_base_url = &params_config.params_base_url();
let query_prover = lgn_provers::provers::v1::query::create_prover(
&params_config.url,
params_base_url,
&params_config.dir,
&params_config
.query_params
Expand All @@ -105,9 +107,10 @@ fn register_v1_groth16(
) -> Result<()>
{
let params_config = &config.public_params;
let params_base_url = &params_config.params_base_url();
let assets = &params_config.groth16_assets;
let groth16_prover = lgn_provers::provers::v1::groth16::create_prover(
&params_config.url,
params_base_url,
&params_config.dir,
&assets.circuit_file,
&params_config.checksum_expected_local_path,
Expand Down
2 changes: 1 addition & 1 deletion lgn-worker/src/one-shot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn main() -> Result<()>

let checksum_url = &config
.public_params
.checksum_url;
.checksum_file_url();
let expected_checksums_file = &config
.public_params
.checksum_expected_local_path;
Expand Down