-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Txpool v2 features for futures connections with other modules #2216
Conversation
…r' into txpool-v2-block-producer-importer
@@ -0,0 +1,272 @@ | |||
//! Test module for update_sender |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File identical to the old one that we had=) skipping
@@ -0,0 +1,129 @@ | |||
use std::{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file is identical to V1, skipping=)
@@ -0,0 +1,135 @@ | |||
use fuel_core_types::{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file is identical to V1, skipping=)
@@ -0,0 +1,392 @@ | |||
use std::{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Content is identical to V1, the difference that 2 types were merged int one file.
@@ -0,0 +1,260 @@ | |||
use std::{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical to the V1, skipping.
@@ -0,0 +1,87 @@ | |||
//! Test module for validating TxUpdateStream state transitions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical to V1, skipping.
…bs/fuel-core into txpool-v2-block-producer-importer
…ge different tasks.
pool: Shared<TxPool>, | ||
current_height: Arc<RwLock<BlockHeight>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any reason why you use the Shared
type alias for pool and not for current_height?
Overall I think Arc<RwLock<_>>
is more clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some opinions on the Shared
type, continuing my review...
// For tests | ||
use crate as fuel_core_services; | ||
#[allow(unused_imports)] | ||
use fuel_core_services as _; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this aliasing dance? We import the crate under a type alias and then alias it to _
. This feels weird, but I guess we must achieve something by doing this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heavy_async_processor: Arc<HeavyAsyncProcessor>, | ||
utxo_validation: bool, | ||
} | ||
pub type Shared<T> = Arc<RwLock<T>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is a pretty nice type-alias, I don't see any point in making it public. Any other modules that would benefit from the type alias can redefine it, which would be more straight-forward to read and just as concise as importing it without the extra indirection.
pub type Shared<T> = Arc<RwLock<T>>; | |
type Shared<T> = Arc<RwLock<T>>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optionally if this is used in a lot of places we should move it out to another module, since the alias has nothing to do with this particular service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to pub(crate) because it's used in the tests
}, | ||
service::{ | ||
memory::MemoryPool, | ||
Shared, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example here I would find it more readable if we instead of importing Shared
redefine the alias in this module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will let @xgreenx give his advice on this as it's a type he added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up to @AurelienFT )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted on my note will think about it in the next days to not block the merge.
…bs/fuel-core into txpool-v2-block-producer-importer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another suggestion (not blocking merge)
should_continue = true; | ||
} else { | ||
should_continue = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know the pattern was established before this PR, but it would make more sense to me to just return here instead of declaring and assigning the variable to later return it.
should_continue = true; | |
} else { | |
should_continue = false; | |
return Ok(true); | |
} else { | |
return Ok(false); |
(and the same for all other branches)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I see you already merged! 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's Ok you can leave comment and I will address in patch in the future. I note this and let this open in the meantime
## Version v0.38.0 ### Added - [2309](#2309): Limit number of concurrent queries to the graphql service. - [2216](#2216): Add more function to the state and task of TxPoolV2 to handle the future interactions with others modules (PoA, BlockProducer, BlockImporter and P2P). - [2263](#2263): Use the Txpool v2 in the whole codebase. ### Removed - [2306](#2306): Removed hack for genesis asset contract from the code. ## What's Changed * Updates to price algorithm by @rafal-ch in #2292 * Removed hack from the code by @xgreenx in #2306 * fix(p2p): useless dials to reserved nodes which dont have a location multiaddress by @rymnc in #2308 * Txpool v2 features for futures connections with other modules by @AurelienFT in #2216 * Limit number of concurrent queries to the graphql service by @netrome in #2309 * Linking TxPoolV2 in place of V1 by @AurelienFT in #2263 **Full Changelog**: v0.37.1...v0.38.0 --------- Co-authored-by: AurelienFT <[email protected]>
REVIEWER NOTE: Review #2193 first for context
Linked Issues/PRs
Closes #2187
Description
(2k of additions is the tests from TxPool v1 which has been instantiated again)
This PR adds all the logic for the service and shared state of the TxPool to be able to be used by all the others modules and to make all the auxiliary mechanisms working.
The PR changes the way the
SharedState
interact with the pool and the service. Now theSharedState
only sends commands to the service that will answer him whenever he is time to do depending on the priority of the request (managed through a tokio select biaised). This makes all methods to return async evenfind
which I'm not a big fan of but didn't found any better solution.EDIT: I have made some tests especially tries to run
execute_suite
tests and it seems that blocking can cause "double blocking forever" and so I'm up for an alternativeHere is a list of all interactions made by the different modules and their new name/behavior/reason :
Block producer
PoA
Block Importer
P2P
GraphQL API
Others changes
Checklist
Before requesting review