Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile.am
Comment thread
evoskuil marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ test_libbitcoin_database_test_SOURCES = \
test/query/properties_block.cpp \
test/query/properties_tx.cpp \
test/query/sequences.cpp \
test/query/silent.cpp \
test/query/sizes.cpp \
test/query/address/address_balance.cpp \
test/query/address/address_history.cpp \
Expand Down Expand Up @@ -217,6 +218,7 @@ include_bitcoin_database_impl_query_HEADERS = \
include/bitcoin/database/impl/query/properties_tx.ipp \
include/bitcoin/database/impl/query/query.ipp \
include/bitcoin/database/impl/query/sequences.ipp \
include/bitcoin/database/impl/query/silent.ipp \
include/bitcoin/database/impl/query/sizes.ipp

include_bitcoin_database_impl_query_addressdir = ${includedir}/bitcoin/database/impl/query/address
Expand Down Expand Up @@ -329,14 +331,16 @@ include_bitcoin_database_tables_optionalsdir = ${includedir}/bitcoin/database/ta
include_bitcoin_database_tables_optionals_HEADERS = \
include/bitcoin/database/tables/optionals/address.hpp \
include/bitcoin/database/tables/optionals/filter_bk.hpp \
include/bitcoin/database/tables/optionals/filter_tx.hpp
include/bitcoin/database/tables/optionals/filter_tx.hpp \
include/bitcoin/database/tables/optionals/silent.hpp

include_bitcoin_database_typesdir = ${includedir}/bitcoin/database/types
include_bitcoin_database_types_HEADERS = \
include/bitcoin/database/types/fee_rate.hpp \
include/bitcoin/database/types/header_state.hpp \
include/bitcoin/database/types/history.hpp \
include/bitcoin/database/types/position.hpp \
include/bitcoin/database/types/silent.hpp \
include/bitcoin/database/types/span.hpp \
include/bitcoin/database/types/type.hpp \
include/bitcoin/database/types/types.hpp \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
<ClCompile Include="..\..\..\..\test\query\properties_block.cpp" />
<ClCompile Include="..\..\..\..\test\query\properties_tx.cpp" />
<ClCompile Include="..\..\..\..\test\query\sequences.cpp" />
<ClCompile Include="..\..\..\..\test\query\silent.cpp" />
<ClCompile Include="..\..\..\..\test\query\sizes.cpp" />
<ClCompile Include="..\..\..\..\test\settings.cpp" />
<ClCompile Include="..\..\..\..\test\store.cpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@
<ClCompile Include="..\..\..\..\test\query\sequences.cpp">
<Filter>src\query</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\query\silent.cpp">
<Filter>src\query</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\query\sizes.cpp">
<Filter>src\query</Filter>
</ClCompile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\optionals\address.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\optionals\filter_bk.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\optionals\filter_tx.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\optionals\silent.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\point_set.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\schema.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\states.hpp" />
Expand All @@ -206,6 +207,7 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\header_state.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\history.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\position.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\silent.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\span.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\type.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\types.hpp" />
Expand Down Expand Up @@ -260,6 +262,7 @@
<None Include="..\..\..\..\include\bitcoin\database\impl\query\properties_tx.ipp" />
<None Include="..\..\..\..\include\bitcoin\database\impl\query\query.ipp" />
<None Include="..\..\..\..\include\bitcoin\database\impl\query\sequences.ipp" />
<None Include="..\..\..\..\include\bitcoin\database\impl\query\silent.ipp" />
<None Include="..\..\..\..\include\bitcoin\database\impl\query\sizes.ipp" />
<None Include="..\..\..\..\include\bitcoin\database\impl\store.ipp" />
<None Include="packages.config" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\optionals\filter_tx.hpp">
<Filter>include\bitcoin\database\tables\optionals</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\optionals\silent.hpp">
<Filter>include\bitcoin\database\tables\optionals</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\point_set.hpp">
<Filter>include\bitcoin\database\tables</Filter>
</ClInclude>
Expand Down Expand Up @@ -329,6 +332,9 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\position.hpp">
<Filter>include\bitcoin\database\types</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\silent.hpp">
<Filter>include\bitcoin\database\types</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\span.hpp">
<Filter>include\bitcoin\database\types</Filter>
</ClInclude>
Expand Down Expand Up @@ -487,6 +493,9 @@
<None Include="..\..\..\..\include\bitcoin\database\impl\query\sequences.ipp">
<Filter>include\bitcoin\database\impl\query</Filter>
</None>
<None Include="..\..\..\..\include\bitcoin\database\impl\query\silent.ipp">
<Filter>include\bitcoin\database\impl\query</Filter>
</None>
<None Include="..\..\..\..\include\bitcoin\database\impl\query\sizes.ipp">
<Filter>include\bitcoin\database\impl\query</Filter>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
<ClCompile Include="..\..\..\..\test\query\properties_block.cpp" />
<ClCompile Include="..\..\..\..\test\query\properties_tx.cpp" />
<ClCompile Include="..\..\..\..\test\query\sequences.cpp" />
<ClCompile Include="..\..\..\..\test\query\silent.cpp" />
<ClCompile Include="..\..\..\..\test\query\sizes.cpp" />
<ClCompile Include="..\..\..\..\test\settings.cpp" />
<ClCompile Include="..\..\..\..\test\store.cpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@
<ClCompile Include="..\..\..\..\test\query\sequences.cpp">
<Filter>src\query</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\query\silent.cpp">
<Filter>src\query</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\query\sizes.cpp">
<Filter>src\query</Filter>
</ClCompile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\optionals\address.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\optionals\filter_bk.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\optionals\filter_tx.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\optionals\silent.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\point_set.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\schema.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\states.hpp" />
Expand All @@ -206,6 +207,7 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\header_state.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\history.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\position.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\silent.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\span.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\type.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\types.hpp" />
Expand Down Expand Up @@ -260,6 +262,7 @@
<None Include="..\..\..\..\include\bitcoin\database\impl\query\properties_tx.ipp" />
<None Include="..\..\..\..\include\bitcoin\database\impl\query\query.ipp" />
<None Include="..\..\..\..\include\bitcoin\database\impl\query\sequences.ipp" />
<None Include="..\..\..\..\include\bitcoin\database\impl\query\silent.ipp" />
<None Include="..\..\..\..\include\bitcoin\database\impl\query\sizes.ipp" />
<None Include="..\..\..\..\include\bitcoin\database\impl\store.ipp" />
<None Include="packages.config" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\optionals\filter_tx.hpp">
<Filter>include\bitcoin\database\tables\optionals</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\optionals\silent.hpp">
<Filter>include\bitcoin\database\tables\optionals</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\tables\point_set.hpp">
<Filter>include\bitcoin\database\tables</Filter>
</ClInclude>
Expand Down Expand Up @@ -329,6 +332,9 @@
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\position.hpp">
<Filter>include\bitcoin\database\types</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\silent.hpp">
<Filter>include\bitcoin\database\types</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\database\types\span.hpp">
<Filter>include\bitcoin\database\types</Filter>
</ClInclude>
Expand Down Expand Up @@ -487,6 +493,9 @@
<None Include="..\..\..\..\include\bitcoin\database\impl\query\sequences.ipp">
<Filter>include\bitcoin\database\impl\query</Filter>
</None>
<None Include="..\..\..\..\include\bitcoin\database\impl\query\silent.ipp">
<Filter>include\bitcoin\database\impl\query</Filter>
</None>
<None Include="..\..\..\..\include\bitcoin\database\impl\query\sizes.ipp">
<Filter>include\bitcoin\database\impl\query</Filter>
</None>
Expand Down
2 changes: 2 additions & 0 deletions include/bitcoin/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@
#include <bitcoin/database/tables/optionals/address.hpp>
#include <bitcoin/database/tables/optionals/filter_bk.hpp>
#include <bitcoin/database/tables/optionals/filter_tx.hpp>
#include <bitcoin/database/tables/optionals/silent.hpp>
#include <bitcoin/database/types/fee_rate.hpp>
#include <bitcoin/database/types/header_state.hpp>
#include <bitcoin/database/types/history.hpp>
#include <bitcoin/database/types/position.hpp>
#include <bitcoin/database/types/silent.hpp>
#include <bitcoin/database/types/span.hpp>
#include <bitcoin/database/types/type.hpp>
#include <bitcoin/database/types/types.hpp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ header_states CLASS::get_validated_fork(size_t& fork_point,
out.reserve(one);
code ec{};

// Disable filter constraint if filtering is disabled.
// Disable optional constraints when the indexes are disabled.
const auto filter = filter_enabled();
const auto silent = silent_enabled();
const auto silent_start = silent_start_height();

///////////////////////////////////////////////////////////////////////////
std::shared_lock interlock{ candidate_reorganization_mutex_ };
Expand All @@ -134,7 +136,8 @@ header_states CLASS::get_validated_fork(size_t& fork_point,
auto height = add1(fork_point);
auto link = to_candidate(height);
while (is_block_validated(ec, link, height, top_checkpoint) &&
(!filter || is_filtered_body(link)))
(!filter || is_filtered_body(link)) &&
(!silent || height < silent_start || is_silent_indexed(link)))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that both filter and silent index states should not be checked here. The filter check may be an impl artifact. See chaser_validate:

    // Valid must be set after set_prevouts and set_filter_body.
    if (!bypass && !query.set_block_valid(link))
        return error::validate8;

The block cannot be in a validated state without the filter having been set. If for some reason these are set and validation did not get set, then these would just get set again - but logically I don't believe that's possible due to node design without a hard fault/stop. Please remove both of these and verify behavior.

{
out.emplace_back(link, ec);
link = to_candidate(++height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,8 @@ bool CLASS::populate_with_metadata(const input& input,

// populate_without_metadata
// ----------------------------------------------------------------------------
// These are used when not performing confirmation. This also implies that
// validation is not being performed, so is used for populating prevouts for
// the purpose of computing client filters in the validation stage. So these
// are not used for in consensus but are kept here for close similarity.
// These are used outside confirmation, so validation is not being performed.
// They only populate prevouts and are kept here for close similarity.

TEMPLATE
bool CLASS::populate_without_metadata(const block& block) const NOEXCEPT
Expand Down
20 changes: 18 additions & 2 deletions include/bitcoin/database/impl/query/extent.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ size_t CLASS::store_body_size() const NOEXCEPT
+ validated_tx_body_size()
+ address_body_size()
+ filter_bk_body_size()
+ filter_tx_body_size();
+ filter_tx_body_size()
+ silent_body_size();
}

TEMPLATE
Expand Down Expand Up @@ -126,7 +127,8 @@ size_t CLASS::store_head_size() const NOEXCEPT
+ validated_tx_head_size()
+ address_head_size()
+ filter_bk_head_size()
+ filter_tx_head_size();
+ filter_tx_head_size()
+ silent_head_size();
}

// Sizes.
Expand All @@ -150,6 +152,7 @@ DEFINE_SIZES(validated_bk)
DEFINE_SIZES(validated_tx)
DEFINE_SIZES(filter_bk)
DEFINE_SIZES(filter_tx)
DEFINE_SIZES(silent)
DEFINE_SIZES(address)

// Buckets (hashmap + arraymap).
Expand All @@ -167,6 +170,7 @@ DEFINE_BUCKETS(validated_bk)
DEFINE_BUCKETS(validated_tx)
DEFINE_BUCKETS(filter_bk)
DEFINE_BUCKETS(filter_tx)
DEFINE_BUCKETS(silent)
DEFINE_BUCKETS(address)

// Records (arrays).
Expand Down Expand Up @@ -255,6 +259,18 @@ bool CLASS::filter_enabled() const NOEXCEPT
return store_.filter_bk.enabled() && store_.filter_tx.enabled();
}

TEMPLATE
bool CLASS::silent_enabled() const NOEXCEPT
{
return store_.silent.enabled();
}

TEMPLATE
size_t CLASS::silent_start_height() const NOEXCEPT
{
return store_.silent_start_height();
}

} // namespace database
} // namespace libbitcoin

Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/database/impl/query/initialize.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ bool CLASS::initialize(const block& genesis) NOEXCEPT
// Unsafe for allocation failure, but only used in store creation.
return set_filter_body(link, genesis)
&& set_filter_head(link)
&& set_silent(link, genesis)
&& push_candidate(link)
&& push_confirmed(link, true);
// ========================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ constexpr size_t CLASS::to_filter_tx(const header_link& link) const NOEXCEPT
return link.is_terminal() ? table::filter_tx::link::terminal : link.value;
}

TEMPLATE
constexpr size_t CLASS::to_silent(const header_link& link) const NOEXCEPT
{
static_assert(header_link::terminal <= table::silent::link::terminal);
return link.is_terminal() ? table::silent::link::terminal : link.value;
}

TEMPLATE
constexpr size_t CLASS::to_prevout(const header_link& link) const NOEXCEPT
{
Expand Down
Loading