Closed philippecamacho closed 4 weeks ago
Completely agree!
Do they already have a PR on this? @philippecamacho
Completely agree!
Do they already have a PR on this? @philippecamacho
Don't think so. The only PR from Common Prefix so far is https://github.com/EspressoSystems/espresso-sequencer/pull/1716
ESTIMATION: HIGH
I'm working on this, I'm gonna completely write the entire _computeChallenges()
using assembly, this should improve gas usage noticeably. Will try to submit a PR tmr (can't finish today)
Affected Code: • PlonkVerifier.sol (line 173) • Transcript.sol (line 81)
Summary: The current implementation of the function
_computeChallenges
in PlonkVerifier.sol andappendVkAndPubInput
in Transcript.sol inefficiently manages memory by repeatedly callingabi.encodePacked
to concatenate elements to the transcript. Each call toabi.encodePacked
results in a new memory allocation and copying of the existing transcript, leading to excessive gas consumption.Suggestion: Create a struct containing all the fields that are appended to the transcript. Hash the parts of the struct using low-level memory access to generate the relevant challenges. To allow for tight packing of the transcript one can also use a bytes array instead of struct and low-level memory writes to populate the array.