Skip to content
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
335 commits
Select commit Hold shift + click to select a range
053c548
[pallet-revive] revm tests scaffolding (#9290)
xermicus Jul 24, 2025
b45b1a2
move back fixture to fixtures folder and generate them from build.rs
pgherveou Jul 24, 2025
27b62f7
add skeleton for fixtures
pgherveou Jul 24, 2025
acf0e6e
wip
pgherveou Jul 25, 2025
f47d7b5
fixes
pgherveou Jul 25, 2025
31c0595
update build.rs
pgherveou Jul 25, 2025
3a07569
nit
pgherveou Jul 25, 2025
9adf741
fixes
pgherveou Jul 26, 2025
b1dbf5d
add missing headers
pgherveou Jul 26, 2025
4341d6d
Merge branch 'master' into pg/revm
pgherveou Jul 27, 2025
91e59e5
add test allow_evm_bytecode_config_works
pgherveou Jul 27, 2025
da7473d
fix lock
pgherveou Jul 27, 2025
df8d71d
Update from github-actions[bot] running command 'fmt'
github-actions[bot] Jul 27, 2025
359b181
fixes
pgherveou Jul 27, 2025
58b9220
Rve/revm arithmetic instructions WIP (#9361)
0xRVE Jul 30, 2025
5b304a0
fixes gas computation of evm arithemtic instructions (#9379)
0xRVE Jul 30, 2025
aa40c56
added bitwise test
Jul 30, 2025
2281fb7
added tests for bitwise
Jul 30, 2025
509b0ee
fix comment
Jul 30, 2025
90d54d7
fixed bitwise compilation issue
Jul 30, 2025
e0a0d9f
ignore CLZ test
Jul 31, 2025
1921aef
host.rs::balance test not working
Aug 1, 2025
94697f7
fixed host:balance test. need to find global var for existential depo…
Aug 1, 2025
93a5dae
mult and offset to variables
Aug 1, 2025
db394c8
cleanup
Aug 1, 2025
a64ce67
added test for selfbalance
Aug 1, 2025
faa067c
fixe test host::selfbalance
Aug 4, 2025
5c30af0
cargo clippy
Aug 4, 2025
b9d1a58
added test for host::extcodesize
Aug 4, 2025
b5c8baf
added test for extcodehash
Aug 4, 2025
34e3e78
stared making blockhash instruction
Aug 4, 2025
6390a20
blockhash runs out of gas for some reason
Aug 4, 2025
b53d220
added stubs for other tests in host.rs
Aug 5, 2025
7a13f03
added Debug to exec.rs::Key
Aug 5, 2025
73adf94
added host test sload
Aug 5, 2025
e92b7d0
added host.rs test sstore
Aug 5, 2025
f5accbf
not so easy to test transient storage
Aug 5, 2025
2d88b1d
added test for selfdestruct but it gives out-of-gas error
Aug 6, 2025
d1b2baf
clean up
Aug 6, 2025
d6c852a
fixed Host.sol
Aug 6, 2025
8b9d9ba
fixed test for blockhash in host.rs
Aug 6, 2025
dfbaf67
created separate Host::selfdetruct fixtures for EVM and PVM
Aug 6, 2025
81f7da0
enabled solc and resolc in blockhash test in host.rs
Aug 6, 2025
aadfe10
added test for extcodecopy
Aug 7, 2025
d376bfc
cleanup
Aug 7, 2025
936c20d
cleanup
Aug 8, 2025
4f0f468
clean up
Aug 8, 2025
148e0e6
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] Aug 12, 2025
8817d7e
Revert "fixes gas computation of evm arithemtic instructions (#9379)"
Aug 12, 2025
02198ce
Revert "Rve/revm arithmetic instructions WIP (#9361)"
Aug 12, 2025
ab72894
added arithmetic
Aug 12, 2025
d8142a3
added test for transient storage in host.rs
Aug 12, 2025
5842fa7
cleanup
Aug 12, 2025
c071b7d
added test for memory
Aug 12, 2025
bb14f1c
[pallet-revive] do not silently fail Solidity fixtures compilation (#…
xermicus Aug 12, 2025
35bc95d
removed some function from Memory.sol fixture
Aug 13, 2025
90fb377
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 13, 2025
ef5bbc8
added test for mstore8
Aug 13, 2025
b00080d
turn off yul optimizer and added test for msize
Aug 13, 2025
22460f8
added test for mcopy in memory.rs
Aug 13, 2025
392cadd
selfdestruct doesnt work
Aug 13, 2025
1bfbaa8
refactor more benchmarks
pgherveou Aug 14, 2025
96e5402
added test for control jump
Aug 14, 2025
61f5bb3
added test for JUMPI instruction in control
Aug 14, 2025
ce3570d
cleanup
Aug 14, 2025
87d61cd
disable host selfdestruct opcode
Aug 14, 2025
c2170db
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 14, 2025
36f6d39
cleanup
Aug 14, 2025
cfec632
cleanup
Aug 15, 2025
6e4ca1f
refactor arithmetic tests
Aug 15, 2025
5278629
refactor bitwise tests
Aug 15, 2025
3e6a43b
refactor control tests
Aug 15, 2025
68bc07c
require call in solidity is not failing on incorrect predicate
Aug 15, 2025
d67c22e
inside test need to check for REVERT flag in result of bare call
Aug 15, 2025
f74a739
require in solidity fails/reverts without giving a clear error message
Aug 16, 2025
434fd78
moved decode_revert_message to tests.rs
Aug 16, 2025
9109b74
fixed bitwise tests
Aug 16, 2025
7f79d2e
Merge branch 'master' into pg/revm
pgherveou Aug 18, 2025
076246c
Merge branch 'master' into pg/revm
pgherveou Aug 18, 2025
b2ceaae
revm file shuffling
pgherveou Aug 18, 2025
7e68c51
fixes
pgherveou Aug 18, 2025
6ec1681
rm stuff for later
pgherveou Aug 18, 2025
c89d026
rm evm
pgherveou Aug 18, 2025
d53e0ac
rm evm stuff
pgherveou Aug 18, 2025
edde1d1
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] Aug 18, 2025
4f38703
rm
pgherveou Aug 18, 2025
d1683f8
removed some tests from arithmetic
Aug 18, 2025
ab3761e
taplo fix
pgherveou Aug 18, 2025
7dadbc1
fix up cargo.lock
pgherveou Aug 18, 2025
abcd13c
try
pgherveou Aug 18, 2025
6d30298
fixes
pgherveou Aug 18, 2025
68e9a84
Merge branch 'master' into pg/revm-base
pgherveou Aug 18, 2025
551c711
rm vm/runtime.rs
pgherveou Aug 18, 2025
2c308d7
Merge branch 'pg/revm-base' into pg/revm
pgherveou Aug 18, 2025
2debf91
fix
pgherveou Aug 18, 2025
0175328
nit
pgherveou Aug 18, 2025
59e59e8
fixes
pgherveou Aug 18, 2025
f1f2ffc
nit
pgherveou Aug 18, 2025
82ea9bc
update call_with_code_per_byte
pgherveou Aug 18, 2025
15935c3
not getting the right balance after INVALID instruction
Aug 18, 2025
6f7b2bf
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 18, 2025
20511d1
fixes
pgherveou Aug 18, 2025
4bf8aee
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 18, 2025
e1bbcb9
added migration
pgherveou Aug 18, 2025
78c92d3
Merge branch 'master' into pg/revm-base
pgherveou Aug 19, 2025
3789665
Merge branch 'pg/revm-base' into pg/revm
pgherveou Aug 19, 2025
f8da76f
refactoring
pgherveou Aug 19, 2025
b1b1192
fix clippy
pgherveou Aug 19, 2025
a829fab
fix clippy
pgherveou Aug 19, 2025
1066074
fixedd test for INVALID opcode
Aug 19, 2025
d11dd3f
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 19, 2025
4b5edb5
added assert for flag revert
Aug 19, 2025
e482eee
added tests for stack
Aug 19, 2025
fd57f68
review comments
Aug 20, 2025
de65cce
rustfmt
Aug 20, 2025
69602ac
added selfdestruct
Aug 20, 2025
d9e50a1
cleanup
Aug 20, 2025
b9c406e
rustfmt
Aug 20, 2025
24f4c6d
license
Aug 20, 2025
b8970a0
rustfmt
Aug 20, 2025
ade000c
fmt
Aug 20, 2025
c6378fb
fix macro import issue
Aug 20, 2025
3e1fc33
cargo check
Aug 20, 2025
dba3403
removed loggings
Aug 21, 2025
8112b00
cleanup
Aug 21, 2025
883af60
removed decode_revert_message
Aug 21, 2025
4731b5e
cargo +nightly fmt
pgherveou Aug 21, 2025
3c4f5c4
Merge branch 'master' into pg/revm
pgherveou Aug 21, 2025
953ee61
merge fix
pgherveou Aug 21, 2025
7cee5be
simplify migration tests
pgherveou Aug 21, 2025
b8dc717
add migration
pgherveou Aug 21, 2025
3503649
removed EVM version check from evm instructions
Aug 21, 2025
574fb97
removed log::info and println
Aug 21, 2025
81578a0
remove unneeded tests for this PR
pgherveou Aug 21, 2025
fa0ffa9
fix CALLDATACOPY gas
Aug 21, 2025
22cd095
cleanup
Aug 21, 2025
9df994e
added comments to control assembly contracts for jump and jumpi
Aug 21, 2025
2f13212
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 21, 2025
6000ed4
fixes
pgherveou Aug 21, 2025
c679776
keep these files for next PR
pgherveou Aug 21, 2025
5f839b6
comments
pgherveou Aug 21, 2025
8110392
fixes
pgherveou Aug 21, 2025
7a1c0a6
fix
pgherveou Aug 21, 2025
f3289d4
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 21, 2025
3512769
fix after merge
Aug 21, 2025
3b19c42
fmt
Aug 21, 2025
fa902be
make cargo check pass
Aug 21, 2025
4657b64
fmt
Aug 21, 2025
83ea8cd
Update from github-actions[bot] running command 'bench --runtime dev …
github-actions[bot] Aug 21, 2025
6706b9c
fix clippy
Aug 21, 2025
165957c
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] Aug 21, 2025
2b07ca6
rename seal_to_account_id
pgherveou Aug 21, 2025
0c4d0cd
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 21, 2025
f96fa39
update PRDOC
pgherveou Aug 21, 2025
2f369ad
Merge branch 'master' into pg/revm
pgherveou Aug 21, 2025
9f92c36
install solc in workflow
Aug 22, 2025
b66b47a
fix bench
pgherveou Aug 21, 2025
4d0db7e
output.data shoudl be untouched
pgherveou Aug 22, 2025
b7c0f7f
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 22, 2025
674e559
fix host test
Aug 22, 2025
42f8c2d
fmt
Aug 22, 2025
f5caa32
review fixes
Aug 22, 2025
4a98ea1
moved transfer_with_dust out of the transfer function
Aug 22, 2025
0784a4a
semicolon
Aug 22, 2025
b747e98
removed allow deadcode from H160Mapper in address.rs
Aug 22, 2025
79b84da
install solidity in job
pgherveou Aug 22, 2025
484edb2
fixed some stuff in host instructions
Aug 22, 2025
c907833
fmt
Aug 22, 2025
6403ef1
added install resolc to tests-misc.yml
Aug 22, 2025
4b80099
use resolc too
pgherveou Aug 22, 2025
4b6f4d2
rm line
pgherveou Aug 22, 2025
28b6217
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 22, 2025
c2332ca
trigger ci
Aug 22, 2025
ab15dc1
enforce evm code size limit
pgherveou Aug 23, 2025
e93c1a0
fix
pgherveou Aug 25, 2025
04d0551
fix
pgherveou Aug 25, 2025
8f8ebcc
fix
pgherveou Aug 25, 2025
dbb4b93
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 26, 2025
47b39c1
fixed gas in hsot.rs
Aug 26, 2025
d1d5199
cleanup
Aug 26, 2025
dec0849
PR review
pgherveou Aug 26, 2025
dbfc430
make pristine unbounded and check PVM & EVM code size
pgherveou Aug 26, 2025
87b7b4e
nit
pgherveou Aug 26, 2025
b4dad01
added comments
Aug 26, 2025
fbdd9fc
commented code so that estending memory will not cost any gas
Aug 26, 2025
cb8b8ce
added TODO in host.rs instruction for extcodecopy gas macro
Aug 26, 2025
ee7c237
unused vars in macros.rs
Aug 26, 2025
b769010
refcount = 1 for evm
pgherveou Aug 26, 2025
0abfc74
fix
pgherveou Aug 26, 2025
6060eb4
fix
pgherveou Aug 26, 2025
2007fb5
add one more assert
pgherveou Aug 26, 2025
f219e06
nit
pgherveou Aug 26, 2025
33e9216
Remove refcount and owner for EVM CodeInfo
pgherveou Aug 26, 2025
f75403a
rm unused
pgherveou Aug 26, 2025
d26d8ac
origin should be held not caller
pgherveou Aug 26, 2025
cc8cef4
Merge branch 'master' into pg/revm
pgherveou Aug 27, 2025
92e36a7
added trace logging in EVM interpreter loop
Aug 27, 2025
5175667
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] Aug 27, 2025
5780c19
fix ci
Aug 27, 2025
256b802
fmt
Aug 27, 2025
59ccd47
fix ci
Aug 27, 2025
9cd90ca
Update from github-actions[bot] running command 'bench --runtime dev …
github-actions[bot] Aug 27, 2025
d647759
fix ci
Aug 27, 2025
63290b9
dummy chang
Aug 27, 2025
d22ac45
nit
Aug 27, 2025
8bd37b6
fix ci
Aug 27, 2025
9d40097
changed prdoc to major
Aug 27, 2025
e405e18
rollback refcount removals
pgherveou Aug 27, 2025
8b1669f
Update Cargo.toml
pgherveou Aug 27, 2025
4f86e9b
Update prdoc/pr_9285.prdoc
pgherveou Aug 27, 2025
315ae52
Update substrate/frame/revive/src/call_builder.rs
pgherveou Aug 27, 2025
3598d6f
Update substrate/frame/revive/src/benchmarking.rs
pgherveou Aug 27, 2025
3272e99
rm charge_evm_init_cost
pgherveou Aug 27, 2025
e2242a2
fix
pgherveou Aug 27, 2025
7fa6421
rm - 1
pgherveou Aug 27, 2025
ae647b6
restore legacy behaviour
pgherveou Aug 27, 2025
e374a38
fix selfdestruct in exec.rs and host.rs
Aug 27, 2025
38602a5
format fixtures
xermicus Aug 28, 2025
1a073b6
update
pgherveou Aug 28, 2025
2765b13
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 28, 2025
11fbe30
using U256Converter trait
Aug 28, 2025
f0b629d
fixed gas charge in host sstore and tstore
Aug 28, 2025
9632db8
review comments
Aug 28, 2025
7de00cc
remove prdoc
Aug 28, 2025
22d1b3c
Merge remote-tracking branch 'origin/rve/revm-instructions-bitwise' i…
Aug 28, 2025
9c4e85c
undo changes to weights
Aug 28, 2025
4bd37a2
fixed copy paste mistake
Aug 28, 2025
fb8ca75
fixed review comment
Aug 28, 2025
5a6b99a
remove allow deadcode in utility.rs
Aug 28, 2025
6d01a53
format
Aug 28, 2025
6d0181e
fixed copy paste mistake
Aug 28, 2025
04001a2
fixed review comment
Aug 28, 2025
f68a53d
remove allow deadcode in utility.rs
Aug 28, 2025
4fc21b4
Merge branch 'rve/revm-instructions-bitwise' into rve/revm2
Aug 28, 2025
833b847
fix ci
Aug 29, 2025
d137f91
fix ci
Aug 29, 2025
51ba0f7
trigger ci
Aug 29, 2025
4edc46e
format
Aug 29, 2025
7afade1
fix compilation issue
Aug 29, 2025
b48e5e1
Merge remote-tracking branch 'origin/rve/revm-instructions-bitwise' i…
Aug 29, 2025
d1808d6
added test for invalid jumpdest
Aug 29, 2025
a064b21
review comments
Aug 29, 2025
4283724
removed formatting diff
Aug 29, 2025
199516c
Merge remote-tracking branch 'origin/rve/revm-instructions-bitwise' i…
Aug 29, 2025
09d7a3a
fix unused variable
Aug 29, 2025
29765fc
fix unused variable
Aug 29, 2025
f10a0b2
Merge branch 'rve/revm-instructions-bitwise' into rve/revm2
Aug 29, 2025
fcae11f
fixed condition import
Aug 29, 2025
fdff8f2
change imports
Aug 29, 2025
d4b67b5
format
Aug 29, 2025
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
12 changes: 12 additions & 0 deletions .github/workflows/tests-misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,17 @@ jobs:
components: cargo, clippy, rust-docs, rust-src, rustfmt, rustc, rust-std
- name: Install protobuf
run: brew install protobuf
- name: install solc
run: brew install solidity
- name: Install resolc
run: |
ASSET_URL="https://github.com/paritytech/revive/releases/download/v${{ inputs.version }}/resolc-universal-apple-darwin"
echo "Downloading resolc v${{ inputs.version }} from $ASSET_URL"
curl -Lsf --show-error -o /tmp/resolc "$ASSET_URL"
sudo cp /tmp/resolc /usr/local/bin/resolc
sudo chmod 755 /usr/local/bin/resolc
with:
version: 0.3.0
- name: cargo info
run: |
echo "######## rustup show ########"
Expand Down Expand Up @@ -406,3 +417,4 @@ jobs:
else
echo '### Good job! All the required jobs passed 🚀' >> $GITHUB_STEP_SUMMARY
fi

Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,10 @@ impl pallet_revive::Config for Runtime {
type RuntimeMemory = ConstU32<{ 128 * 1024 * 1024 }>;
type PVFMemory = ConstU32<{ 512 * 1024 * 1024 }>;
type UnsafeUnstableInterface = ConstBool<false>;
#[cfg(feature = "runtime-benchmarks")]
type AllowEVMBytecode = ConstBool<true>;
#[cfg(not(feature = "runtime-benchmarks"))]
type AllowEVMBytecode = ConstBool<false>;
type UploadOrigin = EnsureSigned<Self::AccountId>;
type InstantiateOrigin = EnsureSigned<Self::AccountId>;
type RuntimeHoldReason = RuntimeHoldReason;
Expand All @@ -1199,7 +1203,10 @@ parameter_types! {
impl pallet_migrations::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
#[cfg(not(feature = "runtime-benchmarks"))]
type Migrations = pallet_revive::migrations::v1::Migration<Runtime>;
type Migrations = (
pallet_revive::migrations::v1::Migration<Runtime>,
pallet_revive::migrations::v2::Migration<Runtime>,
);
// Benchmarks need mocked migrations to guarantee that they succeed.
#[cfg(feature = "runtime-benchmarks")]
type Migrations = pallet_migrations::mock_helpers::MockedMigrations;
Expand Down
1 change: 1 addition & 0 deletions cumulus/parachains/runtimes/testing/penpal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ impl pallet_revive::Config for Runtime {
type RuntimeMemory = ConstU32<{ 128 * 1024 * 1024 }>;
type PVFMemory = ConstU32<{ 512 * 1024 * 1024 }>;
type UnsafeUnstableInterface = ConstBool<true>;
type AllowEVMBytecode = ConstBool<true>;
type UploadOrigin = EnsureSigned<Self::AccountId>;
type InstantiateOrigin = EnsureSigned<Self::AccountId>;
type RuntimeHoldReason = RuntimeHoldReason;
Expand Down
17 changes: 17 additions & 0 deletions prdoc/pr_9285.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
title: '[revive] revm backend'
doc:
- audience: Runtime Dev
description: |
Initial EVM support for pallet-revive via the REVM crate to create a dual-VM system that can execute both PolkaVM and EVM
- Added AllowEVMBytecode: Get<bool> to the config to enable/disable EVM call and instantiation
- The basic flow of uploading an EVM contract and running it should work
- instructions are copied and adapted from REVM they should be ignored in this PR and reviewed in follow-up PR
crates:
- name: pallet-revive
bump: major
- name: pallet-revive-fixtures
bump: patch
- name: asset-hub-westend-runtime
bump: patch
- name: penpal-runtime
bump: patch
35 changes: 35 additions & 0 deletions prdoc/pr_9385.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
title: Rve/revm instructions bitwise WIP
doc:
- audience: Runtime Dev
description: "\u2704 -----------------------------------------------------------------------------\n\
\nThank you for your Pull Request! \U0001F64F Please make sure it follows the\
\ contribution guidelines outlined in [this\ndocument](https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md)\
\ and fill out the\nsections below. Once you're ready to submit your PR for review,\
\ please delete this section and leave only the text under\nthe \"Description\"\
\ heading.\n\n# Description\n\n*A concise description of what your PR is doing,\
\ and what potential issue it is solving. Use [Github semantic\nlinking](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword)\n\
to link the PR to an issue that must be closed once this is merged.*\n\n## Integration\n\
\n*In depth notes about how this PR should be integrated by downstream projects.\
\ This part is\nmandatory, and should be reviewed by reviewers, if the PR does\
\ NOT have the\n`R0-no-crate-publish-required` label. In case of a `R0-no-crate-publish-required`,\
\ it can be\nignored.*\n\n## Review Notes\n\n*In depth notes about the **implementation**\
\ details of your PR. This should be the main guide for reviewers to\nunderstand\
\ your approach and effectively review it. If too long, use\n[`<details>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details)*.\n\
\n*Imagine that someone who is depending on the old code wants to integrate your\
\ new code and the only information that\nthey get is this section. It helps to\
\ include example usage and default value here, with a `diff` code-block to show\n\
possibly integration.*\n\n*Include your leftover TODOs, if any, here.*\n\n# Checklist\n\
\n* [ ] My PR includes a detailed description as outlined in the \"Description\"\
\ and its two subsections above.\n* [ ] My PR follows the [labeling requirements](\n\
https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md#Process\n\
) of this project (at minimum one label for `T` required)\n * External contributors:\
\ ask maintainers to put the right label on your PR.\n* [ ] I have made corresponding\
\ changes to the documentation (if applicable)\n* [ ] I have added tests that\
\ prove my fix is effective or that my feature works (if applicable)\n\nYou can\
\ remove the \"Checklist\" section once all have been checked. Thank you for your\
\ contribution!\n\n\u2704 -----------------------------------------------------------------------------"
crates:
- name: pallet-revive-fixtures
bump: major
- name: pallet-revive
bump: major
1 change: 1 addition & 0 deletions substrate/bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,7 @@ impl pallet_revive::Config for Runtime {
type NativeToEthRatio = ConstU32<1_000_000>; // 10^(18 - 12) Eth is 10^18, Native is 10^12.
type EthGasEncoder = ();
type FindAuthor = <Runtime as pallet_authorship::Config>::FindAuthor;
type AllowEVMBytecode = ConstBool<true>;
}

impl pallet_sudo::Config for Runtime {
Expand Down
13 changes: 10 additions & 3 deletions substrate/frame/revive/fixtures/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ fn compile_with_standard_json(
"sources": {},
"settings": {
"optimizer": {
"enabled": true,
"enabled": false,
"runs": 200
},
"outputSelection":
Expand Down Expand Up @@ -344,12 +344,19 @@ fn compile_solidity_contracts(
return Ok(());
}

let evm_only = vec!["HostEvmOnly"];
let solidity_entries_pvm: Vec<_> = solidity_entries
.iter()
.cloned()
.filter(|entry| !evm_only.contains(&entry.path.file_stem().unwrap().to_str().unwrap()))
.collect();

// Compile with solc for EVM bytecode
let json = compile_with_standard_json("solc", contracts_dir, &solidity_entries)?;
extract_and_write_bytecode(&json, out_dir, ".sol.bin")?;

// Compile with resolc for PVM bytecode
let json = compile_with_standard_json("resolc", contracts_dir, &solidity_entries)?;
let json = compile_with_standard_json("resolc", contracts_dir, &solidity_entries_pvm)?;
extract_and_write_bytecode(&json, out_dir, ".resolc.polkavm")?;

Ok(())
Expand Down Expand Up @@ -463,7 +470,7 @@ fn generate_fixture_location(temp_dir: &Path, out_dir: &Path, entries: &[Entry])
// Generate sol! macros for Solidity contracts
for entry in entries.iter().filter(|e| matches!(e.contract_type, ContractType::Solidity)) {
let relative_path = format!("contracts/{}", entry.path().split('/').last().unwrap());
writeln!(file, r#"alloy_core::sol!("{}");"#, relative_path)
writeln!(file, r#"#[cfg(feature = "std")] alloy_core::sol!("{}");"#, relative_path)
.context("Failed to write sol! macro to fixture_location.rs")?;
}

Expand Down
53 changes: 53 additions & 0 deletions substrate/frame/revive/fixtures/contracts/Arithmetic.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Arithmetic {
function testArithmetic() public {
// ADD tests
require(20 + 22 == 42, "ADD basic");

// SUB tests
require(42 - 20 == 22, "SUB basic");

// MUL tests
require(20 * 22 == 440, "MUL basic");

// DIV tests
require(100 / 5 == 20, "DIV basic");

// SDIV tests
require(int(-100) / 5 == -20, "SDIV neg/pos");
require(int(100) / -5 == -20, "SDIV pos/neg");
require(int(-100) / -5 == 20, "SDIV neg/neg");

// REM/MOD tests
require(100 % 7 == 2, "REM basic");

// SMOD tests
require(int(-100) % 7 == -2, "SMOD neg dividend");
require(int(100) % -7 == 2, "SMOD neg divisor");

// ADDMOD tests
require((10 + 15) % 7 == 4, "ADDMOD basic");

// MULMOD tests
require((10 * 15) % 7 == 3, "MULMOD basic");

// EXP tests
require(2 ** 3 == 8, "EXP basic");
require(10 ** 0 == 1, "EXP zero exponent");
require(0 ** 5 == 0, "EXP zero base");

// SIGNEXTEND tests
uint result1;
assembly {
result1 := signextend(0, 0xff)
}
require(result1 == type(uint256).max, "SIGNEXTEND negative byte");
uint result2;
assembly {
result2 := signextend(0, 0x7f)
}
require(result2 == 0x7f, "SIGNEXTEND positive byte");
}
}
30 changes: 30 additions & 0 deletions substrate/frame/revive/fixtures/contracts/Bitwise.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract Bitwise {
function testBitwise() public pure {
require(5 < 10, "LT basic");
require(type(uint256).max - 1 < type(uint256).max, "LT max");

require(10 > 5, "GT basic");
require(type(uint256).max > type(uint256).max - 1, "GT max");

require(5 != 10, "NEQ basic");
require(10 == 10, "EQ basic");
require(type(uint256).max == type(uint256).max, "EQ max");

require(int(-5) < int(10), "SLT basic");
require(type(int256).min < 0, "SLT min");

require(int(5) > int(-10), "SGT basic");
require(0 > type(int256).min, "SGT min");

require((5 & 3) == 1, "AND basic");
require((5 | 3) == 7, "OR basic");
require((5 ^ 3) == 6, "XOR basic");
require(~uint(0) == type(uint256).max, "NOT basic");

require((1 << 3) == 8, "SHL basic");
require((8 >> 3) == 1, "SHR basic");
}
}
11 changes: 11 additions & 0 deletions substrate/frame/revive/fixtures/contracts/Fibonacci.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Fibonacci {
function fib(uint n) public pure returns (uint) {
if (n <= 1) {
return n;
}
return fib(n - 1) + fib(n - 2);
}
}
91 changes: 91 additions & 0 deletions substrate/frame/revive/fixtures/contracts/Host.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

contract Host {
function balance(address account) public view returns (uint256) {
return account.balance;
}

function extcodesizeOp(address account) public view returns (uint256) {
uint256 size;
assembly {
size := extcodesize(account)
}
return size;
}

function extcodehashOp(address account) public view returns (bytes32) {
bytes32 hash;
assembly {
hash := extcodehash(account)
}
return hash;
}

function blockhashOp(uint256 blockNumber) public view returns (bytes32) {
bytes32 hash;
assembly {
hash := blockhash(blockNumber)
}
return hash;
}

function sloadOp(uint256 slot) public view returns (uint256) {
uint256 value;
assembly {
value := sload(slot)
}
return value;
}

function sstoreOp(uint256 slot, uint256 value) public {
assembly {
sstore(slot, value)
}
}

function log0Op(bytes32 data) public {
assembly {
log0(data, 0x20)
}
}

function log1Op(bytes32 data, bytes32 topic1) public {
assembly {
log1(data, 0x20, topic1)
}
}

function log2Op(bytes32 data, bytes32 topic1, bytes32 topic2) public {
assembly {
log2(data, 0x20, topic1, topic2)
}
}

function log3Op(
bytes32 data,
bytes32 topic1,
bytes32 topic2,
bytes32 topic3
) public {
assembly {
log3(data, 0x20, topic1, topic2, topic3)
}
}

function log4Op(
bytes32 data,
bytes32 topic1,
bytes32 topic2,
bytes32 topic3,
bytes32 topic4
) public {
assembly {
log4(data, 0x20, topic1, topic2, topic3, topic4)
}
}

function selfbalance() public view returns (uint256) {
return address(this).balance;
}
}
20 changes: 20 additions & 0 deletions substrate/frame/revive/fixtures/contracts/HostEvmOnly.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract HostEvmOnly {
function selfdestructOp(address payable recipient) public {
assembly {
selfdestruct(recipient)
}
}
function extcodecopyOp(
address account,
uint256 offset,
uint256 size
) public view returns (bytes memory code) {
code = new bytes(size);
assembly {
extcodecopy(account, add(code, 32), offset, size)
}
}
}
19 changes: 19 additions & 0 deletions substrate/frame/revive/fixtures/contracts/HostTransientMemory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

contract HostTransientMemory {
function transientMemoryTest(
uint256 slot,
uint256 a
) public returns (uint256) {
uint256 value;
assembly {
tstore(slot, a)
}
value = 1;
assembly {
value := tload(slot)
}
return value - a;
}
}
Loading
Loading