-
Notifications
You must be signed in to change notification settings - Fork 90
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
Enable lazy tangle updates in the Account
#377
Conversation
Account
Account
impl Clone for IdentityIndex { | ||
fn clone(&self) -> Self { | ||
let mut locks = HashMap::new(); | ||
self.data.values().for_each(|id| { | ||
locks.insert(*id, Arc::new(RwLock::new(*id))); | ||
}); | ||
|
||
Self { | ||
data: self.data.clone(), | ||
locks, | ||
} | ||
} | ||
} | ||
|
||
impl PartialEq for IdentityIndex { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.data == other.data | ||
} | ||
} | ||
|
||
impl<'de> serde::Deserialize<'de> for IdentityIndex { | ||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
where | ||
D: serde::Deserializer<'de>, | ||
{ | ||
Result::map( | ||
serde::Deserialize::deserialize(deserializer), | ||
|data: HashMap<IdentityTag, IdentityId>| { | ||
let mut locks = HashMap::new(); | ||
|
||
for value in data.values() { | ||
locks.insert(*value, Arc::new(RwLock::new(*value))); | ||
} | ||
|
||
IdentityIndex { data, locks } | ||
}, | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change get_lock
to lazily create locks as-needed instead of creating them all at once here and on insert
? That would be a performance benefit too since one would not need locking at all if not using update_identity
/ publish_changes
, and then only for those identities being updated.
I am a bit concerned with how the IdentityIndex
is used by the Storage
where it is cloned (in MemStore
) or serialized then de-serialized (Stronghold
) that one could circumvent the locks by using different copies of them. It may be better to store the lock map in the Account
struct proper to avoid these issues altogether?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this is better. I was previously worried about contention on the RwLock<IdentityIndex>
in the account, since get_lock
would then modify the index and require the lock to be acquired as a write lock rather than just a read one. But most likely the performance is better this way then adding locks for a large number of identities.
Yes theoretically possible, but prevent by the design of the account. The index is only cloned when returned by storage, and added when the account is created, and never modified as a whole. So for any given account no cloning happens, and thus this should be fine.
Having the locks in the account requires more locks, as you would have RwLock<IdentityIndex>
and also a separate RwLock<HashMap<IdentityId, Arc<RwLock<IdentityId>>>>
, which I wanted to avoid. One possibility is to remove the custom Clone
impl and add a derive, in which case the Arc
around the lock would be cloned, and thus your concern of getting around the locks when cloning would be alleviated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using something like Dashmap<IdentityId, Arc<RwLock<IdentityId>>>
in the account wouldn't be too terrible.
Clone
is only used by MemStore
, the index is (de)serialized by the Stronghold storage so it would still suffer from that. I think in general this may not be a problem since, as you indicated, the Account
itself is not cloned. I also do not see any cases where an Account
re-loads the index from storage after the initial configuration but may be incorrect.
Overall the locking seems fine. I'll take another look as there may be places where a read lock is appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Minor comments.
I would still prefer the lock map to be in the Account
itself rather than the index to avoid any potential index cloning, storage issues and workarounds for e.g. PartialEq
but this still solves the race condition.
* Implement pushing unpublished commits to tangle * Improve methods added to the storage interface * Bail early if no commits to publish * Implement new storage methods for `Stronghold` * Implement clippy suggestions * Add lazy publish example * Add lazy publish test * Apply format * Replace `unwrap` with `?` * Implement a "network-resilient" test runner * Make identity updates thread-safe * Expand docs, fix nitpicks * Add lock to `publish_changes` * Return locks lazily in `get_lock` * Remove lock when deleting from index * Clone locks when cloning the index * Rename document to did in all examples * Fix spelling, docs, naming * Improve docs, simplify code * Add `IdentityLock` type * Rename `publish_changes` -> `publish_updates`
* Docs/readme improvs (#257) * Update main readme * WASM readme update * Updated example with account * Rust examples readme * Bump wasm version * Revert "Bump wasm version" This reverts commit 73d9d66. * consistent node version * Bump wasm version * Expand unit test coverage in bitset.rs, iota_did.rs, and iota_document.rs (#265) * Add some tests * Add IotaDocument::try_from_core() unit tests * Fix clippy error * read indexation payload from transaction payloads * Remove IotaDID->DID Deref anti-pattern. (#269) * Remove IotaDID->DID Deref anti-pattern. * Address l1h3r review comments. * Rework WASM examples to explicitly use client configs. (#275) * Rework WASM examples to explicitly use client configs. * Add explorer_util.js adn fix typo. * Fix explorer URL construction. Inlined the prefix since it is no longer exported. * Bump dns-packet from 1.3.1 to 1.3.4 in /bindings/wasm (#277) Bumps [dns-packet](https://github.com/mafintosh/dns-packet) from 1.3.1 to 1.3.4. - [Release notes](https://github.com/mafintosh/dns-packet/releases) - [Changelog](https://github.com/mafintosh/dns-packet/blob/master/CHANGELOG.md) - [Commits](mafintosh/dns-packet@v1.3.1...v1.3.4) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump browserslist from 4.16.3 to 4.16.6 in /bindings/wasm (#278) Bumps [browserslist](https://github.com/browserslist/browserslist) from 4.16.3 to 4.16.6. - [Release notes](https://github.com/browserslist/browserslist/releases) - [Changelog](https://github.com/browserslist/browserslist/blob/main/CHANGELOG.md) - [Commits](browserslist/browserslist@4.16.3...4.16.6) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add IotaDocument::from_keypair_with_network() and WASM binding. (#276) * Add IotaDocument::from_keypair_with_network() and WASM binding. * Undo unintentional formatting in README. * Add optional network arg to from_keypair WASM binding. * Update API reference for fromKeyPair. * Update README. * Update bindings/wasm/src/wasm_document.rs * Use u32 for message delays (#281) * Use u32 for message delays * Update docs * Update version * Bump ws from 6.2.1 to 6.2.2 in /bindings/wasm (#282) Bumps [ws](https://github.com/websockets/ws) from 6.2.1 to 6.2.2. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/commits) --- updated-dependencies: - dependency-name: ws dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * docs: Fix some typos in the method spec * docs: Describe build process for wasm bindings * Update iota-client (#270) * Update iota-client * Fix features * New client builder * New wasm client * Update examples * More common types (#283) * Fragment/UnixTimestamp -> core::common * clippy * Timestamp::now -> Timestamp::now_utc * Remove shard from DIDs (#280) * Remove shard from DIDs * wasm fixes * update yarn.lock * doctest * Version Bump * Restore checkCredential/checkPresentation WASM functions (#287) * Restore client.checkCredential/checkPresentation * doc: Serialize `message_id` for `IotaDocument`s * wasm: Fix incorrect path in example imports * client: Rename `read_document` to `resolve` * Revert "doc: Serialize `message_id` for `IotaDocument`s" This reverts commit 26e2dcd. * wasm: Serialize `message_id` for resolve method Co-authored-by: PhilippGackstatter <philipp.gackstatter@iota.org> * Add blake2b to wasm bindings (#288) * Add blake2b to wasm bindings * docs * core: Reimpl `Key` with generics * replace deleted method readDocument(id) with resolve(id) (#294) * account: Disable custom riker logging * Docs/setup docusaurus (#298) * setup docusarus template * add iota style and identity content * add gh deploy action * fix sidebar and titles * change build dir * fix folder name * add specs, fix links * fix images * fix base path and github link * add cname for security * Add `publicKeyMultibase` (#307) * Add publicKeyMultibase support Add and expand base-encoding tests. * Remove publicKeyHex * Add verification method publicKeyMultibase test * Ignore wasm lint warning * setup documentation file structure in docusaurus * Example Cleanup (#292) * Default Network should be Mainnet * Use remote PoW by default * Always set a primary node * Client updates - Add TangleResolve for generic client implementations - Add Receipt return value with additional txn info - Rename `Client::transaction_url` -> `Client::message_url` * Appease clippy * Update examples * Add ability to configure account clients (#293) * Add ability to configure account clients * rename * stricter bound * Use dashmap * Explicit account test mode * Fix missed method * Ignore lint * faster tests * Minutes/2021 14 07 (#316) * 2021-07-14 * 2021-07-14 * final * Rename Co-authored-by: HackMD <no-reply@hackmd.io> * add codeSnippet component * Update actions to pin Rust nightly version (#318) Fix attempt for inconsistent Github Actions failures. * Wasm examples browser (#317) * create did through browser * add examples to create and resolve DID * add manipulate_did and create_vc * and merkle key and revocation * add missing index.html * move node examples to separate folder * update readme file * remove web.js and format browser examples * include node examples in git * update readme links of node examples * account: Add stronghold and re-export wasm feature (#291) Signed-off-by: PhilippGackstatter <philipp.gackstatter@iota.org> account: Complete stronghold feature integration account: Enable new resolver to fix wasm target account: Use tokio 1.5 & split async feature account: Add note on `Stronghold` availability builder: Apply cargo fmt Signed-off-by: PhilippGackstatter <philipp.gackstatter@iota.org> * Fix cyclic dependency (#319) Remove unused preserve_order serde_json feature flag. * update file paths * add remark-import-partial plugin * add missing doc files * update landing page * Fix inconsistent stronghold storage tests (#320) Raise test timeouts and improve handling on slow systems. * update footer/add empty team page * remember selected programming language * fix rust Replit * change height of code snippet * add teams page * adjust team page * minor edits to landing page * Added DID Intro text * Moved meeting minutes * Remove mdbook docs * Renamed DocOps -> documentation * Updated deploy workflow documentation * Updated blogs * signature: Impl thread-safe `Cell` (#329) Signed-off-by: PhilippGackstatter <philipp.gackstatter@iota.org> * update docusaurus.config.js * Docs/docusaurus (#324) * Docs/setup docusaurus (#298) * setup docusarus template * add iota style and identity content * add gh deploy action * fix sidebar and titles * change build dir * fix folder name * add specs, fix links * fix images * fix base path and github link * add cname for security * setup documentation file structure in docusaurus * add codeSnippet component * update file paths * add remark-import-partial plugin * add missing doc files * update landing page * update footer/add empty team page * remember selected programming language * fix rust Replit * change height of code snippet * add teams page * adjust team page * minor edits to landing page * Added DID Intro text * Moved meeting minutes * Remove mdbook docs * Renamed DocOps -> documentation * Updated deploy workflow documentation * Updated blogs * update docusaurus.config.js Co-authored-by: huhn511 <sehe89@gmail.com> Co-authored-by: JelleMillenaar <Jelle.millenaar@iota.org> * Fix workflow * Trigger workflow if itself changes * Moved latest meeting notes * Docs/docusaurus (#331) * Docs/setup docusaurus (#298) * setup docusarus template * add iota style and identity content * add gh deploy action * fix sidebar and titles * change build dir * fix folder name * add specs, fix links * fix images * fix base path and github link * add cname for security * setup documentation file structure in docusaurus * add codeSnippet component * update file paths * add remark-import-partial plugin * add missing doc files * update landing page * update footer/add empty team page * remember selected programming language * fix rust Replit * change height of code snippet * add teams page * adjust team page * minor edits to landing page * Added DID Intro text * Moved meeting minutes * Remove mdbook docs * Renamed DocOps -> documentation * Updated deploy workflow documentation * Updated blogs * update docusaurus.config.js * Fix workflow * Trigger workflow if itself changes * Moved latest meeting notes Co-authored-by: huhn511 <sehe89@gmail.com> Co-authored-by: Abdulrahim Al Methiab <abdulrahim.almethiab@iota.org> * replace package-lock * prevent broken links from failing the build * fix docusaurus base URL * Bump prismjs from 1.23.0 to 1.24.1 in /documentation (#330) Bumps [prismjs](https://github.com/PrismJS/prism) from 1.23.0 to 1.24.1. - [Release notes](https://github.com/PrismJS/prism/releases) - [Changelog](https://github.com/PrismJS/prism/blob/master/CHANGELOG.md) - [Commits](PrismJS/prism@v1.23.0...v1.24.1) --- updated-dependencies: - dependency-name: prismjs dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add sccache to pipeline (#335) * Add sccache to pipeline * Fix Github Actions build-and-test include path CI checks should correctly run if the build-and-test.yml definition changes now. * Fix sccache installation on Linux, Windows * Debug Windows sccache path * Add cache steps to all build CI jobs Fix cache restore keys. * Fix sccache restore keys * * Upgraded docusaurus to improve mobile nav * Fixed docs edit url * * Fixed broken link * Fix import.meta error (#340) * Fix import.meta error Update our workaround for webpack not supporting import.meta properly, which causes an error when trying to use the Wasm web bindings with some frameworks, e.g. React. * Improve workaround regex * Fix wasm examples (#337) * Use camel case for JSON * Fix messageId extraction * Use explicit receipt var in examples * Fix web explorer url * Update yarn.lock * Bump tar from 5.0.5 to 5.0.7 in /bindings/wasm (#346) Bumps [tar](https://github.com/npm/node-tar) from 5.0.5 to 5.0.7. - [Release notes](https://github.com/npm/node-tar/releases) - [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md) - [Commits](isaacs/node-tar@v5.0.5...v5.0.7) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix libjose clippy lint (#348) Remove needless borrow in libjose * Add Wasm examples to CI (#345) * Fix Wasm README.md example Add Wasm examples CI job. Update build-and-test CI to run wasm_bindgen annotated tests. * Add txm annotations to test Wasm README.md example Add txm to examples CI job. * Fix Wasm node and README.md examples tests The examples will now throw error codes on unsuccessful termination. * Enable wasm examples CI job on PR temporarily * Add configurable branch/ref for example CI * Disable examples CI job on pull requests * Rename Wasm Examples CI job * Switch to jest for testing node bindings examples * Add wasm browser example tests with cypress Fix broken browser examples, doc strings. Update example CI job with browser tests. Temporarily enable examples CI job on PR for testing. * Disable examples CI on PR Update yarn.lock to include cypress * improve node tests reliability * improve browser test reliability Co-authored-by: Abdulrahim Al Methiab <abdulrahim.almethiab@iota.org> * Bump version to 0.3.5 for @iota/identity-wasm@dev (#351) Update package-lock.json * Improve Wasm error handling (#344) * Add WasmError Enables idiomatic Javascript error handling with js_sys::Error which includes error enum variant names. * Add WasmError test * remove book.toml (#341) * Fix low-level links (#353) Some of them were pointing to the wrong file. * Update documentation links (#354) * Update doc links * Updated remaining incorrect links Co-authored-by: JelleMillenaar <Jelle.millenaar@iota.org> * Add integration chain history/diff chain API (#347) * Retrieve basic message history * add Client::resolve_diffs * Add WASM support/example * Remove needless borrow * cargo clean * cargo fmt * add did-history node example * fix did-history node example * add did-history browser example * start implementing create_diff example for browser * add create_diff examples * fix revocation * Address comments Add clarifying comments to resolve history example. Add wasm bindings equivalents for the resolve history example. Add diff_chain example to base examples. Add authorisation method to WasmDocument in order to use resolveDiffs. Improve rustdoc comments. Fix base example README.md references. * Fix merge. Fix clippy lint warnings. Fix formatting. * Remove leftover file from merge conflict. * Fix format * Fix wasm examples README.md * Add Wasm binding history types Add bridging Wasm structs for MessageHistory, DiffSet, DocumentDiff, DiffChain, IntegrationChain. Update client methods to return the briding structs where possible instead of a serialized JsValue. Improve error ergonomics in Wasm bindings by replacing `.map_err(wasm_error)` with `.wasm_result()` and define a custom Result type for JsValue errors. Rename integration, diff chain `is_valid`/`check_validity` methods to `is_valid_addition`/`check_valid_addition` to reduce ambiguity. Add an extra check for the `message_id` in `check_valid_addition`. * Export more functions to wasm bindings Add publish_json, diff_address, integration_address to wasm bindings. Update resolve_history example to include diff chain spam. Remove message_id check from check_valid_addition added in previous commit which was causing a test to fail. * Export more structs to Wasm and update examples. Export Timestamp and associated timestamp fields from IotaDocument to Wasm bindings. Update examples for parity between Rust, Nodejs, and browser versions. Add revoke_vc Rust example. Fix examples where from_keypair is used incorrectly to add new verification methods. Fix examples not setting the updated timestamp. Fix printing nested JSON in examples/node/resolve_history. * Fix README.md spelling. * Fix broken Wasm examples Fix merkle_key revocation example. Fix invalid README.md references. * Fix clippy, fmt warnings * Refactor MessageHistory to DocumentHistory Remove duplicate logic. Remove Wasm bindings for DiffChain, IntegrationChain as per discussions that those structures should be reserved for internal use and to keep the external Wasm API cleaner. Change `resolve_diff` to require a document previously published on the integration change to avoid issues with validation. * Export DocumentHistory to Wasm bindings Fix spam messages returning the wrong message ids. Change DocumentHistory structure due to Wasm binding limitations on generics. Update Wasm resolve_history examples. * Update bindings/wasm/src/did/wasm_document.rs Co-authored-by: Philipp <philipp.gackstatter@iota.org> * Update bindings/wasm/examples/browser/mainpulate_did.js Co-authored-by: Philipp <philipp.gackstatter@iota.org> * Update identity-iota/src/chain/document_chain.rs Co-authored-by: Philipp <philipp.gackstatter@iota.org> * Update document_chain.rs Add doc comment for DocumentChain. * Update document_chain.rs Fix formatting. * Fix whitespace formatting to satisfy CI * Rename address to index Corrects integrationAddress -> integrationIndex, diffAddress -> diffIndex. Co-authored-by: Abdulrahim Al Methiab <abdulrahim.almethiab@iota.org> Co-authored-by: Craig Bester <craig.bester@iota.org> Co-authored-by: Philipp <philipp.gackstatter@iota.org> * Bump version to 0.3.6 for @iota/identity-wasm@dev (#363) * added cargo example build and dummy run * added parallel execution for js and rust examples * added actual cargo example run * fixed cargo example run * added output cache, changed cache key, reordering * use jq instead of python * use matrix build, caching for web examples * use current branch * Improve `Network` type to better support private tangles (#360) * Make `Network` not `Copy` This is in preparation for adding another non-`Copy` variant later. * Add `Other` variant in `Network` * Add node.js DID creation on private tangle example * Add `from_name` in Wasm and fix absence of `Copy` * Remove superfluous imports * Add browser Wasm example * Remove old variable * Add low-level Rust API example * Format Wasm network source code * Add account Rust API example * Use same ideas for account & low-level examples * Rename `Network::as_str` to `name` * Impl spec compliance check for `Network` names * Change `IotaDID::network` return type to `Result` * Change bindings according to new return type * Improve Wasm examples with resolution step * Add private tangle test * Add cypress browser test * Use `?` instead of `unwrap` where possible * Add explorer url to `Network::Other` variant * Add explorer_url tests * Merge branch 'dev' into feat/private-tangle-network * Fix `explorer_url` conversion * Fix `message_url` in new examples * Fix network names in Rust private tangle examples * Update bindings/wasm/examples/node/test.js Co-authored-by: Craig Bester <craig.bester@iota.org> * Update bindings/wasm/cypress/integration/browser_test.js Co-authored-by: Craig Bester <craig.bester@iota.org> * Update bindings/wasm/examples/node/private_tangle.js Co-authored-by: Craig Bester <craig.bester@iota.org> * Update bindings/wasm/examples/browser/private_tangle.js Co-authored-by: Craig Bester <craig.bester@iota.org> * Update examples/account/private_tangle.rs Co-authored-by: Craig Bester <craig.bester@iota.org> * Update examples/low-level-api/private_tangle.rs Co-authored-by: Craig Bester <craig.bester@iota.org> Co-authored-by: Craig Bester <craig.bester@iota.org> * remove target cache * added exit condition * improved naming * changed sccache key * use release mode to build examples * renamed workflow * Add HTML remove comments remark plugin (#366) * Remove `toUnix` and `fromUnix` methods in `WasmTimestamp` (#365) * Remove unix methods in Timestamp due to #362 * Add lint to avoid future reintroduction of i64/u64 * Update Wasm docs * Link the relevant issue in the lint * Bump version to 0.3.7 for @iota/identity-wasm@dev (#368) * Bump url-parse from 1.5.1 to 1.5.3 in /documentation (#356) Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.5.1 to 1.5.3. - [Release notes](https://github.com/unshiftio/url-parse/releases) - [Commits](unshiftio/url-parse@1.5.1...1.5.3) --- updated-dependencies: - dependency-name: url-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump url-parse from 1.5.1 to 1.5.3 in /bindings/wasm (#357) Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.5.1 to 1.5.3. - [Release notes](https://github.com/unshiftio/url-parse/releases) - [Commits](unshiftio/url-parse@1.5.1...1.5.3) --- updated-dependencies: - dependency-name: url-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix iota-client dependency (#371) * Update dependency versions Fix iota-client dependency resolution error in GitHub Actions. Update minor dependencies. * Fix Rust examples CI failures Prevent private_tangle examples returning an error on publish when no private Tangle is running locally. * Update wasm bindings resolver to version 2 Removes mio dependency which cannot be compiled to the wasm target. It was brought in by tokio features in dev-dependencies, hence why the new resolver works. * Update iota-client dependency pinned commit Fix Wasm compilation. * Migrate riker stronghold to actix version (#370) Move password expiration to the stronghold thread Asyncify the tests Fix "unnecessary let binding"-lint Update to latest stronghold & crypto.rs Fix clippy "let binding returned" lint Improve unwrap safety documentation Improve error handling in stronghold init Simplify stronghold init statement Upgrade all crates to iota-crypto 0.7 Improve error handling and use `expect` everywhere Alphabetize `Cargo.toml` Fix "block in if condition" clippy lint * Bump to 0.3.8 for @iota/identity-wasm@dev, add set_message_id (#373) * Add set_message_id to WasmDocument Allow setting the message_id on DID documents in the wasm bindings. * Bump version to 0.3.8 for @iota/identity-wasm@dev * Fix messageId in create_did Wasm examples * Make sccache installation a bit faster on macOS (#374) * Bump to 0.3.9 for @iota/identity-wasm@dev, fix messageId (#376) * Fix WasmDocumentDiff message_id Fix message_id incorrectly returning the previous_message_id. * Bump version to 0.3.9 for @iota/identity-wasm@dev * Enable the creation of an identity from a `KeyPair` in the `Account` (#352) * Add `key_insert` function in `Storage` trait * account: Impl keygen from bytes for `MemStore` * account: Remove unused imports * account: Document key size for Ed25519 * account: Fix clippy dereference lint * account: Remove unnecessary comment * account: Document `secret_key` better * account: Fix ed25519 key size doc comment * Add optional `secret_key` to `CreateMethod` * Use renamed crypto methods in `MemStore` * Add creating id from secret key tests * Update stronghold to bug-fixed version * Add stronghold insertion test * Return proper error on invalid key length * Implement method_secret for `CreateMethod` * Add key size check in `CreateIdentity` * Don't test error message itself * Use `MethodSecret` in `IdentityCreate` * Test type/secret mismatch * Move insertion logic to new method * Refactor `NetworkName` (#375) * Add NetworkName Use a newtype wrapper for network names to enforce spec compliance. Fix potential bug with ClientMap theoretically having duplicate network clients when custom explorer URLs are set. * Update IotaDID to validate network name Rename `with_network` to `new_with_network`. * Fix Wasm bindings Add `Network::name_str` to avoid cloning the `NetworkName`. * Remove did! macro The did! macro was unused and just converted the errors from try_did! into panics. Add network validation tests for Account::create_identity. * Address comments Rename Network::from_name to Network::try_from_name Rename NetworkName::try_from_name to NetworkName::try_from Rename try_did! to try_construct_did! * Fix compilation * Bump tar from 5.0.7 to 5.0.11 in /bindings/wasm (#378) Bumps [tar](https://github.com/npm/node-tar) from 5.0.7 to 5.0.11. - [Release notes](https://github.com/npm/node-tar/releases) - [Changelog](https://github.com/npm/node-tar/blob/main/CHANGELOG.md) - [Commits](isaacs/node-tar@v5.0.7...v5.0.11) --- updated-dependencies: - dependency-name: tar dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Extend Network doc comment for other networks (#382) * extend doc comment * Fix spelling * Add build step for Wasm examples (#369) * added build step for examples * enable more examples * enabled more examples, cleaned up utils * removed platform specific examples * fixed node tests * copy index.html to dist * enable all examples * changed example server root * fixed browser test * fixed wasm path * enabled all node tests * added example build to workflow * renamed build step * fixed tests * added example build to README * fixed example path * added sourcemap option to build step * removed redundant try catch * added WASM example build to build and test * fixed Readme links * changed test command * added signature for linkify method * minor rework of resolution workflow * Use a network name that matches part of the private tangle network id (#383) * Fix private tangle examples * Fix Wasm private tangle examples * * Removed comment about txm which causes a compilation error upon importing from the wiki (#384) * Change build workflow step to avoid recompilation (#386) * Fix Wasm private-tangle example (#389) Fixes failing example tests when nothing (undefined) is passed to the function. * Revert "* Removed comment about txm which causes a compilation error upon importing from the wiki (#384)" (#385) This reverts commit 0f5be7e. * Docs - Improve SEO (#380) * * Browser friendly descriptive urls * Removed duplicate onBrokenLinks declaration in config * * Removed Docusarus assets. * Added description, image and keywords for all docs. * Added alt attribute to images * Upgraded to docusarus beta 4 * Added png identity icon * Apply suggestions from code review Co-authored-by: charlesthompson3 <74603461+charlesthompson3@users.noreply.github.com> Co-authored-by: charlesthompson3 <74603461+charlesthompson3@users.noreply.github.com> * Content for create did, replit improvements (#372) * Content for create did, replit improvements * md * Improved phrasing based on suggestions * use Cargo.lock for caches, remove libjose caches (#390) * use Cargo.lock for caches, remove libjose caches * fix sccache env * Update .github/workflows/build-and-test.yml Co-authored-by: Craig Bester <craig.bester@iota.org> * Update .github/workflows/build-and-test.yml Co-authored-by: Craig Bester <craig.bester@iota.org> Co-authored-by: Craig Bester <craig.bester@iota.org> * Enable lazy tangle updates in the `Account` (#377) * Implement pushing unpublished commits to tangle * Improve methods added to the storage interface * Bail early if no commits to publish * Implement new storage methods for `Stronghold` * Implement clippy suggestions * Add lazy publish example * Add lazy publish test * Apply format * Replace `unwrap` with `?` * Implement a "network-resilient" test runner * Make identity updates thread-safe * Expand docs, fix nitpicks * Add lock to `publish_changes` * Return locks lazily in `get_lock` * Remove lock when deleting from index * Clone locks when cloning the index * Rename document to did in all examples * Fix spelling, docs, naming * Improve docs, simplify code * Add `IdentityLock` type * Rename `publish_changes` -> `publish_updates` * Internalize `Account` commands (#391) * Impl basic `account.new_command` idea * Fix apply impl * Enable multiple updates on an updater * Flesh out `IdentityUpdater` impl * Fix command tests * Rename document to did in all examples * Update examples to use new update syntax * Add documentation * Remove Default impl, use proper macro path for key * Document `IdentityUpdater`, derive basic traits * Update recently added tests * Roll back name change * Reference `key` to get rid of `Clone` requirement * Remove `CreateIdentityBuilder` * Call `update_identity` on each update * Move tests inside the account crate * Document `IdentityUpdater` methods * Rename `CommandError` -> `UpdateError` Avoids having `Command` in the public interface. * Update stray occurrence of `CommandError` * Use better name for captured attribute in macro * Move lazy test inside the crate & update syntax * Remove `Clone` bound * Rename `CommandError` -> `UpdateError` in account * Make `resolve_id` method signatures consistent * Move builder doc to the fn instead of the impl * Replace yarn with npm (#394) * Replace yarn with npm * Fix npm publish included files Exclude examples from published wasm bindings package. * Update wasm bindings README.md Add link to examples. Add note on import statements. Improve formatting. * Add toml formatting (#393) * Add dprint for Cargo.toml formatting Add dprint check to format CI action. * Format toml files * Fix format workflow * Use pre-packaged dprint from npm * Disable incremental compilation in CI Attempt to reduce cache size. * Fix rustdoc lint warnings Re-enable incremental cargo compilation in CI except for build-and-test-wasm. * Remove redundant format check * Add composite action to CI (#392) * Add IOTA wiki CLI (#381) * Add document merge to wasm bindings (#401) * Update document merge functions in wasm bindings Add WasmDocumentDiff::merge() Update parameter of WasmDocument::merge() * Fix formatting * Fix IntegrationChainHistory, DiffChainHistory bindings * Remove redundant js_class, js_name attributes * Bump version to 0.3.10 for @iota/identity-wasm@dev (#402) * Rename document1 to did1 in README example. (#400) * Rename document1 to did1 in README example. Previously, the example used `document1` to refer to the DID, whereas the "document" isn't resolved until `account.resolve_identity()` is called. * Apply suggestions * Fix wasm compilation (#404) Explicitly enable tokio "rt" feature to fix compilation of bee-runtime dependency. * Replace `testnet` with `devnet` (#405) * Replace testnet with devnet * Update documentation * Small wiki content tweaks. (#399) - Fix "_Rust_ API Reference" title - Some acronym expansions - Consistently hyphenate Self-Sovereign Identity - Link to Rust and WASM API reference (they're still stubs though) - Some small wording tweaks * Bump version to 0.3.11 for @iota/identity-wasm@dev (#416) Add `proof` field getter for WasmDocumentDiff. * Initial content for VC Wiki Overview page (#407) * Initial content for VC Wiki Overview page * Address Jelle's review comments (round 1). * Update README.md (#413) changed links for documentation to wiki.iota.org links * Bump tmpl from 1.0.4 to 1.0.5 in /bindings/wasm (#410) Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5. - [Release notes](https://github.com/daaku/nodejs-tmpl/releases) - [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5) --- updated-dependencies: - dependency-name: tmpl dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Rename SecretKey to PrivateKey throughout identity.rs code base. (#409) * Rename SecretKey to PrivateKey throughout identity.rs codebase. * Fix formatting issues. * Resolve cycraig review (more secret->private renamings) * Add stub content to IOTA DID Resolution wiki page. (#406) * Add stub content to IOTA DID Resolution wiki page. * Address Jelle's review comments (explorer, wording, etc.) * Add default signing key as a generic verification method (#421) * Rename auth to int chain everywhere * Create verification method with attached auth * Fix generations in tests * Update remaining generations in tests * Remove outdated TODO * Impl generic verif method in low level API * Use 'integration' instead of 'int' * Add test that verifies number of verif. methods * Assert the authentication relationship * Fix Document constructor Typescript bindings (#423) * Fix WasmDocument constructor Typescript bindings Replace IotaDocument `from_keypair()`, `from_keypair_with_network()` with `new()`. Update Wasm binding examples to be more consistent with Rust. * Fix test and benchmark compilation * Fix benchmark compilation * Apply suggestions from code review * Add Document::new_with_options constructor Allow default verification method fragment to be specified. Add doc, unit tests. * Use NetworkName instead of &str Remove IotaDID::from_components. Remove specific InvalidNetworkName strings for consistency with other errors and to use with TryInto. Allow Network::try_from_name to take an actual NetworkName as well as a string. Co-authored-by: Philipp <philipp.gackstatter@iota.org> * Fix example dependencies in Readme (#430) Account feature has to be added to the identity dependencies to use identity::account::*. * Update Account API to return IdentityState from find_identity and create_identity (#414) * Update Account::create_identity() to return IdentityState. * Update Account::find_identity() to return IdentityState. * Fix Wasm network calls, pin reqwest to 0.11.4 (#439) * Rename JSON serialization field name to match spec. (#412) * Rename JSON serialization field name to match spec. * Rename notSupported -> representationNotSupported * Reduce WASM build size (#427) * reduce wasm build size * Enable lto for Wasm release Add `build-dev` task for Wasm for debugging. Co-authored-by: Craig Bester <craig.bester@iota.org> * Chore/combine examples (#420) * Merged Stronghold with basic examples in account * Updated explorer to identity resolver * Added explorer URL after basic example * Renamed examples * Completed manipulate did example * Fixed suggestions, removed replaced examples. * Improved example readme * Consistently use Stronghold and Resolver URL * Fix examples * Merged config example with private tangle * low-level-api private-network example runs * cargo fmt * cargo fmt with nightly * Impl suggestions * Docs - Reogranize Docs, Add Examples & Cheat Sheet (#425) * Reorganized files * Renamed .md files to .mdx (see https://docusaurus.io/docs/next/markdown-features/react) Added examples Deleted unused files Updated sidebar Added 20px margin bottom for replit embedded object Removed redundant units and props in styles.css * added NLOF * Apply suggestions from code review Co-authored-by: charlesthompson3 <74603461+charlesthompson3@users.noreply.github.com> * Added Wasm Cheat and Rust Cheat sheet skeleton * Apply suggestions from code review Co-authored-by: charlesthompson3 <74603461+charlesthompson3@users.noreply.github.com> * fix typo * Fixed links ADded first draft of rust cheat sheet Changed extension in verifiable_presentations.md to mdx * Added example output for all functions in the WASM cheat_sheet.md * Added example JSON output for all functions in the Rust cheat_sheet.md * Added tutorial * Formatted tutorial * Addressing comments: * Added instructions and descriptions on installing both main and dev branches. * Removed low level API items from rust cheat sheet and added Account modules examples where possible. * Added stronghold, private tangle and vp account module examples * * added branch specific installation instructions * fixed html in cheat_sheet.md Co-authored-by: charlesthompson3 <74603461+charlesthompson3@users.noreply.github.com> * Update CI cache action versions (#435) * updated cache action versions * added actions to watched paths * updated cache version for examples workflow * Docs - Fix build (#445) * * Replaced imported account module stronghold example with basic example. * Removed reference to deleted account module examples * Added test action to catch future include issues * testing action * removed action as I wasn't being successful at all * Added combined examples as suggested by @cycraig * Added missing include statements (#446) * Update TimeCop to avoid Into<SystemTime> (#444) Out of an abundance of caution. Not an actual vulnerability since `set_current` is unused and we don't use any SystemTime conversions affected by a known vulnerability. * Update methods to default to `PublicKeyMultibase` (#443) * Update methods to default to PublicKeyMultibase * Update documentation to use PublicKeyMultibase * Separate `DID`, `DIDUrl` constructs (#428) * Add separate DID, DIDUrl constructs Add DID trait. Add CoreDID, IotaDID structs. Add DIDUrl generic struct. Update various structs and functions to use a DID instead of a DIDUrl where appropriate. * Implement RelativeDIDUrl Add extra CoreDID validation. Add RelativeDIDUrl doctests. Update tests, examples. * Add DID Url unit tests. Handle relative DID Url edge-cases. Remove uriparse dependency. * Fix formatting * Fix clippy lint warnings * Fix dereference_document Add dereference unit tests. * Fix formatting, clippy lint warnings Add missing licence headers. * Fix tests, benchmarks * Remove unsafe cast in IotaVerificationMethod * Add WasmDIDUrl Update Wasm examples. * Fix wasm formatting * Improve RelativeDIDUrl comparisons * Improve DIDUrl parsing Re-export BaseDIDUrl to satisfy TryFrom<BaseDIDUrl> without adding the `did_url` crate dependency to other projects. * Remove resolution metadata check Fix formatting. * Change remove_service, remove_method parameters Add doc comments. * improved documentation * fixed formatting * Set `explorer_url` in private Tangle example (#454) * Use explorer_url from custom network * Use devnet explorer url Co-authored-by: Craig Bester <craig.bester@iota.org> * Fix explorer url formatting Co-authored-by: Craig Bester <craig.bester@iota.org> * Fix low-level private tangle example (#461) * Fix low-level private tangle example * Keep discussion on network name requirements * Fix links in documentation (#450) * Fix links in create.mdx * Fix links in validate_university_degree.mdx * Add dark image (#469) * Clean up Documentation (#463) * Removed meeting minutes * Removed copy * Fixing some links * Removed Blog * Add IOTA DIDComm protocols specification (#379) * [WIP] Add DIDComm protocol specifications * [WIP] Describe presentation messages * [WIP] enhanced presentation protocol * [WIP] enhanced presentation protocol * [WIP] enhanced presentation protocol * [WIP] enhanced presentation protocol * [WIP] Add alternative presentation diagrams * [WIP] further work on presentation * [WIP] added signing protocol * [WIP] further signing protocol * [WIP] further signing protocol * [WIP] fixed presentation * [WIP] added issuance * [WIP] further issuance * [WIP] added credential-types, renamed problem-reports * [WIP] minor cleanup * [WIP] furthr work on issuance * [WIP] further work on issuance * [WIP] further work on issuance * [WIP] further work on issuance * [WIP] further work on issuance * [WIP] further work on issuance * [WIP] added revocation * [WIP] added revocation diagram * [WIP] added revocation-options, further revocation * [WIP] further revocation-options, further revocation * [WIP]further revocation * [WIP]further revocation and revocation-options * [WIP]further revocation and revocation-options * [WIP] added termination * [WIP] reference external flows * [WIP] add presentation-exchange to presentation * [WIP] further revocation * [WIP] further revocation * [WIP] further revocation * added connection * [WIP] further connection * [WIP] further connection * [WIP] further connection * [WIP] further connection, added authetication * [WIP] further authetication * [WIP] fixed typos * [WIP] further auth] * [WIP] further auth * [WIP] further auth * [WIP] further auth * fixed typo * [WIP] problem reports * problem reports * further problem reports * further problem reports * problem reports, added 'post' protocol * added post * type negotiation, reworked revocation * type negotiation * cleanup * added introduction * editing * editing * editing * Update issuance.md fixed grammar. * added potential future CrendentialInfo methods * Fix Credential Kinds links Minor formatting. * First 3 files review, typos and extra info * Update DIDComm spec introduction slightly * Change DIDComm spec sidebar ordering * Edit trust paragraph in authentication Remove redundant authentication example. * Update connection->feature discovery relationship * Minor changes to presentation * Spelling fixes * Reorder resources section to after protocols in overview * Reorder revocation to before revocation options * Improve credential links in presentation * Fix footnote numbering in signing * Update signing authorisation consideration * added description to sections * fix sidebar links * added diagram section * Deduplicate authentication protocol links * Deduplicate connection protocol links * Deduplicate issuance protocol links * Deduplicate presentation protocol links * Deduplicate signing protocol links * changed intro text * further presentation * cleaned up presentation * further overview * further authentication * renamed Credential Kinds, added description for trust considerations * further authentication * reworked presentation * updated changelog * removed TODO * fixed links * added disclaimer and changed headline structure * updated 'last updated' Co-authored-by: Eike Haß <eike-hass@web.de> Co-authored-by: Oliver Anderson <oliver.anderson@iota.org> Co-authored-by: JelleMillenaar <Jelle.millenaar@iota.org> * Restrict KeyCollection sizes (#411) * add an upper limit to the amount o keys that can be generated * comment count new behavior * fix pre-existing test to adjust to next power of two policy * set upper limit to 2^32 * define an upper limit of 2^12 for key collection * add check before allocating vec * throw error when trying to create a KeyCollection with 0 keys, improve comments * fix comment * run cargo fmt * add const MAX_PROOF_NODES for limiting the amount of nodes in a Proof * fix fmt * Clean up previous didcomm impl (#470) * Removed messages from the wasm bindings * Revert "Removed messages from the wasm bindings" This reverts commit e66cf82. * cleaned up identity-comm/src/messages and identity-comm/src/tests (#467) * deleted bindings/wasm/src/message (#468) * build api-reference Co-authored-by: Oliver Anderson <oliver.anderson@iota.org> Co-authored-by: Eike Haß <eike-hass@web.de> * bump wasm to v0.4.0 (#472) * Bump crate versions to `0.4.0` (#471) * Bump crate versions to `0.4.0` * Bump `identity-wasm`, too! * Bump `identity-wasm` itself, too. Co-authored-by: l1h3r <devin.turner@iota.org> Co-authored-by: Devin Turner <5410284+l1h3r@users.noreply.github.com> Co-authored-by: Matt Renaud <matt@m-renaud.com> Co-authored-by: Thoralf-M <thoralf.mue@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: PhilippGackstatter <philipp.gackstatter@iota.org> Co-authored-by: Abdulrahim Al Methiab <31316147+abdulmth@users.noreply.github.com> Co-authored-by: huhn511 <sehe89@gmail.com> Co-authored-by: Craig Bester <cycraig33@gmail.com> Co-authored-by: Abdulrahim Al Methiab <abdulrahim.almethiab@iota.org> Co-authored-by: HackMD <no-reply@hackmd.io> Co-authored-by: Craig Bester <craig.bester@iota.org> Co-authored-by: lucastortora <lucas.tortora@iota.org> Co-authored-by: eGarciaR <e.garcia.ribera@gmail.com> Co-authored-by: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> Co-authored-by: Eike Haß <eike-hass@web.de> Co-authored-by: Rajiv Shah <rajivshah1@icloud.com> Co-authored-by: lucas-tortora <85233773+lucas-tortora@users.noreply.github.com> Co-authored-by: charlesthompson3 <74603461+charlesthompson3@users.noreply.github.com> Co-authored-by: Phyloiota <77154511+Phyloiota@users.noreply.github.com> Co-authored-by: Christian M <7541795+chriamue@users.noreply.github.com> Co-authored-by: Oliver Anderson <oliver.anderson@iota.org> Co-authored-by: Dr-Electron <dr-electr0n@protonmail.com> Co-authored-by: Henrique Nogara <nogara.henrique@gmail.com>
Description of change
Give users of the
Account
more control over when to publish to the tangle. For example, if an identity is created and a service and a method are added subsequently, this would currently result in three messages being published to the tangle. With this PR, all changes can be applied to a locally stored document, and then published in a single message. That increases the overall speed, since there are fewer network interactions and less Proof-of-Work, and reduces the used storage space on nodes.Implementation
The
Account
already organizes the updates to a document inCommit
s. EachCommit
is identified by aGeneration
(an incrementingu32
). The basic idea is to store which generation was last published to the tangle, and when updating, publishing all commits that have been added since.One potential use-case might require setting the
autopublish
configuration not just when building theAccount
, but also on the instance itself. Users could then switch between the modes very flexibly. I would probably not add this for now, though, and see if the requirement actually comes up in practice. This is mainly to be in line with the current immutability of the account config, but would be open to discuss this. It would be fairly simple to add this through anAtomicBool
in theConfig
.Testing
Testing this really only makes sense if there is a tangle. As far as I'm aware, no tangle interaction is currently tested, except "passively" in the examples (they do run in CI now, but only once per day, not per PR). So we could do a couple of things:
I've chosen the third option and added an example that tests directly on the testnet. The test runs in 5 seconds; not adding significantly to the CI execution time.
Links to any relevant issues
part of #325
The other tasks of the issue will be completed in separate PRs.
Type of change
Add an
x
to the boxes that are relevant to your changes.How the change has been tested
The stronghold implementation was tested by modifying the stronghold example. The added test uses the
MemStore
.Change checklist
Add an
x
to the boxes that are relevant to your changes.