-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(verifier): zksolc full match support (#912)
* Add basic zksync endpoints definitions. Create ZksyncCompilers struct; use it to fetch solc compilers * Add zkevm settings * Make VersionNotFound error internal String * Create a generic fetcher structs * Remove non-generic fetcher structs. Make use of generic fetcher instead of non-generic one. Finish implementation of list_compilers for zksolidity service * Implement zksolc contracts parsing * Move zksync related code into a separate module. Finish the basic contract comparison * Add verifier_alliance related definitions into verification-common lib * Implement zksolc verification * chore(libs-verification-common): bump blockscout_display_bytes to v1.1.0 * chore: bump blockscout-display-bytes to v1.1.0, solidity-metadata to v1.1.0
- Loading branch information
1 parent
08b38a5
commit bd6352d
Showing
90 changed files
with
4,307 additions
and
788 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
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 +1,2 @@ | ||
pub mod blueprint_contracts; | ||
pub mod verifier_alliance; |
62 changes: 62 additions & 0 deletions
62
libs/verification-common/src/verifier_alliance/compilation_artifacts.rs
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,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") | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
libs/verification-common/src/verifier_alliance/creation_code_artifacts.rs
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,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") | ||
} | ||
} |
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,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}; |
81 changes: 81 additions & 0 deletions
81
libs/verification-common/src/verifier_alliance/runtime_code_artifacts.rs
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,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") | ||
} | ||
} |
Oops, something went wrong.