Skip to content

Commit

Permalink
Merge pull request #2048 from dusk-network/minimum_stake
Browse files Browse the repository at this point in the history
execution-core: centralize `MINIMUM_STAKE`
  • Loading branch information
moCello authored Aug 5, 2024
2 parents 7343706 + 057ed7d commit fa4ebf1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions consensus/src/user/provisioners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use crate::user::sortition;
use crate::user::stake::Stake;
use execution_core::dusk;
use execution_core::stake::MINIMUM_STAKE;
use node_data::bls::{PublicKey, PublicKeyBytes};
use node_data::StepName;

Expand All @@ -16,8 +18,7 @@ use std::mem;

use super::committee::Committee;

pub const DUSK: u64 = 1_000_000_000;
const MINIMUM_STAKE: u64 = 1_000 * DUSK;
pub const DUSK: u64 = dusk(1.0);

#[derive(Clone, Debug)]
pub struct Provisioners {
Expand Down
5 changes: 1 addition & 4 deletions contracts/stake/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@

extern crate alloc;

use execution_core::{dusk, transfer::TRANSFER_CONTRACT, Dusk};
use execution_core::transfer::TRANSFER_CONTRACT;

mod state;
use state::StakeState;

/// The minimum amount of Dusk one can stake.
pub const MINIMUM_STAKE: Dusk = dusk(1_000.0);

static mut STATE: StakeState = StakeState::new();

// Transactions
Expand Down
2 changes: 1 addition & 1 deletion contracts/stake/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use execution_core::{
signatures::bls::PublicKey as BlsPublicKey,
stake::{
next_epoch, Stake, StakeAmount, StakeData, StakeEvent, Withdraw, EPOCH,
STAKE_CONTRACT, STAKE_WARNINGS,
MINIMUM_STAKE, STAKE_CONTRACT, STAKE_WARNINGS,
},
transfer::TRANSFER_CONTRACT,
};
Expand Down
5 changes: 5 additions & 0 deletions execution-core/src/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use crate::{
ContractId,
};

use crate::{dusk, Dusk};

/// ID of the genesis stake contract
pub const STAKE_CONTRACT: ContractId = crate::reserved(0x2);

Expand Down Expand Up @@ -188,6 +190,9 @@ pub struct StakeEvent {
pub receiver: Option<WithdrawReceiver>,
}

/// The minimum amount of Dusk one can stake.
pub const MINIMUM_STAKE: Dusk = dusk(1_000.0);

/// The representation of a public key's stake.
///
/// A user can stake for a particular `amount` larger in value than the
Expand Down
2 changes: 0 additions & 2 deletions rusk/src/lib/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ use rusk_abi::VM;

use crate::http::RuesEvent;

pub const MINIMUM_STAKE: Dusk = dusk(1000.0);

#[derive(Debug, Clone, Copy)]
pub struct RuskTip {
pub current: [u8; 32],
Expand Down
2 changes: 1 addition & 1 deletion rusk/tests/services/stake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use std::path::Path;
use std::sync::{Arc, RwLock};

use execution_core::stake::MINIMUM_STAKE;
use execution_core::{
dusk,
signatures::bls::PublicKey as BlsPublicKey,
Expand All @@ -15,7 +16,6 @@ use execution_core::{
};
use rand::prelude::*;
use rand::rngs::StdRng;
use rusk::node::MINIMUM_STAKE;
use rusk::{Result, Rusk};
use std::collections::HashMap;
use tempfile::tempdir;
Expand Down

0 comments on commit fa4ebf1

Please sign in to comment.