Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

feat: calculate-hashes command to detect contract changes #37

Merged
merged 26 commits into from
Oct 18, 2023

Conversation

benceharomi
Copy link
Contributor

@benceharomi benceharomi commented Oct 6, 2023

What ❔

Created a calculate-hashes script that saves the hash of the preprocessed source code and bytecode of the system contracts.

Why ❔

We should clearly see when bootloader (and account abstraction) hashes have changed.

We should have a file in the repo, that contains the current hashes (of both compiled and source codes - as for bootloader and AA - we actually do some preprocessing of the source code).

we could have a small tool in era-system-contracts, that computes the hash of the compiled file (using zksync_utils::bytecode::hash_bytecode) and also a hash of the source code - and compares it with the hashes that are in the file.

This way, whenever we do the change, the PR would also contain the changes to that file.

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted via yarn prettier:write and yarn lint:fix.

@benceharomi benceharomi marked this pull request as draft October 6, 2023 17:16
@benceharomi benceharomi requested a review from mm-zk October 8, 2023 14:06
@benceharomi benceharomi marked this pull request as ready for review October 8, 2023 14:06
@benceharomi benceharomi marked this pull request as draft October 8, 2023 14:06
SystemContractsHashes.json Outdated Show resolved Hide resolved
scripts/calculate-hashes.ts Outdated Show resolved Hide resolved
scripts/calculate-hashes.ts Outdated Show resolved Hide resolved
scripts/calculate-hashes.ts Outdated Show resolved Hide resolved
scripts/calculate-hashes.ts Outdated Show resolved Hide resolved
scripts/calculate-hashes.ts Outdated Show resolved Hide resolved
@benceharomi benceharomi marked this pull request as ready for review October 11, 2023 20:55
@benceharomi benceharomi requested a review from mm-zk October 12, 2023 16:21
scripts/calculate-hashes.ts Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
scripts/calculate-hashes.ts Outdated Show resolved Hide resolved
@benceharomi benceharomi changed the title feat: calculate-hashes feat: calculate-hashes to detect contract changes Oct 18, 2023
@benceharomi benceharomi changed the title feat: calculate-hashes to detect contract changes feat: calculate-hashes command to detect contract changes Oct 18, 2023
@benceharomi benceharomi merged commit 08d54d5 into dev Oct 18, 2023
8 checks passed
@benceharomi benceharomi deleted the bh-evm-290-detect-when-bootloader-hash-has-changed branch October 18, 2023 13:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants