Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
300 changes: 110 additions & 190 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ members = [
]

[workspace.dependencies]
dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "8cbae416458565faac21d3452fbc6d80b324f6d3" }
dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "8cbae416458565faac21d3452fbc6d80b324f6d3" }
dash-spv-ffi = { git = "https://github.com/dashpay/rust-dashcore", rev = "8cbae416458565faac21d3452fbc6d80b324f6d3" }
key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "8cbae416458565faac21d3452fbc6d80b324f6d3" }
key-wallet-manager = { git = "https://github.com/dashpay/rust-dashcore", rev = "8cbae416458565faac21d3452fbc6d80b324f6d3" }
dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "8cbae416458565faac21d3452fbc6d80b324f6d3" }
dashcore = { git = "https://github.com/dashpay/rust-dashcore", rev = "08ade6e8043ff376bd253c9566b927154ca8a455" }
dash-spv = { git = "https://github.com/dashpay/rust-dashcore", rev = "08ade6e8043ff376bd253c9566b927154ca8a455" }
dash-spv-ffi = { git = "https://github.com/dashpay/rust-dashcore", rev = "08ade6e8043ff376bd253c9566b927154ca8a455" }
key-wallet = { git = "https://github.com/dashpay/rust-dashcore", rev = "08ade6e8043ff376bd253c9566b927154ca8a455" }
dashcore-rpc = { git = "https://github.com/dashpay/rust-dashcore", rev = "08ade6e8043ff376bd253c9566b927154ca8a455" }

# Optimize heavy crypto crates even in dev/test builds so that
# Halo 2 proof generation and verification run at near-release speed.
Expand Down
5 changes: 1 addition & 4 deletions packages/rs-dpp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ chrono = { version = "0.4.35", default-features = false, features = [
chrono-tz = { version = "0.8", optional = true }
ciborium = { version = "0.2.2", optional = true }
dashcore = { workspace = true, features = [
"std",
"secp-recovery",
"rand",
"signer",
"serde",
"eddsa",
], default-features = false }
] }
key-wallet = { workspace = true, optional = true }
key-wallet-manager = { workspace = true, optional = true }
dash-spv = { workspace = true, optional = true }
dashcore-rpc = { workspace = true, optional = true }

Expand Down Expand Up @@ -94,7 +92,6 @@ core_quorum_validation = ["dashcore/quorum_validation"]
core_key_wallet = ["dep:key-wallet"]
core_key_wallet_bincode = ["dep:key-wallet", "key-wallet/bincode"]
core_key_wallet_bip_38 = ["dep:key-wallet", "key-wallet/bip38"]
core_key_wallet_manager = ["dep:key-wallet-manager"]
core_key_wallet_serde = ["dep:key-wallet", "key-wallet/serde"]
core_spv = ["dep:dash-spv"]
core_rpc_client = ["dep:dashcore-rpc"]
Expand Down
3 changes: 0 additions & 3 deletions packages/rs-dpp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ pub use dashcore;
#[cfg(feature = "core_key_wallet")]
pub use key_wallet;

#[cfg(feature = "core_key_wallet_manager")]
pub use key_wallet_manager;

#[cfg(feature = "core_spv")]
pub use dash_spv;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ mod tests {
collateral_address: [0; 20],
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::from_str("1.0.1.1:1234").unwrap(),
service: Some(SocketAddr::from_str("1.0.1.1:1234").unwrap()),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down Expand Up @@ -608,7 +608,7 @@ mod tests {
collateral_address: [0; 20],
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::from_str("1.0.1.1:1234").unwrap(),
service: Some(SocketAddr::from_str("1.0.1.1:1234").unwrap()),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down Expand Up @@ -668,7 +668,7 @@ mod tests {
collateral_address: [0; 20],
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::from_str("1.0.1.1:1234").unwrap(),
service: Some(SocketAddr::from_str("1.0.1.1:1234").unwrap()),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down Expand Up @@ -741,7 +741,7 @@ mod tests {
collateral_address: [0; 20],
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::from_str("1.0.1.1:1234").unwrap(),
service: Some(SocketAddr::from_str("1.0.1.1:1234").unwrap()),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down Expand Up @@ -818,7 +818,7 @@ mod tests {
collateral_address: [0; 20],
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::from_str("1.0.1.1:1234").unwrap(),
service: Some(SocketAddr::from_str("1.0.1.1:1234").unwrap()),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down Expand Up @@ -879,7 +879,7 @@ mod tests {
collateral_address: [0; 20],
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::from_str("1.0.1.1:1234").unwrap(),
service: Some(SocketAddr::from_str("1.0.1.1:1234").unwrap()),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down Expand Up @@ -967,7 +967,7 @@ mod tests {
collateral_address: [0; 20],
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::from_str("1.0.1.1:1234").unwrap(),
service: Some(SocketAddr::from_str("1.0.1.1:1234").unwrap()),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down Expand Up @@ -1097,7 +1097,7 @@ mod tests {
collateral_address: [0; 20],
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::from_str("1.0.1.1:1234").unwrap(),
service: Some(SocketAddr::from_str("1.0.1.1:1234").unwrap()),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down Expand Up @@ -1198,7 +1198,7 @@ mod tests {
collateral_address: [0; 20],
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::from_str("1.0.1.1:1234").unwrap(),
service: Some(SocketAddr::from_str("1.0.1.1:1234").unwrap()),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down Expand Up @@ -1259,7 +1259,7 @@ mod tests {
collateral_address: [0; 20],
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::from_str("1.0.1.1:1234").unwrap(),
service: Some(SocketAddr::from_str("1.0.1.1:1234").unwrap()),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ where
// the ban_height was changed
validator.is_banned = maybe_ban_height.is_some();
}
if let Some(address) = dmn_state_diff.service {
if let Some(Some(address)) = dmn_state_diff.service {
validator.node_ip = address.ip().to_string();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ pub(in crate::execution) mod tests {
collateral_address: rng.gen(),
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::new(IpAddr::V4(random_ip), 19999),
service: Some(SocketAddr::new(IpAddr::V4(random_ip), 19999)),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down Expand Up @@ -768,7 +768,7 @@ pub(in crate::execution) mod tests {
collateral_address: rng.gen(),
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::new(IpAddr::V4(random_ip), 19999),
service: Some(SocketAddr::new(IpAddr::V4(random_ip), 19999)),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl TryFromPlatformVersioned<MasternodeListItem> for Masternode {
platform_version: &PlatformVersion,
) -> Result<Self, Self::Error> {
match platform_version.drive_abci.structs.masternode {
0 => Ok(Self::V0(value.into())),
0 => Ok(Self::V0(value.try_into()?)),
version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch {
method: "Masternode::try_from_platform_versioned(MasternodeListItem)".to_string(),
known_versions: vec![0],
Expand Down
30 changes: 20 additions & 10 deletions packages/rs-drive-abci/src/platform_types/masternode/v0/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/// Accessors for Masternode
pub mod accessors;

use crate::error::execution::ExecutionError;
use crate::error::Error;
use dpp::bincode::{Decode, Encode};
use dpp::dashcore_rpc::dashcore_rpc_json::{DMNState, MasternodeType};
use dpp::dashcore_rpc::json::MasternodeListItem;
Expand Down Expand Up @@ -45,8 +47,10 @@ impl Debug for MasternodeV0 {
}
}

impl From<MasternodeListItem> for MasternodeV0 {
fn from(value: MasternodeListItem) -> Self {
impl TryFrom<MasternodeListItem> for MasternodeV0 {
type Error = Error;

fn try_from(value: MasternodeListItem) -> Result<Self, Self::Error> {
let MasternodeListItem {
node_type,
pro_tx_hash,
Expand All @@ -57,15 +61,15 @@ impl From<MasternodeListItem> for MasternodeV0 {
state,
} = value;

Self {
Ok(Self {
node_type,
pro_tx_hash,
collateral_hash,
collateral_index,
collateral_address,
operator_reward,
state: state.into(),
}
state: state.try_into()?,
})
}
}

Expand Down Expand Up @@ -137,8 +141,10 @@ pub struct MasternodeStateV0 {
pub platform_http_port: Option<u32>,
}

impl From<DMNState> for MasternodeStateV0 {
fn from(value: DMNState) -> Self {
impl TryFrom<DMNState> for MasternodeStateV0 {
type Error = Error;

fn try_from(value: DMNState) -> Result<Self, Self::Error> {
let DMNState {
service,
registered_height,
Expand All @@ -155,7 +161,11 @@ impl From<DMNState> for MasternodeStateV0 {
platform_http_port,
} = value;

Self {
let service = service.ok_or(Error::Execution(ExecutionError::CorruptedCodeExecution(
"masternode service address is required but was empty in core RPC response",
)))?;

Ok(Self {
service,
registered_height,
pose_revived_height,
Expand All @@ -169,7 +179,7 @@ impl From<DMNState> for MasternodeStateV0 {
platform_node_id,
platform_p2p_port,
platform_http_port,
}
})
}
}

Expand All @@ -192,7 +202,7 @@ impl From<MasternodeStateV0> for DMNState {
} = value;

Self {
service,
service: Some(service),
registered_height,
pose_revived_height,
pose_ban_height,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ impl NewValidatorIfMasternodeInState for ValidatorV0 {
return None;
};
let platform_node_id = (*platform_node_id)?;
let service_addr = (*service)?;
Some(ValidatorV0 {
pro_tx_hash,
public_key,
node_ip: service.ip().to_string(),
node_ip: service_addr.ip().to_string(),
node_id: PubkeyHash::from_byte_array(platform_node_id),
core_port: service.port(),
core_port: service_addr.port(),
platform_http_port: *platform_http_port as u16,
platform_p2p_port: *platform_p2p_port as u16,
is_banned: pose_ban_height.is_some(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ mod tests {
collateral_address: [0; 20],
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::from_str(format!("1.0.{}.{}:1234", i / 256, i % 256).as_str())
.unwrap(),
service: Some(
SocketAddr::from_str(format!("1.0.{}.{}:1234", i / 256, i % 256).as_str())
.unwrap(),
),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down
28 changes: 20 additions & 8 deletions packages/rs-drive-abci/tests/strategy_tests/masternodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,10 @@ pub fn generate_test_masternodes(
collateral_address: [0; 20],
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::from_str(format!("1.0.{}.{}:1234", i / 256, i % 256).as_str())
.unwrap(),
service: Some(
SocketAddr::from_str(format!("1.0.{}.{}:1234", i / 256, i % 256).as_str())
.unwrap(),
),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down Expand Up @@ -348,9 +350,13 @@ pub fn generate_test_masternodes(
rng.gen_range(0..255),
rng.gen_range(0..255),
);
let old_port = masternode_list_item_b.state.service.port();
let old_port = masternode_list_item_b
.state
.service
.map(|s| s.port())
.unwrap_or(0);
masternode_list_item_b.state.service =
SocketAddr::new(IpAddr::V4(random_ip), old_port);
Some(SocketAddr::new(IpAddr::V4(random_ip), old_port));
}

latest_masternode_list_item = masternode_list_item_b.clone();
Expand Down Expand Up @@ -384,8 +390,10 @@ pub fn generate_test_masternodes(
collateral_address: [0; 20],
operator_reward: 0.0,
state: DMNState {
service: SocketAddr::from_str(format!("1.1.{}.{}:1234", i / 256, i % 256).as_str())
.unwrap(),
service: Some(
SocketAddr::from_str(format!("1.1.{}.{}:1234", i / 256, i % 256).as_str())
.unwrap(),
),
registered_height: 0,
pose_revived_height: None,
pose_ban_height: None,
Expand Down Expand Up @@ -525,9 +533,13 @@ pub fn generate_test_masternodes(
rng.gen_range(0..255),
rng.gen_range(0..255),
);
let old_port = hpmn_list_item_b.state.service.port();
let old_port = hpmn_list_item_b
.state
.service
.map(|s| s.port())
.unwrap_or(0);
hpmn_list_item_b.state.service =
SocketAddr::new(IpAddr::V4(random_ip), old_port);
Some(SocketAddr::new(IpAddr::V4(random_ip), old_port));
}
if update.p2p_port {
if let Some(port) = hpmn_list_item_b.state.platform_p2p_port.as_mut() {
Expand Down
3 changes: 1 addition & 2 deletions packages/rs-platform-wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ platform-encryption = { path = "../rs-platform-encryption" }

# Key wallet dependencies (from rust-dashcore)
key-wallet = { workspace = true }
key-wallet-manager = { workspace = true, optional = true }

# Core dependencies
dashcore = { workspace = true }
Expand All @@ -34,4 +33,4 @@ rand = "0.8"
default = ["bls", "eddsa", "manager"]
bls = ["key-wallet/bls"]
eddsa = ["key-wallet/eddsa"]
manager = ["key-wallet-manager"]
manager = []
6 changes: 3 additions & 3 deletions packages/rs-platform-wallet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This allows applications to manage both Layer 1 (blockchain) and Layer 2 (Platfo

```rust
use platform_wallet::PlatformWalletInfo;
use key_wallet_manager::wallet_manager::WalletManager;
use key_wallet::manager::WalletManager;
use key_wallet::wallet::managed_wallet_info::wallet_info_interface::WalletInfoInterface;
use dpp::prelude::Identifier;

Expand Down Expand Up @@ -105,12 +105,12 @@ The package is structured as follows:
### Compatibility
- Works with `WalletManager<PlatformWalletInfo>` for standard wallet management
- Works with `SPVWalletManager<PlatformWalletInfo>` for SPV/light client functionality
- Fully compatible with existing `key-wallet-manager` infrastructure
- Fully compatible with existing `key-wallet::manager` infrastructure

## Dependencies

- `key-wallet`: Core wallet functionality
- `key-wallet-manager`: Wallet management and SPV support
- `key-wallet::manager`: Wallet management and SPV support (merged into key-wallet)
- `dpp`: Dash Platform Protocol types and identity definitions
- `dashcore`: Core blockchain types

Expand Down
2 changes: 1 addition & 1 deletion packages/rs-platform-wallet/examples/basic_usage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() -> Result<(), PlatformWalletError> {
// The platform wallet can be used with WalletManager (requires "manager" feature)
#[cfg(feature = "manager")]
{
use key_wallet_manager::wallet_manager::WalletManager;
use key_wallet::manager::WalletManager;

let _wallet_manager = WalletManager::<PlatformWalletInfo>::new(network);
println!("Platform wallet successfully integrated with wallet managers!");
Expand Down
Loading
Loading