MondrianWallet2::_executeTransaction
results in excessive gas usage, unexpected behaviour and unnecessary evm errors.Description: The _executeTransaction
function uses a standard .call
function to execute the transaction. This function returns a bool success
and bytes memory data
.
However, ZKsync handles the return of this the bytes data
differently than on Ethereum mainnet. In their own words, from the ZKsync documentation:
unlike EVM where memory growth occurs before the call itself, on ZKsync Era, the necessary copying of return data happens only after the call has ended
Even though the data field is not used (see the empty space after the comma in (success,)
below), it does receive this data and build it up in memory after the call has succeeded.
Impact: Some calls that ought to return a fail (due to excessive build up of memory) will pass the initial success
check, and only fail afterwards through an evm error
. Or, inversely, because _executeTransaction
allows functions to return data and have it stored in memory, some functions fail that ought to succeed.
The above especially applies to transactions that call a function that returns large amount of bytes.
Additionally,
_executeTransaction
is very gas inefficient due to this issue.
As the execution fails with a evm error
instead of a correct MondrianWallet2__ExecutionFailed
error message, functionality of frontend apps might be impacted.
Proof of Concept:
A contract has been deployed that returns a large amount of data.
MondrianWallet2
calls this contract.
The contract fails with an evm error
instead of MondrianWallet2__ExecutionFailed
.
After mitigating this issue (see the Recommended Mitigation section below)
4. No call fail with an evm error
anymore.
Place the following code after the existing tests in ModrianWallet2Test.t.sol
:
Place the following code in between the existing tests in ModrianWallet2Test.t.sol
:
Recommended Mitigation: By disallowing functions to write return data to memory, this problem can be avoided. In short, replace the standard .call
with an (assembly) call that restricts the return data to length 0.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.