diff options
Diffstat (limited to 'libevmasm')
-rw-r--r-- | libevmasm/GasMeter.cpp | 7 | ||||
-rw-r--r-- | libevmasm/Instruction.cpp | 2 | ||||
-rw-r--r-- | libevmasm/Instruction.h | 7 | ||||
-rw-r--r-- | libevmasm/SemanticInformation.cpp | 2 |
4 files changed, 13 insertions, 5 deletions
diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index c2e4f01d..c96c6ca5 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -129,6 +129,7 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _ case Instruction::CALL: case Instruction::CALLCODE: case Instruction::DELEGATECALL: + case Instruction::STATICCALL: { if (_includeExternalCosts) // 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(); if (_item.instruction() == Instruction::CALL) gas += GasCosts::callNewAccountGas; // We very rarely know whether the address exists. - int valueSize = _item.instruction() == Instruction::DELEGATECALL ? 0 : 1; - if (!classes.knownZero(m_state->relativeStackElement(-1 - valueSize))) + int valueSize = 1; + if (_item.instruction() == Instruction::DELEGATECALL || _item.instruction() == Instruction::STATICCALL) + valueSize = 0; + else if (!classes.knownZero(m_state->relativeStackElement(-1 - valueSize))) gas += GasCosts::callValueTransferGas; gas += memoryGas(-2 - valueSize, -3 - valueSize); gas += memoryGas(-4 - valueSize, -5 - valueSize); diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index d58a47a0..8feb733a 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -159,6 +159,7 @@ const std::map<std::string, Instruction> dev::solidity::c_instructions = { "CREATE", Instruction::CREATE }, { "CALL", Instruction::CALL }, { "CALLCODE", Instruction::CALLCODE }, + { "STATICCALL", Instruction::STATICCALL }, { "RETURN", Instruction::RETURN }, { "DELEGATECALL", Instruction::DELEGATECALL }, { "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::RETURN, { "RETURN", 0, 2, 0, true, Tier::Zero } }, { 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::REVERT, { "REVERT", 0, 2, 0, true, Tier::Zero } }, { Instruction::INVALID, { "INVALID", 0, 0, 0, true, Tier::Zero } }, diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index 37cdccdb..89a25fb7 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -77,8 +77,8 @@ enum class Instruction: uint8_t GASPRICE, ///< get price of gas in current environment EXTCODESIZE, ///< get external code size (from another contract) EXTCODECOPY, ///< copy external code (from another contract) - RETURNDATASIZE, ///< get size of the last return data - RETURNDATACOPY, ///< copy last return data to memory + RETURNDATASIZE = 0x3d, ///< get size of return data buffer + RETURNDATACOPY = 0x3e, ///< copy return data in current environment to memory BLOCKHASH = 0x40, ///< get hash of most recent complete block 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 RETURN, ///< halt execution returning output data 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 INVALID = 0xfe, ///< invalid instruction for expressing runtime errors (e.g., division-by-zero) diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index db4ee867..f63f0c61 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -137,6 +137,7 @@ bool SemanticInformation::isDeterministic(AssemblyItem const& _item) case Instruction::CALL: case Instruction::CALLCODE: case Instruction::DELEGATECALL: + case Instruction::STATICCALL: case Instruction::CREATE: case Instruction::CREATE2: case Instruction::GAS: @@ -165,6 +166,7 @@ bool SemanticInformation::invalidatesMemory(Instruction _instruction) case Instruction::CALL: case Instruction::CALLCODE: case Instruction::DELEGATECALL: + case Instruction::STATICCALL: return true; default: return false; |