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: Cancun SELFDESTRUCT semantics incorrect when contract's beneficiary is the contract itself and it isn't deleted #17477

Open
15 tasks
david-bakin-sl opened this issue Jan 22, 2025 · 0 comments · May be fixed by #17478
Assignees
Labels
Hedera Smart Contract Service Issues related to the Hedera Smart Contract Service.
Milestone

Comments

@david-bakin-sl
Copy link
Member

Background

(See hashgraph/hedera-smart-contracts#936 for original issue.)

Issue reported for SELFDESTRUCT is that EIP-6780 clearly states that the target address for the sweep aka the beneficiary aka the obtainer (in our code for contract delete) can be the contract address itself and there are two cases:

  • SELFDESTRUCT different transaction than contract created - this is the case where (post-cancun) the contract is not self destructed - contract keeps its balance
    • our behavior: return error SELF_DESTRUCT_TO_SELF - this is a bug as the contract/account is not deleted so it should work; in fact SELFDESTRUCT should work even if the account holds native (non-HBAR) tokens
  • SELFDESTRUCT same transaction from contract created - this is the case where the contract is self destructed - "the Ether will be burnt"
    • our behavior: return SELF_DESTRUCT_TO_SELF - is this correct or not? do we have a way to burn HBAR? what happens if the contract account holds native tokens? Investigating this to see what the desired behavior is.

(The case of a HAPI ContractDelete call is that it always fails if there's a balance and the beneficiary is the contract account.)

Acceptance Criteria

  • SELFDESTRUCT behavior unchanged except:
    • SELFDESTRUCT when beneficiary is same as contract being self-destructed, and contract self-destructed in different transaction than it was created (so contract is not deleted) will succeed even if account holds native tokens (it's a noop, except for gas charges).

Dependencies

No response

Definition of Ready (DoR) Checklist

  • Clear acceptance criteria
  • Clear and detailed description
  • Dependencies identified
  • Links to documentation
  • Should be completable in 2-3 Days
  • Initial draft of Low-level design document
  • At least high level test plan
  • Groomed/Estimated

Definition of Done (DoD) Checklist

  • Acceptance Criteria complete
  • No Codacy issues greater than minor (in new code)
  • JavaDocs updated/created
  • Code commented
  • Unit tests created/updated
  • 80% test code coverage (in new code)
  • Happy Path and major negative cases in HAPI tests as applicable
@david-bakin-sl david-bakin-sl added the Hedera Smart Contract Service Issues related to the Hedera Smart Contract Service. label Jan 22, 2025
@david-bakin-sl david-bakin-sl added this to the v0.59 milestone Jan 22, 2025
@david-bakin-sl david-bakin-sl self-assigned this Jan 22, 2025
@david-bakin-sl david-bakin-sl moved this from Backlog to Tasks In Progress in Smart Contract Sprint Board Jan 22, 2025
@david-bakin-sl david-bakin-sl changed the title fix: Cancun SELFDESTRUCT semantics incorrect when contract's beneficiary is the contract itself fix: Cancun SELFDESTRUCT semantics incorrect when contract's beneficiary is the contract itself and it isn't deleted Jan 22, 2025
@david-bakin-sl david-bakin-sl moved this from Tasks In Progress to In Review in Smart Contract Sprint Board Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Hedera Smart Contract Service Issues related to the Hedera Smart Contract Service.
Projects
Status: In Review
1 participant