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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is independent of the status because in the trace object,
result
anderror
are mutually exclusive, failed tx should haveerror
and succeeding txs haveresult
so we actually need to check the return status here:
foundry/anvil/src/eth/backend/mem/storage.rs
Lines 383 to 391 in 91f69dd
rn we always set result
this means we need to make a few changes to the
CallTrace
object I suppose, so it can distinguish betweencode
andoutput
,perhaps just
Option<Bytes>
for code? which is then used inparity_result()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a reason for adding a new field to the
CallTrace
struct.In this function,
retdata
contain revert data or return data (mutually exclusive), depending on the status:foundry/evm/src/executor/inspector/tracer.rs
Lines 228 to 245 in 91f69dd
Even from the EVM perspective, contract code and revert data are stored at the same data location (return data) - see https://www.evm.codes/#f0?fork=merge and https://www.evm.codes/#f0?fork=merge. Return data contain either the contract code or revert reason data, depending on the status.
I believe the
error
field inTrace
serves a different purpose. It should contain human-readable info about why the trace failed. One of these reasons should be "Reverted". Theresult
field should contain the return value - the data contained inreturn data
data storage (see https://www.evm.codes/about#returndata).This can be return value or revert data (mutually exclusive) for non-CREATE traces and contract code or revert data (also mutually exclusive) for CREATE traces.
TL;DR
I would leave the
CallTrace
struct with just one field (namedoutput
) because this is how EVM works (return data
data storage). Theoutput
field would be used accordingly in the parity_result function depending on the tracestatus
. But there is currently no way to set the revert data for CREATE traces and theerror
field inTrace
serves a different purpose.Perhaps to make it clearer, I can also make a PR to the ethers-rs repository that will be needed prior to this PR anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The corresponding pull request in ethers-rs: gakonst/ethers-rs#2392