Skip to content

Commit

Permalink
Merge branch 'master' of github.com:aspectron/rusty-kaspa into typesc…
Browse files Browse the repository at this point in the history
…ript
  • Loading branch information
aspect committed May 5, 2024
2 parents 153b1af + 7974dae commit dd38935
Show file tree
Hide file tree
Showing 73 changed files with 401 additions and 2,919 deletions.
472 changes: 246 additions & 226 deletions Cargo.lock

Large diffs are not rendered by default.

117 changes: 58 additions & 59 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ members = [
"consensus/notify",
"consensus/pow",
"consensus/wasm",
# "kos",
"kaspad",
"simpa",
"wasm",
Expand Down Expand Up @@ -63,7 +62,7 @@ members = [

[workspace.package]
rust-version = "1.77.0"
version = "0.13.6"
version = "0.14.1"
authors = ["Kaspa developers"]
license = "ISC"
repository = "https://github.com/kaspanet/rusty-kaspa"
Expand All @@ -80,63 +79,62 @@ include = [
]

[workspace.dependencies]
# kaspa-testing-integration = { version = "0.13.6", path = "testing/integration" }
kaspa-addresses = { version = "0.13.6", path = "crypto/addresses" }
kaspa-addressmanager = { version = "0.13.6", path = "components/addressmanager" }
kaspa-bip32 = { version = "0.13.6", path = "wallet/bip32" }
kaspa-resolver = { version = "0.13.6", path = "rpr/wrpc/resolver" }
kaspa-cli = { version = "0.13.6", path = "cli" }
kaspa-connectionmanager = { version = "0.13.6", path = "components/connectionmanager" }
kaspa-consensus = { version = "0.13.6", path = "consensus" }
kaspa-consensus-core = { version = "0.13.6", path = "consensus/core" }
kaspa-consensus-client = { version = "0.13.6", path = "consensus/client" }
kaspa-consensus-notify = { version = "0.13.6", path = "consensus/notify" }
kaspa-consensus-wasm = { version = "0.13.6", path = "consensus/wasm" }
kaspa-consensusmanager = { version = "0.13.6", path = "components/consensusmanager" }
kaspa-core = { version = "0.13.6", path = "core" }
kaspa-daemon = { version = "0.13.6", path = "daemon" }
kaspa-database = { version = "0.13.6", path = "database" }
kaspa-grpc-client = { version = "0.13.6", path = "rpc/grpc/client" }
kaspa-grpc-core = { version = "0.13.6", path = "rpc/grpc/core" }
kaspa-grpc-server = { version = "0.13.6", path = "rpc/grpc/server" }
kaspa-hashes = { version = "0.13.6", path = "crypto/hashes" }
kaspa-index-core = { version = "0.13.6", path = "indexes/core" }
kaspa-index-processor = { version = "0.13.6", path = "indexes/processor" }
kaspa-math = { version = "0.13.6", path = "math" }
kaspa-merkle = { version = "0.13.6", path = "crypto/merkle" }
kaspa-metrics-core = { version = "0.13.6", path = "metrics/core" }
kaspa-mining = { version = "0.13.6", path = "mining" }
kaspa-mining-errors = { version = "0.13.6", path = "mining/errors" }
kaspa-muhash = { version = "0.13.6", path = "crypto/muhash" }
kaspa-notify = { version = "0.13.6", path = "notify" }
# kaspa-os = { version = "0.13.6", path = "kaspa-os" }
kaspa-p2p-flows = { version = "0.13.6", path = "protocol/flows" }
kaspa-p2p-lib = { version = "0.13.6", path = "protocol/p2p" }
kaspa-perf-monitor = { version = "0.13.6", path = "metrics/perf_monitor" }
kaspa-pow = { version = "0.13.6", path = "consensus/pow" }
kaspa-rpc-core = { version = "0.13.6", path = "rpc/core" }
kaspa-rpc-macros = { version = "0.13.6", path = "rpc/macros" }
kaspa-rpc-service = { version = "0.13.6", path = "rpc/service" }
kaspa-txscript = { version = "0.13.6", path = "crypto/txscript" }
kaspa-txscript-errors = { version = "0.13.6", path = "crypto/txscript/errors" }
kaspa-utils = { version = "0.13.6", path = "utils" }
kaspa-utils-tower = { version = "0.13.6", path = "utils/tower" }
kaspa-utxoindex = { version = "0.13.6", path = "indexes/utxoindex" }
kaspa-wallet = { version = "0.13.6", path = "wallet/native" }
kaspa-wallet-cli-wasm = { version = "0.13.6", path = "wallet/wasm" }
kaspa-wallet-keys = { version = "0.13.6", path = "wallet/keys" }
kaspa-wallet-core = { version = "0.13.6", path = "wallet/core" }
kaspa-wallet-macros = { version = "0.13.6", path = "wallet/macros" }
kaspa-wasm = { version = "0.13.6", path = "wasm" }
kaspa-wasm-core = { version = "0.13.6", path = "wasm/core" }
kaspa-wrpc-client = { version = "0.13.6", path = "rpc/wrpc/client" }
kaspa-wrpc-core = { version = "0.13.6", path = "rpc/wrpc/core" }
kaspa-wrpc-proxy = { version = "0.13.6", path = "rpc/wrpc/proxy" }
kaspa-wrpc-server = { version = "0.13.6", path = "rpc/wrpc/server" }
kaspa-wrpc-wasm = { version = "0.13.6", path = "rpc/wrpc/wasm" }
kaspa-wrpc-example-subscriber = { version = "0.13.6", path = "rpc/wrpc/examples/subscriber" }
kaspad = { version = "0.13.6", path = "kaspad" }
kaspa-alloc = { version = "0.13.6", path = "utils/alloc" }
# kaspa-testing-integration = { version = "0.14.1", path = "testing/integration" }
kaspa-addresses = { version = "0.14.1", path = "crypto/addresses" }
kaspa-addressmanager = { version = "0.14.1", path = "components/addressmanager" }
kaspa-bip32 = { version = "0.14.1", path = "wallet/bip32" }
kaspa-resolver = { version = "0.14.1", path = "rpr/wrpc/resolver" }
kaspa-cli = { version = "0.14.1", path = "cli" }
kaspa-connectionmanager = { version = "0.14.1", path = "components/connectionmanager" }
kaspa-consensus = { version = "0.14.1", path = "consensus" }
kaspa-consensus-core = { version = "0.14.1", path = "consensus/core" }
kaspa-consensus-client = { version = "0.14.1", path = "consensus/client" }
kaspa-consensus-notify = { version = "0.14.1", path = "consensus/notify" }
kaspa-consensus-wasm = { version = "0.14.1", path = "consensus/wasm" }
kaspa-consensusmanager = { version = "0.14.1", path = "components/consensusmanager" }
kaspa-core = { version = "0.14.1", path = "core" }
kaspa-daemon = { version = "0.14.1", path = "daemon" }
kaspa-database = { version = "0.14.1", path = "database" }
kaspa-grpc-client = { version = "0.14.1", path = "rpc/grpc/client" }
kaspa-grpc-core = { version = "0.14.1", path = "rpc/grpc/core" }
kaspa-grpc-server = { version = "0.14.1", path = "rpc/grpc/server" }
kaspa-hashes = { version = "0.14.1", path = "crypto/hashes" }
kaspa-index-core = { version = "0.14.1", path = "indexes/core" }
kaspa-index-processor = { version = "0.14.1", path = "indexes/processor" }
kaspa-math = { version = "0.14.1", path = "math" }
kaspa-merkle = { version = "0.14.1", path = "crypto/merkle" }
kaspa-metrics-core = { version = "0.14.1", path = "metrics/core" }
kaspa-mining = { version = "0.14.1", path = "mining" }
kaspa-mining-errors = { version = "0.14.1", path = "mining/errors" }
kaspa-muhash = { version = "0.14.1", path = "crypto/muhash" }
kaspa-notify = { version = "0.14.1", path = "notify" }
kaspa-p2p-flows = { version = "0.14.1", path = "protocol/flows" }
kaspa-p2p-lib = { version = "0.14.1", path = "protocol/p2p" }
kaspa-perf-monitor = { version = "0.14.1", path = "metrics/perf_monitor" }
kaspa-pow = { version = "0.14.1", path = "consensus/pow" }
kaspa-rpc-core = { version = "0.14.1", path = "rpc/core" }
kaspa-rpc-macros = { version = "0.14.1", path = "rpc/macros" }
kaspa-rpc-service = { version = "0.14.1", path = "rpc/service" }
kaspa-txscript = { version = "0.14.1", path = "crypto/txscript" }
kaspa-txscript-errors = { version = "0.14.1", path = "crypto/txscript/errors" }
kaspa-utils = { version = "0.14.1", path = "utils" }
kaspa-utils-tower = { version = "0.14.1", path = "utils/tower" }
kaspa-utxoindex = { version = "0.14.1", path = "indexes/utxoindex" }
kaspa-wallet = { version = "0.14.1", path = "wallet/native" }
kaspa-wallet-cli-wasm = { version = "0.14.1", path = "wallet/wasm" }
kaspa-wallet-keys = { version = "0.14.1", path = "wallet/keys" }
kaspa-wallet-core = { version = "0.14.1", path = "wallet/core" }
kaspa-wallet-macros = { version = "0.14.1", path = "wallet/macros" }
kaspa-wasm = { version = "0.14.1", path = "wasm" }
kaspa-wasm-core = { version = "0.14.1", path = "wasm/core" }
kaspa-wrpc-client = { version = "0.14.1", path = "rpc/wrpc/client" }
kaspa-wrpc-core = { version = "0.14.1", path = "rpc/wrpc/core" }
kaspa-wrpc-proxy = { version = "0.14.1", path = "rpc/wrpc/proxy" }
kaspa-wrpc-server = { version = "0.14.1", path = "rpc/wrpc/server" }
kaspa-wrpc-wasm = { version = "0.14.1", path = "rpc/wrpc/wasm" }
kaspa-wrpc-example-subscriber = { version = "0.14.1", path = "rpc/wrpc/examples/subscriber" }
kaspad = { version = "0.14.1", path = "kaspad" }
kaspa-alloc = { version = "0.14.1", path = "utils/alloc" }

# external
aes = "0.8.3"
Expand Down Expand Up @@ -323,3 +321,4 @@ overflow-checks = true
inherits = "release"
debug = true
strip = false

3 changes: 3 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ features = [

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio.workspace = true

[lints.clippy]
empty_docs = "allow"
1 change: 1 addition & 0 deletions components/addressmanager/src/stores/address_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub trait AddressesStoreReader {

pub trait AddressesStore: AddressesStoreReader {
fn set(&mut self, key: AddressKey, entry: Entry) -> StoreResult<()>;
#[allow(dead_code)]
fn set_failed_count(&mut self, key: AddressKey, connection_failed_count: u64) -> StoreResult<()>;
fn remove(&mut self, key: AddressKey) -> StoreResult<()>;
}
Expand Down
3 changes: 3 additions & 0 deletions consensus/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ itertools.workspace = true

workflow-wasm.workspace = true
workflow-log.workspace = true

[lints.clippy]
empty_docs = "allow"
2 changes: 1 addition & 1 deletion consensus/client/src/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn sign_with_multiple_v3(tx: Transaction, privkeys: &[[u8; 32]]) -> crate::r
}
};
let script = script_pub_key.script();
if let Some(schnorr_key) = map.get(&script.to_vec()) {
if let Some(schnorr_key) = map.get(script) {
let sig_hash = calc_schnorr_signature_hash(&populated_transaction, i, SIG_HASH_ALL, &mut reused_values);
let msg = secp256k1::Message::from_digest_slice(sig_hash.as_bytes().as_slice()).unwrap();
let sig: [u8; 64] = *schnorr_key.sign_schnorr(msg).as_ref();
Expand Down
3 changes: 3 additions & 0 deletions consensus/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ web-sys.workspace = true
[[bench]]
name = "serde_benchmark"
harness = false

[lints.clippy]
empty_docs = "allow"
2 changes: 1 addition & 1 deletion consensus/core/src/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub fn sign_with_multiple_v2(mut mutable_tx: SignableTransaction, privkeys: &[[u
let mut additional_signatures_required = false;
for i in 0..mutable_tx.tx.inputs.len() {
let script = mutable_tx.entries[i].as_ref().unwrap().script_public_key.script();
if let Some(schnorr_key) = map.get(&script.to_vec()) {
if let Some(schnorr_key) = map.get(script) {
let sig_hash = calc_schnorr_signature_hash(&mutable_tx.as_verifiable(), i, SIG_HASH_ALL, &mut reused_values);
let msg = secp256k1::Message::from_digest_slice(sig_hash.as_bytes().as_slice()).unwrap();
let sig: [u8; 64] = *schnorr_key.sign_schnorr(msg).as_ref();
Expand Down
37 changes: 31 additions & 6 deletions consensus/core/src/subnets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::str::{self, FromStr};
use borsh::{BorshDeserialize, BorshSerialize};
use kaspa_utils::hex::{FromHex, ToHex};
use kaspa_utils::{serde_impl_deser_fixed_bytes_ref, serde_impl_ser_fixed_bytes_ref};
use thiserror::Error;

/// The size of the array used to store subnetwork IDs.
pub const SUBNETWORK_ID_SIZE: usize = 20;
Expand Down Expand Up @@ -65,12 +66,28 @@ impl SubnetworkId {
}
}

#[derive(Error, Debug, Clone)]
pub enum SubnetworkConversionError {
#[error("Invalid bytes")]
InvalidBytes,

#[error(transparent)]
SliceError(#[from] std::array::TryFromSliceError),

#[error(transparent)]
HexError(#[from] faster_hex::Error),
}

impl TryFrom<&[u8]> for SubnetworkId {
type Error = std::array::TryFromSliceError;
type Error = SubnetworkConversionError;

fn try_from(value: &[u8]) -> Result<Self, Self::Error> {
let bytes = <[u8; SUBNETWORK_ID_SIZE]>::try_from(value)?;
Ok(Self(bytes))
if bytes != Self::from_byte(0).0 && bytes != Self::from_byte(1).0 {
Err(Self::Error::InvalidBytes)
} else {
Ok(Self(bytes))
}
}
}

Expand All @@ -92,22 +109,30 @@ impl ToHex for SubnetworkId {
}

impl FromStr for SubnetworkId {
type Err = faster_hex::Error;
type Err = SubnetworkConversionError;

#[inline]
fn from_str(hex_str: &str) -> Result<Self, Self::Err> {
let mut bytes = [0u8; SUBNETWORK_ID_SIZE];
faster_hex::hex_decode(hex_str.as_bytes(), &mut bytes)?;
Ok(SubnetworkId(bytes))
if bytes != Self::from_byte(0).0 && bytes != Self::from_byte(1).0 {
Err(Self::Err::InvalidBytes)
} else {
Ok(Self(bytes))
}
}
}

impl FromHex for SubnetworkId {
type Error = faster_hex::Error;
type Error = SubnetworkConversionError;
fn from_hex(hex_str: &str) -> Result<Self, Self::Error> {
let mut bytes = [0u8; SUBNETWORK_ID_SIZE];
faster_hex::hex_decode(hex_str.as_bytes(), &mut bytes)?;
Ok(SubnetworkId(bytes))
if bytes != Self::from_byte(0).0 && bytes != Self::from_byte(1).0 {
Err(Self::Error::InvalidBytes)
} else {
Ok(Self(bytes))
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions consensus/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ wasm-bindgen.workspace = true

workflow-wasm.workspace = true
workflow-log.workspace = true

[lints.clippy]
empty_docs = "allow"
3 changes: 3 additions & 0 deletions crypto/addresses/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ web-sys.workspace = true
[[bench]]
name = "bench"
harness = false

[lints.clippy]
empty_docs = "allow"
1 change: 1 addition & 0 deletions crypto/txscript/src/data_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub(crate) trait DataStack {
fn pop_items<const SIZE: usize, T: Debug>(&mut self) -> Result<[T; SIZE], TxScriptError>
where
Vec<u8>: OpcodeData<T>;
#[allow(dead_code)]
fn peek_items<const SIZE: usize, T: Debug>(&self) -> Result<[T; SIZE], TxScriptError>
where
Vec<u8>: OpcodeData<T>;
Expand Down
2 changes: 1 addition & 1 deletion crypto/txscript/src/opcodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ mod test {
let mut reused_values = SigHashReusedValues::new();
for ErrorTestCase { init, code, error } in tests {
let mut vm = TxScriptEngine::new(&mut reused_values, &cache);
vm.dstack = init.clone();
vm.dstack.clone_from(&init);
assert_eq!(
code.execute(&mut vm)
.expect_err(format!("Opcode {} should have errored (init: {:?})", code.value(), init.clone()).as_str()),
Expand Down
2 changes: 1 addition & 1 deletion kaspad/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl Args {
config.is_archival = self.archival;
// TODO: change to `config.enable_sanity_checks = self.sanity` when we reach stable versions
config.enable_sanity_checks = true;
config.user_agent_comments = self.user_agent_comments.clone();
config.user_agent_comments.clone_from(&self.user_agent_comments);
config.block_template_cache_lifetime = self.block_template_cache_lifetime;
config.p2p_listen_address = self.listen.unwrap_or(ContextualNetAddress::unspecified());
config.externalip = self.externalip.map(|v| v.normalize(config.default_p2p_port()));
Expand Down
4 changes: 0 additions & 4 deletions kos/.gitignore

This file was deleted.

68 changes: 0 additions & 68 deletions kos/Cargo.toml

This file was deleted.

Loading

0 comments on commit dd38935

Please sign in to comment.