Skip to content

Commit

Permalink
Add new l2tx hash counters
Browse files Browse the repository at this point in the history
  • Loading branch information
ignasirv committed Jan 26, 2024
1 parent 6feaf2f commit f329179
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/virtual-counters-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ module.exports = class VirtualCountersManager {
this._reduceCounters(250, 'S');
this._reduceCounters(1 + 1, 'B');
this._reduceCounters(Math.ceil((txRLPLength + 1) / 136), 'K');
this._reduceCounters(Math.ceil((txRLPLength + 1) / 56), 'P');
this._reduceCounters(Math.ceil((txRLPLength + 1) / 56), 'D');
this._reduceCounters(Math.ceil((txRLPLength + 1) / 56) + 3, 'P');
this._reduceCounters(Math.ceil((txRLPLength + 1) / 56) + 3, 'D');
this._multiCall('_addBatchHashData', 21);
/**
* We need to calculate the counters consumption of `_checkNonLeadingZeros`, which calls `_getLenBytes`
Expand All @@ -187,12 +187,16 @@ module.exports = class VirtualCountersManager {
* gasPrice -> 256 bits -> 32 bytes
* gasLimit -> 64 bits -> 8 bytes
* value -> 256 bits -> 32 bytes
* dataLen -> 300000 bytes -> xxxx bytes
* dataLen -> 300000 bytes -> xxxx bytes -> only called when txDataLen >= 56 bytes
* chainId -> 64 bits -> 8 bytes
* nonce -> 64 bits -> 8 bytes
*/
this._reduceCounters(6 * 7, 'S'); // Steps to call _checkNonLeadingZeros 7 times
[3, gasPriceLen, gasLimitLen, valueLen, txDataLen, chainIdLen, nonceLen].forEach((bytesLen) => {
const getLenBytesValues = [3, gasPriceLen, gasLimitLen, valueLen, chainIdLen, nonceLen]

Check failure on line 195 in src/virtual-counters-manager.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing semicolon
if(txDataLen >= 56) {

Check failure on line 196 in src/virtual-counters-manager.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Expected space(s) after "if"
getLenBytesValues.push(txDataLen)

Check failure on line 197 in src/virtual-counters-manager.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Missing semicolon
}
getLenBytesValues.forEach((bytesLen) => {
this._getLenBytes({ lenBytesInput: bytesLen });
});
this._divArith();
Expand All @@ -212,7 +216,7 @@ module.exports = class VirtualCountersManager {
processTx(input) {
this._checkInput(input, ['bytecodeLength', 'isDeploy']);
this._reduceCounters(300, 'S');
this._reduceCounters(12 + 7, 'B');
this._reduceCounters(11 + 7, 'B');
this._reduceCounters(14 * MCP, 'P');
this._reduceCounters(5, 'D');
this._reduceCounters(2, 'A');
Expand Down

0 comments on commit f329179

Please sign in to comment.