2021-11-01 09:24:08 +00:00
|
|
|
interface Identity {
|
|
|
|
function selectorAndAppendValue(uint value) external pure returns (uint);
|
|
|
|
}
|
2021-10-28 10:35:06 +00:00
|
|
|
interface ReturnMoreData {
|
|
|
|
function f(uint value) external pure returns (uint, uint, uint);
|
|
|
|
}
|
2021-11-01 09:24:08 +00:00
|
|
|
contract C {
|
|
|
|
Identity constant i = Identity(address(0x0004));
|
|
|
|
function testHighLevel() external pure returns (bool) {
|
2021-10-28 10:35:06 +00:00
|
|
|
// Works because the extcodesize check is skipped
|
|
|
|
// and the precompiled contract returns actual data.
|
2021-11-01 09:24:08 +00:00
|
|
|
i.selectorAndAppendValue(5);
|
|
|
|
return true;
|
|
|
|
}
|
2021-10-28 10:35:06 +00:00
|
|
|
function testHighLevel2() external pure returns (uint, uint, uint) {
|
|
|
|
// Fails because the identity contract does not return enough data.
|
|
|
|
return ReturnMoreData(address(4)).f(2);
|
|
|
|
}
|
2021-11-01 09:24:08 +00:00
|
|
|
function testLowLevel() external view returns (uint value) {
|
|
|
|
(bool success, bytes memory ret) =
|
|
|
|
address(4).staticcall(
|
|
|
|
abi.encodeWithSelector(Identity.selectorAndAppendValue.selector, uint(5))
|
|
|
|
);
|
|
|
|
value = abi.decode(ret, (uint));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
// ====
|
|
|
|
// EVMVersion: >=constantinople
|
|
|
|
// ----
|
2021-11-04 17:20:10 +00:00
|
|
|
// testHighLevel() -> true
|
2021-11-01 09:24:08 +00:00
|
|
|
// testLowLevel() -> 0xc76596d400000000000000000000000000000000000000000000000000000000
|
2021-10-28 10:35:06 +00:00
|
|
|
// testHighLevel2() -> FAILURE
|