diff options
Diffstat (limited to 'libevmasm')
-rw-r--r-- | libevmasm/CommonSubexpressionEliminator.cpp | 4 | ||||
-rw-r--r-- | libevmasm/EVMSchedule.h | 4 | ||||
-rw-r--r-- | libevmasm/GasMeter.cpp | 6 | ||||
-rw-r--r-- | libevmasm/GasMeter.h | 4 | ||||
-rw-r--r-- | libevmasm/Instruction.cpp | 4 | ||||
-rw-r--r-- | libevmasm/Instruction.h | 2 | ||||
-rw-r--r-- | libevmasm/KnownState.cpp | 20 | ||||
-rw-r--r-- | libevmasm/KnownState.h | 8 |
8 files changed, 26 insertions, 26 deletions
diff --git a/libevmasm/CommonSubexpressionEliminator.cpp b/libevmasm/CommonSubexpressionEliminator.cpp index fd4fffa6..70324e7f 100644 --- a/libevmasm/CommonSubexpressionEliminator.cpp +++ b/libevmasm/CommonSubexpressionEliminator.cpp @@ -234,7 +234,7 @@ void CSECodeGenerator::addDependencies(Id _c) if (expr.item && expr.item->type() == Operation && ( expr.item->instruction() == Instruction::SLOAD || expr.item->instruction() == Instruction::MLOAD || - expr.item->instruction() == Instruction::SHA3 + expr.item->instruction() == Instruction::KECCAK256 )) { // this loads an unknown value from storage or memory and thus, in addition to its @@ -260,7 +260,7 @@ void CSECodeGenerator::addDependencies(Id _c) case Instruction::MLOAD: knownToBeIndependent = m_expressionClasses.knownToBeDifferentBy32(slot, slotToLoadFrom); break; - case Instruction::SHA3: + case Instruction::KECCAK256: { Id length = expr.arguments.at(1); AssemblyItem offsetInstr(Instruction::SUB, expr.item->location()); diff --git a/libevmasm/EVMSchedule.h b/libevmasm/EVMSchedule.h index 65d307ae..1695a59c 100644 --- a/libevmasm/EVMSchedule.h +++ b/libevmasm/EVMSchedule.h @@ -32,8 +32,8 @@ struct EVMSchedule unsigned stackLimit = 1024; unsigned expGas = 10; unsigned expByteGas = 10; - unsigned sha3Gas = 30; - unsigned sha3WordGas = 6; + unsigned keccak256Gas = 30; + unsigned keccak256WordGas = 6; unsigned sloadGas = 200; unsigned sstoreSetGas = 20000; unsigned sstoreResetGas = 5000; diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index f5fd00ea..260b7439 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -96,9 +96,9 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item, bool _ classes.find(AssemblyItem(1)) })); break; - case Instruction::SHA3: - gas = GasCosts::sha3Gas; - gas += wordGas(GasCosts::sha3WordGas, m_state->relativeStackElement(-1)); + case Instruction::KECCAK256: + gas = GasCosts::keccak256Gas; + gas += wordGas(GasCosts::keccak256WordGas, m_state->relativeStackElement(-1)); gas += memoryGas(0, -1); break; case Instruction::CALLDATACOPY: diff --git a/libevmasm/GasMeter.h b/libevmasm/GasMeter.h index 3169ff2a..2c3ecf5a 100644 --- a/libevmasm/GasMeter.h +++ b/libevmasm/GasMeter.h @@ -48,8 +48,8 @@ namespace GasCosts static unsigned const balanceGas = 400; static unsigned const expGas = 10; static unsigned const expByteGas = 50; - static unsigned const sha3Gas = 30; - static unsigned const sha3WordGas = 6; + static unsigned const keccak256Gas = 30; + static unsigned const keccak256WordGas = 6; static unsigned const sloadGas = 200; static unsigned const sstoreSetGas = 20000; static unsigned const sstoreResetGas = 5000; diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index 5e92c6e6..25eab60b 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -53,7 +53,7 @@ const std::map<std::string, Instruction> dev::solidity::c_instructions = { "ADDMOD", Instruction::ADDMOD }, { "MULMOD", Instruction::MULMOD }, { "SIGNEXTEND", Instruction::SIGNEXTEND }, - { "SHA3", Instruction::SHA3 }, + { "KECCAK256", Instruction::KECCAK256 }, { "ADDRESS", Instruction::ADDRESS }, { "BALANCE", Instruction::BALANCE }, { "ORIGIN", Instruction::ORIGIN }, @@ -189,7 +189,7 @@ static const std::map<Instruction, InstructionInfo> c_instructionInfo = { Instruction::ADDMOD, { "ADDMOD", 0, 3, 1, false, Tier::Mid } }, { Instruction::MULMOD, { "MULMOD", 0, 3, 1, false, Tier::Mid } }, { Instruction::SIGNEXTEND, { "SIGNEXTEND", 0, 2, 1, false, Tier::Low } }, - { Instruction::SHA3, { "SHA3", 0, 2, 1, false, Tier::Special } }, + { Instruction::KECCAK256, { "KECCAK256", 0, 2, 1, false, Tier::Special } }, { Instruction::ADDRESS, { "ADDRESS", 0, 0, 1, false, Tier::Base } }, { Instruction::BALANCE, { "BALANCE", 0, 1, 1, false, Tier::Balance } }, { Instruction::ORIGIN, { "ORIGIN", 0, 0, 1, false, Tier::Base } }, diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index 192fe090..5fec7988 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -62,7 +62,7 @@ enum class Instruction: uint8_t NOT, ///< bitwise NOT opertation BYTE, ///< retrieve single byte from word - SHA3 = 0x20, ///< compute SHA3-256 hash + KECCAK256 = 0x20, ///< compute KECCAK-256 hash ADDRESS = 0x30, ///< get address of currently executing account BALANCE, ///< get balance of the given account diff --git a/libevmasm/KnownState.cpp b/libevmasm/KnownState.cpp index 6e3130dd..e2f10f22 100644 --- a/libevmasm/KnownState.cpp +++ b/libevmasm/KnownState.cpp @@ -136,10 +136,10 @@ KnownState::StoreOperation KnownState::feedItem(AssemblyItem const& _item, bool m_stackHeight + _item.deposit(), loadFromMemory(arguments[0], _item.location()) ); - else if (_item.instruction() == Instruction::SHA3) + else if (_item.instruction() == Instruction::KECCAK256) setStackElement( m_stackHeight + _item.deposit(), - applySha3(arguments.at(0), arguments.at(1), _item.location()) + applyKeccak256(arguments.at(0), arguments.at(1), _item.location()) ); else { @@ -346,18 +346,18 @@ ExpressionClasses::Id KnownState::loadFromMemory(Id _slot, SourceLocation const& return m_memoryContent[_slot] = m_expressionClasses->find(item, {_slot}, true, m_sequenceNumber); } -KnownState::Id KnownState::applySha3( +KnownState::Id KnownState::applyKeccak256( Id _start, Id _length, SourceLocation const& _location ) { - AssemblyItem sha3Item(Instruction::SHA3, _location); + AssemblyItem keccak256Item(Instruction::KECCAK256, _location); // Special logic if length is a short constant, otherwise we cannot tell. u256 const* l = m_expressionClasses->knownConstant(_length); // unknown or too large length if (!l || *l > 128) - return m_expressionClasses->find(sha3Item, {_start, _length}, true, m_sequenceNumber); + return m_expressionClasses->find(keccak256Item, {_start, _length}, true, m_sequenceNumber); vector<Id> arguments; for (u256 i = 0; i < *l; i += 32) @@ -368,10 +368,10 @@ KnownState::Id KnownState::applySha3( ); arguments.push_back(loadFromMemory(slot, _location)); } - if (m_knownSha3Hashes.count(arguments)) - return m_knownSha3Hashes.at(arguments); + if (m_knownKeccak256Hashes.count(arguments)) + return m_knownKeccak256Hashes.at(arguments); Id v; - // If all arguments are known constants, compute the sha3 here + // If all arguments are known constants, compute the Keccak-256 here if (all_of(arguments.begin(), arguments.end(), [this](Id _a) { return !!m_expressionClasses->knownConstant(_a); })) { bytes data; @@ -381,8 +381,8 @@ KnownState::Id KnownState::applySha3( v = m_expressionClasses->find(AssemblyItem(u256(dev::keccak256(data)), _location)); } else - v = m_expressionClasses->find(sha3Item, {_start, _length}, true, m_sequenceNumber); - return m_knownSha3Hashes[arguments] = v; + v = m_expressionClasses->find(keccak256Item, {_start, _length}, true, m_sequenceNumber); + return m_knownKeccak256Hashes[arguments] = v; } set<u256> KnownState::tagsInExpression(KnownState::Id _expressionId) diff --git a/libevmasm/KnownState.h b/libevmasm/KnownState.h index fd6a26c1..8568b163 100644 --- a/libevmasm/KnownState.h +++ b/libevmasm/KnownState.h @@ -150,8 +150,8 @@ private: StoreOperation storeInMemory(Id _slot, Id _value, SourceLocation const& _location); /// Retrieves the current value at the given slot in memory or creates a new special mload class. Id loadFromMemory(Id _slot, SourceLocation const& _location); - /// Finds or creates a new expression that applies the sha3 hash function to the contents in memory. - Id applySha3(Id _start, Id _length, SourceLocation const& _location); + /// Finds or creates a new expression that applies the Keccak-256 hash function to the contents in memory. + Id applyKeccak256(Id _start, Id _length, SourceLocation const& _location); /// @returns a new or already used Id representing the given set of tags. Id tagUnion(std::set<u256> _tags); @@ -167,8 +167,8 @@ private: /// Knowledge about memory content. Keys are memory addresses, note that the values overlap /// and are not contained here if they are not completely known. std::map<Id, Id> m_memoryContent; - /// Keeps record of all sha3 hashes that are computed. - std::map<std::vector<Id>, Id> m_knownSha3Hashes; + /// Keeps record of all Keccak-256 hashes that are computed. + std::map<std::vector<Id>, Id> m_knownKeccak256Hashes; /// Structure containing the classes of equivalent expressions. std::shared_ptr<ExpressionClasses> m_expressionClasses; /// Container for unions of tags stored on the stack. |