Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ members = [
]

[workspace.package]
rust-version = "1.77.0"
version = "0.13.5"
authors = ["Kaspa developers"]
license = "MIT/Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions components/consensusmanager/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ pub use tokio::task::spawn_blocking;
use crate::BlockProcessingBatch;

#[derive(Clone)]
pub struct SessionOwnedReadGuard(Arc<RfRwLockOwnedReadGuard>);
pub struct SessionOwnedReadGuard(pub Arc<RfRwLockOwnedReadGuard>);

pub struct SessionReadGuard<'a>(RfRwLockReadGuard<'a>);
pub struct SessionReadGuard<'a>(pub RfRwLockReadGuard<'a>);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did this change occur due to inter?
If so I would suggest to suppress it instead of making the field public

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed: 319a624


pub struct SessionWriteGuard<'a>(RfRwLockWriteGuard<'a>);

Expand Down
4 changes: 2 additions & 2 deletions consensus/core/src/api/stats.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use borsh::{BorshDeserialize, BorshSerialize};
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize, BorshSchema, Default)]
#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct BlockCount {
pub header_count: u64,
Expand Down
4 changes: 2 additions & 2 deletions consensus/core/src/header.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{hashing, BlueWorkType};
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use borsh::{BorshDeserialize, BorshSerialize};
use js_sys::{Array, Object};
use kaspa_hashes::Hash;
use kaspa_utils::hex::ToHex;
Expand All @@ -8,7 +8,7 @@ use serde_wasm_bindgen::*;
use wasm_bindgen::prelude::*;
use workflow_wasm::prelude::*;

#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize, BorshSchema)]
#[derive(Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
#[serde(rename_all = "camelCase")]
#[wasm_bindgen(inspectable)]
pub struct Header {
Expand Down
6 changes: 3 additions & 3 deletions consensus/core/src/network.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use borsh::{BorshDeserialize, BorshSerialize};
use kaspa_addresses::Prefix;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
use std::fmt::{Debug, Display, Formatter};
Expand All @@ -15,7 +15,7 @@ pub enum NetworkTypeError {
}

u8_try_from! {
#[derive(Clone, Copy, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize, BorshSchema, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize, PartialEq, Eq)]
#[serde(rename_all = "lowercase")]
#[wasm_bindgen]
pub enum NetworkType {
Expand Down Expand Up @@ -157,7 +157,7 @@ pub enum NetworkIdError {
InvalidNetworkId(String),
}

#[derive(Clone, Copy, Debug, BorshSerialize, BorshDeserialize, BorshSchema, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, BorshSerialize, BorshDeserialize, PartialEq, Eq)]
#[wasm_bindgen(inspectable)]
pub struct NetworkId {
#[wasm_bindgen(js_name = "type")]
Expand Down
4 changes: 2 additions & 2 deletions consensus/core/src/subnets.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use std::fmt::{Debug, Display, Formatter};
use std::str::{self, FromStr};

use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
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};

/// The size of the array used to store subnetwork IDs.
pub const SUBNETWORK_ID_SIZE: usize = 20;

/// The domain representation of a Subnetwork ID
#[derive(Clone, Default, Eq, PartialEq, Ord, PartialOrd, Hash, BorshSerialize, BorshDeserialize, BorshSchema)]
#[derive(Clone, Default, Eq, PartialEq, Ord, PartialOrd, Hash, BorshSerialize, BorshDeserialize)]
pub struct SubnetworkId([u8; SUBNETWORK_ID_SIZE]);

impl Debug for SubnetworkId {
Expand Down
10 changes: 5 additions & 5 deletions consensus/core/src/tx.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod script_public_key;

use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use borsh::{BorshDeserialize, BorshSerialize};
use kaspa_utils::hex::ToHex;
use kaspa_utils::mem_size::MemSizeEstimator;
use kaspa_utils::{serde_bytes, serde_bytes_fixed_ref};
Expand Down Expand Up @@ -28,7 +28,7 @@ pub type TransactionId = kaspa_hashes::Hash;
/// set such as whether or not it was contained in a coinbase tx, the daa
/// score of the block that accepts the tx, its public key script, and how
/// much it pays.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, BorshSerialize, BorshDeserialize, BorshSchema)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
#[serde(rename_all = "camelCase")]
#[wasm_bindgen(inspectable, js_name = TxUtxoEntry)]
pub struct UtxoEntry {
Expand All @@ -52,7 +52,7 @@ impl MemSizeEstimator for UtxoEntry {}
pub type TransactionIndexType = u32;

/// Represents a Kaspa transaction outpoint
#[derive(Eq, Hash, PartialEq, Debug, Copy, Clone, Serialize, Deserialize, BorshSerialize, BorshDeserialize, BorshSchema)]
#[derive(Eq, Hash, PartialEq, Debug, Copy, Clone, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
#[serde(rename_all = "camelCase")]
pub struct TransactionOutpoint {
#[serde(with = "serde_bytes_fixed_ref")]
Expand All @@ -73,7 +73,7 @@ impl Display for TransactionOutpoint {
}

/// Represents a Kaspa transaction input
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize, BorshSchema)]
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
#[serde(rename_all = "camelCase")]
pub struct TransactionInput {
pub previous_outpoint: TransactionOutpoint,
Expand Down Expand Up @@ -105,7 +105,7 @@ impl std::fmt::Debug for TransactionInput {
}

/// Represents a Kaspad transaction output
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize, BorshSchema)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
#[serde(rename_all = "camelCase")]
pub struct TransactionOutput {
pub value: u64,
Expand Down
22 changes: 1 addition & 21 deletions consensus/core/src/tx/script_public_key.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloc::borrow::Cow;
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use borsh::{BorshDeserialize, BorshSerialize};
use core::fmt::Formatter;
use kaspa_utils::{
hex::{FromHex, ToHex},
Expand Down Expand Up @@ -350,26 +350,6 @@ impl BorshDeserialize for ScriptPublicKey {
}
}

impl BorshSchema for ScriptPublicKey {
fn add_definitions_recursively(
definitions: &mut std::collections::HashMap<borsh::schema::Declaration, borsh::schema::Definition>,
) {
let fields = borsh::schema::Fields::NamedFields(std::vec![
("version".to_string(), <u16>::declaration()),
("script".to_string(), <Vec<u8>>::declaration())
]);
let definition = borsh::schema::Definition::Struct { fields };
Self::add_definition(Self::declaration(), definition, definitions);
<u16>::add_definitions_recursively(definitions);
// `<Vec<u8>>` can be safely used as scheme definition for smallvec. See comments above.
<Vec<u8>>::add_definitions_recursively(definitions);
}

fn declaration() -> borsh::schema::Declaration {
"ScriptPublicKey".to_string()
}
}

impl TryFrom<JsValue> for ScriptPublicKey {
type Error = JsValue;

Expand Down
32 changes: 3 additions & 29 deletions crypto/addresses/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use borsh::{BorshDeserialize, BorshSerialize};
use js_sys::Array;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use smallvec::SmallVec;
Expand Down Expand Up @@ -43,9 +43,7 @@ impl From<workflow_wasm::error::Error> for AddressError {
}

/// Address prefix identifying the network type this address belongs to (such as `kaspa`, `kaspatest`, `kaspasim`, `kaspadev`).
#[derive(
PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug, Hash, Serialize, Deserialize, BorshSerialize, BorshDeserialize, BorshSchema,
)]
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug, Hash, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
pub enum Prefix {
#[serde(rename = "kaspa")]
Mainnet,
Expand Down Expand Up @@ -111,9 +109,7 @@ impl TryFrom<&str> for Prefix {
///
/// Kaspa `Address` version (`PubKey`, `PubKey ECDSA`, `ScriptHash`)
///
#[derive(
PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug, Hash, Serialize, Deserialize, BorshSerialize, BorshDeserialize, BorshSchema,
)]
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Debug, Hash, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
#[repr(u8)]
#[wasm_bindgen(js_name = "AddressVersion")]
pub enum Version {
Expand Down Expand Up @@ -282,28 +278,6 @@ impl BorshDeserialize for Address {
}
}

impl BorshSchema for Address {
fn add_definitions_recursively(
definitions: &mut std::collections::HashMap<borsh::schema::Declaration, borsh::schema::Definition>,
) {
let fields = borsh::schema::Fields::NamedFields(std::vec![
("prefix".to_string(), <Prefix>::declaration()),
("version".to_string(), <Version>::declaration()),
("payload".to_string(), <Vec<u8>>::declaration())
]);
let definition = borsh::schema::Definition::Struct { fields };
Self::add_definition(Self::declaration(), definition, definitions);
<Prefix>::add_definitions_recursively(definitions);
<Version>::add_definitions_recursively(definitions);
// `<Vec<u8>>` can be safely used as scheme definition for smallvec. See comments above.
<Vec<u8>>::add_definitions_recursively(definitions);
}

fn declaration() -> borsh::schema::Declaration {
"Address".to_string()
}
}

impl From<Address> for String {
fn from(address: Address) -> Self {
(&address).into()
Expand Down
4 changes: 2 additions & 2 deletions crypto/hashes/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mod hashers;
mod pow_hashers;

use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use borsh::{BorshDeserialize, BorshSerialize};
use kaspa_utils::{
hex::{FromHex, ToHex},
mem_size::MemSizeEstimator,
Expand All @@ -21,7 +21,7 @@ pub const HASH_SIZE: usize = 32;
pub use hashers::*;

// TODO: Check if we use hash more as an array of u64 or of bytes and change the default accordingly
#[derive(Eq, Clone, Copy, Default, PartialOrd, Ord, BorshSerialize, BorshDeserialize, BorshSchema)]
#[derive(Eq, Clone, Copy, Default, PartialOrd, Ord, BorshSerialize, BorshDeserialize)]
#[wasm_bindgen]
pub struct Hash([u8; HASH_SIZE]);

Expand Down
1 change: 1 addition & 0 deletions crypto/txscript/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ mod bitcoind_tests {
result: Result<(), UnifiedError>,
}

#[allow(dead_code)]
#[derive(Deserialize, Debug, Clone)]
#[serde(untagged)]
enum JsonTestRow {
Expand Down
4 changes: 2 additions & 2 deletions crypto/txscript/src/script_class.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{opcodes, MAX_SCRIPT_PUBLIC_KEY_VERSION};
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use borsh::{BorshDeserialize, BorshSerialize};
use kaspa_addresses::Version;
use kaspa_consensus_core::tx::{ScriptPublicKey, ScriptPublicKeyVersion};
use serde::{Deserialize, Serialize};
Expand All @@ -16,7 +16,7 @@ pub enum Error {
}

/// Standard classes of script payment in the blockDAG
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize, BorshSchema)]
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize, BorshSerialize, BorshDeserialize)]
#[repr(u8)]
pub enum ScriptClass {
/// None of the recognized forms
Expand Down
Loading