Conversation
…selfdestruct_post_cancun
|
Why don't we fix the underlying issue instead? |
there is no underlying issue. everything works as it should. |
|
I can't follow. If everything works as it should:
|
|
When implementing this PR I found that What should be done is to fix the pallet such that
If this was implemented correctly in the pallet, the differential test in |
Because I thought the ED was a deposit charge on the meter and was supposed to be refunded to the origin. |
So this is the bug? |
Either I misunderstood the way it is supposed to work or it is a bug. So two issues need to be decided:
|
|
The ED is supposed to be returned to from wherever it came from. The ED being the ED in one contract and then balance to another makes no sense. In EVM you can't turn gas into ETH like that as far as I am aware. If it is deducted from the meter it should be returned to the meter. If it can't be returned to the meter because the meter is one dimensional and this creates an attack vector (because ref_time was already spent but now you found additional gas be reclaiming ED). It may be returned to the origin (which is kind of like refunded gas) or burned. The goal is to achieve high compatibility with EVM. I am unaware of the decision to intentionally break |
I am not 100% convinced the ED was returned to the origin before this PR paritytech/polkadot-sdk#9699 |
|
If termination doesn't happen in the same TX it doesn't need to be returned anywhere. Otherwise, why not just return it to the meter or TX origin (not sure about the details - if it can be used to buy back other resources it seems attackable)? |
|
Hey. I am currently fixing a few things about
|
|
Closing this PR as @athei will change behaviour of selfdestruct that will make the tests pass |
fixes paritytech/contract-issues#209
These three lines make it so that the existential deposit is transferred as regular balance (as opposed to deposit).
https://github.com/paritytech/polkadot-sdk/blob/ef07f24b0cd49a52d1a5a0f3a42ea8d714187f18/substrate/frame/revive/src/exec.rs#L1225
Because of this the beneficiary receives 1 ether + ED which fails our assertion (we assert that the beneficiary received 1 ether). NB: this only happens if the contract is destroyed in the same transaction as it was created.
So I simply changed the assertion to 1 ether + ED.
Another issue is these two tests:
At the time we call
test_balance_after_selfdestructthe contract has not been destroyed yet because the transaction is still going.I removed this type of test and check the balances in a separate transaction.