Skip to content

Commit

Permalink
give explicit method indexes to all our extrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
trusch committed Jan 6, 2023
1 parent a7f7079 commit 9e9aa29
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 3 deletions.
3 changes: 1 addition & 2 deletions nodes/parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,7 @@ pub fn run() -> Result<()> {
"Compile with --features=runtime-benchmarks \
to enable storage benchmarks."
.into(),
)
.into()),
)),
#[cfg(feature = "runtime-benchmarks")]
(BenchmarkCmd::Storage(cmd), "spiritnet") => runner.sync_run(|config| {
let partials = new_partial::<spiritnet_runtime::RuntimeApi, SpiritnetRuntimeExecutor, _>(
Expand Down
2 changes: 1 addition & 1 deletion nodes/parachain/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ async fn build_relay_chain_interface(
collator_options: CollatorOptions,
hwbench: Option<sc_sysinfo::HwBench>,
) -> RelayChainResult<(Arc<(dyn RelayChainInterface + 'static)>, Option<CollatorPair>)> {
if collator_options.relay_chain_rpc_urls.len() > 0 {
if !collator_options.relay_chain_rpc_urls.is_empty() {
build_minimal_relay_chain_node(polkadot_config, task_manager, collator_options.relay_chain_rpc_urls).await
} else {
build_inprocess_relay_chain(
Expand Down
6 changes: 6 additions & 0 deletions pallets/attestation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ pub mod pallet {
/// DelegatedAttestations
/// - Writes: Attestations, (DelegatedAttestations)
/// # </weight>
#[pallet::call_index(0)]
#[pallet::weight(
<T as pallet::Config>::WeightInfo::add()
.saturating_add(authorization.as_ref().map(|ac| ac.can_attest_weight()).unwrap_or(Weight::zero()))
Expand Down Expand Up @@ -303,6 +304,7 @@ pub mod pallet {
/// - Reads per delegation step P: delegation::Delegations
/// - Writes: Attestations, DelegatedAttestations
/// # </weight>
#[pallet::call_index(1)]
#[pallet::weight(
<T as pallet::Config>::WeightInfo::revoke()
.saturating_add(authorization.as_ref().map(|ac| ac.can_revoke_weight()).unwrap_or(Weight::zero()))
Expand Down Expand Up @@ -362,6 +364,7 @@ pub mod pallet {
/// - Reads per delegation step P: delegation::Delegations
/// - Writes: Attestations, DelegatedAttestations
/// # </weight>
#[pallet::call_index(2)]
#[pallet::weight(
<T as pallet::Config>::WeightInfo::remove()
.saturating_add(authorization.as_ref().map(|ac| ac.can_remove_weight()).unwrap_or(Weight::zero()))
Expand Down Expand Up @@ -405,6 +408,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Attestations, DelegatedAttestations
/// - Writes: Attestations, DelegatedAttestations
/// # </weight>
#[pallet::call_index(3)]
#[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)?;
Expand All @@ -429,6 +433,7 @@ pub mod pallet {
///
/// The subject of the call must be the attester who issues the
/// attestation. The sender of the call will be the new deposit owner.
#[pallet::call_index(4)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::change_deposit_owner())]
pub fn change_deposit_owner(origin: OriginFor<T>, claim_hash: ClaimHashOf<T>) -> DispatchResult {
let source = <T as Config>::EnsureOrigin::ensure_origin(origin)?;
Expand All @@ -446,6 +451,7 @@ pub mod pallet {
/// Updates the deposit amount to the current deposit rate.
///
/// The sender must be the deposit owner.
#[pallet::call_index(5)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::update_deposit())]
pub fn update_deposit(origin: OriginFor<T>, claim_hash: ClaimHashOf<T>) -> DispatchResult {
let sender = ensure_signed(origin)?;
Expand Down
1 change: 1 addition & 0 deletions pallets/ctype/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ pub mod pallet {
/// - Reads: Ctypes, Balance
/// - Writes: Ctypes, Balance
/// # </weight>
#[pallet::call_index(0)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::add(ctype.len().saturated_into()))]
pub fn add(origin: OriginFor<T>, ctype: Vec<u8>) -> DispatchResult {
let source = <T as Config>::EnsureOrigin::ensure_origin(origin)?;
Expand Down
7 changes: 7 additions & 0 deletions pallets/delegation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Roots, CTypes
/// - Writes: Roots
/// # </weight>
#[pallet::call_index(0)]
#[pallet::weight(<T as Config>::WeightInfo::create_hierarchy())]
pub fn create_hierarchy(
origin: OriginFor<T>,
Expand Down Expand Up @@ -380,6 +381,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Roots, Delegations
/// - Writes: Delegations
/// # </weight>
#[pallet::call_index(1)]
#[pallet::weight(
<T as Config>::WeightInfo::add_delegation()
.saturating_add(DelegationSignatureVerificationOf::<T>::weight(T::Hash::max_encoded_len()))
Expand Down Expand Up @@ -489,6 +491,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Roots, C * Delegations, C * Children.
/// - Writes: Roots, C * Delegations
/// # </weight>
#[pallet::call_index(2)]
#[pallet::weight(
<T as Config>::WeightInfo::revoke_delegation_root_child(*max_revocations, *max_parent_checks)
.max(<T as Config>::WeightInfo::revoke_delegation_leaf(*max_revocations, *max_parent_checks)))]
Expand Down Expand Up @@ -565,6 +568,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Roots, C * Delegations, C * Children.
/// - Writes: Roots, 2 * C * Delegations
/// # </weight>
#[pallet::call_index(3)]
#[pallet::weight(<T as Config>::WeightInfo::remove_delegation(*max_removals))]
pub fn remove_delegation(
origin: OriginFor<T>,
Expand Down Expand Up @@ -620,6 +624,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Roots, C * Delegations, C * Children.
/// - Writes: Roots, 2 * C * Delegations
/// # </weight>
#[pallet::call_index(4)]
#[pallet::weight(<T as Config>::WeightInfo::reclaim_deposit(*max_removals))]
pub fn reclaim_deposit(
origin: OriginFor<T>,
Expand Down Expand Up @@ -658,6 +663,7 @@ pub mod pallet {
///
/// The subject of the call must be the owner of the delegation node.
/// The sender of the call will be the new deposit owner.
#[pallet::call_index(5)]
#[pallet::weight(<T as Config>::WeightInfo::change_deposit_owner())]
pub fn change_deposit_owner(origin: OriginFor<T>, delegation_id: DelegationNodeIdOf<T>) -> DispatchResult {
let source = <T as Config>::EnsureOrigin::ensure_origin(origin)?;
Expand All @@ -674,6 +680,7 @@ pub mod pallet {
/// Updates the deposit amount to the current deposit rate.
///
/// The sender must be the deposit owner.
#[pallet::call_index(6)]
#[pallet::weight(<T as Config>::WeightInfo::update_deposit())]
pub fn update_deposit(origin: OriginFor<T>, delegation_id: DelegationNodeIdOf<T>) -> DispatchResult {
let sender = ensure_signed(origin)?;
Expand Down
15 changes: 15 additions & 0 deletions pallets/did/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ pub mod pallet {
/// - Writes: Did (with K new key agreement keys), ServiceEndpoints
/// (with N new service endpoints), DidEndpointsCount
/// # </weight>
#[pallet::call_index(0)]
#[pallet::weight({
let new_key_agreement_keys = details.new_key_agreement_keys.len().saturated_into::<u32>();
// We only consider the number of new endpoints.
Expand Down Expand Up @@ -601,6 +602,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Did
/// - Writes: Did
/// # </weight>
#[pallet::call_index(1)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::set_ed25519_authentication_key().max(<T as pallet::Config>::WeightInfo::set_sr25519_authentication_key()).max(<T as pallet::Config>::WeightInfo::set_ecdsa_authentication_key()))]
pub fn set_authentication_key(origin: OriginFor<T>, new_key: DidVerificationKey) -> DispatchResult {
let did_subject = T::EnsureOrigin::ensure_origin(origin)?.subject();
Expand Down Expand Up @@ -641,6 +643,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Did
/// - Writes: Did
/// # </weight>
#[pallet::call_index(2)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::set_ed25519_delegation_key().max(<T as pallet::Config>::WeightInfo::set_sr25519_delegation_key()).max(<T as pallet::Config>::WeightInfo::set_ecdsa_delegation_key()))]
pub fn set_delegation_key(origin: OriginFor<T>, new_key: DidVerificationKey) -> DispatchResult {
let did_subject = T::EnsureOrigin::ensure_origin(origin)?.subject();
Expand Down Expand Up @@ -675,6 +678,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Did
/// - Writes: Did
/// # </weight>
#[pallet::call_index(3)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::remove_ed25519_delegation_key().max(<T as pallet::Config>::WeightInfo::remove_sr25519_delegation_key()).max(<T as pallet::Config>::WeightInfo::remove_ecdsa_delegation_key()))]
pub fn remove_delegation_key(origin: OriginFor<T>) -> DispatchResult {
let did_subject = T::EnsureOrigin::ensure_origin(origin)?.subject();
Expand Down Expand Up @@ -708,6 +712,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Did
/// - Writes: Did
/// # </weight>
#[pallet::call_index(4)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::set_ed25519_attestation_key().max(<T as pallet::Config>::WeightInfo::set_sr25519_attestation_key()).max(<T as pallet::Config>::WeightInfo::set_ecdsa_attestation_key()))]
pub fn set_attestation_key(origin: OriginFor<T>, new_key: DidVerificationKey) -> DispatchResult {
let did_subject = T::EnsureOrigin::ensure_origin(origin)?.subject();
Expand Down Expand Up @@ -742,6 +747,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Did
/// - Writes: Did
/// # </weight>
#[pallet::call_index(5)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::remove_ed25519_attestation_key().max(<T as pallet::Config>::WeightInfo::remove_sr25519_attestation_key()).max(<T as pallet::Config>::WeightInfo::remove_ecdsa_attestation_key()))]
pub fn remove_attestation_key(origin: OriginFor<T>) -> DispatchResult {
let did_subject = T::EnsureOrigin::ensure_origin(origin)?.subject();
Expand Down Expand Up @@ -773,6 +779,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Did
/// - Writes: Did
/// # </weight>
#[pallet::call_index(6)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::add_ed25519_key_agreement_key().max(<T as pallet::Config>::WeightInfo::add_sr25519_key_agreement_key()).max(<T as pallet::Config>::WeightInfo::add_ecdsa_key_agreement_key()))]
pub fn add_key_agreement_key(origin: OriginFor<T>, new_key: DidEncryptionKey) -> DispatchResult {
let did_subject = T::EnsureOrigin::ensure_origin(origin)?.subject();
Expand Down Expand Up @@ -805,6 +812,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Did
/// - Writes: Did
/// # </weight>
#[pallet::call_index(7)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::remove_ed25519_key_agreement_key().max(<T as pallet::Config>::WeightInfo::remove_sr25519_key_agreement_key()).max(<T as pallet::Config>::WeightInfo::remove_ecdsa_key_agreement_key()))]
pub fn remove_key_agreement_key(origin: OriginFor<T>, key_id: KeyIdOf<T>) -> DispatchResult {
let did_subject = T::EnsureOrigin::ensure_origin(origin)?.subject();
Expand Down Expand Up @@ -834,6 +842,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Did, ServiceEndpoints, DidEndpointsCount
/// - Writes: Did, ServiceEndpoints, DidEndpointsCount
/// # </weight>
#[pallet::call_index(8)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::add_service_endpoint())]
pub fn add_service_endpoint(origin: OriginFor<T>, service_endpoint: DidEndpoint<T>) -> DispatchResult {
let did_subject = T::EnsureOrigin::ensure_origin(origin)?.subject();
Expand Down Expand Up @@ -883,6 +892,7 @@ pub mod pallet {
/// - Reads: [Origin Account], ServiceEndpoints, DidEndpointsCount
/// - Writes: Did, ServiceEndpoints, DidEndpointsCount
/// # </weight>
#[pallet::call_index(9)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::remove_service_endpoint())]
pub fn remove_service_endpoint(origin: OriginFor<T>, service_id: ServiceEndpointId<T>) -> DispatchResult {
let did_subject = T::EnsureOrigin::ensure_origin(origin)?.subject();
Expand Down Expand Up @@ -933,6 +943,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Did
/// - Kills: Did entry associated to the DID identifier
/// # </weight>
#[pallet::call_index(10)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::delete(*endpoints_to_remove))]
pub fn delete(origin: OriginFor<T>, endpoints_to_remove: u32) -> DispatchResult {
let source = T::EnsureOrigin::ensure_origin(origin)?;
Expand Down Expand Up @@ -962,6 +973,7 @@ pub mod pallet {
/// - Reads: [Origin Account], Did
/// - Kills: Did entry associated to the DID identifier
/// # </weight>
#[pallet::call_index(11)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::reclaim_deposit(*endpoints_to_remove))]
pub fn reclaim_deposit(
origin: OriginFor<T>,
Expand Down Expand Up @@ -1012,6 +1024,7 @@ pub mod pallet {
/// - Writes: Did
/// # </weight>
#[allow(clippy::boxed_local)]
#[pallet::call_index(12)]
#[pallet::weight({
let di = did_call.call.get_dispatch_info();
let max_sig_weight = <T as pallet::Config>::WeightInfo::submit_did_call_ed25519_key()
Expand Down Expand Up @@ -1078,6 +1091,7 @@ pub mod pallet {
///
/// The subject of the call must be the did owner.
/// The sender of the call will be the new deposit owner.
#[pallet::call_index(13)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::change_deposit_owner())]
pub fn change_deposit_owner(origin: OriginFor<T>) -> DispatchResult {
let source = <T as Config>::EnsureOrigin::ensure_origin(origin)?;
Expand All @@ -1092,6 +1106,7 @@ pub mod pallet {
/// Updates the deposit amount to the current deposit rate.
///
/// The sender must be the deposit owner.
#[pallet::call_index(14)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::update_deposit())]
pub fn update_deposit(origin: OriginFor<T>, did: DidIdentifierOf<T>) -> DispatchResult {
let sender = ensure_signed(origin)?;
Expand Down
7 changes: 7 additions & 0 deletions pallets/pallet-did-lookup/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ pub mod pallet {
/// - Reads: ConnectedDids + ConnectedAccounts + DID Origin Check
/// - Writes: ConnectedDids + ConnectedAccounts
/// # </weight>
#[pallet::call_index(0)]
#[pallet::weight(
<T as Config>::WeightInfo::associate_account_multisig_sr25519().max(
<T as Config>::WeightInfo::associate_account_multisig_ed25519().max(
Expand Down Expand Up @@ -223,6 +224,7 @@ pub mod pallet {
/// - Reads: ConnectedDids + ConnectedAccounts + DID Origin Check
/// - Writes: ConnectedDids + ConnectedAccounts
/// # </weight>
#[pallet::call_index(1)]
#[pallet::weight(<T as Config>::WeightInfo::associate_sender())]
pub fn associate_sender(origin: OriginFor<T>) -> DispatchResult {
let source = <T as Config>::EnsureOrigin::ensure_origin(origin)?;
Expand All @@ -249,6 +251,7 @@ pub mod pallet {
/// - Reads: ConnectedDids + ConnectedAccounts + DID Origin Check
/// - Writes: ConnectedDids + ConnectedAccounts
/// # </weight>
#[pallet::call_index(2)]
#[pallet::weight(<T as Config>::WeightInfo::remove_sender_association())]
pub fn remove_sender_association(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
Expand All @@ -267,6 +270,7 @@ pub mod pallet {
/// - Reads: ConnectedDids + ConnectedAccounts + DID Origin Check
/// - Writes: ConnectedDids + ConnectedAccounts
/// # </weight>
#[pallet::call_index(3)]
#[pallet::weight(<T as Config>::WeightInfo::remove_account_association())]
pub fn remove_account_association(origin: OriginFor<T>, account: LinkableAccountId) -> DispatchResult {
let source = <T as Config>::EnsureOrigin::ensure_origin(origin)?;
Expand All @@ -288,6 +292,7 @@ pub mod pallet {
/// - Reads: ConnectedDids
/// - Writes: ConnectedDids
/// # </weight>
#[pallet::call_index(4)]
#[pallet::weight(<T as Config>::WeightInfo::remove_sender_association())]
pub fn reclaim_deposit(origin: OriginFor<T>, account: LinkableAccountId) -> DispatchResult {
let who = ensure_signed(origin)?;
Expand All @@ -304,6 +309,7 @@ pub mod pallet {
///
/// The subject of the call must be linked to the account.
/// The sender of the call will be the new deposit owner.
#[pallet::call_index(5)]
#[pallet::weight(<T as Config>::WeightInfo::change_deposit_owner())]
pub fn change_deposit_owner(origin: OriginFor<T>, account: LinkableAccountId) -> DispatchResult {
let source = <T as Config>::EnsureOrigin::ensure_origin(origin)?;
Expand All @@ -318,6 +324,7 @@ pub mod pallet {
/// Updates the deposit amount to the current deposit rate.
///
/// The sender must be the deposit owner.
#[pallet::call_index(6)]
#[pallet::weight(<T as Config>::WeightInfo::update_deposit())]
pub fn update_deposit(origin: OriginFor<T>, account: LinkableAccountId) -> DispatchResult {
let source = ensure_signed(origin)?;
Expand Down
7 changes: 7 additions & 0 deletions pallets/pallet-web3-names/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ pub mod pallet {
/// check + origin check
/// - Writes: Names, Owner storage entries + currency deposit reserve
/// # </weight>
#[pallet::call_index(0)]
#[pallet::weight(<T as Config>::WeightInfo::claim(name.len().saturated_into()))]
pub fn claim(origin: OriginFor<T>, name: Web3NameInput<T>) -> DispatchResult {
let origin = T::OwnerOrigin::ensure_origin(origin)?;
Expand Down Expand Up @@ -227,6 +228,7 @@ pub mod pallet {
/// - Reads: Names storage entry + origin check
/// - Writes: Names, Owner storage entries + currency deposit release
/// # </weight>
#[pallet::call_index(1)]
#[pallet::weight(<T as Config>::WeightInfo::release_by_owner())]
pub fn release_by_owner(origin: OriginFor<T>) -> DispatchResult {
let origin = T::OwnerOrigin::ensure_origin(origin)?;
Expand Down Expand Up @@ -257,6 +259,7 @@ pub mod pallet {
/// - Reads: Owner storage entry + origin check
/// - Writes: Names, Owner storage entries + currency deposit release
/// # </weight>
#[pallet::call_index(2)]
#[pallet::weight(<T as Config>::WeightInfo::reclaim_deposit(name.len().saturated_into()))]
pub fn reclaim_deposit(origin: OriginFor<T>, name: Web3NameInput<T>) -> DispatchResult {
let caller = ensure_signed(origin)?;
Expand Down Expand Up @@ -290,6 +293,7 @@ pub mod pallet {
/// - Writes: Names, Owner, Banned storage entries + currency deposit
/// release
/// # </weight>
#[pallet::call_index(3)]
#[pallet::weight(<T as Config>::WeightInfo::ban(name.len().saturated_into()))]
pub fn ban(origin: OriginFor<T>, name: Web3NameInput<T>) -> DispatchResult {
T::BanOrigin::ensure_origin(origin)?;
Expand Down Expand Up @@ -322,6 +326,7 @@ pub mod pallet {
/// - Reads: Banned storage entry + origin check
/// - Writes: Banned storage entry deposit release
/// # </weight>
#[pallet::call_index(4)]
#[pallet::weight(<T as Config>::WeightInfo::unban(name.len().saturated_into()))]
pub fn unban(origin: OriginFor<T>, name: Web3NameInput<T>) -> DispatchResult {
T::BanOrigin::ensure_origin(origin)?;
Expand All @@ -343,6 +348,7 @@ pub mod pallet {
///
/// The subject of the call must be the owner of the web3name.
/// The sender of the call will be the new deposit owner.
#[pallet::call_index(5)]
#[pallet::weight(<T as Config>::WeightInfo::change_deposit_owner())]
pub fn change_deposit_owner(origin: OriginFor<T>) -> DispatchResult {
let source = <T as Config>::OwnerOrigin::ensure_origin(origin)?;
Expand All @@ -356,6 +362,7 @@ pub mod pallet {
/// Updates the deposit amount to the current deposit rate.
///
/// The sender must be the deposit owner.
#[pallet::call_index(6)]
#[pallet::weight(<T as Config>::WeightInfo::update_deposit())]
pub fn update_deposit(origin: OriginFor<T>, name_input: Web3NameInput<T>) -> DispatchResult {
let source = ensure_signed(origin)?;
Expand Down
Loading

0 comments on commit 9e9aa29

Please sign in to comment.