Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: single signature DID calls/creation #551

Merged
merged 35 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b178b23
Don't use true and false to generate two different keys
weichweich Aug 31, 2023
d0d774a
remove not necesarry trait bounds
weichweich Aug 31, 2023
84bd0d6
split tests
weichweich Aug 31, 2023
4a2da5d
Merge remote-tracking branch 'origin/develop' into did-test-update
weichweich Aug 31, 2023
3789ae4
feat: do_did_call
weichweich Aug 21, 2023
9671f4c
feat: wrapped payload support
weichweich Aug 24, 2023
8fdce99
fix: simplify do_did_call
weichweich Aug 25, 2023
19bf686
feat: 1/2 create from account
weichweich Aug 25, 2023
3dbbaf8
check that the sender is the owner of the identifier
weichweich Aug 28, 2023
5e55104
remove wrapped signatures
weichweich Aug 31, 2023
78fc469
fix tests
weichweich Aug 31, 2023
fe32789
simplify create_from_account
weichweich Aug 31, 2023
fa82cc3
Merge remote-tracking branch 'origin/develop' into aw-did-origins
weichweich Sep 5, 2023
cdfadd4
tests: create_from_account
weichweich Sep 5, 2023
853c843
🧹🐢
weichweich Sep 6, 2023
4c6341b
refactor: successful test first
weichweich Sep 6, 2023
5076619
tests
weichweich Sep 6, 2023
2f64a2e
🧹🐢
weichweich Sep 6, 2023
7f362a2
🧹🐢
weichweich Sep 6, 2023
e27f92e
benchmarks
weichweich Sep 7, 2023
346f404
benchmark values
weichweich Sep 7, 2023
f8fef1a
doc
weichweich Sep 7, 2023
6d68a81
Merge branch 'develop' into aw-did-origins
weichweich Sep 11, 2023
5a6a650
explain hashing
weichweich Sep 12, 2023
e9ddbd4
Removed unnecessary `impl AsRef<[u8]>`
weichweich Sep 12, 2023
d04c0e1
use IdentifyAccount
weichweich Sep 12, 2023
a8090e5
drop the requirement that auth key == did identifier
weichweich Sep 12, 2023
11c4fa4
refactor: create DID function
weichweich Sep 18, 2023
602a0f7
refactor: update DID
weichweich Sep 18, 2023
f95667c
🧹🐢
weichweich Sep 18, 2023
cfa486d
doc: add docs
weichweich Sep 18, 2023
9b139f6
refactor: merge new and from_account
weichweich Sep 18, 2023
7c33b9c
doc
weichweich Sep 18, 2023
c70e21c
chore: move to new benchmark tests.
weichweich Sep 18, 2023
cc089f0
fix benchmarks
weichweich Sep 18, 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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pallets/did/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dev-dependencies]
env_logger.workspace = true
hex-literal.workspace = true

ctype = {workspace = true, features = ["mock"]}
kilt-support = {workspace = true, features = ["mock", "try-runtime"]}
Expand Down
31 changes: 31 additions & 0 deletions pallets/did/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ benchmarks! {
<T as frame_system::Config>::RuntimeOrigin: From<RawOrigin<T::DidIdentifier>>,
<T as frame_system::Config>::AccountId: From<AccountId32>,
<T as Config>::Currency: Mutate<T::AccountId>,
T::AccountId: AsRef<[u8; 32]> + From<[u8; 32]>,
}

/* create extrinsic */
Expand Down Expand Up @@ -1188,6 +1189,36 @@ benchmarks! {
},
)
}

dispatch_as {
// ecdsa keys are the most expensive since they require an additional hashing step
let did_public_auth_key = get_ecdsa_public_authentication_key();
let did_subject: DidIdentifierOf<T> = MultiSigner::from(did_public_auth_key).into_account().into();
let did_account: AccountIdOf<T> = MultiSigner::from(did_public_auth_key).into_account().into();

let did_details = generate_base_did_details::<T>(DidVerificationKey::from(did_public_auth_key), None);

Did::<T>::insert(&did_subject, did_details.clone());
make_free_for_did::<T>(&did_account);
CurrencyOf::<T>::hold(&HoldReason::Deposit.into(), &did_account, did_details.deposit.amount).expect("should reserve currency");

let test_call = <T as Config>::RuntimeCall::get_call_for_did_call_benchmark();
let origin = RawOrigin::Signed(did_subject.clone());
}: _(origin, did_subject, Box::new(test_call))

create_from_account {
// ecdsa keys are the most expensive since they require an additional hashing step
let did_public_auth_key = get_ecdsa_public_authentication_key();
let did_subject: DidIdentifierOf<T> = MultiSigner::from(did_public_auth_key).into_account().into();
let did_account: AccountIdOf<T> = MultiSigner::from(did_public_auth_key).into_account().into();

let authentication_key = DidVerificationKey::from(did_public_auth_key);
make_free_for_did::<T>(&did_account);
let origin = RawOrigin::Signed(did_subject.clone());
}: _(origin, authentication_key)
verify {
Did::<T>::get(&did_subject).expect("DID entry should be created");
}
}

impl_benchmark_test_suite! {
Expand Down
100 changes: 72 additions & 28 deletions pallets/did/src/default_weights.rs
Original file line number Diff line number Diff line change
@@ -1,45 +1,27 @@
// KILT Blockchain – https://botlabs.org
// Copyright (C) 2019-2023 BOTLabs GmbH

// The KILT Blockchain is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// The KILT Blockchain is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// If you feel like getting in touch with us, you can do so at info@botlabs.org

//! Autogenerated weights for did
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2023-08-04
//! DATE: 2023-09-07
//! STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `eyrie-7`, CPU: `Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz`
//! HOSTNAME: `rust-2`, CPU: `12th Gen Intel(R) Core(TM) i9-12900K`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024

// Executed Command:
// ./target/release/kilt-parachain
// target/debug/kilt-parachain
// benchmark
// pallet
// --template=.maintain/weight-template.hbs
// --header=HEADER-GPL
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --chain=dev
// --steps=50
// --repeat=20
// --chain=dev
// --pallet=did
// --extrinsic=*
// --output=./pallets/did/src/default_weights.rs
// --extrinsic=dispatch_as,create_from_account
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --output=pallets/did/src/default_weights.rs
// --template=.maintain/weight-template.hbs

#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
Expand Down Expand Up @@ -86,6 +68,8 @@ pub trait WeightInfo {
fn signature_verification_ecdsa(l: u32, ) -> Weight;
fn change_deposit_owner() -> Weight;
fn update_deposit() -> Weight;
fn dispatch_as() -> Weight;
fn create_from_account() -> Weight;
}

/// Weights for did using the Substrate node and recommended hardware.
Expand Down Expand Up @@ -728,6 +712,36 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}

/// Storage: Did Did (r:1 w:0)
/// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen)
fn dispatch_as() -> Weight {
// Proof Size summary in bytes:
// Measured: `353`
// Estimated: `5777`
// Minimum execution time: 187_140 nanoseconds.
Weight::from_parts(190_030_000, 5777)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
/// Storage: Did DidBlacklist (r:1 w:0)
/// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen)
/// Storage: Did Did (r:1 w:1)
/// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen)
/// Storage: Did DidEndpointsCount (r:1 w:0)
/// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen)
/// Storage: System Account (r:2 w:2)
/// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen)
/// Storage: Balances Holds (r:1 w:1)
/// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen)
fn create_from_account() -> Weight {
// Proof Size summary in bytes:
// Measured: `1097`
// Estimated: `6204`
// Minimum execution time: 970_542 nanoseconds.
Weight::from_parts(983_257_000, 6204)
.saturating_add(T::DbWeight::get().reads(6_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
}

// For backwards compatibility and tests
Expand Down Expand Up @@ -1369,4 +1383,34 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}

/// Storage: Did Did (r:1 w:0)
/// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen)
fn dispatch_as() -> Weight {
// Proof Size summary in bytes:
// Measured: `353`
// Estimated: `5777`
// Minimum execution time: 187_140 nanoseconds.
Weight::from_parts(190_030_000, 5777)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
/// Storage: Did DidBlacklist (r:1 w:0)
/// Proof: Did DidBlacklist (max_values: None, max_size: Some(48), added: 2523, mode: MaxEncodedLen)
/// Storage: Did Did (r:1 w:1)
/// Proof: Did Did (max_values: None, max_size: Some(2312), added: 4787, mode: MaxEncodedLen)
/// Storage: Did DidEndpointsCount (r:1 w:0)
/// Proof: Did DidEndpointsCount (max_values: None, max_size: Some(52), added: 2527, mode: MaxEncodedLen)
/// Storage: System Account (r:2 w:2)
/// Proof: System Account (max_values: None, max_size: Some(132), added: 2607, mode: MaxEncodedLen)
/// Storage: Balances Holds (r:1 w:1)
/// Proof: Balances Holds (max_values: None, max_size: Some(949), added: 3424, mode: MaxEncodedLen)
fn create_from_account() -> Weight {
// Proof Size summary in bytes:
// Measured: `1097`
// Estimated: `6204`
// Minimum execution time: 970_542 nanoseconds.
Weight::from_parts(983_257_000, 6204)
.saturating_add(RocksDbWeight::get().reads(6_u64))
.saturating_add(RocksDbWeight::get().writes(4_u64))
}
}
Loading