Mar 25, 9-10 AM (33)
Mar 25, 10-11 AM (42)
Mar 25, 11-12 PM (50)
Mar 25, 12-1 PM (37)
Mar 25, 1-2 PM (37)
Mar 25, 2-3 PM (30)
Mar 25, 3-4 PM (27)
Mar 25, 4-5 PM (29)
Mar 25, 5-6 PM (17)
Mar 25, 6-7 PM (10)
Mar 25, 7-8 PM (15)
Mar 25, 8-9 PM (17)
Mar 25, 9-10 PM (9)
Mar 25, 10-11 PM (6)
Mar 25, 11-12 AM (1)
Mar 26, 12-1 AM (2)
Mar 26, 1-2 AM (8)
Mar 26, 2-3 AM (12)
Mar 26, 3-4 AM (1)
Mar 26, 4-5 AM (12)
Mar 26, 5-6 AM (2)
Mar 26, 6-7 AM (11)
Mar 26, 7-8 AM (41)
Mar 26, 8-9 AM (23)
Mar 26, 9-10 AM (36)
Mar 26, 10-11 AM (33)
Mar 26, 11-12 PM (19)
Mar 26, 12-1 PM (18)
Mar 26, 1-2 PM (27)
Mar 26, 2-3 PM (26)
Mar 26, 3-4 PM (31)
Mar 26, 4-5 PM (61)
Mar 26, 5-6 PM (21)
Mar 26, 6-7 PM (19)
Mar 26, 7-8 PM (30)
Mar 26, 8-9 PM (14)
Mar 26, 9-10 PM (7)
Mar 26, 10-11 PM (5)
Mar 26, 11-12 AM (6)
Mar 27, 12-1 AM (10)
Mar 27, 1-2 AM (0)
Mar 27, 2-3 AM (2)
Mar 27, 3-4 AM (7)
Mar 27, 4-5 AM (8)
Mar 27, 5-6 AM (7)
Mar 27, 6-7 AM (2)
Mar 27, 7-8 AM (8)
Mar 27, 8-9 AM (14)
Mar 27, 9-10 AM (15)
Mar 27, 10-11 AM (34)
Mar 27, 11-12 PM (14)
Mar 27, 12-1 PM (18)
Mar 27, 1-2 PM (7)
Mar 27, 2-3 PM (41)
Mar 27, 3-4 PM (21)
Mar 27, 4-5 PM (25)
Mar 27, 5-6 PM (20)
Mar 27, 6-7 PM (17)
Mar 27, 7-8 PM (15)
Mar 27, 8-9 PM (6)
Mar 27, 9-10 PM (14)
Mar 27, 10-11 PM (15)
Mar 27, 11-12 AM (11)
Mar 28, 12-1 AM (22)
Mar 28, 1-2 AM (12)
Mar 28, 2-3 AM (6)
Mar 28, 3-4 AM (2)
Mar 28, 4-5 AM (5)
Mar 28, 5-6 AM (1)
Mar 28, 6-7 AM (2)
Mar 28, 7-8 AM (4)
Mar 28, 8-9 AM (3)
Mar 28, 9-10 AM (0)
Mar 28, 10-11 AM (0)
Mar 28, 11-12 PM (2)
Mar 28, 12-1 PM (2)
Mar 28, 1-2 PM (1)
Mar 28, 2-3 PM (2)
Mar 28, 3-4 PM (1)
Mar 28, 4-5 PM (8)
Mar 28, 5-6 PM (7)
Mar 28, 6-7 PM (9)
Mar 28, 7-8 PM (7)
Mar 28, 8-9 PM (5)
Mar 28, 9-10 PM (3)
Mar 28, 10-11 PM (1)
Mar 28, 11-12 AM (0)
Mar 29, 12-1 AM (4)
Mar 29, 1-2 AM (0)
Mar 29, 2-3 AM (0)
Mar 29, 3-4 AM (3)
Mar 29, 4-5 AM (4)
Mar 29, 5-6 AM (2)
Mar 29, 6-7 AM (0)
Mar 29, 7-8 AM (3)
Mar 29, 8-9 AM (0)
Mar 29, 9-10 AM (0)
Mar 29, 10-11 AM (0)
Mar 29, 11-12 PM (3)
Mar 29, 12-1 PM (2)
Mar 29, 1-2 PM (3)
Mar 29, 2-3 PM (10)
Mar 29, 3-4 PM (16)
Mar 29, 4-5 PM (0)
Mar 29, 5-6 PM (0)
Mar 29, 6-7 PM (2)
Mar 29, 7-8 PM (2)
Mar 29, 8-9 PM (4)
Mar 29, 9-10 PM (2)
Mar 29, 10-11 PM (7)
Mar 29, 11-12 AM (8)
Mar 30, 12-1 AM (6)
Mar 30, 1-2 AM (2)
Mar 30, 2-3 AM (4)
Mar 30, 3-4 AM (3)
Mar 30, 4-5 AM (7)
Mar 30, 5-6 AM (8)
Mar 30, 6-7 AM (8)
Mar 30, 7-8 AM (17)
Mar 30, 8-9 AM (13)
Mar 30, 9-10 AM (30)
Mar 30, 10-11 AM (21)
Mar 30, 11-12 PM (37)
Mar 30, 12-1 PM (16)
Mar 30, 1-2 PM (15)
Mar 30, 2-3 PM (13)
Mar 30, 3-4 PM (14)
Mar 30, 4-5 PM (21)
Mar 30, 5-6 PM (11)
Mar 30, 6-7 PM (18)
Mar 30, 7-8 PM (22)
Mar 30, 8-9 PM (12)
Mar 30, 9-10 PM (6)
Mar 30, 10-11 PM (13)
Mar 30, 11-12 AM (10)
Mar 31, 12-1 AM (6)
Mar 31, 1-2 AM (19)
Mar 31, 2-3 AM (4)
Mar 31, 3-4 AM (7)
Mar 31, 4-5 AM (11)
Mar 31, 5-6 AM (3)
Mar 31, 6-7 AM (16)
Mar 31, 7-8 AM (25)
Mar 31, 8-9 AM (25)
Mar 31, 9-10 AM (13)
Mar 31, 10-11 AM (15)
Mar 31, 11-12 PM (19)
Mar 31, 12-1 PM (20)
Mar 31, 1-2 PM (25)
Mar 31, 2-3 PM (37)
Mar 31, 3-4 PM (20)
Mar 31, 4-5 PM (13)
Mar 31, 5-6 PM (10)
Mar 31, 6-7 PM (28)
Mar 31, 7-8 PM (15)
Mar 31, 8-9 PM (9)
Mar 31, 9-10 PM (5)
Mar 31, 10-11 PM (6)
Mar 31, 11-12 AM (1)
Apr 01, 12-1 AM (9)
Apr 01, 1-2 AM (11)
Apr 01, 2-3 AM (8)
Apr 01, 3-4 AM (3)
Apr 01, 4-5 AM (4)
Apr 01, 5-6 AM (7)
Apr 01, 6-7 AM (9)
Apr 01, 7-8 AM (26)
Apr 01, 8-9 AM (11)
Apr 01, 9-10 AM (7)
2,077 commits this week Mar 25, 2020 - Apr 01, 2020

ChainDB.StateMachine: trigger the bug in #1624

To verify whether #1625 correctly fixed the bug found in #1624, I reverted the fix from #1625 in the real implementation (but not in the model), i.e.:

modified   ouroboros-consensus/src/Ouroboros/Consensus/Storage/ChainDB/Impl/ChainSel.hs
@@ -224,7 +224,7 @@ addBlockSync [email protected] {..} BlockToAdd { blockToAdd = b, .. } = do

     -- ### Ignore
     if
-      | olderThanK hdr (cdbIsEBB hdr) immBlockNo -> do
+      | At (blockNo hdr) <= immBlockNo && blockNo hdr /= 0 ->
         trace $ IgnoreBlockOlderThanK (blockRealPoint b)
         deliverPromises curTip

and ran many ChainDB.StateMachine tests. Disappointingly, the tests never failed because of this bug (they did trigger a bug in the previous commit, though).

After a long investigation, I discovered it was because the storage TestBlock uses BFT, and its ConsensusProtocol and ValidateEnvelope instances, which do not account for EBBs, in conjunction with EBBs. Many blocks (especially the first block or EBB) we generated that we thought were valid, were actually invalid because they didn’t have the expected block number! As a consequence, we were not able to generate a scenario in which the bug manifested itself.

The fix:

  • Use the ModChainSel combinator to override compareCandidates to be EBB-aware, like in PBFT. This approach is simpler than switching to PBFT entirely, as validation and other things are more complex in PBFT, and we want to keep the test block as simple as possible.
  • Override the ValidateEnvelope instance to be EBB-aware. Similar to Byron’s instance, but where Byron requires the chain to start with an EBB with block number 0, we allow either such an EBB or a regular block with block number 1.

With these changes, we can finally trigger the bug in <1000 tests, e.g.,

k = 2, chunk/epoch size irrelevant, EBBs allowed

  • Add and adopt regular block A fitting on genesis
  • Add and adopt regular block B fitting on A
  • Add and adopt regular block C fitting on B
  • Run background tasks: block A is copied to the ImmutableDB
  • Wipe the VolatileDB: A is now the immutable tip, B and C are gone
  • Add and adopt the EBB of the next epoch, fitting on A. This EBB will have the same block number as A. Before #1625, the EBB was ignored instead of adopted, with the fix it’s not.

Moreover, move the test config creation to the test block module.

Revise section on applying a coin selection algorithm to a wallet.

Of course, the concept of a coin selection algorithm can be completely divorced from the concept of a wallet. So we take a lot of care, for example, to talk about the /initiall UTxO set rather than the /wallet/ UTxO set.

But occasionally placing coin selection in the context of a wallet is helpful, as that is a very common context in which a UTxO appears, and it gives readers a bit of context for how these algorithms are used.

Response to feedback here:

https://github.com/input-output-hk/cardano-coin-selection/pull/16#discussion_r397885226