Skip to content

Commit

Permalink
feat: system data contracts should not have an owner
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Jul 23, 2024
1 parent 2facc4d commit 26d80a5
Show file tree
Hide file tree
Showing 19 changed files with 156 additions and 825 deletions.
5 changes: 1 addition & 4 deletions packages/dashpay-contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ pub const ID_BYTES: [u8; 32] = [
44, 24, 16, 146, 129, 193, 70, 231, 178, 113, 188,
];

pub const OWNER_ID_BYTES: [u8; 32] = [
65, 63, 57, 243, 204, 9, 106, 71, 187, 2, 94, 221, 190, 127, 141, 114, 137, 209, 243, 50, 60,
215, 90, 101, 229, 15, 115, 5, 44, 117, 182, 217,
];
pub const OWNER_ID_BYTES: [u8; 32] = [0; 32];

pub const ID: Identifier = Identifier(IdentifierBytes32(ID_BYTES));
pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES));
Expand Down
5 changes: 1 addition & 4 deletions packages/dpns-contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ pub const ID_BYTES: [u8; 32] = [
196, 13, 87, 33, 246, 34, 191, 83, 197, 49, 85,
];

pub const OWNER_ID_BYTES: [u8; 32] = [
48, 18, 193, 155, 152, 236, 0, 51, 173, 219, 54, 205, 100, 183, 245, 16, 103, 15, 42, 53, 26,
67, 4, 181, 246, 153, 65, 68, 40, 110, 253, 172,
];
pub const OWNER_ID_BYTES: [u8; 32] = [0; 32];

pub const ID: Identifier = Identifier(IdentifierBytes32(ID_BYTES));
pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES));
Expand Down
5 changes: 1 addition & 4 deletions packages/feature-flags-contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ pub const ID_BYTES: [u8; 32] = [
212, 255, 2, 91, 7, 90, 243, 68, 55, 152, 34,
];

pub const OWNER_ID_BYTES: [u8; 32] = [
240, 1, 0, 176, 193, 227, 118, 43, 139, 193, 66, 30, 17, 60, 118, 178, 166, 53, 197, 147, 11,
154, 191, 43, 51, 101, 131, 190, 89, 135, 167, 21,
];
pub const OWNER_ID_BYTES: [u8; 32] = [0; 32];

pub const ID: Identifier = Identifier(IdentifierBytes32(ID_BYTES));
pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES));
Expand Down
5 changes: 1 addition & 4 deletions packages/masternode-reward-shares-contract/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ pub const ID_BYTES: [u8; 32] = [
68, 99, 238, 176, 31, 247, 33, 149, 144, 149, 140,
];

pub const OWNER_ID_BYTES: [u8; 32] = [
159, 101, 165, 10, 103, 89, 107, 118, 134, 35, 62, 205, 14, 245, 130, 168, 86, 190, 41, 247,
139, 113, 170, 202, 91, 69, 135, 242, 242, 219, 97, 152,
];
pub const OWNER_ID_BYTES: [u8; 32] = [0; 32];

pub const ID: Identifier = Identifier(IdentifierBytes32(ID_BYTES));
pub const OWNER_ID: Identifier = Identifier(IdentifierBytes32(OWNER_ID_BYTES));
Expand Down
95 changes: 0 additions & 95 deletions packages/rs-drive-abci/src/abci/config.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
//! Configuration of ABCI Application server
use rand::prelude::StdRng;
use rand::SeedableRng;

use dpp::identity::KeyType::ECDSA_SECP256K1;
use dpp::version::PlatformVersion;
use dpp::ProtocolError;
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

// We allow changes in the ABCI configuration, but there should be a social process
// involved in making this change.
Expand All @@ -23,10 +16,6 @@ pub struct AbciConfig {
#[serde(rename = "abci_consensus_bind_address")]
pub consensus_bind_address: String,

/// Public keys used for system identity
#[serde(flatten)]
pub keys: Keys,

/// Height of genesis block; defaults to 1
#[serde(default = "AbciConfig::default_genesis_height")]
pub genesis_height: u64,
Expand Down Expand Up @@ -59,94 +48,10 @@ impl Default for AbciConfig {
fn default() -> Self {
Self {
consensus_bind_address: "tcp://127.0.0.1:1234".to_string(),
keys: Keys::new_random_keys_with_seed(18012014, PlatformVersion::first())
.expect("random keys for first version can not error"), //Dash genesis day
genesis_height: AbciConfig::default_genesis_height(),
genesis_core_height: AbciConfig::default_genesis_core_height(),
chain_id: "chain_id".to_string(),
log: Default::default(),
}
}
}

// @append_only
/// Struct to easily load from environment keys used by the Platform.
///
/// Once loaded, Keys can be easily converted to [SystemIdentityPublicKeys]
///
/// [SystemIdentityPublicKeys]: super::messages::SystemIdentityPublicKeys
#[serde_as]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Keys {
// dpns contract
/// hex-encoded
#[serde_as(as = "serde_with::hex::Hex")]
pub(crate) dpns_master_public_key: Vec<u8>,
/// hex-encoded
#[serde_as(as = "serde_with::hex::Hex")]
pub(crate) dpns_second_public_key: Vec<u8>,

// dashpay contract
/// hex-encoded
#[serde_as(as = "serde_with::hex::Hex")]
pub(crate) dashpay_master_public_key: Vec<u8>,
/// hex-encoded
#[serde_as(as = "serde_with::hex::Hex")]
pub(crate) dashpay_second_public_key: Vec<u8>,

// feature flags contract
/// hex-encoded
#[serde_as(as = "serde_with::hex::Hex")]
pub(crate) feature_flags_master_public_key: Vec<u8>,
/// hex-encoded
#[serde_as(as = "serde_with::hex::Hex")]
pub(crate) feature_flags_second_public_key: Vec<u8>,

// masternode reward shares contract
/// hex-encoded
#[serde_as(as = "serde_with::hex::Hex")]
pub(crate) masternode_reward_shares_master_public_key: Vec<u8>,
/// hex-encoded
#[serde_as(as = "serde_with::hex::Hex")]
pub(crate) masternode_reward_shares_second_public_key: Vec<u8>,

// withdrawals contract
/// hex-encoded
#[serde_as(as = "serde_with::hex::Hex")]
pub(crate) withdrawals_master_public_key: Vec<u8>,
/// hex-encoded
#[serde_as(as = "serde_with::hex::Hex")]
pub(crate) withdrawals_second_public_key: Vec<u8>,
}

impl Keys {
/// Create new random keys for a given seed
pub fn new_random_keys_with_seed(
seed: u64,
platform_version: &PlatformVersion,
) -> Result<Self, ProtocolError> {
let mut rng = StdRng::seed_from_u64(seed);
Ok(Keys {
dpns_master_public_key: ECDSA_SECP256K1
.random_public_key_data(&mut rng, platform_version)?,
dpns_second_public_key: ECDSA_SECP256K1
.random_public_key_data(&mut rng, platform_version)?,
dashpay_master_public_key: ECDSA_SECP256K1
.random_public_key_data(&mut rng, platform_version)?,
dashpay_second_public_key: ECDSA_SECP256K1
.random_public_key_data(&mut rng, platform_version)?,
feature_flags_master_public_key: ECDSA_SECP256K1
.random_public_key_data(&mut rng, platform_version)?,
feature_flags_second_public_key: ECDSA_SECP256K1
.random_public_key_data(&mut rng, platform_version)?,
masternode_reward_shares_master_public_key: ECDSA_SECP256K1
.random_public_key_data(&mut rng, platform_version)?,
masternode_reward_shares_second_public_key: ECDSA_SECP256K1
.random_public_key_data(&mut rng, platform_version)?,
withdrawals_master_public_key: ECDSA_SECP256K1
.random_public_key_data(&mut rng, platform_version)?,
withdrawals_second_public_key: ECDSA_SECP256K1
.random_public_key_data(&mut rng, platform_version)?,
})
}
}
Loading

0 comments on commit 26d80a5

Please sign in to comment.