Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
460 commits
Select commit Hold shift + click to select a range
f8da76f
refactoring
pgherveou Aug 19, 2025
b1b1192
fix clippy
pgherveou Aug 19, 2025
50aeaab
Merge remote-tracking branch 'origin/pg/revm' into sm/vm-instr
smiasojed 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
9f9cbc1
Add instantiate with code type support
smiasojed 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
b6e6738
Add system instruction tests
smiasojed 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
1c39f58
Add system instr and tests cleanup
smiasojed 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
3fea6b5
Improve gas handling for CREATE intruction
smiasojed Aug 22, 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
cc45f5b
Code cleanup and calls refactoring
smiasojed Aug 26, 2025
ea5011b
Update substrate/frame/revive/src/exec.rs
smiasojed Aug 26, 2025
dbfc430
make pristine unbounded and check PVM & EVM code size
pgherveou Aug 26, 2025
b4e868f
create: set caller frame
xermicus 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
5a6c9f2
the exec error to halt reason mapping function
xermicus 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
5a965c7
the callcode instruction is unsupported
xermicus Aug 26, 2025
6f25eed
typos
xermicus Aug 26, 2025
99718d6
typos
xermicus Aug 26, 2025
2a88092
format the fixtures
xermicus 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
b61416a
Rm copy cost from call
smiasojed 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
3197e68
Add revert test and fix errors mapping
smiasojed Aug 27, 2025
9c56173
Add call tests
smiasojed Aug 27, 2025
38602a5
format fixtures
xermicus Aug 28, 2025
4971e97
the unified error mapping approach
xermicus Aug 28, 2025
90656f2
Enable invalid opcode test for EVM
smiasojed Aug 28, 2025
1a073b6
update
pgherveou Aug 28, 2025
2765b13
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 28, 2025
ce5254d
the instruction result to exec error mapping function
xermicus Aug 28, 2025
11fbe30
using U256Converter trait
Aug 28, 2025
d4d8c1a
deadcode unused for now
pgherveou Aug 28, 2025
511fe2b
the INVALID EVM opcode test
xermicus Aug 28, 2025
115c860
Reject bytecode starting with 0xef (EOF)
smiasojed Aug 28, 2025
17b713a
Merge branch 'pg/revm' into sm/vm-instr
xermicus Aug 28, 2025
f0b629d
fixed gas charge in host sstore and tstore
Aug 28, 2025
eac460a
the create tester needs value to instantiate contracts
xermicus Aug 28, 2025
e286c49
deposit fixes
pgherveou Aug 28, 2025
f9aebdc
add missing assert
pgherveou Aug 28, 2025
7232f99
tweak tests
pgherveou 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
f175c1b
ensure pallet_account exits
pgherveou Aug 28, 2025
76a2078
Use U256 converter
smiasojed Aug 28, 2025
bf19cf0
fixes
pgherveou Aug 29, 2025
7211711
nit
pgherveou Aug 29, 2025
c1ba77d
update comment
pgherveou Aug 29, 2025
46f6dfb
Add back remove_code
pgherveou Aug 29, 2025
d137f91
fix ci
Aug 29, 2025
135a9e0
Merge remote-tracking branch 'origin/pg/revm' into sm/vm-instr
smiasojed Aug 29, 2025
a7c3083
Add missing license
smiasojed Aug 29, 2025
546d65d
nit
pgherveou Aug 29, 2025
51ba0f7
trigger ci
Aug 29, 2025
4edc46e
format
Aug 29, 2025
7afade1
fix compilation issue
Aug 29, 2025
972a51f
Address comment
smiasojed Aug 29, 2025
9a34932
Update substrate/frame/revive/src/vm/evm.rs
smiasojed Aug 29, 2025
d820477
Update substrate/frame/revive/src/lib.rs
pgherveou Aug 29, 2025
c16e6ce
mint balance in migration
pgherveou Aug 29, 2025
1541263
rm check
pgherveou Aug 29, 2025
0a8935c
fmt
pgherveou Aug 29, 2025
692abb2
fixes
pgherveou Aug 29, 2025
d1808d6
added test for invalid jumpdest
Aug 29, 2025
a504987
reject hash == 0
pgherveou Aug 29, 2025
a064b21
review comments
Aug 29, 2025
4283724
removed formatting diff
Aug 29, 2025
3a9f3d7
warm up pallet_account
pgherveou Aug 29, 2025
c245621
Update substrate/frame/revive/src/migrations/v2.rs
pgherveou Aug 29, 2025
f04044f
Apply comments
smiasojed Aug 29, 2025
29765fc
fix unused variable
Aug 29, 2025
88c6b23
Update ExtBuilder
pgherveou Aug 29, 2025
60b168d
Fmt
smiasojed Aug 29, 2025
5dc7d0b
Add assert for gas checking
smiasojed Aug 29, 2025
3201fb2
Merge branch 'master' into pg/revm
pgherveou Aug 29, 2025
a4be918
fix selfdestruct
Aug 29, 2025
400c912
Update .github/workflows/tests-misc.yml
pgherveou Aug 29, 2025
a1178f3
Update from github-actions[bot] running command 'bench --runtime dev …
github-actions[bot] Aug 29, 2025
0362daf
added contracts_created check to selfdestruct in Stack
Aug 31, 2025
f79c8dd
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Aug 31, 2025
d502f36
fix tests-misc
pgherveou Sep 1, 2025
28a1b65
fix
pgherveou Sep 1, 2025
739300d
test for selfdestruct needs create
Sep 1, 2025
3f5bc89
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
Sep 1, 2025
80b2d56
Merge branch 'pg/revm' into sm/vm-instr
pgherveou Sep 1, 2025
d85b361
Merge branch 'master' into sm/vm-instr
pgherveou Sep 1, 2025
44ea81c
fix log level
pgherveou Sep 1, 2025
4e58574
fix
pgherveou Sep 1, 2025
da38232
Merge remote-tracking branch 'origin/sm/vm-instr' into rve/revm-instr…
Sep 1, 2025
7d1da2a
disabled test call_invalid_opcode
Sep 1, 2025
80ffaa4
fix CI
Sep 1, 2025
73aaaee
selfdestruct_delete_works not working
Sep 1, 2025
4b491f9
make it compile
Sep 2, 2025
b57e6d3
Merge remote-tracking branch 'origin/master' into rve/revm-instructio…
Sep 2, 2025
167e660
format
Sep 2, 2025
0c18dda
Update prdoc/pr_9385.prdoc
0xRVE Sep 2, 2025
3a32468
clippy
Sep 2, 2025
4fc05d1
disable selfdestruct
Sep 2, 2025
588d5a6
mark selfdestruct allow unused
Sep 2, 2025
15b6f09
review comment
Sep 2, 2025
f25f383
fix extcodecopy
Sep 2, 2025
b14da8c
fix ci
Sep 2, 2025
71c2eaa
review comments
Sep 2, 2025
b32b38a
review comments
Sep 2, 2025
761ee3a
review comments
Sep 2, 2025
90acbae
fix ci
Sep 2, 2025
c588272
fix ci
Sep 2, 2025
3e489f3
fix ci
Sep 2, 2025
5897946
fix sstore and tstore
Sep 2, 2025
36bbf73
make helper function fo tstore and sstore
Sep 2, 2025
35219f5
Update substrate/frame/revive/src/vm/evm/instructions/host.rs
0xRVE Sep 2, 2025
430382e
fix ci
Sep 2, 2025
20c15ba
Merge remote-tracking branch 'origin/master' into rve/revm-instructio…
Sep 2, 2025
b0ac8a7
fixed extcodecopy
Sep 3, 2025
2db7b3b
fix ci
Sep 3, 2025
2a2dcac
Update substrate/frame/revive/src/gas.rs
0xRVE Sep 3, 2025
c4f683c
review comments
Sep 3, 2025
14dbb55
fixe blockhash funtion host.rs
Sep 3, 2025
c9df245
fixed extcodecopy
Sep 3, 2025
0b23327
fix ci
Sep 3, 2025
6446e99
Merge remote-tracking branch 'origin/master' into rve/revm-instructio…
Sep 3, 2025
b54b341
fix ci
Sep 3, 2025
dabf62e
[pallet-revive] add logs ops (#9636)
pgherveou Sep 4, 2025
47dca7f
[pallet-revive] extcodecopy benchmark (#9639)
pgherveou Sep 4, 2025
4e7c04f
format
Sep 4, 2025
5404906
[pallet-revive] memory bounds check (#9635)
pgherveou Sep 4, 2025
2c2c5b3
fix n->r
pgherveou Sep 4, 2025
3b54a83
rm require_non_staticcall
pgherveou Sep 4, 2025
9ea4766
fmt
pgherveou Sep 4, 2025
60cf295
add extra test
pgherveou Sep 4, 2025
2b436cd
just to be safe
pgherveou Sep 4, 2025
bdfc7b3
move released primitives and APIs out of staging (#9443)
Sajjon Sep 3, 2025
39e4f80
Account for PoV size when enqueing XCMP message (#9641)
serban300 Sep 4, 2025
18436f5
Merge branch 'master' into rve/revm-instructions-bitwise
pgherveou Sep 4, 2025
0c909ed
prdoc
Sep 4, 2025
3673647
Update substrate/frame/revive/src/exec.rs
0xRVE Sep 5, 2025
c74c1ce
fix unsafe allocation extcodecopy
Sep 5, 2025
b1477e0
Merge remote-tracking branch 'origin/master' into rve/revm-instructio…
Sep 8, 2025
f15f4ba
Update substrate/frame/revive/src/benchmarking.rs
pgherveou Sep 8, 2025
4030738
Update from github-actions[bot] running command 'bench --runtime dev …
github-actions[bot] Sep 8, 2025
320eed7
fix extcodecopy
pgherveou Sep 8, 2025
68f9f68
nit
pgherveou Sep 8, 2025
cf03e40
simplify test
pgherveou Sep 8, 2025
2603ef5
fmt
pgherveou Sep 8, 2025
63d7c6d
clippy
pgherveou Sep 8, 2025
76123ae
uncomment test
pgherveou Sep 8, 2025
10d64ce
fixes
pgherveou Sep 8, 2025
6383891
mv comment
pgherveou Sep 8, 2025
6f27389
Update substrate/frame/revive/src/exec.rs
pgherveou Sep 8, 2025
a8e2f32
Update substrate/frame/revive/src/exec.rs
pgherveou Sep 8, 2025
d1b48f4
Update substrate/frame/revive/src/exec.rs
pgherveou Sep 8, 2025
372c2c0
Update from github-actions[bot] running command 'fmt'
github-actions[bot] Sep 8, 2025
8d8819a
Merge branch 'master' into rve/revm-instructions-bitwise
athei Sep 8, 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
16 changes: 16 additions & 0 deletions prdoc/pr_9385.prdoc
Comment thread
xermicus marked this conversation as resolved.
Comment thread
0xRVE marked this conversation as resolved.
Comment thread
0xRVE marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
title: Rve/revm instructions bitwise WIP
doc:
- audience: Runtime Dev
description: |
Extend EVM support for pallet_revive with the follow instructions:
- arithmetic
- bitwise
- control
- host
- memory
- stack
crates:
- name: pallet-revive-fixtures
bump: minor
- name: pallet-revive
bump: major
11 changes: 9 additions & 2 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
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
Comment thread
0xRVE marked this conversation as resolved.
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");
}
}
91 changes: 17 additions & 74 deletions substrate/frame/revive/fixtures/contracts/Host.sol
Original file line number Diff line number Diff line change
@@ -1,116 +1,59 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
pragma solidity ^0.8.24;

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

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

function extcodecopy(
address /* account */,
uint256 /* destOffset */,
uint256 /* offset */,
uint256 size
) public pure returns (bytes memory) {
bytes memory code = new bytes(size);
return code;
}

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

function blockhash(uint256 blockNumber) public view returns (bytes32) {
return blockhash(blockNumber);
}

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

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

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

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

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

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

function log2(bytes32 data, bytes32 topic1, bytes32 topic2) public {
function sstoreOp(uint256 slot, uint256 value) public {
assembly {
log2(data, 0x20, topic1, topic2)
}
}

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

function log4(
bytes32 data,
bytes32 topic1,
bytes32 topic2,
bytes32 topic3,
bytes32 topic4
) public {
function logOps() public {
assembly {
log4(data, 0x20, topic1, topic2, topic3, topic4)
log0(0x01, 0x20)
log1(0x02, 0x20, 0x11)
log2(0x03, 0x20, 0x22, 0x33)
log3(0x04, 0x20, 0x44, 0x55, 0x66)
log4(0x05, 0x20, 0x77, 0x88, 0x99, 0xaa)
}
}

function selfdestruct(address payable recipient) public {
selfdestruct(recipient);
}

function selfbalance() public view returns (uint256) {
return address(this).balance;
}
Expand Down
33 changes: 33 additions & 0 deletions substrate/frame/revive/fixtures/contracts/HostEvmOnly.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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)
}
}
}

contract HostEvmOnlyFactory {
function createAndSelfdestruct(address payable recipient) public returns (address newContract) {
// Deploy a new instance of HostEvmOnly
HostEvmOnly newInstance = new HostEvmOnly();
newContract = address(newInstance);

// Call selfdestruct on the newly created contract
newInstance.selfdestructOp(recipient);

return newContract;
}
}
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