Skip to content

Commit

Permalink
Merge branch 'main' into matias-zki-consensus
Browse files Browse the repository at this point in the history
  • Loading branch information
Deniallugo authored Sep 12, 2024
2 parents 8c1c48d + 527b5ab commit 729388e
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 50 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
- 'etc/**'
- 'contracts/**'
- 'infrastructure/zk/**'
- 'docker/zk-environment/**'
- '!**/*.md'
- '!**/*.MD'
Expand Down
14 changes: 9 additions & 5 deletions core/tests/upgrade-test/tests/upgrade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,29 @@ describe('Upgrade test', function () {
alice = tester.emptyWallet();

if (fileConfig.loadFromFile) {
let walletConfig = loadConfig({ pathToHome, chain: fileConfig.chain, config: 'wallets.yaml' });
const chainWalletConfig = loadConfig({ pathToHome, chain: fileConfig.chain, config: 'wallets.yaml' });

adminGovWallet = new ethers.Wallet(walletConfig.governor.private_key, alice._providerL1());
adminGovWallet = new ethers.Wallet(chainWalletConfig.governor.private_key, alice._providerL1());

walletConfig = loadConfig({
const ecosystemWalletConfig = loadConfig({
pathToHome,
chain: fileConfig.chain,
configsFolder: '../../configs/',
config: 'wallets.yaml'
});

ecosystemGovWallet = new ethers.Wallet(walletConfig.governor.private_key, alice._providerL1());
if (ecosystemWalletConfig.governor.private_key == chainWalletConfig.governor.private_key) {
ecosystemGovWallet = adminGovWallet;
} else {
ecosystemGovWallet = new ethers.Wallet(ecosystemWalletConfig.governor.private_key, alice._providerL1());
}
} else {
let govMnemonic = ethers.Mnemonic.fromPhrase(
require('../../../../etc/test_config/constant/eth.json').mnemonic
);
let govWalletHD = ethers.HDNodeWallet.fromMnemonic(govMnemonic, "m/44'/60'/0'/0/1");
adminGovWallet = new ethers.Wallet(govWalletHD.privateKey, alice._providerL1());
ecosystemGovWallet = new ethers.Wallet(govWalletHD.privateKey, alice._providerL1());
ecosystemGovWallet = adminGovWallet;
}

logs = fs.createWriteStream('upgrade.log', { flags: 'a' });
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-cpu-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
source: ./etc/reth/chaindata
target: /chaindata

command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 300ms --chain /chaindata/reth_config
command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 600ms --chain /chaindata/reth_config
ports:
- 127.0.0.1:8545:8545

Expand Down
2 changes: 1 addition & 1 deletion docker-compose-gpu-runner-cuda-12-0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
source: ./etc/reth/chaindata
target: /chaindata

command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 300ms --chain /chaindata/reth_config
command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 600ms --chain /chaindata/reth_config
ports:
- 127.0.0.1:8545:8545

Expand Down
2 changes: 1 addition & 1 deletion docker-compose-gpu-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
source: ./etc/reth/chaindata
target: /chaindata

command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 300ms --chain /chaindata/reth_config
command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 600ms --chain /chaindata/reth_config
ports:
- 127.0.0.1:8545:8545

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
source: ./etc/reth/chaindata
target: /chaindata

command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 300ms --chain /chaindata/reth_config
command: node --dev --datadir /rethdata --http --http.addr 0.0.0.0 --http.port 8545 --http.corsdomain "*" --dev.block-time 600ms --chain /chaindata/reth_config


postgres:
Expand Down
4 changes: 2 additions & 2 deletions zk_toolbox/crates/zk_inception/src/commands/prover/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn init_file_backed_proof_storage(
ecosystem_config: &EcosystemConfig,
config: ProofStorageFileBacked,
) -> anyhow::Result<ObjectStoreConfig> {
let proof_store_dir = config.proof_store_dir;
let proof_store_dir = config.proof_store_dir.clone();
let prover_path = get_link_to_prover(ecosystem_config);

let proof_store_dir = prover_path.join(proof_store_dir).join("witness_inputs");
Expand All @@ -173,7 +173,7 @@ fn init_file_backed_proof_storage(

let object_store_config = ObjectStoreConfig {
mode: ObjectStoreMode::FileBacked {
file_backed_base_path: proof_store_dir.into_os_string().into_string().unwrap(),
file_backed_base_path: config.proof_store_dir,
},
max_retries: PROVER_STORE_MAX_RETRIES,
local_mirror_path: None,
Expand Down
15 changes: 14 additions & 1 deletion zk_toolbox/crates/zk_inception/src/commands/prover/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::path::PathBuf;

use anyhow::{anyhow, Context};
use common::{check_prerequisites, cmd::Cmd, config::global_config, logger, GPU_PREREQUISITES};
use config::{get_link_to_prover, EcosystemConfig};
use config::{get_link_to_prover, ChainConfig, EcosystemConfig};
use xshell::{cmd, Shell};

use super::args::run::{ProverComponent, ProverRunArgs};
Expand Down Expand Up @@ -69,6 +69,7 @@ pub(crate) async fn run(args: ProverRunArgs, shell: &Shell) -> anyhow::Result<()
if in_docker {
let path_to_configs = chain.configs.clone();
let path_to_prover = get_link_to_prover(&ecosystem_config);
update_setup_data_path(&chain, "prover/data/keys".to_string())?;
run_dockerized_component(
shell,
component.image_name(),
Expand All @@ -80,6 +81,7 @@ pub(crate) async fn run(args: ProverRunArgs, shell: &Shell) -> anyhow::Result<()
&path_to_prover,
)?
} else {
update_setup_data_path(&chain, "data/keys".to_string())?;
run_binary_component(
shell,
component.binary_name(),
Expand Down Expand Up @@ -132,3 +134,14 @@ fn run_binary_component(
cmd = cmd.with_force_run();
cmd.run().context(error)
}

fn update_setup_data_path(chain: &ChainConfig, path: String) -> anyhow::Result<()> {
let mut general_config = chain.get_general_config()?;
general_config
.prover_config
.as_mut()
.expect("Prover config not found")
.setup_data_path = path;
chain.save_general_config(&general_config)?;
Ok(())
}
20 changes: 10 additions & 10 deletions zk_toolbox/crates/zk_supervisor/src/commands/prover/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ use std::{

use anyhow::Context as _;
use common::{config::global_config, logger};
use config::EcosystemConfig;
use config::{ChainConfig, EcosystemConfig};
use xshell::{cmd, Shell};

use crate::messages::MSG_CHAIN_NOT_FOUND_ERR;

pub async fn run(shell: &Shell) -> anyhow::Result<()> {
let link_to_code = EcosystemConfig::from_file(shell)?.link_to_code;
let ecosystem_config = EcosystemConfig::from_file(shell)?;
let chain_config = ecosystem_config
.load_chain(global_config().chain_name.clone())
.expect(MSG_CHAIN_NOT_FOUND_ERR);

let link_to_code = ecosystem_config.link_to_code;
let link_to_prover = link_to_code.join("prover");

let protocol_version = get_protocol_version(shell, &link_to_prover).await?;
let snark_wrapper = get_snark_wrapper(&link_to_prover).await?;
let prover_url = get_database_url(shell).await?;
let prover_url = get_database_url(&chain_config).await?;

logger::info(format!(
"
Expand Down Expand Up @@ -59,13 +64,8 @@ pub(crate) async fn get_snark_wrapper(link_to_prover: &Path) -> anyhow::Result<S
Ok(snark_wrapper)
}

pub(crate) async fn get_database_url(shell: &Shell) -> anyhow::Result<String> {
let ecosystem = EcosystemConfig::from_file(shell)?;
let chain_config = ecosystem
.load_chain(global_config().chain_name.clone())
.context(MSG_CHAIN_NOT_FOUND_ERR)?;

let prover_url = chain_config
pub(crate) async fn get_database_url(chain: &ChainConfig) -> anyhow::Result<String> {
let prover_url = chain
.get_secrets_config()?
.database
.context("Database secrets not found")?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
use common::{check_prerequisites, cmd::Cmd, logger, PROVER_CLI_PREREQUISITE};
use common::{
check_prerequisites, cmd::Cmd, config::global_config, logger, PROVER_CLI_PREREQUISITE,
};
use config::{get_link_to_prover, EcosystemConfig};
use xshell::{cmd, Shell};

use crate::commands::prover::{
args::insert_batch::{InsertBatchArgs, InsertBatchArgsFinal},
info,
use crate::{
commands::prover::{
args::insert_batch::{InsertBatchArgs, InsertBatchArgsFinal},
info,
},
messages::MSG_CHAIN_NOT_FOUND_ERR,
};

pub async fn run(shell: &Shell, args: InsertBatchArgs) -> anyhow::Result<()> {
check_prerequisites(shell, &PROVER_CLI_PREREQUISITE, false);

let ecosystem_config = EcosystemConfig::from_file(shell)?;
let chain_config = ecosystem_config
.load_chain(global_config().chain_name.clone())
.expect(MSG_CHAIN_NOT_FOUND_ERR);

let version = info::get_protocol_version(shell, &get_link_to_prover(&ecosystem_config)).await?;
let prover_url = info::get_database_url(shell).await?;
let prover_url = info::get_database_url(&chain_config).await?;

let InsertBatchArgsFinal { number, version } = args.fill_values_with_prompts(version);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
use common::{check_prerequisites, cmd::Cmd, logger, PROVER_CLI_PREREQUISITE};
use common::{
check_prerequisites, cmd::Cmd, config::global_config, logger, PROVER_CLI_PREREQUISITE,
};
use config::{get_link_to_prover, EcosystemConfig};
use xshell::{cmd, Shell};

use crate::commands::prover::{
args::insert_version::{InsertVersionArgs, InsertVersionArgsFinal},
info,
use crate::{
commands::prover::{
args::insert_version::{InsertVersionArgs, InsertVersionArgsFinal},
info,
},
messages::MSG_CHAIN_NOT_FOUND_ERR,
};

pub async fn run(shell: &Shell, args: InsertVersionArgs) -> anyhow::Result<()> {
check_prerequisites(shell, &PROVER_CLI_PREREQUISITE, false);

let ecosystem_config = EcosystemConfig::from_file(shell)?;
let chain_config = ecosystem_config
.load_chain(global_config().chain_name.clone())
.expect(MSG_CHAIN_NOT_FOUND_ERR);

let version = info::get_protocol_version(shell, &get_link_to_prover(&ecosystem_config)).await?;
let snark_wrapper = info::get_snark_wrapper(&get_link_to_prover(&ecosystem_config)).await?;

let prover_url = info::get_database_url(shell).await?;
let prover_url = info::get_database_url(&chain_config).await?;

let InsertVersionArgsFinal {
version,
Expand Down
20 changes: 3 additions & 17 deletions zk_toolbox/crates/zk_supervisor/src/commands/test/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
dals::{Dal, CORE_DAL_PATH, PROVER_DAL_PATH},
defaults::{TEST_DATABASE_PROVER_URL, TEST_DATABASE_SERVER_URL},
messages::{
MSG_CARGO_NEXTEST_MISSING_ERR, MSG_CHAIN_NOT_FOUND_ERR, MSG_POSTGRES_CONFIG_NOT_FOUND_ERR,
MSG_CHAIN_NOT_FOUND_ERR, MSG_POSTGRES_CONFIG_NOT_FOUND_ERR,
MSG_RESETTING_TEST_DATABASES, MSG_UNIT_TESTS_RUN_SUCCESS, MSG_USING_CARGO_NEXTEST,
},
};
Expand Down Expand Up @@ -61,13 +61,8 @@ pub async fn run(shell: &Shell, args: RustArgs) -> anyhow::Result<()> {

let _dir_guard = shell.push_dir(&link_to_code);

let cmd = if nextest_is_installed(shell)? {
logger::info(MSG_USING_CARGO_NEXTEST);
cmd!(shell, "cargo nextest run --release")
} else {
logger::error(MSG_CARGO_NEXTEST_MISSING_ERR);
cmd!(shell, "cargo test --release")
};
logger::info(MSG_USING_CARGO_NEXTEST);
let cmd = cmd!(shell, "cargo nextest run --release");

let cmd = if let Some(options) = args.options {
Cmd::new(cmd.args(options.split_whitespace())).with_force_run()
Expand All @@ -84,15 +79,6 @@ pub async fn run(shell: &Shell, args: RustArgs) -> anyhow::Result<()> {
Ok(())
}

fn nextest_is_installed(shell: &Shell) -> anyhow::Result<bool> {
let out = String::from_utf8(
Cmd::new(cmd!(shell, "cargo install --list"))
.run_with_output()?
.stdout,
)?;
Ok(out.contains("cargo-nextest"))
}

async fn reset_test_databases(
shell: &Shell,
link_to_code: &Path,
Expand Down
1 change: 0 additions & 1 deletion zk_toolbox/crates/zk_supervisor/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ pub(super) const MSG_TESTS_RECOVERY_SNAPSHOT_HELP: &str =
"Run recovery from a snapshot instead of genesis";
pub(super) const MSG_UNIT_TESTS_RUN_SUCCESS: &str = "Unit tests ran successfully";
pub(super) const MSG_USING_CARGO_NEXTEST: &str = "Using cargo-nextest for running tests";
pub(super) const MSG_CARGO_NEXTEST_MISSING_ERR: &str = "cargo-nextest is missing, please run 'cargo install cargo-nextest'. Falling back to 'cargo test'";
pub(super) const MSG_L1_CONTRACTS_ABOUT: &str = "Run L1 contracts tests";
pub(super) const MSG_L1_CONTRACTS_TEST_SUCCESS: &str = "L1 contracts tests ran successfully";
pub(super) const MSG_PROVER_TEST_ABOUT: &str = "Run prover tests";
Expand Down

0 comments on commit 729388e

Please sign in to comment.