-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[pallet-revive] EVM backend: implement various missing opcodes #9385
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
Merged
Merged
Changes from all commits
Commits
Show all changes
460 commits
Select commit
Hold shift + click to select a range
f8da76f
refactoring
pgherveou b1b1192
fix clippy
pgherveou 50aeaab
Merge remote-tracking branch 'origin/pg/revm' into sm/vm-instr
smiasojed a829fab
fix clippy
pgherveou 1066074
fixedd test for INVALID opcode
d11dd3f
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
9f9cbc1
Add instantiate with code type support
smiasojed 4b5edb5
added assert for flag revert
e482eee
added tests for stack
fd57f68
review comments
de65cce
rustfmt
69602ac
added selfdestruct
d9e50a1
cleanup
b9c406e
rustfmt
24f4c6d
license
b8970a0
rustfmt
ade000c
fmt
c6378fb
fix macro import issue
b6e6738
Add system instruction tests
smiasojed 3e1fc33
cargo check
dba3403
removed loggings
8112b00
cleanup
883af60
removed decode_revert_message
4731b5e
cargo +nightly fmt
pgherveou 3c4f5c4
Merge branch 'master' into pg/revm
pgherveou 953ee61
merge fix
pgherveou 7cee5be
simplify migration tests
pgherveou b8dc717
add migration
pgherveou 3503649
removed EVM version check from evm instructions
574fb97
removed log::info and println
81578a0
remove unneeded tests for this PR
pgherveou fa0ffa9
fix CALLDATACOPY gas
22cd095
cleanup
9df994e
added comments to control assembly contracts for jump and jumpi
2f13212
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
6000ed4
fixes
pgherveou c679776
keep these files for next PR
pgherveou 5f839b6
comments
pgherveou 8110392
fixes
pgherveou 7a1c0a6
fix
pgherveou f3289d4
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
3512769
fix after merge
3b19c42
fmt
fa902be
make cargo check pass
4657b64
fmt
83ea8cd
Update from github-actions[bot] running command 'bench --runtime dev …
github-actions[bot] 1c39f58
Add system instr and tests cleanup
smiasojed 6706b9c
fix clippy
165957c
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] 2b07ca6
rename seal_to_account_id
pgherveou 0c4d0cd
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
f96fa39
update PRDOC
pgherveou 2f369ad
Merge branch 'master' into pg/revm
pgherveou 9f92c36
install solc in workflow
b66b47a
fix bench
pgherveou 3fea6b5
Improve gas handling for CREATE intruction
smiasojed 4d0db7e
output.data shoudl be untouched
pgherveou b7c0f7f
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
674e559
fix host test
42f8c2d
fmt
f5caa32
review fixes
4a98ea1
moved transfer_with_dust out of the transfer function
0784a4a
semicolon
b747e98
removed allow deadcode from H160Mapper in address.rs
79b84da
install solidity in job
pgherveou 484edb2
fixed some stuff in host instructions
c907833
fmt
6403ef1
added install resolc to tests-misc.yml
4b80099
use resolc too
pgherveou 4b6f4d2
rm line
pgherveou 28b6217
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
c2332ca
trigger ci
ab15dc1
enforce evm code size limit
pgherveou e93c1a0
fix
pgherveou 04d0551
fix
pgherveou 8f8ebcc
fix
pgherveou dbb4b93
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
47b39c1
fixed gas in hsot.rs
d1d5199
cleanup
dec0849
PR review
pgherveou cc45f5b
Code cleanup and calls refactoring
smiasojed ea5011b
Update substrate/frame/revive/src/exec.rs
smiasojed dbfc430
make pristine unbounded and check PVM & EVM code size
pgherveou b4e868f
create: set caller frame
xermicus 87b7b4e
nit
pgherveou b4dad01
added comments
fbdd9fc
commented code so that estending memory will not cost any gas
cb8b8ce
added TODO in host.rs instruction for extcodecopy gas macro
ee7c237
unused vars in macros.rs
b769010
refcount = 1 for evm
pgherveou 5a6c9f2
the exec error to halt reason mapping function
xermicus 0abfc74
fix
pgherveou 6060eb4
fix
pgherveou 2007fb5
add one more assert
pgherveou f219e06
nit
pgherveou 5a965c7
the callcode instruction is unsupported
xermicus 6f25eed
typos
xermicus 99718d6
typos
xermicus 2a88092
format the fixtures
xermicus 33e9216
Remove refcount and owner for EVM CodeInfo
pgherveou f75403a
rm unused
pgherveou d26d8ac
origin should be held not caller
pgherveou cc8cef4
Merge branch 'master' into pg/revm
pgherveou b61416a
Rm copy cost from call
smiasojed d647759
fix ci
63290b9
dummy chang
d22ac45
nit
8bd37b6
fix ci
9d40097
changed prdoc to major
e405e18
rollback refcount removals
pgherveou 8b1669f
Update Cargo.toml
pgherveou 4f86e9b
Update prdoc/pr_9285.prdoc
pgherveou 315ae52
Update substrate/frame/revive/src/call_builder.rs
pgherveou 3598d6f
Update substrate/frame/revive/src/benchmarking.rs
pgherveou 3272e99
rm charge_evm_init_cost
pgherveou e2242a2
fix
pgherveou 7fa6421
rm - 1
pgherveou ae647b6
restore legacy behaviour
pgherveou e374a38
fix selfdestruct in exec.rs and host.rs
3197e68
Add revert test and fix errors mapping
smiasojed 9c56173
Add call tests
smiasojed 38602a5
format fixtures
xermicus 4971e97
the unified error mapping approach
xermicus 90656f2
Enable invalid opcode test for EVM
smiasojed 1a073b6
update
pgherveou 2765b13
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
ce5254d
the instruction result to exec error mapping function
xermicus 11fbe30
using U256Converter trait
d4d8c1a
deadcode unused for now
pgherveou 511fe2b
the INVALID EVM opcode test
xermicus 115c860
Reject bytecode starting with 0xef (EOF)
smiasojed 17b713a
Merge branch 'pg/revm' into sm/vm-instr
xermicus f0b629d
fixed gas charge in host sstore and tstore
eac460a
the create tester needs value to instantiate contracts
xermicus e286c49
deposit fixes
pgherveou f9aebdc
add missing assert
pgherveou 7232f99
tweak tests
pgherveou 6d0181e
fixed copy paste mistake
04001a2
fixed review comment
f68a53d
remove allow deadcode in utility.rs
f175c1b
ensure pallet_account exits
pgherveou 76a2078
Use U256 converter
smiasojed bf19cf0
fixes
pgherveou 7211711
nit
pgherveou c1ba77d
update comment
pgherveou 46f6dfb
Add back remove_code
pgherveou d137f91
fix ci
135a9e0
Merge remote-tracking branch 'origin/pg/revm' into sm/vm-instr
smiasojed a7c3083
Add missing license
smiasojed 546d65d
nit
pgherveou 51ba0f7
trigger ci
4edc46e
format
7afade1
fix compilation issue
972a51f
Address comment
smiasojed 9a34932
Update substrate/frame/revive/src/vm/evm.rs
smiasojed d820477
Update substrate/frame/revive/src/lib.rs
pgherveou c16e6ce
mint balance in migration
pgherveou 1541263
rm check
pgherveou 0a8935c
fmt
pgherveou 692abb2
fixes
pgherveou d1808d6
added test for invalid jumpdest
a504987
reject hash == 0
pgherveou a064b21
review comments
4283724
removed formatting diff
3a9f3d7
warm up pallet_account
pgherveou c245621
Update substrate/frame/revive/src/migrations/v2.rs
pgherveou f04044f
Apply comments
smiasojed 29765fc
fix unused variable
88c6b23
Update ExtBuilder
pgherveou 60b168d
Fmt
smiasojed 5dc7d0b
Add assert for gas checking
smiasojed 3201fb2
Merge branch 'master' into pg/revm
pgherveou a4be918
fix selfdestruct
400c912
Update .github/workflows/tests-misc.yml
pgherveou a1178f3
Update from github-actions[bot] running command 'bench --runtime dev …
github-actions[bot] 0362daf
added contracts_created check to selfdestruct in Stack
f79c8dd
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
d502f36
fix tests-misc
pgherveou 28a1b65
fix
pgherveou 739300d
test for selfdestruct needs create
3f5bc89
Merge remote-tracking branch 'origin/pg/revm' into rve/revm-instructi…
80b2d56
Merge branch 'pg/revm' into sm/vm-instr
pgherveou d85b361
Merge branch 'master' into sm/vm-instr
pgherveou 44ea81c
fix log level
pgherveou 4e58574
fix
pgherveou da38232
Merge remote-tracking branch 'origin/sm/vm-instr' into rve/revm-instr…
7d1da2a
disabled test call_invalid_opcode
80ffaa4
fix CI
73aaaee
selfdestruct_delete_works not working
4b491f9
make it compile
b57e6d3
Merge remote-tracking branch 'origin/master' into rve/revm-instructio…
167e660
format
0c18dda
Update prdoc/pr_9385.prdoc
0xRVE 3a32468
clippy
4fc05d1
disable selfdestruct
588d5a6
mark selfdestruct allow unused
15b6f09
review comment
f25f383
fix extcodecopy
b14da8c
fix ci
71c2eaa
review comments
b32b38a
review comments
761ee3a
review comments
90acbae
fix ci
c588272
fix ci
3e489f3
fix ci
5897946
fix sstore and tstore
36bbf73
make helper function fo tstore and sstore
35219f5
Update substrate/frame/revive/src/vm/evm/instructions/host.rs
0xRVE 430382e
fix ci
20c15ba
Merge remote-tracking branch 'origin/master' into rve/revm-instructio…
b0ac8a7
fixed extcodecopy
2db7b3b
fix ci
2a2dcac
Update substrate/frame/revive/src/gas.rs
0xRVE c4f683c
review comments
14dbb55
fixe blockhash funtion host.rs
c9df245
fixed extcodecopy
0b23327
fix ci
6446e99
Merge remote-tracking branch 'origin/master' into rve/revm-instructio…
b54b341
fix ci
dabf62e
[pallet-revive] add logs ops (#9636)
pgherveou 47dca7f
[pallet-revive] extcodecopy benchmark (#9639)
pgherveou 4e7c04f
format
5404906
[pallet-revive] memory bounds check (#9635)
pgherveou 2c2c5b3
fix n->r
pgherveou 3b54a83
rm require_non_staticcall
pgherveou 9ea4766
fmt
pgherveou 60cf295
add extra test
pgherveou 2b436cd
just to be safe
pgherveou bdfc7b3
move released primitives and APIs out of staging (#9443)
Sajjon 39e4f80
Account for PoV size when enqueing XCMP message (#9641)
serban300 18436f5
Merge branch 'master' into rve/revm-instructions-bitwise
pgherveou 0c909ed
prdoc
3673647
Update substrate/frame/revive/src/exec.rs
0xRVE c74c1ce
fix unsafe allocation extcodecopy
b1477e0
Merge remote-tracking branch 'origin/master' into rve/revm-instructio…
f15f4ba
Update substrate/frame/revive/src/benchmarking.rs
pgherveou 4030738
Update from github-actions[bot] running command 'bench --runtime dev …
github-actions[bot] 320eed7
fix extcodecopy
pgherveou 68f9f68
nit
pgherveou cf03e40
simplify test
pgherveou 2603ef5
fmt
pgherveou 63d7c6d
clippy
pgherveou 76123ae
uncomment test
pgherveou 10d64ce
fixes
pgherveou 6383891
mv comment
pgherveou 6f27389
Update substrate/frame/revive/src/exec.rs
pgherveou a8e2f32
Update substrate/frame/revive/src/exec.rs
pgherveou d1b48f4
Update substrate/frame/revive/src/exec.rs
pgherveou 372c2c0
Update from github-actions[bot] running command 'fmt'
github-actions[bot] 8d8819a
Merge branch 'master' into rve/revm-instructions-bitwise
athei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
|
0xRVE marked this conversation as resolved.
0xRVE marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); | ||
| } | ||
| } |
|
0xRVE marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
19
substrate/frame/revive/fixtures/contracts/HostTransientMemory.sol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.