Skip to content

Commit

Permalink
[fix] clean staging environment (#178)
Browse files Browse the repository at this point in the history
Co-authored-by: 0o-de-lally <1364012+0o-de-lally@users.noreply.github.com>
  • Loading branch information
0xzoz and 0o-de-lally authored Feb 15, 2024
1 parent 6789fc0 commit 270c8b8
Show file tree
Hide file tree
Showing 20 changed files with 11,625 additions and 11,672 deletions.
8 changes: 6 additions & 2 deletions framework/libra-framework/sources/block.move
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,12 @@ module diem_framework::block {
return
};

if (timestamp - reconfiguration::last_reconfiguration_time() >= block_metadata_ref.epoch_interval) {
if (!features::epoch_trigger_enabled() || testnet::is_not_mainnet()) {
if (timestamp - reconfiguration::last_reconfiguration_time() >=
block_metadata_ref.epoch_interval) {
// do automatic epochs in testnet.
// in main or stage, check if the feature flag is enabled for
// manual epochs
if (!features::epoch_trigger_enabled() || testnet::is_testnet()) {
epoch_boundary::epoch_boundary(
vm,
reconfiguration::get_current_epoch(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ module diem_framework::genesis {
let sig = create_signer(validator.validator_config.owner_address);
proof_of_fee::set_bid(&sig, 0900, 1000); // make the genesis

if (testnet::is_not_mainnet()) {
if (testnet::is_testnet()) {
// TODO: this is for testnet purposes only
// unlock some of the genesis validators coins so they can issue
// transactions from epoch 0 in test runners.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ module diem_framework::epoch_boundary {
/// by a user, would not cause a halt.
public(friend) fun trigger_epoch(framework_signer: &signer) acquires BoundaryBit,
BoundaryStatus {
// must be mainnet
assert!(!testnet::is_not_mainnet(), ETRIGGER_EPOCH_MAINNET);
// must be mainnet or stage
assert!(!testnet::is_testnet(), ETRIGGER_EPOCH_MAINNET);
// must get root permission from governance.move
system_addresses::assert_ol(framework_signer);
let _ = can_trigger(); // will abort if false
Expand Down
84 changes: 37 additions & 47 deletions framework/libra-framework/sources/ol_sources/globals.move
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ module ol_framework::globals {
struct GlobalConstants has drop {
// For validator set.
epoch_length: u64,
val_set_at_genesis: u64,
subsidy_ceiling_gas: u64,
val_set_at_genesis: u64,// deprecated?
subsidy_ceiling_gas: u64, // deprecated?
vdf_difficulty_baseline: u64,
vdf_security_baseline: u64,
epoch_mining_thres_lower: u64,
epoch_mining_thres_upper: u64,
epoch_slow_wallet_unlock: u64,
min_blocks_per_epoch: u64,
min_blocks_per_epoch: u64, // deprecated?
validator_vouch_threshold: u64,
signing_threshold_pct: u64,
}
Expand Down Expand Up @@ -95,32 +95,9 @@ module ol_framework::globals {
get_constants().signing_threshold_pct
}

/// Get the constants for the current network
fun get_constants(): GlobalConstants {

if (testnet::is_testnet()) {
return GlobalConstants {
epoch_length: 60, // seconds
val_set_at_genesis: 10,
subsidy_ceiling_gas: 296 * get_coin_scaling_factor(),
vdf_difficulty_baseline: 100,
vdf_security_baseline: 512,
epoch_mining_thres_lower: 2, // many tests depend on two proofs because
// the test harness already gives one at
// genesis to validators
epoch_mining_thres_upper: 1000, // upper bound unlimited
epoch_slow_wallet_unlock: 10,
min_blocks_per_epoch: 0,
validator_vouch_threshold: 0,
signing_threshold_pct: 3,
}
};

if (testnet::is_staging_net()) {
// All numbers like MAINNET except shorter epochs of 30 mins
// and minimum mining of 1 proof
fun get_mainnet(): GlobalConstants {
return GlobalConstants {
epoch_length: 60 * 30, // 30 mins, enough for a hard miner proof.
epoch_length: 60 * 60 * 24, // approx 24 hours
val_set_at_genesis: 100, // max expected for BFT limits.
// See DiemVMConfig for gas constants:
// Target max gas units per transaction 100000000
Expand All @@ -131,33 +108,46 @@ module ol_framework::globals {
vdf_difficulty_baseline: 120000000, // wesolowski proof, new parameters. Benchmark available in docs/delay_tower/benchmarking
vdf_security_baseline: 512,
// NOTE Reviewers: this goes back to v5 params since the VDF cryptograpy will actually not be changed
epoch_mining_thres_lower: 1, // lower bound, allows for some operator error
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: 2, // Production must be more than 1 vouch validator (at least 2)
signing_threshold_pct: 3,
}
} else {
}

fun get_testnet(): GlobalConstants {
return GlobalConstants {
epoch_length: 60 * 60 * 24, // approx 24 hours at 1.4 vdf_proofs/sec
val_set_at_genesis: 100, // max expected for BFT limits.
// See DiemVMConfig for gas constants:
// Target max gas units per transaction 100000000
// target max block time: 2 secs
// target transaction per sec max gas: 20
// uses "scaled representation", since there are no decimals.
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
epoch_length: 60, // seconds
val_set_at_genesis: 10,
subsidy_ceiling_gas: 296 * get_coin_scaling_factor(),
vdf_difficulty_baseline: 100,
vdf_security_baseline: 512,
// 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: 2, // Production must be more than 1 vouch validator (at least 2)
epoch_mining_thres_lower: 2, // many tests depend on two proofs because
// the test harness already gives one at
// genesis to validators
epoch_mining_thres_upper: 1000, // upper bound unlimited
epoch_slow_wallet_unlock: 10,
min_blocks_per_epoch: 0,
validator_vouch_threshold: 0,
signing_threshold_pct: 3,
}
}
}
}

/// Get the constants for the current network
fun get_constants(): GlobalConstants {
if (testnet::is_testnet()) {
return get_testnet()
};
// staging net is for upgrade verification.
// we want check epoch boundary behavior without waiting 24h
if (testnet::is_staging_net()) {
let c = get_mainnet();
c.epoch_length = 60 * 15; // 15 mins
return c
};

get_mainnet()
}
}
7 changes: 3 additions & 4 deletions framework/libra-framework/sources/ol_sources/testnet.move
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ module ol_framework::testnet {
chain_id::get() == 4
}

public fun is_not_mainnet(): bool {
chain_id::get() != 1
}
//commit note: confusing is_not_mainnet

public fun assert_testnet(root: &signer): bool {
system_addresses::assert_ol(root);
Expand All @@ -27,7 +25,8 @@ module ol_framework::testnet {
}

public fun is_staging_net(): bool {
chain_id::get() == 2 // TESTNET named chain
// NOTE: confusingly in vendor's rust code chain=2 is called TESTNET
chain_id::get() == 2
}

#[test_only]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ module ol_framework::test_boundary {
use ol_framework::testnet;
use ol_framework::validator_universe;
use ol_framework::epoch_boundary;
use ol_framework::block;
use ol_framework::block;
use ol_framework::ol_account;
use diem_framework::stake;
use diem_framework::reconfiguration;
use diem_framework::timestamp;
use diem_framework::diem_governance;

// use diem_std::debug::print;

const Alice: address = @0x1000a;
Expand Down Expand Up @@ -219,14 +219,14 @@ module ol_framework::test_boundary {
// testing mainnet, so change the chainid
testnet::unset(root);

//verify trigger is not enabled
//verify trigger is not enabled
assert!(!features::epoch_trigger_enabled(), 101);

// test setup advances to epoch #2
let epoch = reconfiguration::get_current_epoch();
assert!(epoch == 2, 7357001);
epoch_boundary::test_set_boundary_ready(root, epoch);


// case: trigger not set and flipped
timestamp::fast_forward_seconds(1); // needed for reconfig
Expand Down
34 changes: 2 additions & 32 deletions framework/libra-framework/sources/ol_sources/tower_state.move
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ module ol_framework::tower_state {
diff.prev_sec = diff.security; // NOTE: this shouldn't change unless in testing

// VDF proofs must be even numbers.
let rando = if (testnet::is_not_mainnet()) { toy_rng(0, 1, 0) }
let rando = if (testnet::is_testnet()) { toy_rng(0, 1, 0) }
else { toy_rng(3, 2, 10) };
if (rando > 0) {
rando = rando * 2;
Expand Down Expand Up @@ -585,7 +585,7 @@ module ol_framework::tower_state {
// pick the next miner
// make sure we get an n smaller than list of miners

// Current case: if miner_index = count_miners could lead to overflow
// Current case: if miner_index = count_miners could lead to overflow

// let k = 0; // k keeps track of this loop, abort if loops too much
// while (this_miner_index >= count_miners) {
Expand Down Expand Up @@ -678,36 +678,6 @@ module ol_framework::tower_state {
};
}

// // Returns if the miner is above the account creation rate-limit
// // Permissions: PUBLIC, ANYONE
// public fun can_create_val_account(node_addr: address): bool acquires TowerProofHistory {
// if(testnet::is_testnet() || testnet::is_staging_net()) return true;
// // check if rate limited, needs 7 epochs of validating.
// if (exists<TowerProofHistory>(node_addr)) {
// return
// borrow_global<TowerProofHistory>(node_addr).epochs_since_last_account_creation
// >= EPOCHS_UNTIL_ACCOUNT_CREATION
// };
// false
// }

// #[view]
// ///
// public fun get_validator_proofs_in_epoch(): u64 acquires TowerCounter{
// let state = borrow_global<TowerCounter>(@ol_framework);
// state.validator_proofs_in_epoch
// }

// public fun get_fullnode_proofs_in_epoch(): u64 acquires TowerCounter{
// let state = borrow_global<TowerCounter>(@ol_framework);
// state.fullnode_proofs_in_epoch
// }

// public fun get_fullnode_proofs_in_epoch_above_thresh(): u64 acquires TowerCounter{
// let state = borrow_global<TowerCounter>(@ol_framework);
// state.fullnode_proofs_in_epoch_above_thresh
// }

#[view]
/// number of proof submitted over lifetime of chain
public fun get_lifetime_proof_count(): u64 acquires TowerCounter{
Expand Down
Binary file modified framework/releases/head.mrb
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
fa42905a0cc3e72f263deba3a3397cf773260d0274d2ffb4f904d2bb60b823ec
614568d14fabba0e8833d4bb974f57e6871b948ebd997082542afbd5b47c0bae
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Upgrade proposal for package `MoveStdlib`

// Framework commit hash: aa95b5827cb4ce38db81ece0e7789dafde9dc39b
// Framework commit hash: 085a0ee874652bbf3bd2e2d624acb8919fc6de9b
// Builder commit hash: db1137ba1f8e7301e325021f71f740063daaf76e

// Next step script hash: 7852564d22179f6b34d005a5df30ddb5edea85b4772f6b45eced454c715cc104
// Next step script hash: 04d4bac5e6e84c346adcc2e5bbdb870b956cebdf68f3d7531c5edf4c40ff3a3c

// source digest: CD5C8655F0340314CC68657DF89A58E257A0A88218E2B07A278A20B843E7A09E
script {
Expand All @@ -17,7 +17,7 @@ script {
let framework_signer = diem_governance::resolve_multi_step_proposal(
proposal_id,
@0000000000000000000000000000000000000000000000000000000000000001,
vector[120u8,82u8,86u8,77u8,34u8,23u8,159u8,107u8,52u8,208u8,5u8,165u8,223u8,48u8,221u8,181u8,237u8,234u8,133u8,180u8,119u8,47u8,107u8,69u8,236u8,237u8,69u8,76u8,113u8,92u8,193u8,4u8,],
vector[4u8,212u8,186u8,197u8,230u8,232u8,76u8,52u8,106u8,220u8,194u8,229u8,187u8,219u8,135u8,11u8,149u8,108u8,235u8,223u8,104u8,243u8,215u8,83u8,28u8,94u8,223u8,76u8,64u8,255u8,58u8,60u8,],
);
let code = vector::empty();
let code_chunk0 =
Expand Down Expand Up @@ -1545,6 +1545,6 @@ script {
13u8,0u8,0u8,0u8,0u8,0u8,0u8,
];
code::publish_package_txn(&framework_signer, metadata_chunk1, code);
version::upgrade_set_git(&framework_signer, x"aa95b5827cb4ce38db81ece0e7789dafde9dc39b")
version::upgrade_set_git(&framework_signer, x"085a0ee874652bbf3bd2e2d624acb8919fc6de9b")
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7852564d22179f6b34d005a5df30ddb5edea85b4772f6b45eced454c715cc104
04d4bac5e6e84c346adcc2e5bbdb870b956cebdf68f3d7531c5edf4c40ff3a3c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Upgrade proposal for package `VendorStdlib`

// Framework commit hash: aa95b5827cb4ce38db81ece0e7789dafde9dc39b
// Framework commit hash: 085a0ee874652bbf3bd2e2d624acb8919fc6de9b
// Builder commit hash: db1137ba1f8e7301e325021f71f740063daaf76e

// Next step script hash: 3f3bef41f1e0ffc7668106f2193f8f0adb8aa05dfc3f231f40cd1d701611d120
// Next step script hash: af5b56589547200439dd37eecee660a076b4e6f64b161589057a09af4847ab3b

// source digest: 5E12DDD8987B153D75378183FB77218A1FAB6038899EB9121ECD4BE94EC1D598
script {
Expand All @@ -17,7 +17,7 @@ script {
let framework_signer = diem_governance::resolve_multi_step_proposal(
proposal_id,
@0000000000000000000000000000000000000000000000000000000000000001,
vector[63u8,59u8,239u8,65u8,241u8,224u8,255u8,199u8,102u8,129u8,6u8,242u8,25u8,63u8,143u8,10u8,219u8,138u8,160u8,93u8,252u8,63u8,35u8,31u8,64u8,205u8,29u8,112u8,22u8,17u8,209u8,32u8,],
vector[175u8,91u8,86u8,88u8,149u8,71u8,32u8,4u8,57u8,221u8,55u8,238u8,206u8,230u8,96u8,160u8,118u8,180u8,230u8,246u8,75u8,22u8,21u8,137u8,5u8,122u8,9u8,175u8,72u8,71u8,171u8,59u8,],
);
let code = vector::empty();
let code_chunk0 =
Expand Down Expand Up @@ -7332,6 +7332,6 @@ script {
vector::append(&mut metadata_chunk1, metadata_chunk2);
vector::append(&mut metadata_chunk1, metadata_chunk3);
code::publish_package_txn(&framework_signer, metadata_chunk1, code);
version::upgrade_set_git(&framework_signer, x"aa95b5827cb4ce38db81ece0e7789dafde9dc39b")
version::upgrade_set_git(&framework_signer, x"085a0ee874652bbf3bd2e2d624acb8919fc6de9b")
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3f3bef41f1e0ffc7668106f2193f8f0adb8aa05dfc3f231f40cd1d701611d120
af5b56589547200439dd37eecee660a076b4e6f64b161589057a09af4847ab3b
Loading

0 comments on commit 270c8b8

Please sign in to comment.