Skip to content

Commit

Permalink
PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
ignasirv committed Jan 31, 2024
1 parent b802e70 commit 12b311c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 375 deletions.
4 changes: 2 additions & 2 deletions src/processor.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ module.exports = class Processor {
this.F = poseidon.F;
this.tmpSmtDB = new TmpSmtDB(db);
this.smt = new SMT(this.tmpSmtDB, poseidon, poseidon.F);
this.smt.maxLevel = smtLevels;
this.initSmtLevels = smtLevels;
this.smt.setMaxLevel(smtLevels);
this.rawTxs = [];
this.decodedTxs = [];
this.builded = false;
Expand Down Expand Up @@ -388,6 +387,7 @@ module.exports = class Processor {
* Set vcm poseidon levels. Maximum (theoretical) levels that can be added in a tx is 50k poseidons.
* We count how much can the smt increase in a tx and compute the virtual poseidons with this worst case scenario. This is a tx full of SSTORE (20000 gas), max gas in a tx is 30M so we can do 1.5k sstore in a tx. Assuming tree already has 0 leafs, increases to 2**11. 11*1.5k = 22.5k * 2 (go up and down in the tree) = 45k poseidon, we round up to 50k for safety reasons.
*/
console.log('LVL: ', this.smt.maxLevel);
const maxLevelPerTx = (2 ** this.smt.maxLevel + 50000).toString(2).length;
this.vcm.setSMTLevels(maxLevelPerTx);
const currentDecodedTx = this.decodedTxs[i];
Expand Down
4 changes: 2 additions & 2 deletions src/smt.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ class SMT {
}

// Update max level in case last insertion increased smt size
if (this.maxLevel < currentLevel) {
this.maxLevel = currentLevel;
if (this.maxLevel < siblings.length) {
this.maxLevel = siblings.length;
}

return {
Expand Down
Loading

0 comments on commit 12b311c

Please sign in to comment.