Skip to content

Commit

Permalink
Add STATE_DIR_PATH env (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonid Tyurin authored Oct 21, 2022
1 parent 71d4a63 commit 764d28f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,4 @@ prover.js
# Log file
zp.log
yarn-error.log
zp-relayer/optimisticTree.db
zp-relayer/optimisticTxs.db
zp-relayer/poolTree.db
zp-relayer/poolTxs.db
zp-relayer/state/
1 change: 1 addition & 0 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
| TREE_UPDATE_PARAMS_PATH | Local path to tree update circuit parameters | string |
| TRANSFER_PARAMS_PATH | Local path to transfer circuit parameters | string |
| TX_VK_PATH | Local path to transaction curcuit verification key | string |
| STATE_DIR_PATH | Path to persistent state files related to tree and transactions storage. Default: `./state` | string |
| GAS_PRICE_FALLBACK | Default fallback gas price | integer |
| GAS_PRICE_ESTIMATION_TYPE | Gas price estimation type | `web3` / `gas-price-oracle` / `eip1559-gas-estimation` / `polygon-gasstation-v2` |
| GAS_PRICE_SPEED_TYPE | This parameter specifies the desirable transaction speed | `instant` / `fast` / `standard` / `low` |
Expand Down
5 changes: 1 addition & 4 deletions zp-relayer/clear.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
rm -rf ./optimisticTree.db
rm -rf ./optimisticTxs.db
rm -rf ./poolTree.db
rm -rf ./poolTxs.db
rm -rf ./state
1 change: 1 addition & 0 deletions zp-relayer/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const config = {
treeUpdateParamsPath: process.env.TREE_UPDATE_PARAMS_PATH || './params/tree_params.bin',
transferParamsPath: process.env.TRANSFER_PARAMS_PATH || './params/transfer_params.bin',
txVKPath: process.env.TX_VK_PATH || './params/transfer_verification_key.json',
stateDirPath: process.env.STATE_DIR_PATH || './state',
gasPriceFallback: process.env.GAS_PRICE_FALLBACK as string,
gasPriceEstimationType: (process.env.GAS_PRICE_ESTIMATION_TYPE as EstimationType) || 'web3',
gasPriceSpeedType: (process.env.GAS_PRICE_SPEED_TYPE as GasPriceKey) || 'fast',
Expand Down
4 changes: 2 additions & 2 deletions zp-relayer/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ class Pool {
const txVK = require(config.txVKPath)
this.txVK = txVK

this.state = new PoolState('pool')
this.optimisticState = new PoolState('optimistic')
this.state = new PoolState('pool', config.stateDirPath)
this.optimisticState = new PoolState('optimistic', config.stateDirPath)
}

private static getHash(path: string) {
Expand Down
6 changes: 3 additions & 3 deletions zp-relayer/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export class PoolState {
private txs: TxStorage
public nullifiers: NullifierSet

constructor(private name: string) {
this.tree = new MerkleTree(`./${name}Tree.db`)
this.txs = new TxStorage(`./${name}Txs.db`)
constructor(private name: string, path: string) {
this.tree = new MerkleTree(`${path}/${name}Tree.db`)
this.txs = new TxStorage(`${path}/${name}Txs.db`)
this.nullifiers = new NullifierSet(`${name}-nullifiers`)
}

Expand Down

0 comments on commit 764d28f

Please sign in to comment.