IntersectMBO / ouroboros-consensus

Implementation of a Consensus Layer for the Ouroboros family of protocols
https://ouroboros-consensus.cardano.intersectmbo.org
Apache License 2.0
31 stars 22 forks source link

Mempool could carry a single era block state always #348

Open jasagredo opened 1 year ago

jasagredo commented 1 year ago

The Mempool is virtually just a block on top of the tip + 1 slot, therefore it lives in a single era. The internal state could carry a single era ledger state + tables, which would make revalidation for the hard fork block faster, going from this:

Syncing with the ledger consists of:
1. Consult txins (blk -> hf)
2. Read backing store (hf)
3. Forward them through db-changelog (hf)
4. Attach result to tip (hf)
5. Tick (hf)
6. Repeatedly *REAPPLY* (hf)
   1. Unwrap HF state (hf -> blk)  -- injection/translation every time
   2. Call ledger reapplyTx (blk)
   3. Compute diff (blk)
   4. Attach diff to Tracking (blk -> hf)
   5. Inject new values to Tracking (blk -> hf)
7. Store diffs (hf)

To this:

Syncing with the ledger consists of:                (NEW)
1. Consult txins (blk -> hf)
2. Read backing store (hf)
3. Forward them through db-changelog (hf)
4. Attach result to tip (hf)
5. Tick (hf)
6. Unwrap HF state (hf -> blk) -- injection/translation once
7. Repeatedly *REAPPLY* (blk)
   1. Call ledger applyTx (blk)
   2. Compute diff (blk)
   3. Attach diff to Tracking (blk)
   4. Inject new values to Tracking (blk)
8. Store diffs (blk)

This might not be necessary depending on #347

jasagredo commented 1 year ago

Demoted to tech-debt as this might be a nice-to-have but we are not doing it now