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

Relayer integration. ServiceBuilder. Context #450

Merged
merged 8 commits into from
Jul 5, 2022

Conversation

rakita
Copy link
Contributor

@rakita rakita commented Jun 29, 2022

Integrate fuel-relayer as fuel-core module and connect it to other module channels. Introduce relayer::Sender

Introduce ServiceBuilder in relayer so that we can build service and service can be called with start() without any inputs.
Introduce notion of Context inside relayer so that we know what to share to fuel_relayer::run and what to expect to be returned back and kept in relayer server.

@rakita rakita marked this pull request as ready for review June 30, 2022 15:19
@rakita rakita added enhancement New feature or request fuel-relayer labels Jun 30, 2022
@rakita rakita self-assigned this Jun 30, 2022
@@ -1,6 +1,7 @@
use crate::config::Config;
use crate::database::Database;
use anyhow::Result;
use fuel_core_interfaces::relayer::RelayerDb;
Copy link
Member

@Voxelot Voxelot Jul 1, 2022

Choose a reason for hiding this comment

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

[nit] Unrelated to this PR, but what do you think about moving the RelayerDb trait to the relayer crate? Since fuel-core already depends on the relayer, it would largely just be changing the import paths. My thinking is that we don't expect other modules outside of the relayer to access the RelayerDb directly, they should only use the Sender interface. So we probably shouldn't share guarded / lower level implementation requirements of modules with each other via fuel-core-interfaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The best way would be to create fuel-storage and extract database related stuff from fuel-core. In this case leaving RelayerDb in fuel-core-interface makes sense. I feel like those traits for db are going to be refactored in future to aggregate them and make better intention/clarification for usage, but for now, they seem good enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i meant fuel-core-storage or fuel-database as we already have fuel-storage

.db(Box::new(database.clone()) as Box<dyn RelayerDb>)
.import_block_event(block_importer.subscribe())
.private_key(
hex::decode("c6bd905dcac2a0b1c43f574ab6933df14d7ceee0194902bce523ed054e8e798b")
Copy link
Member

@Voxelot Voxelot Jul 1, 2022

Choose a reason for hiding this comment

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

Shouldn't this be part of the relayer config / not hardcoded?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed removing this. I have one last thing to do with the integration of fuel-relayer and that would be to include config in cli. This will be resolved there: #447

fuel-relayer/src/service.rs Outdated Show resolved Hide resolved
fuel-relayer/src/service.rs Outdated Show resolved Hide resolved
Voxelot
Voxelot previously approved these changes Jul 1, 2022
Copy link
Member

@Voxelot Voxelot left a comment

Choose a reason for hiding this comment

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

Very clean and nice PR! The use of context as a way to guard singleton resources in a threadsafe way seems like a decent approach. Although I wonder if the same simplicity could be accomplished by merging the context and relayer together?

Thanks for all the database tech debt cleanup as well.

adlerjohn
adlerjohn previously approved these changes Jul 2, 2022
Copy link
Contributor

@adlerjohn adlerjohn left a comment

Choose a reason for hiding this comment

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

utACK

Co-authored-by: Brandon Kite <brandonkite92@gmail.com>
@rakita rakita dismissed stale reviews from adlerjohn and Voxelot via f87f8cc July 3, 2022 10:35
@rakita
Copy link
Contributor Author

rakita commented Jul 3, 2022

Very clean and nice PR! The use of context as a way to guard singleton resources in a threadsafe way seems like a decent approach. Although I wonder if the same simplicity could be accomplished by merging the context and relayer together?

It is a good improvement, context can contain externals to connect to other modules, and there is a clear separation of external dependencies and it allows us to have start without needing inputs.

I didn't think a lot about this, for now, it is still just an idea for the future, but having a separate context allows us to have a clearer idea about what external connections we can switch. As in inserting a sniffing channel that would log interaction/calls between for example fuel-bft and fuel-relayer or fuel-producer and fuel-txpool it is an interesting idea to think about but I wouldn't want to invest time atm until we better know about requirements and restrictions in our system.

@rakita rakita enabled auto-merge (squash) July 3, 2022 11:20
@rakita rakita requested review from adlerjohn and Voxelot and removed request for Voxelot July 3, 2022 11:20
@rakita rakita linked an issue Jul 3, 2022 that may be closed by this pull request
@rakita rakita merged commit 19c48c9 into master Jul 5, 2022
@rakita rakita deleted the rakita/relayer_integration branch July 5, 2022 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fuel-relayer
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Integrate fuel-relayer in fuel-core
3 participants