pub(crate) async fn early_block_is_authenticated<ZS, ZSTip>(
read_state: ZS,
latest_chain_tip: ZSTip,
block: Arc<Block>,
height: Height,
early_check: Option<JoinHandle<bool>>,
) -> boolExpand description
Returns true if block at height passes the rest of the checks that authenticate it for
early relay, so a later validation failure doesn’t score the peer that sent it, if the peer has
an allowance for the block’s parent in its downloader’s EarlyRelayAllowances.
early_check is the task from start_early_relay_check(), if there is one. Otherwise the
state checks the block now.
Only call this for a block from a connection that negotiated compact block relay, after
is_later_validation_failure() returns true for its error.
§Security
The peer can relay the block once its parent is the peer’s best tip, so the block can fail here
before its parent is committed. If the check fails, this waits up to
EARLY_RELAY_PARENT_TIMEOUT for the parent to become the best tip, and checks the block
again. If the check fails while the parent is the best tip, it is retried once, in case the
best tip changed during the check.
The peer keeps its score if that check fails too, if a block at the same height or above becomes the best tip instead, or if the parent doesn’t become the best tip in time. So a forged body is still scored, and so is a block that can’t be checked against the best tip. The expected difficulty of a block depends on its parent’s chain, so without that check, the block could have much less proof of work than a valid block.