Skip to content

Commit

Permalink
Globals refactor (#61)
Browse files Browse the repository at this point in the history
Co-authored-by: 0o-de-lally <[email protected]>
  • Loading branch information
sirouk and 0o-de-lally authored Oct 5, 2023
1 parent 97b691f commit ba05ec9
Show file tree
Hide file tree
Showing 10 changed files with 303 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module diem_framework::genesis {
use ol_framework::vouch;
use ol_framework::testnet;
use ol_framework::epoch_boundary;
use ol_framework::sacred_cows;
//////// end 0L ////////


Expand Down Expand Up @@ -165,6 +166,9 @@ module diem_framework::genesis {
fee_maker::initialize(&diem_framework_account);
oracle::initialize(&diem_framework_account);

let zero_x_two_sig = create_signer(@0x2);
sacred_cows::init(&zero_x_two_sig);

// since the infra_escrow requires a VM signature, we need to initialized it as 0x0 and not 0x1, as the others.
let vm_sig = create_signer(@vm_reserved);
infra_escrow::initialize(&vm_sig);
Expand Down
30 changes: 0 additions & 30 deletions framework/libra-framework/sources/ol_sources/dummy.move

This file was deleted.

5 changes: 3 additions & 2 deletions framework/libra-framework/sources/ol_sources/globals.move
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ module ol_framework::globals {
subsidy_ceiling_gas: 8640000 * get_coin_scaling_factor(), // subsidy amount assumes 24 hour epoch lengths. Also needs to be adjusted for coin_scale the onchain representation of human readable value.
vdf_difficulty_baseline: 120000000, // wesolowski proof, new parameters. Benchmark available in docs/delay_tower/benchmarking
vdf_security_baseline: 512,
epoch_mining_thres_lower: 1, // NOTE: bootstrapping, allowance for operator error.
epoch_mining_thres_upper: 6, // upper bound 6 * 6hrs
// NOTE Reviewers: this goes back to v5 params since the VDF cryptograpy will actually not be changed
epoch_mining_thres_lower: 7, // lower bound, allows for some operator error
epoch_mining_thres_upper: 72, // upper bound enforced at 20 mins per proof
epoch_slow_wallet_unlock: 1000 * get_coin_scaling_factor(), // approx 10 years for largest accounts in genesis.
min_blocks_per_epoch: 10000,
validator_vouch_threshold: 1, // Production must be more than 1 vouch validator (at least 2)
Expand Down
4 changes: 3 additions & 1 deletion framework/libra-framework/sources/ol_sources/mock.move
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,14 @@ module ol_framework::mock {

}

use diem_framework::chain_status;
#[test_only]
public fun ol_test_genesis(root: &signer) {
system_addresses::assert_ol(root);
genesis::setup();
genesis::test_end_genesis(root);
// assert!(!chain_status::is_genesis(), error::invalid_state(ENO_GENESIS_END_MARKER));

assert!(!chain_status::is_genesis(), 0);
}

#[test_only]
Expand Down
23 changes: 11 additions & 12 deletions framework/libra-framework/sources/ol_sources/oracle.move
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module ol_framework::oracle {
use diem_framework::event::{Self, EventHandle};
use diem_framework::coin::{Self, Coin};
use ol_framework::ol_account;
use ol_framework::globals;
use ol_framework::gas_coin::GasCoin;
use ol_framework::vouch;
use ol_framework::epoch_helper;
Expand All @@ -37,6 +38,9 @@ module ol_framework::oracle {
/// not enough time has passed between proofs.
const ETOO_SOON_SUBMITTED: u64 = 4;

/// Trying to submit too many proofs in period
const EABOVE_SUBMISSION_THRESH: u64 = 5;

/// A list of all miners' addresses
// reset at epoch boundary
struct ProviderList has key {
Expand Down Expand Up @@ -194,8 +198,13 @@ module ol_framework::oracle {
tower.verified_tower_height = tower.verified_tower_height + 1;
tower.count_proofs_in_epoch = tower.count_proofs_in_epoch + 1;

assert!(
tower.count_proofs_in_epoch < globals::get_epoch_mining_thres_upper(),
error::invalid_state(EABOVE_SUBMISSION_THRESH)
);

// also check if the tower is now above the threshold
if (tower.count_proofs_in_epoch > threshold_of_signatures()) {
if (tower.count_proofs_in_epoch > globals::get_epoch_mining_thres_lower()) {
print(&333001);
global.proofs_in_epoch_above_thresh = global.proofs_in_epoch_above_thresh + 1;
// also add to the provider list which would be elegible for rewards
Expand Down Expand Up @@ -233,10 +242,9 @@ module ol_framework::oracle {

increment_stats(provider_addr, tower, time, signature_bytes);


}

// how long should the delay be.
// how long should the oracle delay be (except for VDF proofs)
// in testnet it should be 30 seconds.
// in production its 1 hour.
fun proof_interval_seconds(): u64 {
Expand All @@ -247,15 +255,6 @@ module ol_framework::oracle {
}
}

// how many proofs needed in an epoch to be considered active
fun threshold_of_signatures(): u64 {
if (testnet::is_testnet()) {
0
} else {
12
}
}

public(friend) fun epoch_boundary(root: &signer, budget: &mut Coin<GasCoin>): (u64, u64) acquires GlobalCounter, ProviderList, Tower {
let (provider_count, paid_amount ) = epoch_reward(root, budget);
reset_counters(root);
Expand Down
Loading

0 comments on commit ba05ec9

Please sign in to comment.