Skip to content

Commit

Permalink
[fix] toy rng chain halt (0LNetworkCommunity#133)
Browse files Browse the repository at this point in the history
Co-authored-by: 0o-de-lally <[email protected]>
  • Loading branch information
0xzoz and 0o-de-lally committed Aug 17, 2024
1 parent 8b36588 commit c516ad3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
35 changes: 14 additions & 21 deletions framework/libra-framework/sources/ol_sources/tower_state.move
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,6 @@ module ol_framework::tower_state {
exists<TowerProofHistory>(addr)
}

// /// is onboarding
// public fun is_onboarding(addr: address): bool acquires TowerProofHistory {
// let count = get_count_in_epoch(addr);
// let state = borrow_global<TowerProofHistory>(addr);

// count < 2 &&
// state.epochs_since_last_account_creation < 2
// }

// Creates proof blob object from input parameters
// Permissions: PUBLIC, ANYONE can call this function.
public fun create_proof_blob(
Expand Down Expand Up @@ -415,15 +406,17 @@ module ol_framework::tower_state {
// that had proofs this epoch
let outgoing_miners = get_miner_list();
let vals_len = vector::length(&outgoing_miners);
let i = 0;
while (i < vals_len) {
let val = vector::borrow(&outgoing_miners, i);

// For testing: don't call update_metrics unless there is account state for the address.
if (exists<TowerProofHistory>(*val)){
update_epoch_metrics_vals(vm, *val);
};
i = i + 1;
if (vals_len > 0) {
let i = 0;
while (i < vals_len) {
let val = vector::borrow(&outgoing_miners, i);

// For testing: don't call update_metrics unless there is account state for the address.
if (exists<TowerProofHistory>(*val)){
update_epoch_metrics_vals(vm, *val);
};
i = i + 1;
};
};

epoch_reset(vm);
Expand Down Expand Up @@ -598,16 +591,16 @@ module ol_framework::tower_state {
this_miner_index = this_miner_index / count_miners;
k = k + 1;
};
// double check
if (count_miners < this_miner_index) return 0;
// double check length of vector
if (this_miner_index >= count_miners ) return 0;

let miner_addr = vector::borrow<address>(&all_miners, this_miner_index);
let vec = if (exists<TowerProofHistory>(*miner_addr)) {
*&borrow_global<TowerProofHistory>(*miner_addr).previous_proof_hash
} else { return 0 };

if (vector::is_empty(&vec)) { return 0 };
// take the last bit (B) from their last proof hash.

n = (vector::pop_back(&mut vec) as u64);
this_miner_index = n; // randomize selection of next validator
i = i + 1;
Expand Down
6 changes: 3 additions & 3 deletions tools/rescue/src/rescue_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ use move_core_types::language_storage::CORE_CODE_ADDRESS;
use std::path::PathBuf;

#[derive(Parser)]
/// Start a libra node
/// Create a rescue transaction using the path of the node db
pub struct RescueTxOpts {
#[clap(short, long)]
/// directory enclosing the `/db` folder of the node
pub data_path: PathBuf,
#[clap(short, long)]
/// directory to read/write or the rescue.blob. Will default to db_path/rescue.blob
/// directory to read/write for the rescue.blob. Will default to db_path/rescue.blob
pub blob_path: Option<PathBuf>,
#[clap(short, long)]
/// directory to read/write or the rescue.blob
/// directory for the script to be executed
pub script_path: Option<PathBuf>,
#[clap(long)]
/// directory to read/write or the rescue.blob
Expand Down

0 comments on commit c516ad3

Please sign in to comment.