Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Conversation

@tomaka
Copy link
Contributor

@tomaka tomaka commented Aug 13, 2019

As described in #3382, this is the first part that doesn't break anything and that we should merge before #3382.

tomaka added 18 commits August 13, 2019 13:52
In follow-up commits, we want to be able to directly call maintain_transaction_pool, offchain_workers, and start_rpc, without having to implement the Components trait.
This commit is a preliminary step: we extract the code to freestanding functions.
Instead of implementing AbstractService, Future, and Executor on Service, we implement them on NewService instead.

The implementations of AbstractService, Future, and Executor on Service still exist, but they just wrap to the respective implementations for NewService.
Instead of having multiple $build_ parameters passed to the macro, let's group them all into one.

This change is necessary for the follow-up commits, because we are going to call new_impl! only after all the components have already been built.
This makes it possible to be explicit as what the generic parameter of the NewServiceis, without relying on type inference.
Introduces a new builder-like ServiceBuilder struct that creates a NewService.
Similar to the introduction of new_impl!, we extract the actual code into a macro, letting us get rid of the Components and Factory traits
…uilder

Can be used as a replacement for the chain_ops::* methods
Instead of just run, adds run_with_builder to ParseAndPrepareExport/Import/Revert. This lets you run these operations with a ServiceBuilder instead of a ServiceFactory.
This is technically a breaking change, but the transaction-factory crate is only ever used from within substrate-node, which this commit updates as well.
We slightly change the trait bounds in order to make all the methods usable.
@tomaka tomaka mentioned this pull request Aug 13, 2019
@arkpar
Copy link
Member

arkpar commented Aug 13, 2019

Any good reason to turn export_blocks and other chain op functions into a macro?

@tomaka
Copy link
Contributor Author

tomaka commented Aug 13, 2019

Any good reason to turn export_blocks and other chain op functions into a macro?

I did that in order to share the same code between the old and new APIs, and to make solving conflicts while rebasing easier.

It's intended to be temporary, and switched back to regular functions afterwards.

(to be honest I would have gone a different route if I had had the guarantee to not encounter any conflict)

@bkchr
Copy link
Member

bkchr commented Aug 13, 2019

By conflict you mean merge conflict? Or something in polkadot?

@tomaka
Copy link
Contributor Author

tomaka commented Aug 14, 2019

By conflict you mean merge conflict? Or something in polkadot?

Yes, merge conflicts.

@tomaka
Copy link
Contributor Author

tomaka commented Aug 14, 2019

There's a lot of dirt remaining after the refactor (#3382), and where to stop adding commits and when to submit the PR is a bit arbitrary.

For example there are lots of items to move around, we can remove the custom field of the config, we can move passing the config to build so that we don't need to pass it as parameter to the closures, and so on. But I thought that this would be for later.

@bkchr
Copy link
Member

bkchr commented Aug 14, 2019

I still don't understand why we not merge everything at once? If you are afraid of porting the stuff to polkadot, why not start porting directly while we review the new interfaces? And when we merge the other one, you can directly open a pr in polkadot?

@tomaka
Copy link
Contributor Author

tomaka commented Aug 14, 2019

If you are afraid of porting the stuff to polkadot, why not start porting directly while we review the new interfaces?

I actually tried doing that, but Polkadot never seems to be up to date with Substrate master, and I don't really want to fix the breaking changes in the SRML stuff myself.

But to clarify, the idea is not to merge one then wait for the other. The idea is to merge one then immediately the other, so that they are squashed in two different commits. This way, in case of an urgency, we can revert one and not the other.

Alternatively, in case of urgency, we could also cherry-pick the urgent commits on a Substrate branch that doesn't have this refactoring.

@tomaka
Copy link
Contributor Author

tomaka commented Aug 14, 2019

I looked a bit more at Polkadot's code, and I think it should be fine be port.

What I was worried about are the fact that I removed grandpa::BlockImportForService from Substrate, and that there's this PolkadotService trait.
However I understand them more now, and they shouldn't pose any issue.

Feel free to merge only the entire refactor if you prefer.

@bkchr
Copy link
Member

bkchr commented Aug 14, 2019

Ty.

@bkchr bkchr closed this Aug 14, 2019
@tomaka tomaka deleted the service-factory-refactor-1 branch August 14, 2019 15:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants