-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Conversation
fn priority(&self, len: usize) -> TransactionPriority { | ||
self.function.priority(len) | ||
} | ||
fn is_block_full(&self, block_weight: Weight, len: usize) -> bool { |
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.
okay this is not a great name since it is misleading. Should be something along the lines of xt.will_cause_full_block() -> bool
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 runtime is not allowed to panic.
fn priority(&self, _len: usize) -> $crate::dispatch::TransactionPriority { | ||
match self { | ||
$( $call_type::$fn_name(..) => $crate::dispatch::Weighable::priority(&$weight, _len), )* | ||
$call_type::__PhantomItem(_, _) => { unreachable!("__PhantomItem should never be used.") }, |
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 should be ensured at compile-time. For example, __PhantomItem
could contain Infallible
, and then the unreachable!
could be replaced by a pattern-match against 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.
@bkchr this pattern can be replaced probably everywhere in storage macros? I borrowed the unreachable!()
from other places in the code.
_block_weight, | ||
_len, | ||
), )* | ||
$call_type::__PhantomItem(_, _) => { unreachable!("__PhantomItem should never be used.") }, |
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
|
||
fn is_block_full(&self, block_weight: Weight, len: usize) -> bool { | ||
match self { | ||
TransactionWeight::Basic(_, _) => self.weight(len) + block_weight > MAX_TRANSACTIONS_WEIGHT, |
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.
TransactionWeight::Basic(_, _) => self.weight(len) + block_weight > MAX_TRANSACTIONS_WEIGHT, | |
TransactionWeight::Basic(_, _) => self.weight(len).checked_add(block_weight).map(|weight| weight > MAX_TRANSACTIONS_WEIGHT).unwrap_or(true), |
@@ -70,7 +70,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { | |||
// implementation changes and behavior does not, then leave spec_version as | |||
// is and increment impl_version. | |||
spec_version: 109, |
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.
spec_version: 109, | |
spec_version: 111, |
// Operational tx. | ||
assert_eq!(Call::<TraitImpl>::security_tx().weight(100), 0); | ||
assert_eq!(Call::<TraitImpl>::security_tx().priority(100), u64::max_value()); | ||
// one simply does not return false of the transaction type is operational!. |
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.
// one simply does not return false of the transaction type is operational!. | |
// Operational transactions are never denied no matter how full | |
// the block is. |
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.
fair enough. I am personally pretty much okay with having some humor/informal statements as long as it is in test code :p
closes #3092
TODOs:
Weighable
is actually doing more than merely communicating weight info up to the rest of the stack, it should probably be renamed to sth more general. Likewise the#[weight]
thingy.By definition, it can be applied to anything which lives in
decl_module
, it is static information (stateless except for input parameters it receives) and it describes the dispatch function.#[meta =$x]
andpub trait DispatchMetaInfo
?