Skip to content

Commit

Permalink
Fix bug about incorrect caching on Keccak256 hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
hrkrshnn committed Mar 22, 2021
1 parent 6e1d61a commit e299117
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
4 changes: 1 addition & 3 deletions libevmasm/KnownState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,6 @@ KnownState::Id KnownState::applyKeccak256(
);
arguments.push_back(loadFromMemory(slot, _location));
}
if (m_knownKeccak256Hashes.count(arguments))
return m_knownKeccak256Hashes.at(arguments);
Id v;
// 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); }))
Expand All @@ -400,7 +398,7 @@ KnownState::Id KnownState::applyKeccak256(
}
else
v = m_expressionClasses->find(keccak256Item, {_start, _length}, true, m_sequenceNumber);
return m_knownKeccak256Hashes[arguments] = v;
return v;
}

set<u256> KnownState::tagsInExpression(KnownState::Id _expressionId)
Expand Down
2 changes: 0 additions & 2 deletions libevmasm/KnownState.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ class KnownState
/// 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 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.
Expand Down

0 comments on commit e299117

Please sign in to comment.