Skip to content

Commit

Permalink
Aldebaran 1.1.3 (#476)
Browse files Browse the repository at this point in the history
* Added staking events (#421)

* MESH-790/ Add RPC filtering by Link type (#398)

* Misc. fixes (#416)

* Misc. fixes

* Fix

* lint

* lint

Co-authored-by: Satyam Agrawal <[email protected]>

* Batch Dispath in Utility Module (#414)

* UT added

* Update V1

* CodeReview: Remove unused elements

* UT added

* Update V1

* CodeReview: Remove unused elements

Co-authored-by: Adam Dossa <[email protected]>
Co-authored-by: poly-auto-merge[bot] <65769705+poly-auto-merge[bot]@users.noreply.github.com>

* Mesh 1040/Add reserved peer logging (#417)

* logging resered nodes

* rename peers to nodes

Co-authored-by: satyam <[email protected]>
Co-authored-by: Adam Dossa <[email protected]>

* Mesh 991/granular errors (#402)

* wip

* Added internal functions

* wired the rpc

* Added new structure

* Updated structure

* some fixes

* Added test cases

* updated schema

* fixed typo in schema

* fixed merge

Co-authored-by: Adam Dossa <[email protected]>
Co-authored-by: poly-auto-merge[bot] <65769705+poly-auto-merge[bot]@users.noreply.github.com>

* Mesh 1042/rename validator to operator (#425)

* introduced --operator as the alias for the validator

* add dev comment

* fix linting

Co-authored-by: satyam <[email protected]>
Co-authored-by: poly-auto-merge[bot] <65769705+poly-auto-merge[bot]@users.noreply.github.com>

* fix: handle optional parameters correctly (#426)

* Workaround in Committe module (#424)

* Remove unused functions

Incorrectly chosen by cherry-pick

* Mesh 1049/Allow signing keys to leave their identities (#422)

* functions for leaving an identity

* Added tests

* review comments

* bump spec_version & impl_version

* MESH-972/ Add new getDidStatus() RPC (#431)

* Remove incorrect cherry-picked code

* Mesh 1033: Transfer events (#435)

* Simplify transfer events

* Fix tests

* Remove bootnodes 4 - 10 (#436)

Co-authored-by: poly-auto-merge[bot] <65769705+poly-auto-merge[bot]@users.noreply.github.com>

* linting

* RPC to get historical pip voting by address (#433)

* Fix lock file (#440)

* Bridge batching fix (#445)

* Bump versions

* Fix fees and adjust bridge limit (#446)

* Fix for multisig refactor

* Adjust base fee from 0.01 POLYX to 1 POLYX (#448)

* Change chain_spec back to reflect genesis

* MESH-1102, MESH-1101, MESH-1100: Fix events, errors, kill_proposal and set_proposal_cool_off_period #452

* Bump versions

* fixed custodian allowance bug (#455)

* Pay with master key (#462)

* Temp pay via master key

* Fixes

* linting and version bump

* Fix CDD check

* Allow sudo / PIPs to prune old PIPs (#473)

* Allow sudo / PIPs to prune old PIPs

* Remove PipPruned

* Fix upgrade bug and bump versions

* Use root origin rather than committee origin

* Reset version for Aldebaran release

Co-authored-by: Mudit Gupta <[email protected]>
Co-authored-by: Satyam Agrawal <[email protected]>
Co-authored-by: Francisco Miguel García <[email protected]>
Co-authored-by: poly-auto-merge[bot] <65769705+poly-auto-merge[bot]@users.noreply.github.com>
Co-authored-by: satyam <[email protected]>
Co-authored-by: Jeremías Díaz <[email protected]>
Co-authored-by: Vladimir Komendantskiy <[email protected]>
  • Loading branch information
8 people authored Jul 20, 2020
1 parent 2886cb5 commit 9157660
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 9 deletions.
27 changes: 27 additions & 0 deletions pallets/pips/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,33 @@ decl_module! {
Self::prune_data(id, Self::prune_historical_pips());
}

/// An emergency stop measure to kill a proposal. Governance committee can kill
/// a proposal at any time.
#[weight = SimpleDispatchInfo::FixedOperational(100_000)]
pub fn prune_proposal(origin, id: PipId) {
T::CommitteeOrigin::try_origin(origin).map_err(|_| Error::<T>::BadOrigin)?;
// Check that the proposal is in a state valid for pruning
let proposal = Self::proposals(id).ok_or_else(|| Error::<T>::NoSuchProposal)?;
if proposal.state == ProposalState::Referendum {
// Check that the referendum is in a state valid for pruning
let referendum = Self::referendums(id).ok_or_else(|| Error::<T>::NoSuchProposal)?;
ensure!(
referendum.state == ReferendumState::Rejected ||
referendum.state == ReferendumState::Failed ||
referendum.state == ReferendumState::Executed,
Error::<T>::IncorrectReferendumState
);
} else {
ensure!(
proposal.state == ProposalState::Cancelled ||
proposal.state == ProposalState::Killed ||
proposal.state == ProposalState::Rejected,
Error::<T>::IncorrectProposalState
);
}
Self::prune_data(id, true);
}

/// Any governance committee member can fast track a proposal and turn it into a referendum
/// that will be voted on by the committee.
#[weight = SimpleDispatchInfo::FixedOperational(200_000)]
Expand Down
50 changes: 49 additions & 1 deletion pallets/runtime/common/tests/all/pips_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ fn creating_a_referendum_works_we() {
let (alice_signer, _) = make_account_with_balance(alice_acc, 300).unwrap();
let bob_acc = AccountKeyring::Bob.public();
let (bob_signer, _) = make_account_with_balance(bob_acc, 200).unwrap();
// Voting majority
let root = Origin::from(frame_system::RawOrigin::Root);

assert_ok!(Pips::propose(
alice_signer.clone(),
Expand All @@ -166,13 +168,25 @@ fn creating_a_referendum_works_we() {
None
));

// Cannot prune proposal at this stage
assert_err!(
Pips::prune_proposal(root.clone(), 0),
Error::<TestStorage>::IncorrectProposalState
);

assert_err!(
Pips::vote(bob_signer.clone(), 0, true, 50),
Error::<TestStorage>::ProposalOnCoolOffPeriod
);
fast_forward_to(101);
assert_ok!(Pips::vote(bob_signer.clone(), 0, true, 50));

// Cannot prune proposal at this stage
assert_err!(
Pips::prune_proposal(root.clone(), 0),
Error::<TestStorage>::IncorrectProposalState
);

assert_eq!(
Pips::proposal_result(0),
VotingResult {
Expand All @@ -188,6 +202,12 @@ fn creating_a_referendum_works_we() {

fast_forward_to(120);

// Cannot prune referendum at this stage
assert_err!(
Pips::prune_proposal(root.clone(), 0),
Error::<TestStorage>::IncorrectReferendumState
);

assert_eq!(
Pips::referendums(0),
Some(Referendum {
Expand Down Expand Up @@ -253,6 +273,12 @@ fn enacting_a_referendum_works_we() {

fast_forward_to(120);

// Cannot prune referendum at this stage
assert_err!(
Pips::prune_proposal(root.clone(), 0),
Error::<TestStorage>::IncorrectReferendumState
);

assert_eq!(
Pips::referendums(0),
Some(Referendum {
Expand All @@ -267,7 +293,7 @@ fn enacting_a_referendum_works_we() {
Pips::enact_referendum(bob_signer.clone(), 0),
Error::<TestStorage>::BadOrigin
);
assert_ok!(Pips::enact_referendum(root, 0));
assert_ok!(Pips::enact_referendum(root.clone(), 0));

assert_eq!(
Pips::referendums(0),
Expand All @@ -279,6 +305,12 @@ fn enacting_a_referendum_works_we() {
})
);

// Cannot prune referendum at this stage
assert_err!(
Pips::prune_proposal(root.clone(), 0),
Error::<TestStorage>::IncorrectReferendumState
);

fast_forward_to(221);

assert_eq!(
Expand All @@ -290,6 +322,13 @@ fn enacting_a_referendum_works_we() {
enactment_period: 220,
})
);

// Can now prune referendum
assert_ok!(Pips::prune_proposal(root.clone(), 0));

assert_eq!(Pips::referendums(0), None);
assert_eq!(Pips::proposals(0), None);
assert_eq!(Pips::proposal_metadata(0), None);
}

#[test]
Expand Down Expand Up @@ -668,6 +707,7 @@ fn cancel_pips_during_cool_off_period_we() {

let (alice, _) = make_account(AccountKeyring::Alice.public()).unwrap();
let (bob, _) = make_account(AccountKeyring::Bob.public()).unwrap();
let root = Origin::from(frame_system::RawOrigin::Root);

// 1. Create Pips proposals
assert_ok!(Pips::propose(
Expand All @@ -692,6 +732,14 @@ fn cancel_pips_during_cool_off_period_we() {
fast_forward_to(50);
assert_ok!(Pips::cancel_proposal(alice.clone(), 0));

// Can prune cancelled proposals
assert_ok!(Pips::prune_proposal(root.clone(), 0));

// Check proposal is pruned from storage
assert_eq!(Pips::referendums(0), None);
assert_eq!(Pips::proposals(0), None);
assert_eq!(Pips::proposal_metadata(0), None);

// 3. Try to cancel Bob's proposal after cool-off period.
fast_forward_to(101);
assert_err!(
Expand Down
6 changes: 4 additions & 2 deletions pallets/runtime/develop/src/fee_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,10 @@ fn is_auth_valid(
if let AuthorizationData::JoinIdentity(did) = auth.authorization_data {
// make sure that the auth was created by the master key of an identity with valid CDD
let master = Identity::did_records(&did).master_key;
if auth.authorized_by == Signatory::from(master) {
return check_cdd(&did);
let master_signatory = Signatory::AccountKey(master);
if auth.authorized_by == master_signatory {
let _ = check_cdd(&did)?;
return Ok(Some(master_signatory));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pallets/runtime/develop/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polymesh"),
impl_name: create_runtime_str!("polymath-polymesh"),
authoring_version: 1,
spec_version: 1007,
impl_version: 1007,
spec_version: 1008,
impl_version: 1008,
apis: RUNTIME_API_VERSIONS,
};

Expand Down
6 changes: 4 additions & 2 deletions pallets/runtime/testnet-v1/src/fee_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,10 @@ fn is_auth_valid(
if let AuthorizationData::JoinIdentity(did) = auth.authorization_data {
// make sure that the auth was created by the master key of an identity with valid CDD
let master = Identity::did_records(&did).master_key;
if auth.authorized_by == Signatory::from(master) {
return check_cdd(&did);
let master_signatory = Signatory::AccountKey(master);
if auth.authorized_by == master_signatory {
let _ = check_cdd(&did)?;
return Ok(Some(master_signatory));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pallets/runtime/testnet-v1/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polymesh"),
impl_name: create_runtime_str!("polymath-polymesh"),
authoring_version: 1,
spec_version: 1007,
impl_version: 1007,
spec_version: 1008,
impl_version: 1008,
apis: RUNTIME_API_VERSIONS,
};

Expand Down

0 comments on commit 9157660

Please sign in to comment.