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

Cancun support #2795

Merged
merged 21 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
240 changes: 120 additions & 120 deletions Cargo.lock

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -235,40 +235,40 @@ ethereum = { version = "0.15.0", default-features = false, features = [
"with-codec",
] }
ethereum-types = { version = "0.14", default-features = false }
evm = { git = "https://github.com/moonbeam-foundation/evm", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
evm-gasometer = { git = "https://github.com/moonbeam-foundation/evm", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
evm-runtime = { git = "https://github.com/moonbeam-foundation/evm", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
fp-ethereum = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
fp-evm = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
fp-rpc = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
fp-self-contained = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
pallet-ethereum = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false, features = [
evm = { git = "https://github.com/moonbeam-foundation/evm", branch = "v0.4.1-cancun", default-features = false }
evm-gasometer = { git = "https://github.com/moonbeam-foundation/evm", branch = "v0.4.1-cancun", default-features = false }
evm-runtime = { git = "https://github.com/moonbeam-foundation/evm", branch = "v0.4.1-cancun", default-features = false }
fp-ethereum = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false }
fp-evm = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false }
fp-rpc = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false }
fp-self-contained = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false }
pallet-ethereum = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false, features = [
"forbid-evm-reentrancy",
] }
pallet-evm = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false, features = [
pallet-evm = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false, features = [
"forbid-evm-reentrancy",
] }
pallet-evm-chain-id = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
pallet-evm-precompile-blake2 = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
pallet-evm-precompile-bn128 = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
pallet-evm-precompile-dispatch = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
pallet-evm-precompile-modexp = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
pallet-evm-precompile-sha3fips = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
pallet-evm-precompile-simple = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
pallet-evm-precompile-storage-cleaner = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
pallet-evm-chain-id = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false }
pallet-evm-precompile-blake2 = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false }
pallet-evm-precompile-bn128 = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false }
pallet-evm-precompile-dispatch = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false }
pallet-evm-precompile-modexp = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false }
pallet-evm-precompile-sha3fips = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false }
pallet-evm-precompile-simple = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false }
pallet-evm-precompile-storage-cleaner = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", default-features = false }

# Frontier (client)
fc-consensus = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2" }
fc-db = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2" }
fc-api = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2" }
fc-mapping-sync = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2" }
fc-rpc = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2", features = [
fc-consensus = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun" }
fc-db = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun" }
fc-api = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun" }
fc-mapping-sync = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun" }
fc-rpc = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun", features = [
"rpc-binary-search-estimate",
] }
fc-rpc-core = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2" }
fc-storage = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2" }
fp-consensus = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2" }
fp-storage = { git = "https://github.com/moonbeam-foundation/frontier", branch = "moonbeam-polkadot-v1.7.2" }
fc-rpc-core = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun" }
fc-storage = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun" }
fp-consensus = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun" }
fp-storage = { git = "https://github.com/moonbeam-foundation/frontier", branch = "cancun" }

# Cumulus (wasm)
cumulus-pallet-dmp-queue = { git = "https://github.com/moonbeam-foundation/polkadot-sdk", branch = "moonbeam-polkadot-v1.7.2", default-features = false }
Expand Down
12 changes: 3 additions & 9 deletions runtime/moonbase/tests/xcm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2586,17 +2586,11 @@ fn empty_account_should_not_be_reset() {
parachain::EVM::remove_account(&evm_account());
// Verify reference count.
let account = parachain::System::account(evm_account_id);
// TODO: after introducing the suicided fix the value for account.sufficients will remain 1
// until the storage is not completely removed, it will have to be decreased to 0 once the
// storage can be fully removed
assert_eq!(account.sufficients, 1);
assert_eq!(account.sufficients, 0);
assert_eq!(account.consumers, 0);
assert_eq!(account.providers, 1);
// We expect the account to be alive in a Zero ED context.
// TODO: after introducing the suicided fix the nonce is increased by 1
// until the storage is not completely removed, it will have to be decreased to 1 once the
// storage can be fully removed
assert_eq!(parachain::System::account_nonce(evm_account_id), 2);
assert_eq!(parachain::System::account_nonce(evm_account_id), 1);
});
}

Expand All @@ -2606,7 +2600,7 @@ fn test_statemint_like() {

let dest_para = Location::new(1, [Parachain(1)]);

let sov = xcm_builder::SiblingParachainConvertsVia::<
let sov = xcm_builder::SiblingParachainConvertsVia::<
polkadot_parachain::primitives::Sibling,
statemint_like::AccountId,
>::convert_location(&dest_para)
Expand Down
12 changes: 2 additions & 10 deletions runtime/moonbeam/tests/xcm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2310,19 +2310,11 @@ fn empty_account_should_not_be_reset() {
parachain::EVM::remove_account(&evm_account());
// Verify reference count.
let account = parachain::System::account(evm_account_id);
// TODO: since the suicided logic was introduced an smart contract account
// is not deleted completely until it's data is deleted. Data deletion
// will be implemented in a future release
// account.sufficients shall be 0
assert_eq!(account.sufficients, 1);
assert_eq!(account.sufficients, 0);
assert_eq!(account.consumers, 0);
assert_eq!(account.providers, 1);
// We expect the account to be alive in a Zero ED context.
// TODO: since the suicided logic was introduced an smart contract account
// is not deleted completely until it's data is deleted. Data deletion
// will be implemented in a future release
// this shall be changed to 1
assert_eq!(parachain::System::account_nonce(evm_account_id), 2);
assert_eq!(parachain::System::account_nonce(evm_account_id), 1);
});
}

Expand Down
12 changes: 2 additions & 10 deletions runtime/moonriver/tests/xcm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2620,19 +2620,11 @@ fn empty_account_should_not_be_reset() {
parachain::EVM::remove_account(&evm_account());
// Verify reference count.
let account = parachain::System::account(evm_account_id);
// TODO: since the suicided logic was introduced an smart contract account
// is not deleted completely until it's data is deleted. Data deletion
// will be implemented in a future release
// revert account.sufficients to 0
assert_eq!(account.sufficients, 1);
assert_eq!(account.sufficients, 0);
assert_eq!(account.consumers, 0);
assert_eq!(account.providers, 1);
// We expect the account to be alive in a Zero ED context.
// TODO: since the suicided logic was introduced an smart contract account
// is not deleted completely until it's data is deleted. Data deletion
// will be implemented in a future release
// the following needs to be 1
assert_eq!(parachain::System::account_nonce(evm_account_id), 2);
assert_eq!(parachain::System::account_nonce(evm_account_id), 1);
});
}

Expand Down
2 changes: 1 addition & 1 deletion test/contracts/src/ERC20ExcessGas.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ contract ERC20ExcessGas is ERC20WithInitialSupply {
uint256 amount
) public override returns (bool) {
// Consume gas to over Erc20XcmBridgeTransferGasLimit
for (uint i = 0; i < 2000; i++) {
for (uint i = 0; i < 2200; i++) {
_gasHog += i;
}

Expand Down
26 changes: 26 additions & 0 deletions test/contracts/src/dancun/ProxySuicide.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.24;

contract ProxyDeployer {
event ContractDestroyed(address destroyedAddress);

// Function to deploy a new Suicide contract
function deployAndDestroy(address target) public {
Suicide newContract = new Suicide();
newContract.destroy(target);
emit ContractDestroyed(address(newContract));
}

}

contract Suicide {
address public owner;

constructor() payable {
owner = msg.sender;
}

function destroy(address target) public {
selfdestruct(payable(target));
}
}
57 changes: 57 additions & 0 deletions test/contracts/src/dancun/TransientStorage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

contract ReentrancyProtected {
// A constant key for the reentrancy guard stored in Transient Storage.
// This acts as a unique identifier for the reentrancy lock.
bytes32 constant REENTRANCY_GUARD = keccak256("REENTRANCY_GUARD");

// Modifier to prevent reentrant calls.
// It checks if the reentrancy guard is set (indicating an ongoing execution)
// and sets the guard before proceeding with the function execution.
// After the function executes, it resets the guard to allow future calls.
modifier nonReentrant() {
// Ensure the guard is not set (i.e., no ongoing execution).
require(tload(REENTRANCY_GUARD) == 0, "Reentrant call detected.");

// Set the guard to block reentrant calls.
tstore(REENTRANCY_GUARD, 1);

_; // Execute the function body.

// Reset the guard after execution to allow future calls.
tstore(REENTRANCY_GUARD, 0);
}

// Uses inline assembly to access the Transient Storage's tstore operation.
function tstore(bytes32 location, uint value) private {
assembly {
tstore(location, value)
}
}

// Uses inline assembly to access the Transient Storage's tload operation.
// Returns the value stored at the given location.
function tload(bytes32 location) private returns (uint value) {
assembly {
value := tload(location)
}
}

function nonReentrantMethod() public nonReentrant {
(bool success, bytes memory result) = msg.sender.call("");
if (!success) {
assembly {
revert(add(32, result), mload(result))
}
}
}

function test() external {
this.nonReentrantMethod();
}

receive() external payable {
this.nonReentrantMethod();
}
}
2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"randomness": "1.6.8",
"rlp": "3.0.0",
"semver": "7.6.0",
"solc": "0.8.21",
"solc": "0.8.25",
"tsx": "4.7.2",
"viem": "2.9.9",
"vitest": "1.4.0",
Expand Down
Loading