fix(alpen-cli): reserve gas for alpen drain#1931
Conversation
|
Commit: 99c6d00 SP1 Execution Results
|
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #1931 +/- ##
===========================================
- Coverage 84.31% 69.78% -14.54%
===========================================
Files 633 631 -2
Lines 75681 76312 +631
===========================================
- Hits 63812 53254 -10558
- Misses 11869 23058 +11189
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 341 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
We seem to have issues with gas calculation in general, not only in drain -- I'm not sure if this general issue is only when we haven't had sufficient activity (tx history is totally empty or in some recent block range). I think we just don't query what is the minimal gas the network accepts. |
This is only for drain specific invariant so i believe this is acceptable for narrow drain correctness fix. Activity history stuff is not the root issue But i agree that we need something on |
e3b82c7 to
cc7c519
Compare
Summary
U256arithmeticgas_limitandgas_priceused for the balance calculationBug Encountered
During the local k2
alpen-clismoke run,alpen drain --alpen-address 0x000000000000000000000000000000000000c0Fefailed after the CLI wallet had been funded and had already sent an Alpen transfer. The RPC rejected the drain transaction with:The old code estimated gas for a 1-wei transaction, computed
balance - gas_estimate * gas_price, then submitted a different max-value transaction while leaving the provider to fill gas fields again. That allowed the submitted transaction's upfront gas requirement to exceed the amount reserved by the drain calculation.This PR fixes that by calculating the reserved fee with
U256, returning early when there is no spendable balance after gas, and settinggas_limitandgas_priceexplicitly on the submitted drain transaction.