-
Notifications
You must be signed in to change notification settings - Fork 168
Integrate UTxO-HD #1996
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
Integrate UTxO-HD #1996
Conversation
This allows us to carry around ledger tables with a minimal UTxO set, which reduces the amount of processing we have to do when applying blocks to the ledger state
(encodeDisk codecConfig) | ||
(encodeDisk codecConfig) | ||
(encodeDisk codecConfig) | ||
. forgetLedgerTables |
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.
We need to pass the Tables to the encoder. Otherwise the whole UTxO set is lost on restarts.
mconcat | ||
[ encodeExt (clsState cls) | ||
, toCBOR (clsEpochBlockNo cls) | ||
] |
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.
Also encode the ledger tables, preferebly after the clsEpochBlockNo
ldgrState <- decodeExt | ||
CardanoLedgerState ldgrState <$> fromCBOR | ||
let ldgrTables = Consensus.projectLedgerTables (Consensus.unstowLedgerTables ldgrState) | ||
CardanoLedgerState ldgrState ldgrTables <$> fromCBOR |
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.
These ledger tables must be empty here, since forgetLedgerTables
is used before the encoder. The maintained edger tables should be passed here
Another possible extention is trying to achive backwards compatibility on ledger snapshots. This would be a an decoder that can decoder either old snapshots with ledger state containing values or an empty ledger state with a edger table attached separately. This can be done on a separate pr though, so feel free to ignore for now.
(MonadBaseControl IO m, MonadIO m) => | ||
SyncEnv -> | ||
ExtLedgerState CardanoBlock -> | ||
ExtLedgerState CardanoBlock mk -> |
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.
I think we need to pass the Ledger Tables here as well, since the Ledger state is expected to be empty. getUTxO
woud then extract UTxO using the tables instead of the state.
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.
Also if we ever use this function once, we could avoid parametrizing it over mk
} | ||
|
||
epochUpdate :: ExtLedgerState CardanoBlock -> EpochUpdate | ||
epochUpdate :: ExtLedgerState CardanoBlock mk -> EpochUpdate |
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.
Let's avoid parametrizing these functions if we ever use them once.
blk | ||
tipState | ||
-- Apply the diffs | ||
!newTipState = applyDiffs tipState diffState |
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.
Let's monitor tests in case this makes them too slow.Especially tests that mass produce transactions.
Superceded by #1998 |
Description
This separates the Ledger State from Ledger Tables, and we carry them separately. This allows us to keep the smallest possible UTxO set when applying blocks to the ledger state.
Checklist
fourmolu
on version 0.10.1.0 (which can be run withscripts/fourmolize.sh
)Migrations
If there is a breaking change, especially a big one, please add a justification here. Please elaborate
more what the migration achieves, what it cannot achieve or why a migration is not possible.