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

Use unchecked in DepositContract.sol #366

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
22 changes: 12 additions & 10 deletions contracts/lib/DepositContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,19 @@ contract DepositContract is ReentrancyGuardUpgradeable {
}

// Add deposit data root to Merkle tree (update a single `_branch` node)
uint256 size = ++depositCount;
for (
uint256 height = 0;
height < _DEPOSIT_CONTRACT_TREE_DEPTH;
height++
) {
if (((size >> height) & 1) == 1) {
_branch[height] = node;
return;
unchecked {
uint256 size = ++depositCount;
for (
uint256 height = 0;
height < _DEPOSIT_CONTRACT_TREE_DEPTH;
height++
) {
if (((size >> height) & 1) == 1) {
_branch[height] = node;
return;
}
node = keccak256(abi.encodePacked(_branch[height], node));
}
node = keccak256(abi.encodePacked(_branch[height], node));
}
// As the loop should always end prematurely with the `return` statement,
// this code should be unreachable. We assert `false` just to be safe.
Expand Down
4 changes: 2 additions & 2 deletions verifyMainnetDeployment/verifyMainnetProofVerifier.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ git checkout 4a237f1c5d770373c9ff19d75fe87890c4599878
git submodule init
git submodule update
sudo apt install -y build-essential libomp-dev libgmp-dev nlohmann-json3-dev libpqxx-dev nasm libgrpc++-dev libprotobuf-dev grpc-proto libsodium-dev uuid-dev libsecp256k1-dev
make -j bctree fflonkSetup
make -j bctree fflonk_setup
```

this step takes less than 1 minute.
Expand All @@ -81,7 +81,7 @@ this step takes less than 1 minute.
```bash
cd ~
git clone https://github.com/0xPolygonHermez/zkevm-proverjs.git
cd zkevm-proverjs
cd zkevm-proverjs
git checkout cec76cc411838b78d3649543fb0fca712317c713
npm install
tmux -c "npm run buildsetup --bctree=../zkevm-prover/build/bctree --fflonksetup=../zkevm-prover/build/fflonkSetup --mode=25"
Expand Down