Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions tests/eip6780/contracts/Destructible.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.24;

/// @title Destructible
/// @notice A minimal contract that exposes SELFDESTRUCT to any recipient.
///
/// Post EIP-6780 (Cancun / INTERSTELLAR fork):
/// - If called on a **pre-existing** contract: only the balance is
/// transferred; code and storage are preserved.
/// - If called on a contract **created in the same transaction**: the
/// contract is fully deleted (code + storage removed).
contract Destructible {
/// @notice Allow plain VET transfers into the contract so it can hold a balance.
receive() external payable {}

/// @notice Transfer this contract's balance to `recipient` via SELFDESTRUCT.
/// @param recipient The address that receives the balance.
function destroy(address payable recipient) external {
selfdestruct(recipient);
}
}
21 changes: 21 additions & 0 deletions tests/eip6780/contracts/Factory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.24;

import "./Destructible.sol";

/// @title Factory
/// @notice Deploys a Destructible child and immediately calls SELFDESTRUCT on it
/// within the same transaction.
///
/// This exercises the EIP-6780 **same-transaction** deletion path:
/// because the child was created in the same tx as the SELFDESTRUCT call,
/// it is fully deleted (code + storage removed) post-INTERSTELLAR fork.
contract Factory {
/// @notice Deploy a child Destructible and self-destruct it in the same tx.
/// @return child The address of the newly created (and immediately destroyed) child.
function deployAndDestroy() external returns (address child) {
Destructible d = new Destructible();
child = address(d);
d.destroy(payable(msg.sender));
}
}
10 changes: 10 additions & 0 deletions tests/eip6780/contracts/gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2018 The VeChainThor developers
// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying
// file LICENSE or <https://www.gnu.org/licenses/lgpl-3.0.html>

package contracts

// //go:generate docker run --rm -v ./:/sources ghcr.io/argotorg/solc:0.8.28 --evm-version cancun --optimize --optimize-runs 200 -o /sources/compiled --overwrite --abi --bin --bin-runtime /sources/Destructible.sol /sources/Factory.sol

//go:generate sh -c "docker run --rm -v $(pwd):/src ghcr.io/argotorg/solc:stable --combined-json abi,bin,bin-runtime,hashes /src/Destructible.sol | docker run --rm -i -v $(pwd):/src otherview/solgen:latest --out /src/generated"
//go:generate sh -c "docker run --rm -v $(pwd):/src ghcr.io/argotorg/solc:stable --combined-json abi,bin,bin-runtime,hashes /src/Factory.sol | docker run --rm -i -v $(pwd):/src otherview/solgen:latest --out /src/generated"
Loading
Loading