Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add input signature_script checking to submitTransaction RPC #479

Merged
merged 12 commits into from
Jul 26, 2024

Conversation

KaffinPX
Copy link
Contributor

Closes #452

rpc/service/src/service.rs Outdated Show resolved Hide resolved
rpc/service/src/service.rs Outdated Show resolved Hide resolved
rpc/core/src/error.rs Outdated Show resolved Hide resolved
rpc/service/src/service.rs Outdated Show resolved Hide resolved
rpc/service/src/service.rs Outdated Show resolved Hide resolved
rpc/service/src/service.rs Outdated Show resolved Hide resolved
@KaffinPX KaffinPX changed the base branch from master to dev May 30, 2024 11:20
aspect
aspect previously approved these changes Jun 13, 2024
Copy link
Collaborator

@aspect aspect left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@michaelsutton
Copy link
Contributor

I suggest the following instead of the above approach:

diff --git a/consensus/Cargo.toml b/consensus/Cargo.toml
index f151e404b..3f4a1b456 100644
--- a/consensus/Cargo.toml
+++ b/consensus/Cargo.toml
@@ -30,6 +30,7 @@ kaspa-muhash.workspace = true
 kaspa-notify.workspace = true
 kaspa-pow.workspace = true
 kaspa-txscript.workspace = true
+kaspa-txscript-errors.workspace = true
 kaspa-utils.workspace = true
 log.workspace = true
 once_cell.workspace = true
diff --git a/consensus/core/src/errors/tx.rs b/consensus/core/src/errors/tx.rs
index ec1899faa..1aeb5220f 100644
--- a/consensus/core/src/errors/tx.rs
+++ b/consensus/core/src/errors/tx.rs
@@ -80,6 +80,9 @@ pub enum TxRuleError {
     #[error("failed to verify the signature script: {0}")]
     SignatureInvalid(TxScriptError),
 
+    #[error("failed to verify empty signature script. Inner error: {0}")]
+    SignatureEmpty(TxScriptError),
+
     #[error("input {0} sig op count is {1}, but the calculated value is {2}")]
     WrongSigOpCount(usize, u64, u64),
 
diff --git a/consensus/src/processes/transaction_validator/transaction_validator_populated.rs b/consensus/src/processes/transaction_validator/transaction_validator_populated.rs
index 1835ba61e..586b23e57 100644
--- a/consensus/src/processes/transaction_validator/transaction_validator_populated.rs
+++ b/consensus/src/processes/transaction_validator/transaction_validator_populated.rs
@@ -1,7 +1,11 @@
 use crate::constants::{MAX_SOMPI, SEQUENCE_LOCK_TIME_DISABLED, SEQUENCE_LOCK_TIME_MASK};
-use kaspa_consensus_core::{hashing::sighash::SigHashReusedValues, tx::VerifiableTransaction};
+use kaspa_consensus_core::{
+    hashing::sighash::SigHashReusedValues,
+    tx::{TransactionInput, VerifiableTransaction},
+};
 use kaspa_core::warn;
 use kaspa_txscript::{get_sig_op_count, TxScriptEngine};
+use kaspa_txscript_errors::TxScriptError;
 
 use super::{
     errors::{TxResult, TxRuleError},
@@ -167,14 +171,21 @@ impl TransactionValidator {
         let mut reused_values = SigHashReusedValues::new();
         for (i, (input, entry)) in tx.populated_inputs().enumerate() {
             let mut engine = TxScriptEngine::from_transaction_input(tx, input, i, entry, &mut reused_values, &self.sig_cache)
-                .map_err(TxRuleError::SignatureInvalid)?;
-            engine.execute().map_err(TxRuleError::SignatureInvalid)?;
+                .map_err(|err| map_script_err(err, input))?;
+            engine.execute().map_err(|err| map_script_err(err, input))?;
         }
 
         Ok(())
     }
 }
 
+fn map_script_err(script_err: TxScriptError, input: &TransactionInput) -> TxRuleError {
+    match input.signature_script.is_empty() {
+        true => TxRuleError::SignatureEmpty(script_err),
+        false => TxRuleError::SignatureInvalid(script_err),
+    }
+}
+
 #[cfg(test)]
 mod tests {
     use super::super::errors::TxRuleError;

@biryukovmaxim
Copy link
Collaborator

biryukovmaxim commented Jul 23, 2024

match input.signature_script.is_empty() {
+        true => TxRuleError::SignatureEmpty(script_err),
+        false => TxRuleError::SignatureInvalid(script_err),
+    }

match bool always looks weird. Why not use simple if-else?

@KaffinPX KaffinPX requested a review from aspect July 25, 2024 20:36
@michaelsutton michaelsutton merged commit 9feb5dc into kaspanet:dev Jul 26, 2024
6 checks passed
michaelsutton added a commit to biryukovmaxim/rusty-kaspa that referenced this pull request Oct 7, 2024
commit 1378e7b
Author: D-Stacks <[email protected]>
Date:   Mon Oct 7 14:41:32 2024 +0200

    replace statrs and statest deps & upgrade some deps.  (kaspanet#425)

    * replace statrs and statest deps.

    * remove todo in toml.cargo and fmt & lints.

    * do a run of `cargo audit fix` for some miscellaneous reports.

    * use maintained alt ks crate.

    * add cargo.lock.

    * update

    * use new command

    * newline

    * refresh cargo lock with a few more version updates

    * fix minor readme glitches

    ---------

    Co-authored-by: Michael Sutton <[email protected]>

commit b37f030
Author: Michael Sutton <[email protected]>
Date:   Sun Oct 6 14:55:24 2024 +0300

    Bump tonic version (kaspanet#579)

commit 2b0f3ab
Author: George Bogodukhov <[email protected]>
Date:   Thu Oct 3 16:36:45 2024 +1000

    Fix README.md layout and add linting section (kaspanet#488)

commit 66959d4
Author: Maxim <[email protected]>
Date:   Mon Sep 30 20:43:35 2024 +0400

    Bump tonic and prost versions, adapt middlewares (kaspanet#553)

    * bump tonic, prost versions
    update middlewares

    * use unbounded channel

    * change log level to trace

    * use bounded channel

    * reuse counts bytes body to measure bytes body

    * remove unneeded clone

commit 3bc2844
Author: aspect <[email protected]>
Date:   Sun Sep 29 18:59:54 2024 +0300

    cleanup legacy bip39 cfg that interferes with docs.rs builds (kaspanet#573)

commit 180114e
Author: aspect <[email protected]>
Date:   Sun Sep 29 17:14:16 2024 +0300

    fix wasm rpc method types for methods without mandatory arguments (kaspanet#572)

commit 035a394
Author: aspect <[email protected]>
Date:   Fri Sep 27 05:59:59 2024 +0300

    Documentation updates (kaspanet#570)

    * docs

    * Export ConsensusSessionOwned

    * add CI pass to run `cargo doc`

    * module rust docs

    * lints

    * fix typos

    * replace glob import terminology with "re-exports"

    * cleanup

commit 200b8ea
Author: aspect <[email protected]>
Date:   Fri Sep 27 02:09:57 2024 +0300

    fix wRPC json notification format (kaspanet#571)

commit 4bfa392
Author: Maxim <[email protected]>
Date:   Tue Sep 24 21:45:43 2024 +0400

    fix wrong combiner condition (kaspanet#567)

commit d66cbe3
Author: demisrael <[email protected]>
Date:   Mon Sep 23 08:02:58 2024 +0300

    rothschild: donate funds to external address with custom priority fee (kaspanet#482)

    * rothschild: donate funds to external address

    Signed-off-by: Dmitry Perchanov <[email protected]>

    * rothschild: Append priority fee to txs.

    Signed-off-by: Dmitry Perchanov <[email protected]>

    * rothschild: add option to choose and randomize fee

    Signed-off-by: Dmitry Perchanov <[email protected]>

    * rothschild: address clippy formatting issues

    Signed-off-by: Dmitry Perchanov <[email protected]>

    ---------

    Signed-off-by: Dmitry Perchanov <[email protected]>
    Signed-off-by: Dmitry Perchanov <[email protected]>
    Co-authored-by: coderofstuff <[email protected]>
    Co-authored-by: Dmitry Perchanov <[email protected]>

commit 9fae376
Author: Michael Sutton <[email protected]>
Date:   Fri Sep 20 13:31:55 2024 +0300

    Deploy linux binary without musl in its name + various minor miscellaneous things towards v0.15.2  (kaspanet#564)

    * remove musl from linux binary name

    * remove simpa from win and osx builds in order to be consistent with linux build

    * safe eqv optimization: use inplace truncate (tested)

commit 4d03153
Author: Michael Sutton <[email protected]>
Date:   Fri Sep 20 01:58:28 2024 +0300

    A few CLI rpc query fixes (kaspanet#563)

commit b14537f
Author: D-Stacks <[email protected]>
Date:   Thu Sep 19 22:16:54 2024 +0200

    `virtual chain from block` batching. (kaspanet#454)

    * expose vspc_from_block batching possibilities to rpc.

    * fmt

    * limit by merged blocks, set source as def. start.

    * small clean-up

    * fmt

    * actually bound by num of merged blocks, in include transactions case.

    * fmt

    * update.

    * update_2

    * new_high = high

    * remove high hash in consensus api.. as it is not required.

    * fmt

    * make proto comment more accurate.

    * fix tests, and lints, add to ser / der correctly.

    * change two freq warns to debug

    * remove option, default to pp. not source.

    * fix integration test, some Option<Hash> left.

    * bump version: ´0.15.1 => 0.15.2`

    * remove "optional" startHash

    * add to cli rpc.rs

    * remove comment.

    * edit comment in .proto referencing def. startHash behavior.

    * only batch added chain blocks, not removed, add check if source is a chain ancestor of high.

    * remove dangling code in comment

    * remove error from some prev. commit.

    * Optionalize limts.

    ---------

    Co-authored-by: Michael Sutton <[email protected]>

commit 613d082
Author: Michael Sutton <[email protected]>
Date:   Sun Sep 15 02:06:13 2024 +0300

    Fix new gRPC methods to use camel case (non-breaking change) (kaspanet#560)

commit f8f9915
Author: Cryptok777 <[email protected]>
Date:   Thu Sep 12 03:47:21 2024 -0700

    Fix typo in IFeeEstimate (kaspanet#557)

commit f335376
Author: Michael Sutton <[email protected]>
Date:   Wed Sep 11 20:55:53 2024 +0300

    Bump to version 0.15.1 (kaspanet#555)

    * bump version to 0.15.1

    * update readme with new branch strategy

commit 2a99817
Author: aspect <[email protected]>
Date:   Wed Sep 11 00:38:39 2024 +0300

    15 rc4 updates (kaspanet#554)

    * metrics: fix first snapshot sample + cleanup

    * Wallet SDK: scan() - fix UtxoContext processing latency during scan. Add UtxoProcessor notification lock to the scan processor.

    * cleanup

commit d1dc5dd
Author: thesheepcat <[email protected]>
Date:   Tue Sep 10 00:59:36 2024 +0200

    Simple wRPC client example (kaspanet#550)

    * simple client example created

    * fine-tuning on simple wRPC client example (with comments)

    * code fixed after Aspect's suggestions

    * empty lines cleanup

commit 5b9c3cf
Author: aspect <[email protected]>
Date:   Tue Sep 10 00:57:22 2024 +0300

    Fix CLI not showing incorrect URL on connect + add disconnect() before connect() (kaspanet#549)

    * wRPC: update descriptor with URL supplied in connect options

    * cli: present public node connection warning only once

    * cli: update messaging

    * bump version to 0.14.7

commit 7271509
Author: Elichai Turkel <[email protected]>
Date:   Tue Sep 10 00:33:42 2024 +0300

    Replace openssl with rustls + ring + webpki_roots (kaspanet#547)

    * Remove openssl and replace with rustls + ring + webpki_roots

    * - init calls, - unused imports

    - Removed init calls
    - Removed unused imports

    * Add rustls to network stack

    ---------

    Co-authored-by: starkbamse <[email protected]>

commit 27cef9e
Author: aspect <[email protected]>
Date:   Mon Sep 9 15:15:40 2024 +0300

    WIP: Updates for 15-rc3 (kaspanet#546)

    * update unit tests to unwrap mass to u64::max

    * update WASM mass APIs to be more clear with the data they produce

    * add fingerprint() fn to PublicKey

    * cleanup

    * fix recursive mutex in From<&Transaction> for RpcTransaction

    * update rust-version to 1.81.0

    * generator: fix incorrect change output value info triggering a sanity-check assert!

commit afbcf9e
Author: starkbamse <[email protected]>
Date:   Fri Sep 6 05:40:53 2024 +0200

    Change directory back to repo root & Fix Rust v1.81 lints (kaspanet#545)

    * Change directory back to repodir

    Change directory back to repodir after building toolchain

    * Clippy

    * Update crypto/txscript/src/caches.rs

    Co-authored-by: Maxim <[email protected]>

    * Update crypto/txscript/src/caches.rs

    * rename `is_none_or` -> `is_none_or_ex` to avoid conflict with future std

    * remove `use std::mem::size_of` wherever possible (added to std prelude recently)

    ---------

    Co-authored-by: Maxim <[email protected]>
    Co-authored-by: Michael Sutton <[email protected]>

commit 06a874f
Author: starkbamse <[email protected]>
Date:   Thu Sep 5 18:51:04 2024 +0200

    Deprecate zigbuild and glibc in favor of static musl binaries for Linux builds. (kaspanet#541)

    * CTNG Config file, Musl build instructions

    - Crosstools-ng configuration file for quick reproducable builds on musl.
    - Instructions for how to build RK on musl.

    * Test

    * Update ci.yaml

    * Test crosstools install

    * Cache ct-ng build

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Fix error in command

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Comments, naming

    * Update ci.yaml

    * Update ci.yaml

    * Update ci.yaml

    * Merge new musl build with old CI, Release builds

    - Merges the old CI script with the new musl build.
    - Update deploy.yaml to use updated musl toolchain to build musl target for linux.

    * Move to workspace

    * Delete musl-build.md

    * Lock to ctng version 1.26

    * Checkout fix

    * Revert master change

    * Indentation

    * Revert "Indentation"

    This reverts commit 6a7e6c0.

    * Revert "Revert master change"

    This reverts commit 1a047e4.

    * Update ci.yaml

    * Force mimalloc

    * Compress into script

    * Fix typo

    * Update build.sh

    * Replace bloaded config file

    * Update build.sh

    * Update build.sh

    * Source script

    * Revert vendor

    * Update defconfig

    * Update defconfig

    * Update defconfig

    * Update build.sh

    * Update build.sh

    * Update build.sh

    * Update build.sh

    * Update defconfig

    * Delete defconfig

    * Create defconfig

    * Update build.sh

    * Deprecate config, use default preset

    * Update build.sh

    * Add preset hash logic in script

    * Move preset hash update

    Move preset hash update after openssl build

    * Use openssl crate

    * Update exports, cache config

    * Remove spaces in export command

    * Update names

    Should not trigger cache

    * Move source preset

    * CD before preset

    * Add comment

    Adds comment and should invalidate cache.

commit b04092e
Author: aspect <[email protected]>
Date:   Thu Sep 5 18:00:24 2024 +0300

    add proxy limit field to sysinfo (kaspanet#544)

commit f866dfa
Author: Michael Sutton <[email protected]>
Date:   Thu Sep 5 14:04:16 2024 +0300

    Various miscellaneous changes towards 0.15.1 RC2 (kaspanet#543)

    * infrequent logs should be debug

    * cleanup some todos

    * when a network starts, genesis has a body, so there's no need for a special exception

    * remove unneeded method and add an error just in case it is added in the future

    * count and log chain disqualified blocks

    * count and log mempool evictions

    * bump version to 0.14.5

commit 7cdabb4
Author: aspect <[email protected]>
Date:   Mon Sep 2 23:54:04 2024 +0300

    Refactoring of mass calculator utilities (kaspanet#538)

    * rename verbose data mass to compute_mass

    * fix TS interface verbose transaction data property name

    * relocate consensus core processes MassCalculator to consensus core

    * WASM fix ECDSA pubkey generation

    * error variant related to ECDSA from PublicKey creation

    * refactor client mass APIs, propagate minimum_signatures via pending tx.  rename mass calc functions to `unsigned` for clarity.

    * introduce change index to PTX

    * cleanup

    * cleanup

    * fix missing transfer of client Transaction mass to RpcTransaction

    * Introduce IRawBlock and IRawHeader TS types used in GetBlockTemplateResponse and SubmitBlockRequest

    * fix docs

    * Refactor mass calculator and extract a global storage mass fn which operates on iters + use from wallet mass calculator

    ---------

    Co-authored-by: Michael Sutton <[email protected]>

commit 68c298f
Author: Michael Sutton <[email protected]>
Date:   Mon Sep 2 08:15:46 2024 +0300

    adjust mass per block by the specific mass of the outlier transaction and not by the avg mass (kaspanet#537)

commit 864aaf6
Author: Michael Sutton <[email protected]>
Date:   Sun Sep 1 20:06:42 2024 +0300

    Transaction pool -- fix rare cases where byte size tracking was inaccurate (kaspanet#535)

    * remove crate-level mut access to inner mempool tx and fix bytes size tracking

    * another fix to the same problem: only update_revalidated_transaction if validation result is ok, otherwise we remove it anyway so why update

    * Apply suggestions from code review

    Co-authored-by: Maxim <[email protected]>

    * debug log `other`

    ---------

    Co-authored-by: Maxim <[email protected]>

commit c839a9d
Author: Michael Sutton <[email protected]>
Date:   Wed Aug 28 03:43:54 2024 +0300

    Bump to version 0.14.3 (kaspanet#531)

    * expire is 24h, so scan can be every 60s

    * apply ram scale down to mempool size limit

    * bump to v0.14.3 (0.14.2 was already used for unified tn11 unofficial rc)

commit 63e2ab6
Author: Ori Newman <[email protected]>
Date:   Tue Aug 27 20:55:32 2024 +0300

    Mempool tweaks (kaspanet#524)

    * Some mempool tweaks

    * Change mempool tx eviction policy

    * Add test_evict

    * Some fixes

    * clippy

    * move to estimated size

    * remove estimated_size field

    * remove clippy allow

    * Fix clippy warnings

    * Mempool evict policy -- a few fixes  (kaspanet#7)

    * comments and logs

    * validate in context before execute rbf + note

    * use a dedicated mempool_estimated_bytes fn

    * fix redeemers check

    * make sure we found enough space (not sure about this, might be better to remove the assert in the calling function and turn into if)

    * reorganize checks

    * include tx itself in redeemers

    * Add comment to test_evict

    * Add case to test_evict

    * Remove explicit check for too big transactions

    * Raise DEFAULT_MEMPOOL_SIZE_LIMIT to 1GB

    ---------

    Co-authored-by: Michael Sutton <[email protected]>

commit 2306592
Author: KaffinPX <[email protected]>
Date:   Tue Aug 27 02:48:00 2024 +0300

    get_current_block_color RPC utility (kaspanet#528)

    * getCurrentBlockColor algorithm and RPC functions

    * Add a small comment over RPC test

    * Move get_current_block_color to consensus and apply standard sorting

    * Apply msuttons suggestions except the block check

    * Remove not  needed return and format

    * Variable name consistency

    * Check for block existence on get_current_block_color

    * Add extra DAG order checks to ensure about children

    * includes:
    1. stylistic changes using ?
    2. `is_dag_ancestor_of(a, b)` is different than `!is_dag_ancestor_of(b, a)` -- they are not negations of each other, bcs there's also the anticone

    * 1. bug fix: hash -> child
    2. make store calls only where they are actually used (within the if)

    * style: 1. use struct unfloding syntax, 2. use a name such as decedent which reflects the relation to `hash`

    * important note

    * Fix Omega compatibility issues

    * Remove Borsh derivations

    * Fix gRPC message codes

    * Fix gRPC getCurrentBlockColorResponse

    * improve tests

    ---------

    Co-authored-by: Michael Sutton <[email protected]>

commit 1c1a692
Author: aspect <[email protected]>
Date:   Mon Aug 26 22:52:31 2024 +0300

    Cumulative PR - omega branch (wRPC v2, integrations, typescript-v2, resolver v2) (kaspanet#506)

    * support numeric interface (ip) arg without port in --rpclisten-borsh or --rpclisten-json

    * isActive for UtxoProcessor and UtxoContext

    * Script utility functions + WASM changelog update

    * versioned serialization for wRPC

    * spelling

    * Refactorize State into PoW (kaspanet#43)

    * Add fromRaw with optional target_bits

    * Upload builds as GitHub Artifact

    * try moving calculateTarget into PoW class as static funct

    * Use FromHex trait

    * Make PoW constructor accept IHeader & refactorize some parts

    * Lint

    * TransactionDataT and BindingT (kaspanet#44)

    * borsh update to 1.5.1

    * fix returning receive addr from bindings change addr fn.

    * lints

    * update WASM changelog

    * fix WASM module reference in examples

    * migrate lints.clippy to workspace and inherit this in the relevant crates

    * Add provisional fields for storage metrics (db size)

    * fix file creation timestamp issue on some ext4 file systems (updated via workflow-store::fs)

    * bigint values in TransactionRecord (kaspanet#48)

    * change address decoding panics to errors

    * update error messaging

    * Update for bind/listen compatibility with WRS

    * range support added for transactions pagination (kaspanet#49)

    * range support added for transactions pagination

    * cargo fmt/clippy

    * lints

    * WRS 0.13.0

    * wallet ergonomics helper functions

    * WRS 0.13.1

    * WRS 0.13.1 lock

    * WRS 0.13.2

    * kaspa-wallet (cli) updates (using latest resolver APIs + guide cleanup)

    * range support for indexdb store load_range function (kaspanet#52)

    * add balance info to account descriptors, additional wallet connectivity utilities and connect api method changes, export wallet utils in wallet prelude,

    * Improve ConnectRequest builder interface

    * Allow UtxoEntryReference to be re-integrated from a flat object structure.

    * indexdb data maintenance: timestamp fix (kaspanet#53)

    * range support for indexdb store load_range function

    * indexdb data maintenance: timestamp fix

    * removing unused

    * Fix incorrect balance when sending to self

    * fix child_number typo

    * allow setting custom transaction maturity periods

    * fix missing renaming for record.value

    * fix typedoc references

    * pre-borsh-1-5-1 compat

    * testing typedoc

    * testing typedoc

    * lock typedoc to 0.25.8

    * disable typedoc treatWarningsAsErrors

    * deps

    * WIP SPK WASM

    * Cargo.lock

    * SPK raw object cast + fix return of ISerializableTransaction

    * fix le to be when parsing SPK hex version

    * remove string version parsing from SPK

    * update WASM SDK changelog

    * incorrect balance issue (kaspanet#55)

    * TransactionInput signature_script as Option, add associated TS types

    * restructure PSKT + WASM scaffolding (WIP)

    * wallet guard implementation to block concurrent async access to account operations

    * tx serialization example

    * change struct serialization version fields from u32 to u16

    * WIP - decoupling RPC type aliases (kaspanet#45)

    * Provisional RpcConnection propagation via RpcApi methods (kaspanet#46)

    * provisional RpcConnection propagation via RpcApi methods

    * lints

    * change api version handling affecting get_server_info_call

    * Wallet watch-only accounts (kaspanet#59)

    * Prints extended public keys on export mnemonic command (feature of go kaspawallet).

    * Watch-only account implementation for bip32 and multisig kind of accounts with new command account import watchonly.

    * Refactor code for less variables.

    * Patch import type for command.

    * CLI Support for watch only accounts in select account with args function.

    * Function sig_op_count equals implemented.

    * Helper function in wallet to format XPUB according to network. Converter NetworkId for Prefix. BIP32-Watch Account renamed from WatchOnly, multisig feature removed. Multisig account import as watch-only command added.

    * cli watch-only header in list and select.

    * Resolve merge.

    * update resolver to use v2 API

    * change default resolver subdomains

    * resolver v2 updates

    * Refactorize some addresses and Script related parts (kaspanet#61)

    * Refactorize some addresses and Script related parts

    * A ScriptBuilder example on TypeScript

    * addOps Opcodes are now BinaryT

    * Move txscript bindings to relevant folders

    * Sort lines of deps and imports

    * Lint

    * fix wasm subscribe_daa_score

    * expose native RpcClient multiplexer in KaspaRpcClient

    * WIP (local wRPC)

    * breakdown wRPC serialization trait into two ser/de; improve future compatibility patterns;

    * get_connections_call() RPC method + provisional metrics dictionary

    * change get_connections() to return the actual value instead of Response struct.

    * priorityEntries implementation for tx generator

    * fix transaction WASM interface types affecting some function returns

    * input and output types on transactions (WASM)

    * rpc caps

    * update client resolver resolution

    * GetSystemInfo RPC call

    * make priorityEntries optional in the TS interface definition

    * merge cli-resolver

    * remove resolver crate from workspace (move to https://github.com/aspectron/kaspa-resolver)

    * WRS 0.14.0

    * fix merge mishap

    * refactor systeminfo + update resolver target generation

    * Custom input signatureScript ability (kaspanet#69)

    * Refactorize some addresses and Script related parts

    * A ScriptBuilder example on TypeScript

    * addOps Opcodes are now BinaryT

    * Move txscript bindings to relevant folders

    * Sort lines of deps and imports

    * Lint

    * Prototype of custom sighash operations

    * Experimental

    * Add SighashType enum and option on SignInput

    * Format and a small fix

    * Clippy

    * hex view for ScriptBuilder (kaspanet#67)

    * add git_hash to system_id

    * add git_hash to system_id

    * wip

    * wip

    * refactor git head fetch to use build.rs

    * comment

    * split utils/sysinfo into utils/git, refactor utils/build.rs to run git to obtain hashes (in addition to file check)

    * using WalletGuard, account guard (kaspanet#73)

    1) private context issue on legacy accounts
    2) optional url option handling on rpc client connect method
    3) using `WalletGuard` type instead of `AsyncMutexGuard`

    * add short hash to sysinfo, return short hash in GetSystemInfo

    * add contributor DNS seeders (gerri and H@H)

    * Update phrase.rs (kaspanet#74)

    * Base implementation for PSKB and usage in core account with generator wrapper (kaspanet#64)

    * Base implementation for PSKB and usage in core account with generator wrapper stream handling.

    * prune test file

    * prune test file

    * Converters for transanction and populated transaction.

    * Optional signature import in PSKT conversion.

    * PSKB wallet cli commands.

    * More PSKB wallet cli commands for custom script locks.

    * Serialization test case

    * Reviews patches, cli script debug command added.

    * Doc about fee per transaction for script unlocking UTXOS

    * Parameter changed to priority_fee_sompi_per_transaction, revert function renaming.

    * Error handling

    * fix missing RPC refs

    * Update resolver config (WIP)

    * add version to GetSystemInfoResponse

    * fix git version handling

    * update client-side resolver properties to match current structs

    * update resolvers

    * fix kaspa-utils/build.rs to always produce git related env vars.

    * add git commit hash to WASM32 SDK artifacts during CI build

    * fix WASM32 CI build (testing)

    * fix the default url handling in wRPC client

    * Key attributes (make XPrv and XPub inspectable) (kaspanet#77)

    * getters for XPrv and XPub attributes

    * fmt

    * post merge fixes

    * Merge RBF (kaspanet#80)

    * Replace by fee on mempool (kaspanet#499)

    * Replace by fee on mempool with tests

    * Add a custom RemovalReason -- ReplacedByFee

    * Let `MinerManager` handle replace by fee (RBF) for RPC and P2P

    * Refines success conditions and process of RBF policies

    * Add an RPC `submit_transaction_replacement` method

    * fix fmt

    * Fix CLI Build WASM32 error

    * Avoid breaking wRPC

    * Extend some tests coverage to all priority, orphan & RBF policy combinations

    * Let RBF fail early or at least before checking transaction scripts in consensus

    * Cleaning

    * More cleaning

    * Use contextual instead of compute mass in RBF eviction rule

    * Avoid collision with another PR

    * Avoid collision with another PR (2)

    * Extended test coverage of RBF

    * Extended test coverage of RBF (2)

    * Rename `TransactionBatchValidationArgs` to `TransactionValidationBatchArgs`

    * Add comments

    * Assert instead of condition

    * Add an `RbfPolicy` parameter to mining manager tx validate_and_insert_... fns

    * Infer RBF policy from unorphaned transaction

    * Apply the RBF policy to all orphan-related cases

    * In Rbf allowed mode, check feerate threshold vs all double spends (i.e., compare to the max)

    * Minor hashset optimization

    * Rename: fee_per_mass -> feerate

    * Use rbf policy arg for post processing step as well

    * Renames and comments

    * Relaxation: fail gracefully if rbf replaced tx is missing (also fixes an edge case where mempool duplication resulted in this scenario)

    * Tx id is appended by the caller anyway

    ---------

    Co-authored-by: Tiram <[email protected]>
    Co-authored-by: Michael Sutton <[email protected]>

    * post merge fixes

    ---------

    Co-authored-by: KaffinPX <[email protected]>
    Co-authored-by: Tiram <[email protected]>
    Co-authored-by: Michael Sutton <[email protected]>

    * createInputSignature() utility function (kaspanet#79)

    * ``signTransactionInput`` and move sign_input to its proper location

    * Fix typedoc warnings left from old PR

    * createInputSignature

    * Update docs for ConsensusParams (WASM mass calc)

    * fmt

    * bump wRPC

    * wrs 0.15.0

    * replace Uuid.as_ref() to as_bytes()

    * assign RpcApiOps variants numerical values

    * cleanup

    * Remove WASM32 mass calculator + change createTransaction() signature (kaspanet#81)

    * Kip9 updates to WASM/wallet framework mass calc (kaspanet#66)

    * WIP

    * update kip9 processing in WASM mass calculator

    * XPrv.toPrivateKey support

    * replace lazy_static with OnceLock

    * remove NetworkParams Inner

    * make signatureScript optional on ITransactionInput (WASM32)

    * WIP mass calc (WASM32)

    * remove WASM32 mass calc, replace with dedicated functions

    * use OnceCell for NetworkParams (wallet-core)

    * Update changelog

    * fmt

    ---------

    Co-authored-by: Surinder Singh Matoo <[email protected]>

    * change OnceCell to LazyLock in wallet-core utxo settings

    * WASM: update signTransaction() signature

    * fix TS types and method names

    * lints

    * split GetConnections counter into separate clients and peers variables

    * fix missing version in GetConnections method

    * Adding type conversion. (kaspanet#76)

    * fmt

    * refactor kaspa-metrics to expose some internal methods (needed for external processing).

    * Word count (kaspanet#83)

    * Update phrase.rs

    * private context issue for importing legacy wallet

    * account filter updated for calculating account_index

    * gen1 decrypt_mnemonic updated for error unwraping

    * adding resolver tls option

    * cleanup

    * Improve input signature capability (kaspanet#85)

    * ``signTransactionInput`` and move sign_input to its proper location

    * Fix typedoc warnings left from old PR

    * createInputSignature

    * Fix createInputSignature and improve PendingTransaction Inputs DX

    * Format

    * A small Omega change applied to existing code

    * Pass reference of transaction in createInputSignature

    * fix WASM32 PSKT function names

    * refactor PSKB as a type wrapper + update serialization (kaspanet#86)

    * Cleanup of unused JSON test file for PSKB and comments (kaspanet#87)

    * Remove PSKB json test file.

    * Remove/change old PSKB comments and commented out inclusions.

    * PSKB+PSKT merge with omega branch (kaspanet#82)

    * TransactionInput signature_script as Option, add associated TS types

    * restructure PSKT + WASM scaffolding (WIP)

    * Base implementation for PSKB and usage in core account with generator wrapper (kaspanet#64)

    * Base implementation for PSKB and usage in core account with generator wrapper stream handling.

    * prune test file

    * prune test file

    * Converters for transanction and populated transaction.

    * Optional signature import in PSKT conversion.

    * PSKB wallet cli commands.

    * More PSKB wallet cli commands for custom script locks.

    * Serialization test case

    * Reviews patches, cli script debug command added.

    * Doc about fee per transaction for script unlocking UTXOS

    * Parameter changed to priority_fee_sompi_per_transaction, revert function renaming.

    * Error handling

    * Adding type conversion. (kaspanet#76)

    * fmt

    * fix WASM32 PSKT function names

    * refactor PSKB as a type wrapper + update serialization (kaspanet#86)

    * Cleanup of unused JSON test file for PSKB and comments (kaspanet#87)

    * Remove PSKB json test file.

    * Remove/change old PSKB comments and commented out inclusions.

    ---------

    Co-authored-by: 1bananagirl <[email protected]>

    * extra new line char removed (kaspanet#89)

    * lock issue on wallet creation (kaspanet#91)

    * wasm cast refs

    * resolver updates

    * CLI review: import cli watch-only changed to watch, PSKB parse view added (kaspanet#92)

    * CLI - Import commands for watch-only accounts changed to: account watch bip32 and account watch multisig.

    * CLI - PSKB parse view added next to debug view showing input/output addresses and amounts. PSKT finalized check moved from debug view to parse view. Selected account requirement in commands only if needed.

    * WASM RBF (RPC)

    * WASM FeeEstimate (RPC)

    * hex encoding for kaspa_utils::SystemInfo

    * Some symmetry and type fixes (kaspanet#93)

    * UtxoEntry typing fix and isometry w UtxoEntryReference

    * Fix type of IUtxoProcessorEvent

    * Fix interface typings of UtxoProcessor

    * Remove UtxoProcessorEventData and improve UtxoProcessor event

    * Remove unneeded overwrite

    * Clippy and a small mistake fix

    * Note: Clippy can cause fmt issues :nerd:

    * update WASM GeneratorSettings::priorityEntries? to accept UtxoEntryReference[]

    * WASM32 - update resolver casting

    * cleanup

    * WASM32: remove no longer used WAPI account module

    * cleanup

    * introduce new rpc header/block types for BBT and SB (kaspanet#95)

    * introduce new rpc header/block types for BBT and SB

    * remove unneeded clone

    * WASM - Update types for Mnemonic::random()

    * WASM update deprecated methods in web-sys

    * Add bip32 Mnemonic class to kaspa-wasm-sdk-keys build package

    * misc dependency updates

    * Introduce profile data to GetConnections RPC method

    * WASM update TS declarations for wallet events

    * fix WASM sdk submitTransaction API (kaspanet#96)

    * Add custom Debug to GetSystemInfoResponse

    * Add HexString type to ITransactionOutput::scriptPublicKey

    * fix camelCase on RpcTransactionOutpoint

    ---------

    Co-authored-by: KaffinPX <[email protected]>
    Co-authored-by: surinder singh <[email protected]>
    Co-authored-by: 1bananagirl <[email protected]>
    Co-authored-by: Tiram <[email protected]>
    Co-authored-by: Michael Sutton <[email protected]>
    Co-authored-by: IgorKhomenko <[email protected]>

commit b0f07ef
Author: Michael Sutton <[email protected]>
Date:   Mon Aug 26 18:05:54 2024 +0300

    Query all DNS seeders if missing many connections  (kaspanet#530)

    * refactor into `dns_seed_single` (no logical change yet)

    * impl dns seed many

    * rename

commit 63e4863
Author: Michael Sutton <[email protected]>
Date:   Mon Aug 26 13:58:00 2024 +0300

    A few optimizations related to multi-level relations (kaspanet#527)

    * parents_builder: optimize the common case for high levels

    * delete level relations for all levels below the affiliated proof level for this block

    * keep all multi-level parents of the pruning-point-and-anticone roots set

    * drop prune guard where possible

    * minor

    * practically impossible to reach this level (requires a pow hash which is all zeros), but for the sake of good order it should be this way

    * comments

    * fix `get_roots_of_set` for the ascending chain case + test

    * avoid quadratic roots search + rely on header cache

    * rollback `get_roots_of_set`

commit 8e93437
Author: Michael Sutton <[email protected]>
Date:   Thu Aug 22 18:56:55 2024 +0300

    TN11 bug fix: activate mass hashing when modifying a cached block template   (kaspanet#476)

    * fix transaction hash merkle root calculation in modify block template to consider storage mass activation

    * avoid similar future errors: expose only a single calc_hash_merkle_root function with `include_mass_field` arg and update all test usages explicitly

    * move subnet checks to inner location

    * reorganize cache mem estimators

commit 261a750
Author: Michael Sutton <[email protected]>
Date:   Thu Aug 22 12:29:24 2024 +0300

    Semaphore tracing feature (for tracing prune readers vs writers time) (kaspanet#526)

    * semaphore trace + feature

    * comments

    * unrelated: avoid mass fee mult due to possible edge cases

    * style: refactor code, move tracing atomics to TraceInner structure (#5)

    * style: refactor code, move tracing atomics to TraceInner structure

    * style: fmt

    * final refactor

    ---------

    Co-authored-by: Maxim <[email protected]>

commit 866f62f
Author: Maxim <[email protected]>
Date:   Wed Aug 21 21:59:47 2024 +0400

    feat: implement next_block_template_feerate (kaspanet#523)

    * feat: implement next_block_template_feerate

    * add tests, fix feerate stats calculation

    * fix comment

commit e6e0f58
Author: starkbamse <[email protected]>
Date:   Mon Aug 19 10:57:24 2024 +0200

    Upgrade mimalloc to 0.1.43 implementing the fix by microsoft team.

commit 958bc64
Author: Michael Sutton <[email protected]>
Date:   Fri Aug 16 16:32:41 2024 +0300

    O(k log n) mempool transaction sampler + Fee estimation API  (kaspanet#513)

    * initial fee estimation logic + a python notebook detailing a challenge

    * initial usage of btreeset for ready transactions

    * initial frontier + sampling logic

    * mempool sampling benchmark (wip)

    * Use arc tx rather than tx id in order to save the indirect map access as well as reduce frontier sizes + filter all the top bucket and not only selected ones

    * Modify mempool bmk and simnet settings

    * Temp: rpc message initial

    * Move sample to rand utils

    * Fix top bucket sampling to match analysis

    * Add outliers to the bmk

    * sample comments and doc

    * use b plus tree with argument customization in order to implement a highly-efficient O(k log n) one-shot mempool sampling

    * todo

    * keep a computed weight field

    * Test feerate weight queries + an implied fix (change <= to <)

    * temp remove warns

    * 1. use inner BPlusTree in order to allow access to iterator as double ended
    2. reduce collisions by removing the top element from the range if it was hit

    * rename

    * test btree rev iter

    * clamp the query to the bounds (logically)

    * use a larger tree for tests, add checks for clamped search bounds

    * Add benchmarks for frontier insertions and removals

    * add item removal to the queries test

    * Important numeric stability improvement: use the visitor api to implement a prefix weight counter to be used for search narrowing

    * test highly irregular sampling

    * Implement initial selectors + order the code a bit

    * Enhance and use the new selectors

    * rename

    * minor refactor

    * minor optimizations etc

    * increase default devnet prealloc amount to 100 tkas

    * cleanup

    * cleanup

    * initial build_feerate_estimator

    * todos

    * minor

    * Remove obsolete constant

    * Restructure search tree methods into an encapsulated struct

    * Rename module

    * documentation and comments

    * optimization: cmp with cached weight rather than compute feerate

    * minor

    * Finalize build fee estimator and add tests

    * updated notebook

    * fee estimator todos

    * expose get_realtime_feerate_estimations from the mining manager

    * min feerate from config

    * sample_inplace doc

    * test_total_mass_tracking

    * test prefix weights

    * test sequence selector

    * fix rpc feerate structs + comment

    * utils: expiring cache

    * rpc core fee estimate call

    * fee estimate verbose

    * grpc fee estimate calls

    * Benchmark worst-case collision cases + an optimization addressing these cases

    * Expose SearchTree

    * cli support (with @coderofstuff)

    * addressing a few minor review comments

    * feerate estimator - handle various edge cases (with @tiram88)

    * one more test (with @tiram88)

    * build_feerate_estimator - fix edge case of not trying the estimator without all frontier txs (+loop logic is more streamlined now)

    * monitor feerate estimations (debug print every 10 secs)

    * follow rpc naming conventions

    * proto leave blank index range

    * insert in correct abc location (keeping rest of the array as is for easier omega merge)

    * fix comment to reflect the most updated final algo

    * document feerate

    * update notebook

    * add an additional point to normal feerate buckets (between normal and low)

    * enum order

    * with 1 sec there are rare cases where mempool size does not change and we exit early

    * final stuff

commit 6bf1c75
Author: Ori Newman <[email protected]>
Date:   Thu Aug 15 18:03:48 2024 +0300

    Lazy load origin children (kaspanet#518)

    * Lazy load origin children

    * remove redundant collect

    * Delete level-0 relations for blocks which only belong to higher proof levels

    * Comments

    * Edit comment

commit 5ebd9fe
Author: 1bananagirl <[email protected]>
Date:   Wed Aug 7 13:47:14 2024 +0200

    Add hint message for P2P reject reason block not found. (kaspanet#512)

commit 9feb5dc
Author: KaffinPX <[email protected]>
Date:   Fri Jul 26 16:46:59 2024 +0300

    Add input signature_script checking to submitTransaction RPC (kaspanet#479)

    * Add input signature script checking to RPC

    * Return multiple indices w the EmptySignatureScript error

    * Apply suggestions

    * Refctorize some part of code to apply suggestions

    * Revert in-RPC changes and move error to in-consensus

    * Apply Maxims suggestions (match -> if)

    * Simple forgotten lints

    ---------

    Co-authored-by: Michael Sutton <[email protected]>
    Co-authored-by: aspect <[email protected]>

commit 0feba1f
Author: Maxim <[email protected]>
Date:   Fri Jul 26 16:48:44 2024 +0400

    style: fix clippy (kaspanet#510)

    * style: fix clippy

    * relax the restriction to make ci green =)

commit 56c19c9
Author: KaffinPX <[email protected]>
Date:   Tue Jul 23 01:43:35 2024 +0300

    Replace by fee on mempool (kaspanet#499)

    * Replace by fee on mempool with tests

    * Add a custom RemovalReason -- ReplacedByFee

    * Let `MinerManager` handle replace by fee (RBF) for RPC and P2P

    * Refines success conditions and process of RBF policies

    * Add an RPC `submit_transaction_replacement` method

    * fix fmt

    * Fix CLI Build WASM32 error

    * Avoid breaking wRPC

    * Extend some tests coverage to all priority, orphan & RBF policy combinations

    * Let RBF fail early or at least before checking transaction scripts in consensus

    * Cleaning

    * More cleaning

    * Use contextual instead of compute mass in RBF eviction rule

    * Avoid collision with another PR

    * Avoid collision with another PR (2)

    * Extended test coverage of RBF

    * Extended test coverage of RBF (2)

    * Rename `TransactionBatchValidationArgs` to `TransactionValidationBatchArgs`

    * Add comments

    * Assert instead of condition

    * Add an `RbfPolicy` parameter to mining manager tx validate_and_insert_... fns

    * Infer RBF policy from unorphaned transaction

    * Apply the RBF policy to all orphan-related cases

    * In Rbf allowed mode, check feerate threshold vs all double spends (i.e., compare to the max)

    * Minor hashset optimization

    * Rename: fee_per_mass -> feerate

    * Use rbf policy arg for post processing step as well

    * Renames and comments

    * Relaxation: fail gracefully if rbf replaced tx is missing (also fixes an edge case where mempool duplication resulted in this scenario)

    * Tx id is appended by the caller anyway

    ---------

    Co-authored-by: Tiram <[email protected]>
    Co-authored-by: Michael Sutton <[email protected]>

commit 6a56461
Author: Maxim <[email protected]>
Date:   Tue Jun 18 18:09:29 2024 +0300

    Implement  PSKT(Partially Signed Kaspa Transaction) (kaspanet#481)

    * initial support of pskt:
        supported roles: creator, constructor, updater, signer roles

    * add builder

    * handle combine errors

    * finalize

    * extractor

    * chore: typo

    * style: fmt

    * expose txid to global

    * chore: change version

    * feat: serde for optional bytes

    * feat: impl (de)serialization

    * style: fmt

    * add example, fixes

    * style: fmt

    * style: clippy

    * rollback unrelated changes

    * psbt -> pskt

    * refactor: avoid copy-paste by using recursion

    * docs: add description of roles

commit a797e1e
Author: George Bogodukhov <[email protected]>
Date:   Mon Jun 17 15:50:16 2024 +1000

    Add support for IP only for --rpclisten-borsh/json (kaspanet#402) (kaspanet#439)

    * Add support for IP only for --rpclisten-borsh/json

    * Fix cehck complaints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Submitting TXs with incomplete keys must produce easily understandable error
4 participants