-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(prover_cli): Fix the issues with
home
path (#2104)
In this PR: [Pull Request #2022](https://github.com/matter-labs/zksync-era/pull/2022/files), the logic was changed to stop using the $ZKSYNC_HOME environment variable to construct paths relative to the root of zksync-era. But the prover is a separate workspace, so it fails to create the path to the contract with the functions in the main workspace.. ## Checklist - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [x] Code has been formatted via `zk fmt` and `zk lint`. - [x] Spellcheck has been run via `zk spellcheck`.
- Loading branch information
1 parent
70eb588
commit 1e18af2
Showing
7 changed files
with
67 additions
and
13 deletions.
There are no files selected for viewing
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 @@ | ||
PLI__DB_URL=postgres://postgres:notsecurepassword@localhost/prover_local |
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
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,47 @@ | ||
use std::{ | ||
fs::File, | ||
path::{Path, PathBuf}, | ||
}; | ||
|
||
use zksync_types::ethabi::Contract; | ||
use zksync_utils::locate_workspace; | ||
|
||
const ZKSYNC_HYPERCHAIN_CONTRACT_FILE: &str = | ||
"contracts/l1-contracts/artifacts/contracts/state-transition/chain-interfaces/IZkSyncHyperchain.sol/IZkSyncHyperchain.json"; | ||
const VERIFIER_CONTRACT_FILE: &str = | ||
"contracts/l1-contracts/artifacts/contracts/state-transition/Verifier.sol/Verifier.json"; | ||
|
||
pub fn hyperchain_contract() -> Contract { | ||
load_contract_if_present(ZKSYNC_HYPERCHAIN_CONTRACT_FILE) | ||
} | ||
|
||
pub fn verifier_contract() -> Contract { | ||
load_contract_if_present(VERIFIER_CONTRACT_FILE) | ||
} | ||
|
||
fn read_file_to_json_value(path: &PathBuf) -> serde_json::Value { | ||
serde_json::from_reader( | ||
File::open(path).unwrap_or_else(|e| panic!("Failed to open file {:?}: {}", path, e)), | ||
) | ||
.unwrap_or_else(|e| panic!("Failed to parse file {:?}: {}", path, e)) | ||
} | ||
|
||
fn load_contract_if_present(path: &str) -> Contract { | ||
let home = core_workspace_dir_or_current_dir(); | ||
let path = Path::new(&home).join(path); | ||
path.exists() | ||
.then(|| { | ||
serde_json::from_value(read_file_to_json_value(&path)["abi"].take()).unwrap_or_else( | ||
|e| panic!("Failed to parse contract abi from file {:?}: {}", path, e), | ||
) | ||
}) | ||
.unwrap_or_else(|| { | ||
panic!("Failed to load contract from {:?}", path); | ||
}) | ||
} | ||
|
||
pub fn core_workspace_dir_or_current_dir() -> PathBuf { | ||
locate_workspace() | ||
.map(|a| a.join("..")) | ||
.unwrap_or_else(|| PathBuf::from(".")) | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod cli; | ||
pub mod commands; | ||
pub mod config; | ||
pub mod helper; |