-
Notifications
You must be signed in to change notification settings - Fork 56
build silent payment index during validation #1027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,7 @@ enum error_t : uint8_t | |
| validate6, | ||
| validate7, | ||
| validate8, | ||
| validate9, | ||
| confirm1, | ||
| confirm2, | ||
| confirm3, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -388,6 +388,11 @@ bool chaser_confirm::set_organized(const header_link& link, | |
| } | ||
| #endif // !NDEBUG | ||
|
|
||
| const auto silent = query.silent_enabled() && | ||
| confirmed_height >= query.silent_start_height(); | ||
| if (silent && !query.is_silent_indexed(link)) | ||
| return false; | ||
|
|
||
| // Checkpointed blocks are set strong by archiver. | ||
| if (!query.push_confirmed(link, !is_under_checkpoint(confirmed_height))) | ||
| return false; | ||
|
|
@@ -396,6 +401,9 @@ bool chaser_confirm::set_organized(const header_link& link, | |
| fire(events::block_organized, confirmed_height); | ||
| LOGV("Block organized: " << confirmed_height); | ||
|
|
||
| if (silent) | ||
| notify(error::success, chase::silent_indexed, link); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would drop this chaser event. The same can be accomplished by subscribing to block/tx and filtering on feature enabled, which cuts event traffic in half. This is the approach with address and filter as well, so the event count could start becoming a performance and complexity issue at some point. |
||
|
|
||
| announce(link, confirmed_height); | ||
| return true; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,11 @@ chaser_validate::chaser_validate(full_node& node) NOEXCEPT | |
| maximum_backlog_(node.node_settings().maximum_concurrency_()), | ||
| node_witness_(node.network_settings().witness_node()), | ||
| defer_(node.node_settings().defer_validation), | ||
| filter_(!defer_ && node.archive().filter_enabled()) | ||
| filter_(!defer_ && node.archive().filter_enabled()), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that |
||
| silent_(!defer_ && node.network_settings().witness_node() && | ||
| node.node_settings().headers_first && | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why headers first? |
||
| node.system_settings().forks.bip341 && | ||
| node.archive().silent_enabled()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a lot going on here. Prob best to just set this to |
||
| { | ||
| } | ||
|
|
||
|
|
@@ -160,13 +164,14 @@ void chaser_validate::do_bumped(height_t height) NOEXCEPT | |
|
|
||
| const auto bypass = defer_ || is_under_checkpoint(height) || | ||
| query.is_milestone(link); | ||
| const auto silent = silent_ && height >= query.silent_start_height(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should make this a (efficient) query, similar to |
||
|
|
||
| switch (ec.value()) | ||
| { | ||
| case database::error::unvalidated: | ||
| case database::error::unknown_state: | ||
| { | ||
| if (!bypass || filter_) | ||
| if (!bypass || filter_ || silent) | ||
| post_block(link, bypass); | ||
| else | ||
| complete_block(error::success, link, height, true); | ||
|
|
@@ -175,7 +180,11 @@ void chaser_validate::do_bumped(height_t height) NOEXCEPT | |
| case database::error::block_valid: | ||
| case database::error::block_confirmable: | ||
| { | ||
| complete_block(error::success, link, height, true); | ||
| if (silent && !query.is_silent_indexed(link)) | ||
| post_block(link, true); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be removed. The valid (or valid and confirmable) state implies this has already been done. |
||
| else | ||
| complete_block(error::success, link, height, true); | ||
|
|
||
| break; | ||
| } | ||
| case database::error::block_unconfirmable: | ||
|
|
@@ -254,7 +263,7 @@ code chaser_validate::populate(bool bypass, const chain::block& block, | |
|
|
||
| if (bypass) | ||
| { | ||
| // Populating for filters only (no validation metadata required). | ||
| // Populating optional indexes only (no validation metadata required). | ||
| block.populate(ctx); | ||
| if (!query.populate_without_metadata(block)) | ||
| return system::error::missing_previous_output; | ||
|
|
@@ -306,7 +315,10 @@ code chaser_validate::validate(bool bypass, const chain::block& block, | |
| if (!query.set_filter_body(link, block)) | ||
| return error::validate7; | ||
|
|
||
| // Valid must be set after set_prevouts and set_filter_body. | ||
| if (silent_ && !query.set_silent(link, block)) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can avoid the |
||
| return error::validate9; | ||
|
|
||
| // Valid must be set after optional block indexes. | ||
| if (!bypass && !query.set_block_valid(link)) | ||
| return error::validate8; | ||
|
|
||
|
|
@@ -334,7 +346,6 @@ void chaser_validate::complete_block(const code& ec, const header_link& link, | |
| return; | ||
| } | ||
|
|
||
| // VALID BLOCK | ||
| // Under deferral there is no state change, but downloads will stall unless | ||
| // the window is closed out, so notify the check chaser of the increment. | ||
| notify(ec, chase::valid, possible_wide_cast<height_t>(height)); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ configuration::configuration(system::chain::selection context) NOEXCEPT | |
| network(context), | ||
| node(context) | ||
| { | ||
| database.silent_start_height = bitcoin.bip9_bit2_active_checkpoint.height(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This belongs in the settings class that defines the property. The choice of value can be determined explicitly from the chain selection |
||
| } | ||
|
|
||
| } // namespace node | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This belongs somewhere else, application logic. Since it's node-written prob just node. Also we use the term
thresholdfor a minimum in a few places.Though we should consider relationship to address indexing. We don't currently provide a threshold for that. Since that's written directly off of tx archive, it would require store config. That might drive this back into store config as well.
Don't forget to add to server parse once merged here.