Skip to content

Commit 5ca582f

Browse files
fix: update config default.js
1 parent f821288 commit 5ca582f

1 file changed

Lines changed: 96 additions & 131 deletions

File tree

merkle-tree/config/default.js

Lines changed: 96 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,67 @@
1-
/**
2-
@module default.js
3-
@author iAmMichaelConnor
4-
@desc constants used by a nubmer of other modules
5-
*/
6-
7-
let nodeHashLength;
8-
let zero;
9-
10-
if (process.env.HASH_TYPE === 'mimc') {
11-
nodeHashLength = 32;
12-
if (process.env.CURVE === 'BLS12_377') {
13-
zero = 0;
14-
} else {
15-
zero = '0x0000000000000000000000000000000000000000000000000000000000000000';
16-
}
17-
} else {
18-
nodeHashLength = 27;
19-
zero = '0x000000000000000000000000000000000000000000000000000000';
20-
}
21-
221
module.exports = {
23-
// general:
24-
ZERO: zero,
25-
26-
// Tree parameters. You also need to set these in the MerkleTree.sol contract.
27-
28-
HASH_TYPE: process.env.HASH_TYPE,
29-
CURVE: process.env.CURVE,
2+
LOG_LEVEL: process.env.LOG_LEVEL,
3+
zokrates: {
4+
url: process.env.ZOKRATES_ENDPOINT,
5+
},
6+
merkleTree: {
7+
url: process.env.TIMBER_ENDPOINT,
8+
},
9+
transactionManager: {
10+
url: process.env.TRANSACTION_MANAGER_ENDPOINT,
11+
},
12+
blockchainEventManager: {
13+
url: process.env.BEM_ENDPOINT,
14+
},
15+
// merkle-tree stuff:
16+
ZERO: '0',
17+
HASH_TYPE: 'mimc',
18+
CURVE: 'ALT_BN_254',
3019
LEAF_HASHLENGTH: 32, // expected length of leaves' values in bytes
31-
NODE_HASHLENGTH: nodeHashLength, // expected length of nodes' values up the merkle tree, in bytes
32-
TREE_HEIGHT: 32, // the height of the Merkle tree
33-
20+
NODE_HASHLENGTH: 32, // expected length of nodes' values up the merkle tree, in bytes
3421
POLLING_FREQUENCY: 6000, // milliseconds
3522
FILTER_GENESIS_BLOCK_NUMBER: 0, // blockNumber
3623

24+
BN128_GROUP_ORDER: BigInt(
25+
'21888242871839275222246405745257275088548364400416034343698204186575808495617',
26+
),
27+
BN128_PRIME_FIELD: BigInt(
28+
'21888242871839275222246405745257275088696311157297823662689037894645226208583',
29+
),
30+
// the various parameters needed to describe the Babyjubjub curve
31+
// BABYJUBJUB
32+
// Montgomery EC form is y^2 = x^3 + Ax^2 + Bx
33+
// Montgomery EC form of BabyJubJub is y^2 = x^3 + 168698x^2 + x
34+
// A = 168698 and B = 1
35+
BABYJUBJUB: {
36+
JUBJUBA: BigInt(168700),
37+
JUBJUBD: BigInt(168696),
38+
INFINITY: [BigInt(0), BigInt(1)],
39+
GENERATOR: [
40+
BigInt(
41+
'16540640123574156134436876038791482806971768689494387082833631921987005038935',
42+
),
43+
BigInt(
44+
'20819045374670962167435360035096875258406992893633759881276124905556507972311',
45+
),
46+
],
47+
JUBJUBE: BigInt(
48+
'21888242871839275222246405745257275088614511777268538073601725287587578984328',
49+
),
50+
JUBJUBC: BigInt(8),
51+
MONTA: BigInt(168698),
52+
MONTB: BigInt(1),
53+
},
54+
3755
tolerances: {
3856
LAG_BEHIND_CURRENT_BLOCK: 5, // add warnings for use of tree data which lags further behind the current block (e.g. due to anonymity concerns)
3957
},
40-
41-
UPDATE_FREQUENCY: 100, // TODO: recalculate the tree every 'x' leaves - NOT USED YET
4258
BULK_WRITE_BUFFER_SIZE: 1000, // number of documents to add to a buffer before bulk-writing them to the db
43-
59+
contractOrigin: process.env.CONTRACT_LOCATION,
4460
// contracts to filter:
4561
contracts: {
46-
// contract name:
47-
// AssignShield: {
48-
// events: {
49-
// NewLeaf: {
50-
// parameters: ['leafIndex', 'leafValue'],
51-
// },
52-
// NewLeaves: {
53-
// parameters: ['minLeafIndex', 'leafValues'],
54-
// },
55-
// },
56-
// },
5762
// contract name:
58-
MerkleTreeControllerMiMC_BN254: {
63+
AssignShield: {
64+
treeHeight: 32,
5965
events: {
6066
// filter for the following event names:
6167
NewLeaf: {
@@ -68,7 +74,8 @@ module.exports = {
6874
},
6975
},
7076
},
71-
MerkleTreeControllerMiMC_BLS12: {
77+
AssignApiShield: {
78+
treeHeight: 32,
7279
events: {
7380
// filter for the following event names:
7481
NewLeaf: {
@@ -81,104 +88,62 @@ module.exports = {
8188
},
8289
},
8390
},
84-
// contract name:
85-
MerkleTreeControllerSHA: {
86-
events: {
87-
// filter for the following event names:
88-
NewLeaf: {
89-
// filter for these event parameters:
90-
parameters: ['leafIndex', 'leafValue'],
91-
},
92-
NewLeaves: {
93-
// filter for these event parameters:
94-
parameters: ['minLeafIndex', 'leafValues'],
95-
},
96-
},
97-
},
98-
// contract name:
99-
MultipleMerkleTreesControllerSHA: {
100-
treeId: {
101-
a: {
102-
treeHeight: 16,
103-
events: {
104-
// filter for the following event names:
105-
NewLeafA: {
106-
// filter for these event parameters when a single leaf is added:
107-
parameters: ['leafIndex', 'leafValue'],
108-
},
109-
NewLeavesA: {
110-
// filter for these event parameters when multiple leaves are added:
111-
parameters: ['minLeafIndex', 'leafValues'],
112-
},
113-
},
114-
},
115-
b: {
116-
treeHeight: 10,
117-
events: {
118-
// filter for the following event names:
119-
NewLeafB: {
120-
// filter for these event parameters:
121-
parameters: ['leafIndex', 'leafValue'],
122-
},
123-
NewLeavesB: {
124-
// filter for these event parameters:
125-
parameters: ['minLeafIndex', 'leafValues'],
126-
},
127-
},
128-
},
129-
},
130-
},
13191
},
132-
133-
/*
134-
# Where to find the contractInstances?
135-
# Specify one of:
136-
# - 'remote' (to GET them from a remote microservice); or
137-
# - 'mongodb' (to get them from mongodb); or
138-
# - 'compile' (to compile the contracts from /app/build to /app/build/contracts)
139-
# - 'default' (to get them from the /app/build/contracts folder)
140-
*/
141-
contractOrigin: process.env.CONTRACT_ORIGIN,
142-
143-
contractsPath: '/app/contracts/', // where to find contract .sol files (if applicable)
144-
buildPath: '/app/build/contracts/', // where to find the contract interface json files
145-
146-
// external contract deployment microservice (which deploys the MerkleTree.sol contract):
147-
deployer: {
148-
host: process.env.DEPLOYER_HOST,
149-
port: process.env.DEPLOYER_PORT,
150-
},
151-
15292
// mongodb:
93+
// TODO: The latest Timber image has been edited... not sure how to create a 'user' for Timber anymore...
15394
mongo: {
154-
host: 'mongo-merkle-tree',
95+
host: 'timber-mongo',
15596
port: '27017',
156-
databaseName: process.env.DB_NAME || 'merkle_tree',
97+
databaseName: 'merkle_tree',
15798
admin: 'admin',
15899
adminPassword: 'admin',
159-
dbUrl: process.env.DB_URL || 'mongodb://mongo-merkle-tree:27017',
100+
dbUrl: process.env.DB_URL
160101
},
161-
102+
MONGO_URL: process.env.MONGO_URI,
103+
COMMITMENTS_DB: process.env.MONGO_NAME,
104+
COMMITMENTS_COLLECTION: 'commitments',
105+
INFO_COLLECTION: 'info',
106+
isLoggerEnabled: true,
162107
// web3:
163-
web3: {
108+
deployer: {
164109
host: process.env.BLOCKCHAIN_HOST,
165110
port: process.env.BLOCKCHAIN_PORT,
111+
},
112+
// web3:
113+
web3: {
114+
// url: `${process.env.BLOCKCHAIN_HOST}:${process.env.BLOCKCHAIN_PORT}`,
115+
url: process.env.RPC_URL,
166116
rpcUrl: process.env.RPC_URL,
117+
defaultAccountMnemonic: process.env.DEFAULT_ACCOUNT_MNEMONIC,
118+
key: process.env.KEY,
167119
autoReconnectInterval: process.env.BLOCKCHAIN_RECONNECT_INTERVAL || 1000,
120+
168121
options: {
169-
defaultAccount: '0x0',
170-
defaultBlock: '0', // e.g. the genesis block our blockchain
171-
defaultGas: 2000000,
172-
defaultGasPrice: 20000000000,
173-
transactionBlockTimeout: 50,
174-
transactionConfirmationBlocks: 15,
175-
transactionPollingTimeout: 480,
122+
// defaultAccount: '0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1',
123+
defaultAccount: process.env.DEFAULT_ACCOUNT,
124+
// defaultGas: 95221975,
125+
defaultGas: 11511304,
126+
defaultGasPrice: 30000000000,
127+
// defaultBlock: '0', // e.g. the genesis block our blockchain
128+
// defaultGas: 90000000,
129+
// defaultGasPrice: 20000000000,
130+
transactionBlockTimeout: 150,
131+
// transactionConfirmationBlocks: 15,
132+
// transactionPollingTimeout: 480,
176133
// transactionSigner: new CustomTransactionSigner()
134+
clientConfig: {
135+
// Useful to keep a connection alive
136+
keepalive: true,
137+
// Keep keepalive interval small so that socket doesn't die
138+
keepaliveInterval: -1,
139+
},
140+
timeout: 0,
141+
reconnect: {
142+
auto: true,
143+
delay: 5000, // ms
144+
maxAttempts: 120,
145+
onTimeout: false,
146+
},
177147
},
178148
},
179-
180-
isLoggerEnabled: true,
181-
LOG_LEVEL: process.env.LOG_LEVEL || 'info',
182-
183-
REUSE_FILTERS: process.env.REUSE_FILTERS || false,
184149
};

0 commit comments

Comments
 (0)