Skip to content

Commit

Permalink
Cleanups from PR reviews.
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Apr 5, 2023
1 parent de52c39 commit b8b1f9f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 98 deletions.
2 changes: 1 addition & 1 deletion config/management/genesis/src/ol_validator_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl ValidatorBuilder {
}
}

pub fn randomize_first_validator_ports(mut self, value: bool) -> Self {
pub fn set_random_first_validator_ports(mut self, value: bool) -> Self {
self.randomize_first_validator_ports = value;
self
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,11 @@ address DiemFramework{
/// Validators who are no longer compliant may be kicked out of the validator
/// set and/or jailed. To be compliant, validators must be BOTH validating and mining.
module Cases{
// use DiemFramework::TowerState;
use DiemFramework::Stats;
use DiemFramework::Roles;

const VALIDATOR_COMPLIANT: u64 = 1;
// const VALIDATOR_HALF_COMPLIANT: u64 = 2;
// const VALIDATOR_NOT_COMPLIANT: u64 = 3;
const VALIDATOR_DOUBLY_NOT_COMPLIANT: u64 = 4;

const INVALID_DATA: u64 = 0;

// Determine the consensus case for the validator.
Expand Down Expand Up @@ -46,19 +42,8 @@ address DiemFramework{
// compliant: in next set, gets paid, weight increments
VALIDATOR_COMPLIANT
}
// V6: Simplify compliance cases by removing mining.
// NOTE: 0L: V6: Removed code to simplify compliance cases by removing mining.

// }
// else if (signs && !mines) {
// // half compliant: not in next set, does not get paid, weight
// // does not increment.
// VALIDATOR_HALF_COMPLIANT
// }
// else if (!signs && mines) {
// // not compliant: jailed, not in next set, does not get paid,
// // weight increments.
// VALIDATOR_NOT_COMPLIANT
// }
else {
// not compliant: jailed, not in next set, does not get paid,
// weight does not increment.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ address DiemFramework{
TransactionFee::pay_fee<GAS>(c);
}

// TODO: implement migration of infra escrow.
// fun genesis_helper_migrate_pledge(vm: &signer, user_sig: &signer, amount: u64) {
// CoreAddresses::assert_diem_root(vm);
// PledgeAccounts::user_pledge_tx(&user_sig, @VMReserved, amount);
Expand Down
86 changes: 5 additions & 81 deletions diem-move/vm-genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub fn encode_recovery_genesis_changeset(
OLProgress::complete(&format!("Migrate legacy validator configs [{}]", val_assignments.len()));

// Recover the user balances and data
// NOTE: this includes the balances of legacy validators.
// NOTE: 0L: this includes the balances of legacy validators.
if append_users {
migrate_end_users(&mut session, legacy_data)?;
OLProgress::complete(&format!("Migrated User Data [{}]", legacy_data.len()));
Expand Down Expand Up @@ -650,35 +650,7 @@ fn create_and_initialize_owners_operators(
}
}

// //////// 0L ///////
// // Validator/owner state to recover in genesis recovery mode
// #[derive(Debug, Clone, PartialEq, PartialOrd)]
// pub struct ValStateRecover {
// ///
// pub val_account: AccountAddress,
// ///
// pub operator_delegated_account: AccountAddress,
// ///
// pub val_auth_key: AuthenticationKey,
// }

// //////// 0L ///////
// /// Operator state to recover in genesis recovery mode
// #[derive(Debug, Clone, PartialEq)]
// pub struct OperRecover {
// ///
// pub operator_account: AccountAddress,
// ///
// pub operator_auth_key: AuthenticationKey,
// ///
// pub validator_to_represent: AccountAddress,
// ///
// pub operator_consensus_pubkey: Vec<u8>,
// ///
// pub validator_network_addresses: Vec<u8>,
// ///
// pub fullnode_network_addresses: Vec<u8>,
// }
// NOTE: 0L: moved ValStateRecover and OperStateRecover types to ol/types

//////// 0L ////////
/// TODO: recovery mode is WIP.
Expand Down Expand Up @@ -791,23 +763,7 @@ fn recovery_owners_operators(
);
}

// println!("4 ======== Add owner to validator set");
// // Add each validator to the validator set
// for i in val_set {
// // let staged_owner_auth_key = AuthenticationKey::ed25519(owner_key.as_ref().unwrap());
// // let owner_address = staged_owner_auth_key.derived_address();
// // // let owner_address = diem_config::utils::validator_owner_account_from_name(owner_name);
// exec_function(
// session,
// "DiemSystem",
// "add_validator",
// vec![],
// serialize_values(&vec![
// MoveValue::Signer(diem_root_address),
// MoveValue::Address(*i),
// ]),
// );
// }
// NOTE: 0L: removed code which adds validators to validator set, since this is handled in the Move migration logic.
}

/// Publish the standard library.
Expand Down Expand Up @@ -870,18 +826,7 @@ fn verify_genesis_write_set(events: &[ContractEvent]) {
CreateAccountEvent::event_key(),
);

//////// 0L ////////
// // (3) The first non-account creation event should be the new epoch event
// let new_epoch_events: Vec<&ContractEvent> = events
// .iter()
// .filter(|e| e.key() == &NewEpochEvent::event_key())
// .collect();
// assert!(
// new_epoch_events.len() == 1,
// "There should only be one NewEpochEvent"
// );
// // (4) This should be the first new_epoch_event
// assert_eq!(new_epoch_events[0].sequence_number(), 0,);
// NOTE: 0L: We don't need this check anymore. We are running account creations at the genesis.
}

/// An enum specifying whether the compiled stdlib/scripts should be used or freshly built versions
Expand Down Expand Up @@ -1073,28 +1018,7 @@ fn fund_operators(
);
}

// Old (diem 1.3.0 patch) - to remove after review
//
// // Add each validator to the validator set
// for (owner_key, _owner_name, _op_assignment, _genesis_proof, operator_account) in
// operator_assignments
// {
// let diem_root_address = account_config::diem_root_address();

// // give the operator balance to be able to send txs for owner, e.g. tower-builder
// exec_function(
// session,
// // log_context,
// "DiemAccount",
// "genesis_fund_operator",
// vec![],
// serialize_values(&vec![
// MoveValue::Signer(diem_root_address),
// MoveValue::Signer(owner_address),
// MoveValue::Address(*operator_account),
// ]),
// );
// }
// NOTE: 0L: we do not need to fund operators in v6 at genesis. Operators are no longer mining with Tower.
}

//////// 0L ////////
Expand Down

0 comments on commit b8b1f9f

Please sign in to comment.