Skip to content

Commit 558330c

Browse files
pgherveougithub-actions[bot]
authored andcommitted
[revive] move existing files to prepare evm backend introduction (#9501)
- Move exisiting files in pallet-revive to accomodate the upcoming EVM backend - Add solc/resolc compilation feature for fixtures - Add `fn is_pvm` to later distinguish between pvm / evm bytecode --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent eba1641 commit 558330c

31 files changed

Lines changed: 8462 additions & 7396 deletions

Cargo.lock

Lines changed: 575 additions & 94 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ node-rpc = { path = "substrate/bin/node/rpc" }
928928
node-testing = { path = "substrate/bin/node/testing" }
929929
nohash-hasher = { version = "0.2.0" }
930930
novelpoly = { version = "2.0.0", package = "reed-solomon-novelpoly" }
931-
num-bigint = { version = "0.4.3", default-features = false }
931+
num-bigint = { version = "0.4.6", default-features = false }
932932
num-format = { version = "0.4.3" }
933933
num-integer = { version = "0.1.46", default-features = false }
934934
num-rational = { version = "0.4.1" }
@@ -1190,6 +1190,7 @@ regex = { version = "1.10.2" }
11901190
relay-substrate-client = { path = "bridges/relays/client-substrate" }
11911191
relay-utils = { path = "bridges/relays/utils" }
11921192
remote-externalities = { path = "substrate/utils/frame/remote-externalities", default-features = false, package = "frame-remote-externalities" }
1193+
revm = { version = "27.0.2", default-features = false }
11931194
ripemd = { version = "0.1.3", default-features = false }
11941195
rlp = { version = "0.6.1", default-features = false }
11951196
rococo-emulated-chain = { path = "cumulus/parachains/integration-tests/emulated/chains/relays/rococo" }

cumulus/parachains/runtimes/assets/asset-hub-westend/tests/tests.rs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ const ALICE: [u8; 32] = [1u8; 32];
8585
const BOB: [u8; 32] = [2u8; 32];
8686
const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32];
8787

88+
const ERC20_PVM: &[u8] =
89+
include_bytes!("../../../../../../substrate/frame/revive/fixtures/erc20/erc20.polkavm");
90+
91+
const FAKE_ERC20_PVM: &[u8] =
92+
include_bytes!("../../../../../../substrate/frame/revive/fixtures/erc20/fake_erc20.polkavm");
93+
94+
const EXPENSIVE_ERC20_PVM: &[u8] = include_bytes!(
95+
"../../../../../../substrate/frame/revive/fixtures/erc20/expensive_erc20.polkavm"
96+
);
97+
8898
parameter_types! {
8999
pub Governance: GovernanceOrigin<RuntimeOrigin> = GovernanceOrigin::Origin(RuntimeOrigin::root());
90100
}
@@ -1670,10 +1680,7 @@ fn withdraw_and_deposit_erc20s() {
16701680
assert_ok!(Revive::map_account(RuntimeOrigin::signed(sender.clone())));
16711681
assert_ok!(Revive::map_account(RuntimeOrigin::signed(beneficiary.clone())));
16721682

1673-
let code = include_bytes!(
1674-
"../../../../../../substrate/frame/revive/fixtures/contracts/erc20.polkavm"
1675-
)
1676-
.to_vec();
1683+
let code = ERC20_PVM.to_vec();
16771684

16781685
let initial_amount_u256 = U256::from(1_000_000_000_000u128);
16791686
let constructor_data = sol_data::Uint::<256>::abi_encode(&initial_amount_u256);
@@ -1832,10 +1839,7 @@ fn smart_contract_does_not_return_bool_fails() {
18321839
assert_ok!(Revive::map_account(RuntimeOrigin::signed(beneficiary.clone())));
18331840

18341841
// This contract implements the ERC20 interface for `transfer` except it returns a uint256.
1835-
let code = include_bytes!(
1836-
"../../../../../../substrate/frame/revive/fixtures/contracts/fake_erc20.polkavm"
1837-
)
1838-
.to_vec();
1842+
let code = FAKE_ERC20_PVM.to_vec();
18391843

18401844
let initial_amount_u256 = U256::from(1_000_000_000_000u128);
18411845
let constructor_data = sol_data::Uint::<256>::abi_encode(&initial_amount_u256);
@@ -1888,10 +1892,7 @@ fn expensive_erc20_runs_out_of_gas() {
18881892
assert_ok!(Revive::map_account(RuntimeOrigin::signed(beneficiary.clone())));
18891893

18901894
// This contract does a lot more storage writes in `transfer`.
1891-
let code = include_bytes!(
1892-
"../../../../../../substrate/frame/revive/fixtures/contracts/expensive_erc20.polkavm"
1893-
)
1894-
.to_vec();
1895+
let code = EXPENSIVE_ERC20_PVM.to_vec();
18951896

18961897
let initial_amount_u256 = U256::from(1_000_000_000_000u128);
18971898
let constructor_data = sol_data::Uint::<256>::abi_encode(&initial_amount_u256);

prdoc/pr_9501.prdoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
title: '[revive] revm move existing files'
2+
doc:
3+
- audience: Runtime Dev
4+
description: |-
5+
- Move exisiting files in pallet-revive to accomodate the upcoming EVM backend
6+
- Add solc/resolc compilation feature for fixtures
7+
crates:
8+
- name: asset-hub-westend-runtime
9+
bump: patch
10+
- name: pallet-revive
11+
bump: patch
12+
- name: pallet-revive-fixtures
13+
bump: patch

substrate/frame/revive/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ polkavm = { version = "0.27.0", default-features = false }
3535
polkavm-common = { version = "0.27.0", default-features = false, features = ["alloc"] }
3636
rand = { workspace = true, optional = true }
3737
rand_pcg = { workspace = true, optional = true }
38+
revm = { workspace = true }
3839
rlp = { workspace = true }
3940
scale-info = { features = ["derive"], workspace = true }
4041
serde = { features = ["alloc", "derive"], workspace = true, default-features = false }
@@ -98,6 +99,7 @@ std = [
9899
"polkavm-common/std",
99100
"polkavm/std",
100101
"rand?/std",
102+
"revm/std",
101103
"ripemd/std",
102104
"rlp/std",
103105
"scale-info/std",

substrate/frame/revive/fixtures/Cargo.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,28 @@ exclude-from-umbrella = true
1616
workspace = true
1717

1818
[dependencies]
19+
alloy-core = { workspace = true, default-features = true, features = ["sol-types"], optional = true }
1920
anyhow = { workspace = true, default-features = true, optional = true }
2021
sp-core = { workspace = true, default-features = true, optional = true }
2122
sp-io = { workspace = true, default-features = true, optional = true }
2223

2324
[build-dependencies]
2425
anyhow = { workspace = true, default-features = true }
2526
cargo_metadata = { workspace = true }
27+
hex = { workspace = true, features = ["alloc"] }
2628
pallet-revive-uapi = { workspace = true }
2729
polkavm-linker = { version = "0.27.0" }
30+
serde_json = { workspace = true }
2831
toml = { workspace = true }
2932

3033
[features]
3134
default = ["std"]
3235
# only when std is enabled all fixtures are available
33-
std = ["anyhow", "sp-core", "sp-io"]
36+
std = [
37+
"alloy-core",
38+
"anyhow",
39+
"hex/std",
40+
"serde_json/std",
41+
"sp-core",
42+
"sp-io",
43+
]

0 commit comments

Comments
 (0)