Skip to content

Commit

Permalink
update substrate and hasher (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc authored Feb 25, 2020
1 parent 03792c6 commit 07bd018
Show file tree
Hide file tree
Showing 26 changed files with 402 additions and 475 deletions.
698 changes: 324 additions & 374 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions modules/accounts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use frame_support::{
decl_module, decl_storage,
dispatch::Dispatchable,
traits::{
Currency, ExistenceRequirement, Get, LockIdentifier, LockableCurrency, OnReapAccount, OnUnbalanced, Time,
Currency, ExistenceRequirement, Get, LockIdentifier, LockableCurrency, OnKilledAccount, OnUnbalanced, Time,
WithdrawReason, WithdrawReasons,
},
weights::DispatchInfo,
Expand Down Expand Up @@ -45,8 +45,8 @@ pub trait Trait: system::Trait + pallet_transaction_payment::Trait + orml_curren

decl_storage! {
trait Store for Module<T: Trait> as Accounts {
LastFreeTransfers get(fn last_free_transfers): map hasher(blake2_256) T::AccountId => Vec<MomentOf<T>>;
FreeTransferEnabledAccounts get(fn free_transfer_enabled_accounts): map hasher(blake2_256) T::AccountId => Option<()>;
LastFreeTransfers get(fn last_free_transfers): map hasher(twox_64_concat) T::AccountId => Vec<MomentOf<T>>;
FreeTransferEnabledAccounts get(fn free_transfer_enabled_accounts): map hasher(twox_64_concat) T::AccountId => Option<()>;
}
}

Expand Down Expand Up @@ -95,8 +95,8 @@ impl<T: Trait> Module<T> {
}
}

impl<T: Trait> OnReapAccount<T::AccountId> for Module<T> {
fn on_reap_account(who: &T::AccountId) {
impl<T: Trait> OnKilledAccount<T::AccountId> for Module<T> {
fn on_killed_account(who: &T::AccountId) {
<LastFreeTransfers<T>>::remove(who);
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/accounts/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl system::Trait for Runtime {
type ModuleToIndex = ();
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnReapAccount = ();
type OnKilledAccount = ();
}

impl orml_tokens::Trait for Runtime {
Expand Down
2 changes: 1 addition & 1 deletion modules/airdrop/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub trait Trait: system::Trait {

decl_storage! {
trait Store for Module<T: Trait> as AirDrop {
AirDrops get(fn airdrops): double_map hasher(blake2_256) T::AccountId, hasher(blake2_256) T::CurrencyId => T::Balance;
AirDrops get(fn airdrops): double_map hasher(twox_64_concat) T::AccountId, hasher(twox_64_concat) T::CurrencyId => T::Balance;
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/airdrop/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl system::Trait for Runtime {
type ModuleToIndex = ();
type AccountData = ();
type OnNewAccount = ();
type OnReapAccount = ();
type OnKilledAccount = ();
}
pub type System = system::Module<Runtime>;

Expand Down
8 changes: 4 additions & 4 deletions modules/auction_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ decl_error! {

decl_storage! {
trait Store for Module<T: Trait> as AuctionManager {
pub CollateralAuctions get(fn collateral_auctions): map hasher(blake2_256) AuctionIdOf<T> =>
pub CollateralAuctions get(fn collateral_auctions): map hasher(twox_64_concat) AuctionIdOf<T> =>
Option<CollateralAuctionItem<T::AccountId, CurrencyIdOf<T>, BalanceOf<T>, T::BlockNumber>>;
pub DebitAuctions get(fn debit_auctions): map hasher(blake2_256) AuctionIdOf<T> =>
pub DebitAuctions get(fn debit_auctions): map hasher(twox_64_concat) AuctionIdOf<T> =>
Option<DebitAuctionItem<BalanceOf<T>, T::BlockNumber>>;
pub SurplusAuctions get(fn surplus_auctions): map hasher(blake2_256) AuctionIdOf<T> =>
pub SurplusAuctions get(fn surplus_auctions): map hasher(twox_64_concat) AuctionIdOf<T> =>
Option<SurplusAuctionItem<BalanceOf<T>, T::BlockNumber>>;
pub TotalCollateralInAuction get(fn total_collateral_in_auction): map hasher(blake2_256) CurrencyIdOf<T> => BalanceOf<T>;
pub TotalCollateralInAuction get(fn total_collateral_in_auction): map hasher(twox_64_concat) CurrencyIdOf<T> => BalanceOf<T>;
pub TotalTargetInAuction get(fn total_target_in_auction): BalanceOf<T>;
pub TotalDebitInAuction get(fn total_debit_in_auction): BalanceOf<T>;
pub TotalSurplusInAuction get(fn total_surplus_in_auction): BalanceOf<T>;
Expand Down
2 changes: 1 addition & 1 deletion modules/auction_manager/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl system::Trait for Runtime {
type ModuleToIndex = ();
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnReapAccount = ();
type OnKilledAccount = ();
}
pub type System = system::Module<Runtime>;

Expand Down
12 changes: 6 additions & 6 deletions modules/cdp_engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ decl_error! {

decl_storage! {
trait Store for Module<T: Trait> as CdpEngine {
pub StabilityFee get(fn stability_fee): map hasher(blake2_256) CurrencyIdOf<T> => Option<Rate>;
pub LiquidationRatio get(fn liquidation_ratio): map hasher(blake2_256) CurrencyIdOf<T> => Option<Ratio>;
pub LiquidationPenalty get(fn liquidation_penalty): map hasher(blake2_256) CurrencyIdOf<T> => Option<Rate>;
pub RequiredCollateralRatio get(fn required_collateral_ratio): map hasher(blake2_256) CurrencyIdOf<T> => Option<Ratio>;
pub MaximumTotalDebitValue get(fn maximum_total_debit_value): map hasher(blake2_256) CurrencyIdOf<T> => BalanceOf<T>;
pub DebitExchangeRate get(fn debit_exchange_rate): map hasher(blake2_256) CurrencyIdOf<T> => Option<ExchangeRate>;
pub StabilityFee get(fn stability_fee): map hasher(twox_64_concat) CurrencyIdOf<T> => Option<Rate>;
pub LiquidationRatio get(fn liquidation_ratio): map hasher(twox_64_concat) CurrencyIdOf<T> => Option<Ratio>;
pub LiquidationPenalty get(fn liquidation_penalty): map hasher(twox_64_concat) CurrencyIdOf<T> => Option<Rate>;
pub RequiredCollateralRatio get(fn required_collateral_ratio): map hasher(twox_64_concat) CurrencyIdOf<T> => Option<Ratio>;
pub MaximumTotalDebitValue get(fn maximum_total_debit_value): map hasher(twox_64_concat) CurrencyIdOf<T> => BalanceOf<T>;
pub DebitExchangeRate get(fn debit_exchange_rate): map hasher(twox_64_concat) CurrencyIdOf<T> => Option<ExchangeRate>;
pub IsShutdown get(fn is_shutdown): bool;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/cdp_engine/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl system::Trait for Runtime {
type ModuleToIndex = ();
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnReapAccount = ();
type OnKilledAccount = ();
}
pub type System = system::Module<Runtime>;

Expand Down
4 changes: 2 additions & 2 deletions modules/cdp_treasury/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ decl_storage! {
pub SurplusBufferSize get(fn surplus_buffer_size) config(): BalanceOf<T>;
pub InitialAmountPerDebitAuction get(fn initial_amount_per_debit_auction) config(): BalanceOf<T>;
pub DebitAuctionFixedSize get(fn debit_auction_fixed_size) config(): BalanceOf<T>;
pub CollateralAuctionMaximumSize get(fn collateral_auction_maximum_size): map hasher(blake2_256) CurrencyIdOf<T> => BalanceOf<T>;
pub CollateralAuctionMaximumSize get(fn collateral_auction_maximum_size): map hasher(twox_64_concat) CurrencyIdOf<T> => BalanceOf<T>;

pub DebitPool get(fn debit_pool): BalanceOf<T>;
pub SurplusPool get(fn surplus_pool): BalanceOf<T>;
pub TotalCollaterals get(fn total_collaterals): map hasher(blake2_256) CurrencyIdOf<T> => BalanceOf<T>;
pub TotalCollaterals get(fn total_collaterals): map hasher(twox_64_concat) CurrencyIdOf<T> => BalanceOf<T>;
pub IsShutdown get(fn is_shutdown): bool;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/cdp_treasury/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl system::Trait for Runtime {
type ModuleToIndex = ();
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnReapAccount = ();
type OnKilledAccount = ();
}
pub type System = system::Module<Runtime>;

Expand Down
6 changes: 3 additions & 3 deletions modules/dex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ decl_error! {

decl_storage! {
trait Store for Module<T: Trait> as Dex {
LiquidityPool get(fn liquidity_pool): map hasher(blake2_256) CurrencyIdOf<T> => (BalanceOf<T>, BalanceOf<T>);
TotalShares get(fn total_shares): map hasher(blake2_256) CurrencyIdOf<T> => T::Share;
Shares get(fn shares): double_map hasher(blake2_256) CurrencyIdOf<T>, hasher(blake2_256) T::AccountId => T::Share;
LiquidityPool get(fn liquidity_pool): map hasher(twox_64_concat) CurrencyIdOf<T> => (BalanceOf<T>, BalanceOf<T>);
TotalShares get(fn total_shares): map hasher(twox_64_concat) CurrencyIdOf<T> => T::Share;
Shares get(fn shares): double_map hasher(twox_64_concat) CurrencyIdOf<T>, hasher(twox_64_concat) T::AccountId => T::Share;
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/dex/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl system::Trait for Runtime {
type ModuleToIndex = ();
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnReapAccount = ();
type OnKilledAccount = ();
}
pub type System = system::Module<Runtime>;

Expand Down
2 changes: 1 addition & 1 deletion modules/emergency_shutdown/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl system::Trait for Runtime {
type ModuleToIndex = ();
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnReapAccount = ();
type OnKilledAccount = ();
}
pub type System = system::Module<Runtime>;

Expand Down
2 changes: 1 addition & 1 deletion modules/honzon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type AmountOf<T> = <<T as loans::Trait>::Currency as MultiCurrencyExtended<<T as

decl_storage! {
trait Store for Module<T: Trait> as Honzon {
pub Authorization get(fn authorization): double_map hasher(blake2_256) T::AccountId, hasher(blake2_256) (CurrencyIdOf<T>, T::AccountId) => bool;
pub Authorization get(fn authorization): double_map hasher(twox_64_concat) T::AccountId, hasher(blake2_128_concat) (CurrencyIdOf<T>, T::AccountId) => bool;
pub IsShutdown get(fn is_shutdown): bool;
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/honzon/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl system::Trait for Runtime {
type ModuleToIndex = ();
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnReapAccount = ();
type OnKilledAccount = ();
}
pub type System = system::Module<Runtime>;

Expand Down
6 changes: 3 additions & 3 deletions modules/loans/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ pub trait Trait: system::Trait {
decl_storage! {
trait Store for Module<T: Trait> as Loans {
pub Debits get(fn debits): double_map hasher(twox_64_concat) CurrencyIdOf<T>, hasher(twox_64_concat) T::AccountId => (T::DebitBalance, Option<(CurrencyIdOf<T>, T::AccountId)>);
pub Collaterals get(fn collaterals): double_map hasher(blake2_256) T::AccountId, hasher(blake2_256) CurrencyIdOf<T> => BalanceOf<T>;
pub TotalDebits get(fn total_debits): map hasher(blake2_256) CurrencyIdOf<T> => T::DebitBalance;
pub TotalCollaterals get(fn total_collaterals): map hasher(blake2_256) CurrencyIdOf<T> => BalanceOf<T>;
pub Collaterals get(fn collaterals): double_map hasher(twox_64_concat) T::AccountId, hasher(twox_64_concat) CurrencyIdOf<T> => BalanceOf<T>;
pub TotalDebits get(fn total_debits): map hasher(twox_64_concat) CurrencyIdOf<T> => T::DebitBalance;
pub TotalCollaterals get(fn total_collaterals): map hasher(twox_64_concat) CurrencyIdOf<T> => BalanceOf<T>;
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/loans/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl system::Trait for Runtime {
type ModuleToIndex = ();
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnReapAccount = ();
type OnKilledAccount = ();
}
pub type System = system::Module<Runtime>;

Expand Down
2 changes: 1 addition & 1 deletion modules/prices/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub trait Trait: system::Trait {

decl_storage! {
trait Store for Module<T: Trait> as Prices {
LockedPrice get(fn locked_price): map hasher(blake2_256) T::CurrencyId => Option<Option<Price>>;
LockedPrice get(fn locked_price): map hasher(twox_64_concat) T::CurrencyId => Option<Option<Price>>;
}
}

Expand Down
2 changes: 1 addition & 1 deletion modules/prices/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl system::Trait for Runtime {
type ModuleToIndex = ();
type AccountData = ();
type OnNewAccount = ();
type OnReapAccount = ();
type OnKilledAccount = ();
}

pub struct MockDataProvider;
Expand Down
2 changes: 1 addition & 1 deletion orml
Submodule orml updated from 387976 to 3ac228
2 changes: 1 addition & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl system::Trait for Runtime {
type ModuleToIndex = ModuleToIndex;
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnReapAccount = (Balances, Staking, Session, Recovery);
type OnKilledAccount = ();
}

parameter_types! {
Expand Down
4 changes: 2 additions & 2 deletions src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ fn testnet_genesis(
pallet_session: Some(SessionConfig {
keys: initial_authorities
.iter()
.map(|x| (x.0.clone(), session_keys(x.2.clone(), x.3.clone())))
.map(|x| (x.0.clone(), x.0.clone(), session_keys(x.2.clone(), x.3.clone())))
.collect::<Vec<_>>(),
}),
pallet_staking: Some(StakingConfig {
Expand Down Expand Up @@ -348,7 +348,7 @@ fn mandala_genesis(
pallet_session: Some(SessionConfig {
keys: initial_authorities
.iter()
.map(|x| (x.0.clone(), session_keys(x.2.clone(), x.3.clone())))
.map(|x| (x.0.clone(), x.0.clone(), session_keys(x.2.clone(), x.3.clone())))
.collect::<Vec<_>>(),
}),
pallet_staking: Some(StakingConfig {
Expand Down
31 changes: 13 additions & 18 deletions src/command.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
use crate::chain_spec;
use crate::cli::Cli;
use crate::service;
use sc_cli::{error, VersionInfo};
use sc_cli::VersionInfo;

/// Parse and run command line arguments
pub fn run(version: VersionInfo) -> error::Result<()> {
pub fn run(version: VersionInfo) -> sc_cli::Result<()> {
let opt = sc_cli::from_args::<Cli>(&version);

let config = sc_service::Configuration::new(&version);
let mut config = sc_service::Configuration::from_version(&version);

match opt.subcommand {
Some(subcommand) => sc_cli::run_subcommand(
config,
subcommand,
chain_spec::load_spec,
|config: _| Ok(new_full_start!(config).0),
&version,
),
None => sc_cli::run(
config,
opt.run,
service::new_light,
service::new_full,
chain_spec::load_spec,
&version,
),
Some(subcommand) => {
subcommand.init(&version)?;
subcommand.update_config(&mut config, chain_spec::load_spec, &version)?;
subcommand.run(config, |config: _| Ok(new_full_start!(config).0))
}
None => {
opt.run.init(&version)?;
opt.run.update_config(&mut config, chain_spec::load_spec, &version)?;
opt.run.run(config, service::new_light, service::new_full, &version)
}
}
}
6 changes: 2 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ mod cli;
mod command;
mod executor;

pub use sc_cli::{error, VersionInfo};

fn main() -> Result<(), error::Error> {
let version = VersionInfo {
fn main() -> sc_cli::Result<()> {
let version = sc_cli::VersionInfo {
name: "Acala",
commit: env!("VERGEN_SHA_SHORT"),
version: env!("CARGO_PKG_VERSION"),
Expand Down
Loading

0 comments on commit 07bd018

Please sign in to comment.