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

Introduce treasury and document #646

Merged
merged 17 commits into from
Sep 4, 2018
Merged

Introduce treasury and document #646

merged 17 commits into from
Sep 4, 2018

Conversation

gavofyork
Copy link
Member

@gavofyork gavofyork commented Sep 2, 2018

  • Rename Executable to OnFinalise to reflect meaning.
  • Remove unused storage item.
  • Introduce OnMinted trait.
  • Introduce new skeleton treasury module.

@gavofyork gavofyork added the A3-in_progress Pull request is in progress. No review needed at this stage. label Sep 2, 2018
dvdplm
dvdplm previously requested changes Sep 4, 2018
Copy link
Contributor

@dvdplm dvdplm left a 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.
Copy link
Contributor

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.

Copy link
Member Author

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) {
Copy link
Contributor

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…

Copy link
Member Author

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

date

Copy link
Member Author

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.

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
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: specfiic

}

// The module declaration. This states the entry points that we handle. The
// macro looks after the marshalling of arguments and dispatch.
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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/?

@gavofyork gavofyork added A0-please_review Pull request needs code review. and removed A3-in_progress Pull request is in progress. No review needed at this stage. labels Sep 4, 2018
@gavofyork gavofyork dismissed dvdplm’s stale review September 4, 2018 09:15

Grumbles addressed

@gavofyork gavofyork requested review from arkpar and pepyakin September 4, 2018 09:58
#[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;
Copy link
Contributor

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;
Copy link
Contributor

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;
Copy link
Contributor

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) {}
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

@pepyakin pepyakin Sep 4, 2018

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.

Copy link
Member Author

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]]
Copy link
Contributor

@pepyakin pepyakin Sep 4, 2018

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?

Copy link
Member Author

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);
Copy link
Contributor

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?

Copy link
Member Author

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.

@gavofyork
Copy link
Member Author

@pepyakin Grumbles addressed

@pepyakin pepyakin added A8-looksgood and removed A0-please_review Pull request needs code review. labels Sep 4, 2018
@gavofyork gavofyork merged commit 2b41b77 into master Sep 4, 2018
@gavofyork gavofyork deleted the gav-treasury branch September 4, 2018 15:29
dvdplm added a commit that referenced this pull request Sep 4, 2018
* 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)
  ...
dvdplm added a commit that referenced this pull request Sep 5, 2018
…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)
lamafab pushed a commit to lamafab/substrate that referenced this pull request Jun 16, 2020
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