Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,4 @@ key_store.json
#vs code
.vscode/

*.swp

# prevent mv files from being committed
*.mv
diem-move/diem-framework/DPN/releases/artifacts
*/artifacts/
*.swp
6 changes: 2 additions & 4 deletions config/management/genesis/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use diem_global_constants::{
use diem_management::constants::{self, VALIDATOR_CONFIG, VALIDATOR_OPERATOR};
use diem_secure_storage::{KVStorage, Namespaced};
use diem_types::{
account_address::AccountAddress,
chain_id::ChainId,
on_chain_config::{OnChainConsensusConfig, VMPublishingOption},
transaction::{
Expand Down Expand Up @@ -135,9 +134,8 @@ impl<S: KVStorage> GenesisBuilder<S> {
let mut validators = Vec::new();
for owner in &layout.owners {
let name = owner.as_bytes().to_vec();
let address = AccountAddress::from_hex(owner)?;
// let address = diem_config::utils::default_validator_owner_auth_key_from_name(&name)
// .derived_address();
let address = diem_config::utils::default_validator_owner_auth_key_from_name(&name)
.derived_address();
let auth_key = self
.owner_key(owner)
.map_or(AuthenticationKey::zero(), |k| {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ compiled_package_info:
? address: "00000000000000000000000000000001"
name: XUS
: DiemFramework
source_digest: C858C8D4197D82103F1F6F229A8539BACFA2CFF36186C713926E1C43A373A2D4
source_digest: 6FE88762F2E1A750B12C4166250C66AAE205A92570EF975EEBA86738CABDE2A2
build_flags:
dev_mode: false
test_mode: false
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6107,6 +6107,7 @@ based on the conditions checked in the prologue, should never fail.
<b>let</b> gas_used = txn_max_gas_units - gas_units_remaining;
<b>let</b> transaction_fee_amount = txn_gas_price * gas_used;
<b>let</b> coin = <b>global</b>&lt;<a href="DiemAccount.md#0x1_DiemAccount_Balance">Balance</a>&lt;Token&gt;&gt;(sender).coin;
<b>ensures</b> <b>global</b>&lt;<a href="DiemAccount.md#0x1_DiemAccount">DiemAccount</a>&gt;(sender).sequence_number == <b>old</b>(<b>global</b>&lt;<a href="DiemAccount.md#0x1_DiemAccount">DiemAccount</a>&gt;(sender).sequence_number) + 1;
<b>include</b> (transaction_fee_amount &gt; 0) ==&gt; <a href="TransactionFee.md#0x1_TransactionFee_PayFeeEnsures">TransactionFee::PayFeeEnsures</a>&lt;Token&gt;{coin: <a href="Diem.md#0x1_Diem">Diem</a>&lt;Token&gt;{value: transaction_fee_amount}};
}
</code></pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,7 @@ Travel rule limit set during genesis
<b>let</b> initial_limit = <a href="DualAttestation.md#0x1_DualAttestation_INITIAL_DUAL_ATTESTATION_LIMIT">INITIAL_DUAL_ATTESTATION_LIMIT</a> * <a href="Diem.md#0x1_Diem_spec_scaling_factor">Diem::spec_scaling_factor</a>&lt;<a href="GAS.md#0x1_GAS">GAS</a>&gt;();
<b>aborts_if</b> initial_limit &gt; <a href="DualAttestation.md#0x1_DualAttestation_MAX_U64">MAX_U64</a> <b>with</b> Errors::LIMIT_EXCEEDED;
<b>include</b> <a href="Diem.md#0x1_Diem_AbortsIfNoCurrency">Diem::AbortsIfNoCurrency</a>&lt;<a href="GAS.md#0x1_GAS">GAS</a>&gt;;
<b>ensures</b> <b>global</b>&lt;<a href="DualAttestation.md#0x1_DualAttestation_Limit">Limit</a>&gt;(@DiemRoot).micro_xdx_limit == initial_limit;
</code></pre>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
<b>while</b> (i &lt; <a href="../../../../../../../DPN/releases/artifacts/current/build/MoveStdlib/docs/Vector.md#0x1_Vector_length">Vector::length</a>&lt;<b>address</b>&gt;(&previous_set)) {
<b>let</b> addr = *<a href="../../../../../../../DPN/releases/artifacts/current/build/MoveStdlib/docs/Vector.md#0x1_Vector_borrow">Vector::borrow</a>(&previous_set, i);
<b>let</b> case = <a href="Cases.md#0x1_Cases_get_case">Cases::get_case</a>(vm, addr, height_start, height_now);

<b>if</b> (
// we care about nodes that are performing consensus correctly, case 1 and 2.
case &lt; 3 &&
Expand All @@ -243,6 +244,7 @@
// also reset the jail counter for any successful unjails
<a href="Jail.md#0x1_Jail_remove_consecutive_fail">Jail::remove_consecutive_fail</a>(vm, addr);
} <b>else</b> {

<a href="Jail.md#0x1_Jail_jail">Jail::jail</a>(vm, addr);
};
i = i+ 1;
Expand Down Expand Up @@ -277,8 +279,12 @@
<b>let</b> addr = *<a href="../../../../../../../DPN/releases/artifacts/current/build/MoveStdlib/docs/Vector.md#0x1_Vector_borrow">Vector::borrow</a>(&top_accounts, i);
<b>let</b> mined_last_epoch = <a href="TowerState.md#0x1_TowerState_node_above_thresh">TowerState::node_above_thresh</a>(addr);
<b>let</b> case = <a href="Cases.md#0x1_Cases_get_case">Cases::get_case</a>(vm, addr, height_start, height_now);
print(&44444444);
print(&addr);
print(&case);
print(&<a href="Jail.md#0x1_Jail_is_jailed">Jail::is_jailed</a>(addr));
print(&<a href="Audit.md#0x1_Audit_val_audit_passing">Audit::val_audit_passing</a>(addr));
print(&<a href="Vouch.md#0x1_Vouch_unrelated_buddies_above_thresh">Vouch::unrelated_buddies_above_thresh</a>(addr));

<b>if</b> (
// ignore proven nodes already on list
Expand All @@ -296,7 +302,8 @@
// <b>has</b> proven themselves in the previous round. If your
// vouchers fall out of the set, you may also fall out,
// and this chain reaction would cause instability in the network.
<a href="Vouch.md#0x1_Vouch_unrelated_buddies_above_thresh">Vouch::unrelated_buddies_above_thresh</a>(addr) ) {
<a href="Vouch.md#0x1_Vouch_unrelated_buddies_above_thresh">Vouch::unrelated_buddies_above_thresh</a>(addr)
) {
print(&99990901);
<a href="../../../../../../../DPN/releases/artifacts/current/build/MoveStdlib/docs/Vector.md#0x1_Vector_push_back">Vector::push_back</a>(&<b>mut</b> proposed_set, addr);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@

<pre><code><b>public</b> <b>fun</b> <a href="Jail.md#0x1_Jail_jail">jail</a>(vm: &signer, validator: <b>address</b>) <b>acquires</b> <a href="Jail.md#0x1_Jail">Jail</a>{
<a href="CoreAddresses.md#0x1_CoreAddresses_assert_vm">CoreAddresses::assert_vm</a>(vm);

<b>if</b> (<b>exists</b>&lt;<a href="Jail.md#0x1_Jail">Jail</a>&gt;(validator)) {
<b>let</b> j = <b>borrow_global_mut</b>&lt;<a href="Jail.md#0x1_Jail">Jail</a>&gt;(validator);
j.is_jailed = <b>true</b>;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3042,6 +3042,7 @@ module DiemFramework::DiemAccount {
let gas_used = txn_max_gas_units - gas_units_remaining;
let transaction_fee_amount = txn_gas_price * gas_used;
let coin = global<Balance<Token>>(sender).coin;
ensures global<DiemAccount>(sender).sequence_number == old(global<DiemAccount>(sender).sequence_number) + 1;
include (transaction_fee_amount > 0) ==> TransactionFee::PayFeeEnsures<Token>{coin: Diem<Token>{value: transaction_fee_amount}};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ module DiemFramework::DualAttestation {
let initial_limit = INITIAL_DUAL_ATTESTATION_LIMIT * Diem::spec_scaling_factor<GAS>();
aborts_if initial_limit > MAX_U64 with Errors::LIMIT_EXCEEDED;
include Diem::AbortsIfNoCurrency<GAS>; // for scaling_factor.
ensures global<Limit>(@DiemRoot).micro_xdx_limit == initial_limit;
}

/// Return the current dual attestation limit in microdiem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ module EpochBoundary {
while (i < Vector::length<address>(&previous_set)) {
let addr = *Vector::borrow(&previous_set, i);
let case = Cases::get_case(vm, addr, height_start, height_now);

if (
// we care about nodes that are performing consensus correctly, case 1 and 2.
case < 3 &&
Expand All @@ -163,6 +164,7 @@ module EpochBoundary {
// also reset the jail counter for any successful unjails
Jail::remove_consecutive_fail(vm, addr);
} else {

Jail::jail(vm, addr);
};
i = i+ 1;
Expand Down Expand Up @@ -197,8 +199,12 @@ module EpochBoundary {
let addr = *Vector::borrow(&top_accounts, i);
let mined_last_epoch = TowerState::node_above_thresh(addr);
let case = Cases::get_case(vm, addr, height_start, height_now);
print(&44444444);
print(&addr);
print(&case);
print(&Jail::is_jailed(addr));
print(&Audit::val_audit_passing(addr));
print(&Vouch::unrelated_buddies_above_thresh(addr));

if (
// ignore proven nodes already on list
Expand All @@ -216,7 +222,8 @@ module EpochBoundary {
// has proven themselves in the previous round. If your
// vouchers fall out of the set, you may also fall out,
// and this chain reaction would cause instability in the network.
Vouch::unrelated_buddies_above_thresh(addr) ) {
Vouch::unrelated_buddies_above_thresh(addr)
) {
print(&99990901);
Vector::push_back(&mut proposed_set, addr);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ address DiemFramework {

public fun jail(vm: &signer, validator: address) acquires Jail{
CoreAddresses::assert_vm(vm);

if (exists<Jail>(validator)) {
let j = borrow_global_mut<Jail>(validator);
j.is_jailed = true;
Expand Down
25 changes: 12 additions & 13 deletions diem-move/vm-genesis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ pub fn encode_genesis_change_set(
//////// 0L ////////
pub fn encode_recovery_genesis_changeset(
val_assignments: &[ValStateRecover],
operator_registrations: &[OperRecover],
operator_recovers: &[OperRecover],
val_set: &[AccountAddress],
chain: u8,
) -> Result<ChangeSet, Error> {
Expand Down Expand Up @@ -234,7 +234,7 @@ pub fn encode_recovery_genesis_changeset(

// generate the genesis WriteSet
recovery_owners_operators(
&mut session, val_assignments, operator_registrations, val_set
&mut session, val_assignments, operator_recovers, val_set
);

//////// 0L ////////
Expand Down Expand Up @@ -606,7 +606,7 @@ pub struct OperRecover {
fn recovery_owners_operators(
session: &mut Session<StateViewCache<GenesisStateView>>,
val_assignments: &[ValStateRecover],
operator_registrations: &[OperRecover],
operator_recovers: &[OperRecover],
val_set: &[AccountAddress],
) {
let diem_root_address = account_config::diem_root_address();
Expand Down Expand Up @@ -668,7 +668,7 @@ fn recovery_owners_operators(
]),
);

// let all_vals: Vec<AccountAddress> = operator_registrations.iter()
// let all_vals: Vec<AccountAddress> = operator_recovers.iter()
// .map(|a|{ a.validator_to_represent }).collect();
// let mut vals = all_vals.clone();
// vals.retain(|el|{ el != &i.val_account});
Expand All @@ -687,7 +687,7 @@ fn recovery_owners_operators(

println!("1 ======== Create OP Accounts");
// Create accounts for each validator operator
for i in operator_registrations {
for i in operator_recovers {
let create_operator_script =
transaction_builder::encode_create_validator_operator_account_script_function(
0,
Expand All @@ -704,25 +704,24 @@ fn recovery_owners_operators(
}

println!("2 ======== Link owner to OP");
// Authorize an operator for a validator/owner
for i in val_assignments {
// Set the validator operator for each validator owner
for val in val_assignments {
let create_operator_script =
transaction_builder::encode_set_validator_operator_with_nonce_admin_script_function(
0,
i.operator_delegated_account.to_vec(),
i.operator_delegated_account,
transaction_builder::encode_set_validator_operator_script_function(
val.operator_delegated_account.to_vec(),
val.operator_delegated_account
)
.into_script_function();
exec_script_function(
session,
i.val_account, //TODO: check the signer is correct
val.val_account, //TODO: check the signer is correct
&create_operator_script,
);
}

println!("3 ======== OP sends network info to Owner config");
// Set the validator operator configs for each owner
for i in operator_registrations {
for i in operator_recovers {
let create_operator_script =
transaction_builder::encode_register_validator_config_script_function(
i.validator_to_represent,
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 8 additions & 7 deletions ol/genesis-tools/Readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Generate genesis blob from epoch
Sample command:
```cargo run -p ol-genesis-tools -- --path ${FULL_PATH_TO_PROJECT_ROOT}/ol/fixtures/state-snapshot/194/state_ver_74694920.0889/```

# Start swarm with a custom genesis blob file
Sample command:
```NODE_ENV="test" cargo run -p libra-swarm -- --libra-node target/debug/libra-node -c ${SWARM_TEMP_PATH} -n 1 -s --cli-path target/debug/cli --genesis-blob-path ${FULL_PATH_TO_BLOB_FILE}```
### JSON export from snapshot
cargo r -p ol-genesis-tools -- --recover /opt/rec.json --snapshot-path /opt/state_ver*
state_ver: https://github.com/OLSF/epoch-archive/tree/main/359/state_ver_76353076.a0ff

--genesis-blob-path is the additional parameter added to libra-swarm module.
### Create genesis blob from JSON export:
cargo r -p ol-genesis-tools -- --fork --recovery-json-path /opt/rec.json --output-path /opt/genesis_from_recovery.blob

### Verify the validity of genesis blob by starting a node in test mode:
cargo r -p diem-node -- --test --genesis-modules /opt/genesis_from_recovery.blob
18 changes: 14 additions & 4 deletions ol/genesis-tools/src/fork_genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,27 @@ use ol_types::fullnode_counter::FullnodeCounterResource;
use ol_types::wallet::{CommunityWalletsResource, SlowWalletResource};
use vm_genesis::encode_recovery_genesis_changeset;

/// Make a recovery genesis blob
pub async fn make_recovery_genesis(
/// Make a recovery genesis blob from archive
pub async fn make_recovery_genesis_from_archive(
genesis_blob_path: PathBuf,
archive_path: PathBuf,
append: bool,
is_legacy: bool,
) -> Result<(), Error> {
//TODO: have option to "swarmify" this so that the authkey and network addresses.

// get the legacy data from archive
let recovery = archive_into_recovery(&archive_path, is_legacy).await?;

make_recovery_genesis_from_recovery(recovery, genesis_blob_path, append)
}

/// Make a recovery genesis blob
pub fn make_recovery_genesis_from_recovery(
recovery: Vec<LegacyRecovery>,
genesis_blob_path: PathBuf,
append: bool,
) -> Result<(), Error> {
//TODO: have option to "swarmify" this so that the authkey and network addresses.

// get consensus accounts
let genesis_accounts = recover_consensus_accounts(&recovery)?;
// create baseline genesis
Expand Down
Loading