From a40efbb6900333f072043f30bf9c3de2c34ec143 Mon Sep 17 00:00:00 2001 From: Michael Sutton Date: Tue, 22 Oct 2024 12:40:20 +0300 Subject: [PATCH 1/2] Rust 1.82 fixes + mempool std sig op count check (#583) * rust 1.82 fixes * sig op count std check --- cli/src/cli.rs | 4 ++-- crypto/txscript/src/lib.rs | 1 + mining/errors/src/mempool.rs | 2 +- mining/src/mempool/check_transaction_standard.rs | 5 ++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 5ca1997ea..a32956740 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -1016,7 +1016,7 @@ mod panic_handler { fn stack(error: &Error) -> String; } - pub fn process(info: &std::panic::PanicInfo) -> String { + pub fn process(info: &std::panic::PanicHookInfo) -> String { let mut msg = info.to_string(); // Add the error stack to our message. @@ -1053,7 +1053,7 @@ mod panic_handler { impl KaspaCli { pub fn init_panic_hook(self: &Arc) { let this = self.clone(); - let handler = move |info: &std::panic::PanicInfo| { + let handler = move |info: &std::panic::PanicHookInfo| { let msg = panic_handler::process(info); this.term().writeln(msg.crlf()); panic_handler::console_error(msg); diff --git a/crypto/txscript/src/lib.rs b/crypto/txscript/src/lib.rs index f17796272..5fed84328 100644 --- a/crypto/txscript/src/lib.rs +++ b/crypto/txscript/src/lib.rs @@ -93,6 +93,7 @@ fn parse_script( script.iter().batching(|it| deserialize_next_opcode(it)) } +#[must_use] pub fn get_sig_op_count( signature_script: &[u8], prev_script_public_key: &ScriptPublicKey, diff --git a/mining/errors/src/mempool.rs b/mining/errors/src/mempool.rs index 319aaa484..12416be67 100644 --- a/mining/errors/src/mempool.rs +++ b/mining/errors/src/mempool.rs @@ -131,7 +131,7 @@ pub enum NonStandardError { RejectInsufficientFee(TransactionId, u64, u64), #[error("transaction input #{1} has {2} signature operations which is more than the allowed max amount of {3}")] - RejectSignatureCount(TransactionId, usize, u8, u8), + RejectSignatureCount(TransactionId, usize, u64, u8), } impl NonStandardError { diff --git a/mining/src/mempool/check_transaction_standard.rs b/mining/src/mempool/check_transaction_standard.rs index 060677a1e..ef4d3fb9e 100644 --- a/mining/src/mempool/check_transaction_standard.rs +++ b/mining/src/mempool/check_transaction_standard.rs @@ -188,12 +188,11 @@ impl Mempool { ScriptClass::PubKey => {} ScriptClass::PubKeyECDSA => {} ScriptClass::ScriptHash => { - get_sig_op_count::( + let num_sig_ops = get_sig_op_count::( &input.signature_script, &entry.script_public_key, ); - let num_sig_ops = 1; - if num_sig_ops > MAX_STANDARD_P2SH_SIG_OPS { + if num_sig_ops > MAX_STANDARD_P2SH_SIG_OPS as u64 { return Err(NonStandardError::RejectSignatureCount(transaction_id, i, num_sig_ops, MAX_STANDARD_P2SH_SIG_OPS)); } } From aac16a9244e558f719e37663e587838664248466 Mon Sep 17 00:00:00 2001 From: Romain Billot Date: Tue, 22 Oct 2024 11:41:22 +0200 Subject: [PATCH 2/2] typo(cli/utils): kaspa wording (#582) Co-authored-by: Michael Sutton --- cli/src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/utils.rs b/cli/src/utils.rs index 3e1d0ddb1..e52581b4c 100644 --- a/cli/src/utils.rs +++ b/cli/src/utils.rs @@ -8,7 +8,7 @@ pub fn try_parse_required_nonzero_kaspa_as_sompi_u64(kasp let sompi_amount = kaspa_amount .to_string() .parse::() - .map_err(|_| Error::custom(format!("Supplied Kasapa amount is not valid: '{kaspa_amount}'")))? + .map_err(|_| Error::custom(format!("Supplied Kaspa amount is not valid: '{kaspa_amount}'")))? * SOMPI_PER_KASPA as f64; if sompi_amount < 0.0 { Err(Error::custom("Supplied Kaspa amount is not valid: '{kaspa_amount}'"))