-
Notifications
You must be signed in to change notification settings - Fork 632
CBR-499: Extend LastBksSlots data type and storage for OBFT #4003
Conversation
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.
Looks great. I have some nitpicks and questions to check my understanding. I don't think that adoption of my suggestions would cause behavioral changes - they're more for clarity.
Q: why do we have an IORef in addition to the database state? Presumably anywhere we read an IORef we need IO, so then we could use the DB. Is this a caching/performance thing?
I think we have it in the DB and an |
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.
Q: why do we have an IORef in addition to the database state? Presumably anywhere we read an IORef we need IO, so then we could use the DB. Is this a caching/performance thing?
I think we have it in the DB and an IORef so we can read it off disk on startup, but use the IORef at run time. This is not the way I would have done it. If I was to do this from scratch, I would never keep this data in the database, only in memory and on startup, recreate this structure from the data base.
Gotcha. The DB+IORef approach does seem like a weird design decision, and your suggestion makes much more sense. But this works, so LGTM besides that mainnet syncing is failing.
The existing generator was generating 'BlockScenario's with two blocks with the same hash in a sequence of applys. This happened a number of times while I was debugging but now I can't reproduce it without this patch. Will leave this patch in just to make sure.
b49ab4a
to
59eb3f7
Compare
I tried changing it so that |
newLastSlots lastSlots = lastSlots & _Wrapped %~ updateLastSlots | ||
dropEnd n xs = take (length xs - n) xs | ||
|
||
lastSlotsToAppend :: [LastSlotInfo] |
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.
lastSlotsToAppend
replaces lastSlotsToPrepend
which was wrong because it failed to maintain the OldestFirst
invariant.
Dismissing review to guarantee a fresh review since the code has changed so much.
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.
Nice work wrangling this crazy code
bors r+ |
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.
LGTM!
Merge conflict (retrying...) |
4003: CBR-499: Extend LastBksSlots data type and storage for OBFT r=mhuesch a=erikd ## Description Keep the hash of the public key used to sign each block for the last `k` blocks as required by the OBFT protocol. ## Linked issue https://iohk.myjetbrains.com/youtrack/issue/CBR-499 4040: Batch Import Addresses to 1.5.0 r=KtorZ a=KtorZ ## Description <!--- A brief description of this PR and the problem is trying to solve --> Backporting cardano-foundation/cardano-wallet#259 to 1.5.0 ## Linked issue <!--- Put here the relevant issue from YouTrack --> Co-authored-by: Erik de Castro Lopo <erikd@mega-nerd.com> Co-authored-by: KtorZ <matthias.benkort@gmail.com>
Timed out (retrying...) |
bors r- |
Canceled |
bors r+ p=7 |
4003: CBR-499: Extend LastBksSlots data type and storage for OBFT r=disassembler a=erikd ## Description Keep the hash of the public key used to sign each block for the last `k` blocks as required by the OBFT protocol. ## Linked issue https://iohk.myjetbrains.com/youtrack/issue/CBR-499 Co-authored-by: Erik de Castro Lopo <erikd@mega-nerd.com>
Build succeeded |
Description
Keep the hash of the public key used to sign each block for the last
k
blocks as required by the OBFT protocol.Linked issue
https://iohk.myjetbrains.com/youtrack/issue/CBR-499