Add missing 63/64 rule documentation and a test (#462)

- Prominently point out the important differences of the `pallet-revive`
runtime.
- Add a test case illustrating the problem.

See also: https://github.com/paritytech/contract-issues/issues/257

---------

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
This commit is contained in:
xermicus authored and GitHub committed 2026-01-27 19:43:14 +01:00
1 parent 99b73ec083
commit 95ae938ddf
29 files changed
+172 -30

No files matched your search

@@ -0,0 +1,57 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
/* runner.json
{
"differential": true,
"actions": [
{
"Instantiate": {
"code": {
"Solidity": {
"contract": "RevertDataOob"
}
}
}
},
{
"Call": {
"dest": {
"Instantiated": 0
},
"data": "eb8ac921000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffff"
}
},
{
"Call": {
"dest": {
"Instantiated": 0
},
"data": "eb8ac92100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000"
}
}
]
}
*/
contract RevertDataOob {
function test(uint256 offset, uint256 len) external {
assembly {
mstore(0, 0xcc572cf9)
mstore(32, offset)
mstore(64, len)
let stipend := mul(div(gas(), 64), 63) // On EVM this isn't necessary
let success := call(stipend, address(), 0, 28, 68, 0, 0)
mstore(0, 0xdeadbeef)
return(0, 32)
}
}
function main(uint256 offset, uint256 len) external pure {
assembly {
mstore(0x40, 0)
revert(offset, len)
}
}
}
+1
View File
@@ -44,6 +44,7 @@ test_spec!(create, "CreateB", "Create.sol");
test_spec!(call, "Caller", "Call.sol");
test_spec!(balance, "Balance", "Balance.sol");
test_spec!(return_data_oob, "ReturnDataOob", "ReturnDataOob.sol");
test_spec!(revert_data_oob, "RevertDataOob", "RevertDataOob.sol");
test_spec!(immutables, "Immutables", "Immutables.sol");
test_spec!(transaction, "Transaction", "Transaction.sol");
test_spec!(block_hash, "BlockHash", "BlockHash.sol");