-
Notifications
You must be signed in to change notification settings - Fork 174
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
Cumulative PR for Wallet & Metrics Refactoring #360
Cumulative PR for Wallet & Metrics Refactoring #360
Conversation
misc wallet functionality update
… bug for automatic JSON RPC port mapping.
…spa_cli_lib" to prevent build collisions
…nect to occur before utxo_processor shutdown;
… of the RPC channel after closing the wallet
…nel, allow retention of a connected RPC channel past UtxoProcessor shutdown. (API centric defensive functionality)
…uld not be reached.
…to a separate module, add comments to MAGIC values in some locations
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.
Some minor comments.
@@ -0,0 +1,3 @@ | |||
pub mod client; | |||
pub mod server; | |||
// pub mod wasm; |
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.
Is this intentional that wasm is commented out?
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.
Adding a //TODO
note. This is a placeholder with some code copied over from RPC
meant to automate bindings for WalletApi
. I started working on bindings but quickly concluded that the WalletApi
needed to be stabilized before the bindings were made.
Also, there have been efforts made by @starkbamse and other contributors with regard to improving types in RPC bindings (which also apply here) and I had to freeze the effort till January in order to get a concise view of all issues in front of us so that all of this can be addressed and implemented as a single dedicated effort/pass.
} else if decimal_len <= 8 { | ||
decimal.parse::<u64>()? * 10u64.pow(8 - decimal_len as u32) | ||
} else { | ||
decimal[..8].parse::<u64>()? |
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.
Optional: This condition should never happen in a legitimate KAS value. So it might be worth changing this to an Err since this would mean you were passed a string that had 9+ decimals - which could mean something is off elsewhere in the code that made that happen.
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.
Hm.. It's a valid point... The function is constructed and is used mainly for user input and I am not sure of all the pros or cons of both cases. Like if you copy/paste a value from somewhere, it can have a very long fractional value... and I am not sure whether such a value should be rejected or truncated. It kind of falls into "what is best/friendliest for the user" domain... technically I think we should perhaps do something like ceil(v*1e8)/1e8
and then truncate... this way the user can input anything but will get back a rounded value... but perhaps a separate function should be made for that.
Let me add a TODO to this so that we can take a look at this a bit later on.
commit a4ba784 Author: Ori Newman <[email protected]> Date: Tue Dec 26 16:22:36 2023 +0200 Add headers first validation to simpa (kaspanet#364) commit fb1aa5f Author: Ori Newman <[email protected]> Date: Tue Dec 26 16:07:19 2023 +0200 Move to mimalloc (kaspanet#361) * mimalloc * mimalloc disable purge_decommits * Add to simpa and integration tests * remove redundant unix and replace with win/linux/mac * Add comment * Add comment * Sort out features * Get rid of ctor --------- Co-authored-by: Michael Sutton <[email protected]> commit b6f7e09 Author: aspect <[email protected]> Date: Tue Dec 26 13:38:24 2023 +0200 Cumulative PR for Wallet & Metrics Refactoring (kaspanet#360) * external access to kaspad core rpc services API * rename wallet event members for serde serialization misc wallet functionality update * wip - event renaming * wip - event serialization tuneup * remove default wrpc listening ports on kaspad Args + fix port mapping bug for automatic JSON RPC port mapping. * Box wallet events * introduce RpcCtl + isolate wRPC from DynRpcApi * debug trait for secret * de-couple wRPC from the runtiem wallet making RPC bindings generic * convert wallet_list to return Vec<WalletDescriptor> * user-friendly error message on decryption error * UtxoProcessor - ignore task shutdown if not running * wallet storage data versioning * wallet - propagate wallet title * sort traits on WalletDescriptor * wallet - use precise decimal conversion when parsing strings to sompi * display kaspa on get-balance-by-address-rpc * wallet - rename settings fns to have try_ prefixes * rename library names "kaspad" and "kaspa_cli" to "kaspad_lib" and "kaspa_cli_lib" to prevent build collisions * no-unsafe-eval feature * allow for chrome-extension schema in the RPC url * wallet - expose bip32 wordlist for external access * wallet - delegate rpc ownership to utxo_processor; reorder rpc disconnect to occur before utxo_processor shutdown; * wallet - migrate wallet settings loading to cli * rename RpcCtlOp (Open, Close) to RpcState (Opened, Closed) * remove automatic RPC disconnect from wallet stop() to allow retention of the RPC channel after closing the wallet * allow UtxoProcessor to bind to an already existing/connected RPC channel, allow retention of a connected RPC channel past UtxoProcessor shutdown. (API centric defensive functionality) * code formatting * fix clippy warnings * migrate chrome-extension to use ws:// schema by default * wallet list formatting * staging for WRS 0.7.0 * add bip32 word list iterator * update WRS to 0.7.0 * fix rustdoc errors * wip - initial WalletApi trait implementation * wallet - macros and account descriptors * wallet - ping_call * cleanup * wip - wallet api cleanup & testing * kaspa-metrics as a separate crate * wip - metrics cleanup * cargo.lock update * async/sync api changes for storage * merge * master merge * wip * wip * wip * wallet - (wip) changes to AccountDescriptor and Wallet API * metrics - make sink future return as optional * wip - refactor wallet open; improve wallet event ordering; cleanup * wip (debugging UtxoChanged notifications) - fix issuance during failed tx * adding workflow-rs as github dependency (allows CI) * revert github deps for WRS * metrics * refactor metrics to include bdi counts and peer counts * wallet api updates refactoring transaction access interface misc updates to wallet APIs refactor wallet open sequence refactor legacy accounts * wallet framework - fix a but resulting in the early issuane of UTXO maturity events. Refactor handling of outgoing transaction UTXOs (sending outgoing tx ACKs on UtxoChange removal), minor fixes in the Transaction file-system storage. Add "outgoing" property to account balances (to track in-flight transactions being submitted until acceptance). Introduce new Events::Change that gets fired specifically when receiving change of the currently outgoing transaction. Initial steps toward Daa property wrapper. * npm 0.13.0 * metrics - cleanup after RPC refactoring * rename rust-side of wasm bindings as naming conventions interfere with rust use (make fns more explicitly named) * make metrics data formatting fns as pub * expose log levels in kaspa-core::log * rename metrics & improve metrics fetch task * add API calls to pre-configure wallet framework stroage folders * cumulative updates for Cargo.lock * Improve address error messages for human readability * PrvKeyData enumeration, initial account transfer support (wip), wallet descriptor handling * wallet - change error to retain PrvKeyDataId instead of a String * propagate bip39 flag to runtime account and it's descriptor * wip - keydata refactoring * metrics refactoring (bandwidth) * wip (cleanup) * misc improvements to metrics * code formatting * wRPC bandwidth monitoring + scaffolding for global bandwidth metrics * bump WRS to 0.9.0 * metrics - add mempool_size and convert some items to u32/f32 * metrics cleanup * wallet and account rename, remove "title" from accounts * add missing mempool size metric * UTXO "stasis" mode for new coinbase transactions * remove useless Option from the rpc url parser * fix daa score in maturity state check * add name_or_id to PrvKeyDataInfo * wallet RPC Connect/Disconnect and GetStatus API calls * cleanup * support for 12-word bip39 mnemonics * add a hidden --daemon flag to kaspad * refactor get_daa_score_timestamp helper to return Vec<u64> instead of Response struct * Add Scan event * implement support for unixtime in transactions * kaspa value formatting functions * fix a deadlock due to re-entrant mutex lock when loading multiple accounts from storage * introduce utxo stasis mode + make balance carry utxo counts as well as the totals * refactor wallet events, replace reset() with close() where appropriate * manual debug impl for tx components (display script as hex, address as address etc) * fix incorrect gas assignment in WASM bindings * updates for wallet event handling * refactor sign_with_multiple to return Err(tx) when partially signed * refactor Storage and Wallet descriptors * fix account derivation index handling in DerivationCapable * track acceptance DAA stamp in outgoing transaction record * temporary harness for embedding script engine directly into tx generator (used for debugging) * convert PendingTransaction Utxo entries into HashSet * rename pending tx fns * outgoing tx wrapper around pending tx * refactor notification events during wallet ops * as_ref() for PrvKeyData * wip - initial RpcCoreMocks for wallet framework tests * wallet api messages update for StorageDescriptor usage * update AddressDerivationMeta to track addresses from index 0 * add AHash and async_channel to wallet_core crate * allow Args to be used externally for daemon argument pre-validation * impl Hash for UtxoEntryReference and rename "fake()" to "simulated()" * update wallet events * expose tx validator check_scripts() as pub * update wallet wasm fns for wallet and storage descriptors * rename kaspa-metrics to kaspa-metrics-core * code formatting * code formatting * migrate transaction console formatting to cli/extensions * refactor wallet events * use ahash for faster processing in wallet hash maps (utxo context) * wallet - add SendError handling for error::Error * wallet event refactoring, scan/discovery process refactoring, wallet change secret api handling * refactoring: transfer and deep derivation scan * transaction record refactoring * wallet - support for cross-account transfers in generator * wallet - outgoing transaction impl * wallet - refactor maturity handling * wallet/utxo - initial tests scaffolding * minor optimization of the discovery/scan process * wallet - utxo processor outgoing tx and discovery timestamp unixtime handling * refactor utxo context to use output transactions, refactor transfers, compound and change notifications * code formatting + Cargo.lock update * Signed enum to represent Fully or Partially signed tx * bind p2p and grpc bandwidth metrics * misc clippy fixes * cleanup * remove --daemon as Args::parse() offers external mutations * remove previously implemented mnemonic variant in favor of client-side mnemonic creation * remove AccessContextT, convert to wallet_secret, wip WalletApi traits, refactor account args * code formatting * separate runtime wallet into multiple modules * wallet - revert create_accounts to process a single account at a time * cleanup * wallet - JSON import and export + preliminary docs * address - AddressList - fix TryFrom deadlock caused by recursive trait invocation * wallet - api rustdoc + cleanup, transaction calls * wallet docs * change address debug formatting * adding cli rpc addpeer * wip - wallet restructuring * wip - restructure wallet modules * wip - wallet restructuring - cleanup * wip - AccountKind refactoring * wallet - refactoring storage serialization & encryption * fold in PR kaspanet#349 * wallet framework - misc helper fns and cleanup * storage unit tests + prv key data module restructuring * wallet - account factory registrations * Remove panics caused by sudden loss of connection while submitting transactions. * cleanup * cleanup * cleanup + docs * docs * adjust metrics formatting * cleanup * bump workflow-rs to 0.10.1 * fix wallet storage unit tests * fix generator unit tests * convert missing listener_id panic to error * docs * code formatting * lints * misc updates following github reviews * refactor AccountKind to use fixedstr and implement Copy * refactor AccountKind to use fixedstr (str64) and re-implement Copy, removing clone() where necessary * change js-bound fn names from *as* to *to* to follow Rust conventions * replace AssocPrvKeyDataIds iter().any() to contains() * remove vec![] in MetricsGroup iterator fn; add TODO comment on Metric::group() * scope magic numbers within their associated structs * add try_fully_signed() and try_partially_signed() fns to Signed that allow recovery of the tx * refactor local storage cache to use RwLock instead of a Mutex * refactor serialization as per github feedback (partial trait impl) * Optimize AssocPrvKeyDataIds to use Either in the IntoIter impl, removing allocations. * Refactor to bypass aux buffer creation when storing wallet on native platforms. * impl custom Debug for storage structs to display data in hex * adding misc SAFETY comments on unsafe ops * TODO comments for later SignerT+multisig refactoring * Change panic!() to unreachable!() to make it clearer that a state should not be reached. * rename TransactionRecord::unixtime to unixtime_msec * fix wrong references in comments * Fix min_cosigner_index handling in multisig fns * add comments to UtxoContext::insert() error handling * bind AccountStorable:Storable for AccountStorage, migrate Storable into a separate module, add comments to MAGIC values in some locations * make framework init functions unsafe * update workflow-rs to 0.10.2 * fix comments * fix data cloning when getting collection counts * adding TODO notes to wasm macros and KAS value decimal parsing --------- Co-authored-by: Surinder Singh Matoo <[email protected]> commit 10d0ebf Author: D-Stacks <[email protected]> Date: Tue Dec 26 10:43:59 2023 +0100 make step 3. of linux installation not fail copy and paste (kaspanet#363) remove the space to escape the newline instead.
… data sizes (#351) * cache inner struct: prep for tracking size * initial cache policy and mem size estimator * use new cache policies * fix storage calcs * update TN11 genesis * temp: limit max block parents in virtual processor * use more conservative constants (wip) * ensure sufficient cache allocs for high level stores * increase caches related to daa window * Squashed commit of the following: commit a4ba784 Author: Ori Newman <[email protected]> Date: Tue Dec 26 16:22:36 2023 +0200 Add headers first validation to simpa (#364) commit fb1aa5f Author: Ori Newman <[email protected]> Date: Tue Dec 26 16:07:19 2023 +0200 Move to mimalloc (#361) * mimalloc * mimalloc disable purge_decommits * Add to simpa and integration tests * remove redundant unix and replace with win/linux/mac * Add comment * Add comment * Sort out features * Get rid of ctor --------- Co-authored-by: Michael Sutton <[email protected]> commit b6f7e09 Author: aspect <[email protected]> Date: Tue Dec 26 13:38:24 2023 +0200 Cumulative PR for Wallet & Metrics Refactoring (#360) * external access to kaspad core rpc services API * rename wallet event members for serde serialization misc wallet functionality update * wip - event renaming * wip - event serialization tuneup * remove default wrpc listening ports on kaspad Args + fix port mapping bug for automatic JSON RPC port mapping. * Box wallet events * introduce RpcCtl + isolate wRPC from DynRpcApi * debug trait for secret * de-couple wRPC from the runtiem wallet making RPC bindings generic * convert wallet_list to return Vec<WalletDescriptor> * user-friendly error message on decryption error * UtxoProcessor - ignore task shutdown if not running * wallet storage data versioning * wallet - propagate wallet title * sort traits on WalletDescriptor * wallet - use precise decimal conversion when parsing strings to sompi * display kaspa on get-balance-by-address-rpc * wallet - rename settings fns to have try_ prefixes * rename library names "kaspad" and "kaspa_cli" to "kaspad_lib" and "kaspa_cli_lib" to prevent build collisions * no-unsafe-eval feature * allow for chrome-extension schema in the RPC url * wallet - expose bip32 wordlist for external access * wallet - delegate rpc ownership to utxo_processor; reorder rpc disconnect to occur before utxo_processor shutdown; * wallet - migrate wallet settings loading to cli * rename RpcCtlOp (Open, Close) to RpcState (Opened, Closed) * remove automatic RPC disconnect from wallet stop() to allow retention of the RPC channel after closing the wallet * allow UtxoProcessor to bind to an already existing/connected RPC channel, allow retention of a connected RPC channel past UtxoProcessor shutdown. (API centric defensive functionality) * code formatting * fix clippy warnings * migrate chrome-extension to use ws:// schema by default * wallet list formatting * staging for WRS 0.7.0 * add bip32 word list iterator * update WRS to 0.7.0 * fix rustdoc errors * wip - initial WalletApi trait implementation * wallet - macros and account descriptors * wallet - ping_call * cleanup * wip - wallet api cleanup & testing * kaspa-metrics as a separate crate * wip - metrics cleanup * cargo.lock update * async/sync api changes for storage * merge * master merge * wip * wip * wip * wallet - (wip) changes to AccountDescriptor and Wallet API * metrics - make sink future return as optional * wip - refactor wallet open; improve wallet event ordering; cleanup * wip (debugging UtxoChanged notifications) - fix issuance during failed tx * adding workflow-rs as github dependency (allows CI) * revert github deps for WRS * metrics * refactor metrics to include bdi counts and peer counts * wallet api updates refactoring transaction access interface misc updates to wallet APIs refactor wallet open sequence refactor legacy accounts * wallet framework - fix a but resulting in the early issuane of UTXO maturity events. Refactor handling of outgoing transaction UTXOs (sending outgoing tx ACKs on UtxoChange removal), minor fixes in the Transaction file-system storage. Add "outgoing" property to account balances (to track in-flight transactions being submitted until acceptance). Introduce new Events::Change that gets fired specifically when receiving change of the currently outgoing transaction. Initial steps toward Daa property wrapper. * npm 0.13.0 * metrics - cleanup after RPC refactoring * rename rust-side of wasm bindings as naming conventions interfere with rust use (make fns more explicitly named) * make metrics data formatting fns as pub * expose log levels in kaspa-core::log * rename metrics & improve metrics fetch task * add API calls to pre-configure wallet framework stroage folders * cumulative updates for Cargo.lock * Improve address error messages for human readability * PrvKeyData enumeration, initial account transfer support (wip), wallet descriptor handling * wallet - change error to retain PrvKeyDataId instead of a String * propagate bip39 flag to runtime account and it's descriptor * wip - keydata refactoring * metrics refactoring (bandwidth) * wip (cleanup) * misc improvements to metrics * code formatting * wRPC bandwidth monitoring + scaffolding for global bandwidth metrics * bump WRS to 0.9.0 * metrics - add mempool_size and convert some items to u32/f32 * metrics cleanup * wallet and account rename, remove "title" from accounts * add missing mempool size metric * UTXO "stasis" mode for new coinbase transactions * remove useless Option from the rpc url parser * fix daa score in maturity state check * add name_or_id to PrvKeyDataInfo * wallet RPC Connect/Disconnect and GetStatus API calls * cleanup * support for 12-word bip39 mnemonics * add a hidden --daemon flag to kaspad * refactor get_daa_score_timestamp helper to return Vec<u64> instead of Response struct * Add Scan event * implement support for unixtime in transactions * kaspa value formatting functions * fix a deadlock due to re-entrant mutex lock when loading multiple accounts from storage * introduce utxo stasis mode + make balance carry utxo counts as well as the totals * refactor wallet events, replace reset() with close() where appropriate * manual debug impl for tx components (display script as hex, address as address etc) * fix incorrect gas assignment in WASM bindings * updates for wallet event handling * refactor sign_with_multiple to return Err(tx) when partially signed * refactor Storage and Wallet descriptors * fix account derivation index handling in DerivationCapable * track acceptance DAA stamp in outgoing transaction record * temporary harness for embedding script engine directly into tx generator (used for debugging) * convert PendingTransaction Utxo entries into HashSet * rename pending tx fns * outgoing tx wrapper around pending tx * refactor notification events during wallet ops * as_ref() for PrvKeyData * wip - initial RpcCoreMocks for wallet framework tests * wallet api messages update for StorageDescriptor usage * update AddressDerivationMeta to track addresses from index 0 * add AHash and async_channel to wallet_core crate * allow Args to be used externally for daemon argument pre-validation * impl Hash for UtxoEntryReference and rename "fake()" to "simulated()" * update wallet events * expose tx validator check_scripts() as pub * update wallet wasm fns for wallet and storage descriptors * rename kaspa-metrics to kaspa-metrics-core * code formatting * code formatting * migrate transaction console formatting to cli/extensions * refactor wallet events * use ahash for faster processing in wallet hash maps (utxo context) * wallet - add SendError handling for error::Error * wallet event refactoring, scan/discovery process refactoring, wallet change secret api handling * refactoring: transfer and deep derivation scan * transaction record refactoring * wallet - support for cross-account transfers in generator * wallet - outgoing transaction impl * wallet - refactor maturity handling * wallet/utxo - initial tests scaffolding * minor optimization of the discovery/scan process * wallet - utxo processor outgoing tx and discovery timestamp unixtime handling * refactor utxo context to use output transactions, refactor transfers, compound and change notifications * code formatting + Cargo.lock update * Signed enum to represent Fully or Partially signed tx * bind p2p and grpc bandwidth metrics * misc clippy fixes * cleanup * remove --daemon as Args::parse() offers external mutations * remove previously implemented mnemonic variant in favor of client-side mnemonic creation * remove AccessContextT, convert to wallet_secret, wip WalletApi traits, refactor account args * code formatting * separate runtime wallet into multiple modules * wallet - revert create_accounts to process a single account at a time * cleanup * wallet - JSON import and export + preliminary docs * address - AddressList - fix TryFrom deadlock caused by recursive trait invocation * wallet - api rustdoc + cleanup, transaction calls * wallet docs * change address debug formatting * adding cli rpc addpeer * wip - wallet restructuring * wip - restructure wallet modules * wip - wallet restructuring - cleanup * wip - AccountKind refactoring * wallet - refactoring storage serialization & encryption * fold in PR #349 * wallet framework - misc helper fns and cleanup * storage unit tests + prv key data module restructuring * wallet - account factory registrations * Remove panics caused by sudden loss of connection while submitting transactions. * cleanup * cleanup * cleanup + docs * docs * adjust metrics formatting * cleanup * bump workflow-rs to 0.10.1 * fix wallet storage unit tests * fix generator unit tests * convert missing listener_id panic to error * docs * code formatting * lints * misc updates following github reviews * refactor AccountKind to use fixedstr and implement Copy * refactor AccountKind to use fixedstr (str64) and re-implement Copy, removing clone() where necessary * change js-bound fn names from *as* to *to* to follow Rust conventions * replace AssocPrvKeyDataIds iter().any() to contains() * remove vec![] in MetricsGroup iterator fn; add TODO comment on Metric::group() * scope magic numbers within their associated structs * add try_fully_signed() and try_partially_signed() fns to Signed that allow recovery of the tx * refactor local storage cache to use RwLock instead of a Mutex * refactor serialization as per github feedback (partial trait impl) * Optimize AssocPrvKeyDataIds to use Either in the IntoIter impl, removing allocations. * Refactor to bypass aux buffer creation when storing wallet on native platforms. * impl custom Debug for storage structs to display data in hex * adding misc SAFETY comments on unsafe ops * TODO comments for later SignerT+multisig refactoring * Change panic!() to unreachable!() to make it clearer that a state should not be reached. * rename TransactionRecord::unixtime to unixtime_msec * fix wrong references in comments * Fix min_cosigner_index handling in multisig fns * add comments to UtxoContext::insert() error handling * bind AccountStorable:Storable for AccountStorage, migrate Storable into a separate module, add comments to MAGIC values in some locations * make framework init functions unsafe * update workflow-rs to 0.10.2 * fix comments * fix data cloning when getting collection counts * adding TODO notes to wasm macros and KAS value decimal parsing --------- Co-authored-by: Surinder Singh Matoo <[email protected]> commit 10d0ebf Author: D-Stacks <[email protected]> Date: Tue Dec 26 10:43:59 2023 +0100 make step 3. of linux installation not fail copy and paste (#363) remove the space to escape the newline instead. * reduce children cache policy * reduce caches 25% * increase tx cache * fix gd alloc and slightly increase other numbers * fix a cache alloc bug by redesigning the cache and adding a min units option + fix bps constants * fix simpa short cmd op name colision * move impls to inner struct * comments, docs and technical refactoring * refactor MemSizeEstimator * refactor bool to MemMode * memsize docs * remove unneeded min limits * comments and name enhancements * rename `CachePolicy::Units` to `CachePolicy::Count` to avoid confusion with `MemMode` * use estimated num of unique headers in validate pruning point headers cache * cache policy builder * add todos * median window has different size + comments * read ghostdag data from compact access if possible * remove wrong upper bound for reachability sets
* external access to kaspad core rpc services API * rename wallet event members for serde serialization misc wallet functionality update * wip - event renaming * wip - event serialization tuneup * remove default wrpc listening ports on kaspad Args + fix port mapping bug for automatic JSON RPC port mapping. * Box wallet events * introduce RpcCtl + isolate wRPC from DynRpcApi * debug trait for secret * de-couple wRPC from the runtiem wallet making RPC bindings generic * convert wallet_list to return Vec<WalletDescriptor> * user-friendly error message on decryption error * UtxoProcessor - ignore task shutdown if not running * wallet storage data versioning * wallet - propagate wallet title * sort traits on WalletDescriptor * wallet - use precise decimal conversion when parsing strings to sompi * display kaspa on get-balance-by-address-rpc * wallet - rename settings fns to have try_ prefixes * rename library names "kaspad" and "kaspa_cli" to "kaspad_lib" and "kaspa_cli_lib" to prevent build collisions * no-unsafe-eval feature * allow for chrome-extension schema in the RPC url * wallet - expose bip32 wordlist for external access * wallet - delegate rpc ownership to utxo_processor; reorder rpc disconnect to occur before utxo_processor shutdown; * wallet - migrate wallet settings loading to cli * rename RpcCtlOp (Open, Close) to RpcState (Opened, Closed) * remove automatic RPC disconnect from wallet stop() to allow retention of the RPC channel after closing the wallet * allow UtxoProcessor to bind to an already existing/connected RPC channel, allow retention of a connected RPC channel past UtxoProcessor shutdown. (API centric defensive functionality) * code formatting * fix clippy warnings * migrate chrome-extension to use ws:// schema by default * wallet list formatting * staging for WRS 0.7.0 * add bip32 word list iterator * update WRS to 0.7.0 * fix rustdoc errors * wip - initial WalletApi trait implementation * wallet - macros and account descriptors * wallet - ping_call * cleanup * wip - wallet api cleanup & testing * kaspa-metrics as a separate crate * wip - metrics cleanup * cargo.lock update * async/sync api changes for storage * merge * master merge * wip * wip * wip * wallet - (wip) changes to AccountDescriptor and Wallet API * metrics - make sink future return as optional * wip - refactor wallet open; improve wallet event ordering; cleanup * wip (debugging UtxoChanged notifications) - fix issuance during failed tx * adding workflow-rs as github dependency (allows CI) * revert github deps for WRS * metrics * refactor metrics to include bdi counts and peer counts * wallet api updates refactoring transaction access interface misc updates to wallet APIs refactor wallet open sequence refactor legacy accounts * wallet framework - fix a but resulting in the early issuane of UTXO maturity events. Refactor handling of outgoing transaction UTXOs (sending outgoing tx ACKs on UtxoChange removal), minor fixes in the Transaction file-system storage. Add "outgoing" property to account balances (to track in-flight transactions being submitted until acceptance). Introduce new Events::Change that gets fired specifically when receiving change of the currently outgoing transaction. Initial steps toward Daa property wrapper. * npm 0.13.0 * metrics - cleanup after RPC refactoring * rename rust-side of wasm bindings as naming conventions interfere with rust use (make fns more explicitly named) * make metrics data formatting fns as pub * expose log levels in kaspa-core::log * rename metrics & improve metrics fetch task * add API calls to pre-configure wallet framework stroage folders * cumulative updates for Cargo.lock * Improve address error messages for human readability * PrvKeyData enumeration, initial account transfer support (wip), wallet descriptor handling * wallet - change error to retain PrvKeyDataId instead of a String * propagate bip39 flag to runtime account and it's descriptor * wip - keydata refactoring * metrics refactoring (bandwidth) * wip (cleanup) * misc improvements to metrics * code formatting * wRPC bandwidth monitoring + scaffolding for global bandwidth metrics * bump WRS to 0.9.0 * metrics - add mempool_size and convert some items to u32/f32 * metrics cleanup * wallet and account rename, remove "title" from accounts * add missing mempool size metric * UTXO "stasis" mode for new coinbase transactions * remove useless Option from the rpc url parser * fix daa score in maturity state check * add name_or_id to PrvKeyDataInfo * wallet RPC Connect/Disconnect and GetStatus API calls * cleanup * support for 12-word bip39 mnemonics * add a hidden --daemon flag to kaspad * refactor get_daa_score_timestamp helper to return Vec<u64> instead of Response struct * Add Scan event * implement support for unixtime in transactions * kaspa value formatting functions * fix a deadlock due to re-entrant mutex lock when loading multiple accounts from storage * introduce utxo stasis mode + make balance carry utxo counts as well as the totals * refactor wallet events, replace reset() with close() where appropriate * manual debug impl for tx components (display script as hex, address as address etc) * fix incorrect gas assignment in WASM bindings * updates for wallet event handling * refactor sign_with_multiple to return Err(tx) when partially signed * refactor Storage and Wallet descriptors * fix account derivation index handling in DerivationCapable * track acceptance DAA stamp in outgoing transaction record * temporary harness for embedding script engine directly into tx generator (used for debugging) * convert PendingTransaction Utxo entries into HashSet * rename pending tx fns * outgoing tx wrapper around pending tx * refactor notification events during wallet ops * as_ref() for PrvKeyData * wip - initial RpcCoreMocks for wallet framework tests * wallet api messages update for StorageDescriptor usage * update AddressDerivationMeta to track addresses from index 0 * add AHash and async_channel to wallet_core crate * allow Args to be used externally for daemon argument pre-validation * impl Hash for UtxoEntryReference and rename "fake()" to "simulated()" * update wallet events * expose tx validator check_scripts() as pub * update wallet wasm fns for wallet and storage descriptors * rename kaspa-metrics to kaspa-metrics-core * code formatting * code formatting * migrate transaction console formatting to cli/extensions * refactor wallet events * use ahash for faster processing in wallet hash maps (utxo context) * wallet - add SendError handling for error::Error * wallet event refactoring, scan/discovery process refactoring, wallet change secret api handling * refactoring: transfer and deep derivation scan * transaction record refactoring * wallet - support for cross-account transfers in generator * wallet - outgoing transaction impl * wallet - refactor maturity handling * wallet/utxo - initial tests scaffolding * minor optimization of the discovery/scan process * wallet - utxo processor outgoing tx and discovery timestamp unixtime handling * refactor utxo context to use output transactions, refactor transfers, compound and change notifications * code formatting + Cargo.lock update * Signed enum to represent Fully or Partially signed tx * bind p2p and grpc bandwidth metrics * misc clippy fixes * cleanup * remove --daemon as Args::parse() offers external mutations * remove previously implemented mnemonic variant in favor of client-side mnemonic creation * remove AccessContextT, convert to wallet_secret, wip WalletApi traits, refactor account args * code formatting * separate runtime wallet into multiple modules * wallet - revert create_accounts to process a single account at a time * cleanup * wallet - JSON import and export + preliminary docs * address - AddressList - fix TryFrom deadlock caused by recursive trait invocation * wallet - api rustdoc + cleanup, transaction calls * wallet docs * change address debug formatting * adding cli rpc addpeer * wip - wallet restructuring * wip - restructure wallet modules * wip - wallet restructuring - cleanup * wip - AccountKind refactoring * wallet - refactoring storage serialization & encryption * fold in PR kaspanet#349 * wallet framework - misc helper fns and cleanup * storage unit tests + prv key data module restructuring * wallet - account factory registrations * Remove panics caused by sudden loss of connection while submitting transactions. * cleanup * cleanup * cleanup + docs * docs * adjust metrics formatting * cleanup * bump workflow-rs to 0.10.1 * fix wallet storage unit tests * fix generator unit tests * convert missing listener_id panic to error * docs * code formatting * lints * misc updates following github reviews * refactor AccountKind to use fixedstr and implement Copy * refactor AccountKind to use fixedstr (str64) and re-implement Copy, removing clone() where necessary * change js-bound fn names from *as* to *to* to follow Rust conventions * replace AssocPrvKeyDataIds iter().any() to contains() * remove vec![] in MetricsGroup iterator fn; add TODO comment on Metric::group() * scope magic numbers within their associated structs * add try_fully_signed() and try_partially_signed() fns to Signed that allow recovery of the tx * refactor local storage cache to use RwLock instead of a Mutex * refactor serialization as per github feedback (partial trait impl) * Optimize AssocPrvKeyDataIds to use Either in the IntoIter impl, removing allocations. * Refactor to bypass aux buffer creation when storing wallet on native platforms. * impl custom Debug for storage structs to display data in hex * adding misc SAFETY comments on unsafe ops * TODO comments for later SignerT+multisig refactoring * Change panic!() to unreachable!() to make it clearer that a state should not be reached. * rename TransactionRecord::unixtime to unixtime_msec * fix wrong references in comments * Fix min_cosigner_index handling in multisig fns * add comments to UtxoContext::insert() error handling * bind AccountStorable:Storable for AccountStorage, migrate Storable into a separate module, add comments to MAGIC values in some locations * make framework init functions unsafe * update workflow-rs to 0.10.2 * fix comments * fix data cloning when getting collection counts * adding TODO notes to wasm macros and KAS value decimal parsing --------- Co-authored-by: Surinder Singh Matoo <[email protected]>
… data sizes (kaspanet#351) * cache inner struct: prep for tracking size * initial cache policy and mem size estimator * use new cache policies * fix storage calcs * update TN11 genesis * temp: limit max block parents in virtual processor * use more conservative constants (wip) * ensure sufficient cache allocs for high level stores * increase caches related to daa window * Squashed commit of the following: commit a4ba784 Author: Ori Newman <[email protected]> Date: Tue Dec 26 16:22:36 2023 +0200 Add headers first validation to simpa (kaspanet#364) commit fb1aa5f Author: Ori Newman <[email protected]> Date: Tue Dec 26 16:07:19 2023 +0200 Move to mimalloc (kaspanet#361) * mimalloc * mimalloc disable purge_decommits * Add to simpa and integration tests * remove redundant unix and replace with win/linux/mac * Add comment * Add comment * Sort out features * Get rid of ctor --------- Co-authored-by: Michael Sutton <[email protected]> commit b6f7e09 Author: aspect <[email protected]> Date: Tue Dec 26 13:38:24 2023 +0200 Cumulative PR for Wallet & Metrics Refactoring (kaspanet#360) * external access to kaspad core rpc services API * rename wallet event members for serde serialization misc wallet functionality update * wip - event renaming * wip - event serialization tuneup * remove default wrpc listening ports on kaspad Args + fix port mapping bug for automatic JSON RPC port mapping. * Box wallet events * introduce RpcCtl + isolate wRPC from DynRpcApi * debug trait for secret * de-couple wRPC from the runtiem wallet making RPC bindings generic * convert wallet_list to return Vec<WalletDescriptor> * user-friendly error message on decryption error * UtxoProcessor - ignore task shutdown if not running * wallet storage data versioning * wallet - propagate wallet title * sort traits on WalletDescriptor * wallet - use precise decimal conversion when parsing strings to sompi * display kaspa on get-balance-by-address-rpc * wallet - rename settings fns to have try_ prefixes * rename library names "kaspad" and "kaspa_cli" to "kaspad_lib" and "kaspa_cli_lib" to prevent build collisions * no-unsafe-eval feature * allow for chrome-extension schema in the RPC url * wallet - expose bip32 wordlist for external access * wallet - delegate rpc ownership to utxo_processor; reorder rpc disconnect to occur before utxo_processor shutdown; * wallet - migrate wallet settings loading to cli * rename RpcCtlOp (Open, Close) to RpcState (Opened, Closed) * remove automatic RPC disconnect from wallet stop() to allow retention of the RPC channel after closing the wallet * allow UtxoProcessor to bind to an already existing/connected RPC channel, allow retention of a connected RPC channel past UtxoProcessor shutdown. (API centric defensive functionality) * code formatting * fix clippy warnings * migrate chrome-extension to use ws:// schema by default * wallet list formatting * staging for WRS 0.7.0 * add bip32 word list iterator * update WRS to 0.7.0 * fix rustdoc errors * wip - initial WalletApi trait implementation * wallet - macros and account descriptors * wallet - ping_call * cleanup * wip - wallet api cleanup & testing * kaspa-metrics as a separate crate * wip - metrics cleanup * cargo.lock update * async/sync api changes for storage * merge * master merge * wip * wip * wip * wallet - (wip) changes to AccountDescriptor and Wallet API * metrics - make sink future return as optional * wip - refactor wallet open; improve wallet event ordering; cleanup * wip (debugging UtxoChanged notifications) - fix issuance during failed tx * adding workflow-rs as github dependency (allows CI) * revert github deps for WRS * metrics * refactor metrics to include bdi counts and peer counts * wallet api updates refactoring transaction access interface misc updates to wallet APIs refactor wallet open sequence refactor legacy accounts * wallet framework - fix a but resulting in the early issuane of UTXO maturity events. Refactor handling of outgoing transaction UTXOs (sending outgoing tx ACKs on UtxoChange removal), minor fixes in the Transaction file-system storage. Add "outgoing" property to account balances (to track in-flight transactions being submitted until acceptance). Introduce new Events::Change that gets fired specifically when receiving change of the currently outgoing transaction. Initial steps toward Daa property wrapper. * npm 0.13.0 * metrics - cleanup after RPC refactoring * rename rust-side of wasm bindings as naming conventions interfere with rust use (make fns more explicitly named) * make metrics data formatting fns as pub * expose log levels in kaspa-core::log * rename metrics & improve metrics fetch task * add API calls to pre-configure wallet framework stroage folders * cumulative updates for Cargo.lock * Improve address error messages for human readability * PrvKeyData enumeration, initial account transfer support (wip), wallet descriptor handling * wallet - change error to retain PrvKeyDataId instead of a String * propagate bip39 flag to runtime account and it's descriptor * wip - keydata refactoring * metrics refactoring (bandwidth) * wip (cleanup) * misc improvements to metrics * code formatting * wRPC bandwidth monitoring + scaffolding for global bandwidth metrics * bump WRS to 0.9.0 * metrics - add mempool_size and convert some items to u32/f32 * metrics cleanup * wallet and account rename, remove "title" from accounts * add missing mempool size metric * UTXO "stasis" mode for new coinbase transactions * remove useless Option from the rpc url parser * fix daa score in maturity state check * add name_or_id to PrvKeyDataInfo * wallet RPC Connect/Disconnect and GetStatus API calls * cleanup * support for 12-word bip39 mnemonics * add a hidden --daemon flag to kaspad * refactor get_daa_score_timestamp helper to return Vec<u64> instead of Response struct * Add Scan event * implement support for unixtime in transactions * kaspa value formatting functions * fix a deadlock due to re-entrant mutex lock when loading multiple accounts from storage * introduce utxo stasis mode + make balance carry utxo counts as well as the totals * refactor wallet events, replace reset() with close() where appropriate * manual debug impl for tx components (display script as hex, address as address etc) * fix incorrect gas assignment in WASM bindings * updates for wallet event handling * refactor sign_with_multiple to return Err(tx) when partially signed * refactor Storage and Wallet descriptors * fix account derivation index handling in DerivationCapable * track acceptance DAA stamp in outgoing transaction record * temporary harness for embedding script engine directly into tx generator (used for debugging) * convert PendingTransaction Utxo entries into HashSet * rename pending tx fns * outgoing tx wrapper around pending tx * refactor notification events during wallet ops * as_ref() for PrvKeyData * wip - initial RpcCoreMocks for wallet framework tests * wallet api messages update for StorageDescriptor usage * update AddressDerivationMeta to track addresses from index 0 * add AHash and async_channel to wallet_core crate * allow Args to be used externally for daemon argument pre-validation * impl Hash for UtxoEntryReference and rename "fake()" to "simulated()" * update wallet events * expose tx validator check_scripts() as pub * update wallet wasm fns for wallet and storage descriptors * rename kaspa-metrics to kaspa-metrics-core * code formatting * code formatting * migrate transaction console formatting to cli/extensions * refactor wallet events * use ahash for faster processing in wallet hash maps (utxo context) * wallet - add SendError handling for error::Error * wallet event refactoring, scan/discovery process refactoring, wallet change secret api handling * refactoring: transfer and deep derivation scan * transaction record refactoring * wallet - support for cross-account transfers in generator * wallet - outgoing transaction impl * wallet - refactor maturity handling * wallet/utxo - initial tests scaffolding * minor optimization of the discovery/scan process * wallet - utxo processor outgoing tx and discovery timestamp unixtime handling * refactor utxo context to use output transactions, refactor transfers, compound and change notifications * code formatting + Cargo.lock update * Signed enum to represent Fully or Partially signed tx * bind p2p and grpc bandwidth metrics * misc clippy fixes * cleanup * remove --daemon as Args::parse() offers external mutations * remove previously implemented mnemonic variant in favor of client-side mnemonic creation * remove AccessContextT, convert to wallet_secret, wip WalletApi traits, refactor account args * code formatting * separate runtime wallet into multiple modules * wallet - revert create_accounts to process a single account at a time * cleanup * wallet - JSON import and export + preliminary docs * address - AddressList - fix TryFrom deadlock caused by recursive trait invocation * wallet - api rustdoc + cleanup, transaction calls * wallet docs * change address debug formatting * adding cli rpc addpeer * wip - wallet restructuring * wip - restructure wallet modules * wip - wallet restructuring - cleanup * wip - AccountKind refactoring * wallet - refactoring storage serialization & encryption * fold in PR kaspanet#349 * wallet framework - misc helper fns and cleanup * storage unit tests + prv key data module restructuring * wallet - account factory registrations * Remove panics caused by sudden loss of connection while submitting transactions. * cleanup * cleanup * cleanup + docs * docs * adjust metrics formatting * cleanup * bump workflow-rs to 0.10.1 * fix wallet storage unit tests * fix generator unit tests * convert missing listener_id panic to error * docs * code formatting * lints * misc updates following github reviews * refactor AccountKind to use fixedstr and implement Copy * refactor AccountKind to use fixedstr (str64) and re-implement Copy, removing clone() where necessary * change js-bound fn names from *as* to *to* to follow Rust conventions * replace AssocPrvKeyDataIds iter().any() to contains() * remove vec![] in MetricsGroup iterator fn; add TODO comment on Metric::group() * scope magic numbers within their associated structs * add try_fully_signed() and try_partially_signed() fns to Signed that allow recovery of the tx * refactor local storage cache to use RwLock instead of a Mutex * refactor serialization as per github feedback (partial trait impl) * Optimize AssocPrvKeyDataIds to use Either in the IntoIter impl, removing allocations. * Refactor to bypass aux buffer creation when storing wallet on native platforms. * impl custom Debug for storage structs to display data in hex * adding misc SAFETY comments on unsafe ops * TODO comments for later SignerT+multisig refactoring * Change panic!() to unreachable!() to make it clearer that a state should not be reached. * rename TransactionRecord::unixtime to unixtime_msec * fix wrong references in comments * Fix min_cosigner_index handling in multisig fns * add comments to UtxoContext::insert() error handling * bind AccountStorable:Storable for AccountStorage, migrate Storable into a separate module, add comments to MAGIC values in some locations * make framework init functions unsafe * update workflow-rs to 0.10.2 * fix comments * fix data cloning when getting collection counts * adding TODO notes to wasm macros and KAS value decimal parsing --------- Co-authored-by: Surinder Singh Matoo <[email protected]> commit 10d0ebf Author: D-Stacks <[email protected]> Date: Tue Dec 26 10:43:59 2023 +0100 make step 3. of linux installation not fail copy and paste (kaspanet#363) remove the space to escape the newline instead. * reduce children cache policy * reduce caches 25% * increase tx cache * fix gd alloc and slightly increase other numbers * fix a cache alloc bug by redesigning the cache and adding a min units option + fix bps constants * fix simpa short cmd op name colision * move impls to inner struct * comments, docs and technical refactoring * refactor MemSizeEstimator * refactor bool to MemMode * memsize docs * remove unneeded min limits * comments and name enhancements * rename `CachePolicy::Units` to `CachePolicy::Count` to avoid confusion with `MemMode` * use estimated num of unique headers in validate pruning point headers cache * cache policy builder * add todos * median window has different size + comments * read ghostdag data from compact access if possible * remove wrong upper bound for reachability sets
* external access to kaspad core rpc services API * rename wallet event members for serde serialization misc wallet functionality update * wip - event renaming * wip - event serialization tuneup * remove default wrpc listening ports on kaspad Args + fix port mapping bug for automatic JSON RPC port mapping. * Box wallet events * introduce RpcCtl + isolate wRPC from DynRpcApi * debug trait for secret * de-couple wRPC from the runtiem wallet making RPC bindings generic * convert wallet_list to return Vec<WalletDescriptor> * user-friendly error message on decryption error * UtxoProcessor - ignore task shutdown if not running * wallet storage data versioning * wallet - propagate wallet title * sort traits on WalletDescriptor * wallet - use precise decimal conversion when parsing strings to sompi * display kaspa on get-balance-by-address-rpc * wallet - rename settings fns to have try_ prefixes * rename library names "kaspad" and "kaspa_cli" to "kaspad_lib" and "kaspa_cli_lib" to prevent build collisions * no-unsafe-eval feature * allow for chrome-extension schema in the RPC url * wallet - expose bip32 wordlist for external access * wallet - delegate rpc ownership to utxo_processor; reorder rpc disconnect to occur before utxo_processor shutdown; * wallet - migrate wallet settings loading to cli * rename RpcCtlOp (Open, Close) to RpcState (Opened, Closed) * remove automatic RPC disconnect from wallet stop() to allow retention of the RPC channel after closing the wallet * allow UtxoProcessor to bind to an already existing/connected RPC channel, allow retention of a connected RPC channel past UtxoProcessor shutdown. (API centric defensive functionality) * code formatting * fix clippy warnings * migrate chrome-extension to use ws:// schema by default * wallet list formatting * staging for WRS 0.7.0 * add bip32 word list iterator * update WRS to 0.7.0 * fix rustdoc errors * wip - initial WalletApi trait implementation * wallet - macros and account descriptors * wallet - ping_call * cleanup * wip - wallet api cleanup & testing * kaspa-metrics as a separate crate * wip - metrics cleanup * cargo.lock update * async/sync api changes for storage * merge * master merge * wip * wip * wip * wallet - (wip) changes to AccountDescriptor and Wallet API * metrics - make sink future return as optional * wip - refactor wallet open; improve wallet event ordering; cleanup * wip (debugging UtxoChanged notifications) - fix issuance during failed tx * adding workflow-rs as github dependency (allows CI) * revert github deps for WRS * metrics * refactor metrics to include bdi counts and peer counts * wallet api updates refactoring transaction access interface misc updates to wallet APIs refactor wallet open sequence refactor legacy accounts * wallet framework - fix a but resulting in the early issuane of UTXO maturity events. Refactor handling of outgoing transaction UTXOs (sending outgoing tx ACKs on UtxoChange removal), minor fixes in the Transaction file-system storage. Add "outgoing" property to account balances (to track in-flight transactions being submitted until acceptance). Introduce new Events::Change that gets fired specifically when receiving change of the currently outgoing transaction. Initial steps toward Daa property wrapper. * npm 0.13.0 * metrics - cleanup after RPC refactoring * rename rust-side of wasm bindings as naming conventions interfere with rust use (make fns more explicitly named) * make metrics data formatting fns as pub * expose log levels in kaspa-core::log * rename metrics & improve metrics fetch task * add API calls to pre-configure wallet framework stroage folders * cumulative updates for Cargo.lock * Improve address error messages for human readability * PrvKeyData enumeration, initial account transfer support (wip), wallet descriptor handling * wallet - change error to retain PrvKeyDataId instead of a String * propagate bip39 flag to runtime account and it's descriptor * wip - keydata refactoring * metrics refactoring (bandwidth) * wip (cleanup) * misc improvements to metrics * code formatting * wRPC bandwidth monitoring + scaffolding for global bandwidth metrics * bump WRS to 0.9.0 * metrics - add mempool_size and convert some items to u32/f32 * metrics cleanup * wallet and account rename, remove "title" from accounts * add missing mempool size metric * UTXO "stasis" mode for new coinbase transactions * remove useless Option from the rpc url parser * fix daa score in maturity state check * add name_or_id to PrvKeyDataInfo * wallet RPC Connect/Disconnect and GetStatus API calls * cleanup * support for 12-word bip39 mnemonics * add a hidden --daemon flag to kaspad * refactor get_daa_score_timestamp helper to return Vec<u64> instead of Response struct * Add Scan event * implement support for unixtime in transactions * kaspa value formatting functions * fix a deadlock due to re-entrant mutex lock when loading multiple accounts from storage * introduce utxo stasis mode + make balance carry utxo counts as well as the totals * refactor wallet events, replace reset() with close() where appropriate * manual debug impl for tx components (display script as hex, address as address etc) * fix incorrect gas assignment in WASM bindings * updates for wallet event handling * refactor sign_with_multiple to return Err(tx) when partially signed * refactor Storage and Wallet descriptors * fix account derivation index handling in DerivationCapable * track acceptance DAA stamp in outgoing transaction record * temporary harness for embedding script engine directly into tx generator (used for debugging) * convert PendingTransaction Utxo entries into HashSet * rename pending tx fns * outgoing tx wrapper around pending tx * refactor notification events during wallet ops * as_ref() for PrvKeyData * wip - initial RpcCoreMocks for wallet framework tests * wallet api messages update for StorageDescriptor usage * update AddressDerivationMeta to track addresses from index 0 * add AHash and async_channel to wallet_core crate * allow Args to be used externally for daemon argument pre-validation * impl Hash for UtxoEntryReference and rename "fake()" to "simulated()" * update wallet events * expose tx validator check_scripts() as pub * update wallet wasm fns for wallet and storage descriptors * rename kaspa-metrics to kaspa-metrics-core * code formatting * code formatting * migrate transaction console formatting to cli/extensions * refactor wallet events * use ahash for faster processing in wallet hash maps (utxo context) * wallet - add SendError handling for error::Error * wallet event refactoring, scan/discovery process refactoring, wallet change secret api handling * refactoring: transfer and deep derivation scan * transaction record refactoring * wallet - support for cross-account transfers in generator * wallet - outgoing transaction impl * wallet - refactor maturity handling * wallet/utxo - initial tests scaffolding * minor optimization of the discovery/scan process * wallet - utxo processor outgoing tx and discovery timestamp unixtime handling * refactor utxo context to use output transactions, refactor transfers, compound and change notifications * code formatting + Cargo.lock update * Signed enum to represent Fully or Partially signed tx * bind p2p and grpc bandwidth metrics * misc clippy fixes * cleanup * remove --daemon as Args::parse() offers external mutations * remove previously implemented mnemonic variant in favor of client-side mnemonic creation * remove AccessContextT, convert to wallet_secret, wip WalletApi traits, refactor account args * code formatting * separate runtime wallet into multiple modules * wallet - revert create_accounts to process a single account at a time * cleanup * wallet - JSON import and export + preliminary docs * address - AddressList - fix TryFrom deadlock caused by recursive trait invocation * wallet - api rustdoc + cleanup, transaction calls * wallet docs * change address debug formatting * adding cli rpc addpeer * wip - wallet restructuring * wip - restructure wallet modules * wip - wallet restructuring - cleanup * wip - AccountKind refactoring * wallet - refactoring storage serialization & encryption * fold in PR kaspanet#349 * wallet framework - misc helper fns and cleanup * storage unit tests + prv key data module restructuring * wallet - account factory registrations * Remove panics caused by sudden loss of connection while submitting transactions. * cleanup * cleanup * cleanup + docs * docs * adjust metrics formatting * cleanup * bump workflow-rs to 0.10.1 * fix wallet storage unit tests * fix generator unit tests * convert missing listener_id panic to error * docs * code formatting * lints * misc updates following github reviews * refactor AccountKind to use fixedstr and implement Copy * refactor AccountKind to use fixedstr (str64) and re-implement Copy, removing clone() where necessary * change js-bound fn names from *as* to *to* to follow Rust conventions * replace AssocPrvKeyDataIds iter().any() to contains() * remove vec![] in MetricsGroup iterator fn; add TODO comment on Metric::group() * scope magic numbers within their associated structs * add try_fully_signed() and try_partially_signed() fns to Signed that allow recovery of the tx * refactor local storage cache to use RwLock instead of a Mutex * refactor serialization as per github feedback (partial trait impl) * Optimize AssocPrvKeyDataIds to use Either in the IntoIter impl, removing allocations. * Refactor to bypass aux buffer creation when storing wallet on native platforms. * impl custom Debug for storage structs to display data in hex * adding misc SAFETY comments on unsafe ops * TODO comments for later SignerT+multisig refactoring * Change panic!() to unreachable!() to make it clearer that a state should not be reached. * rename TransactionRecord::unixtime to unixtime_msec * fix wrong references in comments * Fix min_cosigner_index handling in multisig fns * add comments to UtxoContext::insert() error handling * bind AccountStorable:Storable for AccountStorage, migrate Storable into a separate module, add comments to MAGIC values in some locations * make framework init functions unsafe * update workflow-rs to 0.10.2 * fix comments * fix data cloning when getting collection counts * adding TODO notes to wasm macros and KAS value decimal parsing --------- Co-authored-by: Surinder Singh Matoo <[email protected]>
… data sizes (kaspanet#351) * cache inner struct: prep for tracking size * initial cache policy and mem size estimator * use new cache policies * fix storage calcs * update TN11 genesis * temp: limit max block parents in virtual processor * use more conservative constants (wip) * ensure sufficient cache allocs for high level stores * increase caches related to daa window * Squashed commit of the following: commit a4ba784 Author: Ori Newman <[email protected]> Date: Tue Dec 26 16:22:36 2023 +0200 Add headers first validation to simpa (kaspanet#364) commit fb1aa5f Author: Ori Newman <[email protected]> Date: Tue Dec 26 16:07:19 2023 +0200 Move to mimalloc (kaspanet#361) * mimalloc * mimalloc disable purge_decommits * Add to simpa and integration tests * remove redundant unix and replace with win/linux/mac * Add comment * Add comment * Sort out features * Get rid of ctor --------- Co-authored-by: Michael Sutton <[email protected]> commit b6f7e09 Author: aspect <[email protected]> Date: Tue Dec 26 13:38:24 2023 +0200 Cumulative PR for Wallet & Metrics Refactoring (kaspanet#360) * external access to kaspad core rpc services API * rename wallet event members for serde serialization misc wallet functionality update * wip - event renaming * wip - event serialization tuneup * remove default wrpc listening ports on kaspad Args + fix port mapping bug for automatic JSON RPC port mapping. * Box wallet events * introduce RpcCtl + isolate wRPC from DynRpcApi * debug trait for secret * de-couple wRPC from the runtiem wallet making RPC bindings generic * convert wallet_list to return Vec<WalletDescriptor> * user-friendly error message on decryption error * UtxoProcessor - ignore task shutdown if not running * wallet storage data versioning * wallet - propagate wallet title * sort traits on WalletDescriptor * wallet - use precise decimal conversion when parsing strings to sompi * display kaspa on get-balance-by-address-rpc * wallet - rename settings fns to have try_ prefixes * rename library names "kaspad" and "kaspa_cli" to "kaspad_lib" and "kaspa_cli_lib" to prevent build collisions * no-unsafe-eval feature * allow for chrome-extension schema in the RPC url * wallet - expose bip32 wordlist for external access * wallet - delegate rpc ownership to utxo_processor; reorder rpc disconnect to occur before utxo_processor shutdown; * wallet - migrate wallet settings loading to cli * rename RpcCtlOp (Open, Close) to RpcState (Opened, Closed) * remove automatic RPC disconnect from wallet stop() to allow retention of the RPC channel after closing the wallet * allow UtxoProcessor to bind to an already existing/connected RPC channel, allow retention of a connected RPC channel past UtxoProcessor shutdown. (API centric defensive functionality) * code formatting * fix clippy warnings * migrate chrome-extension to use ws:// schema by default * wallet list formatting * staging for WRS 0.7.0 * add bip32 word list iterator * update WRS to 0.7.0 * fix rustdoc errors * wip - initial WalletApi trait implementation * wallet - macros and account descriptors * wallet - ping_call * cleanup * wip - wallet api cleanup & testing * kaspa-metrics as a separate crate * wip - metrics cleanup * cargo.lock update * async/sync api changes for storage * merge * master merge * wip * wip * wip * wallet - (wip) changes to AccountDescriptor and Wallet API * metrics - make sink future return as optional * wip - refactor wallet open; improve wallet event ordering; cleanup * wip (debugging UtxoChanged notifications) - fix issuance during failed tx * adding workflow-rs as github dependency (allows CI) * revert github deps for WRS * metrics * refactor metrics to include bdi counts and peer counts * wallet api updates refactoring transaction access interface misc updates to wallet APIs refactor wallet open sequence refactor legacy accounts * wallet framework - fix a but resulting in the early issuane of UTXO maturity events. Refactor handling of outgoing transaction UTXOs (sending outgoing tx ACKs on UtxoChange removal), minor fixes in the Transaction file-system storage. Add "outgoing" property to account balances (to track in-flight transactions being submitted until acceptance). Introduce new Events::Change that gets fired specifically when receiving change of the currently outgoing transaction. Initial steps toward Daa property wrapper. * npm 0.13.0 * metrics - cleanup after RPC refactoring * rename rust-side of wasm bindings as naming conventions interfere with rust use (make fns more explicitly named) * make metrics data formatting fns as pub * expose log levels in kaspa-core::log * rename metrics & improve metrics fetch task * add API calls to pre-configure wallet framework stroage folders * cumulative updates for Cargo.lock * Improve address error messages for human readability * PrvKeyData enumeration, initial account transfer support (wip), wallet descriptor handling * wallet - change error to retain PrvKeyDataId instead of a String * propagate bip39 flag to runtime account and it's descriptor * wip - keydata refactoring * metrics refactoring (bandwidth) * wip (cleanup) * misc improvements to metrics * code formatting * wRPC bandwidth monitoring + scaffolding for global bandwidth metrics * bump WRS to 0.9.0 * metrics - add mempool_size and convert some items to u32/f32 * metrics cleanup * wallet and account rename, remove "title" from accounts * add missing mempool size metric * UTXO "stasis" mode for new coinbase transactions * remove useless Option from the rpc url parser * fix daa score in maturity state check * add name_or_id to PrvKeyDataInfo * wallet RPC Connect/Disconnect and GetStatus API calls * cleanup * support for 12-word bip39 mnemonics * add a hidden --daemon flag to kaspad * refactor get_daa_score_timestamp helper to return Vec<u64> instead of Response struct * Add Scan event * implement support for unixtime in transactions * kaspa value formatting functions * fix a deadlock due to re-entrant mutex lock when loading multiple accounts from storage * introduce utxo stasis mode + make balance carry utxo counts as well as the totals * refactor wallet events, replace reset() with close() where appropriate * manual debug impl for tx components (display script as hex, address as address etc) * fix incorrect gas assignment in WASM bindings * updates for wallet event handling * refactor sign_with_multiple to return Err(tx) when partially signed * refactor Storage and Wallet descriptors * fix account derivation index handling in DerivationCapable * track acceptance DAA stamp in outgoing transaction record * temporary harness for embedding script engine directly into tx generator (used for debugging) * convert PendingTransaction Utxo entries into HashSet * rename pending tx fns * outgoing tx wrapper around pending tx * refactor notification events during wallet ops * as_ref() for PrvKeyData * wip - initial RpcCoreMocks for wallet framework tests * wallet api messages update for StorageDescriptor usage * update AddressDerivationMeta to track addresses from index 0 * add AHash and async_channel to wallet_core crate * allow Args to be used externally for daemon argument pre-validation * impl Hash for UtxoEntryReference and rename "fake()" to "simulated()" * update wallet events * expose tx validator check_scripts() as pub * update wallet wasm fns for wallet and storage descriptors * rename kaspa-metrics to kaspa-metrics-core * code formatting * code formatting * migrate transaction console formatting to cli/extensions * refactor wallet events * use ahash for faster processing in wallet hash maps (utxo context) * wallet - add SendError handling for error::Error * wallet event refactoring, scan/discovery process refactoring, wallet change secret api handling * refactoring: transfer and deep derivation scan * transaction record refactoring * wallet - support for cross-account transfers in generator * wallet - outgoing transaction impl * wallet - refactor maturity handling * wallet/utxo - initial tests scaffolding * minor optimization of the discovery/scan process * wallet - utxo processor outgoing tx and discovery timestamp unixtime handling * refactor utxo context to use output transactions, refactor transfers, compound and change notifications * code formatting + Cargo.lock update * Signed enum to represent Fully or Partially signed tx * bind p2p and grpc bandwidth metrics * misc clippy fixes * cleanup * remove --daemon as Args::parse() offers external mutations * remove previously implemented mnemonic variant in favor of client-side mnemonic creation * remove AccessContextT, convert to wallet_secret, wip WalletApi traits, refactor account args * code formatting * separate runtime wallet into multiple modules * wallet - revert create_accounts to process a single account at a time * cleanup * wallet - JSON import and export + preliminary docs * address - AddressList - fix TryFrom deadlock caused by recursive trait invocation * wallet - api rustdoc + cleanup, transaction calls * wallet docs * change address debug formatting * adding cli rpc addpeer * wip - wallet restructuring * wip - restructure wallet modules * wip - wallet restructuring - cleanup * wip - AccountKind refactoring * wallet - refactoring storage serialization & encryption * fold in PR kaspanet#349 * wallet framework - misc helper fns and cleanup * storage unit tests + prv key data module restructuring * wallet - account factory registrations * Remove panics caused by sudden loss of connection while submitting transactions. * cleanup * cleanup * cleanup + docs * docs * adjust metrics formatting * cleanup * bump workflow-rs to 0.10.1 * fix wallet storage unit tests * fix generator unit tests * convert missing listener_id panic to error * docs * code formatting * lints * misc updates following github reviews * refactor AccountKind to use fixedstr and implement Copy * refactor AccountKind to use fixedstr (str64) and re-implement Copy, removing clone() where necessary * change js-bound fn names from *as* to *to* to follow Rust conventions * replace AssocPrvKeyDataIds iter().any() to contains() * remove vec![] in MetricsGroup iterator fn; add TODO comment on Metric::group() * scope magic numbers within their associated structs * add try_fully_signed() and try_partially_signed() fns to Signed that allow recovery of the tx * refactor local storage cache to use RwLock instead of a Mutex * refactor serialization as per github feedback (partial trait impl) * Optimize AssocPrvKeyDataIds to use Either in the IntoIter impl, removing allocations. * Refactor to bypass aux buffer creation when storing wallet on native platforms. * impl custom Debug for storage structs to display data in hex * adding misc SAFETY comments on unsafe ops * TODO comments for later SignerT+multisig refactoring * Change panic!() to unreachable!() to make it clearer that a state should not be reached. * rename TransactionRecord::unixtime to unixtime_msec * fix wrong references in comments * Fix min_cosigner_index handling in multisig fns * add comments to UtxoContext::insert() error handling * bind AccountStorable:Storable for AccountStorage, migrate Storable into a separate module, add comments to MAGIC values in some locations * make framework init functions unsafe * update workflow-rs to 0.10.2 * fix comments * fix data cloning when getting collection counts * adding TODO notes to wasm macros and KAS value decimal parsing --------- Co-authored-by: Surinder Singh Matoo <[email protected]> commit 10d0ebf Author: D-Stacks <[email protected]> Date: Tue Dec 26 10:43:59 2023 +0100 make step 3. of linux installation not fail copy and paste (kaspanet#363) remove the space to escape the newline instead. * reduce children cache policy * reduce caches 25% * increase tx cache * fix gd alloc and slightly increase other numbers * fix a cache alloc bug by redesigning the cache and adding a min units option + fix bps constants * fix simpa short cmd op name colision * move impls to inner struct * comments, docs and technical refactoring * refactor MemSizeEstimator * refactor bool to MemMode * memsize docs * remove unneeded min limits * comments and name enhancements * rename `CachePolicy::Units` to `CachePolicy::Count` to avoid confusion with `MemMode` * use estimated num of unique headers in validate pruning point headers cache * cache policy builder * add todos * median window has different size + comments * read ghostdag data from compact access if possible * remove wrong upper bound for reachability sets
Please note this PR breaks previously created wallet data files. The wallet data storage has been completely redesigned to provide easier management of data structure versioning. Following this PR data files will be always backward-compatible.
Consensus & RPC service layers:
signed_with_multiple_v2()
to returnenum Signed
comprised of two states:Signed::Fully
andSigned::Partially
to be able to distinguish transaction signed states.Signed
also implementsfully_signed() -> Result<()>
that will return a transaction or an error if the transaction is not fully signed.GetMetrics
RPC call to return various additional metrics including bandwidth monitoring.async_get_tips_len()
andasync_get_virtual_parents_len()
, these are used by theGetMetrics
RPC call when the metrics poll occurs./cli
:/kaspad
:kaspa_daemon::Args
to accept an argument iterator, this allowsArgs
to be used externally to perform argument validation as well as to supply kaspad externally generated arguments./metrics/kaspa-metrics-core
/kos
crate into its own standalone/metrics/kaspa-metrics-core
crate.Wallet framework:
WalletApi
trait that encapsulates all wallet functions in a similar style toRpcApi
, allowing the wallet to be "controlled by wire" (i.e. via serializable data structures over RPC). TheWalletApi
follows the same style and code notations as theRpcApi
(i.e._call
fn suffixes and serializable*Request
/*Response
structs). The original development effort was aiming to avoid RPC-style communication with the wallet framework. However, while testing the framework in the browser extension environment we ran into problems and a requirement for the wallet framework to run "headless" in the background task. This refactoring enables such functionality, while also bringing all APIs into a single trait, making it easy to develop any kind of RPC bindings as well as WASM bindings (since all data structures are serializable).AccessContextT
trait has been removed from the storage subsystem. Storage subsystem now accepts secrets directly. This construct was created as a "layer responsibility isolation" effort but was making APIs and secret retention more complex than they should be.Account::transfer()
method by supplying the target account id. Transfers require a destination account ID and both from and to accounts will receiveTransferIncoming
andTransferOutgoing
notifications containing the correspondingTransactionRecord
.UtxoContext
andUtxoProcessor
have been refactored to track a newOutgoingTransaction
that wrapsPendingTransaction
(and contains additional context information such as submission time and acceptance time). TheOutgoingTransaction
is not tracked byUtxoProcessor
and plays the main role in handling transfers as well as monitoring forChange
outputs.TransactionRecord
processing has been modified to resolve transaction Unixtime timestamp automatically using methods introduced in Implement DAA score timestamp estimation #268. Newly discovered transactions cascade to UtxoProcessor and are then handled internally or propagated to the wallet that checks transaction storage to see if transactions are unknown, resolves unix time from the DAA score, and cascades them to the wallet multiplexer channel clients via the newDiscovery
event @coderofstuff .Stasis
transaction processing queue. The previous implementation places new coinbase transactions into thePending
state which later propagates intoReorg
orMaturity
states resulting in additionalReorg
notifications. The new implementation places new coinbase transactions into aStasis
state for a period of 50 DAA. Upon reorg of a transaction that is currently in theStasis
state, no events are emitted. After 50 DAA expiration, the transaction is placed into aPending
state at which point thePending
event occurs, followed by theMaturity
event once the transaction age reaches 100 DAA. This was implemented to simplify coinbase transaction processing for wallets as during the initial few DAA of the coinbase transaction lifetime it can frequently become subject to a reorg.TransactionRecord
storage encryption (allows transaction data to be encrypted as well - for now provisional only, additional work is required to bring this feature online).dyn Account
always returningaccount_index()
as 0, preventing any additional BIP44 accounts from being signed correctly.open()
andreload()
processes. Opening a wallet now loads the storage dataset and related cache, following which the developer is required to explicitly activate account processing (a.k.a. activate accounts). (Due to event-driven architecture, starting account processing during theopen()
call creates event sequence difficulties where after opening the client may need to load existing transactions before any other processing should occur).static mut
, before using the framework).None
while async functions that require DAA would continue their processing. The panic is now converted to a cascading error.async_std::Mutex
) that blocksUtxoChanged
notification processing during the transaction submission process. Transaction submission is a multi-stage process where 1)OutgoingTransaction
(PendingTransaction
) is registered, 2) the transaction is submitted 3) submission can result in an error in which case 4) registration of theOutgoingTransaction
has to be canceled/reversed. Since these processes are async, there is a danger that acceptance and the corresponding changes come in while this process is taking place.WASM
TryFrom
) when callingUtxoContext.trackAddresses()
from WASMTransaction.gas
setter.Address
functions on the Rust side as they were making the Rust the API confusing (JS needs Strings while on Rust you expect to get native types).WalletApi
trait to WASM.workflow-rs