Skip to content

Commit 2de1e02

Browse files
authored
avoid get dispatch info multiple times (#350)
* avoid get dispatch info multiple times * bump substrate version and enable new resolver * remove clear_on_drop * fix tests
1 parent a428aba commit 2de1e02

File tree

12 files changed

+27
-76
lines changed

12 files changed

+27
-76
lines changed

Cargo.dev.toml

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
cargo-features = ["resolver"]
2+
13
[workspace]
24
members = [
35
"auction",
@@ -13,23 +15,24 @@ members = [
1315
"rewards",
1416
"nft",
1517
]
18+
resolver = "2"
1619

1720
[patch.crates-io]
18-
frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
19-
frame-support = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
20-
frame-system = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
21-
pallet-balances = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
22-
pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
23-
pallet-scheduler = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
24-
pallet-treasury = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
25-
sp-api = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
26-
sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
27-
sp-arithmetic = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
28-
sp-core = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
29-
sp-inherents = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
30-
sp-io = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
31-
sp-runtime = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
32-
sp-runtime-interface = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
33-
sp-std = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
34-
sp-trie = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
35-
sp-version = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
21+
frame-benchmarking = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
22+
frame-support = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
23+
frame-system = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
24+
pallet-balances = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
25+
pallet-elections-phragmen = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
26+
pallet-scheduler = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
27+
pallet-treasury = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
28+
sp-api = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
29+
sp-application-crypto = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
30+
sp-arithmetic = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
31+
sp-core = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
32+
sp-inherents = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
33+
sp-io = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
34+
sp-runtime = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
35+
sp-runtime-interface = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
36+
sp-std = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
37+
sp-trie = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }
38+
sp-version = { git = "https://github.com/paritytech/substrate.git", rev = "9c5fc1caf63bc24eff0e6ef0b3d033cd14359ab0" }

auction/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ orml-traits = { path = "../traits", version = "0.3.3-dev", default-features = fa
2222
[dev-dependencies]
2323
sp-core = { version = "2.0.0", default-features = false }
2424

25-
clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179
26-
2725
[features]
2826
default = ["std"]
2927
std = [

authority/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ orml-traits = { path = "../traits", version = "0.3.3-dev", default-features = fa
2222
[dev-dependencies]
2323
sp-core = { version = "2.0.0", default-features = false }
2424
pallet-scheduler = { version = "2.0.0" }
25-
clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179
2625

2726
[features]
2827
default = ["std"]

authority/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,10 @@ decl_module! {
210210
fn deposit_event() = default;
211211

212212
/// Dispatch a dispatchable on behalf of other origin
213-
#[weight = (T::WeightInfo::dispatch_as().saturating_add(call.get_dispatch_info().weight), call.get_dispatch_info().class)]
213+
#[weight = {
214+
let info = call.get_dispatch_info();
215+
(T::WeightInfo::dispatch_as().saturating_add(info.weight), info.class)
216+
}]
214217
pub fn dispatch_as(
215218
origin,
216219
as_origin: T::AsOriginId,

currencies/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ sp-core = { version = "2.0.0", default-features = false }
2525
pallet-balances = "2.0.0"
2626
orml_tokens = { package = "orml-tokens", path = "../tokens", version = "0.3.3-dev" }
2727

28-
clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179
29-
3028
[features]
3129
default = ["std"]
3230
std = [

oracle/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ orml-utilities = { path = "../utilities", version = "0.3.3-dev", default-feature
2525
[dev-dependencies]
2626
sp-core = { version = "2.0.0", default-features = false }
2727

28-
clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179
29-
3028
[features]
3129
default = ["std"]
3230
std = [

rewards/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ orml-traits = { path = "../traits", version = "0.3.3-dev", default-features = fa
1919

2020
[dev-dependencies]
2121
sp-core = { version = "2.0.0", default-features = false }
22-
clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179
2322

2423
[features]
2524
default = ["std"]

tokens/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,8 @@ orml-traits = { path = "../traits", version = "0.3.3-dev", default-features = fa
2222
[dev-dependencies]
2323
sp-core = { version = "2.0.0", default-features = false }
2424
pallet-treasury = { version = "2.0.0" }
25-
#TODO: use cargo version once `bounties` and `tips` pallets are released.
26-
pallet-bounties = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
27-
pallet-tips = { git = "https://github.com/paritytech/substrate.git", rev = "2eaeb91bc6d20786aa4ad5f5538c0deac46e14cd" }
2825
pallet-elections-phragmen = { version = "2.0.0" }
2926

30-
clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179
31-
3227
[features]
3328
default = ["std"]
3429
std = [

tokens/src/mock.rs

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use sp_core::H256;
1212
use sp_runtime::{
1313
testing::Header,
1414
traits::{AccountIdConversion, IdentityLookup},
15-
AccountId32, ModuleId, Percent, Permill,
15+
AccountId32, ModuleId, Permill,
1616
};
1717
use sp_std::cell::RefCell;
1818

@@ -44,8 +44,6 @@ impl_outer_event! {
4444
frame_system<T>,
4545
tokens<T>,
4646
pallet_treasury<T>,
47-
pallet_bounties<T>,
48-
pallet_tips<T>,
4947
pallet_elections_phragmen<T>,
5048
}
5149
}
@@ -120,20 +118,10 @@ impl ContainsLengthBound for TenToFourteen {
120118
parameter_types! {
121119
pub const ProposalBond: Permill = Permill::from_percent(5);
122120
pub const ProposalBondMinimum: u64 = 1;
123-
pub const TipCountdown: u64 = 1;
124-
pub const TipFindersFee: Percent = Percent::from_percent(20);
125-
pub const TipReportDepositBase: u64 = 1;
126-
pub const DataDepositPerByte: u64 = 1;
127121
pub const SpendPeriod: u64 = 2;
128122
pub const Burn: Permill = Permill::from_percent(50);
129123
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
130124
pub const GetTokenId: CurrencyId = DOT;
131-
pub const BountyDepositBase: Balance = 1;
132-
pub const BountyDepositPayoutDelay: u64 = 1;
133-
pub const BountyUpdatePeriod: u64 = 1;
134-
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
135-
pub const BountyValueMinimum: Balance = 5;
136-
pub const MaximumReasonLength: u32 = 16384;
137125
}
138126

139127
impl pallet_treasury::Config for Runtime {
@@ -148,35 +136,11 @@ impl pallet_treasury::Config for Runtime {
148136
type SpendPeriod = SpendPeriod;
149137
type Burn = Burn;
150138
type BurnDestination = ();
151-
type SpendFunds = Bounties;
152-
type WeightInfo = ();
153-
}
154-
155-
impl pallet_bounties::Config for Runtime {
156-
type Event = TestEvent;
157-
type BountyDepositBase = BountyDepositBase;
158-
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
159-
type BountyUpdatePeriod = BountyUpdatePeriod;
160-
type BountyCuratorDeposit = BountyCuratorDeposit;
161-
type BountyValueMinimum = BountyValueMinimum;
162-
type DataDepositPerByte = DataDepositPerByte;
163-
type MaximumReasonLength = MaximumReasonLength;
164-
type WeightInfo = ();
165-
}
166-
167-
impl pallet_tips::Config for Runtime {
168-
type Event = TestEvent;
169-
type DataDepositPerByte = DataDepositPerByte;
170-
type MaximumReasonLength = MaximumReasonLength;
171-
type Tippers = TenToFourteen;
172-
type TipCountdown = TipCountdown;
173-
type TipFindersFee = TipFindersFee;
174-
type TipReportDepositBase = TipReportDepositBase;
139+
type SpendFunds = ();
175140
type WeightInfo = ();
176141
}
177142

178143
pub type Treasury = pallet_treasury::Module<Runtime>;
179-
pub type Bounties = pallet_bounties::Module<Runtime>;
180144

181145
thread_local! {
182146
pub static MEMBERS: RefCell<Vec<AccountId>> = RefCell::new(vec![]);

traits/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ frame-support = { version = "2.0.0", default-features = false }
1919
orml-utilities = { path = "../utilities", version = "0.3.3-dev", default-features = false }
2020

2121
[dev-dependencies]
22-
clear_on_drop = { version = "0.2.4", features = ["no_cc"] } # https://github.com/paritytech/substrate/issues/4179
23-
2422

2523
[features]
2624
default = ["std"]

0 commit comments

Comments
 (0)