Skip to content

Commit

Permalink
chore(verifier): update response proto for zksync (#977)
Browse files Browse the repository at this point in the history
* merge compilers software and compiler version into a single Compiler struct
* make language to be enum
  • Loading branch information
rimrakhimov authored Jul 10, 2024
1 parent cde3965 commit 5b530da
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 35 deletions.
1 change: 1 addition & 0 deletions smart-contract-verifier/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,28 @@ message VerificationFailure {
message VerificationSuccess {
string file_name = 1;
string contract_name = 2;
string zk_compiler = 3;
string zk_compiler_version = 4;
string evm_compiler = 5;
string evm_compiler_version = 6;
string language = 7;
string compiler_settings = 8;
map <string, string> sources = 9;
string compilation_artifacts = 10;
string creation_code_artifacts = 11;
string runtime_code_artifacts = 12;

optional Match creation_match = 13;
Match runtime_match = 14;

message Compiler {
string compiler = 1;
string version = 2;
}
Compiler zk_compiler = 3;
Compiler evm_compiler = 4;

enum Language {
LANGUAGE_UNKNOWN = 0;
SOLIDITY = 1;
}
Language language = 5;

string compiler_settings = 6;
map <string, string> sources = 7;
string compilation_artifacts = 8;
string creation_code_artifacts = 9;
string runtime_code_artifacts = 10;

optional Match creation_match = 11;
Match runtime_match = 12;
}

message VerifyResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,15 +450,11 @@ definitions:
contractName:
type: string
zkCompiler:
type: string
zkCompilerVersion:
type: string
$ref: '#/definitions/solidityVerificationSuccessCompiler'
evmCompiler:
type: string
evmCompilerVersion:
type: string
$ref: '#/definitions/solidityVerificationSuccessCompiler'
language:
type: string
$ref: '#/definitions/solidityVerificationSuccessLanguage'
compilerSettings:
type: string
sources:
Expand All @@ -475,6 +471,19 @@ definitions:
$ref: '#/definitions/solidityMatch'
runtimeMatch:
$ref: '#/definitions/solidityMatch'
solidityVerificationSuccessCompiler:
type: object
properties:
compiler:
type: string
version:
type: string
solidityVerificationSuccessLanguage:
type: string
enum:
- LANGUAGE_UNKNOWN
- SOLIDITY
default: LANGUAGE_UNKNOWN
solidityVerifyStandardJsonRequest:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::{
proto::zksync::solidity::{
verify_response, zk_sync_solidity_verifier_server::ZkSyncSolidityVerifier,
CompilationFailure, ListCompilersRequest, ListCompilersResponse, VerificationFailure,
VerificationSuccess, VerifyResponse, VerifyStandardJsonRequest,
verification_success, verify_response,
zk_sync_solidity_verifier_server::ZkSyncSolidityVerifier, CompilationFailure,
ListCompilersRequest, ListCompilersResponse, VerificationFailure, VerificationSuccess,
VerifyResponse, VerifyStandardJsonRequest,
},
services::common,
settings::ZksyncSoliditySettings,
Expand Down Expand Up @@ -111,11 +112,15 @@ fn process_verification_result(
let proto_success = VerificationSuccess {
file_name: success.file_path,
contract_name: success.contract_name,
zk_compiler: result.zk_compiler,
zk_compiler_version: result.zk_compiler_version.to_string(),
evm_compiler: result.evm_compiler,
evm_compiler_version: result.evm_compiler_version.to_string(),
language: result.language,
zk_compiler: Some(verification_success::Compiler {
compiler: result.zk_compiler,
version: result.zk_compiler_version.to_string(),
}),
evm_compiler: Some(verification_success::Compiler {
compiler: result.evm_compiler,
version: result.evm_compiler_version.to_string(),
}),
language: result.language.into(),
compiler_settings: result.compiler_settings.to_string(),
sources: result.sources,
compilation_artifacts: serde_json::Value::from(success.compilation_artifacts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,24 @@ impl TestCase for StandardJson {
self.contract_name, success.contract_name,
"invalid contract name"
);
assert_eq!("zksolc", success.zk_compiler, "invalid zk-compiler");
assert_eq!(
self.zk_compiler_version, success.zk_compiler_version,
"zksolc",
success.zk_compiler.as_ref().unwrap().compiler,
"invalid zk-compiler"
);
assert_eq!(
self.zk_compiler_version,
success.zk_compiler.as_ref().unwrap().version,
"invalid zk-compiler version"
);
assert_eq!("solc", success.evm_compiler, "invalid evm-compiler");
assert_eq!(
self.evm_compiler_version, success.evm_compiler_version,
"solc",
success.evm_compiler.as_ref().unwrap().compiler,
"invalid evm-compiler"
);
assert_eq!(
self.evm_compiler_version,
success.evm_compiler.as_ref().unwrap().version,
"invalid evm-compiler version"
);

Expand All @@ -92,7 +102,7 @@ impl TestCase for StandardJson {
Input::deserialize(&self.input).expect("expected language field deserialization");
assert_eq!(
input.language.to_lowercase(),
success.language.to_lowercase(),
success.language().as_str_name().to_lowercase(),
"invalid language"
);
}
Expand Down
2 changes: 2 additions & 0 deletions smart-contract-verifier/smart-contract-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ repository = "https://github.com/blockscout/blockscout-rs"
keywords = ["ethereum", "web3", "solidity"]

[dependencies]
smart-contract-verifier-proto = { path = "../smart-contract-verifier-proto" }

alloy-dyn-abi = "0.6.4"
alloy-json-abi = "0.6.4"
anyhow = "1.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use verification_common::verifier_alliance::{
CompilationArtifacts, CreationCodeArtifacts, Match, MatchBuilder, RuntimeCodeArtifacts,
ToCompilationArtifacts, ToCreationCodeArtifacts, ToRuntimeCodeArtifacts,
};
use smart_contract_verifier_proto::blockscout::smart_contract_verifier::v2::zksync::solidity::verification_success::Language;

#[derive(Clone, Debug)]
pub struct VerificationRequest {
Expand Down Expand Up @@ -56,7 +57,7 @@ pub struct VerificationResult {
pub zk_compiler_version: CompactVersion,
pub evm_compiler: String,
pub evm_compiler_version: DetailedVersion,
pub language: String,
pub language: Language,
pub compiler_settings: Value,
pub sources: BTreeMap<String, String>,
pub successes: Vec<VerificationSuccess>,
Expand Down Expand Up @@ -149,7 +150,7 @@ pub async fn verify(
zk_compiler_version,
evm_compiler: "solc".to_string(),
evm_compiler_version,
language: "solidity".to_string(),
language: Language::Solidity,
compiler_settings: serde_json::to_value(compiler_input.settings)
.context("compiler settings serialization")?,
sources,
Expand Down

0 comments on commit 5b530da

Please sign in to comment.