Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send whole transaction pool upon subscription to gossip #2131

Merged
merged 49 commits into from
Sep 19, 2024

Conversation

AurelienFT
Copy link
Contributor

@AurelienFT AurelienFT commented Aug 27, 2024

Linked Issues/PRs

Part of #1049

Description

This PR introduce a new workflow when we successfully subscribed to the TX topic in gossip we try ask for all the tx_ids in the pool's peer and then ask the full transactions that we don't have.
This PR also build the SharedState of P2PService independently to give more flexibility to the initialisation and avoid cyclic dependencies.

Detailed workflow :

  • When a peer has subscribed to our topic send inform the TxPool
  • The TxPool asks the tx ids of the peer
  • The TxPool filter the one it already knows and ask for the full transactions of the others (a multi message send should be done if the number of txs asked is above the limit (currently 10k chosen randomly)).
  • We verify and add them to our txpool

Questions for review

  • What's happens if the peer doesn't answer to a request that we await ?
  • I placed Option in the request/response because there was in the other messages but why it's needed ?

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

@AurelienFT AurelienFT requested a review from rymnc August 28, 2024 14:31
@AurelienFT
Copy link
Contributor Author

AurelienFT commented Aug 28, 2024

@rymnc The PR is still in draft because I still need to make tests but you can start take a look the logic shouldn't change much.

Thankssss <3

@rymnc
Copy link
Member

rymnc commented Aug 28, 2024

@rymnc The PR is still in draft because I still need to make tests but you can start take a look the logic shouldn't change much.

Thankssss <3

will look at it deeply tomorrow, hope that works!

@rymnc
Copy link
Member

rymnc commented Aug 29, 2024

looking good, however, I don't think we can call this "gossip" since its a direct p2p request/response protocol given that we make the request to the peer directly (peer_id) as part of the request.

What's happens if the peer doesn't answer to a request that we await ?

we should have a timeout for waiting for the response, and then try another peer (cc: @xgreenx for confirmation)

I placed Option in the request/response because there was in the other messages but why it's needed ?

for the other data we're sending over the req/res protocol (sealed_block_headers and transactions), there is a chance that the range provided is greater than the block height, and to handle that we send None for all blocks we don't have data for. We don't need Option usage for transaction pool transactions :)

@AurelienFT AurelienFT marked this pull request as ready for review August 29, 2024 08:51
@AurelienFT
Copy link
Contributor Author

@rymnc Thanks for your overview and your comments

About :

I don't think we can call this "gossip" since its a direct p2p request/response protocol

I don't think we ever call the request/response gossip, it's just that it's been trigger on the tx gossip topic being subscribed.

We don't need Option usage for transaction pool transactions :)

Will remove that

@AurelienFT AurelienFT requested review from xgreenx and rymnc August 29, 2024 11:07
Copy link
Member

@rymnc rymnc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general LGTM, added some comments/questions :)

@AurelienFT AurelienFT requested a review from xgreenx September 18, 2024 08:37
xgreenx
xgreenx previously approved these changes Sep 18, 2024
xgreenx
xgreenx previously approved these changes Sep 18, 2024
@AurelienFT AurelienFT merged commit 5963a4e into master Sep 19, 2024
36 checks passed
@AurelienFT AurelienFT deleted the send_tx_new_peer_subscription branch September 19, 2024 07:55
@Voxelot
Copy link
Member

Voxelot commented Sep 19, 2024

Do we reconcile the txs before or after subscribing? If we start processing gossipped txs while we are still syncing the txpool, we may end up dropping them if they depend on earlier txs that havent been synced yet.

@AurelienFT
Copy link
Contributor Author

Do we reconcile the txs before or after subscribing? If we start processing gossipped txs while we are still syncing the txpool, we may end up dropping them if they depend on earlier txs that havent been synced yet.

The trigger to make this reconciliation is the subscription so yes it happens just after suscribing. You are right it could lead to invalid gossiped transactions from the point of view of the receiver.
Do you have an idea of when we should make the trigger ?
Because if we activate the gossip after the reconciliation there the possibility that we have miss a child during a period where the gossip wasn't activate too.

Possible solution that I see is, given the tx pool v2 is that all gossiped transactions are queued until we finished at least one peer reconcialition and then we start to process them.
It's pretty easy to do given the fact that in TxPool v2 the verif and insert is done in parrallel manged by a threadpool and a queue

@xgreenx xgreenx mentioned this pull request Oct 5, 2024
xgreenx added a commit that referenced this pull request Oct 5, 2024
## Version v0.37.0

### Added
- [1609](#1609): Add DA
compression support. Compressed blocks are stored in the offchain
database when blocks are produced, and can be fetched using the GraphQL
API.
- [2290](#2290): Added a new
CLI argument `--graphql-max-directives`. The default value is `10`.
- [2195](#2195): Added
enforcement of the limit on the size of the L2 transactions per block
according to the `block_transaction_size_limit` parameter.
- [2131](#2131): Add flow in
TxPool in order to ask to newly connected peers to share their
transaction pool
- [2182](#2151): Limit number
of transactions that can be fetched via TxSource::next
- [2189](#2151): Select next
DA height to never include more than u16::MAX -1 transactions from L1.
- [2162](#2162): Pool
structure with dependencies, etc.. for the next transaction pool module.
Also adds insertion/verification process in PoolV2 and tests refactoring
- [2265](#2265): Integrate
Block Committer API for DA Block Costs.
- [2280](#2280): Allow comma
separated relayer addresses in cli
- [2299](#2299): Support blobs
in the predicates.
- [2300](#2300): Added new
function to `fuel-core-client` for checking whether a blob exists.

### Changed

#### Breaking
- [2299](#2299): Anyone who
wants to participate in the transaction broadcasting via p2p must
upgrade to support new predicates on the TxPool level.
- [2299](#2299): Upgraded
`fuel-vm` to `0.58.0`. More information in the
[release](https://github.com/FuelLabs/fuel-vm/releases/tag/v0.58.0).
- [2276](#2276): Changed how
complexity for blocks is calculated. The default complexity now is
80_000. All queries that somehow touch the block header now are more
expensive.
- [2290](#2290): Added a new
GraphQL limit on number of `directives`. The default value is `10`.
- [2206](#2206): Use timestamp
of last block when dry running transactions.
- [2153](#2153): Updated
default gas costs for the local testnet configuration to match
`fuel-core 0.35.0`.

## What's Changed
* fix: use core-test.fuellabs.net for dnsaddr resolution by @rymnc in
#2214
* Removed state transition bytecode from the local testnet by @xgreenx
in #2215
* Send whole transaction pool upon subscription to gossip by @AurelienFT
in #2131
* Update default gas costs based on 0.35.0 benchmarks by @xgreenx in
#2153
* feat: Use timestamp of last block when dry running transactions by
@netrome in #2206
* fix(dnsaddr_resolution): use fqdn separator to prevent suffixing by
dns resolvers by @rymnc in
#2222
* TransactionSource: specify maximum number of transactions to be
fetched by @acerone85 in #2182
* Implement worst case scenario for price algorithm v1 by @rafal-ch in
#2219
* chore(gas_price_service): define port for L2 data by @rymnc in
#2224
* Block producer selects da height to never exceed u64::MAX - 1
transactions from L1 by @acerone85 in
#2189
* Weekly `cargo update` by @github-actions in
#2236
* Use fees to calculate DA reward and avoid issues with Gwei/Wei
conversions by @MitchTurner in
#2229
* Protect against passing `i128::MIN` to `abs()` which causes overflow
by @rafal-ch in #2241
* Acquire `da_finalization_period` from the command line by @rafal-ch in
#2240
* Executor: test Tx_count limit with incorrect tx source by @acerone85
in #2242
* Minor updates to docs + a few typos fixed by @rafal-ch in
#2250
* chore(gas_price_service): move algorithm_updater to
fuel-core-gas-price-service by @rymnc in
#2246
* Use single heavy input in the `transaction_throughput.rs` benchmarks
by @xgreenx in #2205
* Enforce the block size limit by @rafal-ch in
#2195
* feat: build ARM and AMD in parallel by @mchristopher in
#2130
* Weekly `cargo update` by @github-actions in
#2268
* chore(gas_price_service): split into v0 and v1 and squash
FuelGasPriceUpdater type into GasPriceService by @rymnc in
#2256
* feat(gas_price_service): update block committer da source with
established contract by @rymnc in
#2265
* Use bytes from `unrecorded_blocks` rather from the block from DA by
@MitchTurner in #2252
* TxPool v2 General architecture by @AurelienFT in
#2162
* Add value delimiter and tests args by @AurelienFT in
#2280
* fix(da_block_costs): remove Arc<Mutex<>> on shared_state and expose
channel by @rymnc in #2278
* fix(combined_database): syncing auxiliary databases on startup with
custom behaviour by @rymnc in
#2272
* fix: Manually encode Authorization header for eventsource_client by
@Br1ght0ne in #2284
* Address `async-graphql` vulnerability by @MitchTurner in
#2290
* Update the WASM compatibility tests for `0.36` release by @rafal-ch in
#2271
* DA compression by @Dentosal in
#1609
* Use different port for every version compatibility test by @rafal-ch
in #2301
* Fix block query complexity by @xgreenx in
#2297
* Support blobs in predicates by @Voxelot in
#2299


**Full Changelog**:
v0.36.0...v0.37.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants