From bf5581f764e264b2a7adad3bda652fdf2336ff34 Mon Sep 17 00:00:00 2001 From: Alexey Date: Fri, 26 Feb 2021 12:14:43 +0300 Subject: [PATCH] changeTreeHeight script --- .github/workflows/build.yml | 3 ++- contracts/mocks/Pack.sol | 2 +- package.json | 1 + scripts/changeTreeHeight.sh | 7 +++++++ test/pack.test.js | 2 +- 5 files changed, 12 insertions(+), 3 deletions(-) create mode 100755 scripts/changeTreeHeight.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a54453e..312ff9a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,8 +15,9 @@ jobs: - uses: actions/setup-node@v1 with: node-version: 12 - - run: yarn install - run: cargo install zkutil + - run: yarn install + - run: yarn changeTreeHeight 2 - run: yarn circuit - run: yarn test - run: yarn lint diff --git a/contracts/mocks/Pack.sol b/contracts/mocks/Pack.sol index a32c5e1..7c8a4f7 100644 --- a/contracts/mocks/Pack.sol +++ b/contracts/mocks/Pack.sol @@ -3,7 +3,7 @@ pragma solidity ^0.6.0; contract Pack { - uint256 public constant CHUNK_TREE_HEIGHT = 7; + uint256 public constant CHUNK_TREE_HEIGHT = 8; uint256 public constant CHUNK_SIZE = 2**CHUNK_TREE_HEIGHT; uint256 public constant ITEM_SIZE = 32 + 20 + 4; uint256 public constant BYTES_SIZE = CHUNK_SIZE * ITEM_SIZE; diff --git a/package.json b/package.json index 3083b61..5c9f5c8 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "prettier:check": "prettier --check . --config .prettierrc", "prettier:fix": "prettier --write . --config .prettierrc", "lint": "yarn eslint && yarn prettier:check", + "changeTreeHeight": "scripts/changeTreeHeight.sh", "circuit:batchTreeUpdate": "scripts/buildCircuit.sh BatchTreeUpdate", "circuit:batchTreeUpdateLarge": "scripts/buildCircuit.sh BatchTreeUpdate large", "circuit:batchTreeUpdateWitness": "scripts/buildWitness.sh BatchTreeUpdate", diff --git a/scripts/changeTreeHeight.sh b/scripts/changeTreeHeight.sh new file mode 100755 index 0000000..003e8f3 --- /dev/null +++ b/scripts/changeTreeHeight.sh @@ -0,0 +1,7 @@ +#!/bin/bash +case $(sed --help 2>&1) in + *GNU*) sed_i () { xargs sed -i "$@"; };; + *) sed_i () { xargs sed -i '' "$@"; };; +esac + +grep -l --exclude-dir={.git,node_modules,artifacts} -r "CHUNK_TREE_HEIGHT = [0-9]" . | sed_i "s/CHUNK_TREE_HEIGHT = [0-9]/CHUNK_TREE_HEIGHT = ${1}/g" diff --git a/test/pack.test.js b/test/pack.test.js index aaac3c6..4bb982f 100644 --- a/test/pack.test.js +++ b/test/pack.test.js @@ -13,7 +13,7 @@ const hashes = [ '0x57f7b90a3cb4ea6860e6dd5fa44ac4f53ebe6ae3948af577a01ef51738313246', ] -const CHUNK_TREE_HEIGHT = 7 +const CHUNK_TREE_HEIGHT = 8 describe.skip('Pack', () => { it('should work', async () => { const Pack = await ethers.getContractFactory('Pack')