81ea5bab78
* Initial commit * Add sentry gRPC interface * p2psentry directory * Update README.md * Update README.md * Update README.md * Add go package * Correct syntax * add external downloader interface (#2) * Add txpool (#3) * Add private API (#4) * Invert control.proto, add PeerMinBlock, Separare incoming Tx message into a separate stream (#5) Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> * Separate upload messages into its own stream (#6) Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> * Only send changed accounts to listeners (#7) * Txpool interface doc (#9) * More additions * More additions * Fix locking * Intermediate * Fix separation of phases * Intermediate * Fix test * More transformations * New simplified way of downloading headers * Fix hard-coded header sync * Fixed syncing near the tip of the chain * Add architecture diagram source and picture (#10) * More fixes * rename tip to link * Use preverified hashes instead of preverified headers * Fix preverified hashes generation * more parametrisation * Continue parametrisation * Fix grpc data limit, interruption of headers stage * Add ropsten preverified hashes * Typed hashes (#11) * Typed hashes * Fix PeerId * 64-bit tx nonce * Disable penalties * Add goerli settings, bootstrap nodes * Try to fix goerly sync * Remove interfaces * Add proper golang packages, max_block into p2p sentry Status * Prepare for proto overhaul * Squashed 'interfaces/' content from commit ce36053c2 git-subtree-dir: interfaces git-subtree-split: ce36053c24db2f56e48ac752808de60afa1dfb4b * Change EtherReply to address * Adaptations to new types * Switch to new types * Fixes * Fix formatting * Fix lint * Lint fixes, reverse order in types * Fix lint * Fix lint * Fix lint * Fix test * Not supporting eth/66 yet * Fix shutdown * Fix lint * Fix lint * Fix lint * return stopped check Co-authored-by: Artem Vorotnikov <artem@vorotnikov.me> Co-authored-by: b00ris <b00ris@mail.ru> Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> Co-authored-by: lightclient <14004106+lightclient@users.noreply.github.com> Co-authored-by: canepat <16927169+canepat@users.noreply.github.com> |
||
---|---|---|
.. | ||
README.md | ||
txpool_control.proto | ||
txpool.proto |
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