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(verifier): zksolc full match support #912

Merged
merged 19 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a1a7fde
Add basic zksync endpoints definitions. Create ZksyncCompilers struct…
rimrakhimov May 21, 2024
8be5c11
Add zkevm settings
rimrakhimov May 22, 2024
0286283
Make VersionNotFound error internal String
rimrakhimov May 22, 2024
d3f5168
Create a generic fetcher structs
rimrakhimov May 22, 2024
7a424ef
Remove non-generic fetcher structs. Make use of generic fetcher inste…
rimrakhimov May 23, 2024
0fb8e70
Implement zksolc contracts parsing
rimrakhimov Jun 4, 2024
2ea4b09
Move zksync related code into a separate module. Finish the basic con…
rimrakhimov Jun 9, 2024
d3d064e
Merge main into branch
rimrakhimov Jun 9, 2024
e762dd0
Merge branch 'main' into rimrakhimov/verifier/zksolc-support
rimrakhimov Jun 9, 2024
c363d26
Merge branch 'main' into rimrakhimov/verifier/zksolc-support
rimrakhimov Jun 14, 2024
e5b7bff
Add verifier_alliance related definitions into verification-common lib
rimrakhimov Jun 19, 2024
0a84e91
Implement zksolc verification
rimrakhimov Jun 19, 2024
59dcbfa
Update Cargo.lock
rimrakhimov Jun 19, 2024
2e0df0d
Remove double metadata hash test
rimrakhimov Jun 19, 2024
1c2a451
Fix test runs
rimrakhimov Jun 19, 2024
60faed4
Merge branch 'main' into rimrakhimov/verifier/zksolc-support
rimrakhimov Jun 28, 2024
341511e
Remove unused zksync_verification.rs
rimrakhimov Jun 28, 2024
ebcd9e6
chore(libs-verification-common): bump blockscout_display_bytes to v1.1.0
rimrakhimov Jul 1, 2024
f1edb7a
chore: bump blockscout-display-bytes to v1.1.0, solidity-metadata to …
rimrakhimov Jul 1, 2024
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
7 changes: 7 additions & 0 deletions libs/verification-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
alloy-dyn-abi = "0.7"
alloy-json-abi = "0.7"
anyhow = "1.0"
blockscout-display-bytes = "1.1.0"
bytes = "1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_with = "3.8"

[dev-dependencies]
hex = "0.4.3"
1 change: 1 addition & 0 deletions libs/verification-common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pub mod blueprint_contracts;
pub mod verifier_alliance;
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
use serde::{Deserialize, Serialize};
use serde_json::Value;

pub trait ToCompilationArtifacts {
fn abi(&self) -> Option<Value> {
None
}
fn devdoc(&self) -> Option<Value> {
None
}
fn userdoc(&self) -> Option<Value> {
None
}
fn storage_layout(&self) -> Option<Value> {
None
}
}

impl<T: ToCompilationArtifacts> ToCompilationArtifacts for &T {
fn abi(&self) -> Option<Value> {
(*self).abi()
}
fn devdoc(&self) -> Option<Value> {
(*self).devdoc()
}
fn userdoc(&self) -> Option<Value> {
(*self).userdoc()
}
fn storage_layout(&self) -> Option<Value> {
(*self).storage_layout()
}
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CompilationArtifacts {
#[serde(skip_serializing_if = "Option::is_none")]
pub abi: Option<Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub devdoc: Option<Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub userdoc: Option<Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_layout: Option<Value>,
}

impl<T: ToCompilationArtifacts> From<T> for CompilationArtifacts {
fn from(value: T) -> Self {
Self {
abi: value.abi(),
devdoc: value.devdoc(),
userdoc: value.userdoc(),
storage_layout: value.storage_layout(),
}
}
}

impl From<CompilationArtifacts> for Value {
fn from(value: CompilationArtifacts) -> Self {
serde_json::to_value(value).expect("compilation artifacts serialization must succeed")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
use serde::{Deserialize, Serialize};
use serde_json::Value;

pub trait ToCreationCodeArtifacts {
fn cbor_auxdata(&self) -> Option<Value> {
None
}
fn link_references(&self) -> Option<Value> {
None
}
fn source_map(&self) -> Option<Value> {
None
}
}

impl<T: ToCreationCodeArtifacts> ToCreationCodeArtifacts for &T {
fn cbor_auxdata(&self) -> Option<Value> {
(*self).cbor_auxdata()
}
fn link_references(&self) -> Option<Value> {
(*self).link_references()
}
fn source_map(&self) -> Option<Value> {
(*self).source_map()
}
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreationCodeArtifacts {
#[serde(skip_serializing_if = "Option::is_none")]
pub source_map: Option<Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub link_references: Option<Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cbor_auxdata: Option<Value>,
}

impl<T: ToCreationCodeArtifacts> From<T> for CreationCodeArtifacts {
fn from(value: T) -> Self {
Self {
link_references: value.link_references(),
source_map: value.source_map(),
cbor_auxdata: value.cbor_auxdata(),
}
}
}

impl From<CreationCodeArtifacts> for Value {
fn from(value: CreationCodeArtifacts) -> Self {
serde_json::to_value(value).expect("creation code artifacts serialization must succeed")
}
}
12 changes: 12 additions & 0 deletions libs/verification-common/src/verifier_alliance/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
mod compilation_artifacts;
mod creation_code_artifacts;
mod runtime_code_artifacts;
mod verification_match;

mod verification_match_transformations;
mod verification_match_values;

pub use compilation_artifacts::{CompilationArtifacts, ToCompilationArtifacts};
pub use creation_code_artifacts::{CreationCodeArtifacts, ToCreationCodeArtifacts};
pub use runtime_code_artifacts::{RuntimeCodeArtifacts, ToRuntimeCodeArtifacts};
pub use verification_match::{Match, MatchBuilder, MatchTransformation, MatchType, MatchValues};
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
use serde::{Deserialize, Serialize};
use serde_json::Value;

pub trait ToRuntimeCodeArtifacts {
fn cbor_auxdata(&self) -> Option<Value> {
None
}
fn immutable_references(&self) -> Option<Value> {
None
}
fn link_references(&self) -> Option<Value> {
None
}
fn source_map(&self) -> Option<Value> {
None
}
}

impl<T: ToRuntimeCodeArtifacts> ToRuntimeCodeArtifacts for &T {
fn cbor_auxdata(&self) -> Option<Value> {
(*self).cbor_auxdata()
}
fn immutable_references(&self) -> Option<Value> {
(*self).immutable_references()
}
fn link_references(&self) -> Option<Value> {
(*self).link_references()
}
fn source_map(&self) -> Option<Value> {
(*self).source_map()
}
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RuntimeCodeArtifacts {
#[serde(skip_serializing_if = "Option::is_none")]
pub cbor_auxdata: Option<Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub immutable_references: Option<Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub link_references: Option<Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub source_map: Option<Value>,
}

impl<T: ToRuntimeCodeArtifacts> From<T> for RuntimeCodeArtifacts {
fn from(value: T) -> Self {
Self {
cbor_auxdata: value.cbor_auxdata(),
immutable_references: value.immutable_references(),
link_references: value.link_references(),
source_map: value.source_map(),
}
}
}

impl From<(RuntimeCodeArtifacts, RuntimeCodeArtifacts)> for RuntimeCodeArtifacts {
fn from(
(base_artifacts, merged_artifacts): (RuntimeCodeArtifacts, RuntimeCodeArtifacts),
) -> Self {
Self {
cbor_auxdata: merged_artifacts
.cbor_auxdata
.or(base_artifacts.cbor_auxdata),
immutable_references: merged_artifacts
.immutable_references
.or(base_artifacts.immutable_references),
link_references: merged_artifacts
.link_references
.or(base_artifacts.link_references),
source_map: merged_artifacts.source_map.or(base_artifacts.source_map),
}
}
}

impl From<RuntimeCodeArtifacts> for Value {
fn from(value: RuntimeCodeArtifacts) -> Self {
serde_json::to_value(value).expect("runtime code artifacts serialization must succeed")
}
}
Loading
Loading