-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
Not yet complete but 75% there.
= $id:expr ; | ||
)* | ||
) => { | ||
pub mod $mod_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.
could put all the warnings to silence on 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.
what's the best way of doing that? is there a #[allow(*)]
?
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 mean the warnings can be blocked at a module level so they don't need to be silenced per struct.
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.
isn't it better to keep them focussed? suppressing at module level might let accidental errors get through.
demo/runtime/src/dispatch.rs
Outdated
fn from_u8(value: u8) -> Option<Id> { | ||
use self::*; | ||
let functions = [ | ||
$( Id::$fn_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.
why not generate a match statement?
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.
fixed (not intentional - just was adapting existing code)
demo/runtime/src/runtime/system.rs
Outdated
@@ -42,12 +44,17 @@ pub fn block_hash(number: BlockNumber) -> Hash { | |||
storage::get_or_default(&number.to_keyed_vec(BLOCK_HASH_AT)) | |||
} | |||
|
|||
pub mod privileged { | |||
use super::*; | |||
pub struct PrivPass; |
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.
docs
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.
also this could be a little harder to create PrivPass.x()
doesn't guard anything that x()
itself doesn't.
demo/runtime/src/runtime/session.rs
Outdated
@@ -22,6 +22,8 @@ use codec::KeyedVec; | |||
use runtime_support::{storage, StorageVec}; | |||
use demo_primitives::{AccountId, SessionKey, BlockNumber}; | |||
use runtime::{system, staking, consensus}; | |||
use runtime::system::PrivPass; | |||
use runtime::staking::PublicPass; |
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.
these should really reside in the same module where all passes are defined
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.
they now both reside in the only module that is able to actually create them.
demo/runtime/src/runtime/system.rs
Outdated
}; | ||
|
||
println!("TX: {}", HexDisplay::from(&tx.transaction.encode())); |
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.
stray println
@@ -151,72 +184,92 @@ pub fn next_free_ref_index() -> ReferendumIndex { | |||
storage::get_or_default(REFERENDUM_COUNT) | |||
} | |||
|
|||
pub mod public { | |||
use super::*; | |||
pub type BoxedProposal = Box<Proposal>; |
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.
unused
use super::*; | ||
impl_dispatch! { | ||
pub mod privileged; | ||
fn start_referendum(proposal: Box<Proposal>, vote_threshold: VoteThreshold) = 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.
why does this accept a Box
?
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.
because it's inside impl_dispatch
so it needs to be pass-by-value (since the same types will be used in the enum
item prototypes).
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.
just to clarify: there can be a referendum to dispatch any kind of private-only call from any module? (which we've renamed to Proposal
within this module -- I found that confusing)
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.
correct, though it's not "private-only", it's "privileged-only".
|
||
impl_dispatch! { | ||
pub mod public; | ||
fn propose(proposal: Box<Proposal>, value: Balance) = 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.
and this?
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.
same.
pub enum Call { | ||
$( | ||
#[allow(non_camel_case_types)] | ||
$camelcase ( $crate::runtime::$sub_name::$path::Call ) |
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 a little non-general. If we want this to be reusable for other runtimes we shouldn't make any assumptions about module structure.
} | ||
|
||
impl $crate::dispatch::Slicable for Call { | ||
fn decode<I: $crate::dispatch::Input>(input: &mut I) -> Option<Self> { |
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.
likewise here
} | ||
|
||
fn encode(&self) -> Vec<u8> { | ||
let mut v = $crate::dispatch::Vec::new(); |
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.
and here
demo/runtime/src/dispatch.rs
Outdated
council_vote::privileged::set_voting_period(a), | ||
use runtime::{staking, system}; | ||
pub use rstd::prelude::Vec; | ||
pub use codec::{Slicable, Input, NonTrivialSlicable}; |
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.
re-exports in a random module worry me.
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 for the macro.
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 understand that, but it's still bad style -- re-exports should at the very least be #[doc(hidden)]
and preferably in the crate root (ideally, the macro is in its own crate and we can reuse it)
@@ -33,48 +36,12 @@ extern crate demo_primitives; | |||
|
|||
extern crate integer_sqrt; | |||
|
|||
#[macro_use] pub mod 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.
the macros from dispatch
aren't used outside of it as far as I can see
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.
impl_dispatch
is.
use runtime::staking::{PublicPass, Balance}; | ||
|
||
/// A token for privileged dispatch. Can only be created in this module. | ||
pub struct PrivPass; |
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 struct can be created anywhere. It would need a private field to prevent creation in other 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.
fixed...
@@ -188,15 +194,15 @@ mod tests { | |||
Executor::new().call(&mut t, COMPACT_CODE, "execute_block", &block1().0).unwrap(); | |||
|
|||
runtime_io::with_externalities(&mut t, || { | |||
assert_eq!(balance(&Alice), 42); | |||
assert_eq!(balance(&Alice), 41); |
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.
Just wondering why have these changed?
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.
there's a transaction fee now.
demo/runtime/src/dispatch.rs
Outdated
pub use codec::{Slicable, Input, NonTrivialSlicable}; | ||
|
||
#[macro_export] | ||
macro_rules! impl_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.
docs
wasm successful pending has not remove {:?} debug trait
…depth-requirement Increase confirmation depth requirement to 100 blocks
#91 and #92 and more.