-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change(test): Create test harness for calling getblocktemplate in pro…
…posal mode, but don't use it yet (#5884) * adds ValidateBlock request to state * adds `Request` enum in block verifier skips solution check for BlockProposal requests calls CheckBlockValidity instead of Commit block for BlockProposal requests * uses new Request in references to chain verifier * adds getblocktemplate proposal mode response type * makes getblocktemplate-rpcs feature in zebra-consensus select getblocktemplate-rpcs in zebra-state * Adds PR review revisions * adds info log in CheckBlockProposalValidity * Reverts replacement of match statement * adds `GetBlockTemplate::capabilities` fn * conditions calling checkpoint verifier on !request.is_proposal * updates references to validate_and_commit_non_finalized * adds snapshot test, updates test vectors * adds `should_count_metrics` to NonFinalizedState * Returns an error from chain verifier for block proposal requests below checkpoint height adds feature flags * adds "proposal" to GET_BLOCK_TEMPLATE_CAPABILITIES_FIELD * adds back block::Request to zebra-consensus lib * updates snapshots * Removes unnecessary network arg * skips req in tracing intstrument for read state * Moves out block proposal validation to its own fn * corrects `difficulty_threshold_is_valid` docs adds/fixes some comments, adds TODOs general cleanup from a self-review. * Update zebra-state/src/service.rs * Apply suggestions from code review Co-authored-by: teor <[email protected]> * Update zebra-rpc/src/methods/get_block_template_rpcs.rs Co-authored-by: teor <[email protected]> * check best chain tip * Update zebra-state/src/service.rs Co-authored-by: teor <[email protected]> * Applies cleanup suggestions from code review * updates gbt acceptance test to make a block proposal * fixes json parsing mistake * adds retries * returns reject reason if there are no retries left * moves result deserialization to RPCRequestClient method, adds docs, moves jsonrpc_core to dev-dependencies * moves sleep(EXPECTED_TX_TIME) out of loop * updates/adds info logs in retry loop * Revert "moves sleep(EXPECTED_TX_TIME) out of loop" This reverts commit f7f0926. * adds `allow(dead_code)` * tests with curtime, mintime, & maxtime * Fixes doc comment * Logs error responses from chain_verifier CheckProposal requests * Removes retry loop, adds num_txs log * removes verbose info log * sorts mempool_txs before generating merkle root * Make imports conditional on a feature * Disable new CI tests until bugs are fixed Co-authored-by: teor <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
402ed3e
commit b0ba920
Showing
10 changed files
with
246 additions
and
76 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
zebra-rpc/src/methods/get_block_template_rpcs/types/get_block_template/proposal.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//! `ProposalResponse` is the output of the `getblocktemplate` RPC method in 'proposal' mode. | ||
use super::{GetBlockTemplate, Response}; | ||
|
||
/// Error response to a `getblocktemplate` RPC request in proposal mode. | ||
/// | ||
/// See <https://en.bitcoin.it/wiki/BIP_0022#Appendix:_Example_Rejection_Reasons> | ||
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub enum ProposalRejectReason { | ||
/// Block proposal rejected as invalid. | ||
Rejected, | ||
} | ||
|
||
/// Response to a `getblocktemplate` RPC request in proposal mode. | ||
/// | ||
/// See <https://en.bitcoin.it/wiki/BIP_0023#Block_Proposal> | ||
#[derive(Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)] | ||
#[serde(untagged, rename_all = "kebab-case")] | ||
pub enum ProposalResponse { | ||
/// Block proposal was rejected as invalid, returns `reject-reason` and server `capabilities`. | ||
ErrorResponse { | ||
/// Reason the proposal was invalid as-is. | ||
reject_reason: ProposalRejectReason, | ||
|
||
/// The getblocktemplate RPC capabilities supported by Zebra. | ||
capabilities: Vec<String>, | ||
}, | ||
|
||
/// Block proposal was successfully validated, returns null. | ||
Valid, | ||
} | ||
|
||
impl From<ProposalRejectReason> for ProposalResponse { | ||
fn from(reject_reason: ProposalRejectReason) -> Self { | ||
Self::ErrorResponse { | ||
reject_reason, | ||
capabilities: GetBlockTemplate::capabilities(), | ||
} | ||
} | ||
} | ||
|
||
impl From<ProposalRejectReason> for Response { | ||
fn from(error_response: ProposalRejectReason) -> Self { | ||
Self::ProposalMode(ProposalResponse::from(error_response)) | ||
} | ||
} | ||
|
||
impl From<ProposalResponse> for Response { | ||
fn from(proposal_response: ProposalResponse) -> Self { | ||
Self::ProposalMode(proposal_response) | ||
} | ||
} | ||
|
||
impl From<GetBlockTemplate> for Response { | ||
fn from(template: GetBlockTemplate) -> Self { | ||
Self::TemplateMode(Box::new(template)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.