-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Conversation
- Remove HasPublicAux - Rename Concrete -> Runtime
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.
A good read, I learned plenty. Some typos and style question marks.
@@ -65,8 +65,8 @@ pub use runtime_primitives::BuildStorage; | |||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted. | |||
#[derive(Clone, Copy, PartialEq, Eq)] | |||
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] | |||
/// Concrete runtime type used to parameterize the various modules. | |||
pub struct Concrete; | |||
/// Runtime runtime type used to parameterize the various modules. |
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 /// Runtime is the concrete parametrization of the various runtime modules.
?
bikeshed: I would suggest ConcreteRuntime
as the name – this type is sort of the apex type on top of a pile of code containing "runtime"; might be a worth giving it a clearly distinct name.
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 like short, bold and unequivocal naming. The struct that is created is best described as the Runtime as all runtime logic hangs from it. ConcreteRuntime
suggests there's an AbstractRuntime
trait somewhere, which there isn't.
impl<T: Trait> Executable for Module<T> { | ||
fn execute() { | ||
impl<T: Trait> OnFinalise<T::BlockNumber> for Module<T> { | ||
fn on_finalise(_n: T::BlockNumber) { |
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.
Update the docs above to //! Call ['Module::on_finalise'] at the end of the 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.
feel free to make a PR, but that's out of scope for this one.
@@ -0,0 +1,385 @@ | |||
// Copyright 2017 Parity Technologies (UK) Ltd. |
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.
date
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.
out of scope - this is blanket legal boilerplate and duplicated across the codebase and as such should be handled in its own PR for a blanket upgrade.
substrate/runtime/example/src/lib.rs
Outdated
use runtime_support::{StorageValue, dispatch::Result}; | ||
|
||
/// Our module's configuration trait. All our types and consts go in here. If the | ||
/// module is dependent on specfiic other modules, then their configuration traits |
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.
typo: specfiic
substrate/runtime/example/src/lib.rs
Outdated
} | ||
|
||
// The module declaration. This states the entry points that we handle. The | ||
// macro looks after the marshalling of arguments and dispatch. |
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.
s/looks after/takes care of/
@@ -0,0 +1,555 @@ | |||
// Copyright 2017 Parity Technologies (UK) Ltd. |
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.
s/2017/2018/
use balances::OnMinted; | ||
|
||
/// Our module's configuration trait. All our types and consts go in here. If the | ||
/// module is dependent on specfiic other modules, then their configuration traits |
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.
s/specfiic/specific/
|
||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] | ||
pub enum Call where aux: T::PublicAux { | ||
// Put forward a suggestion for spending. A bond of |
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 looks weird. Rephrase?
// proposal gets these back. A rejected proposal doesn't. | ||
ProposalBond get(proposal_bond): required Permill; | ||
|
||
// Proportion of funds that should be bonded in order to place a proposal. An accepted |
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 this really a proportion? If so, shouldn't it be a Permill
?
// Proposals that have been made. | ||
Proposals get(proposals): map [ ProposalIndex => Proposal<T::AccountId, T::Balance> ]; | ||
|
||
// Proposals that have been made. |
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.
s/have been made/have been approved/?
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] | ||
pub enum PrivCall { | ||
// A priviledged call; in this case it resets our dummy value to something new. | ||
fn set_pot(new_pot: T::Balance) -> Result = 0; |
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.
Can we update the comment here?
fn configure(proposal_bond: Permill, proposal_bond_minimum: T::Balance, spend_period: T::BlockNumber, burn: Permill) -> Result = 1; | ||
|
||
// A priviledged call; in this case it resets our dummy value to something new. | ||
fn reject_proposal(proposal_id: ProposalIndex) -> Result = 2; |
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.
Can we update the comment here?
fn reject_proposal(proposal_id: ProposalIndex) -> Result = 2; | ||
|
||
// A priviledged call; in this case it resets our dummy value to something new. | ||
fn approve_proposal(proposal_id: ProposalIndex) -> Result = 3; |
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.
Can we update the comment here?
/// for your module when the block is ending. | ||
pub trait OnFinalise<BlockNumber> { | ||
/// The block is being finalised. Implement to have something happen. | ||
fn on_finalise(_n: BlockNumber) {} |
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 very cool for this trait be renamed to OnFinalise
(I even had this in my latent todo for the next "random fixes" series PR)!
However, I'm not sure if we actually want to introduce the block number here. Why is it 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.
it's available in the caller and it's useful in many of the callees.
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.
True, but i worry a bit that making a slight improvement for two modules we might get a sligh loss in tests: e.g. if we want to test on_finalise
in some module and that module doesn't care about block number then we will still have to supply it.
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.
can always have a helper that calls Module::on_finalise(System::block_number())
@@ -0,0 +1,224 @@ | |||
[[package]] |
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.
Hm, I think this is not supposed to be checked in, is it?
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 think so - it's an entirely separate project
spend_period: T::BlockNumber, | ||
burn: Permill | ||
) -> Result { | ||
<ProposalBond<T>>::put(proposal_bond); |
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 subtle: we must make sure that this isn't called if we already have any proposals, right? Does this worth a check and/or a comment?
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.
Good catch. Needs further work but will just make it safe for now.
@pepyakin Grumbles addressed |
* master: (22 commits) Introduce treasury and document (#646) Off-the-table staking preference (#656) Implement function `json_metadata` in `decl_module!` (#654) Fix warnings in networking (#652) Add a reputation system (#645) Check for pruned block state (#648) Contract runtime polishing (#601) WIP on chain heap (#639) Events to track extrinsic success (#640) Install llvm-tools-preview component (#643) fix wasm executor compile error (#631) random fixes (#638) Empty becomes (), reflecting convention (#637) Allow to build_upon skipped entries, but don't walk back (#635) Separate out staking module into balances and payment (#629) Update .gitlab-ci.yml (#633) Do not attempt to rustup if in CI. This is taken care of by the base (#621) Avoid need for ident strings in storage (#624) rename to panic_handler as panic_implementation is deprecated in nightly (#626) 5 random fixes (#2) (#623) ...
…and-rlpcodec * master: Upgrade to libp2p master (#660) Include function comments into modules `json_metadata` (#657) Replace old headers with CHT in light clients (#512) Fix build Introduce treasury and document (#646) Off-the-table staking preference (#656) Implement function `json_metadata` in `decl_module!` (#654) Fix warnings in networking (#652) Add a reputation system (#645) Check for pruned block state (#648)
Executable
toOnFinalise
to reflect meaning.OnMinted
trait.