Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check simulation call trace for reversion #1861

Merged
merged 4 commits into from
Apr 18, 2023
Merged

Conversation

iamacook
Copy link
Member

@iamacook iamacook commented Apr 13, 2023

What it solves

Resolves successful simulations that should fail.

How this PR fixes it

The simulation call_trace is also checked for errors if the Tenderly simulation is successful. Example simulation can be found here.

How to test it

Open a 1.1.1 Safe on Gnosis Chain and create the following batch in the Transaction Builder:

  1. to of current Safe, changeMasterCopy to 0x3E5c63644E683549055b9Be8653de26E0B4CD36E
  2. to of Current Safe, setMasterCopy to 0xf48f2B2d2a534e402487b3ee7C18c33Aec0Fe5e4
  3. to of 0x7a48Dac683DA91e4faa5aB13D91AB5fd170875bd, swapOwner
  4. to of 0x7a48Dac683DA91e4faa5aB13D91AB5fd170875bd, swapOwner from to-be-added owner added in 3.

Simulate transaction (in the creation modal) and observe the simulation failing with:

The transaction failed during the simulation. Full simulation report is available on Tenderly.

Screenshots

image

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

@github-actions
Copy link

github-actions bot commented Apr 13, 2023

Branch preview

✅ Deploy successful!

https://simulation_call_trace--webcore.review-web-core.5afe.dev

@github-actions
Copy link

github-actions bot commented Apr 13, 2023

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A
  • Result: ✅ success
  • Annotations: 0 total

Report generated by eslint-plus-action

@iamacook iamacook assigned iamacook and unassigned iamacook and DiogoSoaress Apr 13, 2023
@iamacook iamacook marked this pull request as ready for review April 13, 2023 09:49
return []
}

return simulation.transaction.call_trace.filter((call) => call.error)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we go for call errors instead of the ExecutionFailure event as written in the comment?

We could iterate over simulation.transaction.logs and filter by log.name === 'ExecutionFailure' && log.raw.address === safeAddress emitted from safeAddress.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference: after discussing this, differing Safe versions emit different events (<1.1.0 emits ExecutionFailed) so the logs aren't consistent.

As such, we've adjusted the code to only extract the call traces if the transaction simulation "succeeds".

The transaction failed during the simulation{' '}
{isCallTraceError ? (
<>
with error <b>{callTraceErrors[0].error}</b>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this leads to too technical errors. The one in the PRs screenshot for instance reads "value: execution error" which does not really help users IMO.

I would just scan for the event log and give a generic error here OR if we want to give more details on what failed, we could start collecting common call_trace errors and map them to human readable error messages.

For the out of gas error for instance this error is present in the call traces:
"error": "out of gas" which we could rephrase to "The transaction failed with an out of gas error. Try increasing the safeTxGas and try again."

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference: we've generalised the error messages in accordance with the above clarification.

@schmanu
Copy link
Member

schmanu commented Apr 13, 2023

In general I think this is a great addition to our simulations as it is quite confusing that they show up as "Successful" although they revert in the assembly block of our contracts. We could also reach out to tenderly about this issue.

@iamacook iamacook requested a review from schmanu April 13, 2023 11:06
Copy link
Member

@schmanu schmanu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This should improve the simulations for 1.1.0 Safes!

Copy link
Member

@DiogoSoaress DiogoSoaress left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement!

@JagoFigueroa
Copy link

Hola team! The improvement is working nicely.

Only issue I see is that it will conflict with the current tenderly simulation that it is performed on the app itself as the behaviour there will still be the old one. I don't know if this change should be integrated on the app side as well to avoid cases like this:

sim.mp4

Cheers!

@iamacook
Copy link
Member Author

iamacook commented Apr 18, 2023

Only issue I see is that it will conflict with the current tenderly simulation that it is performed on the app itself as the behaviour there will still be the old one. I don't know if this change should be integrated on the app side as well

The Transaction Builder needs to be updated to include the changes in this PR. I'll create an issue for it to be tackled now.

Edit: I've created an issue.

@JagoFigueroa
Copy link

Gracias señor! All good from me to be merged 😎

@iamacook iamacook merged commit 3f06859 into dev Apr 18, 2023
@iamacook iamacook deleted the simulation-call-trace branch April 18, 2023 14:46
@github-actions github-actions bot locked and limited conversation to collaborators Apr 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants