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(contract-verifier): allow other zksolc settings #1174

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
9 changes: 6 additions & 3 deletions core/bin/contract-verifier/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,16 @@ impl ContractVerifier {
enabled: request.req.optimization_used,
mode: request.req.optimizer_mode.and_then(|s| s.chars().next()),
};
let optimizer_value = serde_json::to_value(optimizer).unwrap();

let settings = Settings {
libraries: None,
output_selection: Some(default_output_selection),
optimizer,
is_system: request.req.is_system,
metadata: None,
other: serde_json::Value::Object(
vec![("optimizer".to_string(), optimizer_value)]
.into_iter()
.collect(),
),
};

Ok(ZkSolcInput::StandardJson(StandardJson {
Expand Down
30 changes: 6 additions & 24 deletions core/bin/contract-verifier/src/zksolc_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,20 @@ pub struct Source {
pub content: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub enum MetadataHash {
/// Do not include bytecode hash.
#[serde(rename = "none")]
None,
}

#[derive(Debug, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Metadata {
/// The bytecode hash mode.
#[serde(skip_serializing_if = "Option::is_none")]
pub bytecode_hash: Option<MetadataHash>,
}

/// Compiler settings.
/// There are fields like `output_selection` and `is_system` which are accessed by contract verifier explicitly.
/// Other fields are accumulated in `other`, this way every field that was in the original request will be passed to a compiler.
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Settings {
/// The linker library addresses.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub libraries: Option<HashMap<String, HashMap<String, String>>>,
/// The output selection filters.
pub output_selection: Option<serde_json::Value>,
/// The optimizer settings.
#[serde(default)]
pub optimizer: Optimizer,
/// The metadata settings.
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<Metadata>,
/// Flag for system compilation mode.
#[serde(default)]
pub is_system: bool,
/// Other fields.
#[serde(flatten)]
pub other: serde_json::Value,
}

#[derive(Debug, Serialize, Deserialize)]
Expand Down
7 changes: 7 additions & 0 deletions docker/contract-verifier/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ RUN for VERSION in $(seq -f "v1.3.%g" 9 17); do \
chmod +x /etc/zkvyper-bin/$VERSION/zkvyper; \
done

# install zkvyper 1.4.x
RUN for VERSION in $(seq -f "v1.4.%g" 0 0); do \
mkdir -p /etc/zkvyper-bin/$VERSION && \
wget https://github.com/matter-labs/zkvyper-bin/raw/main/linux-amd64/zkvyper-linux-amd64-musl-$VERSION -O /etc/zkvyper-bin/$VERSION/zkvyper && \
chmod +x /etc/zkvyper-bin/$VERSION/zkvyper; \
done

# install solc
COPY docker/contract-verifier/install-all-solc.sh install-all-solc.sh
RUN bash ./install-all-solc.sh
Expand Down
Loading