Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
361e0e9
first changes: new functions with tests
Dec 2, 2022
605b3f5
Merge remote-tracking branch 'origin/master' into collator-set-refactor
Dec 2, 2022
00bb9f4
changing functions to match invulnerables storage types
Dec 2, 2022
263f050
fix typo
Dec 2, 2022
2c1a139
change try get
Dec 2, 2022
68e50c7
commenting all to debug
Dec 15, 2022
a9ff708
changing way to access storage, using try mutate
Dec 16, 2022
4cfa38d
Provisioner polkadot companion (#1940)
Dec 3, 2022
c482bdb
Bump environmental from 1.1.3 to 1.1.4 (#1933)
dependabot[bot] Dec 5, 2022
8db69a8
Bump syn from 1.0.104 to 1.0.105 (#1936)
dependabot[bot] Dec 5, 2022
04e8a9e
Upgrade tokio to 1.22.0 and replace async-std with tokio (#1917)
dmitry-markin Dec 5, 2022
7e33785
add collectives-polkadot final raw chainspec (#1914)
PierreBesson Dec 6, 2022
037dae3
Companion of Substrate PR 12837 (#1944)
joao-paulo-parity Dec 6, 2022
704b334
Bump serde from 1.0.148 to 1.0.149 (#1948)
dependabot[bot] Dec 6, 2022
17e4d5c
Remove `parity-util-mem` (#1958)
mrcnski Dec 6, 2022
170491f
dependabot: Ignore rococo deps (#1963)
bkchr Dec 6, 2022
9f092ca
Bump ruby/setup-ruby from 1.120.1 to 1.127.0 (#1951)
dependabot[bot] Dec 7, 2022
699fa2b
add collective runtime upgrade to the checklist (#1966)
EgorPopelyaev Dec 7, 2022
69495db
zombienet, store node's logs as artifacts (#1969)
pepoviola Dec 8, 2022
5d31af8
Backport collective weights from v9330 to master (#1959)
gilescope Dec 8, 2022
48471f6
[Backport] version bumps from 9330 (#1956)
EgorPopelyaev Dec 8, 2022
7dff97a
[ci] new ci runners (#1967)
alvicsam Dec 8, 2022
8236d6c
[benchmarks] pr with weights (#1946) (#1971)
gilescope Dec 8, 2022
6c8bd74
Companion for paritytech/substrate#12868 (#1970)
KiChjang Dec 8, 2022
6c74fcc
Collectives runtime: add query call info api (#1976)
muharem Dec 9, 2022
7250635
Companion for paritytech/substrate#12764 (#1930)
altonen Dec 10, 2022
21f2c54
Replace the label checks using bash script by `ruled-labels` (#1576)
chevdor Dec 12, 2022
c85f97f
Description for new cumulus labels (#1879)
the-right-joyce Dec 12, 2022
e8692a3
companion for #12663 jsonrpsee v0.16 (#1905)
niklasad1 Dec 12, 2022
7946cf6
Bump tokio from 1.22.0 to 1.23.0 (#1952)
dependabot[bot] Dec 12, 2022
da93115
add test onto statemint as well as statemine now (#1954) (#1955)
gilescope Dec 12, 2022
20195ef
[ci] use external repo for check-labels (#1985)
alvicsam Dec 13, 2022
14b466e
Introduce migrations for inactive balances (#1943)
gavofyork Dec 13, 2022
f34cdfd
Collectives integration tests (#1979)
muharem Dec 13, 2022
50e18d0
[ci] Add variable to disable selected jobs (#1986)
alvicsam Dec 13, 2022
ebead04
Companion for substrate#12845 (#1960)
agryaznov Dec 13, 2022
16e144b
[ci] small fix for job switcher (#1990)
alvicsam Dec 14, 2022
f5f980d
Allow to specify multiple relay chain RPC urls for collator node (#1880)
skunert Dec 15, 2022
d06598d
companion for try-runtime revamp (#1997)
kianenigma Dec 15, 2022
f236468
Bump serde from 1.0.149 to 1.0.150 (#1987)
dependabot[bot] Dec 15, 2022
a2b37a0
Remove integration tests that are covered by zombienet (#1998)
skunert Dec 15, 2022
5fd7502
Bump scale-info from 2.3.0 to 2.3.1 (#1978)
dependabot[bot] Dec 16, 2022
7190b61
Bump toml from 0.5.9 to 0.5.10 (#1995)
dependabot[bot] Dec 16, 2022
557b1a0
Bump serde from 1.0.150 to 1.0.151 (#2001)
dependabot[bot] Dec 16, 2022
d75030b
Bump quote from 1.0.21 to 1.0.23 (#2003)
dependabot[bot] Dec 20, 2022
dac1e92
Bump dyn-clone from 1.0.9 to 1.0.10 (#2005)
dependabot[bot] Dec 20, 2022
2556106
Bump thiserror from 1.0.37 to 1.0.38 (#2004)
dependabot[bot] Dec 20, 2022
f0b7120
Limit number of blocks per level (2nd attempt) (#1559)
davxy Dec 20, 2022
d3c7727
Expect less chaos: use explicit call indices (#1984)
gilescope Dec 20, 2022
dcb48b2
BlockId removal: refactor: HeaderBackend::header (#1977)
michalkucharczyk Dec 20, 2022
959e2d9
Bridge hub kusama fine-tuning before release (#1999)
bkontur Dec 21, 2022
fe1c3ff
Bump syn from 1.0.105 to 1.0.107 (#2008)
dependabot[bot] Dec 21, 2022
fd036cb
Bump proc-macro2 from 1.0.47 to 1.0.49 (#2010)
dependabot[bot] Dec 21, 2022
3cbf383
BlockId removal: refactor: HeaderBackend::status (#2007)
michalkucharczyk Dec 21, 2022
30fd49d
Companion for Substrate 12307 (#1947)
Dinonard Dec 21, 2022
3e76484
Bump serde_json from 1.0.89 to 1.0.91 (#2009)
dependabot[bot] Dec 21, 2022
5f9c08c
Companion: Accept Kusama StakingAdmin origin (#1865)
muharem Dec 22, 2022
825789c
Alliance: remove veto weight func (#2030)
muharem Dec 22, 2022
521b804
Bump clap from 4.0.29 to 4.0.32 (#2032)
dependabot[bot] Dec 22, 2022
66c9e6d
Bump async-trait from 0.1.59 to 0.1.60 (#2024)
dependabot[bot] Dec 23, 2022
338710e
Collectives parachain integration tests update (#2036)
muharem Dec 23, 2022
d62975d
Bump serde from 1.0.151 to 1.0.152 (#2045)
dependabot[bot] Dec 28, 2022
c2f4cae
Backport weights from 9360 (#2038)
EgorPopelyaev Dec 29, 2022
9adb836
Bump secp256k1 from 0.24.0 to 0.24.2 (#1973)
dependabot[bot] Dec 30, 2022
c10d9b1
BlockId removal: refactor: BlockBackend::block|block_status (#2041)
michalkucharczyk Jan 2, 2023
7260a47
remove 9330 migrations from statemint series (#2031) (#2039)
EgorPopelyaev Jan 5, 2023
a54620a
Backport version bumps from 9360 (#2037)
EgorPopelyaev Jan 5, 2023
d6f63d4
Co #6498: Selectable on-runtime-upgrade checks (#2057)
ggwpez Jan 5, 2023
a77b7be
upgrade libp2p to 0.50.0 (#2056)
melekes Jan 5, 2023
ea2aa61
NFTs 2.0 on Westmint (#2058)
jsidorenko Jan 6, 2023
27d4b17
Bump assert_cmd from 2.0.5 to 2.0.7 (#2066)
dependabot[bot] Jan 7, 2023
c7047dd
Remove the `RelaychainClient` trait (#2068)
bkchr Jan 9, 2023
96c9abe
Bump tokio from 1.23.0 to 1.24.1 (#2065)
dependabot[bot] Jan 9, 2023
de9e608
Refactor `validate_block` (#2069)
bkchr Jan 10, 2023
a84a5e0
Bump ruby/setup-ruby from 1.127.0 to 1.133.2 (#2075)
dependabot[bot] Jan 11, 2023
41ca7e9
Bump JasonEtco/create-an-issue from 2.6.0 to 2.9.1 (#2042)
dependabot[bot] Jan 11, 2023
784c801
Use primitives reexported from `polkadot_primitives` crate root (#2067)
s0me0ne-unkn0wn Jan 11, 2023
9ba9c06
remove update-parachain-template (#2077)
joao-paulo-parity Jan 11, 2023
bdd30b5
Minor update to Readme - Statemint section (#2078)
DrW3RK Jan 11, 2023
11b8033
Remove old migrations (#2040)
gavofyork Jan 11, 2023
1644737
BHK + BH-Westend release backport (#2083)
bkontur Jan 13, 2023
4073d52
XCM v3 Companion (#697)
gavofyork Jan 17, 2023
542f2f3
rebase
vieira-giulia Jan 17, 2023
64894b9
add invulnerable, seems to be working now. Used index 5, maybe this n…
vieira-giulia Jan 19, 2023
c8fd0a6
Merge branch 'master' into collator-set-refactor
vieira-giulia Jan 23, 2023
ebf4617
remove invulnerable
vieira-giulia Jan 23, 2023
13d8924
trying to add weights and benchmarks so this thing can compile and i …
vieira-giulia Jan 24, 2023
9d62399
changing storage access
vieira-giulia Jan 25, 2023
32641af
changing retain to remove
vieira-giulia Jan 25, 2023
a677a07
fix benchmarks
vieira-giulia Jan 25, 2023
35b91fe
adding sort to invulnerables lists
vieira-giulia Jan 25, 2023
e03c8a8
Merge remote-tracking branch 'origin/master' into collator-set-refactor
Jan 25, 2023
8f01439
starting to write tests
vieira-giulia Jan 25, 2023
6ef5197
Merge remote-tracking branch 'origin/master' into collator-set-refactor
vieira-giulia Jan 31, 2023
2b34806
tests
vieira-giulia Feb 8, 2023
996d872
tests
vieira-giulia Feb 9, 2023
0bc89b7
test
vieira-giulia Feb 9, 2023
445425d
Merge remote-tracking branch 'origin/master' into collator-set-refactor
vieira-giulia Feb 9, 2023
42a99b5
test
vieira-giulia Feb 9, 2023
f5032fe
add invulnerable test
vieira-giulia Feb 9, 2023
7a3b7f0
remove invulnerable test
vieira-giulia Feb 9, 2023
19e6e78
removing validator key check for removing invulnerable as this seems …
vieira-giulia Feb 9, 2023
5c2c8b4
delete sort in remove
vieira-giulia Feb 9, 2023
85cc1a8
Merge remote-tracking branch 'origin/master' into collator-set-refactor
vieira-giulia Feb 9, 2023
4eb351a
Merge branch 'master' into collator-set-refactor
vieira-giulia Mar 6, 2023
97330fe
adding weights to bridge hub
vieira-giulia Mar 6, 2023
c74b760
updating syntax
vieira-giulia Mar 6, 2023
1d6e56e
marking weights files to add after benchmarks
vieira-giulia Mar 6, 2023
e6a6d49
Merge branch 'master' into collator-set-refactor
vieira-giulia Mar 6, 2023
0d4ec9c
changing benchmarks so it works somehow
vieira-giulia Mar 6, 2023
9302733
trying to figure out what is wrong with benchmarks
vieira-giulia Mar 7, 2023
2ece3fa
cargo fmt
vieira-giulia Mar 7, 2023
37d8f50
cargo update
vieira-giulia Mar 7, 2023
c2565ec
merge master
vieira-giulia Mar 7, 2023
ddfb569
reset cargo lock to same as master
vieira-giulia Mar 7, 2023
e3dfc72
remove useless print
vieira-giulia Mar 9, 2023
e53007a
Update pallets/collator-selection/src/lib.rs
vieira-giulia Mar 10, 2023
bd6aab5
Bump wasmtime from 6.0.0 to 6.0.1 (#2296)
dependabot[bot] Mar 9, 2023
65bc3b4
Bump all runtimes to 9381
chevdor Mar 8, 2023
fd5786a
XCM: Use matcher API in DenyReserveAssetTransferToRelay (#2290)
KiChjang Mar 10, 2023
4fb7fa6
Cleanup dependencies + dead code (#2302)
skunert Mar 10, 2023
0f96cfe
add amforc bootnodes (#2246)
tugytur Mar 11, 2023
92d92d4
Companion for #13482 (#2303)
jsidorenko Mar 13, 2023
0551bd5
fmt
vieira-giulia Mar 13, 2023
35b3cfa
Merge branch 'master' into collator-set-refactor
vieira-giulia Mar 13, 2023
635f798
refactor and understanding benchmark problem
vieira-giulia Apr 4, 2023
7ab5021
Merge remote-tracking branch 'origin/master' into collator-set-refactor
vieira-giulia Apr 4, 2023
4cf979a
Merge remote-tracking branch 'origin/master' into collator-set-refactor
vieira-giulia Apr 4, 2023
2c40bc0
clean
vieira-giulia Apr 4, 2023
8f05d23
fmt
vieira-giulia Apr 4, 2023
6770d3e
mocks were ordered, so changed to unsorted to really test vector sort…
vieira-giulia Apr 12, 2023
b8600d3
Merge remote-tracking branch 'origin/master' into collator-set-refactor
vieira-giulia Apr 12, 2023
f64ed26
fmt
vieira-giulia Apr 12, 2023
a461628
warn becomes error, there is no other way to set this thing but calli…
vieira-giulia Apr 12, 2023
cb0054c
fmt
vieira-giulia Apr 12, 2023
edecc98
Merge remote-tracking branch 'origin/master' into collator-set-refactor
vieira-giulia Apr 17, 2023
9536806
add migrations
vieira-giulia Apr 17, 2023
b0beafa
fmt
vieira-giulia Apr 17, 2023
3d14dbd
only one instance
vieira-giulia Apr 17, 2023
3c1ffb9
fmt
vieira-giulia Apr 17, 2023
7f1b504
call migration
vieira-giulia May 1, 2023
f4873c2
pull and migration file
vieira-giulia May 1, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add invulnerable, seems to be working now. Used index 5, maybe this n…
…eeds to change.
  • Loading branch information
vieira-giulia committed Jan 19, 2023
commit 64894b95b82247c5b696fda90072a0414c007382
62 changes: 46 additions & 16 deletions pallets/collator-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,39 +317,69 @@ pub mod pallet {
Ok(().into())
}

#[pallet::call_index(5)]
#[pallet::weight(T::WeightInfo::add_invulnerable())]
pub fn add_invulnerable(
origin: OriginFor<T>,
new: <T>::AccountId,
) -> DispatchResultWithPostInfo {
T::UpdateOrigin::ensure_origin(origin)?;

let mut bounded_invulnerables = <Invulnerables<T>>::get();
bounded_invulnerables.try_mutate(|invulnerables: BoundedVec<_, T::AccountId>| -> Result<usize, DispatchError> {
// check if invulnerable is not already in the list
if invulnerables.iter().any(|&invulnerable| invulnerable == new) {
Err(Error::<T>::AlreadyInvulnerable)?
} else {
// check if new invulnerable has associated validator key before it is added
let validator_key =

//let mut current_invulnerables = <Invulnerables<T>>::get();
let mut invulnerables = Self::invulnerables();

// ensure we don't overflow invulnerables quantity
let length = invulnerables.len();
ensure!(((length as u32)+1) < T::MaxInvulnerables::get(), Error::<T>::TooManyCandidates);

// ensure this new invulnerable is not already nomitad
ensure!(!invulnerables.contains(&new), Error::<T>::AlreadyInvulnerable);

// ensure this new invulnerable has registred a validator key
let validator_key =
T::ValidatorIdOf::convert(new.clone()).ok_or(Error::<T>::NoAssociatedValidatorId)?;
ensure!(
T::ValidatorRegistration::is_registered(&validator_key),
Error::<T>::ValidatorNotRegistered
);
// add invulnerable
invulnerables.try_push(new).map_err(|_| Error::<T>::TooManyInvulnerables)?;
Ok(invulnerables.len())
}
})?;

// add new invulnerable to invulnerables list
invulnerables.try_push(new).map_err(|_| Error::<T>::Unknown)?;

// replace invulnerables list with new invulnerable
<Invulnerables<T>>::put(&bounded_invulnerables);
// replace invulnerables list with new invulnerables list in memory
<Invulnerables<T>>::put(&invulnerables);

Self::deposit_event(Event::NewInvulnerable {
added: new,
});
Ok(().into())
//Ok(invulnerables.len())

//current_invulnerables.try_mutate(|invulnerables: BoundedVec<_, T::AccountId>| -> Result<usize, DispatchError> {
//if invulnerables.iter().any(|invulnerable| invulnerable == new) {
// Err(Error::<T>::AlreadyCandidate)?
//} else {
//T::Currency::reserve(&who, deposit)?;
//invulnerables.try_push(new).map_err(|_| Error::<T>::TooManyInvulnerables)?;
//<LastAuthoredBlock<T>>::insert(
// who.clone(),
// frame_system::Pallet::<T>::block_number() + T::KickThreshold::get(),
//);
// check if invulnerable is not already in the list
//if invulnerables.iter().any(|&invulnerable| invulnerable == new) {
// Err(Error::<T>::AlreadyInvulnerable)?
//} else {
// check if new invulnerable has associated validator key before it is added
//let validator_key =
// T::ValidatorIdOf::convert(new.clone()).ok_or(Error::<T>::NoAssociatedValidatorId)?;
//ensure!(
// T::ValidatorRegistration::is_registered(&validator_key),
// Error::<T>::ValidatorNotRegistered
//);
// add invulnerable
//Ok(invulnerables.len())
//})?;

}

// #[pallet::weight(T::WeightInfo::remove_invulnerable())]
Expand Down
100 changes: 49 additions & 51 deletions pallets/collator-selection/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,70 +64,68 @@ fn it_should_set_invulnerables() {
#[test]
fn add_invulnerable_works(){
new_test_ext().execute_with(|| {
let added = 13;
let old_set = CollatorSelection::invulnerables().clone();
let new_set = old_set.append(&added);

//let invulnerables = CollatorSelection::invulnerables().clone();
let new: 13;
// element was added to the list
assert_ok!(CollatorSelection::add_invulnerable(
RuntimeOrigin::signed(RootAccount::get()),
added.clone()
new.clone()
));

// same element cannot be added more than once
assert_noop!(CollatorSelection::add_invulnerable(
RuntimeOrigin::signed(RootAccount::get()),
added.clone()
))
//assert_noop!(CollatorSelection::add_invulnerable(
// RuntimeOrigin::signed(RootAccount::get()),
// added.clone()
//))

// added element was correct
assert_eq!(CollatorSelection::invulnerables(), new_set);
//assert_eq!(CollatorSelection::invulnerables(), new_set);

// cannot set with non-root
assert_noop!(
CollatorSelection::add_invulnerable(RuntimeOrigin::signed(1), added.clone()),
BadOrigin
);
//assert_noop!(
// CollatorSelection::add_invulnerable(RuntimeOrigin::signed(1), added.clone()),
// BadOrigin
//);

// cannot add invulnerable without associated validator keys
let invulnerable = 7;
assert_noop!(
CollatorSelection::add_invulnerable(
RuntimeOrigin::signed(RootAccount::get()),
invulnerable.clone()
),
Error::<Test>::ValidatorNotRegistered
);
//let invulnerable = 7;
//assert_noop!(
// CollatorSelection::add_invulnerable(
// RuntimeOrigin::signed(RootAccount::get()),
// invulnerable.clone()
// ),
// Error::<Test>::ValidatorNotRegistered
//);
});
}

#[test]
fn remove_invulnerable_works(){
new_test_ext().execute_with(|| {
let to_remove = CollatorSelection::invulnerables().clone().first();
let old_set = CollatorSelection::invulnerables().clone();
let new_set = old_set::remove(to_remove);

// element was removed from the list
assert_ok!(CollatorSelection::remove_invulnerable(
RuntimeOrigin::signed(RootAccount::get()),
to_remove.clone()
));

// element cannot be removed more than once from the list
assert_noop!(CollatorSelection::remove_invulnerables(
RuntimeOrigin::signed(RootAccount::get()),
to_remove.clone()
));

// element removed was correct
assert_eq!(CollatorSelection::invulnerables(), new_set);

// cannot set with non-root
assert_noop!(
CollatorSelection::remove_invulnerable(RuntimeOrigin::signed(1), to_remove.clone()),
BadOrigin
);
//#[test]
//fn remove_invulnerable_works(){
// new_test_ext().execute_with(|| {
// let to_remove = CollatorSelection::invulnerables().clone().first();
// let old_set = CollatorSelection::invulnerables().clone();
// let new_set = old_set::remove(to_remove);
//
// // element was removed from the list
// assert_ok!(CollatorSelection::remove_invulnerable(
// RuntimeOrigin::signed(RootAccount::get()),
// to_remove.clone()
// ));
//
// // element cannot be removed more than once from the list
// assert_noop!(CollatorSelection::remove_invulnerables(
// RuntimeOrigin::signed(RootAccount::get()),
// to_remove.clone()
// ));
//
// // element removed was correct
// assert_eq!(CollatorSelection::invulnerables(), new_set);
//
// // cannot set with non-root
// assert_noop!(
// CollatorSelection::remove_invulnerable(RuntimeOrigin::signed(1), to_remove.clone()),
// BadOrigin
// );

// cannot remove invulnerables still with associated validator keys
//let invulnerable = CollatorSelection::invulnerables().clone().last();
Expand All @@ -138,8 +136,8 @@ fn remove_invulnerable_works(){
// ),
// Error::<Test>::ValidatorStillRegistered
//);
});
}
// });
//}

#[test]
fn set_desired_candidates_works() {
Expand Down