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): zksync - add support for era solidity compilers #1091

Merged
merged 4 commits into from
Oct 24, 2024
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
4 changes: 2 additions & 2 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 @@ -36,12 +36,21 @@ impl Service {
let evm_fetcher = common::initialize_fetcher(
settings.evm_fetcher,
settings.evm_compilers_dir.clone(),
settings.evm_refresh_versions_schedule,
settings.evm_refresh_versions_schedule.clone(),
Some(solc_validator),
)
.await
.context("zksync solc fetcher initialization")?;

let era_evm_fetcher = common::initialize_fetcher(
settings.era_evm_fetcher,
settings.evm_compilers_dir.clone(),
settings.evm_refresh_versions_schedule,
None,
)
.await
.context("zksync era solc fetcher initialization")?;

let zk_fetcher = common::initialize_fetcher(
settings.zk_fetcher,
settings.zk_compilers_dir.clone(),
Expand All @@ -53,6 +62,7 @@ impl Service {

let compilers = ZkSyncCompilers::new(
evm_fetcher.clone(),
era_evm_fetcher.clone(),
zk_fetcher.clone(),
compilers_threads_semaphore,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use cron::Schedule;
use serde::Deserialize;
use serde_with::{serde_as, DisplayFromStr};
use smart_contract_verifier::{
DEFAULT_SOLIDITY_COMPILER_LIST, DEFAULT_SOURCIFY_HOST, DEFAULT_VYPER_COMPILER_LIST,
DEFAULT_ZKSOLC_COMPILER_LIST,
DEFAULT_ERA_SOLIDITY_COMPILER_LIST, DEFAULT_SOLIDITY_COMPILER_LIST, DEFAULT_SOURCIFY_HOST,
DEFAULT_VYPER_COMPILER_LIST, DEFAULT_ZKSOLC_COMPILER_LIST,
};
use std::{
num::{NonZeroU32, NonZeroUsize},
Expand Down Expand Up @@ -130,6 +130,7 @@ pub struct ZksyncSoliditySettings {
#[serde_as(as = "DisplayFromStr")]
pub evm_refresh_versions_schedule: Schedule,
pub evm_fetcher: FetcherSettings,
pub era_evm_fetcher: FetcherSettings,
pub zk_compilers_dir: PathBuf,
#[serde_as(as = "DisplayFromStr")]
pub zk_refresh_versions_schedule: Schedule,
Expand All @@ -143,6 +144,7 @@ impl Default for ZksyncSoliditySettings {
evm_compilers_dir: default_compilers_dir("zksync-solc-compilers"),
evm_refresh_versions_schedule: schedule_every_hour(),
evm_fetcher: default_list_fetcher(DEFAULT_SOLIDITY_COMPILER_LIST),
era_evm_fetcher: default_list_fetcher(DEFAULT_ERA_SOLIDITY_COMPILER_LIST),
zk_compilers_dir: default_compilers_dir("zksync-zksolc-compilers"),
zk_refresh_versions_schedule: schedule_every_hour(),
zk_fetcher: default_list_fetcher(DEFAULT_ZKSOLC_COMPILER_LIST),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"_comment": "A contract compiled via era-solidity v0.8.28-1.0.1+commit.acc7d8f9",
"deployed_code": "0x00020000000000020000008004000039000000400040043f00000060031002700000007d0330019700000001002001900000000002000416000000200900008a000000660000c13d000000040030008c000000c10000413d000000000401043b000000e004400270000000850040009c0000009b0000613d000000860040009c000000c10000c13d000000240030008c000000c10000413d000000000002004b000000c10000c13d0000000402100370000000000402043b000000800040009c000000c10000213d0000002302400039000000000032004b000000c10000813d0000000405400039000000000251034f000000000202043b000000800020009c000000970000213d0000001f06200039000000000696016f0000003f06600039000000000696016f000000870060009c000000970000213d0000008006600039000000400060043f000000800020043f00000000042400190000002404400039000000000034004b000000c10000213d0000002003500039000000000331034f00000000049201700000001f0520018f000000a0014000390000003a0000613d000000a006000039000000000703034f000000007807043c0000000006860436000000000016004b000000360000c13d000000000005004b000000470000613d000000000343034f0000000304500210000000000501043300000000054501cf000000000545022f000000000303043b0000010004400089000000000343022f00000000034301cf000000000353019f0000000000310435000000a0012000390000000000010435000000800100043d000000800010009c000000970000213d000000000300041a000000010030019000000001023002700000007f0220618f0000001f0020008c00000000040000390000000104002039000000000343013f0000000100300190000000a70000c13d000000200020008c000001910000413d0000001f031000390000000503300270000000820330009a000000200010008c00000083030040410000001f022000390000000502200270000000820220009a000000000000043f000000000023004b000001910000813d000000000003041b0000000103300039000000610000013d000000000002004b000000c10000c13d0000001f023000390000007e022001970000008002200039000000400020043f0000001f0530018f0000007f063001980000008002600039000000750000613d000000000701034f000000007807043c0000000004840436000000000024004b000000710000c13d000000000005004b000000820000613d000000000161034f0000000304500210000000000502043300000000054501cf000000000545022f000000000101043b0000010004400089000000000141022f00000000014101cf000000000151019f0000000000120435000000200030008c000000c10000413d000000800400043d000000800040009c000000c10000213d0000001f01400039000000000031004b000000000200001900000081020080410000008101100197000000000001004b00000000050000190000008105004041000000810010009c000000000502c019000000000005004b000000c10000c13d00000080014000390000000002010433000000800020009c000000ad0000a13d0000008801000041000000000010043f0000004101000039000000aa0000013d000000000002004b000000c10000c13d000000000200041a000000010320019000000001012002700000007f0110618f0000001f0010008c00000000040000390000000104002039000000000442013f0000000100400190000000c30000613d0000008801000041000000000010043f0000002201000039000000040010043f0000008901000041000001f1000104300000001f01200039000000000191016f0000003f01100039000000000191016f000000400b00043d00000000011b00190000000000b1004b00000000050000390000000105004039000000800010009c000000970000213d0000000100500190000000970000c13d0000008005300039000000400010043f00000000012b0436000000a0034000390000000004320019000000000054004b000001140000a13d0000000001000019000001f100010430000000800010043f000000000003004b000000d10000613d0000008302000041000000000000043f0000000003000019000000000013004b000000d80000813d000000000402041a000000a005300039000000000045043500000020033000390000000102200039000000c90000013d000001000300008a000000000232016f000000a00020043f000000000001004b000000a0010000390000008001006039000000d90000013d0000008001300039000000600210008a000000800100003901ef01bc0000040f0000002002000039000000400100043d0000000003210436000000800200043d0000000000230435000000200a00008a0000000005a2016f0000001f0420018f0000004003100039000000a10030008c000000f70000413d000000000005004b000000f20000613d000000000743001900000080064001bf000000200770008a0000000008570019000000000956001900000000090904330000000000980435000000200550008c000000ec0000c13d000000000004004b0000010d0000613d000000a0050000390000000006030019000001030000013d0000000006530019000000000005004b000001000000613d000000a007000039000000000803001900000000790704340000000008980436000000000068004b000000fc0000c13d000000000004004b0000010d0000613d000000a0055000390000000304400210000000000706043300000000074701cf000000000747022f00000000050504330000010004400089000000000545022f00000000044501cf000000000474019f0000000000460435000000000332001900000000000304350000001f022000390000000002a2016f0000004002200039000000000300001901ef01cf0000040f000000000592016f0000001f0420018f000000000013004b000001280000813d000000000005004b000001240000613d00000000074300190000000006410019000000200660008a000000200770008a0000000008560019000000000957001900000000090904330000000000980435000000200550008c0000011e0000c13d000000000004004b0000013e0000613d0000000006010019000001340000013d0000000006510019000000000005004b000001310000613d0000000007030019000000000801001900000000790704340000000008980436000000000068004b0000012d0000c13d000000000004004b0000013e0000613d00000000035300190000000304400210000000000506043300000000054501cf000000000545022f00000000030304330000010004400089000000000343022f00000000034301cf000000000353019f00000000003604350000000002210019000000000002043500000000050b0433000000800050009c000000970000213d000000000200041a000000010420019000000001032002700000007f0330618f0000001f0030008c00000000020000390000000102002039000000000024004b000000a70000c13d000000200030008c0000015c0000413d0000001f025000390000000502200270000000820220009a000000200050008c00000083020040410000001f033000390000000503300270000000820330009a000000000000043f000000000032004b0000015c0000813d000000000002041b0000000102200039000001570000013d0000001f0050008c0000002008000039000001740000a13d000000000000043f000000000108001900020000000b001d000100000005001d01ef01d90000040f000000200800003900000001070000290000000206000029000000200200008a000000000227016f00000000030800190000000004000019000000000024004b00000000056300190000017f0000813d0000000005050433000000000051041b0000002004400039000000200330003900000001011000390000016b0000013d000000000005004b0000000002000019000001780000613d00000000020104330000000301500210000000010300008a000000000113022f000000000131013f000000000212016f00000001015002100000018b0000013d000000000072004b000001890000813d0000000302700210000000f80220018f000000010300008a000000000223022f000000000232013f0000000003050433000000000223016f000000000021041b00000001010000390000000102700210000000000112019f000000000010041b000001000080044300000120000004430000008401000041000001f00001042e0000001f0010008c000001ae0000a13d000000000391016f00000020040000390000008302000041000000000000043f0000000005000019000000000035004b0000008006400039000001a10000813d0000000006060433000000000062041b000000200550003900000020044000390000000102200039000001980000013d000000000013004b000001ab0000813d0000000303100210000000f80330018f000000010400008a000000000334022f000000000343013f0000000004060433000000000334016f000000000032041b00000001020000390000000103100210000001b80000013d000000000001004b0000000002000019000001b20000613d000000a00200043d0000000303100210000000010400008a000000000334022f000000000343013f000000000332016f0000000102100210000000000123019f000000000010041b0000000001000019000001f00001042e0000001f02200039000000200300008a000000000232016f0000000001120019000000000021004b00000000020000390000000102004039000000800010009c000001c90000213d0000000100200190000001c90000c13d000000400010043f000000000001042d0000008801000041000000000010043f0000004101000039000000040010043f0000008901000041000001f1000104300000007d0010009c0000007d0100804100000040011002100000007d0020009c0000007d020080410000006002200210000000000112019f000000e002300210000000000121019f000001f00001042e0000007d0010009c0000007d01008041000000600110021000000000020004140000007d0020009c0000007d02008041000000c002200210000000000112019f0000008a011001c7000080100200003901ef01ea0000040f0000000100200190000001e80000613d000000000101043b000000000001042d0000000001000019000001f100010430000001ed002104230000000102000039000000000001042d0000000002000019000000000001042d000001ef00000432000001f00001042e000001f1000104300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000001ffffffe000000000000000000000000000000000000000000000000000000000ffffffe0000000000000000000000000000000000000000000000000ffffffffffffffff8000000000000000000000000000000000000000000000000000000000000000d6f21326ab749d5729fcba5677c79037b459436ab7bff709c9d06ce9f10c1a9d290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563000000020000000000000000000000000000004000000100000000000000000000000000000000000000000000000000000000000000000000000000cfae321700000000000000000000000000000000000000000000000000000000a4136862000000000000000000000000000000000000000000000000ffffffffffffff7f4e487b7100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a51d2e13c12093a421b91e8cc786a55312ca8850ffda3475747716ceca929ad8",
"constructor_arguments": "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000094869207468657265210000000000000000000000000000000000000000000000",
"zk_compiler_version": "v1.5.6",
"evm_compiler_version": "v0.8.28+commit.7893614a",
"input": {"language":"Solidity","sources":{"src/Greeter.sol":{"content":"//SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\ncontract Greeter {\n string private greeting;\n\n constructor(string memory _greeting) {\n greeting = _greeting;\n }\n\n function greet() public view returns (string memory) {\n return greeting;\n }\n\n function setGreeting(string memory _greeting) public {\n greeting = _greeting;\n }\n}\n\n"}},"settings":{"viaIR":false,"remappings":["forge-std/=lib/forge-std/src/","forge-zksync-std/=lib/forge-zksync-std/src/"],"evmVersion":"cancun","outputSelection":{"*":{"*":["abi"]}},"optimizer":{"enabled":true,"mode":"z","fallback_to_optimizing_for_size":false,"disable_system_request_memoization":true},"metadata":{},"libraries":{},"detectMissingLibraries":false,"enableEraVMExtensions":false,"forceEVMLA":false}},
"file_name": "src/Greeter.sol",
"contract_name": "Greeter",
"expected_sources": {
"src/Greeter.sol": "//SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\ncontract Greeter {\n string private greeting;\n\n constructor(string memory _greeting) {\n greeting = _greeting;\n }\n\n function greet() public view returns (string memory) {\n return greeting;\n }\n\n function setGreeting(string memory _greeting) public {\n greeting = _greeting;\n }\n}\n\n"
},
"expected_compilation_artifacts": {"abi":[{"inputs":[{"internalType":"string","name":"_greeting","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"greet","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_greeting","type":"string"}],"name":"setGreeting","outputs":[],"stateMutability":"nonpayable","type":"function"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1},"storageLayout":{"storage":[{"astId":3,"contract":"src/Greeter.sol:Greeter","label":"greeting","offset":0,"slot":"0","type":"t_string_storage"}],"types":{"t_string_storage":{"encoding":"bytes","label":"string","numberOfBytes":"32"}}}},
"expected_creation_code_artifacts": {},
"expected_runtime_code_artifacts": {},

"expected_creation_match_type": "full",
"expected_creation_transformations": [
{
"type": "insert",
"reason": "constructor",
"offset": 4512
}
],
"expected_creation_values": {
"constructorArguments": "0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000094869207468657265210000000000000000000000000000000000000000000000"
},
"expected_runtime_match_type": "full",
"expected_runtime_transformations": [],
"expected_runtime_values": {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,27 @@ async fn zksolc_1_3_5() {
test_case.check_verify_response(response);
}

// Era Solidity compilers are forks of Solidity compilers created by zksync.
// They are used by foundry and hardhat tools and affect metadata hash of compiled contracts.
#[tokio::test]
async fn era_solidity_compiled_standard_json() {
const ROUTE: &str = "/api/v2/zksync-verifier/solidity/sources:verify-standard-json";

let test_case = types::from_file::<StandardJson>("era_solidity_0.8.28");

let server = super::start().await;

let request = test_case.to_request();
let response: VerifyResponse = blockscout_service_launcher::test_server::send_post_request(
&server.base_url,
ROUTE,
&request,
)
.await;

test_case.check_verify_response(response);
}

#[tokio::test]
async fn cannot_compile() {
const ROUTE: &str = "/api/v2/zksync-verifier/solidity/sources:verify-standard-json";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod version_detailed;

pub use compilers::{CompilerInput, Compilers, Error, EvmCompiler};
pub use download_cache::DownloadCache;
pub use fetcher::{FetchError, Fetcher, FileValidator, Version};
pub use fetcher::{Fetcher, FileValidator, Version};
pub use fetcher_list::ListFetcher;
pub use fetcher_s3::S3Fetcher;
pub use version_compact::CompactVersion;
Expand Down
7 changes: 7 additions & 0 deletions smart-contract-verifier/smart-contract-verifier/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,10 @@ pub const DEFAULT_ZKSOLC_COMPILER_LIST: &str =
#[cfg(target_os = "macos")]
pub const DEFAULT_ZKSOLC_COMPILER_LIST: &str =
"https://raw.githubusercontent.com/blockscout/solc-bin/main/zksolc.macosx-arm64.list.json";

#[cfg(target_os = "linux")]
pub const DEFAULT_ERA_SOLIDITY_COMPILER_LIST: &str =
"https://raw.githubusercontent.com/blockscout/solc-bin/main/era-solidity.linux-amd64.list.json";
#[cfg(target_os = "macos")]
pub const DEFAULT_ERA_SOLIDITY_COMPILER_LIST: &str =
"https://raw.githubusercontent.com/blockscout/solc-bin/main/era-solidity.macosx-arm64.list.json";
4 changes: 2 additions & 2 deletions smart-contract-verifier/smart-contract-verifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ pub mod zksync;
pub(crate) use blockscout_display_bytes::Bytes as DisplayBytes;

pub use consts::{
DEFAULT_SOLIDITY_COMPILER_LIST, DEFAULT_SOURCIFY_HOST, DEFAULT_VYPER_COMPILER_LIST,
DEFAULT_ZKSOLC_COMPILER_LIST,
DEFAULT_ERA_SOLIDITY_COMPILER_LIST, DEFAULT_SOLIDITY_COMPILER_LIST, DEFAULT_SOURCIFY_HOST,
DEFAULT_VYPER_COMPILER_LIST, DEFAULT_ZKSOLC_COMPILER_LIST,
};

pub use middleware::Middleware;
Expand Down
Loading
Loading