fix(sdk) depositETH gas estimation bug#9949
fix(sdk) depositETH gas estimation bug#9949tsite wants to merge 7 commits intoethereum-optimism:developfrom
Conversation
propagate the deposit address instead of using the zero address as the source for eth_estimateGas
WalkthroughWalkthroughThe recent changes involve enhancements to the Changes
Assessment against linked issues
Possibly related issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9949 +/- ##
===========================================
- Coverage 28.34% 19.01% -9.33%
===========================================
Files 165 155 -10
Lines 7271 6194 -1077
Branches 1330 1327 -3
===========================================
- Hits 2061 1178 -883
+ Misses 5104 4941 -163
+ Partials 106 75 -31
Flags with carried forward coverage won't be shown. Click here to find out more.
|
roninjin10
left a comment
There was a problem hiding this comment.
I believe this code has tests and I'm not 100% clear on why gasEstimation would fail here. Can you please write test that fails before your change demonstrating the issue?
| const from = | ||
| opts?.overrides?.from ?? | ||
| (ethers.Signer.isSigner(this.l1SignerOrProvider) | ||
| ? (this.l1SignerOrProvider as Signer).getAddress() | ||
| : undefined) |
There was a problem hiding this comment.
Does ethers not already default to the signer address?
There was a problem hiding this comment.
it was using the provider instead of signer for gas estimation - I updated the fix to use l1SignerOrProvider instead of l1Provider and cleaned up depositERC20 as well.
There was a problem hiding this comment.
@roninjin10 if you could take another look at the pr, that would be awesome
There was a problem hiding this comment.
ok I updated the depositETH test to catch regressions @roninjin10 - the tests now fail without the changes made in this pr
we need to use the signer instead of provider to estimate the gas properly
use the signer instead of the provider
roninjin10
left a comment
There was a problem hiding this comment.
Thanks for adding the tests and apologies if getting this pr merged has been fustrating. My general inclination is to not accept this change but I'm borderline.
@smartcontracts any thoughts? I will defer to you if you think this change is worth merging. As far as I can tell it doesn't hurt anything
| // include a balance check as part of the estimateGas() call. | ||
| for (const signer of [l1Signer, l2Signer]) { | ||
| const estimateGas = signer.provider.estimateGas | ||
| signer.provider.estimateGas = async function (tx) { |
There was a problem hiding this comment.
So if I'm understanding this correctly, the issue here is geth reverts on balance checks. What I'm failing to understand though is we already have these tests running against geth via our devnet tests and against anvil via our anvil/vitest tests
There was a problem hiding this comment.
I think new versions of geth do fail the gas estimate if the balance is lower than the call value. I'll update the test to check for strict inequality since a zero balance is permitted for non-payable functions.
There was a problem hiding this comment.
for example, cast rpc eth_estimateGas '{"to":"0x00a149B262EA8ACA092Af1c43a899e7B18C5A4De", "from":"0x00a149B262EA8ACA092Af1c43a899e7B18C5A4De","value":"0x1"}' fails on most networks due to insufficient balance while cast rpc eth_estimateGas '{"to":"0x00a149B262EA8ACA092Af1c43a899e7B18C5A4De", "from":"0x00a149B262EA8ACA092Af1c43a899e7B18C5A4De","value":"0x0"}' succeeds.
There was a problem hiding this comment.
hmmm definitely confusing to me because I'm pretty sure we are using a new version of geth for our devnet tests. I think you are right though and I just don't know enough to be able to approve this pr. @smartcontracts will check it out within a day or 2. Thank you for patience.
The sender is allowed to have no balance when calling estimateGas on nonpayable functions. Also revert some unnecessary test changes
|
I updated the test - would appreciate another review. We currently have patched code running in production to fix this bug and it would be nice to merge the fix upstream as well |
|
This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Description
Fix a bug in the sdk where gas estimation uses the zero address as the source instead of propagating the source address for the transaction.
Tests
Depositing eth via the CrossChainMessenger now works properly and estimateGas no longer reverts due to a lack of funds available at the zero address.
Metadata