Skip to content

Commit

Permalink
feat: support builtInWithoutSecurity option (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbaztec authored Oct 17, 2023
1 parent b13fa9d commit 29bb65d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
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,
DevSystemContracts::Local => system_contracts::Options::Local,
};

let node = InMemoryNode::new(
Expand Down

0 comments on commit 29bb65d

Please sign in to comment.