Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tool Scrubber Graduation PR for V6 #1174

Open
wants to merge 8 commits into
base: v6
Choose a base branch
from
Open
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
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.
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
6 changes: 5 additions & 1 deletion ol/cli/src/commands/whoami_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ impl Runnable for WhoamiCmd {

let (auth, addr, wallet) = wallet::get_account_from_prompt();

let val_cfg = ValConfigs::new(
let val_cfg_res = ValConfigs::new(
None,
KeyScheme::new(&wallet),
app_cfg.profile.ip,
app_cfg.profile.vfn_ip.unwrap_or("0.0.0.0".parse().unwrap()),
None,
None,
);
let val_cfg = match val_cfg_res {
Ok(cfg) => cfg,
Err(error) => panic!("Could not create validator config: {:?}", error),
};

println!("\n0L ACCOUNT\n");
println!("address: {}", addr);
Expand Down
3 changes: 2 additions & 1 deletion ol/cli/src/node/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ impl Node {
/// database is initialized, Please do NOT invoke this function frequently
pub fn db_files_exist(&mut self) -> bool {
// check to see no files are present
let db_path = self.app_conf.workspace.db_path.clone().join("diemdb");
//let db_path = self.app_conf.workspace.db_path.clone().join("diemdb");
let db_path = self.app_conf.workspace.db_path.join("diemdb");
db_path.exists()
}

Expand Down
15 changes: 10 additions & 5 deletions ol/onboard/src/commands/wizard_fork_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl Runnable for ForkCmd {

let home_dir = cfg.workspace.node_home.to_owned();
// 0L convention is for the namespace of the operator to be appended by '-oper'
let namespace = cfg.profile.auth_key.clone().to_string() + "-oper";
let namespace = cfg.profile.auth_key.to_string() + "-oper";
let val_ip_address = cfg.profile.ip;

// TODO: use node_config to get the seed peers and then write upstream_node vec in 0L.toml from that.
Expand Down Expand Up @@ -285,16 +285,21 @@ pub fn write_account_json(
let json_path = json_path.clone().unwrap_or(cfg.workspace.node_home.clone());
let keys = KeyScheme::new(&wallet);
let block = VDFProof::parse_block_file(cfg.get_block_dir().join("proof_0.json").to_owned());

match ValConfigs::new(
let val_cfg_res = ValConfigs::new(
Some(block),
keys,
cfg.profile.ip,
cfg.profile.vfn_ip.unwrap_or("0.0.0.0".parse().unwrap()),
autopay_batch,
autopay_signed,
)
.create_manifest(json_path)
);

let val_cfg = match val_cfg_res {
Ok(cfg) => cfg,
Err(error) => panic!("Could not create validator config: {:?}", error),
};

match val_cfg.create_manifest(json_path)
{
Ok(_) => {
status_ok!(
Expand Down
13 changes: 10 additions & 3 deletions ol/onboard/src/commands/wizard_val_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,22 @@ pub fn write_account_json(
let keys = KeyScheme::new(&wallet);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

write_account_json should return Result

let block = VDFProof::parse_block_file(cfg.get_block_dir().join("proof_0.json").to_owned());

match ValConfigs::new(
let val_cfg_res = ValConfigs::new(
Some(block),
keys,
cfg.profile.ip,
cfg.profile.vfn_ip.unwrap_or("0.0.0.0".parse().unwrap()),
autopay_batch,
autopay_signed,
)
.create_manifest(json_path)
);

let val_cfg = match val_cfg_res {
Ok(cfg) => cfg,
Err(error) => panic!("Could not create validator config: {:?}", error),
};

match val_cfg.create_manifest(json_path)

{
Ok(_) => {
status_ok!(
Expand Down
18 changes: 13 additions & 5 deletions ol/onboard/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::prelude::app_config;
use diem_types::transaction::SignedTransaction;
use diem_wallet::WalletLibrary;
use ol_types::{account::ValConfigs, pay_instruction::PayInstruction};
use std::path::PathBuf;
use std::{path::PathBuf, process::exit};

/// Creates an account.json file for the validator
pub fn write_manifest(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should return Result

Expand All @@ -31,14 +31,22 @@ pub fn write_manifest(

let keys = KeyScheme::new(&wallet);
let block = VDFProof::parse_block_file(cfg.get_block_dir().join("proof_0.json").to_owned());

return ValConfigs::new(
let val_cfg_res = ValConfigs::new(
Some(block),
keys,
cfg.profile.ip,
cfg.profile.vfn_ip.unwrap_or("0.0.0.0".parse().unwrap()),
autopay_batch,
autopay_signed,
)
.create_manifest(miner_home)
);

let val_cfg = match val_cfg_res {
Ok(cfg) => cfg,
Err(error) => {
println!("Could not create validator config: {:?}", error);
exit(1);
}

};
return val_cfg.create_manifest(miner_home)
}
2 changes: 1 addition & 1 deletion ol/tower/src/preimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn genesis_preimage(cfg: &AppCfg) -> Vec<u8> {
let mut preimage: Vec<u8> = vec![];

// AUTH_KEY_BYTES
let mut padded_key_bytes = match decode(cfg.profile.auth_key.clone().to_string()) {
let mut padded_key_bytes = match decode(cfg.profile.auth_key.to_string()) {
Err(x) => panic!("Invalid 0L Auth Key: {}", x),
Ok(key_bytes) => padding(key_bytes, AUTH_KEY_BYTES),
};
Expand Down
7 changes: 6 additions & 1 deletion ol/txs/src/commands/val_config_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Runnable for ValConfigCmd {
// let _entry_args = entrypoint::get_args();
let (_, _, w) = wallet::get_account_from_prompt();

let val_cfg = ValConfigs::new(
let val_cfg_res = ValConfigs::new(
None,
KeyScheme::new(&w),
self.val_ip.expect("neeed a validator ip address"),
Expand All @@ -41,6 +41,11 @@ impl Runnable for ValConfigCmd {
None,
);

let val_cfg = match val_cfg_res {
Ok(cfg) => cfg,
Err(error) => panic!("Could not create validator config: {:?}", error),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove panic! for exit()

};

let txt = format!("New consensus pubkey: {} \n
New validator network addresses: {}, \n
New vfn fullnode network addresses: {}",
Expand Down
21 changes: 10 additions & 11 deletions ol/types/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use diem_crypto::x25519::PublicKey;
use diem_global_constants::{DEFAULT_PUB_PORT, DEFAULT_VAL_PORT, DEFAULT_VFN_PORT};
use diem_types::{
account_address::AccountAddress,
network_address::{NetworkAddress},
network_address::NetworkAddress,
transaction::{SignedTransaction, TransactionPayload},
};

Expand Down Expand Up @@ -85,12 +85,11 @@ impl ValConfigs {
vfn_ip_address: Ipv4Addr,
autopay_instructions: Option<Vec<PayInstruction>>,
autopay_signed: Option<Vec<SignedTransaction>>,
) -> Self {
) -> Result<ValConfigs, anyhow::Error> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Result<ValConfigs...
Result<Self...

let owner_address = keys.child_0_owner.get_address();

let val_pubkey =
PublicKey::from_ed25519_public_bytes(&keys.child_2_val_network.get_public().to_bytes())
.unwrap();
PublicKey::from_ed25519_public_bytes(&keys.child_2_val_network.get_public().to_bytes())?;

let val_addr_for_val_net =
ValConfigs::make_unencrypted_addr(&val_ip_address, val_pubkey, NetworkId::Validator);
Expand All @@ -115,12 +114,11 @@ impl ValConfigs {
// to connect to its fullnode.
let vfn_pubkey = PublicKey::from_ed25519_public_bytes(
&keys.child_3_fullnode_network.get_public().to_bytes(),
)
.unwrap();
)?;
let vfn_addr_obj =
ValConfigs::make_unencrypted_addr(&vfn_ip_address, vfn_pubkey, NetworkId::Public);

Self {
let new_conf = Self {
/// Proof zero of the onboarded miner
block_zero,
ow_human_name: owner_address,
Expand All @@ -133,15 +131,16 @@ impl ValConfigs {
op_consensus_pubkey: keys.child_4_consensus.get_public().to_bytes().to_vec(),
// 0L todo diem-1.4.1
// op_validator_network_addresses: bcs::to_bytes(&vec![encrypted_addr]).unwrap(),
op_validator_network_addresses: bcs::to_bytes(&vec![&val_addr_for_val_net]).unwrap(),
op_fullnode_network_addresses: bcs::to_bytes(&vec![&vfn_addr_obj]).unwrap(),
op_validator_network_addresses: bcs::to_bytes(&vec![&val_addr_for_val_net])?,
op_fullnode_network_addresses: bcs::to_bytes(&vec![&vfn_addr_obj])?,
op_val_net_addr_for_vals: val_addr_for_val_net.to_owned(),
op_val_net_addr_for_vfn: val_addr_for_vfn_net.to_owned(),
op_vfn_net_addr_for_public: vfn_addr_obj.to_owned(),
op_human_name: format!("{}-oper", owner_address), //NOTE: This must match ol/types/src/config.rs format_oper_namespace
autopay_instructions,
autopay_signed,
}
};
Ok(new_conf)
}
/// Creates the json file needed for onchain account creation - validator
pub fn create_manifest(&self, mut json_path: PathBuf) -> Result<(), anyhow::Error>{
Expand Down Expand Up @@ -231,7 +230,7 @@ impl ValConfigs {
let tx = signed.iter().nth(i).unwrap();
let payload = tx.clone().into_raw_transaction().into_payload();
if let TransactionPayload::Script(s) = payload {
match instr.check_instruction_match_tx(s.clone()) {
match instr.check_instruction_match_tx(&s) { // Now passing reference instead of s.clone() (Michael64)
Ok(_) => {}
Err(e) => {
// TODO: should this panic?
Expand Down
Loading