-
Notifications
You must be signed in to change notification settings - Fork 710
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
Split polkadot parachains service file into multiple modules #4369
Conversation
use parachains_common::{AccountId, Balance, Block, Nonce}; | ||
use crate::service::common_types::{AccountId, Balance, Block, Nonce}; |
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.
Hmm, this should maybe be at the crate root now that I look at it.
/// Module with common types. | ||
/// | ||
/// The idea is to help downstream implementors who don't rely on `parachains_common` for types. | ||
/// Proxying the imports paths via this module makes it possible to only adjust imports here, as | ||
/// opposed to replacing `parachains_common` imports in every file. | ||
pub mod common_types { | ||
pub use parachains_common::{AuraId, AccountId, Balance, Block, Hash, Nonce, Header}; | ||
} | ||
|
||
use common_types::Block; |
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.
This is one of the simple but efficient core changes to help parachain teams.
I really this PR! this is very similar to the refactors that I also see necessary in #3597 That being said, I see some differences. We should break down a fully featured We should make sure these components are reused in Finally, we can then use these reusable components to build a nice configurable omni-node :) @serban300 also wants to work on this. @clangenb what is your intentions? would you like to congtinue contributing? |
I am happy to have someone else building upon my work. However, I don't understand the following:
Isn't this exactly what I have been doing? So maybe with some detailed review this PR is mergeable? I absolutely agree that we should actually re-use these components in the template, it is the only way that the parachain-template will not be out of sync anymore. If the work will only consist of incorporating a PR review and using these components in the template, I am happy to continue. If the expectations are higher, I will gladly pass the torch. |
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 agree with @kianenigma , this is a nice step.
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance> | ||
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>, | ||
{ | ||
let deps = crate::rpc::FullDeps { client, pool, deny_unsafe }; |
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.
IMO we could further simplify this. The FullDeps
struct only has three members and this method here does nothing except create the struct and forward it to the rpc
module.
My suggestion is to remove FullDeps
alltogether and just pass the arguments to the rpc
module methods. Then delete this file.
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.
Yes, I agree. I just thought that this PR should maybe consist of file-splitting only, so that we have a better understandable diff when we want to change the code afterward. But I agree that this would be kind of a minor change.
/// The idea is to help downstream implementors who don't rely on `parachains_common` for types. | ||
/// Proxying the imports paths via this module makes it possible to only adjust imports here, as | ||
/// opposed to replacing `parachains_common` imports in every file. | ||
pub mod common_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.
I don't think this makes sense. polkadot-parachain
crate is just code that is necessary to build the polkadot-parachain
binary. It has no external facing API, so there are no downstream implementors using this. We should continue using parachains_common
here.
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.
Maybe I badly formulated here. The reasoning here was that if a parachain team updates the polkadot version, and they want to integrate the changes by comparing the source files, they need to change the files in more places instead of just here.
Moonbeam for example would have to change the parachains_common::AccountId
import in about four places now if I remember correctly, but I don't really like this re-export thing either, but I think it is better than the status quo.
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/2024-05-21-technical-fellowship-opendev-call/8264/1 |
Awesome and thanks for the contribution so far ! I would like to also take a look on the PR probably next week and let's discuss the way forward after that. |
The main reason I said that, and the only disagreement I have with this PR is that these reusable-components should live outside of |
ohhhh, got it! This makes absolute sense. I would probably go for an |
I looked on the PR. Thank you again for the contribution ! For more context, our intention is to make the entire node code more reusable and the end goal is indeed to remove friction for the parachain teams trying to stay up-to-date with the polkadot-sdk. There are some details here: #5 . Probably one of the steps would be to split the
The entire project is quite big and ambiguous, and there are some unknowns at this point. The idea of splitting the
Please let's sync again at a later time about this as well since we'll probably touch the |
@clangenb given the outcome above, please provide your DOT address in the PR description and I will submit an onchain DOT tip for your contributions. I do agree that this particular refactor might be best done by a full time contributor. Nonetheless, the exploration you have done here is super valuable. |
Thanks a lot, it is highly appreciated. However, I am a fairly new Rank 1 member of the fellowship and just became active. Hence, I would have assumed this to be part of the fellowship. Regardless, as a Rank 1 salary is not really that high, I will gladly accept the tip, I just don't know if this considered to be ok. Just in case, I will leave my address here: :) My polkadot address would be: 16YCL3UVpVWQLGW3p3Zx4k5WAEp9W1DwdDnxAbyAaPxVxnp3 |
I absolutely align with what you have intended here. My idea was to have the PR as a first step to that refactoring. And merging this PR would immediately simplify the maintenance process for parachain teams. However, I also agree that we don't want to have too many refactoring PRs as every refactoring is an extra overhead for the parachain maintainers. I guess the decision of merging this PR more or less as-is should mainly depend on the timeline you have in mind for the overall project. I am simply stating my thoughts here, if you think you want to build take it from here without merging the PR I am completely fine with it. 👍 |
Yes, I also thought of that and I have the same concern about changing this too many times. And because of this to me it seems safer to postpone the split a bit.
Thanks ! I'm not sure how the final split will look like, but I will use the split from this PR as a template while moving forward with the refactoring. |
/tip medium |
@kianenigma A referendum for a medium (80 DOT) tip was successfully submitted for @clangenb (16YCL3UVpVWQLGW3p3Zx4k5WAEp9W1DwdDnxAbyAaPxVxnp3 on polkadot). |
The referendum has appeared on Polkassembly. |
I have been maintaining multiple parachains for the past years, and in every team, we try to stay close to upstream for the collator implementation.
Hence, staying up-to-date with upstream when updating polkadot versions was usually done by comparing the individual files. Comparing the service file to upstream was always a pain because it contains a lot of unnecessary code for parachain teams, i.e. implementations for irrelevant nodes like glutton, contracts_rococo etc. However, at the same time there are sometimes minor adjustments necessary for the parachain teams, e.g. RPC extensions and custom types. Having more than 1000 lines of code doesn't make it easier. I know that there is the parachains template, but it is outdated too often, and I don't have enough trust in it to be honest.
This PR aims to remove friction for parachain teams trying to stay up-to-date with the polkadot-sdk by:
parachain_commons
types such that down_stream implementors don't have to replace theparachain_commons
import in every file. They can just update the re-export at a single place.I thought it will take me almost as long to formulate an issue with my suggestions as already implementing it, which is why I made this draft here now. So I am happy to receive feedback and re-adjust things. Spoileralert: I am thinking about a similar change for the commands.rs
NOTE: It is hard to spot the diff as the code has been put into new files. There was absolutely no change in the functions except for some public modifiers. The service module API stayed the same except for the type exports, which reside now in the new
common_types
module.Polkadot address: 16YCL3UVpVWQLGW3p3Zx4k5WAEp9W1DwdDnxAbyAaPxVxnp3