Skip to content

Commit 0617794

Browse files
committed
Fix zk init
1 parent a459c3e commit 0617794

File tree

28 files changed

+162
-253
lines changed

28 files changed

+162
-253
lines changed

.githooks/pre-commit

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,3 @@ if ! cargo fmt -- --check; then
1212
echo "Please format the code via 'cargo fmt', cannot commit unformatted code"
1313
exit 1
1414
fi
15-
16-
VERFIER_CONTRACT_FILE="contracts/contracts/Verifier.sol"
17-
18-
# Check if diff for contract contains setting the `DUMMY_VERIFIER` to the true.
19-
if git diff --cached $VERFIER_CONTRACT_FILE | grep -lq 'constant DUMMY_VERIFIER = true'; then
20-
echo -e "${RED}Commit error!${NC}"
21-
echo "It seems that line 'constant DUMMY_VERIFIER = true' in 'Verifier.sol' is staged to be committed"
22-
echo "Cannot commit the code with enabled DUMMY_VERIFIER"
23-
echo "Please disable the DUMMY_VERIFIER and try to commit changes again"
24-
exit 1
25-
fi

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ jobs:
4040
yarn lint:sol
4141
# So database will be created for compilation.
4242
zk db setup
43-
zk dummy-prover ensure-disabled
4443
cargo fmt --all -- --check
4544
# For some reason, `cargo clippy` currently doesn't work in sqlx offline mod. So, we're checking it in online mode.
4645
zk f cargo clippy --tests --benches -- -D warnings
@@ -53,7 +52,7 @@ jobs:
5352
# Unpack keys to build dev contracts
5453
zk run verify-keys unpack
5554
# EIP1271 contract is used in Rust & JS unit tests.
56-
zk contract build-dev
55+
zk contract build
5756
zk run deploy-eip1271
5857
5958
- name: integration-tests

Cargo.lock

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ members = [
55
"core/bin/key_generator",
66
"core/bin/server",
77
"core/bin/prover",
8-
"core/bin/gen_token_add_contract",
98
"core/bin/parse_pub_data",
109

1110
# Server micro-services

contracts/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/build
22
# /contracts/keys
33
/contracts/KeysWithPlonkVerifier.sol
4-
/contracts/TokenInit.sol
54
/artifacts
65
/cache
7-
/contracts/dev-contracts/generated
86
/typechain

contracts/config/prod.json

Lines changed: 0 additions & 2 deletions
This file was deleted.

contracts/contracts/TokenInit.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
3+
pragma solidity ^0.7.0;
4+
5+
contract TokenDeployInit {
6+
function getTokens() internal pure returns (address[] memory) {
7+
address[] memory tokens = new address[](0);
8+
return tokens;
9+
}
10+
}

contracts/contracts/Verifier.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import "./KeysWithPlonkVerifier.sol";
77

88
// Hardcoded constants to avoid accessing store
99
contract Verifier is KeysWithPlonkVerifier {
10-
bool constant DUMMY_VERIFIER = $(DUMMY_VERIFIER);
11-
1210
function initialize(bytes calldata) external {}
1311

1412
/// @notice Verifier contract upgrade. Can be external because Proxy contract intercepts illegal calls of this function.
@@ -23,7 +21,8 @@ contract Verifier is KeysWithPlonkVerifier {
2321
uint256[16] memory _subproofs_limbs,
2422
bool blockProof
2523
) external view returns (bool) {
26-
if (DUMMY_VERIFIER && blockProof) {
24+
// #if DUMMY_VERIFIER
25+
if (blockProof) {
2726
uint256 oldGasValue = gasleft();
2827
uint256 tmp;
2928
while (gasleft() + 500000 > oldGasValue) {
@@ -36,6 +35,7 @@ contract Verifier is KeysWithPlonkVerifier {
3635
uint256 mask = (~uint256(0)) >> 3;
3736
_individual_vks_inputs[i] = uint256(commitment) & mask;
3837
}
38+
// #endif
3939
VerificationKey memory vk = getVkAggregated(uint32(_vkIndexes.length));
4040

4141
uint256 treeRoot = blockProof ? VK_TREE_ROOT : VK_EXIT_TREE_ROOT;

contracts/hardhat.config.ts

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,12 @@
11
import '@nomiclabs/hardhat-waffle';
22
import '@nomiclabs/hardhat-solpp';
3+
import '@nomiclabs/hardhat-etherscan';
34
import 'hardhat-typechain';
45
import 'hardhat-contract-sizer';
5-
import '@nomiclabs/hardhat-etherscan';
6-
7-
const prodConfig = {
8-
// UPGRADE_NOTICE_PERIOD: 0,
9-
MAX_AMOUNT_OF_REGISTERED_TOKENS: 127,
10-
// PRIORITY_EXPIRATION: 101,
11-
DUMMY_VERIFIER: false
12-
};
13-
const testnetConfig = {
14-
UPGRADE_NOTICE_PERIOD: 0,
15-
MAX_AMOUNT_OF_REGISTERED_TOKENS: 127,
16-
// PRIORITY_EXPIRATION: 101,
17-
DUMMY_VERIFIER: false
18-
};
19-
const testConfig = {
20-
UPGRADE_NOTICE_PERIOD: 0,
21-
MAX_AMOUNT_OF_REGISTERED_TOKENS: 5,
22-
PRIORITY_EXPIRATION: 101,
23-
DUMMY_VERIFIER: true
24-
};
25-
26-
const localConfig = Object.assign({}, prodConfig);
27-
localConfig.DUMMY_VERIFIER = process.env.DUMMY_VERIFIER ? true : localConfig.DUMMY_VERIFIER;
28-
29-
const contractDefs = {
30-
rinkeby: testnetConfig,
31-
ropsten: testnetConfig,
32-
mainnet: prodConfig,
33-
test: testConfig,
34-
localhost: localConfig
35-
};
6+
import { Network, loadDefs } from './hardhat.utils';
367

378
export default {
9+
defaultNetwork: 'env',
3810
solidity: {
3911
version: '0.7.3',
4012
settings: {
@@ -51,11 +23,11 @@ export default {
5123
sources: './contracts'
5224
},
5325
solpp: {
54-
defs: process.env.ETH_NETWORK ? contractDefs[process.env.ETH_NETWORK] : contractDefs['test']
26+
defs: loadDefs(process.env.ETH_NETWORK as Network)
5527
},
5628
networks: {
5729
env: {
58-
url: process.env.WEB3_URL
30+
url: `${process.env.WEB3_URL}`
5931
}
6032
},
6133
etherscan: {

contracts/hardhat.test-config.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import '@nomiclabs/hardhat-waffle';
2+
import '@nomiclabs/hardhat-solpp';
3+
import '@nomiclabs/hardhat-etherscan';
4+
import 'hardhat-contract-sizer';
5+
import { loadDefs } from './hardhat.utils';
6+
7+
export default {
8+
defaultNetwork: 'env',
9+
solidity: {
10+
version: '0.7.3',
11+
settings: {
12+
optimizer: {
13+
enabled: true,
14+
runs: 200
15+
}
16+
}
17+
},
18+
contractSizer: {
19+
runOnCompile: false
20+
},
21+
paths: {
22+
sources: './contracts',
23+
cache: './cache/test-contracts',
24+
artifacts: './artifacts/test-contracts'
25+
},
26+
solpp: {
27+
defs: loadDefs('test')
28+
},
29+
networks: {
30+
env: {
31+
url: `${process.env.WEB3_URL}`,
32+
allowUnlimitedContractSize: true
33+
}
34+
},
35+
etherscan: {
36+
apiKey: process.env.ETHERSCAN_API_KEY
37+
}
38+
};

0 commit comments

Comments
 (0)