-
Notifications
You must be signed in to change notification settings - Fork 90
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
Internal dependencies organization #1380
Comments
Thanks for bringing this up and supporting your argument with nifty diagrams! Say I have a custom type in |
So by applying this proposal, we would have to provide all |
Yes (that is what we are doing all the time). Or if the type is very generic, then it can be place in |
@wischli @mustermeiszer I was thinking about if we would really need to differentiate between |
IMO, |
I like what you say in your last comment @wischli, I think after this, the structure would be as follows: Quite simple / straightforward I think the main idea is that:
|
No opinion here from my side 😃 |
|
Yeah, actually, I agree with you.- The drawn box now called |
So |
Yes if those types are intended to be used to configure the runtime. Right now, |
So, as an overview, we should divide
|
Description
We don't have well-defined rules about where things should be. Here I propose some changes and rules that I think can improve the repo organization and get rid of dependency problems in the future.
Feel free to discuss!
Link to the diagram sources
Current state
Our repo has the following dependencies, and we have 2 main levels:
Note: These arrows are transitive. It means i.e. that a
runtime-common
could make use ofcfg-traits
, or that thepallet level
has access tocfg-primitives
Ideally, we would want to remove those red upward dependencies that exist now.
Down/right directions in this diagram mean "more generic", so those upper lines involve a lot of knowledge from a part that should not be known about. We only want to remain dependencies to "more generic" and avoid generic things knowing about specific things.
Desired
By removing the red lines, and redefining the purpose of each crate, we can get a down/right diagram:
Purpose of each crate:
From more generic (widely purpose) to less generic (centrifuge-related purpose):
cfg-primitives
: Common utilities without any specific behavior associated. All constant with knowledge about the usage on runtime should be moved tocfg-types
, and we only left the generic ones:Adjustement
type orSECONDS_PER_MINUTE
,DAYS
constants..cfg-traits
: Common interfaces to all runtimes. It implies traits and also could imply types tied to those traits. But it should not usecfg-types
, because they are specific types for configuring in the runtimes.Permission
,InterestAccrual
, orPoolInvest
.cfg-types
: Should know about centrifuge-related types. These are types used in runtimes to configure pallets, but should not be used direclty in the pallets. They make sense for our use cases but not for others who can use our pallets. These types, therefore, should not know about pallets or runtimes. And should not be types used bycfg-traits
.CurrencyId
,FeeKey
,Location
PoolId
,AccountId
,Balance
.MAXIMUM_BLOCK_WEIGHT
,CFG
(?),SLOT_DURATION
,TREASURY_FEE_RATIO
AIR
andCFG
, I think each should be into some runtime-dependent module asruntime/altair/src/types.rs
.runtime-common
: Common utilities to all runtimes. It knows about how runtimes work and has hard dependencies on the pallet used. It's simply a common place where to store code common to all runtimes.The text was updated successfully, but these errors were encountered: