refactor: block_pool will forward txs to block discovery#1037
Conversation
| } | ||
|
|
||
| // Check IDs match in order and signatures are valid | ||
| for (tx, expected_id) in txs.iter().zip(expected_ids.iter()) { |
There was a problem hiding this comment.
Not sure if it's going to be beneficial, but we probably can to a par_iter here, since we can have a lot of transactions, and this is a latency-critical path, since that's were the block gets gossiped. We should probably discuss it on a call, since it may very well be a non-issue
There was a problem hiding this comment.
ok this actually highlighed a few things: we have a consensus param for defining a max count of data and commitment txs per block that needs to be enforced - I added new checks for this, which was previously missing.
I did not switch to par iter, given that our mainnet and testnet use max_data_txs_per_block: 100 and same for max commitment txs.
|
I decided to merge the changes from #1040 into this branch as it was not actually that big, and keeping both branches in sync became bothersome. |
| let block_hash = block.block_hash; | ||
|
|
||
| // Take any cached transactions for this block | ||
| let cached_txs = self.block_pool.take_cached_txs_for_block(&block_hash).await; |
There was a problem hiding this comment.
I think this list is actually always going to be empty - transactions are added to the cache in the block pool after the process_block has been called, i.e. they have to fetched first to get into the cache. I don't think anything actually needs to be changed here probably, but something just doesn't feel right when I look at it
Describe the changes
Transactions are now passed alongside blocks to Block Discovery to block validatoin pipeline instead of being fetched during block discovery and then re-fetched in block val.
Block DiscoveryBlockTransactions(contains all txs for a block)get commitment/data txshelpers that are used across the codebase now use mempool read guard instead of mpsc channels.this way we don't need to keep re-fetching them from the mempool
Block producerBlockTransactionsalongside block header when producing blocks, useful for testsBlock poolprocess_block()now takesBlockTransactionsparameterreprocess_block()becuase it was no longer used - chian_sync now uses the sameprocess_blockGossip data handlerBlockTransactoinsstructChecklist