mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 08:05:41 +00:00
Document more TODOs as tickets (#1418)
Went through the TODOs, removed a bunch, which are outdated or nothing more than a regular comment, documented a bunch more as actual tickets and made them FIXMEs and unified their structure (`FIXME #TICKETNO DESC` for local tickets, `FIXME: DESC LINK` for external tickets) for easier in-editor support. Further more remove unnecessary remarks and related old code that I noticed in that instance.
This commit is contained in:
committed by
GitHub
parent
d2cfd7b9dc
commit
15ae7cfef6
@@ -201,7 +201,6 @@ decl_module! {
|
||||
/// Report some misbehaviour.
|
||||
fn report_misbehavior(origin, _report: Vec<u8>) {
|
||||
ensure_signed(origin)?;
|
||||
// TODO: requires extension trait.
|
||||
}
|
||||
|
||||
/// Note the previous block's validator missed their opportunity to propose a block.
|
||||
|
||||
@@ -347,12 +347,8 @@ decl_storage! {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: consider storing upper-bound for contract's gas limit in fixed-length runtime
|
||||
// code in contract itself and use that.
|
||||
|
||||
/// The storage items associated with an account/key.
|
||||
///
|
||||
/// TODO: keys should also be able to take AsRef<KeyType> to ensure Vec<u8>s can be passed as &[u8]
|
||||
pub(crate) struct StorageOf<T>(rstd::marker::PhantomData<T>);
|
||||
impl<T: Trait> StorageDoubleMap for StorageOf<T> {
|
||||
const PREFIX: &'static [u8] = b"con:sto:";
|
||||
|
||||
@@ -196,8 +196,6 @@ fn write_sandbox_memory<T: Trait>(
|
||||
// * AFTER MAKING A CHANGE MAKE SURE TO UPDATE COMPLEXITY.MD *
|
||||
// ***********************************************************
|
||||
|
||||
// TODO: ext_balance, ext_address, ext_callvalue, etc.
|
||||
|
||||
// Define a function `fn init_env<E: Ext>() -> HostFunctionSet<E>` that returns
|
||||
// a function set which can be imported by an executed contract.
|
||||
define_env!(Env, <E: Ext>,
|
||||
|
||||
@@ -181,7 +181,7 @@ decl_module! {
|
||||
/// Report some misbehaviour.
|
||||
fn report_misbehavior(origin, _report: Vec<u8>) {
|
||||
ensure_signed(origin)?;
|
||||
// TODO: https://github.com/paritytech/substrate/issues/1112
|
||||
// FIXME: https://github.com/paritytech/substrate/issues/1112
|
||||
}
|
||||
|
||||
fn on_finalise(block_number: T::BlockNumber) {
|
||||
@@ -259,7 +259,7 @@ impl<T: Trait> Module<T> where Ed25519AuthorityId: core::convert::From<<T as Tra
|
||||
/// sets should be.
|
||||
pub struct SyncedAuthorities<T>(::rstd::marker::PhantomData<T>);
|
||||
|
||||
// TODO: remove when https://github.com/rust-lang/rust/issues/26925 is fixed
|
||||
// FIXME: remove when https://github.com/rust-lang/rust/issues/26925 is fixed
|
||||
impl<T> Default for SyncedAuthorities<T> {
|
||||
fn default() -> Self {
|
||||
SyncedAuthorities(::rstd::marker::PhantomData)
|
||||
|
||||
@@ -138,7 +138,7 @@ decl_storage! {
|
||||
impl<T: Trait> Module<T> {
|
||||
/// The number of validators currently.
|
||||
pub fn validator_count() -> u32 {
|
||||
<Validators<T>>::get().len() as u32 // TODO: can probably optimised
|
||||
<Validators<T>>::get().len() as u32
|
||||
}
|
||||
|
||||
/// The last length change, if there was one, zero if not.
|
||||
@@ -158,7 +158,7 @@ impl<T: Trait> Module<T> {
|
||||
/// Called by `staking::new_era()` only. `next_session` should be called after this in order to
|
||||
/// update the session keys to the next validator set.
|
||||
pub fn set_validators(new: &[T::AccountId]) {
|
||||
<Validators<T>>::put(&new.to_vec()); // TODO: optimise.
|
||||
<Validators<T>>::put(&new.to_vec());
|
||||
<consensus::Module<T>>::set_authorities(
|
||||
&new.iter().cloned().map(T::ConvertAccountIdToSessionKey::convert).collect::<Vec<_>>()
|
||||
);
|
||||
|
||||
@@ -355,7 +355,7 @@ impl<T: Trait> Module<T> {
|
||||
let noms = Self::current_nominators_for(v);
|
||||
let total = noms.iter().map(<balances::Module<T>>::total_balance).fold(T::Balance::zero(), |acc, x| acc + x);
|
||||
if !total.is_zero() {
|
||||
let safe_mul_rational = |b| b * rem / total;// TODO: avoid overflow
|
||||
let safe_mul_rational = |b| b * rem / total;// FIXME #1572 avoid overflow
|
||||
for n in noms.iter() {
|
||||
let _ = <balances::Module<T>>::slash(n, safe_mul_rational(<balances::Module<T>>::total_balance(n))); // best effort - not much that can be done on fail.
|
||||
}
|
||||
@@ -376,7 +376,7 @@ impl<T: Trait> Module<T> {
|
||||
.map(<balances::Module<T>>::total_balance)
|
||||
.fold(<balances::Module<T>>::total_balance(who), |acc, x| acc + x)
|
||||
.max(One::one());
|
||||
let safe_mul_rational = |b| b * reward / total;// TODO: avoid overflow
|
||||
let safe_mul_rational = |b| b * reward / total;// FIXME #1572: avoid overflow
|
||||
for n in noms.iter() {
|
||||
let _ = <balances::Module<T>>::reward(n, safe_mul_rational(<balances::Module<T>>::total_balance(n)));
|
||||
}
|
||||
@@ -454,7 +454,7 @@ impl<T: Trait> Module<T> {
|
||||
// combination of validators, then use session::internal::set_validators().
|
||||
// for now, this just orders would-be stakers by their balances and chooses the top-most
|
||||
// <ValidatorCount<T>>::get() of them.
|
||||
// TODO: this is not sound. this should be moved to an off-chain solution mechanism.
|
||||
// FIXME #1571 this is not sound. this should be moved to an off-chain solution mechanism.
|
||||
let mut intentions = Self::intentions()
|
||||
.into_iter()
|
||||
.map(|v| (Self::slashable_balance(&v), v))
|
||||
|
||||
@@ -416,7 +416,6 @@ fn nominating_slashes_should_work() {
|
||||
assert_eq!(Balances::total_balance(&2), 20); //not slashed
|
||||
assert_eq!(Balances::total_balance(&3), 10); //slashed
|
||||
assert_eq!(Balances::total_balance(&4), 30); //slashed
|
||||
// TODO: change slash % to something sensible.
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ struct AddExtraGenesisLine {
|
||||
pub extra_field: ext::Parens<Ident>,
|
||||
pub coldot_token: Token![:],
|
||||
pub extra_type: syn::Type,
|
||||
// TODO use a custom ext::Option instead (syn option on '=' fails)
|
||||
// FIXME #1570: use a custom ext::Option instead (syn option on '=' fails)
|
||||
pub default_value: ext::Seq<DeclStorageDefault>,
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ struct DeclStorageLine {
|
||||
pub build: Option<DeclStorageBuild>,
|
||||
pub coldot_token: Token![:],
|
||||
pub storage_type: DeclStorageType,
|
||||
// TODO use a custom ext::Option instead (syn option on '=' fails)
|
||||
// FIXME #1570: use a custom ext::Option instead (syn option on '=' fails)
|
||||
pub default_value: ext::Seq<DeclStorageDefault>,
|
||||
}
|
||||
|
||||
|
||||
@@ -57,9 +57,7 @@ macro_rules! custom_keyword {
|
||||
}
|
||||
|
||||
|
||||
// TODO following functions are copied from sr-api-macros : do a merge to get a unique procedural
|
||||
// macro tooling crate (this crate path does not look good for it)
|
||||
|
||||
// FIXME #1569, remove the following functions, which are copied from sr-api-macros
|
||||
use proc_macro2::{TokenStream, Span};
|
||||
use syn::Ident;
|
||||
|
||||
|
||||
@@ -485,7 +485,7 @@ macro_rules! decl_module {
|
||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
// TODO: switching based on std feature is because of an issue in
|
||||
// FIXME: switching based on std feature is because of an issue in
|
||||
// serde-derive for when we attempt to derive `Deserialize` on these types,
|
||||
// in a situation where we've imported `srml_support` as another name.
|
||||
#[cfg(feature = "std")]
|
||||
|
||||
@@ -194,7 +194,7 @@ pub trait StorageMap<K: codec::Codec, V: codec::Codec> {
|
||||
fn mutate<R, F: FnOnce(&mut Self::Query) -> R, S: Storage>(key: &K, f: F, storage: &S) -> R;
|
||||
}
|
||||
|
||||
// TODO: Remove this in favour of `decl_storage` macro.
|
||||
// FIXME #1466 Remove this in favour of `decl_storage` macro.
|
||||
/// Declares strongly-typed wrappers around codec-compatible types in storage.
|
||||
#[macro_export]
|
||||
macro_rules! storage_items {
|
||||
@@ -445,7 +445,6 @@ macro_rules! __storage_items_internal {
|
||||
}
|
||||
|
||||
/// Get the key used to put the length field.
|
||||
// TODO: concat macro should accept byte literals.
|
||||
fn len_key() -> $crate::rstd::vec::Vec<u8> {
|
||||
let mut key = $prefix.to_vec();
|
||||
key.extend(b"len");
|
||||
@@ -513,7 +512,7 @@ macro_rules! __handle_wrap_internal {
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: revisit this idiom once we get `type`s in `impl`s.
|
||||
// FIXME: revisit this idiom once we get `type`s in `impl`s.
|
||||
/*impl<T: Trait> Module<T> {
|
||||
type Now = super::Now<T>;
|
||||
}*/
|
||||
|
||||
@@ -24,8 +24,6 @@ use codec::{Codec, Decode, KeyedVec, Input};
|
||||
#[macro_use]
|
||||
pub mod generator;
|
||||
|
||||
// TODO: consider using blake256 to avoid possible preimage attack.
|
||||
|
||||
struct IncrementalInput<'a> {
|
||||
key: &'a [u8],
|
||||
pos: usize,
|
||||
|
||||
@@ -344,9 +344,9 @@ impl<T: Trait> Module<T> {
|
||||
#[cfg(any(feature = "std", test))]
|
||||
pub fn externalities() -> TestExternalities<Blake2Hasher> {
|
||||
TestExternalities::new(map![
|
||||
twox_128(&<BlockHash<T>>::key_for(T::BlockNumber::zero())).to_vec() => [69u8; 32].encode(), // TODO: replace with Hash::default().encode
|
||||
twox_128(&<BlockHash<T>>::key_for(T::BlockNumber::zero())).to_vec() => [69u8; 32].encode(),
|
||||
twox_128(<Number<T>>::key()).to_vec() => T::BlockNumber::one().encode(),
|
||||
twox_128(<ParentHash<T>>::key()).to_vec() => [69u8; 32].encode(), // TODO: replace with Hash::default().encode
|
||||
twox_128(<ParentHash<T>>::key()).to_vec() => [69u8; 32].encode(),
|
||||
twox_128(<RandomSeed<T>>::key()).to_vec() => T::Hash::default().encode()
|
||||
])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user