-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[pallet-revive] EVM backend: Implement tx, block system and call stack instructions #9414
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 250 commits
Commits
Show all changes
266 commits
Select commit
Hold shift + click to select a range
18108f7
fix
pgherveou 68e4ae4
fixes
pgherveou 7f650f3
fixes
pgherveou 380a1b4
fix build
pgherveou e0e5316
Update from github-actions[bot] running command 'bench --runtime dev …
github-actions[bot] 8c21f11
Fix seal_call benchmark
pgherveou 8158cea
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] 215e8a3
Update from github-actions[bot] running command 'bench --runtime dev …
github-actions[bot] a2aa1a1
Merge branch 'master' into pg/fix-seal-call-weights
pgherveou 0c6059f
Merge branch 'pg/fix-seal-call-weights' into pg/eth-decimals
pgherveou be98709
fixes
pgherveou 66d14f8
add migration
pgherveou cb06489
get rid of dust_account_id
pgherveou 1edd2c2
fixes
pgherveou 7840bdd
Update from github-actions[bot] running command 'bench --runtime dev …
github-actions[bot] 3631e90
lint fix
pgherveou c387d13
nit updates
pgherveou e9e6038
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] 3ce1df7
fix pallet-xcm test
pgherveou a1d9b7c
fix build err
pgherveou 3f27159
fix assets precompible build
pgherveou e3403f3
fix
pgherveou 5b9c6ed
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] f386278
Merge branch 'master' into pg/eth-decimals
pgherveou 5f7adfa
pallet-xcm
pgherveou 0cae21f
Update bench tests
pgherveou 8a11d71
Update from github-actions[bot] running command 'bench --runtime dev …
github-actions[bot] 74cb003
Update cargo files
pgherveou fc31a0e
store the runtime code for EVM instantiate
pgherveou bf2c046
wip
pgherveou 4c3c09f
wip
pgherveou 279c132
fix
pgherveou 9e7ee08
fix
pgherveou a37dd15
PR review move has_dust and has_balance and remove pub
pgherveou a764344
use local function instead of closure
pgherveou 6eb87c8
make migration
pgherveou 2959185
scope function
pgherveou 41c7afd
charge 0 for input_data_len on err
pgherveou e74ed21
comment bench_map
pgherveou 2d8d417
use drain to remove old storage in migration
pgherveou bdc1365
make balance, dust private in BalanceWithDust
pgherveou c94be4f
Update substrate/frame/revive/src/migrations/v1.rs
pgherveou 7d3bca0
Revert "Update substrate/frame/revive/src/migrations/v1.rs"
pgherveou a2a5a18
add migration unit test
pgherveou 0dc2210
typo
pgherveou e8ca9fb
Add additional tests
pgherveou 1da95a2
Merge branch 'master' into pg/eth-decimals
pgherveou 7e9f2c9
Merge branch 'pg/eth-decimals' into pg/revm
pgherveou 874e7c0
update lock
pgherveou d7eb888
wip
pgherveou 38c2b80
add instructions
pgherveou a55cc7a
wip
pgherveou 3a42cf7
split evm / pvm
pgherveou 8af812d
basic host interaction
pgherveou 165b7e7
fix gas
pgherveou ec3d84f
Merge branch 'master' into pg/revm
pgherveou ade709b
wip
pgherveou 65ddd58
update lock
pgherveou 006cb15
fix
pgherveou c3ff24a
rm
pgherveou 661d251
fix
pgherveou 8b55fe8
Update
pgherveou 8335340
fix
pgherveou 538bf49
comment bitwise test for now
pgherveou 70d07b9
Add AllowEVMBytecode config
pgherveou 364201c
wip
pgherveou a2edcbe
fix compile error
pgherveou 97c00f4
fixes
pgherveou 6edb4a1
use 0 value
pgherveou 053c548
[pallet-revive] revm tests scaffolding (#9290)
xermicus b45b1a2
move back fixture to fixtures folder and generate them from build.rs
pgherveou 27b62f7
add skeleton for fixtures
pgherveou acf0e6e
wip
pgherveou f47d7b5
fixes
pgherveou 31c0595
update build.rs
pgherveou 3a07569
nit
pgherveou 9adf741
fixes
pgherveou b1dbf5d
add missing headers
pgherveou 4341d6d
Merge branch 'master' into pg/revm
pgherveou 91e59e5
add test allow_evm_bytecode_config_works
pgherveou da7473d
fix lock
pgherveou df8d71d
Update from github-actions[bot] running command 'fmt'
github-actions[bot] 359b181
fixes
pgherveou 58b9220
Rve/revm arithmetic instructions WIP (#9361)
0xRVE 5b304a0
fixes gas computation of evm arithemtic instructions (#9379)
0xRVE c441672
Add block info instructions to revm
smiasojed 3736b5c
Fix timestamp test
smiasojed 6da9ed6
Add tx info instructions
smiasojed 05fa48b
Add system instructions
smiasojed b9c5780
Add call instruction support
smiasojed cf22948
Improve cross contract calls
smiasojed d318b27
Cleanup
smiasojed 37de6ea
Fix error codes
smiasojed 8817d7e
Revert "fixes gas computation of evm arithemtic instructions (#9379)"
02198ce
Revert "Rve/revm arithmetic instructions WIP (#9361)"
fccdb93
charge precompile call base costs
xermicus bb14f1c
[pallet-revive] do not silently fail Solidity fixtures compilation (#…
xermicus b5782a4
more generic call tester
xermicus 490d59c
Merge branch 'pg/revm' into sm/vm-instr
xermicus 1bfbaa8
refactor more benchmarks
pgherveou 7d867a4
Add CREATE opcode support
smiasojed eafa023
Add Create opcode test
smiasojed fa34f22
Applied comments
smiasojed 42bea89
Apply comments
smiasojed 452c853
Create2 works
smiasojed 155f2d4
Add delegate and call instructions
smiasojed 7f79d2e
Merge branch 'master' into pg/revm
pgherveou 076246c
Merge branch 'master' into pg/revm
pgherveou b2ceaae
revm file shuffling
pgherveou 7e68c51
fixes
pgherveou 6ec1681
rm stuff for later
pgherveou c89d026
rm evm
pgherveou d53e0ac
rm evm stuff
pgherveou edde1d1
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] 4f38703
rm
pgherveou ab3761e
taplo fix
pgherveou 7dadbc1
fix up cargo.lock
pgherveou abcd13c
try
pgherveou 6d30298
fixes
pgherveou 68e9a84
Merge branch 'master' into pg/revm-base
pgherveou 551c711
rm vm/runtime.rs
pgherveou 2c308d7
Merge branch 'pg/revm-base' into pg/revm
pgherveou 2debf91
fix
pgherveou 0175328
nit
pgherveou 22aff1d
Add gas and keccak256 instructions
smiasojed 59e59e8
fixes
pgherveou 6a38acd
Address comments
smiasojed f1f2ffc
nit
pgherveou 82ea9bc
update call_with_code_per_byte
pgherveou 20511d1
fixes
pgherveou e1bbcb9
added migration
pgherveou 78c92d3
Merge branch 'master' into pg/revm-base
pgherveou 3789665
Merge branch 'pg/revm-base' into pg/revm
pgherveou f8da76f
refactoring
pgherveou b1b1192
fix clippy
pgherveou 50aeaab
Merge remote-tracking branch 'origin/pg/revm' into sm/vm-instr
smiasojed a829fab
fix clippy
pgherveou 9f9cbc1
Add instantiate with code type support
smiasojed b6e6738
Add system instruction tests
smiasojed 3c4f5c4
Merge branch 'master' into pg/revm
pgherveou 953ee61
merge fix
pgherveou 7cee5be
simplify migration tests
pgherveou b8dc717
add migration
pgherveou 81578a0
remove unneeded tests for this PR
pgherveou 6000ed4
fixes
pgherveou c679776
keep these files for next PR
pgherveou 5f839b6
comments
pgherveou 8110392
fixes
pgherveou 7a1c0a6
fix
pgherveou 83ea8cd
Update from github-actions[bot] running command 'bench --runtime dev …
github-actions[bot] 1c39f58
Add system instr and tests cleanup
smiasojed 165957c
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] 2b07ca6
rename seal_to_account_id
pgherveou f96fa39
update PRDOC
pgherveou 2f369ad
Merge branch 'master' into pg/revm
pgherveou b66b47a
fix bench
pgherveou 3fea6b5
Improve gas handling for CREATE intruction
smiasojed 4d0db7e
output.data shoudl be untouched
pgherveou 79b84da
install solidity in job
pgherveou 4b80099
use resolc too
pgherveou 4b6f4d2
rm line
pgherveou ab15dc1
enforce evm code size limit
pgherveou e93c1a0
fix
pgherveou 04d0551
fix
pgherveou 8f8ebcc
fix
pgherveou 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 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 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 3197e68
Add revert test and fix errors mapping
smiasojed 9c56173
Add call tests
smiasojed 4971e97
the unified error mapping approach
xermicus 90656f2
Enable invalid opcode test for EVM
smiasojed 1a073b6
update
pgherveou ce5254d
the instruction result to exec error mapping function
xermicus 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 eac460a
the create tester needs value to instantiate contracts
xermicus e286c49
deposit fixes
pgherveou f9aebdc
add missing assert
pgherveou 7232f99
tweak tests
pgherveou 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 135a9e0
Merge remote-tracking branch 'origin/pg/revm' into sm/vm-instr
smiasojed a7c3083
Add missing license
smiasojed 546d65d
nit
pgherveou 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 a504987
reject hash == 0
pgherveou 3a9f3d7
warm up pallet_account
pgherveou c245621
Update substrate/frame/revive/src/migrations/v2.rs
pgherveou f04044f
Apply comments
smiasojed 88c6b23
Update ExtBuilder
pgherveou 60b168d
Fmt
smiasojed 5dc7d0b
Add assert for gas checking
smiasojed 3201fb2
Merge branch 'master' into pg/revm
pgherveou 400c912
Update .github/workflows/tests-misc.yml
pgherveou a1178f3
Update from github-actions[bot] running command 'bench --runtime dev …
github-actions[bot] d502f36
fix tests-misc
pgherveou 28a1b65
fix
pgherveou 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 cf357ae
the caller fixture bubbles up errors
xermicus ce8a282
add missing instruction error handling
xermicus e49b5b4
Update substrate/frame/revive/src/exec.rs
xermicus edbc42c
rename the trait method
xermicus 109841b
rename the trait method
xermicus 6d4878e
Merge branch 'master' into sm/vm-instr
xermicus 216d9d9
Update from github-actions[bot] running command 'fmt'
github-actions[bot] c561085
Update from github-actions[bot] running command 'prdoc --audience run…
github-actions[bot] 039dccf
prdoc
xermicus 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
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,32 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| contract BlockInfo { | ||
| function blockNumber() public view returns (uint) { | ||
| return block.number; | ||
| } | ||
|
|
||
| function coinbase() public view returns (address) { | ||
| return block.coinbase; | ||
| } | ||
|
|
||
| function timestamp() public view returns (uint) { | ||
| return block.timestamp; | ||
| } | ||
|
|
||
| function difficulty() public view returns (uint) { | ||
| return block.difficulty; | ||
| } | ||
|
|
||
| function gaslimit() public view returns (uint) { | ||
| return block.gaslimit; | ||
| } | ||
|
|
||
| function chainid() public view returns (uint) { | ||
| return block.chainid; | ||
| } | ||
|
|
||
| function basefee() public view returns (uint) { | ||
| return block.basefee; | ||
| } | ||
| } |
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,35 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| pragma solidity >=0.8.0; | ||
|
|
||
| contract Callee { | ||
| uint public stored; | ||
|
|
||
| function echo(uint _data) external pure returns (uint data) { | ||
| data = _data; | ||
| } | ||
|
|
||
| function whoSender() external view returns (address) { | ||
| return msg.sender; | ||
| } | ||
|
|
||
| function store(uint _data) external { | ||
| stored = _data; | ||
| } | ||
|
|
||
| function revert() public pure returns (uint256) { | ||
| require(false, "This is a revert"); | ||
| return 42; // never reached | ||
| } | ||
|
|
||
| function invalid() public pure returns (uint256 result) { | ||
| assembly { | ||
| invalid() // 0xFE opcode | ||
| } | ||
| } | ||
|
|
||
| function stop() public pure returns (uint256 result) { | ||
| assembly { | ||
| stop() | ||
| } | ||
| } | ||
| } |
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,57 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| pragma solidity >=0.8.0; | ||
|
|
||
| contract Caller { | ||
| function normal( | ||
| address _callee, | ||
| uint _value, | ||
| bytes memory _data, | ||
| uint _gas | ||
| ) external returns (bool success, bytes memory output) { | ||
| (success, output) = _callee.call{value: _value, gas: _gas}(_data); | ||
| } | ||
|
|
||
| function delegate( | ||
| address _callee, | ||
| bytes memory _data, | ||
| uint _gas | ||
| ) external returns (bool success, bytes memory output) { | ||
| (success, output) = _callee.delegatecall{gas: _gas}(_data); | ||
| } | ||
|
|
||
| function staticCall( | ||
| // Don't rename to `static` (it's a Rust keyword). | ||
| address _callee, | ||
| bytes memory _data, | ||
| uint _gas | ||
| ) external view returns (bool success, bytes memory output) { | ||
| (success, output) = _callee.staticcall{gas: _gas}(_data); | ||
| } | ||
|
|
||
| function create( | ||
| bytes memory initcode | ||
| ) external payable returns (address addr) { | ||
| assembly { | ||
| // CREATE with no value | ||
| addr := create(0, add(initcode, 0x20), mload(initcode)) | ||
| if iszero(addr) { | ||
| // bubble failure | ||
| revert(0, 0) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| function create2( | ||
| bytes memory initcode, | ||
| bytes32 salt | ||
| ) external payable returns (address addr) { | ||
| assembly { | ||
| // CREATE2 with no value | ||
| addr := create2(0, add(initcode, 0x20), mload(initcode), salt) | ||
| if iszero(addr) { | ||
| // bubble failure | ||
| revert(0, 0) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it still valid and shall be address in this PR? |
||
| } | ||
| } | ||
| } | ||
| } | ||
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,4 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8; | ||
|
|
||
| contract Dummy {} |
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,117 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| contract Host { | ||
| function balance(address account) public view returns (uint256) { | ||
| return account.balance; | ||
| } | ||
|
|
||
| function extcodesize(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) { | ||
| 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) { | ||
| assembly { | ||
| sstore(slot, value) | ||
| } | ||
| return value; | ||
| } | ||
|
|
||
| function tload(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) | ||
| } | ||
| 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 { | ||
| assembly { | ||
| log2(data, 0x20, topic1, topic2) | ||
| } | ||
| } | ||
|
|
||
| function log3( | ||
| bytes32 data, | ||
| bytes32 topic1, | ||
| bytes32 topic2, | ||
| bytes32 topic3 | ||
| ) public { | ||
| assembly { | ||
| log3(data, 0x20, topic1, topic2, topic3) | ||
| } | ||
| } | ||
|
|
||
| function log4( | ||
| bytes32 data, | ||
| bytes32 topic1, | ||
| bytes32 topic2, | ||
| bytes32 topic3, | ||
| bytes32 topic4 | ||
| ) public { | ||
| assembly { | ||
| log4(data, 0x20, topic1, topic2, topic3, topic4) | ||
| } | ||
| } | ||
|
|
||
| function selfdestruct(address payable recipient) public { | ||
| selfdestruct(recipient); | ||
| } | ||
|
|
||
| function selfbalance() public view returns (uint256) { | ||
| return address(this).balance; | ||
| } | ||
| } |
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,95 @@ | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity ^0.8.20; | ||
|
|
||
| contract System { | ||
| function keccak256Func(bytes memory data) public pure returns (bytes32) { | ||
| return keccak256(data); | ||
| } | ||
|
|
||
| function addressFunc() public view returns (address) { | ||
| return address(this); | ||
| } | ||
|
|
||
| function caller() public view returns (address) { | ||
| return msg.sender; | ||
| } | ||
|
|
||
| function callvalue() public payable returns (uint256) { | ||
| return msg.value; | ||
| } | ||
|
|
||
| function calldataload(uint256 offset) public pure returns (bytes32) { | ||
| bytes32 data; | ||
| assembly { | ||
| data := calldataload(offset) | ||
| } | ||
| return data; | ||
| } | ||
|
|
||
| function calldatasize() public pure returns (uint256) { | ||
| return msg.data.length; | ||
| } | ||
|
|
||
| function calldatacopy( | ||
| uint256 destOffset, | ||
| uint256 offset, | ||
| uint256 size | ||
| ) public pure returns (bytes memory) { | ||
| bytes memory data = new bytes(size); | ||
| assembly { | ||
| calldatacopy(add(data, 0x20), offset, size) | ||
| } | ||
| return data; | ||
| } | ||
|
|
||
| function codesize() public pure returns (uint256) { | ||
| uint256 size; | ||
| assembly { | ||
| size := codesize() | ||
| } | ||
| return size; | ||
| } | ||
|
|
||
| function codecopy( | ||
| uint256 /* destOffset */, | ||
| uint256 /* offset */, | ||
| uint256 size | ||
| ) public pure returns (bytes memory) { | ||
| bytes memory code = new bytes(size); | ||
| return code; | ||
| } | ||
|
|
||
| function returndatasize( | ||
| address _callee, | ||
| bytes memory _data, | ||
| uint _gas | ||
| ) public returns (uint256) { | ||
| uint256 size; | ||
| _callee.staticcall{gas: _gas}(_data); | ||
| assembly { | ||
| size := returndatasize() | ||
| } | ||
| return size; | ||
| } | ||
|
|
||
| function returndatacopy( | ||
| address _callee, | ||
| bytes memory _data, | ||
| uint _gas, | ||
| uint256 destOffset, | ||
| uint256 offset, | ||
| uint256 size | ||
| ) public returns (bytes memory) { | ||
| bytes memory data = new bytes(size); | ||
| _callee.staticcall{gas: _gas}(_data); | ||
| assembly { | ||
| returndatacopy(add(data, 0x20), offset, size) | ||
| } | ||
| return data; | ||
| } | ||
|
|
||
| function gas() public view returns (uint256) { | ||
| return gasleft(); | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
substrate/frame/revive/fixtures/contracts/TransactionInfo.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,16 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| contract TransactionInfo { | ||
| function origin() public view returns (address) { | ||
| return tx.origin; | ||
| } | ||
|
|
||
| function gasprice() public view returns (uint256) { | ||
| return tx.gasprice; | ||
| } | ||
|
|
||
| function blobhash(uint256 index) public view returns (bytes32) { | ||
| return blobhash(index); | ||
| } | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should forward the return data and then be asserted on in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it still valid and shall be address in this PR?