Skip to content

Commit

Permalink
Merge pull request #1264 from 0o-de-lally/recovery-ancestry-patch
Browse files Browse the repository at this point in the history
[Tools] Recovery ancestry patch
  • Loading branch information
sirouk authored Aug 31, 2023
2 parents 4da317f + 9e4b68c commit b0ce13c
Show file tree
Hide file tree
Showing 17 changed files with 508,548 additions and 303,711 deletions.
50 changes: 25 additions & 25 deletions diem-move/diem-framework/DPN/sources/0L/EpochBoundary.move
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module EpochBoundary {
use DiemFramework::DiemConfig;
use DiemFramework::DiemAccount;
use DiemFramework::Burn;
use DiemFramework::FullnodeSubsidy;
use DiemFramework::FullnodeSubsidy;
use DiemFramework::RecoveryMode;
use DiemFramework::Jail;
use DiemFramework::TransactionFee;
Expand Down Expand Up @@ -77,23 +77,23 @@ module EpochBoundary {
// Check compliance of nodes
let height_start = Epoch::get_timer_height_start();
// print(&800200);
let (outgoing_compliant_set, new_set_size) =
let (outgoing_compliant_set, new_set_size) =
MusicalChairs::stop_the_music(vm, height_start, height_now);

// print(&800300);

// get the total fees produced before we start spending them.
let total_fees = TransactionFee::get_fees_collected();
// Get the consensus reward established at the beginning of the epoch
// so we know what to pay people
let (reward, _, _) = ProofOfFee::get_consensus_reward();
let (reward, _, _) = ProofOfFee::get_consensus_reward();

// process the oracles first (previously the identiy reward)
process_fullnodes(vm, reward);
// print(&800400);

// print(&800500);

process_validators(vm, reward, &outgoing_compliant_set);
// print(&800600);

Expand Down Expand Up @@ -123,7 +123,7 @@ module EpochBoundary {

// trigger the thermostat if the reward needs to be adjusted
ProofOfFee::reward_thermostat(vm);
let (reward_budget, _, _) = ProofOfFee::get_consensus_reward();
let (reward_budget, _, _) = ProofOfFee::get_consensus_reward();

// fund the network fee address with the reward budget
InfraEscrow::epoch_boundary_collection(vm, reward_budget * Vector::length(&proposed_set));
Expand All @@ -149,9 +149,9 @@ module EpochBoundary {
k = k + 1;
continue
};
// TODO: this call is repeated in propose_new_set.
// Not sure if the performance hit at epoch boundary is worth the refactor.

// TODO: this call is repeated in propose_new_set.
// Not sure if the performance hit at epoch boundary is worth the refactor.
if (TowerState::node_above_thresh(addr)) {
let count = TowerState::get_count_above_thresh_in_epoch(addr);

Expand Down Expand Up @@ -197,7 +197,7 @@ module EpochBoundary {
let addr = *Vector::borrow(&all_previous_vals, i);

if (

// if they are compliant, remove the consecutive fail, otherwise jail
// V6 Note: audit functions are now all contained in
// ProofOfFee.move and exludes validators at auction time.
Expand All @@ -216,7 +216,7 @@ module EpochBoundary {
// print(&904);
}

fun propose_new_set(vm: &signer, outgoing_compliant_set: &vector<address>, n_musical_chairs: u64): vector<address>
fun propose_new_set(vm: &signer, outgoing_compliant_set: &vector<address>, n_musical_chairs: u64): vector<address>
{
let proposed_set = Vector::empty<address>();

Expand All @@ -237,27 +237,27 @@ module EpochBoundary {
};

//////// Failover Rules ////////
// If the cardinality of validator_set in the next epoch is less than 4,
// If the cardinality of validator_set in the next epoch is less than 4,
// if we are failing to qualify anyone. Pick top 1/2 of outgoing compliant validator set
// by proposals. They are probably online.
if (Vector::length<address>(&proposed_set) <= 3)
proposed_set =
if (Vector::length<address>(&proposed_set) <= 3)
proposed_set =
Stats::get_sorted_vals_by_props(vm, Vector::length<address>(outgoing_compliant_set) / 2);

// If still failing...in extreme case if we cannot qualify anyone.
// Don't change the validator set. we keep the same validator set.
// Don't change the validator set. we keep the same validator set.
if (Vector::length<address>(&proposed_set) <= 3)
proposed_set = DiemSystem::get_val_set_addr();
proposed_set = DiemSystem::get_val_set_addr();
// Patch for april incident. Make no changes to validator set.

// Usually an issue in staging network for QA only.
// This is very rare and theoretically impossible for network with
// at least 6 nodes and 6 rounds. If we reach an epoch boundary with
// at least 6 rounds, we would have at least 2/3rd of the validator
// set with at least 66% liveliness.
// This is very rare and theoretically impossible for network with
// at least 6 nodes and 6 rounds. If we reach an epoch boundary with
// at least 6 rounds, we would have at least 2/3rd of the validator
// set with at least 66% liveliness.
proposed_set
}

fun reset_counters(
vm: &signer,
proposed_set: &vector<address>,
Expand Down Expand Up @@ -289,7 +289,7 @@ module EpochBoundary {

TransactionFee::epoch_reset_fee_maker(vm);



// print(&800900107);

Expand All @@ -303,13 +303,13 @@ module EpochBoundary {

//////// TEST HELPERS ////////

public fun test_settle(vm: &signer, height_now: u64) {
public fun test_settle(vm: &signer, height_now: u64) {
CoreAddresses::assert_vm(vm);
Testnet::assert_testnet(vm);
epilogue_settle_accounts(vm, height_now);
}

public fun test_prepare(vm: &signer, outgoing: &vector<address>, set_size: u64) {
public fun test_prepare(vm: &signer, outgoing: &vector<address>, set_size: u64) {
CoreAddresses::assert_vm(vm);
Testnet::assert_testnet(vm);
prologue_prepare_and_fund_coming_epoch(vm, outgoing, set_size);
Expand Down
8 changes: 4 additions & 4 deletions diem-move/diem-framework/DPN/sources/TransactionFee.move
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module DiemFramework::TransactionFee {

// use DiemFramework::XUS::XUS; /////// 0L /////////
use DiemFramework::GAS::GAS; /////// 0L /////////
use DiemFramework::CoreAddresses;
use DiemFramework::CoreAddresses;
use DiemFramework::XDX;
use DiemFramework::Diem::{Self, Diem, Preburn};
use DiemFramework::Roles;
Expand Down Expand Up @@ -264,7 +264,7 @@ module DiemFramework::TransactionFee {
);

Diem::withdraw_all(&mut fees.balance)

}

/////// 0L /////////
Expand Down Expand Up @@ -298,7 +298,7 @@ module DiemFramework::TransactionFee {
lifetime: u64,
}

/// We need a list of who is producing fees this epoch.
/// We need a list of who is producing fees this epoch.
/// This lives on the VM address
struct EpochFeeMakerRegistry has key {
fee_makers: vector<address>,
Expand Down Expand Up @@ -362,7 +362,7 @@ module DiemFramework::TransactionFee {
}

//////// GETTERS ///////

// get list of fee makers
public fun get_fee_makers(): vector<address> acquires EpochFeeMakerRegistry {
let registry = borrow_global<EpochFeeMakerRegistry>(@VMReserved);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ script {

// assert!(cap == bal, 735701);

let burn_amount = 1000000;
let burn_amount = 1000000;
DiemAccount::vm_burn_from_balance<GAS>(
@Alice,
burn_amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ script {

let addr = Vector::singleton<address>(@Alice);
Vector::push_back(&mut addr, @Bob);

MultiSig::init_gov(&d_sig, 2, &addr);
MultiSig::init_type<PaymentType>(&d_sig, true);
MultiSig::finalize_and_brick(&d_sig);
Expand Down Expand Up @@ -74,7 +74,7 @@ script {
use Std::Vector;
fun main(_dr: signer, b_sig: signer) {
MultiSig::propose_governance(&b_sig, @DaveMultiSig, Vector::singleton(@Alice), false, Option::none(), Option::none());

// no change yet
let a = MultiSig::get_authorities(@DaveMultiSig);
assert!(Vector::length(&a) == 3, 7357003);
Expand All @@ -91,7 +91,7 @@ script {
use Std::Vector;
fun main(_dr: signer, b_sig: signer) {
MultiSig::propose_governance(&b_sig, @DaveMultiSig, Vector::singleton(@Alice), false, Option::none(), Option::none());

// no change yet
let a = MultiSig::get_authorities(@DaveMultiSig);
assert!(Vector::length(&a) == 2, 7357003);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// DaveMultiSig: non-validators with 1M GAS

// DAVE is going to become a multisig wallet. It's going to get bricked.
// From that point forward only Alice, Bob, and Carol are the only ones
// From that point forward only Alice, Bob, and Carol are the only ones
// who can submit multi-sig transactions.

//# run --admin-script --signers DiemRoot DaveMultiSig
Expand Down Expand Up @@ -44,7 +44,7 @@ script {
// let p = MultiSigPayment::new_payment(@Alice, 10, b"send it");

MultiSigPayment::propose_payment(&b_sig, @DaveMultiSig, @Alice, 10, b"send it", Option::none());

// no change since proposal is pending
let bal = DiemAccount::balance<GAS>(@DaveMultiSig);
// print(&bal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//# run --admin-script --signers DiemRoot Alice
script {
use DiemFramework::TurnoutTallyDemo;
fun main(_root: signer, a_sig: signer) {
fun main(_root: signer, a_sig: signer) {

TurnoutTallyDemo::init(&a_sig);
TurnoutTallyDemo::propose_ballot_by_owner(&a_sig, 100, 10);
}
Expand All @@ -25,7 +25,7 @@ script {
use Std::GUID;
use Std::Option;

fun main(_root: signer, b_sig: signer) {
fun main(_root: signer, b_sig: signer) {
let next_id = GUID::get_next_creation_num(@Alice);

let uid = GUID::create_id(@Alice, next_id - 1); // TODO: unclear why it's 2 and not 0
Expand Down Expand Up @@ -63,7 +63,7 @@ script {
use Std::GUID;
use Std::Option;

fun main(_root: signer, c_sig: signer) {
fun main(_root: signer, c_sig: signer) {
let next_id = GUID::get_next_creation_num(@Alice);

let uid = GUID::create_id(@Alice, next_id - 1); // TODO: unclear why it's 2 and not 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ script {
use DiemFramework::TurnoutTally;
// use DiemFramework::Debug::print;

fun main(_root: signer, _sig: signer) {
fun main(_root: signer, _sig: signer) {

// confirm upperbound
let y = TurnoutTally::get_threshold_from_turnout(8750, 10000);
assert!(y == 5100, 0);
Expand All @@ -24,21 +24,21 @@ script {

let y = TurnoutTally::get_threshold_from_turnout(5000, 10000);
// print(&y);
assert!(y == 7550, 0);
assert!(y == 7550, 0);

let y = TurnoutTally::get_threshold_from_turnout(7500, 10000);
// print(&y);
assert!(y == 5917, 0);
assert!(y == 5917, 0);

// cannot be below the minimum treshold. I.e. more than 100%
let y = TurnoutTally::get_threshold_from_turnout(500, 10000);
// print(&y);
assert!(y == 10000, 0);
assert!(y == 10000, 0);

// same for maximum. More votes cannot go below 51% approval
let y = TurnoutTally::get_threshold_from_turnout(9000, 10000);
// print(&y);
assert!(y == 5100, 0);
assert!(y == 5100, 0);
}
}
// check: EXECUTED
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ script {
//# run --admin-script --signers DiemRoot Bob
script {
use DiemFramework::DonorDirected;

fun main(_dr: signer, sender: signer) {
let uid = DonorDirected::propose_payment(&sender, @Alice, @Bob, 100, b"thanks bob");
let (found, idx, status_enum, completed) = DonorDirected::get_multisig_proposal_state(@Alice, &uid);
Expand All @@ -42,7 +42,7 @@ script {
script {
use DiemFramework::DonorDirected;
use Std::Vector;

fun main(_dr: signer, sender: signer) {
let uid = DonorDirected::propose_payment(&sender, @Alice, @Bob, 100, b"thanks bob");
let (found, idx, status_enum, completed) = DonorDirected::get_multisig_proposal_state(@Alice, &uid);
Expand Down Expand Up @@ -83,7 +83,7 @@ script {
use DiemFramework::GAS::GAS;
use DiemFramework::Receipts;
// use DiemFramework::Debug::print;

fun main(_dr: signer, sender: signer) {
// Receipts::init(&sender);
let _a = Receipts::is_init(@Carol);
Expand Down Expand Up @@ -112,7 +112,7 @@ script {
use Std::Signer;
use Std::GUID;
// use DiemFramework::Debug::print;

fun main(_dr: signer, sender: signer) {
let a = DonorDirectedGovernance::check_is_donor(@Alice, Signer::address_of(&sender));
assert!(a, 7357009);
Expand Down
File renamed without changes.
Loading

0 comments on commit b0ce13c

Please sign in to comment.