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: gasEstimation for counterfactual deployments #3257

Merged
merged 9 commits into from
Feb 15, 2024

Conversation

schmanu
Copy link
Member

@schmanu schmanu commented Feb 14, 2024

What it solves

  • We compute the expected native costs wrong by double accounting the maxPriorityFee
  • Gas estimation for counterfactual transactions sometimes reverts too early for more advanced txs, that require the msg.sender to be the undeployed safe proxy

How this PR fixes it

  • fixes totalFee calculation by only multiplying maxFeePerGas * gasLimit
  • Estimates the counterfactual batch together using the simulate function of the fallback handler. This way the inner transaction is a correct delegateCall

How to test it

  • Create a new counterfactual Safe
  • Add an owner as the first transaction
  • Enable Recovery as a first transaction
  • Observe the expected gasLimit costs to be much closer to the actual gasLimit

Screenshots

Screenshot 2024-02-14 at 16 09 37

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) πŸ§‘β€πŸ’»

Copy link

github-actions bot commented Feb 14, 2024

Copy link

github-actions bot commented Feb 14, 2024

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

Copy link

github-actions bot commented Feb 14, 2024

πŸ“¦ Next.js Bundle Analysis for safe-wallet-web

This analysis was generated by the Next.js Bundle Analysis action. πŸ€–

πŸŽ‰ Global Bundle Size Decreased

Page Size (compressed)
global 1.03Β MB (-15Β B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Two Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/new-safe/create 31.91 KB (🟒 -4 B) 1.06 MB
/settings/setup 72.41 KB (🟑 +234 B) 1.1 MB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

Copy link

github-actions bot commented Feb 14, 2024

Coverage report

St.❔
Category Percentage Covered / Total
🟑 Statements
78.96% (+0.27% πŸ”Ό)
11571/14654
πŸ”΄ Branches
56.95% (+0.16% πŸ”Ό)
2584/4537
🟑 Functions
63.76% (+0.13% πŸ”Ό)
1840/2886
🟒 Lines
80.27% (+0.25% πŸ”Ό)
10435/13000
Show files with reduced coverage πŸ”»
St.❔
File Statements Branches Functions Lines
πŸ”΄
... / undeployedSafesSlice.ts
44% (+5.76% πŸ”Ό)
0% (-33.33% πŸ”»)
60% (+10% πŸ”Ό)
50% (+4.17% πŸ”Ό)
🟒
... / useGasPrice.ts
95.38%
80.65% (-1.17% πŸ”»)
100% 95.16%
🟑
... / index.tsx
58.62% (-1.38% πŸ”»)
0% 0%
65.38% (-1.28% πŸ”»)
🟒
... / useDeployGasLimit.ts
97.37% (-2.63% πŸ”»)
88.89% 100% 100%
🟑
... / CounterfactualForm.tsx
73.53% (-1.86% πŸ”»)
42.86% (-3.81% πŸ”»)
50% (-16.67% πŸ”»)
73.85% (-1.96% πŸ”»)

Test suite run success

1402 tests passing in 191 suites.

Report generated by πŸ§ͺjest coverage report action from 2e861d4

@francovenica
Copy link
Contributor

LGTM

I've checked in tx that the gas limit value we show in the tx form is the same (or almost the same) as the one that the wallet shows at the time of execution
Before the gas limit could vary a lot between those 2 instances

Copy link

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

@usame-algan
Copy link
Member

@francovenica I disabled the gasLimit input for undeployed safes as discussed

@francovenica
Copy link
Contributor

Checked that is disabled. Looks good

@usame-algan usame-algan merged commit d21ddd9 into dev Feb 15, 2024
13 checks passed
@usame-algan usame-algan deleted the fix-cf-gas-estimation branch February 15, 2024 19:36
@github-actions github-actions bot locked and limited conversation to collaborators Feb 15, 2024
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.

None yet

3 participants