Optimize solverOps array in Verification #74
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When
AtlasVerification.validCalls()
is called, it returns a filtered solverOps array.Instead of leaving blank solverOps objects (checked using
solverOp.from == address(0)
) in their prev spots in the array, we can pack the array with only the valid ones from the start.This should see a gas improvement in some cases - in the
_execute
part of ametacall
tx, we can simplify the checks while looping, as well as breaking early after checking only the valid solverOps.One concern is that rearranging the order of the solverOps array could mess with the simulator. In
validCalls
, if the call is in simulator mode, the original solverOps array is returned before being filtered. These differences in orders could be problematic.First pass at mitigating these concerns:
isSimulation == true
check is now below the solverOps pruning loop, so solverOps returned are in the same pruned form that_execute
will receive.simUserOperation
simulates the metacall with an empty solverOps array (length 0) instead of one of length 1, where it's a single empty solverOp. This change stops the sim call from reverting when it tries to verify the blank solverOp in that pruning loop.