mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge branch 'develop' into asm-aux
This commit is contained in:
commit
66881bd675
@ -1,9 +1,9 @@
|
|||||||
### 0.4.12 (unreleased)
|
### 0.4.12 (unreleased)
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
* Assembly: Add ``CREATE2`` (EIP86), ``RETURNDATASIZE`` and ``RETURNDATACOPY`` (EIP211) instructions.
|
* Assembly: renamed ``SHA3`` to ``KECCAK256``.
|
||||||
* Assembly: Display auxiliary data in the assembly output.
|
* Assembly: Display auxiliary data in the assembly output.
|
||||||
* Assembly: Renamed ``SHA3`` to ``KECCAK256``.
|
* Assembly: Add ``CREATE2`` (EIP86), ``STATICCALL`` (EIP214), ``RETURNDATASIZE`` and ``RETURNDATACOPY`` (EIP211) instructions.
|
||||||
* AST: export all attributes to JSON format.
|
* AST: export all attributes to JSON format.
|
||||||
* Inline Assembly: Present proper error message when not supplying enough arguments to a functional
|
* Inline Assembly: Present proper error message when not supplying enough arguments to a functional
|
||||||
instruction.
|
instruction.
|
||||||
|
@ -236,11 +236,15 @@ In the grammar, opcodes are represented as pre-defined identifiers.
|
|||||||
+-------------------------+------+-----------------------------------------------------------------+
|
+-------------------------+------+-----------------------------------------------------------------+
|
||||||
| returndatasize | | size of the last returndata |
|
| returndatasize | | size of the last returndata |
|
||||||
+-------------------------+------+-----------------------------------------------------------------+
|
+-------------------------+------+-----------------------------------------------------------------+
|
||||||
| returndatacopy(t, f, s) | `*` | copy s bytes from returndata at position f to mem at position t |
|
| returndatacopy(t, f, s) | `-` | copy s bytes from returndata at position f to mem at position t |
|
||||||
+-------------------------+------+-----------------------------------------------------------------+
|
+-------------------------+------+-----------------------------------------------------------------+
|
||||||
| create(v, p, s) | | create new contract with code mem[p..(p+s)) and send v wei |
|
| create(v, p, s) | | create new contract with code mem[p..(p+s)) and send v wei |
|
||||||
| | | and return the new address |
|
| | | and return the new address |
|
||||||
+-------------------------+------+-----------------------------------------------------------------+
|
+-------------------------+------+-----------------------------------------------------------------+
|
||||||
|
| create2(v, n, p, s) | | create new contract with code mem[p..(p+s)) at address |
|
||||||
|
| | | keccak256(<address> . n . keccak256(mem[p..(p+s))) and send v |
|
||||||
|
| | | wei and return the new address |
|
||||||
|
+-------------------------+------+-----------------------------------------------------------------+
|
||||||
| call(g, a, v, in, | | call contract at address a with input mem[in..(in+insize)) |
|
| call(g, a, v, in, | | call contract at address a with input mem[in..(in+insize)) |
|
||||||
| insize, out, outsize) | | providing g gas and v wei and output area |
|
| insize, out, outsize) | | providing g gas and v wei and output area |
|
||||||
| | | mem[out..(out+outsize)) returning 0 on error (eg. out of gas) |
|
| | | mem[out..(out+outsize)) returning 0 on error (eg. out of gas) |
|
||||||
@ -252,6 +256,9 @@ In the grammar, opcodes are represented as pre-defined identifiers.
|
|||||||
| delegatecall(g, a, in, | | identical to `callcode` but also keep ``caller`` |
|
| delegatecall(g, a, in, | | identical to `callcode` but also keep ``caller`` |
|
||||||
| insize, out, outsize) | | and ``callvalue`` |
|
| insize, out, outsize) | | and ``callvalue`` |
|
||||||
+-------------------------+------+-----------------------------------------------------------------+
|
+-------------------------+------+-----------------------------------------------------------------+
|
||||||
|
| staticcall(g, a, in, | | identical to `call(g, a, 0, in, insize, out, outsize)` but do |
|
||||||
|
| insize, out, outsize) | | not allow state modifications |
|
||||||
|
+-------------------------+------+-----------------------------------------------------------------+
|
||||||
| return(p, s) | `-` | end execution, return data mem[p..(p+s)) |
|
| return(p, s) | `-` | end execution, return data mem[p..(p+s)) |
|
||||||
+-------------------------+------+-----------------------------------------------------------------+
|
+-------------------------+------+-----------------------------------------------------------------+
|
||||||
| revert(p, s) | `-` | end execution, revert state changes, return data mem[p..(p+s)) |
|
| revert(p, s) | `-` | end execution, revert state changes, return data mem[p..(p+s)) |
|
||||||
|
@ -129,6 +129,7 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _
|
|||||||
case Instruction::CALL:
|
case Instruction::CALL:
|
||||||
case Instruction::CALLCODE:
|
case Instruction::CALLCODE:
|
||||||
case Instruction::DELEGATECALL:
|
case Instruction::DELEGATECALL:
|
||||||
|
case Instruction::STATICCALL:
|
||||||
{
|
{
|
||||||
if (_includeExternalCosts)
|
if (_includeExternalCosts)
|
||||||
// We assume that we do not know the target contract and thus, the consumption is infinite.
|
// We assume that we do not know the target contract and thus, the consumption is infinite.
|
||||||
@ -142,8 +143,10 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _
|
|||||||
gas = GasConsumption::infinite();
|
gas = GasConsumption::infinite();
|
||||||
if (_item.instruction() == Instruction::CALL)
|
if (_item.instruction() == Instruction::CALL)
|
||||||
gas += GasCosts::callNewAccountGas; // We very rarely know whether the address exists.
|
gas += GasCosts::callNewAccountGas; // We very rarely know whether the address exists.
|
||||||
int valueSize = _item.instruction() == Instruction::DELEGATECALL ? 0 : 1;
|
int valueSize = 1;
|
||||||
if (!classes.knownZero(m_state->relativeStackElement(-1 - valueSize)))
|
if (_item.instruction() == Instruction::DELEGATECALL || _item.instruction() == Instruction::STATICCALL)
|
||||||
|
valueSize = 0;
|
||||||
|
else if (!classes.knownZero(m_state->relativeStackElement(-1 - valueSize)))
|
||||||
gas += GasCosts::callValueTransferGas;
|
gas += GasCosts::callValueTransferGas;
|
||||||
gas += memoryGas(-2 - valueSize, -3 - valueSize);
|
gas += memoryGas(-2 - valueSize, -3 - valueSize);
|
||||||
gas += memoryGas(-4 - valueSize, -5 - valueSize);
|
gas += memoryGas(-4 - valueSize, -5 - valueSize);
|
||||||
|
@ -159,6 +159,7 @@ const std::map<std::string, Instruction> dev::solidity::c_instructions =
|
|||||||
{ "CREATE", Instruction::CREATE },
|
{ "CREATE", Instruction::CREATE },
|
||||||
{ "CALL", Instruction::CALL },
|
{ "CALL", Instruction::CALL },
|
||||||
{ "CALLCODE", Instruction::CALLCODE },
|
{ "CALLCODE", Instruction::CALLCODE },
|
||||||
|
{ "STATICCALL", Instruction::STATICCALL },
|
||||||
{ "RETURN", Instruction::RETURN },
|
{ "RETURN", Instruction::RETURN },
|
||||||
{ "DELEGATECALL", Instruction::DELEGATECALL },
|
{ "DELEGATECALL", Instruction::DELEGATECALL },
|
||||||
{ "CREATE2", Instruction::CREATE2 },
|
{ "CREATE2", Instruction::CREATE2 },
|
||||||
@ -300,6 +301,7 @@ static const std::map<Instruction, InstructionInfo> c_instructionInfo =
|
|||||||
{ Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true, Tier::Special } },
|
{ Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true, Tier::Special } },
|
||||||
{ Instruction::RETURN, { "RETURN", 0, 2, 0, true, Tier::Zero } },
|
{ Instruction::RETURN, { "RETURN", 0, 2, 0, true, Tier::Zero } },
|
||||||
{ Instruction::DELEGATECALL, { "DELEGATECALL", 0, 6, 1, true, Tier::Special } },
|
{ Instruction::DELEGATECALL, { "DELEGATECALL", 0, 6, 1, true, Tier::Special } },
|
||||||
|
{ Instruction::STATICCALL, { "STATICCALL", 0, 6, 1, true, Tier::Special } },
|
||||||
{ Instruction::CREATE2, { "CREATE2", 0, 4, 1, true, Tier::Special } },
|
{ Instruction::CREATE2, { "CREATE2", 0, 4, 1, true, Tier::Special } },
|
||||||
{ Instruction::REVERT, { "REVERT", 0, 2, 0, true, Tier::Zero } },
|
{ Instruction::REVERT, { "REVERT", 0, 2, 0, true, Tier::Zero } },
|
||||||
{ Instruction::INVALID, { "INVALID", 0, 0, 0, true, Tier::Zero } },
|
{ Instruction::INVALID, { "INVALID", 0, 0, 0, true, Tier::Zero } },
|
||||||
|
@ -77,8 +77,8 @@ enum class Instruction: uint8_t
|
|||||||
GASPRICE, ///< get price of gas in current environment
|
GASPRICE, ///< get price of gas in current environment
|
||||||
EXTCODESIZE, ///< get external code size (from another contract)
|
EXTCODESIZE, ///< get external code size (from another contract)
|
||||||
EXTCODECOPY, ///< copy external code (from another contract)
|
EXTCODECOPY, ///< copy external code (from another contract)
|
||||||
RETURNDATASIZE, ///< get size of the last return data
|
RETURNDATASIZE = 0x3d, ///< get size of return data buffer
|
||||||
RETURNDATACOPY, ///< copy last return data to memory
|
RETURNDATACOPY = 0x3e, ///< copy return data in current environment to memory
|
||||||
|
|
||||||
BLOCKHASH = 0x40, ///< get hash of most recent complete block
|
BLOCKHASH = 0x40, ///< get hash of most recent complete block
|
||||||
COINBASE, ///< get the block's coinbase address
|
COINBASE, ///< get the block's coinbase address
|
||||||
@ -187,7 +187,8 @@ enum class Instruction: uint8_t
|
|||||||
CALLCODE, ///< message-call with another account's code only
|
CALLCODE, ///< message-call with another account's code only
|
||||||
RETURN, ///< halt execution returning output data
|
RETURN, ///< halt execution returning output data
|
||||||
DELEGATECALL, ///< like CALLCODE but keeps caller's value and sender
|
DELEGATECALL, ///< like CALLCODE but keeps caller's value and sender
|
||||||
CREATE2 = 0xfb, ///< create new account with associated code
|
STATICCALL = 0xfa, ///< like CALL but disallow state modifications
|
||||||
|
CREATE2 = 0xfb, ///< create new account with associated code at address `sha3(sender + salt + sha3(init code)) % 2**160`
|
||||||
|
|
||||||
REVERT = 0xfd, ///< halt execution, revert state and return output data
|
REVERT = 0xfd, ///< halt execution, revert state and return output data
|
||||||
INVALID = 0xfe, ///< invalid instruction for expressing runtime errors (e.g., division-by-zero)
|
INVALID = 0xfe, ///< invalid instruction for expressing runtime errors (e.g., division-by-zero)
|
||||||
|
@ -137,6 +137,7 @@ bool SemanticInformation::isDeterministic(AssemblyItem const& _item)
|
|||||||
case Instruction::CALL:
|
case Instruction::CALL:
|
||||||
case Instruction::CALLCODE:
|
case Instruction::CALLCODE:
|
||||||
case Instruction::DELEGATECALL:
|
case Instruction::DELEGATECALL:
|
||||||
|
case Instruction::STATICCALL:
|
||||||
case Instruction::CREATE:
|
case Instruction::CREATE:
|
||||||
case Instruction::CREATE2:
|
case Instruction::CREATE2:
|
||||||
case Instruction::GAS:
|
case Instruction::GAS:
|
||||||
@ -165,6 +166,7 @@ bool SemanticInformation::invalidatesMemory(Instruction _instruction)
|
|||||||
case Instruction::CALL:
|
case Instruction::CALL:
|
||||||
case Instruction::CALLCODE:
|
case Instruction::CALLCODE:
|
||||||
case Instruction::DELEGATECALL:
|
case Instruction::DELEGATECALL:
|
||||||
|
case Instruction::STATICCALL:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <libsolidity/interface/Utils.h>
|
#include <libsolidity/interface/Utils.h>
|
||||||
|
|
||||||
#include <boost/range/adaptor/reversed.hpp>
|
#include <boost/range/adaptor/reversed.hpp>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@ -447,25 +448,18 @@ void AsmAnalyzer::expectValidType(string const& type, SourceLocation const& _loc
|
|||||||
|
|
||||||
void AsmAnalyzer::warnOnFutureInstruction(solidity::Instruction _instr, SourceLocation const& _location)
|
void AsmAnalyzer::warnOnFutureInstruction(solidity::Instruction _instr, SourceLocation const& _location)
|
||||||
{
|
{
|
||||||
string instr;
|
static set<solidity::Instruction> futureInstructions{
|
||||||
switch (_instr)
|
solidity::Instruction::CREATE2,
|
||||||
{
|
solidity::Instruction::RETURNDATACOPY,
|
||||||
case solidity::Instruction::CREATE2:
|
solidity::Instruction::RETURNDATASIZE,
|
||||||
instr = "create2";
|
solidity::Instruction::STATICCALL
|
||||||
break;
|
};
|
||||||
case solidity::Instruction::RETURNDATASIZE:
|
if (futureInstructions.count(_instr))
|
||||||
instr = "returndatasize";
|
|
||||||
break;
|
|
||||||
case solidity::Instruction::RETURNDATACOPY:
|
|
||||||
instr = "returndatacopy";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!instr.empty())
|
|
||||||
m_errorReporter.warning(
|
m_errorReporter.warning(
|
||||||
_location,
|
_location,
|
||||||
"The \"" + instr + "\" instruction is only available after " +
|
"The \"" +
|
||||||
|
boost::to_lower_copy(instructionInfo(_instr).name)
|
||||||
|
+ "\" instruction is only available after " +
|
||||||
"the Metropolis hard fork. Before that it acts as an invalid instruction."
|
"the Metropolis hard fork. Before that it acts as an invalid instruction."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -572,6 +572,16 @@ BOOST_AUTO_TEST_CASE(returndatacopy_functional)
|
|||||||
BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }"));
|
BOOST_CHECK(successAssemble("{ returndatacopy(0, 32, 64) }"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(staticcall)
|
||||||
|
{
|
||||||
|
BOOST_CHECK(successAssemble("{ pop(staticcall(10000, 0x123, 64, 0x10, 128, 0x10)) }"));
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(create2)
|
||||||
|
{
|
||||||
|
BOOST_CHECK(successAssemble("{ pop(create2(10, 0x123, 32, 64)) }"));
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
Loading…
Reference in New Issue
Block a user