Conversation
|
@mattsse the org has to be on paid plan to be able to make draft PRs in private repos |
e2ec70c to
9e1e377
Compare
c8afd48 to
8ba1501
Compare
|
@rakita opening this up for review, however there are still some things missing and things I want to change, especially when it comes to how transactions are stored. this started out as a modification of the pool we wrote for anvil which works like a graph, where a transaction can depend on a previous transaction, and unlock the following transaction. For this, there are a few more things to consider like dynamic fee, balance, which are not handled yet. erigon's txpool is essentially a This currently references the next transaction by storing its (sender, nonce) id. So basically erigon can cheaply update account changes because there's a trying to come up with a solution for this EDIT: just found out you can do something like this with rust's Also, this still needs a bunch of tests. |
rakita
left a comment
There was a problem hiding this comment.
It was hard for me to wrap my head around this, there seems like there are things in need of cleanup or simplification. There are a lot of pools and new transaction types. SenderId is weird one, why not just use the account address? Parity really knows how to overcomplicate things :).
Maybe the best path is to merge this as it is, and continue working on it there, wdyt @mattsse?
|
|
||
| /// The interface used to interact with the blockchain and access storage. | ||
| #[async_trait::async_trait] | ||
| pub trait PoolClient: Send + Sync + TransactionValidator { |
There was a problem hiding this comment.
Why is TransactionValidator needed here?
| fn ensure_block_number(&self, block_id: &BlockID) -> PoolResult<U64> { | ||
| self.convert_block_id(block_id) | ||
| .and_then(|number| number.ok_or(PoolError::BlockNumberNotFound(*block_id))) | ||
| } |
There was a problem hiding this comment.
note: we probably need account_info(address) to get the account nonce and balance.
| type Error: Into<PoolError>; | ||
|
|
||
| /// Returns the block number for the given block identifier. | ||
| fn convert_block_id(&self, block_id: &BlockID) -> PoolResult<Option<U64>>; |
There was a problem hiding this comment.
I am not sure if i understand why would we need get block number and mapping of hash->height. TxPool should only care about base_fee and transactions that are removed/added, and that is broadcasted to txpool on block inclusion.
| /// | ||
| /// This assigns a _unique_ `SenderId` for a new `Address`. | ||
| #[derive(Debug)] | ||
| pub struct SenderIdentifiers { |
There was a problem hiding this comment.
I searched code and this seems not used
| /// This is the identifier of an internal `address` mapping that is valid in the context of this | ||
| /// program. | ||
| #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] | ||
| pub struct SenderId(u64); |
There was a problem hiding this comment.
It seems like there is some internal mapping that uses SenderId, and it is used inside TransactionId as a field.
GraphPool has it as sender_info but it seems like it is not used, maybe it is just a leftover, that still needs impl to be used.
| //! In essence the transaction pool is made of two separate sub-pools: | ||
| //! | ||
| //! _Pending Pool_: Contains all transactions that are valid on the current state and satisfy | ||
| //! (3. a)(1): _No_ nonce gaps _Queued Pool_: Contains all transactions that are currently |
There was a problem hiding this comment.
| //! (3. a)(1): _No_ nonce gaps _Queued Pool_: Contains all transactions that are currently | |
| //! (3. a)(1): _No_ nonce gaps | |
| //! _Queued Pool_: Contains all transactions that are currently |
| /// | ||
| /// This pool maintains a dependency graph of transactions and provides the currently ready | ||
| /// transactions. | ||
| pub struct GraphPool<T: TransactionOrdering> { |
There was a problem hiding this comment.
This is the main pool that is inside PoolInner that contains all data/Transaction
|
|
||
| /// A reference to a transaction in the _pending_ pool | ||
| #[derive(Debug)] | ||
| pub(crate) struct PoolTransactionRef<T: TransactionOrdering> { |
There was a problem hiding this comment.
There are a lot of transaction types, maybe we can consolidate them into one that is easier to follow. It is just an idea, unsure if it is good.
| /// | ||
| /// This will be an empty list if there are no nonce gaps across multiple transactions of the | ||
| /// same sender in the pool. If there are gaps, this will include the missing transactions. | ||
| pub(crate) missing_dependencies: HashSet<TransactionId>, |
There was a problem hiding this comment.
TransactionId contains of SenderId (that is internal u64) and nonce, we probably need account address to verify dependencies
| /// Returns the EIP-1559 Priority fee the caller is paying to the block author. | ||
| /// | ||
| /// This will return `None` for non-EIP1559 transactions | ||
| fn max_priority_fee_per_gas(&self) -> Option<&U256>; |
There was a problem hiding this comment.
There is something called effective gas price that for new transactions is base_fee+max_priority_fee_per_gas and for legact transaction this is gas_price, this was used to sort transactions inside pool.
Definitely. Need to refactor some internals to handle things like base fee and balance. I'm currently in the process of integrating some designs that erigon took. which will eventually replace the
idea was that this would reduce an Address to a simple u64, but since of the maps used are
sgtm! I'll merge this as is, and follow up with additional PRs. |
Resolution checkpoint Resolution checkpoint paradigmxyz#2 Resolution checkpoint paradigmxyz#3 x Resolution checkpoint paradigmxyz#4 Resolution checkpoint paradigmxyz#5 Resolution checkpoint paradigmxyz#6 Resolution checkpoint paradigmxyz#7 Resolution checkpoint paradigmxyz#8 Resolve checkpoint paradigmxyz#9 (transaction primitive) Resolve checkpoint paradigmxyz#10 (rpc api transactions) Resolve checkpoint paradigmxyz#11 (building w/o feature flag) Start review Compiling with and without `optimism` feature flag Remove `DepositTx` from txpool mock tests, they never go into the txpool fmt code lint fix signature tests Co-authored-by: nicolas <48695862+merklefruit@users.noreply.github.com> Use free CI runners (revert before upstream) Co-authored-by: refcell <abigger87@gmail.com> Signature test fixes Co-authored-by refcell <abigger87@gmail.com> Fix Receipt proptest Co-authored-by BB <brian.t.bland@gmail.com> lint Fix variable-length compact for txtype/transaction Co-authored-by: Brian Bland <brian.t.bland@gmail.com> Fix basefee tests Remove unnecessary rpc deps Co-authored-by: Brian Bland <brian.t.bland@gmail.com> Co-authored-by: refcell <abigger87@gmail.com> Co-authored-by: nicolas <48695862+merklefruit@users.noreply.github.com> Co-authored-by: Roberto <bayardo@alum.mit.edu>
Resolution checkpoint Resolution checkpoint paradigmxyz#2 Resolution checkpoint paradigmxyz#3 x Resolution checkpoint paradigmxyz#4 Resolution checkpoint paradigmxyz#5 Resolution checkpoint paradigmxyz#6 Resolution checkpoint paradigmxyz#7 Resolution checkpoint paradigmxyz#8 Resolve checkpoint paradigmxyz#9 (transaction primitive) Resolve checkpoint paradigmxyz#10 (rpc api transactions) Resolve checkpoint paradigmxyz#11 (building w/o feature flag) Start review Compiling with and without `optimism` feature flag Remove `DepositTx` from txpool mock tests, they never go into the txpool fmt code lint fix signature tests Co-authored-by: nicolas <48695862+merklefruit@users.noreply.github.com> Use free CI runners (revert before upstream) Co-authored-by: refcell <abigger87@gmail.com> Signature test fixes Co-authored-by refcell <abigger87@gmail.com> Fix Receipt proptest Co-authored-by BB <brian.t.bland@gmail.com> lint Fix variable-length compact for txtype/transaction Co-authored-by: Brian Bland <brian.t.bland@gmail.com> Fix basefee tests Remove unnecessary rpc deps Co-authored-by: Brian Bland <brian.t.bland@gmail.com> Co-authored-by: refcell <abigger87@gmail.com> Co-authored-by: nicolas <48695862+merklefruit@users.noreply.github.com> Co-authored-by: Roberto <bayardo@alum.mit.edu>
* add feature 'enable_tps_gas_record' * format and rebase code --------- Co-authored-by: anonymousGiga <cryptonymGong@gmail.com>
Merge v0.2.0 beta.7
…mxyz#7) Concurrent verification of transaction finality state
…mxyz#7) Concurrent verification of transaction finality state
* upstreamed to alloy * upstreamed to alloy
…length - Issue #5: Add flush_current_changeset_offset() before reading sidecar in truncate_changesets() to ensure in-memory offset is written - Issue #7: Use ChangesetOffsetReader::with_len() instead of new() to respect committed length from header, ignoring uncommitted records - Add regression tests for both issues - Update changeset-healing-review.md to reflect 17 tests - Remove unused variables in tests
…aradigmxyz#7 slow re-download - Issue paradigmxyz#6 downgraded P0→P3: bad FCU feeder was the cause (all 3 hashes same) - Fixed reth-fcu-feeder.py to use genesis as finalizedBlockHash - Pipeline completes ALL 13 stages with single FCU (1M+ blocks!) - Added Issue paradigmxyz#7: reverse headers downloader extremely slow after restart - Updated status and strategy
WIP...
interesting, looks like you can't create draft PRs in private repos.Update: