You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As mentioned in IntersectMBO/cardano-ledger#1785 (comment), the majority of block replay time is spent in C functions doing crypto checks, see the two top of the profiling report:
Both are part of validateHeader, which accounts for 63.2% of the time and 11.6% of the allocations.
Note that this is when we're reapplying blocks, so we know these blocks and thus their headers are already valid. While we already distinguish between block body application and reapplication, we don't do the same thing for block header validation.
validateEnvelope, which is cheap, but could be skipped during header revalidation. Maybe leave it in as a basic sanity check?
updateChainDepState, expensive, as Shelley's implementation uses the Prtcl rule, which calls the Overlay rule, which includes pbftVrfChecks (current hotspot) and praosVrfChecks (likely the future hotspot when more decentralised). The Overlay rule also calls the Ocert rule, which does a KES check with verifySignedKES, which is the second verify from the profiling report.
Both of these checks should not be needed during revalidation. However, the Prtcl rule and its subrules do update some state, i.e., the ChainDepState, so we can't just not call these rules.
If the ledger provides a version of updateChainDepState (note that this is a function in cardano-ledger-specs, provided exactly to be used for the Shelley implementation of consensus' updateChainDepState function) that skips the VRF and KES checks, we can use that in consensus to speed up header revalidation.
headerStatePush, cheapest of all three and required, as it builds up required state. Must be included in revalidation.
Consensus changes:
Introduce the reupdateChainDepState method in the ConsensusProtocol class, similar to updateChainDepState, but its implementation can assume updateChainDepState has been called before with the same header so it can skip the expensive crypto checks. I'm not sure yet whether it will still return an Except or just the updated ChainDepState.
Introduce a function called revalidateHeader in Ouroboros.Consensus.HeaderValidation (to be used when reapplying blocks here), which calls validateEnvelope, headerStatePush, and reupdateChainDepState.
The text was updated successfully, but these errors were encountered:
Used for IntersectMBO/ouroboros-network#2520
This allows the avoidance of expensive crypto checks during block
reapplication, and shoudl shave something like 60% of the time off of
block reapplication.
Implements the plan described in #2520.
My block revalidation test went from 1m52s to 45s, which nicely matches the
expected speed-up: header validation took ~60% of the time.
Implements the plan described in #2520.
My block revalidation test went from 1m52s to 45s, which nicely matches the
expected speed-up: header validation took ~60% of the time.
2521: Introduce header revalidation to speed up Shelley block revalidation r=mrBliss a=mrBliss
Implements the plan described in #2520.
My block revalidation test went from 1m52s to 45s, which nicely matches the
expected speed-up: header validation took ~60% of the time.
Co-authored-by: Thomas Winant <thomas@well-typed.com>
As mentioned in IntersectMBO/cardano-ledger#1785 (comment), the majority of block replay time is spent in C functions doing crypto checks, see the two top of the profiling report:
Both are part of
validateHeader
, which accounts for 63.2% of the time and 11.6% of the allocations.Note that this is when we're reapplying blocks, so we know these blocks and thus their headers are already valid. While we already distinguish between block body application and reapplication, we don't do the same thing for block header validation.
Header validation consists of three parts:
https://github.com/input-output-hk/ouroboros-network/blob/cfb465726c9d023ad3ab2a3030d847df27787c3d/ouroboros-consensus/src/Ouroboros/Consensus/HeaderValidation.hs#L474-L492
validateEnvelope
, which is cheap, but could be skipped during header revalidation. Maybe leave it in as a basic sanity check?updateChainDepState
, expensive, as Shelley's implementation uses thePrtcl
rule, which calls theOverlay
rule, which includespbftVrfChecks
(current hotspot) andpraosVrfChecks
(likely the future hotspot when more decentralised). TheOverlay
rule also calls theOcert
rule, which does a KES check withverifySignedKES
, which is the secondverify
from the profiling report.Both of these checks should not be needed during revalidation. However, the
Prtcl
rule and its subrules do update some state, i.e., theChainDepState
, so we can't just not call these rules.If the ledger provides a version of
updateChainDepState
(note that this is a function incardano-ledger-specs
, provided exactly to be used for the Shelley implementation of consensus'updateChainDepState
function) that skips the VRF and KES checks, we can use that in consensus to speed up header revalidation.headerStatePush
, cheapest of all three and required, as it builds up required state. Must be included in revalidation.Consensus changes:
reupdateChainDepState
method in theConsensusProtocol
class, similar toupdateChainDepState
, but its implementation can assumeupdateChainDepState
has been called before with the same header so it can skip the expensive crypto checks. I'm not sure yet whether it will still return anExcept
or just the updatedChainDepState
.revalidateHeader
inOuroboros.Consensus.HeaderValidation
(to be used when reapplying blocks here), which callsvalidateEnvelope
,headerStatePush
, andreupdateChainDepState
.The text was updated successfully, but these errors were encountered: