Skip to content

Commit

Permalink
[move] reduce thresholds on validators (#1152)
Browse files Browse the repository at this point in the history
* Move vouch constant to Globals, reduce to 2 vouchers per validator

* move validator signing threshold to Globals, and reduce from 5% to 3%

* patch testing defaults
  • Loading branch information
0o-de-lally authored Aug 11, 2022
1 parent 4aef437 commit 689cb94
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
16 changes: 16 additions & 0 deletions language/diem-framework/modules/0L/Globals.move
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ module Globals {
epoch_mining_thres_upper: u64,
epoch_slow_wallet_unlock: u64,
min_blocks_per_epoch: u64,
vouch_threshold: u64,
signing_threshold_pct: u64,
}

const COIN_SCALING_FACTOR: u64 = 1000000;
Expand Down Expand Up @@ -89,7 +91,15 @@ module Globals {
get_constants().min_blocks_per_epoch
}

/// Get the threshold for unrelated vouchers per validator
public fun get_vouch_threshold(): u64 {
get_constants().vouch_threshold
}

/// Get the threshold of number of signed blocks in an epoch per validator
public fun get_signing_threshold(): u64 {
get_constants().signing_threshold_pct
}

/// Get the constants for the current network
fun get_constants(): GlobalConstants {
Expand All @@ -107,6 +117,8 @@ module Globals {
epoch_mining_thres_upper: 1000, // upper bound unlimited
epoch_slow_wallet_unlock: 10,
min_blocks_per_epoch: 0,
vouch_threshold: 0,
signing_threshold_pct: 3,
}
};

Expand All @@ -121,6 +133,8 @@ module Globals {
epoch_mining_thres_upper: 72, // upper bound enforced at 20 mins per proof.
epoch_slow_wallet_unlock: 10000000,
min_blocks_per_epoch: 1000,
vouch_threshold: 0,
signing_threshold_pct: 3,
}
} else {
return GlobalConstants {
Expand All @@ -138,6 +152,8 @@ module Globals {
epoch_mining_thres_upper: 72, // upper bound enforced at 20 mins per proof.
epoch_slow_wallet_unlock: 1000 * COIN_SCALING_FACTOR, // approx 10 years for largest accounts in genesis.
min_blocks_per_epoch: 10000,
vouch_threshold: 2, // Production is 2 vouchers per validator
signing_threshold_pct: 3,
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions language/diem-framework/modules/0L/Stats.move
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ module Stats{
use 0x1::FixedPoint32;
use 0x1::Signer;
use 0x1::Testnet;
use 0x1::Vector;
use 0x1::Vector;
use 0x1::Globals;

// TODO: yes we know this slows down block production. In "make it fast" mode this will be moved to Rust, in the vm execution block prologue. TBD.

Expand Down Expand Up @@ -113,7 +114,10 @@ module Stats{
assert(sender == CoreAddresses::DIEM_ROOT_ADDRESS(), Errors::requires_role(190006));
let range = height_end-height_start;
// TODO: Change to 5 percent
let threshold_signing = FixedPoint32::multiply_u64(range, FixedPoint32::create_from_rational(5, 100));
let threshold_signing = FixedPoint32::multiply_u64(
range,
FixedPoint32::create_from_rational(Globals::get_signing_threshold(), 100)
);
if (node_current_votes(vm, node_addr) > threshold_signing) { return true };
return false
}
Expand Down
9 changes: 2 additions & 7 deletions language/diem-framework/modules/0L/Vouch.move
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ address 0x1 {
use 0x1::ValidatorUniverse;
use 0x1::DiemSystem;
use 0x1::Ancestry;
use 0x1::Testnet;
use 0x1::StagingNet;
use 0x1::CoreAddresses;
use 0x1::Globals;

// triggered once per epoch
struct Vouch has key {
Expand Down Expand Up @@ -145,15 +144,11 @@ address 0x1 {
}

public fun unrelated_buddies_above_thresh(val: address): bool acquires Vouch{
if (Testnet::is_testnet() || StagingNet::is_staging_net()) {
return true
};

if (!exists<Vouch>(val)) return false;

let len = Vector::length(&unrelated_buddies(val));

(len >= 4) // TODO: move to Globals
(len >= Globals::get_vouch_threshold())
}
}
}

0 comments on commit 689cb94

Please sign in to comment.