Skip to content

Commit bbc1232

Browse files
committed
fix: update from v0.9.27 to v0.9.36
v0.9.28 - changes v0.9.29 - changes v0.9.30 - changes v0.9.31 - changes v0.9.37 changes Add indices for calls of ethereum-transactions See: paritytech/substrate#12891 paritytech/substrate#11381 Fixes ethereum-events tests Add indices for calls of ethereum-transactions See: - paritytech/substrate#12891 - paritytech/substrate#11381 Fixes compilation errors of avn-proxy pallet - Cleanups WiP - Adds indices for calls Fixes compilation errors of nft-manager pallet - Cleanup - Adds indices for calls Fixes tests for nft-manager pallet Fixup nft-manager imports Fixes avn-proxy tests Fixes tests on Ethereum Events pallet SYS-3197 - token-manager pallet::call changed SYS-3197 - summary pallet and exact substrate version fix: tests Cleanup warnings and adds call indexes Fixes some of the test in token manager Reverts the interface changes to use Box<call>. Fixes mock, re-introduces some of the tests, and temporarily disables some. Re-enable the rest of token manager tests Fixup: Remove warning Fixes token-manager benchmarks compilation errors Updates and fixes Benchmarks cargo dependencies. Also fixes avn-proxy compilation errors. Adds instructions to run pallet benchmarks fix: updated benchmarks fix: added prod-like benchmarks for parachain-staking Fix staking tests fix: benchmark test for parachain staking fix: add max proof to weights init fix: linting
1 parent 8bec087 commit bbc1232

File tree

106 files changed

+3615
-2822
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+3615
-2822
lines changed

Cargo.lock

+885-423
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,21 @@ We welcome contributions but before you devote quite a bit of time to contributi
1717
Read our contribution guide [HERE](./CONTRIBUTING.adoc).
1818

1919
Note: This repository is managed frequently so you do not need to email/contact us to notify us of your submission.
20+
21+
## Building and testing the pallets
22+
23+
To build and test a pallet, navigate to the directory of the pallet in your project by running the following command:
24+
```sh
25+
cd pallets/<pallet_name>/
26+
```
27+
Once you're in the pallet directory, use cargo to build and test the pallet by running the following commands:
28+
```sh
29+
# Build the pallet
30+
cargo build
31+
32+
# Run the unit and integration tests
33+
cargo test
34+
35+
# Test the benchmark tests
36+
cargo test --features runtime-benchmarks
37+
```

pallets/avn-finality-tracker/Cargo.toml

+12-11
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,31 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
1212
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
1313
scale-info = { version = "2.0", default-features = false, features = ["derive"] }
1414

15-
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
16-
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
17-
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
18-
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
19-
sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
15+
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
16+
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
17+
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
18+
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
19+
sp-application-crypto = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
2020
sp-avn-common = { version = "0.12.0", default-features = false, path = "../../primitives/avn-common" }
21-
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
22-
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
21+
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
22+
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
2323
pallet-avn = { version = "0.12.0", default-features = false, path = "../avn" }
2424

2525
# Optional imports
2626
serde = { version = "1.0.137", optional = true }
27-
frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", optional = true }
27+
frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", optional = true }
2828

2929
[dev-dependencies]
3030
hex-literal = { version = "0.3.4", default-features = false }
3131
parking_lot = { version = "0.12.0" }
32-
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
33-
substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
32+
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
33+
substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
3434

3535
[features]
3636
migrate = []
3737
default = ["std"]
3838
std = [
39+
"frame-benchmarking?/std",
3940
"serde",
4041
"codec/std",
4142
"sp-std/std",
@@ -48,7 +49,7 @@ std = [
4849
"pallet-avn/std"
4950
]
5051
runtime-benchmarks = [
51-
"frame-benchmarking",
52+
"frame-benchmarking/runtime-benchmarks",
5253
"frame-support/runtime-benchmarks",
5354
"frame-system/runtime-benchmarks",
5455
]

pallets/avn-finality-tracker/src/benchmarking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
#![cfg(feature = "runtime-benchmarks")]
77

8-
use super::*;
8+
use crate::*;
99

1010
use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite};
1111
use frame_system::RawOrigin;

pallets/avn-finality-tracker/src/default_weights.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
6464
// Storage: AvnFinalityTracker LastFinalisedBlockSubmission (r:0 w:1)
6565
/// The range of component `v` is `[3, 10]`.
6666
fn submit_latest_finalised_block_number(v: u32, ) -> Weight {
67-
(19_069_000 as Weight)
67+
(Weight::from_ref_time(19_069_000))
6868
// Standard Error: 18_000
69-
.saturating_add((118_000 as Weight).saturating_mul(v as Weight))
70-
.saturating_add(T::DbWeight::get().reads(3 as Weight))
71-
.saturating_add(T::DbWeight::get().writes(2 as Weight))
69+
.saturating_add(Weight::from_ref_time(118_000)).saturating_mul(v as u64)
70+
.saturating_add(T::DbWeight::get().reads(3))
71+
.saturating_add(T::DbWeight::get().writes(2))
7272
}
7373
}
7474

@@ -80,10 +80,10 @@ impl WeightInfo for () {
8080
// Storage: AvnFinalityTracker LastFinalisedBlockSubmission (r:0 w:1)
8181
/// The range of component `v` is `[3, 10]`.
8282
fn submit_latest_finalised_block_number(v: u32, ) -> Weight {
83-
(19_069_000 as Weight)
83+
(Weight::from_ref_time(19_069_000))
8484
// Standard Error: 18_000
85-
.saturating_add((118_000 as Weight).saturating_mul(v as Weight))
86-
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
87-
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
85+
.saturating_add(Weight::from_ref_time(118_000)).saturating_mul(v as u64)
86+
.saturating_add(RocksDbWeight::get().reads(3))
87+
.saturating_add(RocksDbWeight::get().writes(2))
8888
}
8989
}

pallets/avn-finality-tracker/src/lib.rs

+24-21
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const MAX_VALIDATOR_ACCOUNT_IDS: u32 = 10;
4747
pub type AVN<T> = avn::Pallet<T>;
4848

4949
#[cfg(test)]
50+
#[path = "mock.rs"]
5051
mod mock;
5152

5253
mod benchmarking;
@@ -65,9 +66,9 @@ pub mod pallet {
6566
SendTransactionTypes<Call<Self>> + frame_system::Config + avn::Config
6667
{
6768
/// Overarching event type
68-
type Event: From<Event<Self>>
69-
+ IsType<<Self as frame_system::Config>::Event>
70-
+ Into<<Self as frame_system::Config>::Event>;
69+
type RuntimeEvent: From<Event<Self>>
70+
+ IsType<<Self as frame_system::Config>::RuntimeEvent>
71+
+ Into<<Self as frame_system::Config>::RuntimeEvent>;
7172
/// The number of block we can keep the calculated finalised block, before recalculating it
7273
/// again.
7374
type CacheAge: Get<Self::BlockNumber>;
@@ -131,6 +132,7 @@ pub mod pallet {
131132
#[pallet::weight(
132133
<T as pallet::Config>::WeightInfo::submit_latest_finalised_block_number(MAX_VALIDATOR_ACCOUNT_IDS)
133134
)]
135+
#[pallet::call_index(0)]
134136
pub fn submit_latest_finalised_block_number(
135137
origin: OriginFor<T>,
136138
new_finalised_block_number: T::BlockNumber,
@@ -219,9 +221,21 @@ pub mod pallet {
219221
}
220222
}
221223

224+
#[derive(Encode, Decode, Default, Clone, Copy, PartialEq, Debug, Eq, TypeInfo, MaxEncodedLen)]
225+
pub struct SubmissionData<BlockNumber: Member + AtLeast32Bit> {
226+
pub finalised_block: BlockNumber,
227+
pub submitted_at_block: BlockNumber,
228+
}
229+
230+
impl<BlockNumber: Member + AtLeast32Bit> SubmissionData<BlockNumber> {
231+
pub fn new(finalised_block: BlockNumber, submitted_at_block: BlockNumber) -> Self {
232+
return SubmissionData::<BlockNumber> { finalised_block, submitted_at_block }
233+
}
234+
}
235+
222236
impl<T: Config> Pallet<T> {
223-
/// This function will only update the finalised block if there are 2/3rd or more submissions
224-
/// from distinct validators
237+
/// This function will only update the finalised block if there are 2/3rd or more
238+
/// submissions from distinct validators
225239
pub fn update_latest_finalised_block_if_required() {
226240
let quorum = AVN::<T>::calculate_two_third_quorum();
227241
let current_block_number = <frame_system::Pallet<T>>::block_number();
@@ -246,7 +260,8 @@ impl<T: Config> Pallet<T> {
246260
});
247261
}
248262

249-
// check if there is something wrong with submissions in general and notify via an event
263+
// check if there is something wrong with submissions in general and notify via an
264+
// event
250265
if current_block_number - last_finalised_block_submission > T::ReportLatency::get() {
251266
Self::deposit_event(Event::<T>::FinalisedBlockUpdateStalled {
252267
block: last_finalised_block_submission,
@@ -329,9 +344,9 @@ impl<T: Config> Pallet<T> {
329344
return
330345
}
331346

332-
// send a transaction on chain with the latest finalised block data. We shouldn't have any
333-
// sig re-use issue here because new block number must be > current finalised block
334-
// number
347+
// send a transaction on chain with the latest finalised block data. We shouldn't have
348+
// any sig re-use issue here because new block number must be > current
349+
// finalised block number
335350
let signature = this_validator
336351
.key
337352
.sign(&(UPDATE_FINALISED_BLOCK_NUMBER_CONTEXT, calculated_finalised_block).encode())
@@ -453,15 +468,3 @@ impl<T: Config> FinalisedBlockChecker<T::BlockNumber> for Pallet<T> {
453468
return Self::latest_finalised_block_number() >= block_number
454469
}
455470
}
456-
457-
#[derive(Encode, Decode, Default, Clone, Copy, PartialEq, Debug, Eq, TypeInfo, MaxEncodedLen)]
458-
pub struct SubmissionData<BlockNumber: Member + AtLeast32Bit> {
459-
pub finalised_block: BlockNumber,
460-
pub submitted_at_block: BlockNumber,
461-
}
462-
463-
impl<BlockNumber: Member + AtLeast32Bit> SubmissionData<BlockNumber> {
464-
fn new(finalised_block: BlockNumber, submitted_at_block: BlockNumber) -> Self {
465-
return SubmissionData::<BlockNumber> { finalised_block, submitted_at_block }
466-
}
467-
}

pallets/avn-finality-tracker/src/mock.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use sp_runtime::{
1111
traits::{BlakeTwo256, IdentityLookup},
1212
};
1313

14-
pub type Extrinsic = TestXt<Call, ()>;
14+
pub type Extrinsic = TestXt<RuntimeCall, ()>;
1515

1616
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<TestRuntime>;
1717
type Block = frame_system::mocking::MockBlock<TestRuntime>;
@@ -34,8 +34,8 @@ parameter_types! {
3434
pub const ReportLatency: u64 = 1000;
3535
}
3636

37-
impl Config for TestRuntime {
38-
type Event = Event;
37+
impl avn_finality_tracker::Config for TestRuntime {
38+
type RuntimeEvent = RuntimeEvent;
3939
type CacheAge = CacheAge;
4040
type SubmissionInterval = SubmissionInterval;
4141
type ReportLatency = ReportLatency;
@@ -51,16 +51,16 @@ impl system::Config for TestRuntime {
5151
type BlockWeights = ();
5252
type BlockLength = ();
5353
type DbWeight = ();
54-
type Origin = Origin;
55-
type Call = Call;
54+
type RuntimeOrigin = RuntimeOrigin;
55+
type RuntimeCall = RuntimeCall;
5656
type Index = u64;
5757
type BlockNumber = u64;
5858
type Hash = H256;
5959
type Hashing = BlakeTwo256;
6060
type AccountId = u64;
6161
type Lookup = IdentityLookup<Self::AccountId>;
6262
type Header = Header;
63-
type Event = Event;
63+
type RuntimeEvent = RuntimeEvent;
6464
type BlockHashCount = BlockHashCount;
6565
type Version = ();
6666
type PalletInfo = PalletInfo;
@@ -83,9 +83,9 @@ impl avn::Config for TestRuntime {
8383

8484
impl<LocalCall> frame_system::offchain::SendTransactionTypes<LocalCall> for TestRuntime
8585
where
86-
Call: From<LocalCall>,
86+
RuntimeCall: From<LocalCall>,
8787
{
88-
type OverarchingCall = Call;
88+
type OverarchingCall = RuntimeCall;
8989
type Extrinsic = Extrinsic;
9090
}
9191

pallets/avn-offence-handler/Cargo.toml

+11-10
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,30 @@ homepage = "http://www.aventus.io/"
88
repository = "https://github.com/Aventus-Network-Services/avn-parachain/"
99

1010
[dependencies]
11-
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
12-
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
11+
frame-system = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
12+
frame-support = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
1313
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
1414
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
1515
sp-avn-common = { version = "0.12.0", default-features = false, path = "../../primitives/avn-common" }
16-
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
17-
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
18-
sp-staking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
19-
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
16+
sp-core = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
17+
sp-runtime = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
18+
sp-staking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
19+
sp-std = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
2020
pallet-avn = { version = "0.12.0", default-features = false, path = "../avn" }
21-
pallet-session = { default-features = false, features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
21+
pallet-session = { default-features = false, features = ["historical"], git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
2222

2323
# Optional imports for benchmarking
24-
frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27", optional = true }
24+
frame-benchmarking = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36", optional = true }
2525

2626
[dev-dependencies]
2727
serde = { version = "1.0.101"}
2828
parking_lot = { version = "0.12.0" }
29-
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.27" }
29+
sp-io = { default-features = false, git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.36" }
3030

3131
[features]
3232
default = ["std"]
3333
std = [
34+
"frame-benchmarking?/std",
3435
"codec/std",
3536
"frame-support/std",
3637
"frame-system/std",
@@ -42,7 +43,7 @@ std = [
4243
"pallet-avn/std",
4344
]
4445
runtime-benchmarks = [
45-
"frame-benchmarking",
46+
"frame-benchmarking/runtime-benchmarks",
4647
"frame-support/runtime-benchmarks",
4748
"frame-system/runtime-benchmarks",
4849
]

pallets/avn-offence-handler/src/benchmarking.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ impl_benchmark_test_suite!(
2727
crate::mock::TestRuntime,
2828
);
2929

30-
fn assert_last_event<T: Config>(generic_event: <T as Config>::Event) {
30+
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
3131
let events = frame_system::Pallet::<T>::events();
32-
let system_event: <T as frame_system::Config>::Event = generic_event.into();
32+
let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();
3333
// compare to the last event record
3434
let EventRecord { event, .. } = &events[events.len().saturating_sub(1 as usize)];
3535
assert_eq!(event, &system_event);

pallets/avn-offence-handler/src/default_weights.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ pub struct SubstrateWeight<T>(PhantomData<T>);
6060
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
6161
// Storage: AvnOffenceHandler SlashingEnabled (r:0 w:1)
6262
fn configure_slashing() -> Weight {
63-
(15_281_000 as Weight)
64-
.saturating_add(T::DbWeight::get().writes(1 as Weight))
63+
(Weight::from_ref_time(15_281_000))
64+
.saturating_add(T::DbWeight::get().writes(1))
6565
}
6666
}
6767

6868
// For backwards compatibility and tests
6969
impl WeightInfo for () {
7070
// Storage: AvnOffenceHandler SlashingEnabled (r:0 w:1)
7171
fn configure_slashing() -> Weight {
72-
(15_281_000 as Weight)
73-
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
72+
(Weight::from_ref_time(15_281_000))
73+
.saturating_add(RocksDbWeight::get().writes(1))
7474
}
7575
}

pallets/avn-offence-handler/src/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ pub mod pallet {
3838
#[pallet::config]
3939
pub trait Config: frame_system::Config + session::historical::Config {
4040
/// The overarching event type.
41-
type Event: From<Event<Self>>
42-
+ Into<<Self as frame_system::Config>::Event>
43-
+ IsType<<Self as frame_system::Config>::Event>;
41+
type RuntimeEvent: From<Event<Self>>
42+
+ Into<<Self as frame_system::Config>::RuntimeEvent>
43+
+ IsType<<Self as frame_system::Config>::RuntimeEvent>;
4444

4545
/// A trait responsible for punishing malicious validators
4646
type Enforcer: Enforcer<<Self as session::Config>::ValidatorId>;
@@ -82,6 +82,7 @@ pub mod pallet {
8282
#[pallet::call]
8383
impl<T: Config> Pallet<T> {
8484
#[pallet::weight(<T as pallet::Config>::WeightInfo::configure_slashing())]
85+
#[pallet::call_index(0)]
8586
pub fn configure_slashing(origin: OriginFor<T>, enabled: bool) -> DispatchResult {
8687
let _sender = ensure_root(origin)?;
8788
<SlashingEnabled<T>>::put(enabled);
@@ -108,7 +109,7 @@ impl<T: Config> OnOffenceHandler<T::AccountId, IdentificationTuple<T>, Weight> f
108109
_session: SessionIndex,
109110
_disable_strategy: DisableStrategy,
110111
) -> Weight {
111-
let mut consumed_weight: Weight = 0;
112+
let mut consumed_weight: Weight = Weight::from_ref_time(0);
112113
let mut add_db_reads_writes = |reads, writes| {
113114
consumed_weight += T::DbWeight::get().reads_writes(reads, writes);
114115
};

0 commit comments

Comments
 (0)