Skip to content

Commit

Permalink
fix issues with detecting upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless committed Oct 1, 2023
1 parent 9557e3e commit 6bfa1bf
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 10 deletions.
12 changes: 11 additions & 1 deletion core/lib/zksync_core/src/eth_watch/event_processors/upgrades.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::eth_watch::{
};
use std::convert::TryFrom;
use std::time::Instant;
use zksync_contracts::governance_contract;
use zksync_contracts::{governance_contract, zksync_contract};
use zksync_dal::StorageProcessor;
use zksync_types::{
protocol_version::GovernanceOperation, web3::types::Log, Address, ProtocolUpgrade,
Expand All @@ -17,6 +17,7 @@ pub struct UpgradesEventProcessor {
diamond_proxy_address: Address,
last_seen_version_id: ProtocolVersionId,
upgrade_proposal_signature: H256,
execute_upgrade_short_signature: [u8; 4],
}

impl UpgradesEventProcessor {
Expand All @@ -28,6 +29,10 @@ impl UpgradesEventProcessor {
.event("TransparentOperationScheduled")
.expect("TransparentOperationScheduled event is missing in abi")
.signature(),
execute_upgrade_short_signature: zksync_contract()
.function("executeUpgrade")
.unwrap()
.short_signature(),
}
}
}
Expand All @@ -53,8 +58,13 @@ impl<W: EthClient + Sync> EventProcessor<W> for UpgradesEventProcessor {
.into_iter()
.filter(|call| call.target == self.diamond_proxy_address)
{
if call.data.len() < 4 || &call.data[..4] != &self.execute_upgrade_short_signature {
continue;
}

let upgrade = ProtocolUpgrade::try_from(call)
.map_err(|err| Error::LogParse(format!("{:?}", err)))?;

// Scheduler VK is not present in proposal event. It is hardcoded in verifier contract.
let scheduler_vk_hash = if let Some(address) = upgrade.verifier_address {
Some(client.scheduler_vk_hash(address).await?)
Expand Down
5 changes: 4 additions & 1 deletion core/tests/ts-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"devDependencies": {
"@matterlabs/hardhat-zksync-deploy": "^0.6.1",
"@matterlabs/hardhat-zksync-solc": "^0.3.15",
"@matterlabs/hardhat-zksync-solc": "0.4.2",
"@matterlabs/hardhat-zksync-vyper": "^0.2.0",
"@nomiclabs/hardhat-vyper": "^3.0.3",
"@types/jest": "^29.0.3",
Expand All @@ -29,5 +29,8 @@
"ts-node": "^10.1.0",
"typescript": "^4.3.5",
"zksync-web3": "link:../../../sdk/zksync-web3.js"
},
"dependencies": {
"@matterlabs/hardhat-zksync-solc": "0.4.2"
}
}
18 changes: 11 additions & 7 deletions core/tests/ts-integration/scripts/compile-yul.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import * as hre from 'hardhat';
import * as fs from 'fs';
import { spawn as _spawn } from 'child_process';
import { exec as _exec, spawn as _spawn } from 'child_process';

import { getZksolcPath, getZksolcUrl, saltFromUrl } from '@matterlabs/hardhat-zksync-solc';
import { getZksolcUrl, saltFromUrl } from '@matterlabs/hardhat-zksync-solc';
import { getCompilersDir } from 'hardhat/internal/util/global-dir';
import path from 'path';

const COMPILER_VERSION = '1.3.14';
const IS_COMPILER_PRE_RELEASE = false;

async function compilerLocation(): Promise<string> {
const compilersCache = await getCompilersDir();

let salt = '';

if (IS_COMPILER_PRE_RELEASE) {
const url = getZksolcUrl('https://github.com/matter-labs/zksolc-prerelease', hre.config.zksolc.version);
const salt = saltFromUrl(url);
return await getZksolcPath(COMPILER_VERSION, salt);
} else {
return await getZksolcPath(COMPILER_VERSION, '');
salt = saltFromUrl(url);
}

return path.join(compilersCache, 'zksolc', `zksolc-v${COMPILER_VERSION}${salt ? '-' : ''}${salt}`);
}

// executes a command in a new shell
// but pipes data to parent's stdout/stderr
export function spawn(command: string) {
command = command.replace(/\n/g, ' ');
Expand Down
42 changes: 41 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1393,6 +1393,18 @@
chalk "4.1.2"
dockerode "^3.3.4"

"@matterlabs/[email protected]":
version "0.4.2"
resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-solc/-/hardhat-zksync-solc-0.4.2.tgz#64121082e88c5ab22eb4e9594d120e504f6af499"
integrity sha512-6NFWPSZiOAoo7wNuhMg4ztj7mMEH+tLrx09WuCbcURrHPijj/KxYNsJD6Uw5lapKr7G8H7SQISGid1/MTXVmXQ==
dependencies:
"@nomiclabs/hardhat-docker" "^2.0.0"
chalk "4.1.2"
dockerode "^3.3.4"
fs-extra "^11.1.1"
proper-lockfile "^4.1.2"
semver "^7.5.1"

"@matterlabs/hardhat-zksync-solc@^0.3.15":
version "0.3.16"
resolved "https://registry.yarnpkg.com/@matterlabs/hardhat-zksync-solc/-/hardhat-zksync-solc-0.3.16.tgz#dd8ed44f1a580f282794a15fee995f418b040158"
Expand Down Expand Up @@ -6528,6 +6540,15 @@ fs-extra@^0.30.0:
path-is-absolute "^1.0.0"
rimraf "^2.2.8"

fs-extra@^11.1.1:
version "11.1.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.1.1.tgz#da69f7c39f3b002378b0954bb6ae7efdc0876e2d"
integrity sha512-MGIE4HOvQCeUCzmlHs0vXpih4ysz4wg9qiSAu6cd42lVwPbTM1TjV7RusoyQqMmk/95gdQZX72u+YW+c3eEpFQ==
dependencies:
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^2.0.0"

fs-extra@^4.0.2, fs-extra@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-4.0.3.tgz#0d852122e5bc5beb453fb028e9c0c9bf36340c94"
Expand Down Expand Up @@ -6947,6 +6968,11 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9,
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c"
integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==

graceful-fs@^4.2.4:
version "4.2.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==

"graceful-readlink@>= 1.0.0":
version "1.0.1"
resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725"
Expand Down Expand Up @@ -10422,6 +10448,15 @@ prompts@^2.0.1:
kleur "^3.0.3"
sisteransi "^1.0.5"

proper-lockfile@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/proper-lockfile/-/proper-lockfile-4.1.2.tgz#c8b9de2af6b2f1601067f98e01ac66baa223141f"
integrity sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==
dependencies:
graceful-fs "^4.2.4"
retry "^0.12.0"
signal-exit "^3.0.2"

proxy-addr@~2.0.7:
version "2.0.7"
resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025"
Expand Down Expand Up @@ -11001,6 +11036,11 @@ ret@~0.1.10:
resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc"
integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==

retry@^0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/retry/-/retry-0.12.0.tgz#1b42a6266a21f07421d1b0b54b7dc167b01c013b"
integrity sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==

reusify@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76"
Expand Down Expand Up @@ -11191,7 +11231,7 @@ semver@^7.3.4:
dependencies:
lru-cache "^6.0.0"

semver@^7.3.8, semver@^7.5.2:
semver@^7.3.8, semver@^7.5.1, semver@^7.5.2:
version "7.5.4"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e"
integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==
Expand Down

0 comments on commit 6bfa1bf

Please sign in to comment.