Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add(mempool): Verify transactions with unmined inputs in the mempool (#…
…8857) * Adds a parameter to `zebra_consensus::router::init()` for accepting a mempool setup argument, adds and uses an `init_test()` fn for passing a closed channel receiver in tests where no mempool service is needed in the transaction verifier. * Adds a `mempool` argument to the transaction::Verifier constructor (and a `new_for_tests()` constructor for convenience) * Removes `Clone` impl on `transaction::Verifier` to add mempool oneshot receiver, updates tests. * Adds TODOs * updates transaction verifier's poll_ready() method to setup the mempool service handle. * Updates VerifiedSet struct used in mempool storage * Updates mempool service and its `Storage` to use the updated `VerifiedSet` `transactions()` return type. * updates `created_outputs` when inserting or removing a transaction from the mempool's verified set * Adds a TODO, updates field docs * Updates `spent_utxos()` to query the mempool for unspent outputs * Adds `spent_mempool_outpoints` as a field on tx verifier mempool response * Updates mempool `Downloads` to return the spent_mempool_outpoints from the tx verifier response * Updates `Storage.insert()` to accept a list of spent mempool transaction outputs * Adds transaction dependencies when inserting a tx in `VerifiedSet` * polls mempool svc from tx verifier when a mempool tx that creates transparent outputs has been verified. adds a TODO for adding a `pending_outputs` field to the mempool Storage * Adds `pending_outputs` field on mempool Storage and responds to pending outputs requests when inserting new transactions into the mempool's verified set * replaces `UnminedTxId` type with `transaction::Hash` in mempool's verified set * prune pending outputs when rejecting and removing same effects. * Remove dependent transactions from verified set when removing a tx * updates tests * appeases clippy. * removes unused `len()` method * fixes doc links * Adds transaction dependencies to the `FullTransactions` response, let the caller handle it (required to avoid moving zip317 tx selection code to mempool) * updates block template construction to avoid including transactions unless their dependencies have already been added. * updates tests * Replaces placeholder setup channel with one that sends the mempool svc to the tx verifier, adds a timeout layer, adds a TODO about a concurrency bug * Use a single query to check for unspent outputs in the mempool * Updates `getblocktemplate` method to consider dependencies when sorting transactions for the final template * fixes clippy lints, removes unnecessary Option in UnspentOutput response variant * renames type alias and method, adds a TODO to use iteration instead of recursion * Adds mempool_removes_dependent_transactions() test * Updates Storage and VerifiedSet clear() methods to clear pending_outputs, created_outputs, and transaction_dependencies, adds TODO to use iteration instead of recursion. * removes outdated TODO * Adds a TODO for reporting queued transaction verification results from the mempool from the poll_ready() method * Adds `mempool_responds_to_await_output` test * updates mempool_responds_to_await_output test * Uses iteration instead of recursion in verified set's remove() method and zip317 mod's dependencies_depth() method * Adds a mempool_request_with_mempool_output_is_accepted test for the transaction verifier * Moves delay duration before polling the mempool to a constant, uses a shorter timeout for mempool output lookups, adds a `poll_count` to MockService, and updates `mempool_request_with_unmined_output_spends_is_accepted` to check that the transaction verifier polls the mempool after verifying a mempool transaction with transparent outputs * adds long_poll_input_mempool_tx_ids_are_sorted test * Adds a `excludes_tx_with_unselected_dependencies` test * Updates a TODO * moves `TransactionDependencies` struct to `zebra-node-services` * Updates `FullTransactions` response variant's `transaction_dependencies` type * updates zip317 transaction selection for block templates to include dependent transactions * Moves and refactors zip317 tx selection test to its own module, adds an `unmined_transactions_in_blocks()` method on network * Removes `unmined_transactions_in_blocks()` test utility fn from mempool Storage test module and replaces calls to it with calls to the new test method on Network * Fixes spelling mistake * Adds `includes_tx_with_selected_dependencies` test * fixes zip317 block construction issue * Fixes vectors test * Update zebra-node-services/src/mempool.rs * restores `tip_rejected_exact` type * updates affected tests * Documents the new argument in `Storage::insert()`, updates outdated comment * Update zebrad/src/components/mempool/storage/verified_set.rs * fixes potential issue with calling buffered mempool's poll_ready() method without calling it. * Avoids removing dependent transactions of transactions that have been mined onto the best chain. * Updates `spent_utxos()` method documentation * Avoids sorting getblocktemplate transactions in non-test compilations * documents PendingOutputs struct * Apply suggestions from code review Co-authored-by: Marek <[email protected]> * cargo fmt * Applies suggestions from code review Avoids unnecessarily rejecting dependent transactions of randomly evicted mempool transactions. Updates `TransactionDependencies::remove_all()` to omit provided transaction id from the list of removed transaction ids. * Applies suggestions from code review. * Adds minor comments * Update zebrad/src/components/mempool/storage/verified_set.rs Co-authored-by: Marek <[email protected]> * Remove an outdated comment (#9013) --------- Co-authored-by: Marek <[email protected]>
- Loading branch information