mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #7457 from ethereum/docAndTestsForChainIdAndSelfBalance
Document chainid and selfbalance.
This commit is contained in:
commit
c4208a6ab8
@ -163,7 +163,8 @@ If an opcode takes arguments (always from the top of the stack), they are given
|
|||||||
Note that the order of arguments can be seen to be reversed in non-functional style (explained below).
|
Note that the order of arguments can be seen to be reversed in non-functional style (explained below).
|
||||||
Opcodes marked with ``-`` do not push an item onto the stack (do not return a result),
|
Opcodes marked with ``-`` do not push an item onto the stack (do not return a result),
|
||||||
those marked with ``*`` are special and all others push exactly one item onto the stack (their "return value").
|
those marked with ``*`` are special and all others push exactly one item onto the stack (their "return value").
|
||||||
Opcodes marked with ``F``, ``H``, ``B`` or ``C`` are present since Frontier, Homestead, Byzantium or Constantinople, respectively.
|
Opcodes marked with ``F``, ``H``, ``B``, ``C`` or ``I`` are present since Frontier, Homestead,
|
||||||
|
Byzantium, Constantinople or Istanbul, respectively.
|
||||||
|
|
||||||
In the following, ``mem[a...b)`` signifies the bytes of memory starting at position ``a`` up to
|
In the following, ``mem[a...b)`` signifies the bytes of memory starting at position ``a`` up to
|
||||||
but not including position ``b`` and ``storage[p]`` signifies the storage contents at position ``p``.
|
but not including position ``b`` and ``storage[p]`` signifies the storage contents at position ``p``.
|
||||||
@ -259,6 +260,8 @@ In the grammar, opcodes are represented as pre-defined identifiers.
|
|||||||
+-------------------------+-----+---+-----------------------------------------------------------------+
|
+-------------------------+-----+---+-----------------------------------------------------------------+
|
||||||
| balance(a) | | F | wei balance at address a |
|
| balance(a) | | F | wei balance at address a |
|
||||||
+-------------------------+-----+---+-----------------------------------------------------------------+
|
+-------------------------+-----+---+-----------------------------------------------------------------+
|
||||||
|
| selfbalance() | | I | equivalent to balance(address()), but cheaper |
|
||||||
|
+-------------------------+-----+---+-----------------------------------------------------------------+
|
||||||
| caller | | F | call sender (excluding ``delegatecall``) |
|
| caller | | F | call sender (excluding ``delegatecall``) |
|
||||||
+-------------------------+-----+---+-----------------------------------------------------------------+
|
+-------------------------+-----+---+-----------------------------------------------------------------+
|
||||||
| callvalue | | F | wei sent together with the current call |
|
| callvalue | | F | wei sent together with the current call |
|
||||||
@ -325,6 +328,8 @@ In the grammar, opcodes are represented as pre-defined identifiers.
|
|||||||
| log4(p, s, t1, t2, t3, | `-` | F | log with topics t1, t2, t3, t4 and data mem[p...(p+s)) |
|
| log4(p, s, t1, t2, t3, | `-` | F | log with topics t1, t2, t3, t4 and data mem[p...(p+s)) |
|
||||||
| t4) | | | |
|
| t4) | | | |
|
||||||
+-------------------------+-----+---+-----------------------------------------------------------------+
|
+-------------------------+-----+---+-----------------------------------------------------------------+
|
||||||
|
| chainid | | I | ID of the executing chain (EIP 1344) |
|
||||||
|
+-------------------------+-----+---+-----------------------------------------------------------------+
|
||||||
| origin | | F | transaction sender |
|
| origin | | F | transaction sender |
|
||||||
+-------------------------+-----+---+-----------------------------------------------------------------+
|
+-------------------------+-----+---+-----------------------------------------------------------------+
|
||||||
| gasprice | | F | gas price of the transaction |
|
| gasprice | | F | gas price of the transaction |
|
||||||
|
@ -122,7 +122,8 @@ at each version. Backward compatibility is not guaranteed between each version.
|
|||||||
- Shifting operators use shifting opcodes and thus need less gas.
|
- Shifting operators use shifting opcodes and thus need less gas.
|
||||||
- ``petersburg`` (**default**)
|
- ``petersburg`` (**default**)
|
||||||
- The compiler behaves the same way as with constantinople.
|
- The compiler behaves the same way as with constantinople.
|
||||||
- ``istanbul`` (**experimental**)
|
- ``istanbul``
|
||||||
|
- Opcodes ``chainid`` and ``selfbalance`` are available in assembly.
|
||||||
- ``berlin`` (**experimental**)
|
- ``berlin`` (**experimental**)
|
||||||
|
|
||||||
|
|
||||||
|
@ -836,6 +836,20 @@ BOOST_AUTO_TEST_CASE(shift_constantinople_warning)
|
|||||||
CHECK_PARSE_WARNING("{ pop(sar(10, 32)) }", TypeError, "The \"sar\" instruction is only available for Constantinople-compatible VMs");
|
CHECK_PARSE_WARNING("{ pop(sar(10, 32)) }", TypeError, "The \"sar\" instruction is only available for Constantinople-compatible VMs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(chainid_instanbul_warning)
|
||||||
|
{
|
||||||
|
if (dev::test::Options::get().evmVersion().hasChainID())
|
||||||
|
return;
|
||||||
|
CHECK_PARSE_WARNING("{ pop(chainid()) }", TypeError, "The \"chainid\" instruction is only available for Istanbul-compatible VMs");
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(selfbalance_instanbul_warning)
|
||||||
|
{
|
||||||
|
if (dev::test::Options::get().evmVersion().hasSelfBalance())
|
||||||
|
return;
|
||||||
|
CHECK_PARSE_WARNING("{ pop(selfbalance()) }", TypeError, "The \"selfbalance\" instruction is only available for Istanbul-compatible VMs");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(jump_warning)
|
BOOST_AUTO_TEST_CASE(jump_warning)
|
||||||
{
|
{
|
||||||
CHECK_PARSE_WARNING("{ 1 jump }", Warning, "Jump instructions");
|
CHECK_PARSE_WARNING("{ 1 jump }", Warning, "Jump instructions");
|
||||||
|
15
test/libsolidity/syntaxTests/inlineAssembly/istanbul.sol
Normal file
15
test/libsolidity/syntaxTests/inlineAssembly/istanbul.sol
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
contract C {
|
||||||
|
function f() pure external {
|
||||||
|
assembly {
|
||||||
|
pop(chainid())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function g() view external {
|
||||||
|
assembly {
|
||||||
|
pop(selfbalance())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// EVMVersion: >=istanbul
|
||||||
|
// ----
|
Loading…
Reference in New Issue
Block a user