Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 2 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ clippy:
stage: test
timeout: 1 hours
script:
- rustup component add clippy --toolchain nightly
- cargo +nightly clippy --all-features --all-targets --locked -- -D warnings
- cargo clippy --all-features --all-targets --locked -- -D warnings

fmt:
# Corresponds to paritytech/ci-linux:production at the time of this PR
Expand All @@ -19,8 +18,7 @@ fmt:
stage: test
timeout: 1 hours
script:
- rustup component add rustfmt --toolchain nightly
- cargo +nightly fmt -- --check
- cargo fmt -- --check

test:
# Corresponds to paritytech/ci-linux:production at the time of this PR
Expand Down
2 changes: 1 addition & 1 deletion .maintain/srtool.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM docker.io/library/ubuntu:22.04
LABEL maintainer "chevdor@gmail.com"
LABEL description="This image contains tools for Substrate blockchains runtimes."

ARG RUSTC_VERSION="1.62.0"
ARG RUSTC_VERSION="1.64.0"
ENV RUSTC_VERSION=$RUSTC_VERSION
ENV DOCKER_IMAGE="paritytech/srtool"
ENV PROFILE=release
Expand Down
2 changes: 0 additions & 2 deletions crates/assets/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cargo-features = ["workspace-inheritance"]

[package]
authors.workspace = true
documentation.workspace = true
Expand Down
2 changes: 0 additions & 2 deletions nodes/parachain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cargo-features = ["workspace-inheritance"]

[package]
authors.workspace = true
documentation.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion nodes/parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ pub fn run() -> Result<()> {
runner.run_node_until_exit(|config| async move {
let hwbench = if !cli.no_hardware_benchmarks {
config.database.path().map(|database_path| {
let _ = std::fs::create_dir_all(&database_path);
let _ = std::fs::create_dir_all(database_path);
sc_sysinfo::gather_hwbench(Some(database_path))
})
} else {
Expand Down
2 changes: 0 additions & 2 deletions nodes/standalone/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cargo-features = ["workspace-inheritance"]

[package]
authors.workspace = true
documentation.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion nodes/standalone/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub fn create_benchmark_extrinsic(
let period = runtime::BlockHashCount::get()
.checked_next_power_of_two()
.map(|c| c / 2)
.unwrap_or(2) as u64;
.unwrap_or(2);
let extra: runtime::SignedExtra = (
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
Expand Down
2 changes: 0 additions & 2 deletions pallets/attestation/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cargo-features = ["workspace-inheritance"]

[package]
authors.workspace = true
documentation.workspace = true
Expand Down
12 changes: 6 additions & 6 deletions pallets/attestation/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ benchmarks! {
let claim_hash: T::Hash = T::Hashing::hash(b"claim");
let ctype_hash: T::Hash = T::Hash::default();

ctype::Ctypes::<T>::insert(&ctype_hash, attester.clone());
ctype::Ctypes::<T>::insert(ctype_hash, attester.clone());
<T as Config>::Currency::make_free_balance_be(&sender, <T as Config>::Deposit::get() + <T as Config>::Deposit::get());

let origin = <T as Config>::EnsureOrigin::generate_origin(sender.clone(), attester.clone());
Expand All @@ -66,7 +66,7 @@ benchmarks! {
let claim_hash: T::Hash = T::Hashing::hash(b"claim");
let ctype_hash: T::Hash = T::Hash::default();

ctype::Ctypes::<T>::insert(&ctype_hash, attester.clone());
ctype::Ctypes::<T>::insert(ctype_hash, attester.clone());
<T as Config>::Currency::make_free_balance_be(&sender, <T as Config>::Deposit::get() + <T as Config>::Deposit::get());

let origin = <T as Config>::EnsureOrigin::generate_origin(sender.clone(), attester.clone());
Expand All @@ -92,7 +92,7 @@ benchmarks! {
let claim_hash: T::Hash = T::Hashing::hash(b"claim");
let ctype_hash: T::Hash = T::Hash::default();

ctype::Ctypes::<T>::insert(&ctype_hash, attester.clone());
ctype::Ctypes::<T>::insert(ctype_hash, attester.clone());
<T as Config>::Currency::make_free_balance_be(&sender, <T as Config>::Deposit::get() + <T as Config>::Deposit::get());

let origin = <T as Config>::EnsureOrigin::generate_origin(sender.clone(), attester.clone());
Expand All @@ -109,7 +109,7 @@ benchmarks! {
let claim_hash: T::Hash = T::Hashing::hash(b"claim");
let ctype_hash: T::Hash = T::Hash::default();

ctype::Ctypes::<T>::insert(&ctype_hash, attester.clone());
ctype::Ctypes::<T>::insert(ctype_hash, attester.clone());
<T as Config>::Currency::make_free_balance_be(&sender, <T as Config>::Deposit::get() + <T as Config>::Deposit::get());

let origin = <T as Config>::EnsureOrigin::generate_origin(sender.clone(), attester);
Expand All @@ -127,7 +127,7 @@ benchmarks! {
let claim_hash: T::Hash = T::Hashing::hash(b"claim");
let ctype_hash: T::Hash = T::Hash::default();

ctype::Ctypes::<T>::insert(&ctype_hash, attester.clone());
ctype::Ctypes::<T>::insert(ctype_hash, attester.clone());
<T as Config>::Currency::make_free_balance_be(&deposit_owner_old, <T as Config>::Deposit::get() + <T as Config>::Deposit::get());
<T as Config>::Currency::make_free_balance_be(&deposit_owner_new, <T as Config>::Deposit::get() + <T as Config>::Deposit::get());

Expand All @@ -154,7 +154,7 @@ benchmarks! {
let claim_hash: T::Hash = T::Hashing::hash(b"claim");
let ctype_hash: T::Hash = T::Hash::default();

ctype::Ctypes::<T>::insert(&ctype_hash, attester.clone());
ctype::Ctypes::<T>::insert(ctype_hash, attester.clone());
<T as Config>::Currency::make_free_balance_be(&deposit_owner, <T as Config>::Deposit::get() + <T as Config>::Deposit::get());

let origin = <T as Config>::EnsureOrigin::generate_origin(deposit_owner.clone(), attester.clone());
Expand Down
20 changes: 10 additions & 10 deletions pallets/attestation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ pub mod pallet {
let deposit_amount = <T as Config>::Deposit::get();

ensure!(
ctype::Ctypes::<T>::contains_key(&ctype_hash),
ctype::Ctypes::<T>::contains_key(ctype_hash),
ctype::Error::<T>::CTypeNotFound
);
ensure!(
!Attestations::<T>::contains_key(&claim_hash),
!Attestations::<T>::contains_key(claim_hash),
Error::<T>::AlreadyAttested
);

Expand All @@ -268,7 +268,7 @@ pub mod pallet {
log::debug!("insert Attestation");

Attestations::<T>::insert(
&claim_hash,
claim_hash,
AttestationDetails {
ctype_hash,
attester: who.clone(),
Expand Down Expand Up @@ -315,7 +315,7 @@ pub mod pallet {
let source = <T as Config>::EnsureOrigin::ensure_origin(origin)?;
let who = source.subject();

let attestation = Attestations::<T>::get(&claim_hash).ok_or(Error::<T>::AttestationNotFound)?;
let attestation = Attestations::<T>::get(claim_hash).ok_or(Error::<T>::AttestationNotFound)?;

ensure!(!attestation.revoked, Error::<T>::AlreadyRevoked);

Expand All @@ -333,7 +333,7 @@ pub mod pallet {

log::debug!("revoking Attestation");
Attestations::<T>::insert(
&claim_hash,
claim_hash,
AttestationDetails {
revoked: true,
..attestation
Expand Down Expand Up @@ -374,7 +374,7 @@ pub mod pallet {
let source = <T as Config>::EnsureOrigin::ensure_origin(origin)?;
let who = source.subject();

let attestation = Attestations::<T>::get(&claim_hash).ok_or(Error::<T>::AttestationNotFound)?;
let attestation = Attestations::<T>::get(claim_hash).ok_or(Error::<T>::AttestationNotFound)?;

if attestation.attester != who {
let attestation_auth_id = attestation.authorization_id.as_ref().ok_or(Error::<T>::Unauthorized)?;
Expand Down Expand Up @@ -408,7 +408,7 @@ pub mod pallet {
#[pallet::weight(<T as pallet::Config>::WeightInfo::reclaim_deposit())]
pub fn reclaim_deposit(origin: OriginFor<T>, claim_hash: ClaimHashOf<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
let attestation = Attestations::<T>::get(&claim_hash).ok_or(Error::<T>::AttestationNotFound)?;
let attestation = Attestations::<T>::get(claim_hash).ok_or(Error::<T>::AttestationNotFound)?;

ensure!(attestation.deposit.owner == who, Error::<T>::Unauthorized);

Expand All @@ -435,7 +435,7 @@ pub mod pallet {
let subject = source.subject();
let sender = source.sender();

let attestation = Attestations::<T>::get(&claim_hash).ok_or(Error::<T>::AttestationNotFound)?;
let attestation = Attestations::<T>::get(claim_hash).ok_or(Error::<T>::AttestationNotFound)?;
ensure!(attestation.attester == subject, Error::<T>::Unauthorized);

AttestationStorageDepositCollector::<T>::change_deposit_owner(&claim_hash, sender)?;
Expand All @@ -450,7 +450,7 @@ pub mod pallet {
pub fn update_deposit(origin: OriginFor<T>, claim_hash: ClaimHashOf<T>) -> DispatchResult {
let sender = ensure_signed(origin)?;

let attestation = Attestations::<T>::get(&claim_hash).ok_or(Error::<T>::AttestationNotFound)?;
let attestation = Attestations::<T>::get(claim_hash).ok_or(Error::<T>::AttestationNotFound)?;
ensure!(attestation.deposit.owner == sender, Error::<T>::Unauthorized);

AttestationStorageDepositCollector::<T>::update_deposit(&claim_hash)?;
Expand All @@ -462,7 +462,7 @@ pub mod pallet {
impl<T: Config> Pallet<T> {
fn remove_attestation(attestation: AttestationDetails<T>, claim_hash: ClaimHashOf<T>) {
kilt_support::free_deposit::<AccountIdOf<T>, CurrencyOf<T>>(&attestation.deposit);
Attestations::<T>::remove(&claim_hash);
Attestations::<T>::remove(claim_hash);
if let Some(authorization_id) = &attestation.authorization_id {
ExternalAttestations::<T>::remove(authorization_id, claim_hash);
}
Expand Down
2 changes: 1 addition & 1 deletion pallets/attestation/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub fn insert_attestation<T: Config>(claim_hash: ClaimHashOf<T>, details: Attest
)
.expect("Should have balance");

crate::Attestations::<T>::insert(&claim_hash, details.clone());
crate::Attestations::<T>::insert(claim_hash, details.clone());
if let Some(delegation_id) = details.authorization_id.as_ref() {
crate::ExternalAttestations::<T>::insert(delegation_id, claim_hash, true)
}
Expand Down
2 changes: 0 additions & 2 deletions pallets/ctype/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cargo-features = ["workspace-inheritance"]

[package]
authors.workspace = true
documentation.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion pallets/ctype/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ benchmarks! {

}: _<T::Origin>(origin, ctype)
verify {
let stored_ctype_creator: T::CtypeCreatorId = Ctypes::<T>::get(&ctype_hash).expect("CType hash should be present on chain.");
let stored_ctype_creator: T::CtypeCreatorId = Ctypes::<T>::get(ctype_hash).expect("CType hash should be present on chain.");

// Verify the CType has the right owner
assert_eq!(stored_ctype_creator, did);
Expand Down
4 changes: 2 additions & 2 deletions pallets/ctype/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub mod pallet {

let hash = <T as frame_system::Config>::Hashing::hash(&ctype[..]);

ensure!(!Ctypes::<T>::contains_key(&hash), Error::<T>::CTypeAlreadyExists);
ensure!(!Ctypes::<T>::contains_key(hash), Error::<T>::CTypeAlreadyExists);

// *** No Fail except during withdraw beyond this point ***

Expand All @@ -176,7 +176,7 @@ pub mod pallet {

T::FeeCollector::on_unbalanced(imbalance);
log::debug!("Creating CType with hash {:?} and creator {:?}", hash, creator);
Ctypes::<T>::insert(&hash, creator.clone());
Ctypes::<T>::insert(hash, creator.clone());

Self::deposit_event(Event::CTypeCreated(creator, hash));

Expand Down
2 changes: 0 additions & 2 deletions pallets/delegation/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cargo-features = ["workspace-inheritance"]

[package]
authors.workspace = true
documentation.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions pallets/delegation/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ where
<T as Config>::Currency::minimum_balance() + <T as Config>::Deposit::get() + <T as Config>::Deposit::get(),
);

ctype::Ctypes::<T>::insert(&ctype_hash, T::CtypeCreatorId::from(root_acc.clone()));
ctype::Ctypes::<T>::insert(ctype_hash, T::CtypeCreatorId::from(root_acc.clone()));

Pallet::<T>::create_hierarchy(
<T as Config>::EnsureOrigin::generate_origin(sender, root_acc.clone()),
Expand Down Expand Up @@ -148,7 +148,7 @@ where
)?;

// only return first leaf
first_leaf = first_leaf.or(Some((delegation_acc_public, delegation_acc_id, delegation_id)));
first_leaf = first_leaf.or_else(|| Some((delegation_acc_public, delegation_acc_id, delegation_id)));
}

let (leaf_acc_public, leaf_acc_id, leaf_id) =
Expand Down Expand Up @@ -234,7 +234,7 @@ benchmarks! {
let creator: T::DelegationEntityId = account("creator", 0, SEED);
let ctype = <T::Hash as Default>::default();
let delegation = generate_delegation_id::<T>(0);
ctype::Ctypes::<T>::insert(&ctype, <T as ctype::Config>::CtypeCreatorId::from(creator.clone()));
ctype::Ctypes::<T>::insert(ctype, <T as ctype::Config>::CtypeCreatorId::from(creator.clone()));
<T as Config>::Currency::make_free_balance_be(
&sender,
<T as Config>::Currency::minimum_balance() + <T as Config>::Deposit::get(),
Expand Down
24 changes: 12 additions & 12 deletions pallets/delegation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,12 @@ pub mod pallet {
let creator = source.subject();

ensure!(
!<DelegationHierarchies<T>>::contains_key(&root_node_id),
!<DelegationHierarchies<T>>::contains_key(root_node_id),
Error::<T>::HierarchyAlreadyExists
);

ensure!(
<ctype::Ctypes<T>>::contains_key(&ctype_hash),
<ctype::Ctypes<T>>::contains_key(ctype_hash),
<ctype::Error<T>>::CTypeNotFound
);

Expand Down Expand Up @@ -397,11 +397,11 @@ pub mod pallet {
let delegator = source.subject();

ensure!(
!<DelegationNodes<T>>::contains_key(&delegation_id),
!<DelegationNodes<T>>::contains_key(delegation_id),
Error::<T>::DelegationAlreadyExists
);

let parent_node = <DelegationNodes<T>>::get(&parent_id).ok_or(Error::<T>::ParentDelegationNotFound)?;
let parent_node = <DelegationNodes<T>>::get(parent_id).ok_or(Error::<T>::ParentDelegationNotFound)?;
let hierarchy_root_id = parent_node.hierarchy_root_id;

// Calculate the hash root
Expand Down Expand Up @@ -501,7 +501,7 @@ pub mod pallet {
let invoker = <T as Config>::EnsureOrigin::ensure_origin(origin)?.subject();

ensure!(
<DelegationNodes<T>>::contains_key(&delegation_id),
<DelegationNodes<T>>::contains_key(delegation_id),
Error::<T>::DelegationNotFound
);

Expand All @@ -525,7 +525,7 @@ pub mod pallet {
let (revocation_checks, _) = Self::revoke(&delegation_id, &invoker, max_revocations.saturating_add(1))?;

// If the revoked node is a root node, emit also a HierarchyRevoked event.
if DelegationHierarchies::<T>::contains_key(&delegation_id) {
if DelegationHierarchies::<T>::contains_key(delegation_id) {
Self::deposit_event(Event::HierarchyRevoked(invoker, delegation_id));
}

Expand Down Expand Up @@ -574,7 +574,7 @@ pub mod pallet {
let source = <T as Config>::EnsureOrigin::ensure_origin(origin)?;
let invoker = source.subject();

let delegation = DelegationNodes::<T>::get(&delegation_id).ok_or(Error::<T>::DelegationNotFound)?;
let delegation = DelegationNodes::<T>::get(delegation_id).ok_or(Error::<T>::DelegationNotFound)?;

// Node can only be removed by owner of the node, not the parent or another
// ancestor
Expand All @@ -589,7 +589,7 @@ pub mod pallet {
let (removal_checks, _) = Self::remove(&delegation_id, max_removals.saturating_add(1))?;

// If the removed node is a root node, emit also a HierarchyRemoved event.
if DelegationHierarchies::<T>::take(&delegation_id).is_some() {
if DelegationHierarchies::<T>::take(delegation_id).is_some() {
Self::deposit_event(Event::HierarchyRemoved(invoker, delegation_id));
}

Expand Down Expand Up @@ -628,7 +628,7 @@ pub mod pallet {
) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?;

let delegation = DelegationNodes::<T>::get(&delegation_id).ok_or(Error::<T>::DelegationNotFound)?;
let delegation = DelegationNodes::<T>::get(delegation_id).ok_or(Error::<T>::DelegationNotFound)?;

// Deposit can only be removed by the owner of the deposit, not the
// parent or another ancestor.
Expand All @@ -646,7 +646,7 @@ pub mod pallet {
// Delete the delegation hierarchy details, if the provided ID was for a root
// node. No event generated as we don't have information about the owner DID
// here.
DelegationHierarchies::<T>::remove(&delegation_id);
DelegationHierarchies::<T>::remove(delegation_id);

Ok(Some(<T as Config>::WeightInfo::remove_delegation(removal_checks)).into())
}
Expand All @@ -662,7 +662,7 @@ pub mod pallet {
pub fn change_deposit_owner(origin: OriginFor<T>, delegation_id: DelegationNodeIdOf<T>) -> DispatchResult {
let source = <T as Config>::EnsureOrigin::ensure_origin(origin)?;

let delegation = DelegationNodes::<T>::get(&delegation_id).ok_or(Error::<T>::DelegationNotFound)?;
let delegation = DelegationNodes::<T>::get(delegation_id).ok_or(Error::<T>::DelegationNotFound)?;

// Deposit can only be swapped by the owner of the delegation node, not the
// parent or another ancestor.
Expand All @@ -678,7 +678,7 @@ pub mod pallet {
pub fn update_deposit(origin: OriginFor<T>, delegation_id: DelegationNodeIdOf<T>) -> DispatchResult {
let sender = ensure_signed(origin)?;

let delegation = DelegationNodes::<T>::get(&delegation_id).ok_or(Error::<T>::DelegationNotFound)?;
let delegation = DelegationNodes::<T>::get(delegation_id).ok_or(Error::<T>::DelegationNotFound)?;

// Deposit can only be swapped by the owner of the delegation node, not the
// parent or another ancestor.
Expand Down
2 changes: 0 additions & 2 deletions pallets/did/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cargo-features = ["workspace-inheritance"]

[package]
authors.workspace = true
documentation.workspace = true
Expand Down
Loading