aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-04-21 04:36:53 +0800
committerchriseth <chris@ethereum.org>2017-06-14 22:00:39 +0800
commitbec30051c57098bef482c9be2537bda46b7571ee (patch)
tree4c7e7aaf26048b268c0e4f4d3caeadda9d9b6ec9
parent1ae0e082b316adfc1a048928e5c535559d3780b3 (diff)
downloaddexon-solidity-bec30051c57098bef482c9be2537bda46b7571ee.tar
dexon-solidity-bec30051c57098bef482c9be2537bda46b7571ee.tar.gz
dexon-solidity-bec30051c57098bef482c9be2537bda46b7571ee.tar.bz2
dexon-solidity-bec30051c57098bef482c9be2537bda46b7571ee.tar.lz
dexon-solidity-bec30051c57098bef482c9be2537bda46b7571ee.tar.xz
dexon-solidity-bec30051c57098bef482c9be2537bda46b7571ee.tar.zst
dexon-solidity-bec30051c57098bef482c9be2537bda46b7571ee.zip
Introduce CREATE2 in the assembler
-rw-r--r--Changelog.md4
-rw-r--r--libevmasm/GasMeter.cpp1
-rw-r--r--libevmasm/Instruction.cpp4
-rw-r--r--libevmasm/Instruction.h1
-rw-r--r--libevmasm/SemanticInformation.cpp2
5 files changed, 9 insertions, 3 deletions
diff --git a/Changelog.md b/Changelog.md
index 8f1fe045..92fd21f2 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,8 +1,8 @@
### 0.4.12 (unreleased)
Features:
- * Assembly: renamed ``SHA3`` to `KECCAK256``.
- * Assembly: Add ``RETURNDATASIZE`` and ``RETURNDATACOPY`` (EIP211) instructions.
+ * Assembly: renamed ``SHA3`` to ``KECCAK256``.
+ * Assembly: Add ``CREATE2`` (EIP86), ``RETURNDATASIZE`` and ``RETURNDATACOPY`` (EIP211) instructions.
* AST: export all attributes to JSON format.
* Inline Assembly: Present proper error message when not supplying enough arguments to a functional
instruction.
diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp
index 31a7d13e..c2e4f01d 100644
--- a/libevmasm/GasMeter.cpp
+++ b/libevmasm/GasMeter.cpp
@@ -155,6 +155,7 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _
gas += GasCosts::callNewAccountGas; // We very rarely know whether the address exists.
break;
case Instruction::CREATE:
+ case Instruction::CREATE2:
if (_includeExternalCosts)
// We assume that we do not know the target contract and thus, the consumption is infinite.
gas = GasConsumption::infinite();
diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp
index af7e9ff9..d58a47a0 100644
--- a/libevmasm/Instruction.cpp
+++ b/libevmasm/Instruction.cpp
@@ -161,6 +161,7 @@ const std::map<std::string, Instruction> dev::solidity::c_instructions =
{ "CALLCODE", Instruction::CALLCODE },
{ "RETURN", Instruction::RETURN },
{ "DELEGATECALL", Instruction::DELEGATECALL },
+ { "CREATE2", Instruction::CREATE2 },
{ "REVERT", Instruction::REVERT },
{ "INVALID", Instruction::INVALID },
{ "SELFDESTRUCT", Instruction::SELFDESTRUCT }
@@ -299,7 +300,8 @@ static const std::map<Instruction, InstructionInfo> c_instructionInfo =
{ Instruction::CALLCODE, { "CALLCODE", 0, 7, 1, true, Tier::Special } },
{ Instruction::RETURN, { "RETURN", 0, 2, 0, true, Tier::Zero } },
{ Instruction::DELEGATECALL, { "DELEGATECALL", 0, 6, 1, true, Tier::Special } },
- { Instruction::REVERT, { "REVERT", 0, 2, 0, true, Tier::Zero } },
+ { Instruction::CREATE2, { "CREATE2", 0, 4, 1, true, Tier::Special } },
+ { Instruction::REVERT, { "REVERT", 0, 2, 0, true, Tier::Zero } },
{ Instruction::INVALID, { "INVALID", 0, 0, 0, true, Tier::Zero } },
{ Instruction::SELFDESTRUCT, { "SELFDESTRUCT", 0, 1, 0, true, Tier::Special } }
};
diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h
index a8c3bf4a..37cdccdb 100644
--- a/libevmasm/Instruction.h
+++ b/libevmasm/Instruction.h
@@ -187,6 +187,7 @@ enum class Instruction: uint8_t
CALLCODE, ///< message-call with another account's code only
RETURN, ///< halt execution returning output data
DELEGATECALL, ///< like CALLCODE but keeps caller's value and sender
+ CREATE2 = 0xfb, ///< create new account with associated code
REVERT = 0xfd, ///< halt execution, revert state and return output data
INVALID = 0xfe, ///< invalid instruction for expressing runtime errors (e.g., division-by-zero)
diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp
index 86feb1d2..db4ee867 100644
--- a/libevmasm/SemanticInformation.cpp
+++ b/libevmasm/SemanticInformation.cpp
@@ -138,6 +138,7 @@ bool SemanticInformation::isDeterministic(AssemblyItem const& _item)
case Instruction::CALLCODE:
case Instruction::DELEGATECALL:
case Instruction::CREATE:
+ case Instruction::CREATE2:
case Instruction::GAS:
case Instruction::PC:
case Instruction::MSIZE: // depends on previous writes and reads, not only on content
@@ -178,6 +179,7 @@ bool SemanticInformation::invalidatesStorage(Instruction _instruction)
case Instruction::CALLCODE:
case Instruction::DELEGATECALL:
case Instruction::CREATE:
+ case Instruction::CREATE2:
case Instruction::SSTORE:
return true;
default: