erigon-pulse/interfaces/txpool
Alex Sharov 14c15cba43
Check version of remote services (#1989)
* save

* save

* Squashed 'interfaces/' content from commit 08c32a09e

git-subtree-dir: interfaces
git-subtree-split: 08c32a09e40b1e6fcb5922e723191c9477545356

* Revert "Squashed 'interfaces/' content from commit 08c32a09e"

This reverts commit 8393d9fd

* save

* seve

* Squashed 'interfaces/' content from commit dd6a42724

git-subtree-dir: interfaces
git-subtree-split: dd6a42724401f34c21662ca1aa1718effb92320d

* ensure versions compatibility of all remote services

* Revert "Squashed 'interfaces/' content from commit dd6a42724"

This reverts commit 2a764bf9

* Squashed 'interfaces/' content from commit dd6a42724

git-subtree-dir: interfaces
git-subtree-split: dd6a42724401f34c21662ca1aa1718effb92320d

* Revert "Squashed 'interfaces/' content from commit dd6a42724"

This reverts commit 52621846

* Squashed 'interfaces/' content from commit dd6a42724

git-subtree-dir: interfaces
git-subtree-split: dd6a42724401f34c21662ca1aa1718effb92320d

* a

* a

* a

* a

* a

Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
2021-05-22 11:00:13 +01:00
..
mining.proto Remove mining methods from ethbackend.proto (#1954) 2021-05-18 12:10:47 +07:00
README.md Remove interfaces from root (#1951) 2021-05-17 20:28:50 +07:00
txpool_control.proto Remove interfaces from root (#1951) 2021-05-17 20:28:50 +07:00
txpool.proto Check version of remote services (#1989) 2021-05-22 11:00:13 +01:00

txpool interface

Transaction pool is supposed to import and track pending transactions. As such, it should conduct at least two checks:

  • Transactions must have correct nonce
  • Gas fees must be covered

State streaming

For transaction checks to function, the pool must also track balance and nonce for sending accounts.

On import of transactions from unknown sender, transaction pool can request balance and nonce at a particular block.

To track existing accounts, transaction pool connects to Ethereum client and receives a stream of BlockDiffs. Each of these represents one block, applied or reverted, and contains all the necessary information for transaction pool to track its accounts.

For applied blocks:

  • Block's hash
  • Parent block's hash
  • New balances and nonces for all accounts changed in this block

For reverted blocks:

  • Reverted block's hash
  • New (reverted's parent) hash
  • New parent (reverted's grandfather) hash
  • List of reverted transactions
  • Balances and nonces for all accounts changed in reverted block, at new (reverted's parent) state.

BlockDiffs must be streamed in the chain's order without any gaps. If BlockDiff's parent does not match current block hash, transaction pool must make sure that it is not left in inconsistent state. One option is to reset the transaction pool, reimport transactions and rerequest state for those senders.

Reorg handling

Simple example:

A - D -- E -- F
 \
  - B -- C

Transaction pool is at block C, canonical chain reorganizes to F.

We backtrack to common ancestor and apply new chain, block by block.

Client must send the following BlockDiffs to txpool, in order:

  • revert C to B
  • revert B to A
  • apply D on A
  • apply E on D
  • apply F on E