-
Notifications
You must be signed in to change notification settings - Fork 86
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
Mempool: better revalidation and caching of the ledger state #1599
Conversation
ec4ac88
to
51a85fc
Compare
51a85fc
to
2a6f5c7
Compare
2a6f5c7
to
14f0906
Compare
14f0906
to
146187f
Compare
93332d5
to
31fff9c
Compare
ff9d849
to
2f7b7a7
Compare
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.
Reviewed over Hangout.
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.
Not finished reviewing yet but here are some comments.
2f7b7a7
to
ff1ff9d
Compare
validationErrorImpossible $ | ||
applyByronGenTx validationMode cfg tx st | ||
where | ||
validationMode = CC.ValidationMode CC.NoBlockValidation Utxo.NoTxValidation |
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.
Does this mean that we no longer need the NoTxValidation
mode in cardano-ledger
?
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.
Indeed not. @edsko and I have been looking for a ticket about this (that we could close), but we couldn't find it. Do you know which one that would be?
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'm not sure that there has been a ticket in ledger that specifically speaks to removing NoTxValidation
.
Using the `Mock.Utxo` instead of the overly simplistic `TestTx` we were using allows for more complicated dependencies between transactions. This better resembles the real transactions, at the cost of some complexity. Moreover, using the new transaction type reveals a bug that was not visible with the previous transaction type, i.e., #1565.
ff1ff9d
to
4ed6801
Compare
4ed6801
to
2c9c10c
Compare
bors r+ |
1599: Mempool: better revalidation and caching of the ledger state r=mrBliss a=mrBliss Fixes #1565 and #1301. * Replace `Mempool.addTxs` with `Mempool.tryAddTxs`, which doesn't block. This function will be much easier to test. We provide an implementation of `Mempool.addTxs` in terms of `Mempool.tryAddTxs`. We simplify the implementations by relying on the background thread for synchronising the Mempool with an updated ledger state. * Cache the `TickedLedgerState` after applying all transactions in the Mempool to it (#1301). Previously, we had to reapply all transactions whenever we added a new transaction. The new approach is much faster. * As we're keeping the `TickedLedgerState` in memory, make sure it is thunk-free. * Correct revalidation in (#1564) after explicitly removing transactions from the Mempool, see `revalidateTxsFor`. * Cleanup of conversion functions in `TxSeq`. * O(1) `MempoolSize` calculation for a `TxSeq` using its fingertree measure. Also includes a rewrite of the Mempool tests using the `Mock.Utxo`. Using the `Mock.Utxo` instead of the overly simplistic `TestTx` we were using allows for more complicated dependencies between transactions. This better resembles the real transactions, at the cost of some complexity. With the former transaction type, we weren't even able to trigger #1565. Co-authored-by: Thomas Winant <[email protected]>
bors r- |
Canceled |
Fixes #1565 and #1301. * Replace `Mempool.addTxs` with `Mempool.tryAddTxs`, which doesn't block. This function will be much easier to test. We provide an implementation of `Mempool.addTxs` in terms of `Mempool.tryAddTxs`. We simplify the implementations by relying on the background thread for synchronising the Mempool with an updated ledger state. * Cache the `TickedLedgerState` after applying all transactions in the Mempool to it (#1301). Previously, we had to reapply all transactions whenever we added a new transaction. The new approach is much faster. * As we're keeping the `TickedLedgerState` in memory, make sure it is thunk-free. * Correct revalidation in (#1565) after explicitly removing transactions from the Mempool, see `revalidateTxsFor`. * Cleanup of conversion functions in `TxSeq`. * O(1) `MempoolSize` calculation for a `TxSeq` using its fingertree measure.
This was failing the tests with thunk checking enabled (`-fchecktvarinvariant`).
2c9c10c
to
064ce45
Compare
bors r+ |
1599: Mempool: better revalidation and caching of the ledger state r=mrBliss a=mrBliss Fixes #1565 and #1301. * Replace `Mempool.addTxs` with `Mempool.tryAddTxs`, which doesn't block. This function will be much easier to test. We provide an implementation of `Mempool.addTxs` in terms of `Mempool.tryAddTxs`. We simplify the implementations by relying on the background thread for synchronising the Mempool with an updated ledger state. * Cache the `TickedLedgerState` after applying all transactions in the Mempool to it (#1301). Previously, we had to reapply all transactions whenever we added a new transaction. The new approach is much faster. * As we're keeping the `TickedLedgerState` in memory, make sure it is thunk-free. * Correct revalidation in (#1564) after explicitly removing transactions from the Mempool, see `revalidateTxsFor`. * Cleanup of conversion functions in `TxSeq`. * O(1) `MempoolSize` calculation for a `TxSeq` using its fingertree measure. Also includes a rewrite of the Mempool tests using the `Mock.Utxo`. Using the `Mock.Utxo` instead of the overly simplistic `TestTx` we were using allows for more complicated dependencies between transactions. This better resembles the real transactions, at the cost of some complexity. With the former transaction type, we weren't even able to trigger #1565. Co-authored-by: Thomas Winant <[email protected]>
Fixes #1565 and #1301.
Replace
Mempool.addTxs
withMempool.tryAddTxs
, which doesn't block. This function will be much easier to test. We provide an implementation ofMempool.addTxs
in terms ofMempool.tryAddTxs
. We simplify the implementations by relying on the background thread for synchronising the Mempool with an updated ledger state.Cache the
TickedLedgerState
after applying all transactions in the Mempool to it (Mempool should cache "final ledger state" #1301). Previously, we had to reapply all transactions whenever we added a new transaction. The new approach is much faster.As we're keeping the
TickedLedgerState
in memory, make sure it is thunk-free.Correct revalidation in (Add optional expiry slot to Mock transactions #1564) after explicitly removing transactions from the Mempool, see
revalidateTxsFor
.Cleanup of conversion functions in
TxSeq
.O(1)
MempoolSize
calculation for aTxSeq
using its fingertree measure.Also includes a rewrite of the Mempool tests using the
Mock.Utxo
. Using theMock.Utxo
instead of the overly simplisticTestTx
we were using allows for more complicated dependencies between transactions. This better resembles the real transactions, at the cost of some complexity. With the former transaction type, we weren't even able to trigger #1565.