Paygas refund issue
See original GitHub issueWhat is wrong?
If a transaction fails after PAYGAS has been called, the sender ends up with his initial balance plus some additional funds. The reason for this seems to be that at the point of failure, the state is reverted to the pre gas payment state (i.e. the original balance), and on top of that the unused gas is refunded.
Here’s the test case that discovered the bug: https://github.com/jannikluhn/py-evm/blob/de5365458c1839a47a1301551e3b62e54c5214ef/tests/fillers/vm_fillers/paygas_fillers.py#L322-L349
In this case, the account at address
ends up with a balance of 138958
instead of 38958
.
How can it be fixed
After reverting the state subtract the transaction fee again
Ping @NIC619
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (9 by maintainers)
Top Results From Across the Web
Problems activating your California gas refund debit card?
After many Californians were unable to activate the cards with the provided 1-800 number, the phone line appears to be working.
Read more >Why did I pay gas fees for a failed transaction? – MetaMask
This is not a fee that MetaMask receives so we cannot refund it. This fee is paid to miners or validators for finalizing...
Read more >CON ED ASKS TO PAY GAS REBATE SOONER
The $20 million refund stems from savings earned by the utility during the year by burning gas, rather than oil, to produce electricity....
Read more >ConstitutionDAO refunds $27 million, but fees are ... - The Verge
ConstitutionDAO has refunded more than half of the contributions to its failed attempt to buy a rare copy of the US Constitution at...
Read more >Payment Options - Washington Gas
Take advantage of payment options for your Washington Gas bill including mail, phone, online and walk-in payment centers.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That worries me. It couples the state database with EVM business logic which feels wrong.
This leaves me with the original idea, which is to add a mechanism to bypass the journal. After taking a look at the code, I think this is quite doable and you should be able to validate this approach pretty easily with a basic test.
The
JournalDB
will need to be updated to allow bypassing the journal. I think the best way to do this would be to add abypass_journal
flag to all of theget/set/delete
methods which defaults toFalse
When
bypass_journal
isTrue
the journal should do the following.self.wrapped_db
This code can be tested with the following somewhat simple test cases.
Let me know what you think about this approach. It feels cleaner than intertwining the actual PAYGAS business logic into different layers of the stack. There will also need to be a change to the
AccountStateDB
object itself to tell it to bypass the journal which should probably just be a flag passed to it during instantiation.Thanks for exploring the idea. Nothing wrong with your approach. Make it so! 👍