Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChainDB: ChainDB should be able to return chain fragments with associated ledger states #1440

Closed
edsko opened this issue Jan 10, 2020 · 4 comments · Fixed by #1446
Closed
Assignees
Labels
chain db consensus issues related to ouroboros-consensus
Milestone

Comments

@edsko
Copy link
Contributor

edsko commented Jan 10, 2020

This will be required in order to be able to create a fork in block production; see #1437 for details. The tentative API proposal is

getLedgerHistory :: STM m (Lazy.AnchoredFragment (Header blk, ExtLedgerState blk))
@edsko edsko added chain db consensus issues related to ouroboros-consensus labels Jan 10, 2020
@edsko edsko added this to the S4 2020-01-16 milestone Jan 10, 2020
@edsko
Copy link
Contributor Author

edsko commented Jan 10, 2020

This will be required for the implementation of the local state query protocol also (#1366).

@edsko
Copy link
Contributor Author

edsko commented Jan 10, 2020

Due to concerns about laziness, will implement

    , getPastLedger      :: STM m (Point -> Maybe (ExtLedgerState blk))

instead.

@edsko
Copy link
Contributor Author

edsko commented Jan 10, 2020

Turns out, this is not implementable (either function). The problem is that computing an arbitrary ledger state may involve reading from disk, and hence this cannot live in STM. We need to split up block production in order to do this; that is, we need to close #786 first.

@edsko
Copy link
Contributor Author

edsko commented Jan 10, 2020

Marking as high priority because required to fix a bug (#1437).

edsko added a commit that referenced this issue Jan 13, 2020
edsko added a commit that referenced this issue Jan 13, 2020
edsko added a commit that referenced this issue Jan 13, 2020
iohk-bors bot added a commit that referenced this issue Jan 13, 2020
1446: Add ability to get past ledger states r=edsko a=edsko

This also fixes a regression in the tests where non-saturated chains (fewer than `k` blocks) were ruled out; fortunately, this was a regression in the tests only, not in the code. Running 1M tests on the in-memory ledger DB:

```
# cabal run test-storage -- -p InMemory --quickcheck-tests=1000000
Up to date
ouroboros-storage
  Storage
    LedgerDB
      InMemory
        Serialisation
          ChainSummary:           OK (5.80s)
            +++ OK, passed 1000000 tests.
        Genesis
          length:                 OK (1.21s)
            +++ OK, passed 1000000 tests.
          current:                OK (1.21s)
            +++ OK, passed 1000000 tests.
        Push
          incrementsLength:       OK (2.26s)
            +++ OK, passed 1000000 tests (64.0082% saturated).
          lengthMatchesNumBlocks: OK (2.08s)
            +++ OK, passed 1000000 tests (63.9868% saturated).
          matchesPolicy:          OK (2.38s)
            +++ OK, passed 1000000 tests (63.9719% saturated).
          expectedLedger:         OK (3.02s)
            +++ OK, passed 1000000 tests (63.9387% saturated).
          pastLedger:             OK (3.76s)
            +++ OK, passed 1000000 tests:
            96.4751% within reach
            63.9570% saturated
        Rollback
          maxRollbackGenesisZero: OK (1.26s)
            +++ OK, passed 1000000 tests.
          ledgerDbMaxRollback:    OK (2.83s)
            +++ OK, passed 1000000 tests (63.9984% saturated).
          switchSameChain:        OK (3.35s)
            +++ OK, passed 1000000 tests (63.9431% saturated).
          switchMatchesPolicy:    OK (3.84s)
            +++ OK, passed 1000000 tests (64.0446% saturated).
          switchExpectedLedger:   OK (4.99s)
            +++ OK, passed 1000000 tests (64.0571% saturated).
          pastAfterSwitch:        OK (5.34s)
            +++ OK, passed 1000000 tests:
            92.9097% within reach
            63.9944% saturated
```

All 14 tests passed (43.35s)

Closes #1440.

Co-authored-by: Edsko de Vries <[email protected]>
@iohk-bors iohk-bors bot closed this as completed in 4896df7 Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chain db consensus issues related to ouroboros-consensus
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant