Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Tommytrg committed Oct 11, 2023
1 parent aca1520 commit b943c03
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 151 deletions.
10 changes: 0 additions & 10 deletions config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,6 @@ fn to_partial_consensus_constants(c: &ConsensusConstants) -> PartialConsensusCon
genesis_hash: Some(c.genesis_hash),
max_vt_weight: Some(c.max_vt_weight),
max_dr_weight: Some(c.max_dr_weight),
max_st_weight: Some(c.max_st_weight),
max_st_number: Some(c.max_st_number),
activity_period: Some(c.activity_period),
reputation_expire_alpha_diff: Some(c.reputation_expire_alpha_diff),
reputation_issuance: Some(c.reputation_issuance),
Expand Down Expand Up @@ -535,14 +533,6 @@ pub fn consensus_constants_from_partial(
.max_dr_weight
.to_owned()
.unwrap_or_else(|| defaults.consensus_constants_max_dr_weight()),
max_st_weight: config
.max_st_weight
.to_owned()
.unwrap_or_else(|| defaults.consensus_constants_max_st_weight()),
max_st_number: config
.max_st_number
.to_owned()
.unwrap_or_else(|| defaults.consensus_constants_max_st_number()),
activity_period: config
.activity_period
.to_owned()
Expand Down
8 changes: 0 additions & 8 deletions config/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,6 @@ pub trait Defaults {
80_000
}

fn consensus_constants_max_st_weight(&self) -> u32 {
10_000
}

fn consensus_constants_max_st_number(&self) -> u16 {
42
}

/// Default number of seconds before giving up waiting for requested blocks: `400`.
/// Sending 500 blocks should take less than 400 seconds.
fn connections_blocks_timeout(&self) -> i64 {
Expand Down
6 changes: 0 additions & 6 deletions data_structures/src/chain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,6 @@ pub struct ConsensusConstants {
pub max_vt_weight: u32,
/// Maximum aggregated weight of all the data requests transactions in one block
pub max_dr_weight: u32,
/// Maximum aggregated weight of all the stake transactions in one block
pub max_st_weight: u32,
// FIXME: we can't use u8 because the ProtoBuffConvert implementation for u8 is commented due to a conflict with vec[u8]
/// Maximum number of stake transactions in one block
pub max_st_number: u16,

/// An identity is considered active if it participated in the witnessing protocol at least once in the last `activity_period` epochs
pub activity_period: u32,
Expand Down Expand Up @@ -452,7 +447,6 @@ impl Block {
commit_txns: vec![],
reveal_txns: vec![],
tally_txns: vec![],
// TODO: can't init genesis with staked tx's
stake_txns: vec![],
};

Expand Down
25 changes: 14 additions & 11 deletions data_structures/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use failure::Fail;
use std::num::ParseIntError;

use crate::chain::{
DataRequestOutput, Epoch, Hash, HashParseError, OutputPointer, PublicKey, PublicKeyHash,
DataRequestOutput, Epoch, Hash, HashParseError, OutputPointer, PublicKeyHash,
RADType,
};

Expand Down Expand Up @@ -281,10 +281,19 @@ pub enum TransactionError {
},
/// Stake weight limit exceeded
#[fail(
display = "Stake weight ({}) exceeds the limit ({})",
weight, max_weight
display = "Stake ({}) doesn't reach the minimum amount ({})",
min_stake, stake
)]
MinStakeNotReached {
min_stake: u64,
stake: u64,
},
/// An stake output with zero value does not make sense
#[fail(
display = "Transaction {} has a zero value stake output",
tx_hash,
)]
StakeWeightLimitExceeded { weight: u32, max_weight: u32 },
ZeroValueStakeOutput{ tx_hash: Hash },
#[fail(
display = "The reward-to-collateral ratio for this data request is {}, but must be equal or less than {}",
reward_collateral_ratio, required_reward_collateral_ratio
Expand Down Expand Up @@ -414,13 +423,7 @@ pub enum BlockError {
weight, max_weight
)]
TotalStakeWeightLimitExceeded { weight: u32, max_weight: u32 },
/// Stake number limit exceeded
#[fail(
display = "Total number of Stake Transactions in a block ({}) exceeds the limit ({})",
stakes, max_stakes
)]
TotalStakeNumberLimitExceeded { stakes: usize, max_stakes: u16 },
/// Repeated operator Stake
/// Repeated operator Stake
#[fail(display = "A single operator is staking more than once: ({}) ", pkh)]
RepeatedStakeOperator { pkh: Hash },
/// Missing expected tallies
Expand Down
1 change: 0 additions & 1 deletion node/src/actors/chain_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,6 @@ impl ChainManager {
collateral_age,
chain_info.consensus_constants.max_vt_weight,
chain_info.consensus_constants.max_dr_weight,
chain_info.consensus_constants.max_st_weight,
chain_info.consensus_constants.minimum_difficulty,
required_reward_collateral_ratio,
&active_wips,
Expand Down
2 changes: 0 additions & 2 deletions node/tests/serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ fn chain_state() {
genesis_hash,
max_vt_weight: 0,
max_dr_weight: 0,
max_st_number: 0,
max_st_weight: 0,
activity_period: 0,
reputation_expire_alpha_diff: 0,
reputation_issuance: 0,
Expand Down
41 changes: 19 additions & 22 deletions schemas/witnet/witnet.proto
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ message MintTransaction {

message StakeOutput {
uint64 value = 1;
// TODO: should this field be repeated?
KeyedSignature authorization = 2;
}

Expand Down Expand Up @@ -332,27 +331,25 @@ message ConsensusConstants {
Hash genesis_hash = 4;
uint32 max_vt_weight = 5;
uint32 max_dr_weight = 6;
uint32 max_st_weight = 7;
uint32 max_st_number= 8;
uint32 activity_period = 9;
uint32 reputation_expire_alpha_diff = 10;
uint32 reputation_issuance = 11;
uint32 reputation_issuance_stop = 12;
double reputation_penalization_factor = 13;
uint32 mining_backup_factor = 14;
uint32 mining_replication_factor = 15;
uint64 collateral_minimum = 16;
uint32 collateral_age = 17;
uint32 superblock_period = 18;
uint32 extra_rounds = 19;
uint32 minimum_difficulty = 20;
uint32 epochs_with_minimum_difficulty = 21;
repeated string bootstrapping_committee = 22;
uint32 superblock_signing_committee_size = 23;
uint32 superblock_committee_decreasing_period = 24;
uint32 superblock_committee_decreasing_step = 25;
uint64 initial_block_reward = 26;
uint32 halving_period = 27;
uint32 activity_period = 7;
uint32 reputation_expire_alpha_diff = 8;
uint32 reputation_issuance = 9;
uint32 reputation_issuance_stop = 10;
double reputation_penalization_factor = 11;
uint32 mining_backup_factor = 12;
uint32 mining_replication_factor = 13;
uint64 collateral_minimum = 14;
uint32 collateral_age = 15;
uint32 superblock_period = 16;
uint32 extra_rounds = 17;
uint32 minimum_difficulty = 18;
uint32 epochs_with_minimum_difficulty = 19;
repeated string bootstrapping_committee = 20;
uint32 superblock_signing_committee_size = 21;
uint32 superblock_committee_decreasing_period = 22;
uint32 superblock_committee_decreasing_step = 23;
uint64 initial_block_reward = 24;
uint32 halving_period = 25;
}

message VrfProof {
Expand Down
34 changes: 1 addition & 33 deletions validations/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ mod witnessing;
static ONE_WIT: u64 = 1_000_000_000;
const MAX_VT_WEIGHT: u32 = 20_000;
const MAX_DR_WEIGHT: u32 = 80_000;
const MAX_ST_WEIGHT: u32 = 10_000;
const MAX_ST_NUMBER: u16 = 42;

const REQUIRED_REWARD_COLLATERAL_RATIO: u64 =
PSEUDO_CONSENSUS_CONSTANTS_WIP0022_REWARD_COLLATERAL_RATIO;
Expand Down Expand Up @@ -9504,8 +9502,6 @@ fn test_block_with_drpool_and_utxo_set<F: FnMut(&mut Block) -> bool>(
reputation_issuance: 0,
reputation_issuance_stop: 0,
max_vt_weight: MAX_VT_WEIGHT,
max_st_number: 0,
max_st_weight: 0,
checkpoints_period: 0,
reputation_penalization_factor: 0.0,
mining_replication_factor: 0,
Expand Down Expand Up @@ -9780,8 +9776,6 @@ fn block_difficult_proof() {
bootstrap_hash: BOOTSTRAP_HASH.parse().unwrap(),
genesis_hash: GENESIS_BLOCK_HASH.parse().unwrap(),
max_dr_weight: MAX_DR_WEIGHT,
max_st_number: 0,
max_st_weight: 0,
activity_period: 0,
reputation_expire_alpha_diff: 0,
reputation_issuance: 0,
Expand Down Expand Up @@ -10458,8 +10452,6 @@ fn test_blocks(txns: Vec<(BlockTransactions, u64)>) -> Result<(), failure::Error
txns,
MAX_VT_WEIGHT,
MAX_DR_WEIGHT,
MAX_ST_WEIGHT,
MAX_ST_NUMBER,
GENESIS_BLOCK_HASH.parse().unwrap(),
)
}
Expand All @@ -10468,8 +10460,6 @@ fn test_blocks_with_limits(
txns: Vec<(BlockTransactions, u64)>,
max_vt_weight: u32,
max_dr_weight: u32,
max_st_weight: u32,
max_st_number: u16,
genesis_block_hash: Hash,
) -> Result<(), failure::Error> {
if txns.len() > 1 {
Expand All @@ -10493,8 +10483,6 @@ fn test_blocks_with_limits(
bootstrap_hash: BOOTSTRAP_HASH.parse().unwrap(),
genesis_hash: genesis_block_hash,
max_dr_weight,
max_st_number,
max_st_weight,
activity_period: 0,
reputation_expire_alpha_diff: 0,
reputation_issuance: 0,
Expand Down Expand Up @@ -11062,8 +11050,6 @@ fn genesis_block_after_not_bootstrap_hash() {
bootstrap_hash,
genesis_hash: b.hash(),
max_dr_weight: MAX_DR_WEIGHT,
max_st_weight: MAX_ST_WEIGHT,
max_st_number: MAX_ST_NUMBER,
activity_period: 0,
reputation_expire_alpha_diff: 0,
reputation_issuance: 0,
Expand Down Expand Up @@ -11143,8 +11129,6 @@ fn genesis_block_value_overflow() {
bootstrap_hash,
genesis_hash: b.hash(),
max_dr_weight: MAX_DR_WEIGHT,
max_st_number: MAX_ST_NUMBER,
max_st_weight: MAX_ST_WEIGHT,
activity_period: 0,
reputation_expire_alpha_diff: 0,
reputation_issuance: 0,
Expand Down Expand Up @@ -11237,8 +11221,6 @@ fn genesis_block_full_validate() {
reputation_issuance: 0,
reputation_issuance_stop: 0,
max_vt_weight: MAX_VT_WEIGHT,
max_st_number: MAX_ST_NUMBER,
max_st_weight: MAX_ST_WEIGHT,
checkpoints_period: 0,
reputation_penalization_factor: 0.0,
mining_replication_factor: 0,
Expand Down Expand Up @@ -11300,8 +11282,6 @@ fn validate_block_transactions_uses_block_number_in_utxo_diff() {
superblock_period: 0,
genesis_hash: GENESIS_BLOCK_HASH.parse().unwrap(),
max_dr_weight: MAX_DR_WEIGHT,
max_st_number: 0,
max_st_weight: 0,
activity_period: 0,
reputation_expire_alpha_diff: 0,
reputation_issuance: 0,
Expand Down Expand Up @@ -11491,8 +11471,6 @@ fn validate_commit_transactions_included_in_utxo_diff() {
reputation_penalization_factor: 0.0,
mining_backup_factor: 0,
max_vt_weight: MAX_VT_WEIGHT,
max_st_number: MAX_ST_NUMBER,
max_st_weight: MAX_ST_WEIGHT,
bootstrap_hash: Default::default(),
mining_replication_factor: 0,
extra_rounds: 0,
Expand Down Expand Up @@ -11746,8 +11724,6 @@ fn validate_vt_weight_overflow() {
vec![t0],
2 * 493 - 1,
0,
0,
0,
GENESIS_BLOCK_HASH.parse().unwrap(),
);
assert_eq!(
Expand Down Expand Up @@ -11791,8 +11767,6 @@ fn validate_vt_weight_valid() {
vec![t0],
2 * 493,
0,
0,
0,
GENESIS_BLOCK_HASH.parse().unwrap(),
);
x.unwrap();
Expand Down Expand Up @@ -11930,7 +11904,7 @@ fn validate_vt_weight_genesis_valid() {
1_000_000 - 10,
)
};
let x = test_blocks_with_limits(vec![t0], 0, 0, 0, 0, new_genesis.parse().unwrap());
let x = test_blocks_with_limits(vec![t0], 0, 0, new_genesis.parse().unwrap());
x.unwrap();
}

Expand Down Expand Up @@ -11965,8 +11939,6 @@ fn validate_dr_weight_overflow() {
vec![t0],
0,
2 * 1589 - 1,
0,
0,
GENESIS_BLOCK_HASH.parse().unwrap(),
);
assert_eq!(
Expand Down Expand Up @@ -12005,8 +11977,6 @@ fn validate_dr_weight_overflow_126_witnesses() {
vec![t0],
0,
MAX_DR_WEIGHT,
0,
0,
GENESIS_BLOCK_HASH.parse().unwrap(),
);
assert_eq!(
Expand Down Expand Up @@ -12050,8 +12020,6 @@ fn validate_dr_weight_valid() {
vec![t0],
0,
2 * 1605,
0,
0,
GENESIS_BLOCK_HASH.parse().unwrap(),
);
x.unwrap();
Expand Down
Loading

0 comments on commit b943c03

Please sign in to comment.