Skip to content

Commit

Permalink
feat: calculate-hashes command to detect contract changes (#37)
Browse files Browse the repository at this point in the history
* feat: calculate-hashes

* fix: build-yul command updated

* chore: CI workflow renamed

* feat(calculate-hashes): "--check-only" flag added

* ci: calculate-hashes added to pipeline

* modifying hash to test calculate-hashes in CI

* Revert "modifying hash to test calculate-hashes in CI"

This reverts commit 639650b3dfb4fcc7f64e75f316aa6262976c4c3f.

* chore: bytecodeHash renamed

* chore: importing and typo

* feat: revert command renames

* chore: major calculate-hashes refactor

* ci: check hashes into separate job

* ci: yarn cacheing

* fix: absolutePath

* fix: hash updated

* fix: SHA256 hash updated

* docs: readme updated

* chore: changed hashes to array

* chore: SystemContractsHashes updated

* lint(calculate-hashes): format+lint

* docs: command name typo

* fix: calculate hashes updated

* chore: automatic contracts details generation

* chore: changed the order of json properties
  • Loading branch information
benceharomi authored Oct 18, 2023
1 parent efc9637 commit 08d54d5
Show file tree
Hide file tree
Showing 6 changed files with 455 additions and 1 deletion.
34 changes: 34 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 18.18.0
cache: yarn

- name: Install dependencies
run: yarn
Expand Down Expand Up @@ -52,6 +53,39 @@ jobs:
- name: Run lint
run: yarn lint

check_hashes:
needs: [build]
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18.18.0
cache: yarn

- name: Install dependencies
run: yarn

- name: Restore artifacts cache
uses: actions/cache/restore@v3
with:
fail-on-cache-miss: true
key: artifacts-${{ github.sha }}
path: |
artifacts-zk
cache-zk
typechain-types
contracts/artifacts
contracts/precompiles/artifacts
bootloader/build
- name: Check hashes
run: yarn calculate-hashes --check-only

test:
needs: [build, lint]
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ This repository is used as a submodule of the [zksync-2-dev](https://github.com/

Compile the solidity and yul contracts: `yarn build`

Check the system contracts hashes: `yarn calculate-hashes --check-only`

Update the system contracts hashes: `yarn calculate-hashes`

## Update Process

System contracts handle core functionalities and play a critical role in maintaining the integrity of our protocol. To
Expand Down
177 changes: 177 additions & 0 deletions SystemContractsHashes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
[
{
"contractName": "AccountCodeStorage",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/AccountCodeStorage.sol/AccountCodeStorage.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/AccountCodeStorage.sol",
"bytecodeHash": "0x0100009b3cd9a137912ffbd406a1d73eaffbcf40a760f3956fea7e051f0c6101",
"sourceCodeHash": "0xf56f18d6ccec4a1e083ece9d5dea511b610905b3be42bf81e81e53f8a7028162"
},
{
"contractName": "BootloaderUtilities",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/BootloaderUtilities.sol/BootloaderUtilities.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/BootloaderUtilities.sol",
"bytecodeHash": "0x01000975e811c2ba4a3b28f70426598129f0029feb086714980f9513f59531c7",
"sourceCodeHash": "0xcb8d18786a9dca90524de992e3216f57d89192600c2aa758f071a6a6ae3162c4"
},
{
"contractName": "ComplexUpgrader",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/ComplexUpgrader.sol/ComplexUpgrader.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/ComplexUpgrader.sol",
"bytecodeHash": "0x0100005b2eef785c804dc40ec24b3c2339b11a314fec6eb91db551a2523d6a2b",
"sourceCodeHash": "0x02b3234b8aa3dde88cf2cf6c1447512dd953ed355be9ba21c22d48ca6d3eee67"
},
{
"contractName": "Compressor",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/Compressor.sol/Compressor.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/Compressor.sol",
"bytecodeHash": "0x010001b7a7bb988e52b8fca05d82bccf63ea34c6617ebea1765c91e911386756",
"sourceCodeHash": "0x214a2b123ecdf3b135709d0b6207b3d41d9e8c68a0aa74b88c64fc983382d7b0"
},
{
"contractName": "ContractDeployer",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/ContractDeployer.sol/ContractDeployer.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/ContractDeployer.sol",
"bytecodeHash": "0x010005bb3e1bb343565920b37c6c0d716dcfca45bbdada20a305e80ab60a6916",
"sourceCodeHash": "0xed9088758b3cbc9c450da0ac18e0e11359efe7341219ac1c331a4f5712c2dacb"
},
{
"contractName": "DefaultAccount",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/DefaultAccount.sol/DefaultAccount.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/DefaultAccount.sol",
"bytecodeHash": "0x0100065d0ea6130f484f6cd4936f2d5114abc9961328d6acd8b311dd00b94546",
"sourceCodeHash": "0x34aaf3d8fbe90cf35efcfa5d8361de8a97be0a7cb60b9b117cda0dfd78fab6a6"
},
{
"contractName": "EmptyContract",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/EmptyContract.sol/EmptyContract.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/EmptyContract.sol",
"bytecodeHash": "0x01000007c08e60bc60d70f759bc49f2488b70054b0cec1a64f0cf27953448f4c",
"sourceCodeHash": "0x34cf9324829a0a1653486242a5dbee58aa93a8b9888415791bafe2c7a966400d"
},
{
"contractName": "ImmutableSimulator",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/ImmutableSimulator.sol/ImmutableSimulator.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/ImmutableSimulator.sol",
"bytecodeHash": "0x01000047b7e40b0e0f7bd7051e20853a49b972c6c0ac16872425067cb3288f08",
"sourceCodeHash": "0x315e71df564977165decbbbda504fee9d3dd98b6ca1e5dc68572d74bc308b03f"
},
{
"contractName": "KnownCodesStorage",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/KnownCodesStorage.sol/KnownCodesStorage.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/KnownCodesStorage.sol",
"bytecodeHash": "0x0100008b806f904a40cadb94318db1d8a8ae9a579f46ee0b50432e4c221572ee",
"sourceCodeHash": "0x33c7e9af04650d7e802ecfcf099fefde1ddb1a4268f521c0d69dea014ce5853d"
},
{
"contractName": "L1Messenger",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/L1Messenger.sol/L1Messenger.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/L1Messenger.sol",
"bytecodeHash": "0x010002fb863dc09dbfdae276418c307eb39af03f335a0b23a2edc8bcd1835fce",
"sourceCodeHash": "0x1c355d04ecf4e4c39ab6481f2bb17e5e30d3aa4563342aaa4c9aa122ac3a14d3"
},
{
"contractName": "L2EthToken",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/L2EthToken.sol/L2EthToken.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/L2EthToken.sol",
"bytecodeHash": "0x01000139b0930df0818b0f10f7c78feed9ca93020efcb72e749a7ea842d08576",
"sourceCodeHash": "0xb8e404a5e82c50b9f0cfb6412049d1174df3fbe8af40750a756ad0c1cfefb593"
},
{
"contractName": "MsgValueSimulator",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/MsgValueSimulator.sol/MsgValueSimulator.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/MsgValueSimulator.sol",
"bytecodeHash": "0x0100006f5dab2685a586d5ebbd360a2c1c2d593df1ab8267d8e172d92a202bfa",
"sourceCodeHash": "0x038cc8e7fe97ad4befa2d5ab4ae77fdefdecc20338142565b8086cd9342868ef"
},
{
"contractName": "NonceHolder",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/NonceHolder.sol/NonceHolder.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/NonceHolder.sol",
"bytecodeHash": "0x0100012f7252eee16af884775bd3279b577bbed64f124349ac6179aeb6ae3cb8",
"sourceCodeHash": "0xdfdd234e9d7f6cc7dfb0b9c8b6a2dea3dc40204539bfb836c9ae2bb1dc9cbb1f"
},
{
"contractName": "SystemContext",
"bytecodePath": "artifacts-zk/cache-zk/solpp-generated-contracts/SystemContext.sol/SystemContext.json",
"sourceCodePath": "cache-zk/solpp-generated-contracts/SystemContext.sol",
"bytecodeHash": "0x0100023f1761d12df53e8581fabcb359cb069bbd2a7a7a3ef0b49f2f5d46169a",
"sourceCodeHash": "0x60d9007efb7f1bf9417f0856f3799937357a64c2e5f858d13d3ee584e8b9832e"
},
{
"contractName": "EventWriter",
"bytecodePath": "contracts/artifacts/EventWriter.yul/EventWriter.yul.zbin",
"sourceCodePath": "contracts/EventWriter.yul",
"bytecodeHash": "0x01000019642d87621fdd82cf65aa9146486c9256d5f8849af9a37c78ef519339",
"sourceCodeHash": "0x55cfee65f174350edfd690c949bc0a29458f25da11f1d5f90b57621567df1fc3"
},
{
"contractName": "EcAdd",
"bytecodePath": "contracts/precompiles/artifacts/EcAdd.yul/EcAdd.yul.zbin",
"sourceCodePath": "contracts/precompiles/EcAdd.yul",
"bytecodeHash": "0x010000c56c054a0de4a36b133d3c114ec514c3ce0334ad7759c202392386a913",
"sourceCodeHash": "0xe73c8960a8b4060113adca9f03207d379580d172df9f0b499dd5353934a557a6"
},
{
"contractName": "EcMul",
"bytecodePath": "contracts/precompiles/artifacts/EcMul.yul/EcMul.yul.zbin",
"sourceCodePath": "contracts/precompiles/EcMul.yul",
"bytecodeHash": "0x010001378d31273c8e58caa12bcf1a5694e66a0aefdba2504adb8e3eb02b21c7",
"sourceCodeHash": "0x6c4b11542bcf85e6e02ca193fc0548353b1f21c27e972b9e73781e8f7eaf50b0"
},
{
"contractName": "Ecrecover",
"bytecodePath": "contracts/precompiles/artifacts/Ecrecover.yul/Ecrecover.yul.zbin",
"sourceCodePath": "contracts/precompiles/Ecrecover.yul",
"bytecodeHash": "0x010000114daca2ff44f27d543b8ef67d885bfed09a74ba9cb25f5912dd3d739c",
"sourceCodeHash": "0x18eac0a993afec4112da99fc8e2978891598ab12566528628896f430c855fb81"
},
{
"contractName": "Keccak256",
"bytecodePath": "contracts/precompiles/artifacts/Keccak256.yul/Keccak256.yul.zbin",
"sourceCodePath": "contracts/precompiles/Keccak256.yul",
"bytecodeHash": "0x0100001fb52ca33668d01c230a1c3b13ede90fe2e37d77222410e9f183cb7a89",
"sourceCodeHash": "0x6415e127a4e07907fb87d0cbdf480fff8c70326c4f2f670af0cf3248862e4df4"
},
{
"contractName": "SHA256",
"bytecodePath": "contracts/precompiles/artifacts/SHA256.yul/SHA256.yul.zbin",
"sourceCodePath": "contracts/precompiles/SHA256.yul",
"bytecodeHash": "0x010000178d93b2d7d6448866009892223caf018a8e8dbcf090c2b9053a285f8d",
"sourceCodeHash": "0x8f5a719394836111c850774e89ffb22ef825ff4d24d116ca750888be906f0109"
},
{
"contractName": "bootloader_test",
"bytecodePath": "bootloader/build/artifacts/bootloader_test.yul/bootloader_test.yul.zbin",
"sourceCodePath": "bootloader/build/bootloader_test.yul",
"bytecodeHash": "0x0100037b0462ed355364eaabccbea2a018afad4c8841b9856514c027400f1b10",
"sourceCodeHash": "0x467a36057882d6740a016cda812798d1be9a0ea60cb7ef90996e2c5be55e75a4"
},
{
"contractName": "fee_estimate",
"bytecodePath": "bootloader/build/artifacts/fee_estimate.yul/fee_estimate.yul.zbin",
"sourceCodePath": "bootloader/build/fee_estimate.yul",
"bytecodeHash": "0x010009434283c0bc9f32e51a9aa84523ee7a381e3e0c5ae63f639998d915f54b",
"sourceCodeHash": "0x3fb415ac6f59c35ea17b85aabb551df1b44a6fc7e051c2e33f5fc76c17432167"
},
{
"contractName": "gas_test",
"bytecodePath": "bootloader/build/artifacts/gas_test.yul/gas_test.yul.zbin",
"sourceCodePath": "bootloader/build/gas_test.yul",
"bytecodeHash": "0x01000927ea81a1afe5a586853a9c43fb928bcf1f1fba51a19c48ce1b940867c7",
"sourceCodeHash": "0x84648c958714d952248b8553456b5a5e3860e00871f01644297531e991a67d64"
},
{
"contractName": "playground_batch",
"bytecodePath": "bootloader/build/artifacts/playground_batch.yul/playground_batch.yul.zbin",
"sourceCodePath": "bootloader/build/playground_batch.yul",
"bytecodeHash": "0x0100094d801bf4180d020692a95cf26a3c9adcaedfd5be47ec08b1637b0282da",
"sourceCodeHash": "0xe02bed16015da2f03dcf5a7ed1bf2132009e69f4bfb5335e13cc406327e84d5e"
},
{
"contractName": "proved_batch",
"bytecodePath": "bootloader/build/artifacts/proved_batch.yul/proved_batch.yul.zbin",
"sourceCodePath": "bootloader/build/proved_batch.yul",
"bytecodeHash": "0x010009411d9c2342671c57d5ce038ce3e142c750df85ac5d23f67b4e4215fede",
"sourceCodeHash": "0xd48e5abbfbb493eacfcbe6dc788eada867d58ab8596d55736b496b1c2e22c636"
}
]
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
"@typechain/ethers-v5": "^10.0.0",
"@typechain/hardhat": "^7.0.0",
"@types/chai": "^4.3.1",
"@types/lodash": "^4.14.199",
"@types/mocha": "^9.1.1",
"@types/node": "^17.0.34",
"@typescript-eslint/eslint-plugin": "^6.7.4",
"@typescript-eslint/parser": "^6.7.4",
"chai": "^4.3.6",
"lodash": "^4.17.21",
"eslint": "^8.51.0",
"markdownlint-cli": "^0.33.0",
"mocha": "^10.0.0",
Expand All @@ -50,6 +52,7 @@
"build": "yarn build:sol && yarn build:yul",
"build:sol": "hardhat compile",
"build:yul": "yarn preprocess:yul && yarn compile-yul",
"calculate-hashes": "ts-node scripts/calculate-hashes.ts",
"clean": "yarn clean:sol && yarn clean:yul",
"clean:sol": "hardhat clean",
"clean:yul": "rm -rf ./bootloader/build ./bootloader/tests/artifacts ./contracts/artifacts ./contracts/precompiles/artifacts",
Expand All @@ -60,9 +63,9 @@
"lint:md": "markdownlint **/*.md",
"lint:sol": "solhint \"contracts/**/*.sol\"",
"lint:ts": "eslint .",
"preprocess:yul": "rm -rf ./bootloader/build && yarn ts-node scripts/process.ts",
"prettier:check": "prettier --check \"**/*.{js,json,md,sol,ts,yaml}\"",
"prettier:write": "prettier --write \"**/*.{js,json,md,sol,ts,yaml}\"",
"preprocess:yul": "rm -rf ./bootloader/build && yarn ts-node scripts/process.ts",
"test": "hardhat test --network zkSyncTestNode",
"test:bootloader": "cd bootloader/test_infra && cargo run"
}
Expand Down
Loading

0 comments on commit 08d54d5

Please sign in to comment.