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: support builtInWithoutSecurity option #186

Merged
merged 3 commits into from
Oct 17, 2023
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ Please note that `era-test-node` is still in its **alpha** stage. Some features
make run
```

## 📄 System Contracts

The system contract within the node can be specified via the `--dev-system-contracts` option.
It can take one of the following options:
* `built-in`: Use the compiled built-in contracts
* `built-in-no-verify`: Use the compiled built-in contracts, but without signature verification
* `local`: Load contracts from `ZKSYNC_HOME`

## 📃 Logging

The node may be started in either of `debug`, `info`, `warn` or `error` logging levels via the `--log` option:
Expand Down
25 changes: 17 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ enum CacheType {
Disk,
}

/// System contract options.
#[derive(ValueEnum, Debug, Clone)]
enum DevSystemContracts {
BuiltIn,
BuiltInNoVerify,
Local,
}

#[derive(Debug, Parser)]
#[command(author = "Matter Labs", version, about = "Test Node", long_about = None)]
struct Cli {
Expand Down Expand Up @@ -208,9 +216,10 @@ struct Cli {
/// It will make debug log more readable, but will decrease the performance.
resolve_hashes: bool,

#[arg(long)]
/// If true, will load the locally compiled system contracts (useful when doing changes to system contracts or bootloader)
dev_use_local_contracts: bool,
/// Specifies the option for the system contracts (use compiled built-in with or without signature verification, or load locally).
/// Default: built-in
#[arg(long, default_value = "built-in")]
dev_system_contracts: DevSystemContracts,

/// Log filter level - default: info
#[arg(long, default_value = "info")]
Expand Down Expand Up @@ -296,7 +305,7 @@ async fn main() -> anyhow::Result<()> {
])
.expect("failed instantiating logger");

if opt.dev_use_local_contracts {
if matches!(opt.dev_system_contracts, DevSystemContracts::Local) {
if let Some(path) = env::var_os("ZKSYNC_HOME") {
log::info!("+++++ Reading local contracts from {:?} +++++", path);
}
Expand Down Expand Up @@ -340,10 +349,10 @@ async fn main() -> anyhow::Result<()> {
} else {
vec![]
};
let system_contracts_options = if opt.dev_use_local_contracts {
system_contracts::Options::Local
} else {
system_contracts::Options::BuiltIn
let system_contracts_options = match opt.dev_system_contracts {
DevSystemContracts::BuiltIn => system_contracts::Options::BuiltIn,
DevSystemContracts::BuiltInNoVerify => system_contracts::Options::BuiltInWithoutSecurity,
nbaztec marked this conversation as resolved.
Show resolved Hide resolved
DevSystemContracts::Local => system_contracts::Options::Local,
};

let node = InMemoryNode::new(
Expand Down