Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions brownie/brownie-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
compiler:
solc:
version: null
optimizer:
enabled: false
runs: 200
117 changes: 117 additions & 0 deletions brownie/contracts/SHA3.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.17;

contract CheckKeccak {

function checkBatchYul(uint256 l) external returns (bytes32 r) {
uint256 len = l / 100;
uint256 p = 0;
uint256 n = 1;
for (uint256 i; i<len; i++) {
assembly {
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
pop(keccak256(p, n))
}
}
return 0;
}
}
26 changes: 16 additions & 10 deletions brownie/scripts/chainTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,22 +125,28 @@ def test_benchProof(lcl,circuit,iterations=100, proof_options="", abort=False, f
except:
pass

proofs = task["result"]["Ok"]

metrics = {
"Block":block,
"Duration": {
"Aggregation" :proofs['aggregation']['duration'],
"Circuit" :proofs['circuit']['duration']
},
"Config": proofs['config']
}
if not error and task_completed:
proofs = task["result"]["Ok"]

metrics = {
"Block":block,
"k" : {
"Aggregation":proofs['aggregation']['k'],
"Circuit" : proofs['circuit']['k']
},
"Duration": {
"Aggregation" :proofs['aggregation']['duration'],
"Circuit" :proofs['circuit']['duration']
},
"Config": proofs['config']
}

pprint(metrics)
return metrics




def test_calculateBlockCircuitCosts(lcl, blocknumber, dumpTxTrace=False, layer=2):
'''
Enter doc strings here
Expand Down
3 changes: 2 additions & 1 deletion brownie/scripts/deploy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from brownie import CheckSdiv,CheckMload
from brownie import CheckSdiv,CheckMload, CheckKeccak
from brownie.network import accounts
from web3 import Web3
from pathlib import Path
Expand All @@ -20,3 +20,4 @@ def main():

checksdiv = CheckSdiv.deploy({"from": owner})
checkmload = CheckMload.deploy({"from": owner})
checksha3 = CheckKeccak.deploy({"from": owner})
10 changes: 7 additions & 3 deletions brownie/scripts/w3Utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from brownie import CheckSdiv, CheckMload
from brownie import CheckSdiv, CheckMload, CheckKeccak
from web3 import Web3
from web3.middleware import geth_poa_middleware
# from commonUtils import loadJson, getProjectDir
Expand All @@ -18,7 +18,10 @@ def sendTx(numOfiterations,contractInstance,owner):
'''
txNotSent = True
try:
tx = contractInstance.checkBatchYul(((numOfiterations),),{"from": owner})
try:
tx = contractInstance.checkBatchYul(((numOfiterations),),{"from": owner})
except:
tx = contractInstance.checkBatchYul(numOfiterations,{"from": owner})
txNotSent = False
except ValueError as _err:
tx = None
Expand Down Expand Up @@ -65,7 +68,8 @@ def getScName(circuit):
'''
worstCaseOPs = {
"EVM" : ("CheckSdiv","SDIV"),
"STATE": ("CheckMload", "MLOAD")
"STATE": ("CheckMload", "MLOAD"),
"KECCAK" : ("CheckKeccak", "SHA3")
}

return worstCaseOPs[circuit]
Expand Down