Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Andrei Maiboroda <[email protected]>
  • Loading branch information
chfast and gumb0 authored Jan 5, 2024
1 parent d774d80 commit b4727c9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/state/mpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void MPTNode::insert(const Path& path, bytes&& value) // NOLINT(misc-no-recursi
const auto [this_idx, insert_idx] = std::ranges::mismatch(m_path, path);

// insert_idx is always valid if requirements are fulfilled:
// - if m_path is not shorter than path they must have mismatched nibbles,
// - if m_path is not shorter than path they must have mismatched nibbles, given the requirement that key uniqeness and inserted key not being a prefix if existing key,
// - if m_path is shorter and matches the path prefix
// then insert_idx points at path[m_path.size()].
assert(insert_idx != path.end() && "a key must not be a prefix of another key");
Expand Down
2 changes: 1 addition & 1 deletion test/state/mpt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ constexpr auto emptyMPTHash =
/// out of (key, value) pairs.
///
/// Limitations:
/// 1. A keys must not be longer than 32 bytes. Protected by debug assert.
/// 1. A key must not be longer than 32 bytes. Protected by debug assert.
/// 2. A key must not be a prefix of another key. Protected by debug assert.
/// This comes from the spec (Yellow Paper Appendix D) - a branch node cannot store a value.
/// 3. A key must be unique. Protected by debug assert.
Expand Down
4 changes: 2 additions & 2 deletions test/unittests/state_mpt_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ TEST(state_mpt, branch_node_example1)
TEST(state_mpt, branch_node_of_3)
{
// A trie of single branch node and three leaf nodes with paths of length 2.
// The branch node has leaf nodes at positions [0], [1] and [2]. All leafs have path 0.
// The branch node has leaf nodes at positions [0], [1] and [2]. All leaves have path 0.
// {0:0 1:0 2:0}

MPT trie;
Expand All @@ -102,7 +102,7 @@ TEST(state_mpt, branch_node_of_3)

TEST(state_mpt, leaf_node_with_empty_path)
{
// Both inserted leafs have empty path in the end.
// Both inserted leaves have empty path in the end.
// 0:{0:"X", 1:"Y"}
MPT trie;
trie.insert("00"_hex, "X"_b);
Expand Down

0 comments on commit b4727c9

Please sign in to comment.