diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/BuildInfo.yaml b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/BuildInfo.yaml index e6ca0417cc..71496995a8 100644 --- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/BuildInfo.yaml +++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/BuildInfo.yaml @@ -31,9 +31,6 @@ compiled_package_info: ? address: "00000000000000000000000000000001" name: Ancestry : DiemFramework - ? address: "00000000000000000000000000000001" - name: Audit - : DiemFramework ? address: "00000000000000000000000000000001" name: Authenticator : DiemFramework @@ -223,6 +220,9 @@ compiled_package_info: ? address: "00000000000000000000000000000001" name: PersistenceDemo : DiemFramework + ? address: "00000000000000000000000000000001" + name: ProofOfFee + : DiemFramework ? address: "00000000000000000000000000000001" name: Receipts : DiemFramework @@ -346,7 +346,7 @@ compiled_package_info: ? address: "00000000000000000000000000000001" name: XUS : DiemFramework - source_digest: E73442AD7A1B65175ABE2ACCB60D6A59204FBFD1C63E20E767E29AAC56BD3285 + source_digest: 110A62F23F4C530726F3CD908ED8A7393D8E6E9D5B8E6F2543C536D0C02458CB build_flags: dev_mode: false test_mode: false diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/abis/ProofOfFee/init_bidding.abi b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/abis/ProofOfFee/init_bidding.abi new file mode 100644 index 0000000000..cdcc68fa87 Binary files /dev/null and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/abis/ProofOfFee/init_bidding.abi differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/abis/ProofOfFee/pof_retract_bid.abi b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/abis/ProofOfFee/pof_retract_bid.abi new file mode 100644 index 0000000000..2e93d36189 Binary files /dev/null and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/abis/ProofOfFee/pof_retract_bid.abi differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/abis/ProofOfFee/pof_update_bid.abi b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/abis/ProofOfFee/pof_update_bid.abi new file mode 100644 index 0000000000..29a2cc5bcd Binary files /dev/null and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/abis/ProofOfFee/pof_update_bid.abi differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/abis/ol_validator/self_unjail.abi b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/abis/ol_validator/self_unjail.abi deleted file mode 100644 index 5656c11d66..0000000000 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/abis/ol_validator/self_unjail.abi and /dev/null differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Ancestry.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Ancestry.mv index 1fe39b0569..1848b37d1e 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Ancestry.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Ancestry.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Audit.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Audit.mv deleted file mode 100644 index 1bfdfbc3c0..0000000000 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Audit.mv and /dev/null differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/AutoPay.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/AutoPay.mv index 3fee779876..2cc0657158 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/AutoPay.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/AutoPay.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Burn.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Burn.mv index 1af3e582d0..14a3566a3c 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Burn.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Burn.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Cases.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Cases.mv index 571a32287e..894db04ef4 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Cases.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Cases.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DemoBonding.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DemoBonding.mv index 5a82c5d5d5..28267bfe99 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DemoBonding.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DemoBonding.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DiemAccount.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DiemAccount.mv index 53e1743184..49bb090195 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DiemAccount.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DiemAccount.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DiemSystem.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DiemSystem.mv index f41c0ff1ab..151dd923b0 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DiemSystem.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DiemSystem.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DonorDirected.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DonorDirected.mv index 618c158558..32e0991238 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DonorDirected.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/DonorDirected.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Epoch.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Epoch.mv index 98dfe13a5d..4403ca368f 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Epoch.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Epoch.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/EpochBoundary.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/EpochBoundary.mv index fd85b2d2ba..7c84d29709 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/EpochBoundary.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/EpochBoundary.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/FullnodeSubsidy.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/FullnodeSubsidy.mv index 0d93298332..343a5946ef 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/FullnodeSubsidy.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/FullnodeSubsidy.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Genesis.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Genesis.mv index a5084a17a0..a902ac9e8c 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Genesis.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Genesis.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/GenesisMigration.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/GenesisMigration.mv index 0d1668939e..7dd3a45541 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/GenesisMigration.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/GenesisMigration.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Jail.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Jail.mv index 8538b73583..db4978276a 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Jail.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Jail.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Mock.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Mock.mv index d6f44637c3..0e8567bafa 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Mock.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Mock.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/MultiSig.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/MultiSig.mv index 72dfd73496..ec941556b6 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/MultiSig.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/MultiSig.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/MultiSigPayment.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/MultiSigPayment.mv index a3e48bb30f..489027572b 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/MultiSigPayment.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/MultiSigPayment.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/ProofOfFee.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/ProofOfFee.mv new file mode 100644 index 0000000000..a771031471 Binary files /dev/null and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/ProofOfFee.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Receipts.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Receipts.mv index 9fbfadc9eb..e5b13122f8 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Receipts.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Receipts.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/StagingNet.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/StagingNet.mv index c89bf2d449..f7fb5f8219 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/StagingNet.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/StagingNet.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Stats.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Stats.mv index 7f33315ca3..d0112a1cf7 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Stats.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Stats.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Subsidy.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Subsidy.mv index 08e2246228..cf21ec6118 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Subsidy.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Subsidy.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TestFixtures.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TestFixtures.mv index d5979e47ce..da129c513b 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TestFixtures.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TestFixtures.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Testnet.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Testnet.mv index 0306b10497..b1ddc41983 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Testnet.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Testnet.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TowerState.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TowerState.mv index dfbd37fecc..343fefb5a9 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TowerState.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TowerState.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TransactionFee.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TransactionFee.mv index 717e5b4bb4..9f1fa9bf84 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TransactionFee.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TransactionFee.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TransferScripts.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TransferScripts.mv index 062636ac17..ae8918f2bb 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TransferScripts.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/TransferScripts.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Upgrade.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Upgrade.mv index fe3b084a52..b472b49634 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Upgrade.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/Upgrade.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/ValidatorScripts.mv b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/ValidatorScripts.mv index b824f76ff3..c54af636d1 100644 Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/ValidatorScripts.mv and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/bytecode_modules/ValidatorScripts.mv differ diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Ancestry.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Ancestry.md index 9eaf2b5e6f..262f6b28c3 100644 --- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Ancestry.md +++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Ancestry.md @@ -16,7 +16,6 @@
use 0x1::CoreAddresses;
-use 0x1::Debug;
use 0x1::Option;
use 0x1::Signer;
use 0x1::Vector;
@@ -67,7 +66,7 @@
public fun init(new_account_sig: &signer, onboarder_sig: &signer ) acquires Ancestry{
- print(&100100);
+ // print(&100100);
let parent = Signer::address_of(onboarder_sig);
set_tree(new_account_sig, parent);
}
@@ -94,7 +93,7 @@
fun set_tree(new_account_sig: &signer, parent: address ) acquires Ancestry {
let child = Signer::address_of(new_account_sig);
- print(&100200);
+ // print(&100200);
let new_tree = Vector::empty<address>();
// get the parent's ancestry if initialized.
@@ -103,31 +102,31 @@
if (exists<Ancestry>(parent)) {
let parent_state = borrow_global_mut<Ancestry>(parent);
let parent_tree = *&parent_state.tree;
- print(&100210);
+ // print(&100210);
if (Vector::length<address>(&parent_tree) > 0) {
Vector::append(&mut new_tree, parent_tree);
};
- print(&100220);
+ // print(&100220);
};
// add the parent to the tree
Vector::push_back(&mut new_tree, parent);
- print(&100230);
+ // print(&100230);
if (!exists<Ancestry>(child)) {
move_to<Ancestry>(new_account_sig, Ancestry {
tree: new_tree,
});
- print(&100240);
+ // print(&100240);
} else {
// this is only for migration cases.
let child_ancestry = borrow_global_mut<Ancestry>(child);
child_ancestry.tree = new_tree;
- print(&100250);
+ // print(&100250);
};
- print(&100260);
+ // print(&100260);
}
@@ -183,40 +182,40 @@
public fun is_family(left: address, right: address): (bool, address) acquires Ancestry {
let is_family = false;
let common_ancestor = @0x0;
- print(&100300);
- print(&exists<Ancestry>(left));
- print(&exists<Ancestry>(right));
+ // // print(&100300);
+ // // print(&exists<Ancestry>(left));
+ // // print(&exists<Ancestry>(right));
// if (exists<Ancestry>(left) && exists<Ancestry>(right)) {
// if tree is empty it will still work.
- print(&100310);
+ // // print(&100310);
let left_tree = get_tree(left);
- print(&100311);
+ // // print(&100311);
let right_tree = get_tree(right);
- print(&100320);
+ // // print(&100320);
// check for direct relationship.
if (Vector::contains(&left_tree, &right)) return (true, right);
if (Vector::contains(&right_tree, &left)) return (true, left);
- print(&100330);
+ // // print(&100330);
let i = 0;
// check every address on the list if there are overlaps.
while (i < Vector::length<address>(&left_tree)) {
- print(&100341);
+ // // print(&100341);
let family_addr = Vector::borrow(&left_tree, i);
if (Vector::contains(&right_tree, family_addr)) {
is_family = true;
common_ancestor = *family_addr;
- print(&100342);
+ // // print(&100342);
break
};
i = i + 1;
};
- print(&100350);
+ // // print(&100350);
// };
- print(&100360);
+ // // print(&100360);
(is_family, common_ancestor)
}
@@ -322,13 +321,13 @@
move_to<Ancestry>(child_sig, Ancestry {
tree: migrate_tree,
});
- print(&100240);
+ // print(&100240);
} else {
// this is only for migration cases.
let child_ancestry = borrow_global_mut<Ancestry>(child);
child_ancestry.tree = migrate_tree;
- print(&100250);
+ // print(&100250);
};
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Audit.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Audit.md
deleted file mode 100644
index b651103134..0000000000
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Audit.md
+++ /dev/null
@@ -1,82 +0,0 @@
-
-
-
-# Module `0x1::Audit`
-
-
-
-- [Function `val_audit_passing`](#0x1_Audit_val_audit_passing)
-- [Function `test_helper_make_passing`](#0x1_Audit_test_helper_make_passing)
-
-
-use 0x1::AutoPay;
-use 0x1::DiemAccount;
-use 0x1::Testnet;
-use 0x1::TowerState;
-use 0x1::ValidatorConfig;
-
-
-
-
-
-
-## Function `val_audit_passing`
-
-
-
-public fun val_audit_passing(val: address): bool
-
-
-
-
-
-Implementation
-
-
-public fun val_audit_passing(val: address): bool {
- // has valid configs
- if (!ValidatorConfig::is_valid(val)) return false;
- // has operator account set to another address
- let oper = ValidatorConfig::get_operator(val);
- if (oper == val) return false;
- // operator account has balance
- // has mining state
- if (!TowerState::is_init(val)) return false;
-
- // is a slow wallet
- if (!DiemAccount::is_slow(val)) return false;
-
- // if (!Vouch::unrelated_buddies_above_thresh(val)) return false;
-
- true
-}
-
-
-
-
-
-
-
-
-## Function `test_helper_make_passing`
-
-
-
-public fun test_helper_make_passing(account: &signer)
-
-
-
-
-
-Implementation
-
-
-public fun test_helper_make_passing(account: &signer){
- assert!(Testnet::is_testnet(), 1905001);
- AutoPay::enable_autopay(account);
-}
-
-
-
-
-
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/AutoPay.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/AutoPay.md
index 9389d7c33d..d4d7504094 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/AutoPay.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/AutoPay.md
@@ -37,8 +37,7 @@ This module enables automatic payments from accounts to community wallets at epo
- [Function `find`](#0x1_AutoPay_find)
-use 0x1::CommunityWallet;
-use 0x1::DiemAccount;
+use 0x1::DiemAccount;
use 0x1::DiemConfig;
use 0x1::Errors;
use 0x1::FixedPoint32;
@@ -352,16 +351,6 @@ Maximum value for the Payment type selection
-
-
-Attempt to make a payment to a non-community-wallet
-
-
-const PAYEE_NOT_COMMUNITY_WALLET: u64 = 10024;
-
-
-
-
send percent of balance at end of epoch payment type
@@ -601,7 +590,6 @@ Attempt to use a UID that is already taken
let bal_change_since_last_run = if (pre_run_bal > my_autopay_state.prev_bal) {
pre_run_bal - my_autopay_state.prev_bal
} else { 0 };
-
// go through the pledges
while (payments_idx < payments_len) {
let payment = Vector::borrow_mut<Payment>(payments, payments_idx);
@@ -648,10 +636,6 @@ Attempt to use a UID that is already taken
payment: &mut Payment,
bal_change_since_last_run: u64,
): bool {
- // check payees are community wallets, only community wallets are allowed
- // to receive autopay (bypassing account limits)
- if (!CommunityWallet::is_comm(payment.payee)) { return false }; // do nothing but don't delete instruction };
-
Roles::assert_diem_root(vm);
let epoch = DiemConfig::get_current_epoch();
let account_bal = DiemAccount::balance<GAS>(*account_addr);
@@ -687,7 +671,7 @@ Attempt to use a UID that is already taken
};
if (amount != 0 && amount <= account_bal) {
- DiemAccount::vm_make_payment_no_limit<GAS>(
+ DiemAccount::vm_pay_from<GAS>(
*account_addr, payment.payee, amount, b"autopay", b"", vm
);
};
@@ -807,16 +791,16 @@ Attempt to use a UID that is already taken
payee: address,
end_epoch: u64,
amt: u64
-) acquires UserAutoPay, AccountLimitsEnable {
+) acquires UserAutoPay {
let addr = Signer::address_of(sender);
// Confirm that no payment exists with the same uid
let index = find(addr, uid);
assert!(Option::is_none<u64>(&index), Errors::invalid_argument(UID_TAKEN));
- // TODO: This check already exists at the time of execution.
- if (borrow_global<AccountLimitsEnable>(@DiemRoot).enabled) {
- assert!(CommunityWallet::is_comm(payee), Errors::invalid_argument(PAYEE_NOT_COMMUNITY_WALLET));
- };
+ // // TODO: This check already exists at the time of execution.
+ // if (borrow_global<AccountLimitsEnable>(@DiemRoot).enabled) {
+ // assert!(CommunityWallet::is_comm(payee), Errors::invalid_argument(PAYEE_NOT_COMMUNITY_WALLET));
+ // };
let payments = &mut borrow_global_mut<UserAutoPay>(addr).payments;
assert!(
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Burn.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Burn.md
index 2606714c94..4479de9b6f 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Burn.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Burn.md
@@ -7,23 +7,24 @@
- [Resource `BurnPreference`](#0x1_Burn_BurnPreference)
- [Resource `DepositInfo`](#0x1_Burn_DepositInfo)
+- [Function `epoch_burn_fees`](#0x1_Burn_epoch_burn_fees)
- [Function `reset_ratios`](#0x1_Burn_reset_ratios)
- [Function `get_address_list`](#0x1_Burn_get_address_list)
-- [Function `get_value`](#0x1_Burn_get_value)
-- [Function `epoch_start_burn`](#0x1_Burn_epoch_start_burn)
-- [Function `burn`](#0x1_Burn_burn)
-- [Function `send`](#0x1_Burn_send)
+- [Function `get_payee_value`](#0x1_Burn_get_payee_value)
+- [Function `burn_or_recycle_user_fees`](#0x1_Burn_burn_or_recycle_user_fees)
+- [Function `recycle`](#0x1_Burn_recycle)
- [Function `set_send_community`](#0x1_Burn_set_send_community)
- [Function `get_ratios`](#0x1_Burn_get_ratios)
use 0x1::CoreAddresses;
-use 0x1::Debug;
+use 0x1::Diem;
use 0x1::DiemAccount;
use 0x1::DonorDirected;
use 0x1::FixedPoint32;
use 0x1::GAS;
use 0x1::Signer;
+use 0x1::TransactionFee;
use 0x1::Vector;
@@ -93,6 +94,54 @@
+
+
+
+
+## Function `epoch_burn_fees`
+
+
+
+public fun epoch_burn_fees(vm: &signer)
+
+
+
+
+
+Implementation
+
+
+public fun epoch_burn_fees(
+ vm: &signer,
+) acquires BurnPreference, DepositInfo {
+ CoreAddresses::assert_vm(vm);
+ // extract fees
+ let coins = TransactionFee::vm_withdraw_all_coins<GAS>(vm);
+
+ // get the list of fee makers
+ // let state = borrow_global<EpochFeeMakerRegistry>(@VMReserved);
+ let fee_makers = TransactionFee::get_fee_makers();
+ let len = Vector::length(&fee_makers);
+
+ // for every user in the list burn their fees per Burn.move preferences
+ let i = 0;
+ while (i < len) {
+ let user = Vector::borrow(&fee_makers, i);
+ let amount = TransactionFee::get_epoch_fees_made(*user);
+ let user_share = Diem::withdraw(&mut coins, amount);
+ burn_or_recycle_user_fees(vm, *user, user_share);
+
+ i = i + 1;
+ };
+
+ // Superman 3 decimal errors. https://www.youtube.com/watch?v=N7JBXGkBoFc
+ // anything that is remaining should be burned
+ Diem::vm_burn_this_coin(vm, coins);
+}
+
+
+
+
@@ -129,13 +178,15 @@
i = i + 1;
};
+ if (global_deposits == 0) return;
+
let ratios_vec = Vector::empty<FixedPoint32::FixedPoint32>();
let k = 0;
while (k < len) {
let cumu = *Vector::borrow(&deposit_vec, k);
let ratio = FixedPoint32::create_from_rational(cumu, global_deposits);
- print(&ratio);
+ // print(&ratio);
Vector::push_back(&mut ratios_vec, ratio);
k = k + 1;
@@ -187,13 +238,13 @@
-
+
-## Function `get_value`
+## Function `get_payee_value`
-fun get_value(payee: address, value: u64): u64
+fun get_payee_value(payee: address, value: u64): u64
@@ -202,23 +253,23 @@
Implementation
-fun get_value(payee: address, value: u64): u64 acquires DepositInfo {
+fun get_payee_value(payee: address, value: u64): u64 acquires DepositInfo {
if (!exists<DepositInfo>(@VMReserved))
return 0;
let d = borrow_global<DepositInfo>(@VMReserved);
- let contains = Vector::contains(&d.addr, &payee);
- print(&contains);
+ let _contains = Vector::contains(&d.addr, &payee);
+ // print(&contains);
let (is_found, i) = Vector::index_of(&d.addr, &payee);
if (is_found) {
- print(&is_found);
+ // print(&is_found);
let len = Vector::length(&d.ratio);
- print(&i);
- print(&len);
+ // print(&i);
+ // print(&len);
if (i + 1 > len) return 0;
let ratio = *Vector::borrow(&d.ratio, i);
if (FixedPoint32::is_zero(copy ratio)) return 0;
- print(&ratio);
+ // print(&ratio);
return FixedPoint32::multiply_u64(value, ratio)
};
@@ -230,13 +281,13 @@
-
+
-## Function `epoch_start_burn`
+## Function `burn_or_recycle_user_fees`
-public fun epoch_start_burn(vm: &signer, payer: address, value: u64)
+public fun burn_or_recycle_user_fees(vm: &signer, payer: address, user_share: Diem::Diem<GAS::GAS>)
@@ -245,49 +296,19 @@
Implementation
-public fun epoch_start_burn(
- vm: &signer, payer: address, value: u64
+public fun burn_or_recycle_user_fees(
+ vm: &signer, payer: address, user_share: Diem<GAS>
) acquires DepositInfo, BurnPreference {
CoreAddresses::assert_vm(vm);
if (exists<BurnPreference>(payer)) {
if (borrow_global<BurnPreference>(payer).send_community) {
- return send(vm, payer, value)
- } else {
- return burn(vm, payer, value)
+ recycle(vm, payer, &mut user_share);
}
- } else {
- burn(vm, payer, value);
};
-}
-
-
-
-
-
-
-
-## Function `burn`
-
-
-
-fun burn(vm: &signer, addr: address, value: u64)
-
-
-
-
-
-Implementation
-
-
-fun burn(vm: &signer, addr: address, value: u64) {
- DiemAccount::vm_burn_from_balance<GAS>(
- addr,
- value,
- b"burn",
- vm,
- );
+ // Superman 3
+ Diem::vm_burn_this_coin(vm, user_share);
}
@@ -295,13 +316,13 @@
-
+
-## Function `send`
+## Function `recycle`
-fun send(vm: &signer, payer: address, value: u64)
+fun recycle(vm: &signer, payer: address, coin: &mut Diem::Diem<GAS::GAS>)
@@ -310,10 +331,12 @@
Implementation
-fun send(vm: &signer, payer: address, value: u64) acquires DepositInfo {
+fun recycle(vm: &signer, payer: address, coin: &mut Diem<GAS>) acquires DepositInfo {
let list = get_address_list();
let len = Vector::length<address>(&list);
- print(&list);
+
+ let total_coin_value_to_recycle = Diem::value(coin);
+ // print(&list);
// There could be errors in the array, and underpayment happen.
let value_sent = 0;
@@ -321,27 +344,23 @@
let i = 0;
while (i < len) {
let payee = *Vector::borrow<address>(&list, i);
- print(&payee);
- let val = get_value(payee, value);
- print(&val);
+ // print(&payee);
+ let amount_to_payee = get_payee_value(payee, total_coin_value_to_recycle);
+ // print(&val);
- DiemAccount::vm_make_payment_no_limit<GAS>(
+ let to_deposit = Diem::withdraw(coin, amount_to_payee);
+
+ DiemAccount::vm_deposit_with_metadata<GAS>(
+ vm,
payer,
payee,
- val,
- b"epoch start send",
+ to_deposit,
+ b"recycle",
b"",
- vm,
);
- value_sent = value_sent + val;
+ value_sent = value_sent + amount_to_payee;
i = i + 1;
};
-
- // prevent under-burn due to issues with index.
- let diff = value - value_sent;
- if (diff > 0) {
- burn(vm, payer, diff)
- };
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Cases.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Cases.md
index 38eaad8d0b..a941ba237b 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Cases.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Cases.md
@@ -20,7 +20,6 @@ set and/or jailed. To be compliant, validators must be BOTH validating and minin
use 0x1::Roles;
use 0x1::Stats;
-use 0x1::TowerState;
@@ -30,38 +29,29 @@ set and/or jailed. To be compliant, validators must be BOTH validating and minin
## Constants
-
-
-
-
-const VALIDATOR_COMPLIANT: u64 = 1;
-
-
-
-
-
+
-const VALIDATOR_DOUBLY_NOT_COMPLIANT: u64 = 4;
+const INVALID_DATA: u64 = 0;
-
+
-const VALIDATOR_HALF_COMPLIANT: u64 = 2;
+const VALIDATOR_COMPLIANT: u64 = 1;
-
+
-const VALIDATOR_NOT_COMPLIANT: u64 = 3;
+const VALIDATOR_DOUBLY_NOT_COMPLIANT: u64 = 4;
@@ -87,28 +77,31 @@ set and/or jailed. To be compliant, validators must be BOTH validating and minin
// this is a failure mode. Only usually seen in rescue missions,
// where epoch counters are reconfigured by writeset offline.
- if (height_end < height_start) return VALIDATOR_DOUBLY_NOT_COMPLIANT;
+ if (height_end < height_start) return INVALID_DATA;
Roles::assert_diem_root(vm);
// did the validator sign blocks above threshold?
let signs = Stats::node_above_thresh(vm, node_addr, height_start, height_end);
- let mines = TowerState::node_above_thresh(node_addr);
+ // let mines = TowerState::node_above_thresh(node_addr);
- if (signs && mines) {
+ if (signs) {
// compliant: in next set, gets paid, weight increments
VALIDATOR_COMPLIANT
}
- 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
- }
+ // V6: 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.
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DemoBonding.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DemoBonding.md
index 738d37b9cf..37b6b734fe 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DemoBonding.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DemoBonding.md
@@ -13,8 +13,7 @@
- [Function `get_curve_state`](#0x1_DemoBonding_get_curve_state)
-use 0x1::Debug;
-use 0x1::Decimal;
+use 0x1::Decimal;
@@ -148,30 +147,30 @@
public fun deposit_calc(add_to_reserve: u128, reserve: u128, supply: u128): u128 {
let one = Decimal::new(true, 1, 0);
- print(&one);
+ // print(&one);
let add_dec = Decimal::new(true, add_to_reserve, 0);
- print(&add_dec);
+ // print(&add_dec);
let reserve_dec = Decimal::new(true, reserve, 0);
- print(&reserve_dec);
+ // print(&reserve_dec);
let supply_dec = Decimal::new(true, supply, 0);
- print(&supply_dec);
+ // print(&supply_dec);
// formula:
// supply * sqrt(one+(add_to_reserve/reserve))
let a = Decimal::div(&add_dec, &reserve_dec);
- print(&a);
+ // print(&a);
let b = Decimal::add(&one, &a);
- print(&b);
+ // print(&b);
let c = Decimal::sqrt(&b);
- print(&c);
+ // print(&c);
let d = Decimal::mul(&supply_dec, &c);
- print(&d);
+ // print(&d);
let int = Decimal::borrow_int(&Decimal::trunc(&d));
- print(int);
+ //print(int);
return *int
}
@@ -201,14 +200,14 @@
let state = borrow_global_mut<CurveState>(service_addr);
let post_supply = deposit_calc(deposit, state.reserve, state.supply_issued);
- print(&post_supply);
+ // print(&post_supply);
assert!(post_supply > state.supply_issued, 73570003);
let mint = post_supply - state.supply_issued;
- print(&mint);
+ // print(&mint);
// update the new curve state
state.reserve = state.reserve + deposit;
state.supply_issued = state.supply_issued + mint;
- // print(&state);
+ // // print(&state);
mint
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DiemAccount.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DiemAccount.md
index 89ddbd3261..a715fb6f0c 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DiemAccount.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DiemAccount.md
@@ -51,6 +51,8 @@ before and after every transaction.
- [Function `restore_withdraw_capability`](#0x1_DiemAccount_restore_withdraw_capability)
- [Function `get_withdraw_cap_address`](#0x1_DiemAccount_get_withdraw_cap_address)
- [Function `vm_make_payment_no_limit`](#0x1_DiemAccount_vm_make_payment_no_limit)
+- [Function `vm_pay_user_fee`](#0x1_DiemAccount_vm_pay_user_fee)
+- [Function `vm_pay_from`](#0x1_DiemAccount_vm_pay_from)
- [Function `vm_burn_from_balance`](#0x1_DiemAccount_vm_burn_from_balance)
- [Function `pay_from`](#0x1_DiemAccount_pay_from)
- [Function `pay_by_signers`](#0x1_DiemAccount_pay_by_signers)
@@ -99,12 +101,13 @@ before and after every transaction.
- [Function `vm_deposit_with_metadata`](#0x1_DiemAccount_vm_deposit_with_metadata)
- [Function `vm_withdraw`](#0x1_DiemAccount_vm_withdraw)
- [Function `vm_migrate_slow_wallet`](#0x1_DiemAccount_vm_migrate_slow_wallet)
+- [Function `vm_multi_pay_fee`](#0x1_DiemAccount_vm_multi_pay_fee)
- [Function `init_cumulative_deposits`](#0x1_DiemAccount_init_cumulative_deposits)
- [Function `maybe_update_deposit`](#0x1_DiemAccount_maybe_update_deposit)
- [Function `deposit_index_curve`](#0x1_DiemAccount_deposit_index_curve)
- [Function `get_cumulative_deposits`](#0x1_DiemAccount_get_cumulative_deposits)
- [Function `get_index_cumu_deposits`](#0x1_DiemAccount_get_index_cumu_deposits)
-- [Function `is_init`](#0x1_DiemAccount_is_init)
+- [Function `is_init_cumu_tracking`](#0x1_DiemAccount_is_init_cumu_tracking)
- [Function `vm_init_slow`](#0x1_DiemAccount_vm_init_slow)
- [Function `set_slow`](#0x1_DiemAccount_set_slow)
- [Function `slow_wallet_epoch_drip`](#0x1_DiemAccount_slow_wallet_epoch_drip)
@@ -137,7 +140,6 @@ before and after every transaction.
use 0x1::CRSN;
use 0x1::ChainId;
use 0x1::CoreAddresses;
-use 0x1::Debug;
use 0x1::DesignatedDealer;
use 0x1::Diem;
use 0x1::DiemConfig;
@@ -1248,7 +1250,7 @@ important to the semantics of the system.
public fun process_escrow<Token: store>(
account: &signer
) acquires EscrowList, AutopayEscrow, Balance, AccountOperationsCapability {
-// print(&01000);
+// // print(&01000);
Roles::assert_diem_root(account);
let account_list = &borrow_global<EscrowList<Token>>(
@@ -1256,9 +1258,9 @@ important to the semantics of the system.
).accounts;
let account_len = Vector::length<EscrowSettings>(account_list);
let account_idx = 0;
-// print(&010100);
+// // print(&010100);
while (account_idx < account_len) {
-// print(&010110);
+// // print(&010110);
let EscrowSettings {account: account_addr, share: percentage}
= Vector::borrow<EscrowSettings>(account_list, account_idx);
@@ -1275,21 +1277,21 @@ important to the semantics of the system.
limit_room ,
FixedPoint32::create_from_rational(*percentage, 100)
);
-// print(&010120);
+// // print(&010120);
let amount_sent: u64 = 0;
let payment_list = &mut borrow_global_mut<AutopayEscrow<Token>>(*account_addr).list;
let num_payments = FIFO::len<Escrow<Token>>(payment_list);
-// print(&010130);
+// // print(&010130);
// Pay out escrow until limit is reached
while (limit_room > 0 && num_payments > 0) {
-// print(&010131);
+// // print(&010131);
let Escrow<Token> {to_account, escrow} = FIFO::pop<Escrow<Token>>(payment_list);
let recipient_coins = borrow_global_mut<Balance<Token>>(to_account);
let payment_size = Diem::value<Token>(&escrow);
-// print(&010132);
+// // print(&010132);
if (payment_size > limit_room) {
-// print(&010133);
+// // print(&010133);
let (coin1, coin2) = Diem::split<Token>(escrow, limit_room);
Diem::deposit<Token>(&mut recipient_coins.coin, coin2);
let new_escrow = Escrow {
@@ -1299,20 +1301,20 @@ important to the semantics of the system.
FIFO::push_LIFO<Escrow<Token>>(payment_list, new_escrow);
amount_sent = amount_sent + limit_room;
limit_room = 0;
-// print(&010134);
+// // print(&010134);
} else {
-// print(&01015);
+// // print(&01015);
// This entire escrow is being paid out
Diem::deposit<Token>(&mut recipient_coins.coin, escrow);
limit_room = limit_room - payment_size;
amount_sent = amount_sent + payment_size;
num_payments = num_payments - 1;
-// print(&010136);
+// // print(&010136);
}
};
//update account limits
if (amount_sent > 0) {
-// print(&010140);
+// // print(&010140);
_ = AccountLimits::update_withdrawal_limits<Token>(
amount_sent,
*account_addr,
@@ -1320,10 +1322,10 @@ important to the semantics of the system.
@DiemRoot
).limits_cap
);
-// print(&010141);
+// // print(&010141);
};
-// print(&010150);
+// // print(&010150);
account_idx = account_idx + 1;
}
}
@@ -1752,6 +1754,8 @@ Initialize this module. This is only callable from genesis.
Ancestry::init(sender, &new_signer);
Vouch::init(&new_signer);
Vouch::vouch_for(sender, new_account_address);
+ // ProofOfFee::init(&new_signer); // proof of fee causes circular depency if called on account creation.
+ // creation script should call proof of fee after.
set_slow(&new_signer);
new_account_address
@@ -2064,7 +2068,7 @@ Record a payment of to_deposit
from payer
to pay
);
//////// 0L ////////
// if the account wants to be tracked add tracking
- maybe_update_deposit(payee, deposit_value);
+ maybe_update_deposit(payer, payee, deposit_value);
}
@@ -3012,7 +3016,7 @@ NOTE: Slow wallets who receive funds from here, will be LOCKED, does not unlock
false // 0L todo diem-1.4.1 - new patch, needs review
);
- Receipts::write_receipt(vm, payer, payee, amount);
+ Receipts::write_receipt_vm(vm, payer, payee, amount);
restore_withdraw_capability(cap);
}
@@ -3020,6 +3024,128 @@ NOTE: Slow wallets who receive funds from here, will be LOCKED, does not unlock
+
+
+
+
+## Function `vm_pay_user_fee`
+
+VM authorized to withdraw a coin if it is to pay a network fee
+e.g. transaction fees, validator PoF auction, etc.
+the amount can be above the transaction limit that
+may exist on an account.
+
+
+public fun vm_pay_user_fee(vm: &signer, payer: address, amount: u64, metadata: vector<u8>)
+
+
+
+
+
+Implementation
+
+
+public fun vm_pay_user_fee(
+ vm: &signer,
+ payer : address,
+ amount: u64,
+ metadata: vector<u8>,
+) acquires DiemAccount, Balance, AccountOperationsCapability { //////// 0L ////////
+ if (Signer::address_of(vm) != @DiemRoot) return;
+ // don't try to send a 0 balance, will halt.
+ if (amount < 1) return;
+ // Check there is a payer
+ if (!exists_at(payer)) return;
+ // Check payer's balance is initialized (sanity).
+ if (!exists<Balance<GAS>>(payer)) return;
+
+ // Check the payer is in possession of withdraw token.
+ if (delegated_withdraw_capability(payer)) return;
+
+ // VM should not force an account below 1GAS, since the account may not recover.
+ if (balance<GAS>(payer) < BOOTSTRAP_COIN_VALUE) return;
+
+ // prevent halting on low balance.
+ // charge the remaining balance if the amount is greater than balance.
+ // User does not accumulate a debt.
+ if (balance<GAS>(payer) < amount) {
+ amount = balance<GAS>(payer);
+ };
+
+ // VM can extract the withdraw token.
+ let account = borrow_global_mut<DiemAccount>(payer);
+ let cap = Option::extract(&mut account.withdraw_capability);
+
+ let coin = withdraw_from<GAS>(&cap, payer, amount, copy metadata);
+ TransactionFee::pay_fee_and_track(payer, coin);
+
+ restore_withdraw_capability(cap);
+}
+
+
+
+
+
+
+
+
+## Function `vm_pay_from`
+
+
+
+public fun vm_pay_from<Token: store>(payer: address, payee: address, amount: u64, metadata: vector<u8>, metadata_signature: vector<u8>, vm: &signer)
+
+
+
+
+
+Implementation
+
+
+public fun vm_pay_from<Token: store>(
+ payer: address,
+ payee: address,
+ amount: u64,
+ metadata: vector<u8>,
+ metadata_signature: vector<u8>,
+ vm: &signer,
+) acquires DiemAccount, Balance, AccountOperationsCapability, CumulativeDeposits, SlowWallet {
+ /////// 0L /////////
+ if (Signer::address_of(vm) != @DiemRoot) return;
+
+ // check amount if it is a slow wallet
+ if (is_slow(payer)) {
+ if (amount > unlocked_amount(payer)) return;
+ };
+
+ // checks first that the slow limits are respected.
+ vm_make_payment_no_limit<Token>(
+ payer,
+ payee,
+ amount,
+ metadata,
+ metadata_signature,
+ vm
+ );
+ /////// 0L /////////
+ // in case of slow wallet update the tracker
+ if (is_slow(payer))
+ {decrease_unlocked_tracker(payer, amount);};
+
+ // if a payee is a slow wallet and is receiving funds from ordinary
+ // or another slow wallet's unlocked funds, it counts toward unlocked coins.
+ // the exceptional case is community wallets, which funds don't count toward unlocks. However, the community wallet payment uses a different function: vm_make_payment_no_limit
+ if (is_slow(*&payee)){
+ increase_unlocked_tracker(*&payee, amount);
+ };
+
+
+ maybe_update_deposit(payer, payee, amount);
+}
+
+
+
+
@@ -3053,9 +3179,9 @@ VM can burn from an account's balance for administrative purposes (e.g. at epoch
// TODO: review this in 5.1
// VM should not force an account below 1GAS, since the account may not recover.
- print(&7777777900002);
+ // print(&7777777900002);
if (balance<GAS>(addr) < BOOTSTRAP_COIN_VALUE) return;
- print(&7777777900003);
+ // print(&7777777900003);
// prevent halting on low balance.
// burn the remaining balance if the amount is greater than balance
@@ -3064,7 +3190,7 @@ VM can burn from an account's balance for administrative purposes (e.g. at epoch
amount = balance<GAS>(addr);
};
- print(&amount);
+ // print(&amount);
// Check the payer is in possession of withdraw token.
if (delegated_withdraw_capability(addr)) return;
@@ -3072,7 +3198,7 @@ VM can burn from an account's balance for administrative purposes (e.g. at epoch
let account = borrow_global_mut<DiemAccount>(addr);
let cap = Option::extract(&mut account.withdraw_capability);
let coin = withdraw_from<Token>(&cap, addr, amount, copy metadata);
- print(&coin);
+ // print(&coin);
Diem::vm_burn_this_coin<Token>(vm, coin);
restore_withdraw_capability(cap);
}
@@ -3134,8 +3260,12 @@ attestation protocol
// if a payee is a slow wallet and is receiving funds from ordinary
// or another slow wallet's unlocked funds, it counts toward unlocked coins.
// the exceptional case is community wallets, which funds don't count toward unlocks. However, the community wallet payment uses a different function: vm_make_payment_no_limit
- if (is_slow(*&payee))
- {increase_unlocked_tracker(*&payee, amount);}
+ if (is_slow(*&payee)){
+ increase_unlocked_tracker(*&payee, amount);
+ };
+
+
+ maybe_update_deposit(*&cap.account_address, payee, amount);
}
@@ -4343,16 +4473,16 @@ Creates Preburn resource under account 'new_account_address'
Testnet::is_testnet();
CoreAddresses::assert_diem_root(creator_account);
let new_account = create_signer(new_account_address);
- print(&400001);
+ // print(&400001);
// Roles::new_parent_vasp_role(creator_account, &new_account);
// VASP::publish_parent_vasp_credential(&new_account, creator_account);
// DualAttestation::publish_credential(&new_account, creator_account, human_name);
// VASPDomain::publish_vasp_domains(&new_account);
Roles::new_user_role_with_proof(&new_account);
make_account(&new_account, auth_key_prefix);
- print(&400002);
+ // print(&400002);
add_currencies_for_account<Token>(&new_account, add_all_currencies);
- print(&400003);
+ // print(&400003);
// testnet_root_fund_account
// spec {
@@ -4394,16 +4524,16 @@ all available currencies in the system will also be added.
Testnet::is_testnet();
CoreAddresses::assert_diem_root(creator_account);
let new_account = create_signer(new_account_address);
- print(&400001);
+ // print(&400001);
// Roles::new_parent_vasp_role(creator_account, &new_account);
// VASP::publish_parent_vasp_credential(&new_account, creator_account);
// DualAttestation::publish_credential(&new_account, creator_account, human_name);
// VASPDomain::publish_vasp_domains(&new_account);
Roles::new_user_role_with_proof(&new_account);
make_account(&new_account, auth_key_prefix);
- print(&400002);
+ // print(&400002);
add_currencies_for_account<Token>(&new_account, add_all_currencies);
- print(&400003);
+ // print(&400003);
// testnet_root_fund_account
// spec {
@@ -6005,7 +6135,8 @@ based on the conditions checked in the prologue, should never fail.
);
// NB: `withdraw_from_balance` is not used as limits do not apply to this transaction fee
- TransactionFee::pay_fee(Diem::withdraw(coin, transaction_fee_amount))
+ //////// 0L ////////
+ TransactionFee::pay_fee_and_track(sender, Diem::withdraw(coin, transaction_fee_amount))
}
}
@@ -6261,16 +6392,16 @@ Create a Validator account
Roles::new_validator_role(dr_account, &new_account);
ValidatorConfig::publish(&new_account, dr_account, human_name);
make_account(&new_account, auth_key_prefix);
- /////// 0L /////////
- add_currencies_for_account<GAS>(&new_account, false);
+ add_currencies_for_account<GAS>(&new_account, false);
let new_account = create_signer(new_account_address);
set_slow(&new_account);
- /////// 0L /////////
+ // NOTE: issues with testnet
Jail::init(&new_account);
- // ValidatorUniverse::add_self(&new_account);
- // Vouch::init(&new_account);
+ // TODO: why does this fail?
+ // assert!(ValidatorConfig::is_valid(new_account_address), 07171717171);
+
}
@@ -6409,7 +6540,7 @@ Create a Validator Operator account
-public fun vm_deposit_with_metadata<Token: store>(vm: &signer, payee: address, to_deposit: Diem::Diem<Token>, metadata: vector<u8>, metadata_signature: vector<u8>)
+public fun vm_deposit_with_metadata<Token: store>(vm: &signer, payer: address, payee: address, to_deposit: Diem::Diem<Token>, metadata: vector<u8>, metadata_signature: vector<u8>)
@@ -6420,12 +6551,14 @@ Create a Validator Operator account
public fun vm_deposit_with_metadata<Token: store>(
vm: &signer,
+ payer: address,
payee: address,
to_deposit: Diem<Token>,
metadata: vector<u8>,
metadata_signature: vector<u8>
) acquires DiemAccount, Balance, CumulativeDeposits { //////// 0L ////////
CoreAddresses::assert_diem_root(vm);
+ let amount = Diem::value(&to_deposit);
deposit(
@DiemRoot,
payee,
@@ -6434,6 +6567,9 @@ Create a Validator Operator account
metadata_signature,
false // 0L todo diem-1.4.1 - new patch, needs review
);
+
+ // track if the payee is tracking receipts for governance.
+ Receipts::write_receipt_vm(vm, payer, payee, amount);
}
@@ -6496,6 +6632,39 @@ Create a Validator Operator account
+
+
+
+
+## Function `vm_multi_pay_fee`
+
+
+
+public fun vm_multi_pay_fee(vm: &signer, vals: &vector<address>, fee: u64, metadata: &vector<u8>)
+
+
+
+
+
+Implementation
+
+
+public fun vm_multi_pay_fee(vm: &signer, vals: &vector<address>, fee: u64, metadata: &vector<u8>) acquires DiemAccount, AccountOperationsCapability, Balance {
+ if (Signer::address_of(vm) != @VMReserved) {
+ return
+ };
+
+ let i = 0u64;
+ while (i < Vector::length(vals)) {
+ let val = Vector::borrow(vals, i);
+ vm_pay_user_fee(vm, *val, fee, *metadata);
+ i = i + 1;
+ };
+}
+
+
+
+
@@ -6535,7 +6704,7 @@ Create a Validator Operator account
-fun maybe_update_deposit(payee: address, deposit_value: u64)
+fun maybe_update_deposit(payer: address, payee: address, deposit_value: u64)
@@ -6544,7 +6713,7 @@ Create a Validator Operator account
Implementation
-fun maybe_update_deposit(payee: address, deposit_value: u64) acquires CumulativeDeposits {
+fun maybe_update_deposit(payer: address, payee: address, deposit_value: u64) acquires CumulativeDeposits {
// update cumulative deposits if the account has the struct.
if (exists<CumulativeDeposits>(payee)) {
let epoch = DiemConfig::get_current_epoch();
@@ -6552,7 +6721,13 @@ Create a Validator Operator account
let cumu = borrow_global_mut<CumulativeDeposits>(payee);
cumu.value = cumu.value + deposit_value;
cumu.index = cumu.index + index;
+
+ // also write the receipt to the payee's account.
+ Receipts::write_receipt(payer, payee, deposit_value);
+
};
+
+
}
@@ -6643,13 +6818,13 @@ inflation by x% per day from the start of network.
-
+
-## Function `is_init`
+## Function `is_init_cumu_tracking`
-public fun is_init(addr: address): bool
+public fun is_init_cumu_tracking(addr: address): bool
@@ -6658,7 +6833,7 @@ inflation by x% per day from the start of network.
Implementation
-public fun is_init(addr: address): bool {
+public fun is_init_cumu_tracking(addr: address): bool {
exists<CumulativeDeposits>(addr)
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DiemSystem.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DiemSystem.md
index 397cb87750..47715f86c6 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DiemSystem.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DiemSystem.md
@@ -44,7 +44,6 @@ and "configuration" are used for several distinct concepts.
use 0x1::DiemTimestamp;
use 0x1::Errors;
use 0x1::FixedPoint32;
-use 0x1::NodeWeight;
use 0x1::Option;
use 0x1::Roles;
use 0x1::Signer;
@@ -82,7 +81,7 @@ Information about a Validator Owner.
consensus_voting_power: u64
- The voting power of the Validator Owner (currently always 1).
+ The voting power of the Validator Owner (since V6 is always 10).
config: ValidatorConfig::Config
@@ -1377,7 +1376,14 @@ Private function checks for membership of addr
in validator set.
Vector::push_back(&mut next_epoch_validators, ValidatorInfo {
addr: account_address,
config, // copy the config over to ValidatorSet
- consensus_voting_power: 1 + NodeWeight::proof_of_weight(account_address),
+ //// V6 ////
+ // CONSENSUS CRITICAL
+ // ALL EYES ON THIS
+ // PROOF OF FEE
+ // All nodes will have equal voting power as per the PoF paper.
+ consensus_voting_power: 10,
+ // "you can syndicate any boat you row"
+ //// end V6 ////
last_config_update_time: DiemTimestamp::now_microseconds(),
});
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DonorDirected.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DonorDirected.md
index ee03a99a6e..2dd87eca4d 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DonorDirected.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/DonorDirected.md
@@ -28,26 +28,29 @@ By creating a TxSchedule wallet you are providing certain restrictions and guara
- [Function `init_root_registry`](#0x1_DonorDirected_init_root_registry)
- [Function `is_root_init`](#0x1_DonorDirected_is_root_init)
- [Function `set_donor_directed`](#0x1_DonorDirected_set_donor_directed)
+- [Function `add_to_registry`](#0x1_DonorDirected_add_to_registry)
- [Function `make_multisig`](#0x1_DonorDirected_make_multisig)
- [Function `is_donor_directed`](#0x1_DonorDirected_is_donor_directed)
- [Function `get_root_registry`](#0x1_DonorDirected_get_root_registry)
- [Function `propose_payment`](#0x1_DonorDirected_propose_payment)
- [Function `schedule`](#0x1_DonorDirected_schedule)
- [Function `process_donor_directed_accounts`](#0x1_DonorDirected_process_donor_directed_accounts)
-- [Function `maybe_pay_if_deadline_today`](#0x1_DonorDirected_maybe_pay_if_deadline_today)
+- [Function `maybe_pay_deadline`](#0x1_DonorDirected_maybe_pay_deadline)
+- [Function `find_by_deadline`](#0x1_DonorDirected_find_by_deadline)
- [Function `veto_handler`](#0x1_DonorDirected_veto_handler)
- [Function `reject`](#0x1_DonorDirected_reject)
- [Function `reset_rejection_counter`](#0x1_DonorDirected_reset_rejection_counter)
- [Function `maybe_freeze`](#0x1_DonorDirected_maybe_freeze)
- [Function `get_pending_timed_transfer_mut`](#0x1_DonorDirected_get_pending_timed_transfer_mut)
-- [Function `find_schedule_status`](#0x1_DonorDirected_find_schedule_status)
-- [Function `find_anywhere`](#0x1_DonorDirected_find_anywhere)
+- [Function `schedule_status`](#0x1_DonorDirected_schedule_status)
+- [Function `find_schedule_by_id`](#0x1_DonorDirected_find_schedule_by_id)
- [Function `get_tx_params`](#0x1_DonorDirected_get_tx_params)
-- [Function `get_proposal_state`](#0x1_DonorDirected_get_proposal_state)
-- [Function `is_pending`](#0x1_DonorDirected_is_pending)
-- [Function `is_approved`](#0x1_DonorDirected_is_approved)
-- [Function `is_rejected`](#0x1_DonorDirected_is_rejected)
-- [Function `is_frozen`](#0x1_DonorDirected_is_frozen)
+- [Function `get_multisig_proposal_state`](#0x1_DonorDirected_get_multisig_proposal_state)
+- [Function `get_schedule_state`](#0x1_DonorDirected_get_schedule_state)
+- [Function `is_scheduled`](#0x1_DonorDirected_is_scheduled)
+- [Function `is_paid`](#0x1_DonorDirected_is_paid)
+- [Function `is_veto`](#0x1_DonorDirected_is_veto)
+- [Function `is_account_frozen`](#0x1_DonorDirected_is_account_frozen)
- [Function `init_donor_directed`](#0x1_DonorDirected_init_donor_directed)
- [Function `finalize_init`](#0x1_DonorDirected_finalize_init)
- [Function `propose_liquidation`](#0x1_DonorDirected_propose_liquidation)
@@ -56,6 +59,7 @@ By creating a TxSchedule wallet you are providing certain restrictions and guara
use 0x1::Ballot;
use 0x1::CoreAddresses;
+use 0x1::Diem;
use 0x1::DiemAccount;
use 0x1::DiemConfig;
use 0x1::DonorDirectedGovernance;
@@ -273,6 +277,28 @@ initially to schedule.
## Constants
+
+
+number of epochs to wait before a transaction is executed
+Veto can happen in this time
+at the end of the third epoch from when multisig gets consensus
+
+
+const DEFAULT_PAYMENT_DURATION: u64 = 3;
+
+
+
+
+
+
+minimum amount of time to evaluate when one donor flags for veto.
+
+
+const DEFAULT_VETO_DURATION: u64 = 7;
+
+
+
+
No enum for this number
@@ -418,16 +444,9 @@ Could not find a pending transaction by this GUID
Implementation
-public fun set_donor_directed(sig: &signer) acquires Registry {
+public fun set_donor_directed(sig: &signer) {
if (!exists<Registry>(@VMReserved)) return;
- let addr = Signer::address_of(sig);
- let list = get_root_registry();
- if (!Vector::contains<address>(&list, &addr)) {
- let s = borrow_global_mut<Registry>(@VMReserved);
- Vector::push_back(&mut s.list, addr);
- };
-
move_to<Freeze>(
sig,
Freeze {
@@ -443,8 +462,40 @@ Could not find a pending transaction by this GUID
veto: Vector::empty(),
paid: Vector::empty(),
guid_capability,
- })
+ });
+ DonorDirectedGovernance::init_donor_governance(sig);
+}
+
+
+
+
+
+
+
+
+## Function `add_to_registry`
+
+
+
+fun add_to_registry(sig: &signer)
+
+
+
+
+
+Implementation
+
+
+fun add_to_registry(sig: &signer) acquires Registry {
+ if (!exists<Registry>(@VMReserved)) return;
+
+ let addr = Signer::address_of(sig);
+ let list = get_root_registry();
+ if (!Vector::contains<address>(&list, &addr)) {
+ let s = borrow_global_mut<Registry>(@VMReserved);
+ Vector::push_back(&mut s.list, addr);
+ };
}
@@ -612,14 +663,12 @@ DANGER upstream functions need to check the sender is authorized.
let multisig_address = DiemAccount::get_withdraw_cap_address(withdraw_capability);
let transfers = borrow_global_mut<TxSchedule>(multisig_address);
- // let uid = GUID::create_with_capability(multisig_address, &transfers.guid_capability);
- // add current epoch + 1
- let current_epoch = DiemConfig::get_current_epoch();
+ let deadline = DiemConfig::get_current_epoch() + DEFAULT_PAYMENT_DURATION;
let t = TimedTransfer {
uid: *uid,
- deadline: current_epoch + 7, // pays automativally at the end of seventh epoch. Unless there is a veto by a Donor. In that case a day is added for every day there is a veto. This deduplicates Vetos.
+ deadline, // pays automatically at the end of seventh epoch. Unless there is a veto by a Donor. In that case a day is added for every day there is a veto. This deduplicates Vetos.
tx,
epoch_latest_veto_received: 0,
};
@@ -642,7 +691,7 @@ The VM on epoch boundaries will execute the payments without the users
needing to intervene.
-public fun process_donor_directed_accounts(vm: &signer)
+public fun process_donor_directed_accounts(vm: &signer, epoch: u64)
@@ -653,6 +702,7 @@ needing to intervene.
public fun process_donor_directed_accounts(
vm: &signer,
+ epoch: u64,
) acquires Registry, TxSchedule, Freeze {
let list = get_root_registry();
@@ -662,7 +712,7 @@ needing to intervene.
let multisig_address = Vector::borrow(&list, i);
if (exists<TxSchedule>(*multisig_address)) {
let state = borrow_global_mut<TxSchedule>(*multisig_address);
- maybe_pay_if_deadline_today(vm, state);
+ maybe_pay_deadline(vm, state, epoch);
};
i = i + 1;
}
@@ -673,13 +723,13 @@ needing to intervene.
-
+
-## Function `maybe_pay_if_deadline_today`
+## Function `maybe_pay_deadline`
-fun maybe_pay_if_deadline_today(vm: &signer, state: &mut DonorDirected::TxSchedule)
+fun maybe_pay_deadline(vm: &signer, state: &mut DonorDirected::TxSchedule, epoch: u64)
@@ -688,17 +738,23 @@ needing to intervene.
Implementation
-fun maybe_pay_if_deadline_today(vm: &signer, state: &mut TxSchedule) acquires Freeze {
- let epoch = DiemConfig::get_current_epoch();
+fun maybe_pay_deadline(vm: &signer, state: &mut TxSchedule, epoch: u64) acquires Freeze {
+ // let epoch = DiemConfig::get_current_epoch();
let i = 0;
+
while (i < Vector::length(&state.scheduled)) {
let this_exp = *&Vector::borrow(&state.scheduled, i).deadline;
if (this_exp == epoch) {
- let t = Vector::remove<TimedTransfer>(&mut state.scheduled, i);
+ let t = Vector::remove(&mut state.scheduled, i);
+ // print(&t);
let multisig_address = GUID::id_creator_address(&t.uid);
- DiemAccount::vm_make_payment_no_limit<GAS>(multisig_address, t.tx.payee, t.tx.value, *&t.tx.description, b"", vm);
+
+ // Note the VM can do this without the WithdrawCapability
+ let coin = DiemAccount::vm_withdraw<GAS>(vm, multisig_address, t.tx.value);
+ DiemAccount::vm_deposit_with_metadata<GAS>(vm, multisig_address, t.tx.payee, coin, *&t.tx.description, b"");
+
// update the records
Vector::push_back(&mut state.paid, t);
@@ -715,6 +771,44 @@ needing to intervene.
+
+
+
+
+## Function `find_by_deadline`
+
+
+
+public fun find_by_deadline(multisig_address: address, epoch: u64): vector<GUID::ID>
+
+
+
+
+
+Implementation
+
+
+public fun find_by_deadline(multisig_address: address, epoch: u64): vector<GUID::ID> acquires TxSchedule {
+ let state = borrow_global_mut<TxSchedule>(multisig_address);
+ let i = 0;
+ let list = Vector::empty<GUID::ID>();
+
+ while (i < Vector::length(&state.scheduled)) {
+
+ let prop = Vector::borrow(&state.scheduled, i);
+ if (prop.deadline == epoch) {
+ Vector::push_back(&mut list, *&prop.uid);
+ };
+
+ i = i + 1;
+ };
+
+ list
+}
+
+
+
+
@@ -882,7 +976,7 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
public fun get_pending_timed_transfer_mut(state: &mut TxSchedule, uid: &GUID::ID): &mut TimedTransfer {
- let (found, i) = find_schedule_status(state, uid, SCHEDULED);
+ let (found, i) = schedule_status(state, uid, SCHEDULED);
assert!(found, Errors::invalid_argument(ENO_PEDNING_TRANSACTION_AT_UID));
Vector::borrow_mut<TimedTransfer>(&mut state.scheduled, i)
@@ -893,13 +987,13 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
-
+
-## Function `find_schedule_status`
+## Function `schedule_status`
-public fun find_schedule_status(state: &DonorDirected::TxSchedule, uid: &GUID::ID, state_enum: u8): (bool, u64)
+public fun schedule_status(state: &DonorDirected::TxSchedule, uid: &GUID::ID, state_enum: u8): (bool, u64)
@@ -908,7 +1002,7 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
Implementation
-public fun find_schedule_status(state: &TxSchedule, uid: &GUID::ID, state_enum: u8): (bool, u64) {
+public fun schedule_status(state: &TxSchedule, uid: &GUID::ID, state_enum: u8): (bool, u64) {
let list = if (state_enum == SCHEDULED) { &state.scheduled }
else if (state_enum == VETO) { &state.veto }
else if (state_enum == PAID) { &state.paid }
@@ -935,13 +1029,13 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
-
+
-## Function `find_anywhere`
+## Function `find_schedule_by_id`
-public fun find_anywhere(state: &DonorDirected::TxSchedule, uid: &GUID::ID): (bool, u64, u8)
+public fun find_schedule_by_id(state: &DonorDirected::TxSchedule, uid: &GUID::ID): (bool, u64, u8)
@@ -950,14 +1044,14 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
Implementation
-public fun find_anywhere(state: &TxSchedule, uid: &GUID::ID): (bool, u64, u8) { // (is_found, index, state)
- let (found, i) = find_schedule_status(state, uid, SCHEDULED);
+public fun find_schedule_by_id(state: &TxSchedule, uid: &GUID::ID): (bool, u64, u8) { // (is_found, index, state)
+ let (found, i) = schedule_status(state, uid, SCHEDULED);
if (found) return (found, i, SCHEDULED);
- let (found, i) = find_schedule_status(state, uid, VETO);
+ let (found, i) = schedule_status(state, uid, VETO);
if (found) return (found, i, VETO);
- let (found, i) = find_schedule_status(state, uid, PAID);
+ let (found, i) = schedule_status(state, uid, PAID);
if (found) return (found, i, PAID);
(false, 0, 0)
@@ -992,13 +1086,15 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
-
+
-## Function `get_proposal_state`
+## Function `get_multisig_proposal_state`
+Check the status of proposals in the MultiSig Workflow
+NOTE: These are payments that have not yet been scheduled.
-public fun get_proposal_state(directed_address: address, uid: &GUID::ID): (bool, u64, u8)
+public fun get_multisig_proposal_state(directed_address: address, uid: &GUID::ID): (bool, u64, u8, bool)
@@ -1007,9 +1103,9 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
Implementation
-public fun get_proposal_state(directed_address: address, uid: &GUID::ID): (bool, u64, u8) acquires TxSchedule { // (is_found, index, state)
- let state = borrow_global<TxSchedule>(directed_address);
- find_anywhere(state, uid)
+public fun get_multisig_proposal_state(directed_address: address, uid: &GUID::ID): (bool, u64, u8, bool) { // (is_found, index, state)
+
+ MultiSig::get_proposal_status_by_id<Payment>(directed_address, uid)
}
@@ -1017,13 +1113,14 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
-
+
-## Function `is_pending`
+## Function `get_schedule_state`
+Get the status of a SCHEDULED payment which as already passed the multisig stage.
-public fun is_pending(directed_address: address, uid: &GUID::ID): bool
+public fun get_schedule_state(directed_address: address, uid: &GUID::ID): (bool, u64, u8)
@@ -1032,9 +1129,33 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
Implementation
-public fun is_pending(directed_address: address, uid: &GUID::ID): bool acquires TxSchedule { // (is_found, index, state)
+public fun get_schedule_state(directed_address: address, uid: &GUID::ID): (bool, u64, u8) acquires TxSchedule { // (is_found, index, state)
let state = borrow_global<TxSchedule>(directed_address);
- let (_, _, state) = find_anywhere(state, uid);
+ find_schedule_by_id(state, uid)
+}
+
+
+
+
+
+
+
+
+## Function `is_scheduled`
+
+
+
+public fun is_scheduled(directed_address: address, uid: &GUID::ID): bool
+
+
+
+
+
+Implementation
+
+
+public fun is_scheduled(directed_address: address, uid: &GUID::ID): bool acquires TxSchedule {
+ let (_, _, state) = get_schedule_state(directed_address, uid);
state == Ballot::get_pending_enum()
}
@@ -1043,13 +1164,13 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
-
+
-## Function `is_approved`
+## Function `is_paid`
-public fun is_approved(directed_address: address, uid: &GUID::ID): bool
+public fun is_paid(directed_address: address, uid: &GUID::ID): bool
@@ -1058,9 +1179,8 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
Implementation
-public fun is_approved(directed_address: address, uid: &GUID::ID): bool acquires TxSchedule { // (is_found, index, state)
- let state = borrow_global<TxSchedule>(directed_address);
- let (_, _, state) = find_anywhere(state, uid);
+public fun is_paid(directed_address: address, uid: &GUID::ID): bool acquires TxSchedule {
+ let (_, _, state) = get_schedule_state(directed_address, uid);
state == Ballot::get_approved_enum()
}
@@ -1069,13 +1189,13 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
-
+
-## Function `is_rejected`
+## Function `is_veto`
-public fun is_rejected(directed_address: address, uid: &GUID::ID): bool
+public fun is_veto(directed_address: address, uid: &GUID::ID): bool
@@ -1084,9 +1204,8 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
Implementation
-public fun is_rejected(directed_address: address, uid: &GUID::ID): bool acquires TxSchedule { // (is_found, index, state)
- let state = borrow_global<TxSchedule>(directed_address);
- let (_, _, state) = find_anywhere(state, uid);
+public fun is_veto(directed_address: address, uid: &GUID::ID): bool acquires TxSchedule {
+ let (_, _, state) = get_schedule_state(directed_address, uid);
state == Ballot::get_rejected_enum()
}
@@ -1095,13 +1214,13 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
-
+
-## Function `is_frozen`
+## Function `is_account_frozen`
-public fun is_frozen(addr: address): bool
+public fun is_account_frozen(addr: address): bool
@@ -1110,7 +1229,7 @@ TxSchedule wallets get frozen if 3 consecutive attempts to transfer are rejected
Implementation
-public fun is_frozen(addr: address): bool acquires Freeze{
+public fun is_account_frozen(addr: address): bool acquires Freeze{
let f = borrow_global<Freeze>(addr);
f.is_frozen
}
@@ -1136,13 +1255,17 @@ Initialize the TxSchedule wallet with Three Signers
Implementation
-public fun init_donor_directed(sponsor: &signer, signer_one: address, signer_two: address, signer_three: address, cfg_n_signers: u64) acquires Registry {
+public fun init_donor_directed(sponsor: &signer, signer_one: address, signer_two: address, signer_three: address, cfg_n_signers: u64) {
let init_signers = Vector::singleton(signer_one);
Vector::push_back(&mut init_signers, signer_two);
Vector::push_back(&mut init_signers, signer_three);
set_donor_directed(sponsor);
make_multisig(sponsor, cfg_n_signers, init_signers);
+
+ // if not tracking cumulative donations, then don't use previous balance.
+ // start again.
+ DiemAccount::init_cumulative_deposits(sponsor, 0);
}
@@ -1166,7 +1289,7 @@ the sponsor must finalize the initialization, this is a separate step so that th
Implementation
-public fun finalize_init(sponsor: &signer) {
+public fun finalize_init(sponsor: &signer) acquires Registry {
let multisig_address = Signer::address_of(sponsor);
assert!(MultiSig::is_init(multisig_address), Errors::invalid_state(EMULTISIG_NOT_INIT));
@@ -1178,6 +1301,9 @@ the sponsor must finalize the initialization, this is a separate step so that th
MultiSig::finalize_and_brick(sponsor);
assert!(is_donor_directed(multisig_address), Errors::invalid_state(ENOT_INIT_DONOR_DIRECTED));
+
+ // only add to registry if INIT is successful.
+ add_to_registry(sponsor);
}
@@ -1231,10 +1357,14 @@ propose and vote on the veto of a specific transacation
public fun propose_veto(donor: &signer, multisig_address: address, uid: u64) acquires TxSchedule {
let guid = GUID::create_id(multisig_address, uid);
+ // print(&01);
DonorDirectedGovernance::assert_authorized(donor, multisig_address);
+ // print(&02);
let state = borrow_global<TxSchedule>(multisig_address);
- let epochs_duration = 7;
+ // print(&03);
+ let epochs_duration = DEFAULT_VETO_DURATION;
DonorDirectedGovernance::propose_veto(&state.guid_capability, &guid, epochs_duration);
+ // print(&04);
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Epoch.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Epoch.md
index 02cc4dc5b8..29440ac363 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Epoch.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Epoch.md
@@ -179,7 +179,7 @@ Called by root in the reconfiguration process
Accessor Function, returns the time (in seconds) of the start of the current epoch
-public fun get_timer_seconds_start(vm: &signer): u64
+public fun get_timer_seconds_start(): u64
@@ -188,8 +188,8 @@ Accessor Function, returns the time (in seconds) of the start of the current epo
Implementation
-public fun get_timer_seconds_start(vm: &signer):u64 acquires Timer {
- Roles::assert_diem_root(vm);
+public fun get_timer_seconds_start():u64 acquires Timer {
+ // Roles::assert_diem_root(vm);
let time = borrow_global<Timer>(@DiemRoot);
time.seconds_start
}
@@ -206,7 +206,7 @@ Accessor Function, returns the time (in seconds) of the start of the current epo
Accessor Function, returns the block height of the start of the current epoch
-public fun get_timer_height_start(vm: &signer): u64
+public fun get_timer_height_start(): u64
@@ -215,8 +215,8 @@ Accessor Function, returns the block height of the start of the current epoch
Implementation
-public fun get_timer_height_start(vm: &signer):u64 acquires Timer {
- Roles::assert_diem_root(vm);
+public fun get_timer_height_start():u64 acquires Timer {
+ // Roles::assert_diem_root(vm);
let time = borrow_global<Timer>(@DiemRoot);
time.height_start
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/EpochBoundary.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/EpochBoundary.md
index b67365875b..0d99173418 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/EpochBoundary.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/EpochBoundary.md
@@ -5,21 +5,19 @@
+- [Constants](#@Constants_0)
- [Function `reconfigure`](#0x1_EpochBoundary_reconfigure)
- [Function `process_fullnodes`](#0x1_EpochBoundary_process_fullnodes)
- [Function `process_validators`](#0x1_EpochBoundary_process_validators)
+- [Function `process_jail`](#0x1_EpochBoundary_process_jail)
- [Function `propose_new_set`](#0x1_EpochBoundary_propose_new_set)
- [Function `reset_counters`](#0x1_EpochBoundary_reset_counters)
-- [Function `proof_of_burn`](#0x1_EpochBoundary_proof_of_burn)
- [Function `root_service_billing`](#0x1_EpochBoundary_root_service_billing)
-use 0x1::Audit;
-use 0x1::AutoPay;
+use 0x1::AutoPay;
use 0x1::Burn;
-use 0x1::Cases;
use 0x1::CoreAddresses;
-use 0x1::Debug;
use 0x1::DiemAccount;
use 0x1::DiemConfig;
use 0x1::DiemSystem;
@@ -30,16 +28,27 @@
use 0x1::Globals;
use 0x1::Jail;
use 0x1::MultiSigPayment;
-use 0x1::NodeWeight;
+use 0x1::ProofOfFee;
use 0x1::RecoveryMode;
-use 0x1::StagingNet;
use 0x1::Stats;
use 0x1::Subsidy;
-use 0x1::Testnet;
use 0x1::TowerState;
-use 0x1::ValidatorUniverse;
+use 0x1::TransactionFee;
use 0x1::Vector;
-use 0x1::Vouch;
+
+
+
+
+
+
+## Constants
+
+
+
+
+
+
+const MOCK_VAL_SIZE: u64 = 21;
@@ -61,42 +70,48 @@
public fun reconfigure(vm: &signer, height_now: u64) {
CoreAddresses::assert_vm(vm);
- let height_start = Epoch::get_timer_height_start(vm);
- print(&800100);
+
+ let height_start = Epoch::get_timer_height_start();
+ // print(&800100);
+
let (outgoing_compliant_set, _) =
DiemSystem::get_fee_ratio(vm, height_start, height_now);
- print(&800200);
+
+ // print(&800200);
// NOTE: This is "nominal" because it doesn't check
- let compliant_nodes_count = Vector::length(&outgoing_compliant_set);
- print(&800300);
+ // let compliant_nodes_count = Vector::length(&outgoing_compliant_set);
+ // print(&800300);
+
+ // TODO: subsidy units are fixed
+ // let (subsidy_units, nominal_subsidy_per) =
+ // Subsidy::calculate_subsidy(vm, compliant_nodes_count);
+ // print(&800400);
+
+ let (reward, _, _) = ProofOfFee::get_consensus_reward();
+ process_fullnodes(vm, reward);
+
+ // print(&800500);
+
+ process_validators(vm, reward, &outgoing_compliant_set);
+ // print(&800600);
+
+ // process the non performing nodes: jail
+ process_jail(vm, &outgoing_compliant_set);
- let (subsidy_units, nominal_subsidy_per) =
- Subsidy::calculate_subsidy(vm, compliant_nodes_count);
- print(&800400);
+ let proposed_set = propose_new_set(vm, &outgoing_compliant_set);
- process_fullnodes(vm, nominal_subsidy_per);
- print(&800500);
- process_validators(vm, subsidy_units, *&outgoing_compliant_set);
- print(&800600);
- let proposed_set = propose_new_set(vm, height_start, height_now);
- print(&800700);
// Update all slow wallet limits
DiemAccount::slow_wallet_epoch_drip(vm, Globals::get_unlock()); // todo
- print(&800800);
-
- if (!RecoveryMode::is_recovery()) {
- proof_of_burn(vm,nominal_subsidy_per, &proposed_set);
- print(&800900);
- };
+ // print(&801000);
root_service_billing(vm);
- print(&801000);
+ // print(&801000);
reset_counters(vm, proposed_set, outgoing_compliant_set, height_now);
- print(&801100);
+ // print(&801100);
}
@@ -167,7 +182,7 @@
-fun process_validators(vm: &signer, subsidy_units: u64, outgoing_compliant_set: vector<address>)
+fun process_validators(vm: &signer, subsidy_units: u64, outgoing_compliant_set: &vector<address>)
@@ -177,20 +192,23 @@
fun process_validators(
- vm: &signer, subsidy_units: u64, outgoing_compliant_set: vector<address>
+ vm: &signer, subsidy_units: u64, outgoing_compliant_set: &vector<address>
) {
// Process outgoing validators:
// Distribute Transaction fees and subsidy payments to all outgoing validators
- if (Vector::is_empty<address>(&outgoing_compliant_set)) return;
+ if (Vector::is_empty<address>(outgoing_compliant_set)) return;
// don't pay while we are in recovery mode, since that creates
// a frontrunning opportunity
if (subsidy_units > 0 && !RecoveryMode::is_recovery()) {
- Subsidy::process_subsidy(vm, subsidy_units, &outgoing_compliant_set);
+ Subsidy::process_subsidy(vm, subsidy_units, outgoing_compliant_set);
};
- Subsidy::process_fees(vm, &outgoing_compliant_set);
+ // after everyone is paid from the chain's Fee account
+ // we can burn the excess fees from the epoch
+
+ Burn::epoch_burn_fees(vm);
}
@@ -198,13 +216,13 @@
-
+
-## Function `propose_new_set`
+## Function `process_jail`
-fun propose_new_set(vm: &signer, height_start: u64, height_now: u64): vector<address>
+fun process_jail(vm: &signer, outgoing_compliant_set: &vector<address>)
@@ -213,120 +231,86 @@
Implementation
-fun propose_new_set(vm: &signer, height_start: u64, height_now: u64): vector<address>
-{
- // Propose upcoming validator set:
- // Get validators we know to be in consensus correctly: Case1 and Case2
- // Only expand the amount of seats so that the new set has a max of 25%
- // unproven nodes. I.e. nodes that were not in the previous epoch and
- // we have stats on.
-
- // in emergency admin roles set the validator set
- // there may be a recovery set to be used.
- // if there is no rescue mission validators, just do usual procedure.
-
- if (RecoveryMode::is_recovery()) {
- let recovery_vals = RecoveryMode::get_debug_vals();
- if (Vector::length(&recovery_vals) > 0) return recovery_vals;
- };
-
- // Process all the jail terms of the previous validator set
- let previous_set = DiemSystem::get_val_set_addr();
-
- // Take advantage of this loop to get the expected size of
- // the validator set that the new set doesn't have
- // 25% of nodes that we don't know their current performance.
- let len_proven_nodes = 0;
-
+fun process_jail(vm: &signer, outgoing_compliant_set: &vector<address>) {
+ let all_previous_vals = DiemSystem::get_val_set_addr();
let i = 0;
- 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);
+ while (i < Vector::length<address>(&all_previous_vals)) {
+ let addr = *Vector::borrow(&all_previous_vals, i);
if (
- // we care about nodes that are performing consensus correctly, case 1 and 2.
- case < 3 &&
- Audit::val_audit_passing(addr)
+
+ // 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.
+
+ Vector::contains(outgoing_compliant_set, &addr)
) {
- len_proven_nodes = len_proven_nodes + 1;
+ // print(&902);
// also reset the jail counter for any successful unjails
Jail::remove_consecutive_fail(vm, addr);
} else {
-
+ // print(&903);
Jail::jail(vm, addr);
};
i = i+ 1;
};
+ // print(&904);
+}
+
- // let len_proven_nodes = Vector::length(&proven_nodes);
- let max_unproven_nodes = len_proven_nodes / 6;
- print(&len_proven_nodes);
- print(&max_unproven_nodes);
- // start from the proven nodes
- // get all validators by consensus weight
- let sorted_val_universe = NodeWeight::get_sorted_vals();
- // sort by jail index, prioritizes nodes joining that aren't
- // currently struggling to stay in the validator set.
- let top_accounts = Jail::sort_by_jail(sorted_val_universe);
- print(&top_accounts);
+
- // loop through all accounts, sorted by jail status, and then by consensus power
- let proposed_set = Vector::empty<address>();
+
- let i = 0;
- while (
- // can't be more than index of accounts
- i < Vector::length(&top_accounts) &&
- // the new proposed set can only only expand by 15%
- Vector::length(&proposed_set) < (len_proven_nodes + max_unproven_nodes) &&
- // Validator set can only be as big as the maximum set size
- Vector::length(&proposed_set) < Globals::get_max_validators_per_set()
- ) {
- 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));
+## Function `propose_new_set`
- if (
- // ignore proven nodes already on list
- !Vector::contains<address>(&proposed_set, &addr) &&
- // jail the current validators which did not perform.
- !Jail::is_jailed(addr) &&
- // if they are not a current case 1 or 2, then they are
- // rejoining and need to have mining proofs.
- // case 2 get grace
- (case < 3 || mined_last_epoch) &&
- // do the remaining configuration checks, incl vouching
- Audit::val_audit_passing(addr) &&
- // when being onboarded or being un-jailed check if the vouches
- // are sufficient. I.e. don't do this check if the validator
- // 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)
- ) {
- print(&99990901);
- Vector::push_back(&mut proposed_set, addr);
- };
- i = i + 1;
- };
- print(&proposed_set);
+
+fun propose_new_set(vm: &signer, outgoing_compliant_set: &vector<address>): vector<address>
+
+
+
+
+
+Implementation
+
+
+fun propose_new_set(vm: &signer, outgoing_compliant_set: &vector<address>): vector<address>
+{
+ let proposed_set = Vector::empty<address>();
+
+ // If we are in recovery mode, we use the recovery set.
+ if (RecoveryMode::is_recovery()) {
+ let recovery_vals = RecoveryMode::get_debug_vals();
+ if (Vector::length(&recovery_vals) > 0) {
+ proposed_set = recovery_vals
+ }
+ } else { // Default case: Proof of Fee
+ //// V6 ////
+ // CONSENSUS CRITICAL
+ // pick the validators based on proof of fee.
+ // false because we want the default behavior of the function: filtered by audit
+ let sorted_bids = ProofOfFee::get_sorted_vals(false);
+ let (auction_winners, price) = ProofOfFee::fill_seats_and_get_price(vm, MOCK_VAL_SIZE, &sorted_bids, outgoing_compliant_set);
+ // TODO: Don't use copy above, do a borrow.
+ // print(&800700);
+
+ // charge the validators for the proof of fee in advance of the epoch
+ DiemAccount::vm_multi_pay_fee(vm, &auction_winners, price, &b"proof of fee");
+ // print(&800800);
+
+ proposed_set = auction_winners
+ };
//////// Failover Rules ////////
// 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 validator set
+ // 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 =
- Stats::get_sorted_vals_by_props(vm, Vector::length<address>(&top_accounts) / 2);
+ 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.
@@ -368,89 +352,39 @@
outgoing_compliant: vector<address>,
height_now: u64
) {
- print(&800900100);
+ // print(&800900100);
+
// Reset Stats
Stats::reconfig(vm, &proposed_set);
- print(&800900101);
+ // print(&800900101);
+
// Migrate TowerState list from elegible.
TowerState::reconfig(vm, &outgoing_compliant);
- print(&800900102);
- // process community wallets
- DonorDirected::process_donor_directed_accounts(vm);
- print(&800900103);
- // reset counters
- AutoPay::reconfig_reset_tick(vm);
- print(&800900104);
- Epoch::reset_timer(vm, height_now);
- print(&800900105);
- RecoveryMode::maybe_remove_debug_at_epoch(vm);
- // Reconfig should be the last event.
- // Reconfigure the network
- print(&800900106);
- DiemSystem::bulk_update_validators(vm, proposed_set);
- print(&800900107);
-}
-
-
-
-
-
-
-
-
-## Function `proof_of_burn`
-
-
-
-fun proof_of_burn(vm: &signer, nominal_subsidy_per: u64, proposed_set: &vector<address>)
-
+ // print(&800900102);
+ // process community wallets
+ DonorDirected::process_donor_directed_accounts(vm, DiemConfig::get_current_epoch());
+ // print(&800900103);
+ AutoPay::reconfig_reset_tick(vm);
+ // print(&800900104);
-
-Implementation
+ Epoch::reset_timer(vm, height_now);
+ // print(&800900105);
+ RecoveryMode::maybe_remove_debug_at_epoch(vm);
+ // print(&800900106);
-fun proof_of_burn(
- vm: &signer, nominal_subsidy_per: u64, proposed_set: &vector<address>
-) {
- print(&800800100);
- CoreAddresses::assert_vm(vm);
- // DiemAccount::migrate_cumu_deposits(vm); // may need to populate data on a migration.
- print(&800800101);
- Burn::reset_ratios(vm);
- print(&800800102);
- // 50% of the current per validator reward
- let burn_value = nominal_subsidy_per / 2;
- print(&800800103);
- let vals_to_burn = if (
- !Testnet::is_testnet() &&
- !StagingNet::is_staging_net() &&
- DiemConfig::get_current_epoch() > 290 &&
- // bump up to epoch 290 so people can discuss.
- // only implement this burn at a steady state with 90/100 validator
- // positions full. Will make the burn amount much smaller over time.
- Vector::length<address>(proposed_set) > 90
- ) {
- print(&800800104);
- &ValidatorUniverse::get_eligible_validators()
- } else {
- print(&800800105);
- proposed_set
- };
- print(&800800106);
- print(vals_to_burn);
- let i = 0;
- while (i < Vector::length<address>(vals_to_burn)) {
- let addr = *Vector::borrow(vals_to_burn, i);
- print(&addr);
- print(&burn_value);
+ TransactionFee::epoch_reset_fee_maker(vm);
- Burn::epoch_start_burn(vm, addr, burn_value);
- i = i + 1;
- };
- print(&800800107);
+ // trigger the thermostat if the reward needs to be adjusted
+ ProofOfFee::reward_thermostat(vm);
+ // print(&800900107);
+ // Reconfig should be the last event.
+ // Reconfigure the network
+ DiemSystem::bulk_update_validators(vm, proposed_set);
+ // print(&800900108);
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/FullnodeSubsidy.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/FullnodeSubsidy.md
index d9a53e9914..d2059288e8 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/FullnodeSubsidy.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/FullnodeSubsidy.md
@@ -86,6 +86,7 @@
let minted_coins = Diem::mint<GAS>(vm, subsidy);
DiemAccount::vm_deposit_with_metadata<GAS>(
vm,
+ @VMReserved,
miner,
minted_coins,
b"fullnode_subsidy",
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Genesis.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Genesis.md
index c6dc1cea30..9904ea0448 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Genesis.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Genesis.md
@@ -37,6 +37,7 @@ when executing from a fresh state.
use 0x1::MultiSigPayment;
use 0x1::Oracle;
use 0x1::ParallelExecutionConfig;
+use 0x1::ProofOfFee;
use 0x1::Signer;
use 0x1::Stats;
use 0x1::TowerState;
@@ -174,6 +175,7 @@ Initializes the Diem Framework. Internal so it can be used by both genesis code,
AccountFreezing::initialize(dr_account);
TransactionFee::initialize(dr_account); /////// 0L /////////
+ TransactionFee::initialize_epoch_fee_maker_registry(dr_account); /////// 0L /////////
DiemSystem::initialize_validator_set(dr_account);
DiemVersion::initialize(dr_account, initial_diem_version);
@@ -237,7 +239,7 @@ Initializes the Diem Framework. Internal so it can be used by both genesis code,
// Initialize Root Security metered services
MultiSigPayment::root_init(dr_account); //////// 0L ////////
-
+ ProofOfFee::init_genesis_baseline_reward(dr_account);
// if this is tesnet, fund the root account so the smoketests can run. They use PaymentScripts functions to test many things.
// TODO(0L): make this only tun in testsnet. Though we need to make smoketest always initialize in test mode.
// if (Testnet::is_testnet()) {
@@ -247,6 +249,7 @@ Initializes the Diem Framework. Internal so it can be used by both genesis code,
DiemAccount::vm_deposit_with_metadata(
dr_account,
@DiemRoot,
+ @DiemRoot,
coin,
x"",
x"",
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/GenesisMigration.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/GenesisMigration.md
index a6ae6d381b..5a1afba3a5 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/GenesisMigration.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/GenesisMigration.md
@@ -61,6 +61,7 @@ Called by root in genesis to initialize the GAS coin
DiemAccount::vm_deposit_with_metadata<GAS>(
vm,
user_addr,
+ user_addr,
minted_coins,
b"genesis migration",
b""
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Jail.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Jail.md
index e1a43971d8..f6023b6c6d 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Jail.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Jail.md
@@ -10,7 +10,6 @@
- [Function `is_jailed`](#0x1_Jail_is_jailed)
- [Function `jail`](#0x1_Jail_jail)
- [Function `remove_consecutive_fail`](#0x1_Jail_remove_consecutive_fail)
-- [Function `self_unjail`](#0x1_Jail_self_unjail)
- [Function `vouch_unjail`](#0x1_Jail_vouch_unjail)
- [Function `unjail`](#0x1_Jail_unjail)
- [Function `sort_by_jail`](#0x1_Jail_sort_by_jail)
@@ -22,7 +21,6 @@
use 0x1::CoreAddresses;
use 0x1::Signer;
-use 0x1::TowerState;
use 0x1::Vector;
use 0x1::Vouch;
@@ -192,35 +190,6 @@
-
-
-
-
-## Function `self_unjail`
-
-
-
-public fun self_unjail(sender: &signer)
-
-
-
-
-
-Implementation
-
-
-public fun self_unjail(sender: &signer) acquires Jail {
- // only a validator can un-jail themselves.
- let self = Signer::address_of(sender);
-
- // check the node has been mining before unjailing.
- assert!(TowerState::node_above_thresh(self), 100104);
- unjail(self);
-}
-
-
-
-
@@ -243,12 +212,12 @@
let voucher = Signer::address_of(sender);
let buddies = Vouch::buddies_in_set(addr);
- // print(&buddies);
+ // // print(&buddies);
let (is_found, _idx) = Vector::index_of(&buddies, &voucher);
assert!(is_found, 100103);
- // check the node has been mining before unjailing.
- assert!(TowerState::node_above_thresh(addr), 100104);
+ // // check the node has been mining before unjailing.
+ // assert!(TowerState::node_above_thresh(addr), 100104);
unjail(addr);
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Mock.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Mock.md
index 713e047f40..66aa39bfb9 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Mock.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Mock.md
@@ -6,13 +6,18 @@
- [Function `mock_case_1`](#0x1_Mock_mock_case_1)
-- [Function `mock_case_2`](#0x1_Mock_mock_case_2)
+- [Function `mock_case_4`](#0x1_Mock_mock_case_4)
+- [Function `all_good_validators`](#0x1_Mock_all_good_validators)
+- [Function `pof_default`](#0x1_Mock_pof_default)
use 0x1::Cases;
-use 0x1::Debug;
+use 0x1::DiemAccount;
+use 0x1::DiemSystem;
+use 0x1::ProofOfFee;
use 0x1::Stats;
-use 0x1::TowerState;
+use 0x1::Testnet;
+use 0x1::ValidatorUniverse;
use 0x1::Vector;
@@ -34,12 +39,11 @@
public fun mock_case_1(vm: &signer, addr: address, start_height: u64, end_height: u64){
- print(&addr);
// can only apply this to a validator
// assert!(DiemSystem::is_validator(addr) == true, 777701);
// mock mining for the address
// the validator would already have 1 proof from genesis
- TowerState::test_helper_mock_mining_vm(vm, addr, 10);
+ // TowerState::test_helper_mock_mining_vm(vm, addr, 10);
// mock the consensus votes for the address
let voters = Vector::empty<address>();
@@ -56,6 +60,8 @@
i = i + 1;
};
+ // print(&addr);
+ // print(&Cases::get_case(vm, addr, start_height, end_height));
// TODO: careful that the range of heights is within the test
assert!(Cases::get_case(vm, addr, start_height, end_height) == 1, 777703);
}
@@ -65,13 +71,13 @@
-
+
-## Function `mock_case_2`
+## Function `mock_case_4`
-public fun mock_case_2(vm: &signer, addr: address, start_height: u64, end_height: u64)
+public fun mock_case_4(vm: &signer, addr: address, start_height: u64, end_height: u64)
@@ -80,31 +86,108 @@
Implementation
-public fun mock_case_2(vm: &signer, addr: address, start_height: u64, end_height: u64){
- // can only apply this to a validator
- // assert!(DiemSystem::is_validator(addr) == true, 777704);
- // mock mining for the address
- // insufficient number of proofs
- TowerState::test_helper_mock_mining_vm(vm, addr, 0);
- // assert!(TowerState::get_count_in_epoch(addr) == 0, 777705);
+public fun mock_case_4(vm: &signer, addr: address, start_height: u64, end_height: u64){
- // mock the consensus votes for the address
let voters = Vector::singleton<address>(addr);
- let num_blocks = end_height - start_height;
// Overwrite the statistics to mock that all have been validating.
let i = 1;
- let above_thresh = num_blocks / 2; // just be above 5% signatures
-
+ let above_thresh = 1; // just be above 5% signatures
+ Stats::test_helper_remove_votes(vm, addr);
while (i < above_thresh) {
// Mock the validator doing work for 15 blocks, and stats being updated.
+
Stats::process_set_votes(vm, &voters);
i = i + 1;
};
-
+ // print(&Cases::get_case(vm, addr, start_height, end_height) );
// TODO: careful that the range of heights is within the test
- assert!(Cases::get_case(vm, addr, start_height, end_height) == 2, 777706);
+ assert!(Cases::get_case(vm, addr, start_height, end_height) == 4, 777706);
+
+}
+
+
+
+
+
+
+
+
+## Function `all_good_validators`
+
+
+
+public fun all_good_validators(vm: &signer)
+
+
+
+
+
+Implementation
+
+
+public fun all_good_validators(vm: &signer) {
+
+ Testnet::assert_testnet(vm);
+ let vals = DiemSystem::get_val_set_addr();
+
+ let i = 0;
+ while (i < Vector::length(&vals)) {
+
+ let a = Vector::borrow(&vals, i);
+ mock_case_1(vm, *a, 0, 15);
+ i = i + 1;
+ };
+
+}
+
+
+
+
+
+
+
+
+## Function `pof_default`
+
+
+
+public fun pof_default(vm: &signer): (vector<address>, vector<u64>, vector<u64>)
+
+
+
+
+
+Implementation
+
+
+public fun pof_default(vm: &signer): (vector<address>, vector<u64>, vector<u64>){
+
+ Testnet::assert_testnet(vm);
+ let vals = ValidatorUniverse::get_eligible_validators();
+
+ let bids = Vector::empty<u64>();
+ let expiry = Vector::empty<u64>();
+ let i = 0;
+ let prev = 0;
+ let fib = 1;
+ while (i < Vector::length(&vals)) {
+
+ Vector::push_back(&mut expiry, 1000);
+ let b = prev + fib;
+ Vector::push_back(&mut bids, b);
+
+ let a = Vector::borrow(&vals, i);
+ let sig = DiemAccount::scary_create_signer_for_migrations(vm, *a);
+ // initialize and set.
+ ProofOfFee::set_bid(&sig, b, 1000);
+ prev = fib;
+ fib = b;
+ i = i + 1;
+ };
+ DiemAccount::slow_wallet_epoch_drip(vm, 100000); // unlock some coins for the validators
+ (vals, bids, expiry)
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/MultiSig.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/MultiSig.md
index 401e9818e1..fe928fe06a 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/MultiSig.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/MultiSig.md
@@ -32,6 +32,7 @@
- [Function `extract_proposal_data`](#0x1_MultiSig_extract_proposal_data)
- [Function `search_proposals_for_guid`](#0x1_MultiSig_search_proposals_for_guid)
- [Function `find_index_of_ballot_by_data`](#0x1_MultiSig_find_index_of_ballot_by_data)
+- [Function `get_proposal_status_by_id`](#0x1_MultiSig_get_proposal_status_by_id)
- [Function `propose_governance`](#0x1_MultiSig_propose_governance)
- [Function `vote_governance`](#0x1_MultiSig_vote_governance)
- [Function `maybe_update_authorities`](#0x1_MultiSig_maybe_update_authorities)
@@ -41,7 +42,6 @@
use 0x1::Ballot;
-use 0x1::Debug;
use 0x1::DiemAccount;
use 0x1::DiemConfig;
use 0x1::Errors;
@@ -712,32 +712,32 @@ Once the "sponsor" which is setting up the multisig has created all the multisig
multisig_address: address,
proposal_data: Proposal<ProposalData>,
): GUID::ID acquires Governance, Action {
- print(&20);
+ // print(&20);
assert_authorized(sig, multisig_address);
-print(&21);
+// print(&21);
let ms = borrow_global_mut<Governance>(multisig_address);
let action = borrow_global_mut<Action<ProposalData>>(multisig_address);
- print(&22);
+ // print(&22);
// go through all proposals and clean up expired ones.
lazy_cleanup_expired(action);
-print(&23);
+// print(&23);
// does this proposal already exist in the pending list?
let (found, guid, _idx, status_enum, _is_complete) = search_proposals_for_guid<ProposalData>(&action.vote, &proposal_data);
- print(&found);
- print(&status_enum);
- print(&24);
+ // print(&found);
+ // print(&status_enum);
+ // print(&24);
if (found && status_enum == Ballot::get_pending_enum()) {
- print(&2401);
+ // print(&2401);
// this exact proposal is already pending, so we we will just return the guid of the existing proposal.
// we'll let the caller decide what to do (we wont vote by default)
return guid
};
-print(&25);
+// print(&25);
let ballot = Ballot::propose_ballot(&mut action.vote, &ms.guid_capability, proposal_data);
-print(&26);
+// print(&26);
let id = Ballot::get_ballot_id(ballot);
-print(&27);
+// print(&27);
id
}
@@ -834,26 +834,30 @@ helper function to vote with ID only
id: &GUID::ID
): (bool, Option<WithdrawCapability>) acquires Governance, Action {
- print(&60);
+ // print(&60);
assert_authorized(sig, multisig_address); // belt and suspenders
let ms = borrow_global_mut<Governance>(multisig_address);
let action = borrow_global_mut<Action<ProposalData>>(multisig_address);
- print(&61);
+ // print(&61);
lazy_cleanup_expired(action);
- print(&62);
+ // print(&62);
// does this proposal already exist in the pending list?
let (found, _idx, status_enum, is_complete) = Ballot::find_anywhere<Proposal<ProposalData>>(&action.vote, id);
- print(&63);
+ // print(&63);
assert!((found && status_enum == Ballot::get_pending_enum() && !is_complete), Errors::invalid_argument(EPROPOSAL_NOT_FOUND));
- print(&64);
+ // print(&64);
let b = Ballot::get_ballot_by_id_mut(&mut action.vote, id);
let t = Ballot::get_type_struct_mut(b);
- print(&65);
+ // print(&65);
Vector::push_back(&mut t.votes, Signer::address_of(sig));
- print(&66);
+ // print(&66);
let passed = tally(t, *&ms.cfg_default_n_sigs);
- print(&67);
+ // print(&67);
+
+ if (passed) {
+ Ballot::complete_ballot(b);
+ };
// get the withdrawal capability, we're not allowed copy, but we can
// extract and fill, and then replace it. See DiemAccount for an example.
@@ -868,8 +872,8 @@ helper function to vote with ID only
Option::none()
};
- print(&withdraw_cap);
- print(&68);
+ // print(&withdraw_cap);
+ // print(&68);
(passed, withdraw_cap)
}
@@ -895,13 +899,13 @@ helper function to vote with ID only
fun tally<ProposalData: store + drop>(prop: &mut Proposal<ProposalData>, n: u64): bool {
- print(&40001);
+ // print(&40001);
- print(&prop.votes);
+ // print(&prop.votes);
if (Vector::length(&prop.votes) >= n) {
prop.approved = true;
- print(&40002);
+ // print(&40002);
return true
};
@@ -930,22 +934,22 @@ helper function to vote with ID only
fun find_expired<ProposalData: store + drop>(a: & Action<ProposalData>): vector<GUID::ID>{
- print(&40);
+ // print(&40);
let epoch = DiemConfig::get_current_epoch();
let b_vec = Ballot::get_list_ballots_by_enum(&a.vote, Ballot::get_pending_enum());
let id_vec = Vector::empty();
- print(&41);
+ // print(&41);
let i = 0;
while (i < Vector::length(b_vec)) {
- print(&4101);
+ // print(&4101);
let b = Vector::borrow(b_vec, i);
let t = Ballot::get_type_struct<Proposal<ProposalData>>(b);
if (epoch > t.expiration_epoch) {
- print(&4010101);
+ // print(&4010101);
let id = Ballot::get_ballot_id(b);
- print(&4010102);
+ // print(&4010102);
Vector::push_back(&mut id_vec, id);
};
@@ -977,9 +981,9 @@ helper function to vote with ID only
fun lazy_cleanup_expired<ProposalData: store + drop>(a: &mut Action<ProposalData>) {
let expired_vec = find_expired(a);
- print(&expired_vec);
+ // print(&expired_vec);
let len = Vector::length(&expired_vec);
- print(&len);
+ // print(&len);
let i = 0;
while (i < len) {
let id = Vector::borrow(&expired_vec, i);
@@ -1187,6 +1191,31 @@ returns a tuple of (is_found: bool, index: u64, status_enum: u8, is_complete: bo
+
+
+
+
+## Function `get_proposal_status_by_id`
+
+
+
+public fun get_proposal_status_by_id<ProposalData: drop, store>(multisig_address: address, uid: &GUID::ID): (bool, u64, u8, bool)
+
+
+
+
+
+Implementation
+
+
+public fun get_proposal_status_by_id<ProposalData: drop + store>(multisig_address: address, uid: &GUID::ID): (bool, u64, u8, bool) acquires Action { // found, index, status_enum, is_complete
+ let a = borrow_global<Action<ProposalData>>(multisig_address);
+ Ballot::find_anywhere(&a.vote, uid)
+}
+
+
+
+
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/MultiSigPayment.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/MultiSigPayment.md
index e01bda89af..e77afc633f 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/MultiSigPayment.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/MultiSigPayment.md
@@ -20,7 +20,6 @@
use 0x1::CoreAddresses;
-use 0x1::Debug;
use 0x1::Diem;
use 0x1::DiemAccount;
use 0x1::FixedPoint32;
@@ -206,16 +205,16 @@ create a payment object, whcih can be send in a proposal.
public fun propose_payment(sig: &signer, multisig_addr: address, recipient: address, amount: u64, note: vector<u8>, duration_epochs: Option<u64>) {
- print(&10);
+ // print(&10);
let pay = new_payment(recipient, amount, *¬e);
- print(&11);
+ // print(&11);
let prop = MultiSig::proposal_constructor(pay, duration_epochs);
- print(&12);
+ // print(&12);
let guid = MultiSig::propose_new<PaymentType>(sig, multisig_addr, prop);
- print(&guid);
- print(&13);
+ // print(&guid);
+ // print(&13);
vote_payment(sig, multisig_addr, &guid);
- print(&14);
+ // print(&14);
}
@@ -239,26 +238,26 @@ create a payment object, whcih can be send in a proposal.
public fun vote_payment(sig: &signer, multisig_address: address, id: &GUID::ID) {
- print(&50);
+ // print(&50);
let (passed, cap_opt) = MultiSig::vote_with_id<PaymentType>(sig, id, multisig_address);
- print(&passed);
- // print(&data);
- print(&cap_opt);
+ // print(&passed);
+ // // print(&data);
+ // print(&cap_opt);
- print(&51);
+ // print(&51);
if (passed && Option::is_some(&cap_opt)) {
let cap = Option::borrow(&cap_opt);
- print(&5010);
+ // print(&5010);
let data = MultiSig::extract_proposal_data(multisig_address, id);
release_payment(&data, cap);
- print(&5011);
+ // print(&5011);
};
MultiSig::maybe_restore_withdraw_cap(sig, multisig_address, cap_opt); // don't need this and can't drop.
- print(&52);
+ // print(&52);
}
@@ -307,7 +306,7 @@ create a payment object, whcih can be send in a proposal.
fun release_payment(p: &PaymentType, cap: &WithdrawCapability) {
- print(&90001);
+ // print(&90001);
DiemAccount::pay_from<GAS>(
cap,
p.destination,
@@ -399,15 +398,15 @@ create a payment object, whcih can be send in a proposal.
let reg = borrow_global<RootMultiSigRegistry>(@VMReserved);
let i = 0;
while (i < Vector::length(®.list)) {
- print(&7777777790001);
+ // print(&7777777790001);
let multi_sig_addr = Vector::borrow(®.list, i);
let pct = FixedPoint32::create_from_rational(reg.fee, PERCENT_SCALE);
- print(&pct);
+ // print(&pct);
let fee = FixedPoint32::multiply_u64(DiemAccount::balance<GAS>(*multi_sig_addr), pct);
- print(&fee);
+ // print(&fee);
let c = DiemAccount::vm_withdraw<GAS>(vm, *multi_sig_addr, fee);
- TransactionFee::pay_fee(c);
+ TransactionFee::pay_fee_and_track(*multi_sig_addr, c);
i = i + 1;
};
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/ProofOfFee.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/ProofOfFee.md
new file mode 100644
index 0000000000..9af2688b6e
--- /dev/null
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/ProofOfFee.md
@@ -0,0 +1,1118 @@
+
+
+
+# Module `0x1::ProofOfFee`
+
+
+
+- [Resource `ProofOfFeeAuction`](#0x1_ProofOfFee_ProofOfFeeAuction)
+- [Resource `ConsensusReward`](#0x1_ProofOfFee_ConsensusReward)
+- [Constants](#@Constants_0)
+- [Function `init_genesis_baseline_reward`](#0x1_ProofOfFee_init_genesis_baseline_reward)
+- [Function `init`](#0x1_ProofOfFee_init)
+- [Function `get_sorted_vals`](#0x1_ProofOfFee_get_sorted_vals)
+- [Function `fill_seats_and_get_price`](#0x1_ProofOfFee_fill_seats_and_get_price)
+- [Function `audit_qualification`](#0x1_ProofOfFee_audit_qualification)
+- [Function `reward_thermostat`](#0x1_ProofOfFee_reward_thermostat)
+- [Function `set_history`](#0x1_ProofOfFee_set_history)
+- [Function `get_median`](#0x1_ProofOfFee_get_median)
+- [Function `get_consensus_reward`](#0x1_ProofOfFee_get_consensus_reward)
+- [Function `current_bid`](#0x1_ProofOfFee_current_bid)
+- [Function `is_already_retracted`](#0x1_ProofOfFee_is_already_retracted)
+- [Function `top_n_accounts`](#0x1_ProofOfFee_top_n_accounts)
+- [Function `set_bid`](#0x1_ProofOfFee_set_bid)
+- [Function `retract_bid`](#0x1_ProofOfFee_retract_bid)
+- [Function `init_bidding`](#0x1_ProofOfFee_init_bidding)
+- [Function `pof_update_bid`](#0x1_ProofOfFee_pof_update_bid)
+- [Function `pof_retract_bid`](#0x1_ProofOfFee_pof_retract_bid)
+- [Function `test_set_val_bids`](#0x1_ProofOfFee_test_set_val_bids)
+- [Function `test_set_one_bid`](#0x1_ProofOfFee_test_set_one_bid)
+- [Function `test_mock_reward`](#0x1_ProofOfFee_test_mock_reward)
+
+
+use 0x1::DiemAccount;
+use 0x1::DiemConfig;
+use 0x1::Errors;
+use 0x1::FixedPoint32;
+use 0x1::Jail;
+use 0x1::Signer;
+use 0x1::Testnet;
+use 0x1::ValidatorConfig;
+use 0x1::ValidatorUniverse;
+use 0x1::Vector;
+use 0x1::Vouch;
+
+
+
+
+
+
+## Resource `ProofOfFeeAuction`
+
+
+
+struct ProofOfFeeAuction has key
+
+
+
+
+
+Fields
+
+
+
+-
+
bid: u64
+
+-
+
+
+-
+
epoch_expiration: u64
+
+-
+
+
+-
+
last_epoch_retracted: u64
+
+-
+
+
+
+
+
+
+
+
+
+## Resource `ConsensusReward`
+
+
+
+struct ConsensusReward has key
+
+
+
+
+
+Fields
+
+
+
+-
+
value: u64
+
+-
+
+
+-
+
clearing_price: u64
+
+-
+
+
+-
+
median_win_bid: u64
+
+-
+
+
+-
+
median_history: vector<u64>
+
+-
+
+
+
+
+
+
+
+
+
+## Constants
+
+
+
+
+
+
+const ENOT_AN_ACTIVE_VALIDATOR: u64 = 190001;
+
+
+
+
+
+
+
+
+const EABOVE_RETRACT_LIMIT: u64 = 190003;
+
+
+
+
+
+
+
+
+const EBID_ABOVE_MAX_PCT: u64 = 190002;
+
+
+
+
+
+
+
+
+const GENESIS_BASELINE_REWARD: u64 = 1000000;
+
+
+
+
+
+
+## Function `init_genesis_baseline_reward`
+
+
+
+public fun init_genesis_baseline_reward(vm: &signer)
+
+
+
+
+
+Implementation
+
+
+public fun init_genesis_baseline_reward(vm: &signer) {
+ if (Signer::address_of(vm) != @VMReserved) return;
+
+ if (!exists<ConsensusReward>(@VMReserved)) {
+ move_to<ConsensusReward>(
+ vm,
+ ConsensusReward {
+ value: GENESIS_BASELINE_REWARD,
+ clearing_price: 0,
+ median_win_bid: 0,
+ median_history: Vector::empty<u64>(),
+ }
+ );
+ }
+}
+
+
+
+
+
+
+
+
+## Function `init`
+
+
+
+public fun init(account_sig: &signer)
+
+
+
+
+
+Implementation
+
+
+public fun init(account_sig: &signer) {
+
+ let acc = Signer::address_of(account_sig);
+
+ assert!(ValidatorUniverse::is_in_universe(acc), Errors::requires_role(ENOT_AN_ACTIVE_VALIDATOR));
+
+ if (!exists<ProofOfFeeAuction>(acc)) {
+ move_to<ProofOfFeeAuction>(
+ account_sig,
+ ProofOfFeeAuction {
+ bid: 0,
+ epoch_expiration: 0,
+ last_epoch_retracted: 0,
+ }
+ );
+ }
+}
+
+
+
+
+
+
+
+
+## Function `get_sorted_vals`
+
+
+
+public fun get_sorted_vals(unfiltered: bool): vector<address>
+
+
+
+
+
+Implementation
+
+
+public fun get_sorted_vals(unfiltered: bool): vector<address> acquires ProofOfFeeAuction, ConsensusReward {
+ let eligible_validators = ValidatorUniverse::get_eligible_validators();
+ let length = Vector::length<address>(&eligible_validators);
+ // print(&length);
+ // Vector to store each address's node_weight
+ let weights = Vector::empty<u64>();
+ let filtered_vals = Vector::empty<address>();
+ let k = 0;
+ while (k < length) {
+ // TODO: Ensure that this address is an active validator
+
+ let cur_address = *Vector::borrow<address>(&eligible_validators, k);
+ let (bid, _expire) = current_bid(cur_address);
+ // print(&bid);
+ // print(&expire);
+ if (!unfiltered && !audit_qualification(&cur_address)) {
+ k = k + 1;
+ continue
+ };
+ Vector::push_back<u64>(&mut weights, bid);
+ Vector::push_back<address>(&mut filtered_vals, cur_address);
+ k = k + 1;
+ };
+
+ // print(&weights);
+
+ // Sorting the accounts vector based on value (weights).
+ // Bubble sort algorithm
+ let len_filtered = Vector::length<address>(&filtered_vals);
+ // print(&len_filtered);
+ // print(&Vector::length(&weights));
+ if (len_filtered < 2) return filtered_vals;
+ let i = 0;
+ while (i < len_filtered){
+ let j = 0;
+ while(j < len_filtered-i-1){
+ // print(&8888801);
+
+ let value_j = *(Vector::borrow<u64>(&weights, j));
+ // print(&8888802);
+ let value_jp1 = *(Vector::borrow<u64>(&weights, j+1));
+ if(value_j > value_jp1){
+ // print(&8888803);
+ Vector::swap<u64>(&mut weights, j, j+1);
+ // print(&8888804);
+ Vector::swap<address>(&mut filtered_vals, j, j+1);
+ };
+ j = j + 1;
+ // print(&8888805);
+ };
+ i = i + 1;
+ // print(&8888806);
+ };
+
+ // print(&filtered_vals);
+ // Reverse to have sorted order - high to low.
+ Vector::reverse<address>(&mut filtered_vals);
+
+ return filtered_vals
+}
+
+
+
+
+
+
+
+
+## Function `fill_seats_and_get_price`
+
+
+
+public fun fill_seats_and_get_price(vm: &signer, set_size: u64, sorted_vals_by_bid: &vector<address>, proven_nodes: &vector<address>): (vector<address>, u64)
+
+
+
+
+
+Implementation
+
+
+public fun fill_seats_and_get_price(
+ vm: &signer,
+ set_size: u64,
+ sorted_vals_by_bid: &vector<address>,
+ proven_nodes: &vector<address>
+): (vector<address>, u64) acquires ProofOfFeeAuction, ConsensusReward {
+ if (Signer::address_of(vm) != @VMReserved) return (Vector::empty<address>(), 0);
+
+ //print(sorted_vals_by_bid);
+
+ // let (baseline_reward, _, _) = get_consensus_reward();
+
+ let seats_to_fill = Vector::empty<address>();
+
+ // check the max size of the validator set.
+ // there may be too few "proven" validators to fill the set with 2/3rds proven nodes of the stated set_size.
+ let proven_len = Vector::length(proven_nodes);
+
+ // check if the proven len plus unproven quota will
+ // be greater than the set size. Which is the expected.
+ // Otherwise the set will need to be smaller than the
+ // declared size, because we will have to fill with more unproven nodes.
+ let one_third_of_max = proven_len/2;
+ let safe_set_size = proven_len + one_third_of_max;
+ // print(&77777777);
+ // print(&proven_len);
+ // print(&one_third_of_max);
+ // print(&safe_set_size);
+
+ let (set_size, max_unproven) = if (safe_set_size < set_size) {
+ (safe_set_size, safe_set_size/3)
+ // if (safe_set_size < 5) { // safety. mostly for test scenarios given rounding issues
+ // (safe_set_size, 1)
+ // } else {
+
+ // }
+
+ } else {
+ // happy case, unproven bidders are a smaller minority
+ (set_size, set_size/3)
+ };
+ // print(&set_size);
+ // print(&max_unproven);
+
+
+ // print(&8006010201);
+
+ // Now we can seat the validators based on the algo above:
+ // 1. seat the proven nodes of previous epoch
+ // 2. seat validators who did not participate in the previous epoch:
+ // 2a. seat the vals with jail reputation < 2
+ // 2b. seat the remainder of the unproven vals with any jail reputation.
+
+ let num_unproven_added = 0;
+ let i = 0u64;
+ while (
+ (Vector::length(&seats_to_fill) < set_size) &&
+ (i < Vector::length(sorted_vals_by_bid))
+ ) {
+ // // print(&i);
+ let val = Vector::borrow(sorted_vals_by_bid, i);
+
+ // // belt and suspenders, we get_sorted_vals(true) should filter ineligible validators
+ // if (!audit_qualification(val, baseline_reward)) {
+ // i = i + 1;
+ // continue
+ // };
+
+
+ // check if a proven node
+ if (Vector::contains(proven_nodes, val)) {
+ // print(&8006010205);
+ // // print(&01);
+ Vector::push_back(&mut seats_to_fill, *val);
+ } else {
+ // print(&8006010206);
+ // print(&max_unproven);
+ // print(&num_unproven_added);
+ // // print(&02);
+ // for unproven nodes, push it to list if we haven't hit limit
+ if (num_unproven_added < max_unproven ) {
+ // TODO: check jail reputation
+ // // print(&03);
+ Vector::push_back(&mut seats_to_fill, *val);
+ // // print(&04);
+ // print(&8006010207);
+ num_unproven_added = num_unproven_added + 1;
+ };
+ };
+ // don't advance if we havent filled
+ i = i + 1;
+ };
+ // // print(&05);
+ // print(&8006010208);
+ // print(&seats_to_fill);
+
+
+
+ // Set history
+ set_history(vm, &seats_to_fill);
+
+ // we failed to seat anyone.
+ // let EpochBoundary deal with this.
+ if (Vector::is_empty(&seats_to_fill)) {
+ // print(&8006010209);
+
+ return (seats_to_fill, 0)
+ };
+
+ // Find the clearing price which all validators will pay
+ let lowest_bidder = Vector::borrow(&seats_to_fill, Vector::length(&seats_to_fill) - 1);
+
+ let (lowest_bid_pct, _) = current_bid(*lowest_bidder);
+
+ // print(&lowest_bid_pct);
+
+ // update the clearing price
+ let cr = borrow_global_mut<ConsensusReward>(@VMReserved);
+ cr.clearing_price = lowest_bid_pct;
+
+ return (seats_to_fill, lowest_bid_pct)
+}
+
+
+
+
+
+
+
+
+## Function `audit_qualification`
+
+
+
+public fun audit_qualification(val: &address): bool
+
+
+
+
+
+Implementation
+
+
+public fun audit_qualification(val: &address): bool acquires ProofOfFeeAuction, ConsensusReward {
+
+ // Safety check: node has valid configs
+ if (!ValidatorConfig::is_valid(*val)) return false;
+ // has operator account set to another address
+ let oper = ValidatorConfig::get_operator(*val);
+ if (oper == *val) return false;
+
+ // is a slow wallet
+ if (!DiemAccount::is_slow(*val)) return false;
+
+ // print(&8006010203);
+ // we can't seat validators that were just jailed
+ // NOTE: epoch reconfigure needs to reset the jail
+ // before calling the proof of fee.
+ if (Jail::is_jailed(*val)) return false;
+ // print(&8006010204);
+ // we can't seat validators who don't have minimum viable vouches
+ if (!Vouch::unrelated_buddies_above_thresh(*val)) return false;
+
+ // print(&80060102041);
+
+ let (bid, expire) = current_bid(*val);
+ //print(val);
+ // print(&bid);
+ // print(&expire);
+
+ // Skip if the bid expired. belt and suspenders, this should have been checked in the sorting above.
+ // TODO: make this it's own function so it can be publicly callable, it's useful generally, and for debugging.
+ // print(&DiemConfig::get_current_epoch());
+ if (DiemConfig::get_current_epoch() > expire) return false;
+
+ // skip the user if they don't have sufficient UNLOCKED funds
+ // or if the bid expired.
+ // print(&80060102042);
+ let unlocked_coins = DiemAccount::unlocked_amount(*val);
+ // print(&unlocked_coins);
+
+ let (baseline_reward, _, _) = get_consensus_reward();
+ let coin_required = FixedPoint32::multiply_u64(baseline_reward, FixedPoint32::create_from_rational(bid, 1000));
+
+ // print(&coin_required);
+ if (unlocked_coins < coin_required) return false;
+
+ // print(&80060102043);
+ true
+}
+
+
+
+
+
+
+
+
+## Function `reward_thermostat`
+
+
+
+public fun reward_thermostat(vm: &signer)
+
+
+
+
+
+Implementation
+
+
+public fun reward_thermostat(vm: &signer) acquires ConsensusReward {
+ if (Signer::address_of(vm) != @VMReserved) {
+ return
+ };
+ // check the bid history
+ // if there are 5 days above 95% adjust the reward up by 5%
+ // adjust by more if it has been 10 days then, 10%
+ // if there are 5 days below 50% adjust the reward down.
+ // adjust by more if it has been 10 days then 10%
+
+ let bid_upper_bound = 0950;
+ let bid_lower_bound = 0500;
+
+ let short_window: u64 = 5;
+ let long_window: u64 = 10;
+
+ let cr = borrow_global_mut<ConsensusReward>(@VMReserved);
+
+ // print(&8006010551);
+ let len = Vector::length<u64>(&cr.median_history);
+ let i = 0;
+
+ let epochs_above = 0;
+ let epochs_below = 0;
+ while (i < 16 && i < len) { // max ten days, but may have less in history, filling set should truncate the history at 15 epochs.
+ // print(&8006010552);
+ let avg_bid = *Vector::borrow<u64>(&cr.median_history, i);
+ // print(&8006010553);
+ if (avg_bid > bid_upper_bound) {
+ epochs_above = epochs_above + 1;
+ } else if (avg_bid < bid_lower_bound) {
+ epochs_below = epochs_below + 1;
+ };
+
+ i = i + 1;
+ };
+
+ // print(&8006010554);
+ if (cr.value > 0) {
+ // print(&8006010555);
+ // print(&epochs_above);
+ // print(&epochs_below);
+
+
+ // TODO: this is an initial implementation, we need to
+ // decide if we want more granularity in the reward adjustment
+ // Note: making this readable for now, but we can optimize later
+ if (epochs_above > epochs_below) {
+
+ // if (epochs_above > short_window) {
+ // print(&8006010556);
+ // check for zeros.
+ // TODO: put a better safety check here
+
+ // If the Validators are bidding near 100% that means
+ // the reward is very generous, i.e. their opportunity
+ // cost is met at small percentages. This means the
+ // implicit bond is very high on validators. E.g.
+ // at 1% median bid, the implicit bond is 100x the reward.
+ // We need to DECREASE the reward
+ // print(&8006010558);
+
+ if (epochs_above > long_window) {
+
+ // decrease the reward by 10%
+ // print(&8006010559);
+
+
+ cr.value = cr.value - (cr.value / 10);
+ return // return early since we can't increase and decrease simultaneously
+ } else if (epochs_above > short_window) {
+ // decrease the reward by 5%
+ // print(&80060105510);
+ cr.value = cr.value - (cr.value / 20);
+
+
+ return // return early since we can't increase and decrease simultaneously
+ }
+ };
+
+
+ // if validators are bidding low percentages
+ // it means the nominal reward is not high enough.
+ // That is the validator's opportunity cost is not met within a
+ // range where the bond is meaningful.
+ // For example: if the bids for the epoch's reward is 50% of the value, that means the potential profit, is the same as the potential loss.
+ // At a 25% bid (potential loss), the profit is thus 75% of the value, which means the implicit bond is 25/75, or 1/3 of the bond, the risk favors the validator. This means among other things, that an attacker can pay for the cost of the attack with the profits. See paper, for more details.
+
+ // we need to INCREASE the reward, so that the bond is more meaningful.
+ // print(&80060105511);
+
+ if (epochs_below > long_window) {
+ // print(&80060105513);
+
+ // increase the reward by 10%
+ cr.value = cr.value + (cr.value / 10);
+ } else if (epochs_below > short_window) {
+ // print(&80060105512);
+
+ // increase the reward by 5%
+ cr.value = cr.value + (cr.value / 20);
+ };
+ // };
+ };
+}
+
+
+
+
+
+
+
+
+## Function `set_history`
+
+find the median bid to push to history
+
+
+public fun set_history(vm: &signer, seats_to_fill: &vector<address>)
+
+
+
+
+
+Implementation
+
+
+public fun set_history(vm: &signer, seats_to_fill: &vector<address>) acquires ProofOfFeeAuction, ConsensusReward {
+ if (Signer::address_of(vm) != @VMReserved) {
+ return
+ };
+
+ // print(&99901);
+ let median_bid = get_median(seats_to_fill);
+ // push to history
+ let cr = borrow_global_mut<ConsensusReward>(@VMReserved);
+ cr.median_win_bid = median_bid;
+ if (Vector::length(&cr.median_history) < 10) {
+ // print(&99902);
+ Vector::push_back(&mut cr.median_history, median_bid);
+ } else {
+ // print(&99903);
+ Vector::remove(&mut cr.median_history, 0);
+ Vector::push_back(&mut cr.median_history, median_bid);
+ };
+}
+
+
+
+
+
+
+
+
+## Function `get_median`
+
+
+
+fun get_median(seats_to_fill: &vector<address>): u64
+
+
+
+
+
+Implementation
+
+
+fun get_median(seats_to_fill: &vector<address>):u64 acquires ProofOfFeeAuction {
+ // TODO: the list is sorted above, so
+ // we assume the median is the middle element
+ let len = Vector::length(seats_to_fill);
+ if (len == 0) {
+ return 0
+ };
+ let median_bidder = if (len > 2) {
+ Vector::borrow(seats_to_fill, len/2)
+ } else {
+ Vector::borrow(seats_to_fill, 0)
+ };
+ let (median_bid, _) = current_bid(*median_bidder);
+ return median_bid
+}
+
+
+
+
+
+
+
+
+## Function `get_consensus_reward`
+
+
+
+public fun get_consensus_reward(): (u64, u64, u64)
+
+
+
+
+
+Implementation
+
+
+public fun get_consensus_reward(): (u64, u64, u64) acquires ConsensusReward {
+ let b = borrow_global<ConsensusReward>(@VMReserved );
+ return (b.value, b.clearing_price, b.median_win_bid)
+}
+
+
+
+
+
+
+
+
+## Function `current_bid`
+
+
+
+public fun current_bid(node_addr: address): (u64, u64)
+
+
+
+
+
+Implementation
+
+
+public fun current_bid(node_addr: address): (u64, u64) acquires ProofOfFeeAuction {
+ if (exists<ProofOfFeeAuction>(node_addr)) {
+ let pof = borrow_global<ProofOfFeeAuction>(node_addr);
+ let e = DiemConfig::get_current_epoch();
+ // check the expiration of the bid
+ // the bid is zero if it expires.
+ // The expiration epoch number is inclusive of the epoch.
+ // i.e. the bid expires on e + 1.
+ if (pof.epoch_expiration >= e || pof.epoch_expiration == 0) {
+ return (pof.bid, pof.epoch_expiration)
+ };
+ return (0, pof.epoch_expiration)
+ };
+ return (0, 0)
+}
+
+
+
+
+
+
+
+
+## Function `is_already_retracted`
+
+
+
+public fun is_already_retracted(node_addr: address): (bool, u64)
+
+
+
+
+
+Implementation
+
+
+public fun is_already_retracted(node_addr: address): (bool, u64) acquires ProofOfFeeAuction {
+ if (exists<ProofOfFeeAuction>(node_addr)) {
+ let when_retract = *&borrow_global<ProofOfFeeAuction>(node_addr).last_epoch_retracted;
+ return (DiemConfig::get_current_epoch() >= when_retract, when_retract)
+ };
+ return (false, 0)
+}
+
+
+
+
+
+
+
+
+## Function `top_n_accounts`
+
+
+
+public fun top_n_accounts(account: &signer, n: u64, unfiltered: bool): vector<address>
+
+
+
+
+
+Implementation
+
+
+public fun top_n_accounts(account: &signer, n: u64, unfiltered: bool): vector<address> acquires ProofOfFeeAuction, ConsensusReward {
+ assert!(Signer::address_of(account) == @DiemRoot, Errors::requires_role(140101));
+
+ let eligible_validators = get_sorted_vals(unfiltered);
+ let len = Vector::length<address>(&eligible_validators);
+ if(len <= n) return eligible_validators;
+
+ let diff = len - n;
+ while(diff > 0){
+ Vector::pop_back(&mut eligible_validators);
+ diff = diff - 1;
+ };
+
+ eligible_validators
+}
+
+
+
+
+
+
+
+
+## Function `set_bid`
+
+
+
+public fun set_bid(account_sig: &signer, bid: u64, expiry_epoch: u64)
+
+
+
+
+
+Implementation
+
+
+public fun set_bid(account_sig: &signer, bid: u64, expiry_epoch: u64) acquires ProofOfFeeAuction {
+
+ let acc = Signer::address_of(account_sig);
+ if (!exists<ProofOfFeeAuction>(acc)) {
+ init(account_sig);
+ };
+
+ // bid must be below 110%
+ assert!(bid <= 1100, Errors::ol_tx(EBID_ABOVE_MAX_PCT));
+
+ let pof = borrow_global_mut<ProofOfFeeAuction>(acc);
+ pof.epoch_expiration = expiry_epoch;
+ pof.bid = bid;
+}
+
+
+
+
+
+
+
+
+## Function `retract_bid`
+
+Note that the validator will not be bidding on any future
+epochs if they retract their bid. The must set a new bid.
+
+
+public fun retract_bid(account_sig: &signer)
+
+
+
+
+
+Implementation
+
+
+public fun retract_bid(account_sig: &signer) acquires ProofOfFeeAuction {
+
+ let acc = Signer::address_of(account_sig);
+ if (!exists<ProofOfFeeAuction>(acc)) {
+ init(account_sig);
+ };
+
+
+ let pof = borrow_global_mut<ProofOfFeeAuction>(acc);
+ let this_epoch = DiemConfig::get_current_epoch();
+
+ //////// LEAVE COMMENTED. Code for a potential upgrade. ////////
+ // See above discussion for retracting of bids.
+ //
+ // already retracted this epoch
+ // assert!(this_epoch > pof.last_epoch_retracted, Errors::ol_tx(EABOVE_RETRACT_LIMIT));
+ //////// LEAVE COMMENTED. Code for a potential upgrade. ////////
+
+
+ pof.epoch_expiration = 0;
+ pof.bid = 0;
+ pof.last_epoch_retracted = this_epoch;
+}
+
+
+
+
+
+
+
+
+## Function `init_bidding`
+
+
+
+public(script) fun init_bidding(sender: signer)
+
+
+
+
+
+Implementation
+
+
+public(script) fun init_bidding(sender: signer) {
+ init(&sender);
+}
+
+
+
+
+
+
+
+
+## Function `pof_update_bid`
+
+
+
+public(script) fun pof_update_bid(sender: signer, bid: u64, epoch_expiry: u64)
+
+
+
+
+
+Implementation
+
+
+public(script) fun pof_update_bid(sender: signer, bid: u64, epoch_expiry: u64) acquires ProofOfFeeAuction {
+ // update the bid, initializes if not already.
+ set_bid(&sender, bid, epoch_expiry);
+}
+
+
+
+
+
+
+
+
+## Function `pof_retract_bid`
+
+
+
+public(script) fun pof_retract_bid(sender: signer)
+
+
+
+
+
+Implementation
+
+
+public(script) fun pof_retract_bid(sender: signer) acquires ProofOfFeeAuction {
+ // retract a bid
+ retract_bid(&sender);
+}
+
+
+
+
+
+
+
+
+## Function `test_set_val_bids`
+
+
+
+public fun test_set_val_bids(vm: &signer, vals: &vector<address>, bids: &vector<u64>, expiry: &vector<u64>)
+
+
+
+
+
+Implementation
+
+
+public fun test_set_val_bids(vm: &signer, vals: &vector<address>, bids: &vector<u64>, expiry: &vector<u64>) acquires ProofOfFeeAuction {
+ Testnet::assert_testnet(vm);
+
+ let len = Vector::length(vals);
+ let i = 0;
+ while (i < len) {
+ let bid = Vector::borrow(bids, i);
+ let exp = Vector::borrow(expiry, i);
+ let addr = Vector::borrow(vals, i);
+ test_set_one_bid(vm, addr, *bid, *exp);
+ i = i + 1;
+ };
+}
+
+
+
+
+
+
+
+
+## Function `test_set_one_bid`
+
+
+
+public fun test_set_one_bid(vm: &signer, val: &address, bid: u64, exp: u64)
+
+
+
+
+
+Implementation
+
+
+public fun test_set_one_bid(vm: &signer, val: &address, bid: u64, exp: u64) acquires ProofOfFeeAuction {
+ Testnet::assert_testnet(vm);
+ let pof = borrow_global_mut<ProofOfFeeAuction>(*val);
+ pof.epoch_expiration = exp;
+ pof.bid = bid;
+}
+
+
+
+
+
+
+
+
+## Function `test_mock_reward`
+
+
+
+public fun test_mock_reward(vm: &signer, value: u64, clearing_price: u64, median_win_bid: u64, median_history: vector<u64>)
+
+
+
+
+
+Implementation
+
+
+public fun test_mock_reward(
+ vm: &signer,
+ value: u64,
+ clearing_price: u64,
+ median_win_bid: u64,
+ median_history: vector<u64>,
+) acquires ConsensusReward {
+ Testnet::assert_testnet(vm);
+
+ let cr = borrow_global_mut<ConsensusReward>(@VMReserved );
+ cr.value = value;
+ cr.clearing_price = clearing_price;
+ cr.median_win_bid = median_win_bid;
+ cr.median_history = median_history;
+
+}
+
+
+
+
+
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Receipts.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Receipts.md
index 43b5edfeb9..267b6e3fba 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Receipts.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Receipts.md
@@ -7,6 +7,8 @@
- [Resource `UserReceipts`](#0x1_Receipts_UserReceipts)
- [Function `init`](#0x1_Receipts_init)
+- [Function `is_init`](#0x1_Receipts_is_init)
+- [Function `write_receipt_vm`](#0x1_Receipts_write_receipt_vm)
- [Function `write_receipt`](#0x1_Receipts_write_receipt)
- [Function `read_receipt`](#0x1_Receipts_read_receipt)
@@ -97,15 +99,67 @@
+
+
+
+
+## Function `is_init`
+
+
+
+public fun is_init(addr: address): bool
+
+
+
+
+
+Implementation
+
+
+public fun is_init(addr: address):bool {
+ exists<UserReceipts>(addr)
+}
+
+
+
+
+
+
+
+
+## Function `write_receipt_vm`
+
+
+
+public fun write_receipt_vm(sender: &signer, payer: address, destination: address, value: u64): (u64, u64, u64)
+
+
+
+
+
+Implementation
+
+
+public fun write_receipt_vm(sender: &signer, payer: address, destination: address, value: u64):(u64, u64, u64) acquires UserReceipts {
+ // TODO: make a function for user to write own receipt.
+ CoreAddresses::assert_vm(sender);
+ write_receipt(payer, destination, value)
+}
+
+
+
+
## Function `write_receipt`
+Restricted to DiemAccount, we need to write receipts for certain users, like to DonorDirected Accounts.
+Core Devs: Danger: only DiemAccount can use this.
-public fun write_receipt(sender: &signer, payer: address, destination: address, value: u64): (u64, u64, u64)
+public(friend) fun write_receipt(payer: address, destination: address, value: u64): (u64, u64, u64)
@@ -114,9 +168,8 @@
Implementation
-public fun write_receipt(sender: &signer, payer: address, destination: address, value: u64):(u64, u64, u64) acquires UserReceipts {
+public(friend) fun write_receipt(payer: address, destination: address, value: u64):(u64, u64, u64) acquires UserReceipts {
// TODO: make a function for user to write own receipt.
- CoreAddresses::assert_vm(sender);
if (!exists<UserReceipts>(payer)) {
return (0, 0, 0)
};
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Stats.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Stats.md
index 3ccc273e3e..e6c6d84127 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Stats.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Stats.md
@@ -22,8 +22,9 @@
- [Function `get_total_votes`](#0x1_Stats_get_total_votes)
- [Function `get_total_props`](#0x1_Stats_get_total_props)
- [Function `get_history`](#0x1_Stats_get_history)
-- [Function `test_helper_inc_vote_addr`](#0x1_Stats_test_helper_inc_vote_addr)
- [Function `get_sorted_vals_by_props`](#0x1_Stats_get_sorted_vals_by_props)
+- [Function `test_helper_inc_vote_addr`](#0x1_Stats_test_helper_inc_vote_addr)
+- [Function `test_helper_remove_votes`](#0x1_Stats_test_helper_remove_votes)
use 0x1::Errors;
@@ -478,12 +479,12 @@
} else {
// debugging rescue mission. Remove after network stabilizes Apr 2022.
// something bad happened and we can't find this node in our list.
- // print(&666);
- // print(&node_addr);
+ // // print(&666);
+ // // print(&node_addr);
};
// update total vote count anyways even if we can't find this person.
stats.current.total_votes = stats.current.total_votes + 1;
- // print(&stats.current);
+ // // print(&stats.current);
}
@@ -599,35 +600,6 @@
-
-
-
-
-## Function `test_helper_inc_vote_addr`
-
-TEST HELPERS
-
-
-public fun test_helper_inc_vote_addr(vm: &signer, node_addr: address)
-
-
-
-
-
-Implementation
-
-
-public fun test_helper_inc_vote_addr(vm: &signer, node_addr: address) acquires ValStats {
- let sender = Signer::address_of(vm);
- assert!(sender == @DiemRoot, Errors::requires_role(190015));
- assert!(Testnet::is_testnet(), Errors::invalid_state(190015));
-
- inc_vote(vm, node_addr);
-}
-
-
-
-
@@ -701,4 +673,66 @@ TEST HELPERS
+
+
+
+
+## Function `test_helper_inc_vote_addr`
+
+TEST HELPERS
+
+
+public fun test_helper_inc_vote_addr(vm: &signer, node_addr: address)
+
+
+
+
+
+Implementation
+
+
+public fun test_helper_inc_vote_addr(vm: &signer, node_addr: address) acquires ValStats {
+ let sender = Signer::address_of(vm);
+ assert!(sender == @DiemRoot, Errors::requires_role(190015));
+ assert!(Testnet::is_testnet(), Errors::invalid_state(190015));
+
+ inc_vote(vm, node_addr);
+}
+
+
+
+
+
+
+
+
+## Function `test_helper_remove_votes`
+
+
+
+public fun test_helper_remove_votes(vm: &signer, node_addr: address)
+
+
+
+
+
+Implementation
+
+
+public fun test_helper_remove_votes(vm: &signer, node_addr: address) acquires ValStats {
+ Testnet::assert_testnet(vm);
+
+ let stats = borrow_global_mut<ValStats>(@VMReserved);
+ let (is_true, i) = Vector::index_of<address>(&mut stats.current.addr, &node_addr);
+ if (is_true) {
+ let votes = *Vector::borrow<u64>(&mut stats.current.vote_count, i);
+ Vector::push_back(&mut stats.current.vote_count, 0);
+ Vector::swap_remove(&mut stats.current.vote_count, i);
+ stats.current.total_votes = stats.current.total_votes - votes;
+ }
+}
+
+
+
+
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Subsidy.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Subsidy.md
index ec4a809adf..952f784b21 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Subsidy.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Subsidy.md
@@ -83,6 +83,7 @@
let minted_coins = Diem::mint<GAS>(vm, subsidy_granted);
DiemAccount::vm_deposit_with_metadata<GAS>(
vm,
+ @VMReserved,
node_address,
minted_coins,
b"validator subsidy",
@@ -241,6 +242,7 @@
let minted_coins = Diem::mint<GAS>(vm_sig, *&subsidy);
DiemAccount::vm_deposit_with_metadata<GAS>(
vm_sig,
+ @VMReserved,
node_address,
minted_coins,
b"genesis subsidy",
@@ -301,6 +303,7 @@
DiemAccount::vm_deposit_with_metadata<GAS>(
vm,
+ @VMReserved,
node_address,
TransactionFee::get_transaction_fees_coins_amount<GAS>(vm, fees),
b"transaction fees",
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/TestFixtures.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/TestFixtures.md
index 6a5921d2a8..c2d076a551 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/TestFixtures.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/TestFixtures.md
@@ -22,9 +22,14 @@
- [Function `eve_0_easy_sol`](#0x1_TestFixtures_eve_0_easy_sol)
- [Function `eve_1_easy_chal`](#0x1_TestFixtures_eve_1_easy_chal)
- [Function `eve_1_easy_sol`](#0x1_TestFixtures_eve_1_easy_sol)
+- [Function `pof_default`](#0x1_TestFixtures_pof_default)
-use 0x1::Testnet;
+use 0x1::DiemAccount;
+use 0x1::ProofOfFee;
+use 0x1::Testnet;
+use 0x1::ValidatorUniverse;
+use 0x1::Vector;
@@ -449,4 +454,53 @@
+
+
+
+
+## Function `pof_default`
+
+
+
+public fun pof_default(vm: &signer): (vector<address>, vector<u64>, vector<u64>)
+
+
+
+
+
+Implementation
+
+
+public fun pof_default(vm: &signer): (vector<address>, vector<u64>, vector<u64>){
+
+ Testnet::assert_testnet(vm);
+ let vals = ValidatorUniverse::get_eligible_validators();
+
+ let bids = Vector::empty<u64>();
+ let expiry = Vector::empty<u64>();
+ let i = 0;
+ let prev = 0;
+ let fib = 1;
+ while (i < Vector::length(&vals)) {
+
+ Vector::push_back(&mut expiry, 1000);
+ let b = prev + fib;
+ Vector::push_back(&mut bids, b);
+
+ let a = Vector::borrow(&vals, i);
+ let sig = DiemAccount::scary_create_signer_for_migrations(vm, *a);
+ // initialize and set.
+ ProofOfFee::set_bid(&sig, b, 1000);
+ prev = fib;
+ fib = b;
+ i = i + 1;
+ };
+ DiemAccount::slow_wallet_epoch_drip(vm, 100000); // unlock some coins for the validators
+
+ (vals, bids, expiry)
+}
+
+
+
+
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Testnet.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Testnet.md
index 59fa5430a7..62b6434893 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Testnet.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Testnet.md
@@ -6,6 +6,7 @@
- [Resource `IsStagingNet`](#0x1_StagingNet_IsStagingNet)
+- [Constants](#@Constants_0)
- [Function `initialize`](#0x1_StagingNet_initialize)
- [Function `is_staging_net`](#0x1_StagingNet_is_staging_net)
@@ -43,6 +44,20 @@
+
+
+## Constants
+
+
+
+
+
+
+const EWHY_U_NO_ROOT: u64 = 667;
+
+
+
+
## Function `initialize`
@@ -61,7 +76,7 @@
public fun initialize(account: &signer) {
assert!(
Signer::address_of(account) == @DiemRoot,
- Errors::requires_role(190301)
+ Errors::requires_role(EWHY_U_NO_ROOT)
);
move_to(account, IsStagingNet{})
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/TowerState.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/TowerState.md
index a0d702d894..c84bf14896 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/TowerState.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/TowerState.md
@@ -73,7 +73,6 @@
use 0x1::CoreAddresses;
-use 0x1::Debug;
use 0x1::DiemConfig;
use 0x1::Errors;
use 0x1::Globals;
@@ -1373,24 +1372,24 @@ Reset the tower counter at the end of epoch.
// double check
if (len <= n) return 0;
- print(&666602);
+ // print(&666602);
let miner_addr = Vector::borrow<address>(&l, n);
- print(&666603);
+ // print(&666603);
let vec = if (exists<TowerProofHistory>(*miner_addr)) {
*&borrow_global<TowerProofHistory>(*miner_addr).previous_proof_hash
} else { return 0 };
- print(&vec);
+ // print(&vec);
- print(&666604);
+ // print(&666604);
// take the last bit (B) from their last proof hash.
n = (Vector::pop_back(&mut vec) as u64);
- print(&666605);
+ // print(&666605);
i = i + 1;
};
- print(&8888);
+ // print(&8888);
n
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/TransactionFee.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/TransactionFee.md
index 51dafbfc63..13008131fe 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/TransactionFee.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/TransactionFee.md
@@ -6,18 +6,28 @@
- [Resource `TransactionFee`](#0x1_TransactionFee_TransactionFee)
+- [Resource `FeeMaker`](#0x1_TransactionFee_FeeMaker)
+- [Resource `EpochFeeMakerRegistry`](#0x1_TransactionFee_EpochFeeMakerRegistry)
- [Constants](#@Constants_0)
- [Function `initialize`](#0x1_TransactionFee_initialize)
- [Function `is_coin_initialized`](#0x1_TransactionFee_is_coin_initialized)
- [Function `is_initialized`](#0x1_TransactionFee_is_initialized)
- [Function `add_txn_fee_currency`](#0x1_TransactionFee_add_txn_fee_currency)
- [Function `pay_fee`](#0x1_TransactionFee_pay_fee)
+- [Function `pay_fee_and_track`](#0x1_TransactionFee_pay_fee_and_track)
- [Function `burn_fees`](#0x1_TransactionFee_burn_fees)
- [Specification of the case where burn type is XDX.](#@Specification_of_the_case_where_burn_type_is_XDX._1)
- [Specification of the case where burn type is not XDX.](#@Specification_of_the_case_where_burn_type_is_not_XDX._2)
- [Function `get_amount_to_distribute`](#0x1_TransactionFee_get_amount_to_distribute)
-- [Function `get_transaction_fees_coins`](#0x1_TransactionFee_get_transaction_fees_coins)
+- [Function `vm_withdraw_all_coins`](#0x1_TransactionFee_vm_withdraw_all_coins)
- [Function `get_transaction_fees_coins_amount`](#0x1_TransactionFee_get_transaction_fees_coins_amount)
+- [Function `initialize_epoch_fee_maker_registry`](#0x1_TransactionFee_initialize_epoch_fee_maker_registry)
+- [Function `initialize_fee_maker`](#0x1_TransactionFee_initialize_fee_maker)
+- [Function `epoch_reset_fee_maker`](#0x1_TransactionFee_epoch_reset_fee_maker)
+- [Function `reset_one_fee_maker`](#0x1_TransactionFee_reset_one_fee_maker)
+- [Function `track_user_fee`](#0x1_TransactionFee_track_user_fee)
+- [Function `get_fee_makers`](#0x1_TransactionFee_get_fee_makers)
+- [Function `get_epoch_fees_made`](#0x1_TransactionFee_get_epoch_fees_made)
- [Module Specification](#@Module_Specification_3)
- [Initialization](#@Initialization_4)
- [Helper Function](#@Helper_Function_5)
@@ -29,6 +39,7 @@
use 0x1::Errors;
use 0x1::GAS;
use 0x1::Roles;
+use 0x1::Vector;
use 0x1::XDX;
@@ -67,6 +78,71 @@ fiat CoinType
that can be collected as a transaction fee.
+
+
+
+
+## Resource `FeeMaker`
+
+FeeMaker struct lives on an individual's account
+We check how many fees the user has paid.
+This will interact with Burn preferences when there is a remainder of fees in the TransactionFee account
+
+
+struct FeeMaker has key
+
+
+
+
+
+Fields
+
+
+
+-
+
epoch: u64
+
+-
+
+
+-
+
lifetime: u64
+
+-
+
+
+
+
+
+
+
+
+
+## Resource `EpochFeeMakerRegistry`
+
+We need a list of who is producing fees this epoch.
+This lives on the VM address
+
+
+struct EpochFeeMakerRegistry has key
+
+
+
+
+
+Fields
+
+
+
+-
+
fee_makers: vector<address>
+
+-
+
+
+
+
+
@@ -250,8 +326,8 @@ Deposit coin
into the transaction fees bucket
public fun pay_fee<CoinType>(coin: Diem<CoinType>) acquires TransactionFee {
DiemTimestamp::assert_operating();
assert!(is_coin_initialized<CoinType>(), Errors::not_published(ETRANSACTION_FEE));
- let fees = borrow_global_mut<TransactionFee<CoinType>>(@TreasuryCompliance);
- Diem::deposit(&mut fees.balance, coin)
+ let fees = borrow_global_mut<TransactionFee<CoinType>>(@TreasuryCompliance); // TODO: this is just the VM root actually
+ Diem::deposit(&mut fees.balance, coin);
}
@@ -299,6 +375,35 @@ Deposit coin
into the transaction fees bucket
+
+
+
+
+## Function `pay_fee_and_track`
+
+
+
+public fun pay_fee_and_track<CoinType>(user: address, coin: Diem::Diem<CoinType>)
+
+
+
+
+
+Implementation
+
+
+public fun pay_fee_and_track<CoinType>(user: address, coin: Diem<CoinType>) acquires TransactionFee, FeeMaker, EpochFeeMakerRegistry {
+ DiemTimestamp::assert_operating();
+ assert!(is_coin_initialized<CoinType>(), Errors::not_published(ETRANSACTION_FEE));
+ let amount = Diem::value(&coin);
+ let fees = borrow_global_mut<TransactionFee<CoinType>>(@TreasuryCompliance); // TODO: this is just the VM root actually
+ Diem::deposit(&mut fees.balance, coin);
+ track_user_fee(user, amount);
+}
+
+
+
+
@@ -477,13 +582,14 @@ BurnCapability is not transferrable [[J3]][PERMISSION].
-
+
-## Function `get_transaction_fees_coins`
+## Function `vm_withdraw_all_coins`
+only to be used by VM through the Burn.move module
-public fun get_transaction_fees_coins<Token: store>(dr_account: &signer): Diem::Diem<Token>
+public(friend) fun vm_withdraw_all_coins<Token: store>(dr_account: &signer): Diem::Diem<Token>
@@ -492,7 +598,7 @@ BurnCapability is not transferrable [[J3]][PERMISSION].
Implementation
-public fun get_transaction_fees_coins<Token: store>(
+public(friend) fun vm_withdraw_all_coins<Token: store>(
dr_account: &signer
): Diem<Token> acquires TransactionFee {
// Can only be invoked by DiemVM privilege.
@@ -545,6 +651,216 @@ BurnCapability is not transferrable [[J3]][PERMISSION].
+
+
+
+
+## Function `initialize_epoch_fee_maker_registry`
+
+Initialize the registry at the VM address.
+
+
+public fun initialize_epoch_fee_maker_registry(vm: &signer)
+
+
+
+
+
+Implementation
+
+
+public fun initialize_epoch_fee_maker_registry(vm: &signer) {
+ CoreAddresses::assert_vm(vm);
+ let registry = EpochFeeMakerRegistry {
+ fee_makers: Vector::empty(),
+ };
+ move_to(vm, registry);
+}
+
+
+
+
+
+
+
+
+## Function `initialize_fee_maker`
+
+FeeMaker is initialized when the account is created
+
+
+public fun initialize_fee_maker(account: &signer)
+
+
+
+
+
+Implementation
+
+
+public fun initialize_fee_maker(account: &signer) {
+ let fee_maker = FeeMaker {
+ epoch: 0,
+ lifetime: 0,
+ };
+ move_to(account, fee_maker);
+}
+
+
+
+
+
+
+
+
+## Function `epoch_reset_fee_maker`
+
+
+
+public fun epoch_reset_fee_maker(vm: &signer)
+
+
+
+
+
+Implementation
+
+
+public fun epoch_reset_fee_maker(vm: &signer) acquires EpochFeeMakerRegistry, FeeMaker {
+ CoreAddresses::assert_vm(vm);
+ let registry = borrow_global_mut<EpochFeeMakerRegistry>(@VMReserved);
+ let fee_makers = ®istry.fee_makers;
+
+ let i = 0;
+ while (i < Vector::length(fee_makers)) {
+ let account = *Vector::borrow(fee_makers, i);
+ reset_one_fee_maker(vm, account);
+ i = i + 1;
+ };
+ registry.fee_makers = Vector::empty();
+}
+
+
+
+
+
+
+
+
+## Function `reset_one_fee_maker`
+
+FeeMaker is reset at the epoch boundary, and the lifetime is updated.
+
+
+fun reset_one_fee_maker(vm: &signer, account: address)
+
+
+
+
+
+Implementation
+
+
+fun reset_one_fee_maker(vm: &signer, account: address) acquires FeeMaker {
+ CoreAddresses::assert_vm(vm);
+ let fee_maker = borrow_global_mut<FeeMaker>(account);
+ fee_maker.lifetime = fee_maker.lifetime + fee_maker.epoch;
+ fee_maker.epoch = 0;
+}
+
+
+
+
+
+
+
+
+## Function `track_user_fee`
+
+add a fee to the account fee maker for an epoch
+PRIVATE function
+
+
+fun track_user_fee(account: address, amount: u64)
+
+
+
+
+
+Implementation
+
+
+fun track_user_fee(account: address, amount: u64) acquires FeeMaker, EpochFeeMakerRegistry {
+ if (!exists<FeeMaker>(account)) {
+ return
+ };
+
+ let fee_maker = borrow_global_mut<FeeMaker>(account);
+ fee_maker.epoch = fee_maker.epoch + amount;
+
+ // update the registry
+ let registry = borrow_global_mut<EpochFeeMakerRegistry>(@VMReserved);
+ if (!Vector::contains(®istry.fee_makers, &account)) {
+ Vector::push_back(&mut registry.fee_makers, account);
+ }
+}
+
+
+
+
+
+
+
+
+## Function `get_fee_makers`
+
+
+
+public fun get_fee_makers(): vector<address>
+
+
+
+
+
+Implementation
+
+
+public fun get_fee_makers(): vector<address> acquires EpochFeeMakerRegistry {
+ let registry = borrow_global<EpochFeeMakerRegistry>(@VMReserved);
+ *®istry.fee_makers
+}
+
+
+
+
+
+
+
+
+## Function `get_epoch_fees_made`
+
+
+
+public fun get_epoch_fees_made(account: address): u64
+
+
+
+
+
+Implementation
+
+
+public fun get_epoch_fees_made(account: address): u64 acquires FeeMaker {
+ if (!exists<FeeMaker>(account)) {
+ return 0
+ };
+ let fee_maker = borrow_global<FeeMaker>(account);
+ fee_maker.epoch
+}
+
+
+
+
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Upgrade.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Upgrade.md
index 27a98dd837..e3626cdacd 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Upgrade.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/Upgrade.md
@@ -206,7 +206,7 @@ Structs for UpgradeHistory resource
// unless the prologue gives it to us.
// The upgrade reconfigure happens on round 2, so we'll increment the
// new start by 2 from previous.
- let new_epoch_height = Epoch::get_timer_height_start(vm) + 2;
+ let new_epoch_height = Epoch::get_timer_height_start() + 2;
Epoch::reset_timer(vm, new_epoch_height);
// TODO: check if this has any impact.
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/ol_transfer.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/ol_transfer.md
index 521278151c..ea9d6c8dac 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/ol_transfer.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/ol_transfer.md
@@ -9,8 +9,7 @@
- [Function `community_transfer`](#0x1_TransferScripts_community_transfer)
-use 0x1::CommunityWallet;
-use 0x1::DiemAccount;
+use 0x1::DiemAccount;
use 0x1::DonorDirected;
use 0x1::GAS;
use 0x1::GUID;
@@ -89,8 +88,8 @@
// unscaled_value. This script converts it to the Move internal scale
// by multiplying by COIN_SCALING_FACTOR.
let value = unscaled_value * Globals::get_coin_scaling_factor();
- let sender_addr = Signer::address_of(&sender);
- assert!(CommunityWallet::is_comm(sender_addr), 30001);
+ // let sender_addr = Signer::address_of(&sender);
+ // assert!(CommunityWallet::is_comm(sender_addr), 30001);
// confirm the destination account has a slow wallet
// TODO: this check only happens in this script since there's
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/ol_validator.md b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/ol_validator.md
index 1ef61f1399..c9facf33ae 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/ol_validator.md
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/docs/ol_validator.md
@@ -6,7 +6,6 @@
- [Constants](#@Constants_0)
-- [Function `self_unjail`](#0x1_ValidatorScripts_self_unjail)
- [Function `voucher_unjail`](#0x1_ValidatorScripts_voucher_unjail)
- [Function `val_add_self`](#0x1_ValidatorScripts_val_add_self)
- [Function `ol_reconfig_bulk_update_setup`](#0x1_ValidatorScripts_ol_reconfig_bulk_update_setup)
@@ -64,48 +63,6 @@
-
-
-## Function `self_unjail`
-
-
-
-public(script) fun self_unjail(validator: signer)
-
-
-
-
-
-Implementation
-
-
-public(script) fun self_unjail(validator: signer) {
- let addr = Signer::address_of(&validator);
- // if is above threshold continue, or raise error.
- assert!(
- TowerState::node_above_thresh(addr),
- Errors::invalid_state(NOT_ABOVE_THRESH_JOIN)
- );
- // if is not in universe, add back
- if (!ValidatorUniverse::is_in_universe(addr)) {
- ValidatorUniverse::add_self(&validator);
- };
- // Initialize jailbit if not present
- if (!ValidatorUniverse::exists_jailedbit(addr)) {
- ValidatorUniverse::initialize(&validator);
- };
-
- // if is jailed, try to unjail
- if (Jail::is_jailed(addr)) {
- Jail::self_unjail(&validator);
- };
-}
-
-
-
-
-
-
## Function `voucher_unjail`
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Ancestry.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Ancestry.mvsm
index 2ff53cf679..f8abc512e6 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Ancestry.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Ancestry.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Audit.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Audit.mvsm
deleted file mode 100644
index 8de5738f94..0000000000
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Audit.mvsm and /dev/null differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/AutoPay.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/AutoPay.mvsm
index cb6f83ab99..4f226f7b8f 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/AutoPay.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/AutoPay.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Burn.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Burn.mvsm
index ea5643b758..c7347de801 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Burn.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Burn.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Cases.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Cases.mvsm
index d8cb4a08e4..ee90d414f7 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Cases.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Cases.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DemoBonding.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DemoBonding.mvsm
index fd0750108b..0f01f98060 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DemoBonding.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DemoBonding.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DiemAccount.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DiemAccount.mvsm
index 6ab229b900..e16bcde152 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DiemAccount.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DiemAccount.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DiemSystem.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DiemSystem.mvsm
index f4dd889139..e72a692070 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DiemSystem.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DiemSystem.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DonorDirected.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DonorDirected.mvsm
index 67be4418b0..3826bfba8f 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DonorDirected.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/DonorDirected.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Epoch.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Epoch.mvsm
index 824ba06b5d..b4e47d90d2 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Epoch.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Epoch.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/EpochBoundary.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/EpochBoundary.mvsm
index d922aed3cd..92ce73918c 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/EpochBoundary.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/EpochBoundary.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/FullnodeSubsidy.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/FullnodeSubsidy.mvsm
index 8f25563713..5cf2feb057 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/FullnodeSubsidy.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/FullnodeSubsidy.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Genesis.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Genesis.mvsm
index d0d4450111..38b9e93e5f 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Genesis.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Genesis.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/GenesisMigration.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/GenesisMigration.mvsm
index 547bcf115b..574eb88d5e 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/GenesisMigration.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/GenesisMigration.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Jail.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Jail.mvsm
index 83b46e96cc..9d08a630a8 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Jail.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Jail.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Mock.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Mock.mvsm
index f1226c4fa4..5d6017fc90 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Mock.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Mock.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/MultiSig.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/MultiSig.mvsm
index 6a43174881..f85c665db5 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/MultiSig.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/MultiSig.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/MultiSigPayment.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/MultiSigPayment.mvsm
index c13c06ad31..aacd187489 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/MultiSigPayment.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/MultiSigPayment.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/ProofOfFee.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/ProofOfFee.mvsm
new file mode 100644
index 0000000000..62c0daba2b
Binary files /dev/null and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/ProofOfFee.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Receipts.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Receipts.mvsm
index f5dbb5c61e..1bc97d5487 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Receipts.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Receipts.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/StagingNet.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/StagingNet.mvsm
index 6410640aab..daef66eaaf 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/StagingNet.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/StagingNet.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Stats.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Stats.mvsm
index eb16eec854..2843daf8d8 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Stats.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Stats.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Subsidy.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Subsidy.mvsm
index 3dd920ff66..fd425be1cf 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Subsidy.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Subsidy.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TestFixtures.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TestFixtures.mvsm
index c07660f99b..cb11bf2b96 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TestFixtures.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TestFixtures.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Testnet.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Testnet.mvsm
index d6940f9998..fb44c3f4d4 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Testnet.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Testnet.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TowerState.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TowerState.mvsm
index a3a7137d85..63caf35e4b 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TowerState.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TowerState.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TransactionFee.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TransactionFee.mvsm
index 9e5780ec69..5f9f0dfb7a 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TransactionFee.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TransactionFee.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TransferScripts.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TransferScripts.mvsm
index 43e4d500e0..702d8c267d 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TransferScripts.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/TransferScripts.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Upgrade.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Upgrade.mvsm
index 0215b5b7cf..c52eba5d0a 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Upgrade.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Upgrade.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/ValidatorScripts.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/ValidatorScripts.mvsm
index 454ded340d..e0fec08819 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/ValidatorScripts.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/ValidatorScripts.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Vouch.mvsm b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Vouch.mvsm
index f87471c48a..04f97a36d5 100644
Binary files a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Vouch.mvsm and b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/source_maps/Vouch.mvsm differ
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Ancestry.move b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Ancestry.move
index 88fbe0e043..6f3fe87f42 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Ancestry.move
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Ancestry.move
@@ -9,7 +9,7 @@ address DiemFramework {
use Std::Signer;
use Std::Vector;
use Std::Option::{Self, Option};
- use DiemFramework::Debug::print;
+ // use DiemFramework::Debug::print;
use DiemFramework::CoreAddresses;
// triggered once per epoch
@@ -21,7 +21,7 @@ address DiemFramework {
// this is limited to onboarding.
// TODO: limit this with `friend` of DiemAccount module.
public fun init(new_account_sig: &signer, onboarder_sig: &signer ) acquires Ancestry{
- print(&100100);
+ // print(&100100);
let parent = Signer::address_of(onboarder_sig);
set_tree(new_account_sig, parent);
}
@@ -29,7 +29,7 @@ address DiemFramework {
// private. The user should NEVER be able to change ancestry through a transaction.
fun set_tree(new_account_sig: &signer, parent: address ) acquires Ancestry {
let child = Signer::address_of(new_account_sig);
- print(&100200);
+ // print(&100200);
let new_tree = Vector::empty();
// get the parent's ancestry if initialized.
@@ -38,31 +38,31 @@ address DiemFramework {
if (exists(parent)) {
let parent_state = borrow_global_mut(parent);
let parent_tree = *&parent_state.tree;
- print(&100210);
+ // print(&100210);
if (Vector::length(&parent_tree) > 0) {
Vector::append(&mut new_tree, parent_tree);
};
- print(&100220);
+ // print(&100220);
};
// add the parent to the tree
Vector::push_back(&mut new_tree, parent);
- print(&100230);
+ // print(&100230);
if (!exists(child)) {
move_to(new_account_sig, Ancestry {
tree: new_tree,
});
- print(&100240);
+ // print(&100240);
} else {
// this is only for migration cases.
let child_ancestry = borrow_global_mut(child);
child_ancestry.tree = new_tree;
- print(&100250);
+ // print(&100250);
};
- print(&100260);
+ // print(&100260);
}
@@ -80,40 +80,40 @@ address DiemFramework {
public fun is_family(left: address, right: address): (bool, address) acquires Ancestry {
let is_family = false;
let common_ancestor = @0x0;
- print(&100300);
- print(&exists(left));
- print(&exists(right));
+ // // print(&100300);
+ // // print(&exists(left));
+ // // print(&exists(right));
// if (exists(left) && exists(right)) {
// if tree is empty it will still work.
- print(&100310);
+ // // print(&100310);
let left_tree = get_tree(left);
- print(&100311);
+ // // print(&100311);
let right_tree = get_tree(right);
- print(&100320);
+ // // print(&100320);
// check for direct relationship.
if (Vector::contains(&left_tree, &right)) return (true, right);
if (Vector::contains(&right_tree, &left)) return (true, left);
- print(&100330);
+ // // print(&100330);
let i = 0;
// check every address on the list if there are overlaps.
while (i < Vector::length(&left_tree)) {
- print(&100341);
+ // // print(&100341);
let family_addr = Vector::borrow(&left_tree, i);
if (Vector::contains(&right_tree, family_addr)) {
is_family = true;
common_ancestor = *family_addr;
- print(&100342);
+ // // print(&100342);
break
};
i = i + 1;
};
- print(&100350);
+ // // print(&100350);
// };
- print(&100360);
+ // // print(&100360);
(is_family, common_ancestor)
}
@@ -160,13 +160,13 @@ address DiemFramework {
move_to(child_sig, Ancestry {
tree: migrate_tree,
});
- print(&100240);
+ // print(&100240);
} else {
// this is only for migration cases.
let child_ancestry = borrow_global_mut(child);
child_ancestry.tree = migrate_tree;
- print(&100250);
+ // print(&100250);
};
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/AutoPay.move b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/AutoPay.move
index 2a6818e2cc..62b6ff71b5 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/AutoPay.move
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/AutoPay.move
@@ -16,7 +16,6 @@ address DiemFramework {
use Std::FixedPoint32;
use DiemFramework::DiemConfig;
use Std::Errors;
- use DiemFramework::CommunityWallet;
use DiemFramework::Roles;
/// Attempted to send funds to an account that does not exist
@@ -51,8 +50,8 @@ address DiemFramework {
const INVALID_PERCENTAGE: u64 = 010022;
/// Attempt to use a UID that is already taken
const UID_TAKEN: u64 = 010023;
- /// Attempt to make a payment to a non-community-wallet
- const PAYEE_NOT_COMMUNITY_WALLET: u64 = 010024;
+ // /// Attempt to make a payment to a non-community-wallet
+ // const PAYEE_NOT_COMMUNITY_WALLET: u64 = 010024;
// triggered once per epoch
struct Tick has key {
@@ -202,7 +201,6 @@ address DiemFramework {
let bal_change_since_last_run = if (pre_run_bal > my_autopay_state.prev_bal) {
pre_run_bal - my_autopay_state.prev_bal
} else { 0 };
-
// go through the pledges
while (payments_idx < payments_len) {
let payment = Vector::borrow_mut(payments, payments_idx);
@@ -231,10 +229,6 @@ address DiemFramework {
payment: &mut Payment,
bal_change_since_last_run: u64,
): bool {
- // check payees are community wallets, only community wallets are allowed
- // to receive autopay (bypassing account limits)
- if (!CommunityWallet::is_comm(payment.payee)) { return false }; // do nothing but don't delete instruction };
-
Roles::assert_diem_root(vm);
let epoch = DiemConfig::get_current_epoch();
let account_bal = DiemAccount::balance(*account_addr);
@@ -268,9 +262,9 @@ address DiemFramework {
// in remaining cases, payment is simple amount given, not a percentage
payment.amt
};
-
+
if (amount != 0 && amount <= account_bal) {
- DiemAccount::vm_make_payment_no_limit(
+ DiemAccount::vm_pay_from(
*account_addr, payment.payee, amount, b"autopay", b"", vm
);
};
@@ -341,16 +335,16 @@ address DiemFramework {
payee: address,
end_epoch: u64,
amt: u64
- ) acquires UserAutoPay, AccountLimitsEnable {
+ ) acquires UserAutoPay {
let addr = Signer::address_of(sender);
// Confirm that no payment exists with the same uid
let index = find(addr, uid);
assert!(Option::is_none(&index), Errors::invalid_argument(UID_TAKEN));
- // TODO: This check already exists at the time of execution.
- if (borrow_global(@DiemRoot).enabled) {
- assert!(CommunityWallet::is_comm(payee), Errors::invalid_argument(PAYEE_NOT_COMMUNITY_WALLET));
- };
+ // // TODO: This check already exists at the time of execution.
+ // if (borrow_global(@DiemRoot).enabled) {
+ // assert!(CommunityWallet::is_comm(payee), Errors::invalid_argument(PAYEE_NOT_COMMUNITY_WALLET));
+ // };
let payments = &mut borrow_global_mut(addr).payments;
assert!(
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Burn.move b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Burn.move
index fada758c2a..f1f010f89e 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Burn.move
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Burn.move
@@ -6,8 +6,9 @@ module Burn {
use DiemFramework::DiemAccount;
use DiemFramework::CoreAddresses;
use DiemFramework::GAS::GAS;
+ use DiemFramework::TransactionFee;
use Std::Signer;
- use DiemFramework::Debug::print;
+ use DiemFramework::Diem::{Self, Diem};
struct BurnPreference has key {
send_community: bool
@@ -19,6 +20,36 @@ module Burn {
ratio: vector,
}
+
+ public fun epoch_burn_fees(
+ vm: &signer,
+ ) acquires BurnPreference, DepositInfo {
+ CoreAddresses::assert_vm(vm);
+ // extract fees
+ let coins = TransactionFee::vm_withdraw_all_coins(vm);
+
+ // get the list of fee makers
+ // let state = borrow_global(@VMReserved);
+ let fee_makers = TransactionFee::get_fee_makers();
+ let len = Vector::length(&fee_makers);
+
+ // for every user in the list burn their fees per Burn.move preferences
+ let i = 0;
+ while (i < len) {
+ let user = Vector::borrow(&fee_makers, i);
+ let amount = TransactionFee::get_epoch_fees_made(*user);
+ let user_share = Diem::withdraw(&mut coins, amount);
+ burn_or_recycle_user_fees(vm, *user, user_share);
+
+ i = i + 1;
+ };
+
+ // Superman 3 decimal errors. https://www.youtube.com/watch?v=N7JBXGkBoFc
+ // anything that is remaining should be burned
+ Diem::vm_burn_this_coin(vm, coins);
+ }
+
+
public fun reset_ratios(vm: &signer) acquires DepositInfo {
CoreAddresses::assert_diem_root(vm);
let list = DonorDirected::get_root_registry();
@@ -38,13 +69,15 @@ module Burn {
i = i + 1;
};
+ if (global_deposits == 0) return;
+
let ratios_vec = Vector::empty();
let k = 0;
while (k < len) {
let cumu = *Vector::borrow(&deposit_vec, k);
let ratio = FixedPoint32::create_from_rational(cumu, global_deposits);
- print(&ratio);
+ // print(&ratio);
Vector::push_back(&mut ratios_vec, ratio);
k = k + 1;
@@ -72,59 +105,51 @@ module Burn {
}
// calculate the ratio which the community wallet should receive
- fun get_value(payee: address, value: u64): u64 acquires DepositInfo {
+ fun get_payee_value(payee: address, value: u64): u64 acquires DepositInfo {
if (!exists(@VMReserved))
return 0;
let d = borrow_global(@VMReserved);
- let contains = Vector::contains(&d.addr, &payee);
- print(&contains);
+ let _contains = Vector::contains(&d.addr, &payee);
+ // print(&contains);
let (is_found, i) = Vector::index_of(&d.addr, &payee);
if (is_found) {
- print(&is_found);
+ // print(&is_found);
let len = Vector::length(&d.ratio);
- print(&i);
- print(&len);
+ // print(&i);
+ // print(&len);
if (i + 1 > len) return 0;
let ratio = *Vector::borrow(&d.ratio, i);
if (FixedPoint32::is_zero(copy ratio)) return 0;
- print(&ratio);
+ // print(&ratio);
return FixedPoint32::multiply_u64(value, ratio)
};
0
}
- public fun epoch_start_burn(
- vm: &signer, payer: address, value: u64
+ public fun burn_or_recycle_user_fees(
+ vm: &signer, payer: address, user_share: Diem
) acquires DepositInfo, BurnPreference {
CoreAddresses::assert_vm(vm);
if (exists(payer)) {
if (borrow_global(payer).send_community) {
- return send(vm, payer, value)
- } else {
- return burn(vm, payer, value)
+ recycle(vm, payer, &mut user_share);
}
- } else {
- burn(vm, payer, value);
- };
- }
+ };
- fun burn(vm: &signer, addr: address, value: u64) {
- DiemAccount::vm_burn_from_balance(
- addr,
- value,
- b"burn",
- vm,
- );
+ // Superman 3
+ Diem::vm_burn_this_coin(vm, user_share);
}
- fun send(vm: &signer, payer: address, value: u64) acquires DepositInfo {
+ fun recycle(vm: &signer, payer: address, coin: &mut Diem) acquires DepositInfo {
let list = get_address_list();
let len = Vector::length(&list);
- print(&list);
+
+ let total_coin_value_to_recycle = Diem::value(coin);
+ // print(&list);
// There could be errors in the array, and underpayment happen.
let value_sent = 0;
@@ -132,27 +157,23 @@ module Burn {
let i = 0;
while (i < len) {
let payee = *Vector::borrow(&list, i);
- print(&payee);
- let val = get_value(payee, value);
- print(&val);
+ // print(&payee);
+ let amount_to_payee = get_payee_value(payee, total_coin_value_to_recycle);
+ // print(&val);
+
+ let to_deposit = Diem::withdraw(coin, amount_to_payee);
- DiemAccount::vm_make_payment_no_limit(
+ DiemAccount::vm_deposit_with_metadata(
+ vm,
payer,
payee,
- val,
- b"epoch start send",
+ to_deposit,
+ b"recycle",
b"",
- vm,
);
- value_sent = value_sent + val;
+ value_sent = value_sent + amount_to_payee;
i = i + 1;
};
-
- // prevent under-burn due to issues with index.
- // let diff = value - value_sent;
- // if (diff > 0) {
- // burn(vm, payer, diff)
- // };
}
public fun set_send_community(sender: &signer, community: bool) acquires BurnPreference {
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Cases.move b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Cases.move
index ad92bc7f7e..638897ea03 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Cases.move
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Cases.move
@@ -10,15 +10,17 @@ 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::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_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.
// This happens at an epoch prologue, and labels the validator based on
// performance in the outgoing epoch.
@@ -32,28 +34,31 @@ address DiemFramework{
// this is a failure mode. Only usually seen in rescue missions,
// where epoch counters are reconfigured by writeset offline.
- if (height_end < height_start) return VALIDATOR_DOUBLY_NOT_COMPLIANT;
+ if (height_end < height_start) return INVALID_DATA;
Roles::assert_diem_root(vm);
// did the validator sign blocks above threshold?
let signs = Stats::node_above_thresh(vm, node_addr, height_start, height_end);
- let mines = TowerState::node_above_thresh(node_addr);
+ // let mines = TowerState::node_above_thresh(node_addr);
- if (signs && mines) {
+ if (signs) {
// compliant: in next set, gets paid, weight increments
VALIDATOR_COMPLIANT
- }
- 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
}
+ // V6: 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.
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DemoBonding.move b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DemoBonding.move
index 5d0d04fd49..0b95d00950 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DemoBonding.move
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DemoBonding.move
@@ -2,7 +2,7 @@
address DiemFramework {
module DemoBonding {
use DiemFramework::Decimal;
- use DiemFramework::Debug::print;
+ // use DiemFramework::Debug::print;
struct CurveState has key {
is_deprecated: bool,
@@ -51,30 +51,30 @@ module DemoBonding {
public fun deposit_calc(add_to_reserve: u128, reserve: u128, supply: u128): u128 {
let one = Decimal::new(true, 1, 0);
- print(&one);
+ // print(&one);
let add_dec = Decimal::new(true, add_to_reserve, 0);
- print(&add_dec);
+ // print(&add_dec);
let reserve_dec = Decimal::new(true, reserve, 0);
- print(&reserve_dec);
+ // print(&reserve_dec);
let supply_dec = Decimal::new(true, supply, 0);
- print(&supply_dec);
+ // print(&supply_dec);
// formula:
// supply * sqrt(one+(add_to_reserve/reserve))
let a = Decimal::div(&add_dec, &reserve_dec);
- print(&a);
+ // print(&a);
let b = Decimal::add(&one, &a);
- print(&b);
+ // print(&b);
let c = Decimal::sqrt(&b);
- print(&c);
+ // print(&c);
let d = Decimal::mul(&supply_dec, &c);
- print(&d);
+ // print(&d);
let int = Decimal::borrow_int(&Decimal::trunc(&d));
- print(int);
+ //print(int);
return *int
}
@@ -95,14 +95,14 @@ module DemoBonding {
let state = borrow_global_mut(service_addr);
let post_supply = deposit_calc(deposit, state.reserve, state.supply_issued);
- print(&post_supply);
+ // print(&post_supply);
assert!(post_supply > state.supply_issued, 73570003);
let mint = post_supply - state.supply_issued;
- print(&mint);
+ // print(&mint);
// update the new curve state
state.reserve = state.reserve + deposit;
state.supply_issued = state.supply_issued + mint;
- // print(&state);
+ // // print(&state);
mint
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DiemAccount.move b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DiemAccount.move
index 5436f835de..36b2e991a1 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DiemAccount.move
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DiemAccount.move
@@ -11,6 +11,8 @@ module DiemFramework::DiemAccount {
friend DiemFramework::MakeWhole;
friend DiemFramework::MigrateJail;
friend DiemFramework::Genesis;
+ friend DiemFramework::TestFixtures; // Todo: remove
+ friend DiemFramework::Mock;
use DiemFramework::AccountFreezing;
use DiemFramework::CoreAddresses;
@@ -52,7 +54,7 @@ module DiemFramework::DiemAccount {
// use DiemFramework::DonorDirected;
use DiemFramework::Ancestry;
use DiemFramework::Vouch;
- use DiemFramework::Debug::print;
+ // use DiemFramework::Debug::print;
use DiemFramework::Jail;
use DiemFramework::Testnet;
@@ -163,6 +165,7 @@ module DiemFramework::DiemAccount {
role_id: u64
}
+
const MAX_U64: u128 = 18446744073709551615;
/////// 0L /////////
@@ -298,7 +301,7 @@ module DiemFramework::DiemAccount {
public fun process_escrow(
account: &signer
) acquires EscrowList, AutopayEscrow, Balance, AccountOperationsCapability {
-// print(&01000);
+// // print(&01000);
Roles::assert_diem_root(account);
let account_list = &borrow_global>(
@@ -306,9 +309,9 @@ module DiemFramework::DiemAccount {
).accounts;
let account_len = Vector::length(account_list);
let account_idx = 0;
-// print(&010100);
+// // print(&010100);
while (account_idx < account_len) {
-// print(&010110);
+// // print(&010110);
let EscrowSettings {account: account_addr, share: percentage}
= Vector::borrow(account_list, account_idx);
@@ -325,21 +328,21 @@ module DiemFramework::DiemAccount {
limit_room ,
FixedPoint32::create_from_rational(*percentage, 100)
);
-// print(&010120);
+// // print(&010120);
let amount_sent: u64 = 0;
let payment_list = &mut borrow_global_mut>(*account_addr).list;
let num_payments = FIFO::len>(payment_list);
-// print(&010130);
+// // print(&010130);
// Pay out escrow until limit is reached
while (limit_room > 0 && num_payments > 0) {
-// print(&010131);
+// // print(&010131);
let Escrow {to_account, escrow} = FIFO::pop>(payment_list);
let recipient_coins = borrow_global_mut>(to_account);
let payment_size = Diem::value(&escrow);
-// print(&010132);
+// // print(&010132);
if (payment_size > limit_room) {
-// print(&010133);
+// // print(&010133);
let (coin1, coin2) = Diem::split(escrow, limit_room);
Diem::deposit(&mut recipient_coins.coin, coin2);
let new_escrow = Escrow {
@@ -349,20 +352,20 @@ module DiemFramework::DiemAccount {
FIFO::push_LIFO>(payment_list, new_escrow);
amount_sent = amount_sent + limit_room;
limit_room = 0;
-// print(&010134);
+// // print(&010134);
} else {
-// print(&01015);
+// // print(&01015);
// This entire escrow is being paid out
Diem::deposit(&mut recipient_coins.coin, escrow);
limit_room = limit_room - payment_size;
amount_sent = amount_sent + payment_size;
num_payments = num_payments - 1;
-// print(&010136);
+// // print(&010136);
}
};
//update account limits
if (amount_sent > 0) {
-// print(&010140);
+// // print(&010140);
_ = AccountLimits::update_withdrawal_limits(
amount_sent,
*account_addr,
@@ -370,10 +373,10 @@ module DiemFramework::DiemAccount {
@DiemRoot
).limits_cap
);
-// print(&010141);
+// // print(&010141);
};
-// print(&010150);
+// // print(&010150);
account_idx = account_idx + 1;
}
}
@@ -689,6 +692,8 @@ module DiemFramework::DiemAccount {
Ancestry::init(sender, &new_signer);
Vouch::init(&new_signer);
Vouch::vouch_for(sender, new_account_address);
+ // ProofOfFee::init(&new_signer); // proof of fee causes circular depency if called on account creation.
+ // creation script should call proof of fee after.
set_slow(&new_signer);
new_account_address
@@ -915,7 +920,7 @@ module DiemFramework::DiemAccount {
);
//////// 0L ////////
// if the account wants to be tracked add tracking
- maybe_update_deposit(payee, deposit_value);
+ maybe_update_deposit(payer, payee, deposit_value);
}
spec deposit {
pragma opaque;
@@ -1435,9 +1440,94 @@ module DiemFramework::DiemAccount {
false // 0L todo diem-1.4.1 - new patch, needs review
);
+ Receipts::write_receipt_vm(vm, payer, payee, amount);
+
+ restore_withdraw_capability(cap);
+ }
+
+ /// VM authorized to withdraw a coin if it is to pay a network fee
+ /// e.g. transaction fees, validator PoF auction, etc.
+ /// the amount can be above the transaction limit that
+ /// may exist on an account.
+ public fun vm_pay_user_fee(
+ vm: &signer,
+ payer : address,
+ amount: u64,
+ metadata: vector,
+ ) acquires DiemAccount, Balance, AccountOperationsCapability { //////// 0L ////////
+ if (Signer::address_of(vm) != @DiemRoot) return;
+ // don't try to send a 0 balance, will halt.
+ if (amount < 1) return;
+ // Check there is a payer
+ if (!exists_at(payer)) return;
+ // Check payer's balance is initialized (sanity).
+ if (!exists>(payer)) return;
+
+ // Check the payer is in possession of withdraw token.
+ if (delegated_withdraw_capability(payer)) return;
+
+ // VM should not force an account below 1GAS, since the account may not recover.
+ if (balance(payer) < BOOTSTRAP_COIN_VALUE) return;
+
+ // prevent halting on low balance.
+ // charge the remaining balance if the amount is greater than balance.
+ // User does not accumulate a debt.
+ if (balance(payer) < amount) {
+ amount = balance(payer);
+ };
+
+ // VM can extract the withdraw token.
+ let account = borrow_global_mut(payer);
+ let cap = Option::extract(&mut account.withdraw_capability);
+
+ let coin = withdraw_from(&cap, payer, amount, copy metadata);
+ TransactionFee::pay_fee_and_track(payer, coin);
restore_withdraw_capability(cap);
}
+
+ // respects slow wallet limits
+ public fun vm_pay_from(
+ payer: address,
+ payee: address,
+ amount: u64,
+ metadata: vector,
+ metadata_signature: vector,
+ vm: &signer,
+ ) acquires DiemAccount, Balance, AccountOperationsCapability, CumulativeDeposits, SlowWallet {
+ /////// 0L /////////
+ if (Signer::address_of(vm) != @DiemRoot) return;
+
+ // check amount if it is a slow wallet
+ if (is_slow(payer)) {
+ if (amount > unlocked_amount(payer)) return;
+ };
+
+ // checks first that the slow limits are respected.
+ vm_make_payment_no_limit(
+ payer,
+ payee,
+ amount,
+ metadata,
+ metadata_signature,
+ vm
+ );
+ /////// 0L /////////
+ // in case of slow wallet update the tracker
+ if (is_slow(payer))
+ {decrease_unlocked_tracker(payer, amount);};
+
+ // if a payee is a slow wallet and is receiving funds from ordinary
+ // or another slow wallet's unlocked funds, it counts toward unlocked coins.
+ // the exceptional case is community wallets, which funds don't count toward unlocks. However, the community wallet payment uses a different function: vm_make_payment_no_limit
+ if (is_slow(*&payee)){
+ increase_unlocked_tracker(*&payee, amount);
+ };
+
+
+ maybe_update_deposit(payer, payee, amount);
+ }
+
//////// 0L ////////
/// VM can burn from an account's balance for administrative purposes (e.g. at epoch boundaries)
@@ -1456,9 +1546,9 @@ module DiemFramework::DiemAccount {
// TODO: review this in 5.1
// VM should not force an account below 1GAS, since the account may not recover.
- print(&7777777900002);
+ // print(&7777777900002);
if (balance(addr) < BOOTSTRAP_COIN_VALUE) return;
- print(&7777777900003);
+ // print(&7777777900003);
// prevent halting on low balance.
// burn the remaining balance if the amount is greater than balance
@@ -1467,7 +1557,7 @@ module DiemFramework::DiemAccount {
amount = balance(addr);
};
- print(&amount);
+ // print(&amount);
// Check the payer is in possession of withdraw token.
if (delegated_withdraw_capability(addr)) return;
@@ -1475,7 +1565,7 @@ module DiemFramework::DiemAccount {
let account = borrow_global_mut(addr);
let cap = Option::extract(&mut account.withdraw_capability);
let coin = withdraw_from(&cap, addr, amount, copy metadata);
- print(&coin);
+ // print(&coin);
Diem::vm_burn_this_coin(vm, coin);
restore_withdraw_capability(cap);
}
@@ -1520,10 +1610,15 @@ module DiemFramework::DiemAccount {
// if a payee is a slow wallet and is receiving funds from ordinary
// or another slow wallet's unlocked funds, it counts toward unlocked coins.
// the exceptional case is community wallets, which funds don't count toward unlocks. However, the community wallet payment uses a different function: vm_make_payment_no_limit
- if (is_slow(*&payee))
- {increase_unlocked_tracker(*&payee, amount);}
+ if (is_slow(*&payee)){
+ increase_unlocked_tracker(*&payee, amount);
+ };
+
+
+ maybe_update_deposit(*&cap.account_address, payee, amount);
}
+
/// Withdraw `amount` Diem from the address embedded in `WithdrawCapability` and
/// deposits it into the `payee`'s account balance.
/// The included `metadata` will appear in the `SentPaymentEvent` and `ReceivedPaymentEvent`.
@@ -2191,16 +2286,16 @@ module DiemFramework::DiemAccount {
Testnet::is_testnet();
CoreAddresses::assert_diem_root(creator_account);
let new_account = create_signer(new_account_address);
- print(&400001);
+ // print(&400001);
// Roles::new_parent_vasp_role(creator_account, &new_account);
// VASP::publish_parent_vasp_credential(&new_account, creator_account);
// DualAttestation::publish_credential(&new_account, creator_account, human_name);
// VASPDomain::publish_vasp_domains(&new_account);
Roles::new_user_role_with_proof(&new_account);
make_account(&new_account, auth_key_prefix);
- print(&400002);
+ // print(&400002);
add_currencies_for_account(&new_account, add_all_currencies);
- print(&400003);
+ // print(&400003);
// testnet_root_fund_account
// spec {
@@ -2230,16 +2325,16 @@ module DiemFramework::DiemAccount {
Testnet::is_testnet();
CoreAddresses::assert_diem_root(creator_account);
let new_account = create_signer(new_account_address);
- print(&400001);
+ // print(&400001);
// Roles::new_parent_vasp_role(creator_account, &new_account);
// VASP::publish_parent_vasp_credential(&new_account, creator_account);
// DualAttestation::publish_credential(&new_account, creator_account, human_name);
// VASPDomain::publish_vasp_domains(&new_account);
Roles::new_user_role_with_proof(&new_account);
make_account(&new_account, auth_key_prefix);
- print(&400002);
+ // print(&400002);
add_currencies_for_account(&new_account, add_all_currencies);
- print(&400003);
+ // print(&400003);
// testnet_root_fund_account
// spec {
@@ -2989,7 +3084,8 @@ module DiemFramework::DiemAccount {
);
// NB: `withdraw_from_balance` is not used as limits do not apply to this transaction fee
- TransactionFee::pay_fee(Diem::withdraw(coin, transaction_fee_amount))
+ //////// 0L ////////
+ TransactionFee::pay_fee_and_track(sender, Diem::withdraw(coin, transaction_fee_amount))
}
}
spec epilogue_common {
@@ -3106,16 +3202,16 @@ module DiemFramework::DiemAccount {
Roles::new_validator_role(dr_account, &new_account);
ValidatorConfig::publish(&new_account, dr_account, human_name);
make_account(&new_account, auth_key_prefix);
- /////// 0L /////////
- add_currencies_for_account(&new_account, false);
+ add_currencies_for_account(&new_account, false);
let new_account = create_signer(new_account_address);
set_slow(&new_account);
- /////// 0L /////////
+ // NOTE: issues with testnet
Jail::init(&new_account);
- // ValidatorUniverse::add_self(&new_account);
- // Vouch::init(&new_account);
+ // TODO: why does this fail?
+ // assert!(ValidatorConfig::is_valid(new_account_address), 07171717171);
+
}
spec create_validator_account {
pragma disable_invariants_in_body;
@@ -3462,12 +3558,14 @@ module DiemFramework::DiemAccount {
// with the attached `metadata`
public fun vm_deposit_with_metadata(
vm: &signer,
+ payer: address,
payee: address,
to_deposit: Diem,
metadata: vector,
metadata_signature: vector
) acquires DiemAccount, Balance, CumulativeDeposits { //////// 0L ////////
CoreAddresses::assert_diem_root(vm);
+ let amount = Diem::value(&to_deposit);
deposit(
@DiemRoot,
payee,
@@ -3476,6 +3574,9 @@ module DiemFramework::DiemAccount {
metadata_signature,
false // 0L todo diem-1.4.1 - new patch, needs review
);
+
+ // track if the payee is tracking receipts for governance.
+ Receipts::write_receipt_vm(vm, payer, payee, amount);
}
// for billing. TODO: merge with other implementation on separate branch.
@@ -3508,6 +3609,22 @@ module DiemFramework::DiemAccount {
index: u64,
}
+ //////// 0L ////////
+ // Blockchain Fee helpers
+ // used for example in making all upcoming validators pay PoF fee in advance.
+ public fun vm_multi_pay_fee(vm: &signer, vals: &vector, fee: u64, metadata: &vector) acquires DiemAccount, AccountOperationsCapability, Balance {
+ if (Signer::address_of(vm) != @VMReserved) {
+ return
+ };
+
+ let i = 0u64;
+ while (i < Vector::length(vals)) {
+ let val = Vector::borrow(vals, i);
+ vm_pay_user_fee(vm, *val, fee, *metadata);
+ i = i + 1;
+ };
+ }
+
//////// 0L ////////
// init struct for storing cumulative deposits, for community wallets
public fun init_cumulative_deposits(sender: &signer, starting_balance: u64) {
@@ -3521,7 +3638,7 @@ module DiemFramework::DiemAccount {
};
}
- fun maybe_update_deposit(payee: address, deposit_value: u64) acquires CumulativeDeposits {
+ fun maybe_update_deposit(payer: address, payee: address, deposit_value: u64) acquires CumulativeDeposits {
// update cumulative deposits if the account has the struct.
if (exists(payee)) {
let epoch = DiemConfig::get_current_epoch();
@@ -3529,7 +3646,13 @@ module DiemFramework::DiemAccount {
let cumu = borrow_global_mut(payee);
cumu.value = cumu.value + deposit_value;
cumu.index = cumu.index + index;
+
+ // also write the receipt to the payee's account.
+ Receipts::write_receipt(payer, payee, deposit_value);
+
};
+
+
}
/// adjust the points of the deposits favoring more recent deposits.
@@ -3556,7 +3679,7 @@ module DiemFramework::DiemAccount {
borrow_global(addr).index
}
- public fun is_init(addr: address): bool {
+ public fun is_init_cumu_tracking(addr: address): bool {
exists(addr)
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DiemSystem.move b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DiemSystem.move
index e03979517f..8c66e255c5 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DiemSystem.move
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DiemSystem.move
@@ -21,13 +21,13 @@ module DiemFramework::DiemSystem {
use Std::FixedPoint32;
use DiemFramework::Stats;
use DiemFramework::Cases;
- use DiemFramework::NodeWeight;
/// Information about a Validator Owner.
struct ValidatorInfo has copy, drop, store {
/// The address (account) of the Validator Owner
addr: address,
- /// The voting power of the Validator Owner (currently always 1).
+ //////// 0L ////////
+ /// The voting power of the Validator Owner (since V6 is always 10).
consensus_voting_power: u64,
/// Configuration information about the Validator, such as the
/// Validator Operator, human name, and info such as consensus key
@@ -734,7 +734,14 @@ module DiemFramework::DiemSystem {
Vector::push_back(&mut next_epoch_validators, ValidatorInfo {
addr: account_address,
config, // copy the config over to ValidatorSet
- consensus_voting_power: 1 + NodeWeight::proof_of_weight(account_address),
+ //// V6 ////
+ // CONSENSUS CRITICAL
+ // ALL EYES ON THIS
+ // PROOF OF FEE
+ // All nodes will have equal voting power as per the PoF paper.
+ consensus_voting_power: 10,
+ // "you can syndicate any boat you row"
+ //// end V6 ////
last_config_update_time: DiemTimestamp::now_microseconds(),
});
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DonorDirected.move b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DonorDirected.move
index 42b36b0ae8..93e1135a4d 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DonorDirected.move
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/DonorDirected.move
@@ -37,6 +37,9 @@ module DonorDirected {
use DiemFramework::DiemAccount::{Self, WithdrawCapability};
use DiemFramework::DonorDirectedGovernance;
use DiemFramework::Ballot;
+ // use DiemFramework::Testnet;
+
+ // use DiemFramework::Debug::print;
/// Not initialized as a donor directed account.
const ENOT_INIT_DONOR_DIRECTED: u64 = 231001;
@@ -53,6 +56,14 @@ module DonorDirected {
const VETO: u8 = 2;
const PAID: u8 = 3;
+ /// number of epochs to wait before a transaction is executed
+ /// Veto can happen in this time
+ /// at the end of the third epoch from when multisig gets consensus
+ const DEFAULT_PAYMENT_DURATION: u64 = 3;
+ /// minimum amount of time to evaluate when one donor flags for veto.
+ const DEFAULT_VETO_DURATION: u64 = 7;
+
+
// root registry for the donor directed accounts
struct Registry has key {
list: vector
@@ -116,16 +127,9 @@ module DonorDirected {
// 3. Once the MultiSig is initialized, the account needs to be bricked, before the MultiSig can be used.
- public fun set_donor_directed(sig: &signer) acquires Registry {
+ public fun set_donor_directed(sig: &signer) {
if (!exists(@VMReserved)) return;
- let addr = Signer::address_of(sig);
- let list = get_root_registry();
- if (!Vector::contains(&list, &addr)) {
- let s = borrow_global_mut(@VMReserved);
- Vector::push_back(&mut s.list, addr);
- };
-
move_to(
sig,
Freeze {
@@ -141,11 +145,25 @@ module DonorDirected {
veto: Vector::empty(),
paid: Vector::empty(),
guid_capability,
- })
+ });
+
+ DonorDirectedGovernance::init_donor_governance(sig);
+ }
+
+ // add to root registry
+ fun add_to_registry(sig: &signer) acquires Registry {
+ if (!exists(@VMReserved)) return;
+ let addr = Signer::address_of(sig);
+ let list = get_root_registry();
+ if (!Vector::contains(&list, &addr)) {
+ let s = borrow_global_mut(@VMReserved);
+ Vector::push_back(&mut s.list, addr);
+ };
}
+
/// Like any MultiSig instance, a sponsor which is the original owner of the account, needs to initialize the account.
/// The account must be "bricked" by the owner before MultiSig actions can be taken.
/// Note, as with any multisig, the new_authorities cannot include the sponsor, since that account will no longer be able to sign transactions.
@@ -225,14 +243,12 @@ module DonorDirected {
let multisig_address = DiemAccount::get_withdraw_cap_address(withdraw_capability);
let transfers = borrow_global_mut(multisig_address);
- // let uid = GUID::create_with_capability(multisig_address, &transfers.guid_capability);
- // add current epoch + 1
- let current_epoch = DiemConfig::get_current_epoch();
-
+ let deadline = DiemConfig::get_current_epoch() + DEFAULT_PAYMENT_DURATION;
+
let t = TimedTransfer {
uid: *uid,
- deadline: current_epoch + 7, // pays automativally at the end of seventh epoch. Unless there is a veto by a Donor. In that case a day is added for every day there is a veto. This deduplicates Vetos.
+ deadline, // pays automatically at the end of seventh epoch. Unless there is a veto by a Donor. In that case a day is added for every day there is a veto. This deduplicates Vetos.
tx,
epoch_latest_veto_received: 0,
};
@@ -247,6 +263,7 @@ module DonorDirected {
/// needing to intervene.
public fun process_donor_directed_accounts(
vm: &signer,
+ epoch: u64,
) acquires Registry, TxSchedule, Freeze {
let list = get_root_registry();
@@ -256,23 +273,29 @@ module DonorDirected {
let multisig_address = Vector::borrow(&list, i);
if (exists(*multisig_address)) {
let state = borrow_global_mut(*multisig_address);
- maybe_pay_if_deadline_today(vm, state);
+ maybe_pay_deadline(vm, state, epoch);
};
i = i + 1;
}
}
- fun maybe_pay_if_deadline_today(vm: &signer, state: &mut TxSchedule) acquires Freeze {
- let epoch = DiemConfig::get_current_epoch();
+ fun maybe_pay_deadline(vm: &signer, state: &mut TxSchedule, epoch: u64) acquires Freeze {
+ // let epoch = DiemConfig::get_current_epoch();
let i = 0;
+
while (i < Vector::length(&state.scheduled)) {
let this_exp = *&Vector::borrow(&state.scheduled, i).deadline;
if (this_exp == epoch) {
- let t = Vector::remove(&mut state.scheduled, i);
+ let t = Vector::remove(&mut state.scheduled, i);
+ // print(&t);
let multisig_address = GUID::id_creator_address(&t.uid);
- DiemAccount::vm_make_payment_no_limit(multisig_address, t.tx.payee, t.tx.value, *&t.tx.description, b"", vm);
+
+ // Note the VM can do this without the WithdrawCapability
+ let coin = DiemAccount::vm_withdraw(vm, multisig_address, t.tx.value);
+ DiemAccount::vm_deposit_with_metadata(vm, multisig_address, t.tx.payee, coin, *&t.tx.description, b"");
+
// update the records
Vector::push_back(&mut state.paid, t);
@@ -286,6 +309,25 @@ module DonorDirected {
}
+ public fun find_by_deadline(multisig_address: address, epoch: u64): vector acquires TxSchedule {
+ let state = borrow_global_mut(multisig_address);
+ let i = 0;
+ let list = Vector::empty();
+
+ while (i < Vector::length(&state.scheduled)) {
+
+ let prop = Vector::borrow(&state.scheduled, i);
+ if (prop.deadline == epoch) {
+ Vector::push_back(&mut list, *&prop.uid);
+ };
+
+ i = i + 1;
+ };
+
+ list
+ }
+
+
//////// GOVERNANCE HANDLERS ////////
@@ -369,13 +411,13 @@ module DonorDirected {
}
public fun get_pending_timed_transfer_mut(state: &mut TxSchedule, uid: &GUID::ID): &mut TimedTransfer {
- let (found, i) = find_schedule_status(state, uid, SCHEDULED);
+ let (found, i) = schedule_status(state, uid, SCHEDULED);
assert!(found, Errors::invalid_argument(ENO_PEDNING_TRANSACTION_AT_UID));
Vector::borrow_mut(&mut state.scheduled, i)
}
- public fun find_schedule_status(state: &TxSchedule, uid: &GUID::ID, state_enum: u8): (bool, u64) {
+ public fun schedule_status(state: &TxSchedule, uid: &GUID::ID, state_enum: u8): (bool, u64) {
let list = if (state_enum == SCHEDULED) { &state.scheduled }
else if (state_enum == VETO) { &state.veto }
else if (state_enum == PAID) { &state.paid }
@@ -397,14 +439,14 @@ module DonorDirected {
(false, 0)
}
- public fun find_anywhere(state: &TxSchedule, uid: &GUID::ID): (bool, u64, u8) { // (is_found, index, state)
- let (found, i) = find_schedule_status(state, uid, SCHEDULED);
+ public fun find_schedule_by_id(state: &TxSchedule, uid: &GUID::ID): (bool, u64, u8) { // (is_found, index, state)
+ let (found, i) = schedule_status(state, uid, SCHEDULED);
if (found) return (found, i, SCHEDULED);
- let (found, i) = find_schedule_status(state, uid, VETO);
+ let (found, i) = schedule_status(state, uid, VETO);
if (found) return (found, i, VETO);
- let (found, i) = find_schedule_status(state, uid, PAID);
+ let (found, i) = schedule_status(state, uid, PAID);
if (found) return (found, i, PAID);
(false, 0, 0)
@@ -416,33 +458,37 @@ module DonorDirected {
}
+ /// Check the status of proposals in the MultiSig Workflow
+ /// NOTE: These are payments that have not yet been scheduled.
+ public fun get_multisig_proposal_state(directed_address: address, uid: &GUID::ID): (bool, u64, u8, bool) { // (is_found, index, state)
+
+ MultiSig::get_proposal_status_by_id(directed_address, uid)
+ }
- public fun get_proposal_state(directed_address: address, uid: &GUID::ID): (bool, u64, u8) acquires TxSchedule { // (is_found, index, state)
+ /// Get the status of a SCHEDULED payment which as already passed the multisig stage.
+ public fun get_schedule_state(directed_address: address, uid: &GUID::ID): (bool, u64, u8) acquires TxSchedule { // (is_found, index, state)
let state = borrow_global(directed_address);
- find_anywhere(state, uid)
+ find_schedule_by_id(state, uid)
}
- public fun is_pending(directed_address: address, uid: &GUID::ID): bool acquires TxSchedule { // (is_found, index, state)
- let state = borrow_global(directed_address);
- let (_, _, state) = find_anywhere(state, uid);
+ public fun is_scheduled(directed_address: address, uid: &GUID::ID): bool acquires TxSchedule {
+ let (_, _, state) = get_schedule_state(directed_address, uid);
state == Ballot::get_pending_enum()
}
- public fun is_approved(directed_address: address, uid: &GUID::ID): bool acquires TxSchedule { // (is_found, index, state)
- let state = borrow_global(directed_address);
- let (_, _, state) = find_anywhere(state, uid);
+ public fun is_paid(directed_address: address, uid: &GUID::ID): bool acquires TxSchedule {
+ let (_, _, state) = get_schedule_state(directed_address, uid);
state == Ballot::get_approved_enum()
}
- public fun is_rejected(directed_address: address, uid: &GUID::ID): bool acquires TxSchedule { // (is_found, index, state)
- let state = borrow_global(directed_address);
- let (_, _, state) = find_anywhere(state, uid);
+ public fun is_veto(directed_address: address, uid: &GUID::ID): bool acquires TxSchedule {
+ let (_, _, state) = get_schedule_state(directed_address, uid);
state == Ballot::get_rejected_enum()
}
// getter to check if wallet is frozen
// used in DiemAccount before attempting a transfer.
- public fun is_frozen(addr: address): bool acquires Freeze{
+ public fun is_account_frozen(addr: address): bool acquires Freeze{
let f = borrow_global(addr);
f.is_frozen
}
@@ -452,17 +498,21 @@ module DonorDirected {
/// Initialize the TxSchedule wallet with Three Signers
// TODO: this version of Diem, does not allow vector in the script arguments. So we are hard coding this to initialize with three signers. Gross.
- public fun init_donor_directed(sponsor: &signer, signer_one: address, signer_two: address, signer_three: address, cfg_n_signers: u64) acquires Registry {
+ public fun init_donor_directed(sponsor: &signer, signer_one: address, signer_two: address, signer_three: address, cfg_n_signers: u64) {
let init_signers = Vector::singleton(signer_one);
Vector::push_back(&mut init_signers, signer_two);
Vector::push_back(&mut init_signers, signer_three);
set_donor_directed(sponsor);
make_multisig(sponsor, cfg_n_signers, init_signers);
+
+ // if not tracking cumulative donations, then don't use previous balance.
+ // start again.
+ DiemAccount::init_cumulative_deposits(sponsor, 0);
}
/// the sponsor must finalize the initialization, this is a separate step so that the user can optionally check everything is in order before bricking the account key.
- public fun finalize_init(sponsor: &signer) {
+ public fun finalize_init(sponsor: &signer) acquires Registry {
let multisig_address = Signer::address_of(sponsor);
assert!(MultiSig::is_init(multisig_address), Errors::invalid_state(EMULTISIG_NOT_INIT));
@@ -474,6 +524,9 @@ module DonorDirected {
MultiSig::finalize_and_brick(sponsor);
assert!(is_donor_directed(multisig_address), Errors::invalid_state(ENOT_INIT_DONOR_DIRECTED));
+
+ // only add to registry if INIT is successful.
+ add_to_registry(sponsor);
}
/// propose and vote on the liquidation of this wallet
@@ -487,10 +540,14 @@ module DonorDirected {
/// propose and vote on the veto of a specific transacation
public fun propose_veto(donor: &signer, multisig_address: address, uid: u64) acquires TxSchedule {
let guid = GUID::create_id(multisig_address, uid);
+ // print(&01);
DonorDirectedGovernance::assert_authorized(donor, multisig_address);
+ // print(&02);
let state = borrow_global(multisig_address);
- let epochs_duration = 7;
+ // print(&03);
+ let epochs_duration = DEFAULT_VETO_DURATION;
DonorDirectedGovernance::propose_veto(&state.guid_capability, &guid, epochs_duration);
+ // print(&04);
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Epoch.move b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Epoch.move
index 6fd19766a8..e92f92d35b 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Epoch.move
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/Epoch.move
@@ -66,15 +66,15 @@ module Epoch {
}
/// Accessor Function, returns the time (in seconds) of the start of the current epoch
- public fun get_timer_seconds_start(vm: &signer):u64 acquires Timer {
- Roles::assert_diem_root(vm);
+ public fun get_timer_seconds_start():u64 acquires Timer {
+ // Roles::assert_diem_root(vm);
let time = borrow_global(@DiemRoot);
time.seconds_start
}
/// Accessor Function, returns the block height of the start of the current epoch
- public fun get_timer_height_start(vm: &signer):u64 acquires Timer {
- Roles::assert_diem_root(vm);
+ public fun get_timer_height_start():u64 acquires Timer {
+ // Roles::assert_diem_root(vm);
let time = borrow_global(@DiemRoot);
time.height_start
}
diff --git a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/EpochBoundary.move b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/EpochBoundary.move
index 8c19cddfdc..6e483b5997 100644
--- a/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/EpochBoundary.move
+++ b/diem-move/diem-framework/DPN/releases/artifacts/current/build/DPNFramework/sources/EpochBoundary.move
@@ -11,7 +11,7 @@ address DiemFramework {
module EpochBoundary {
use DiemFramework::CoreAddresses;
use DiemFramework::Subsidy;
- use DiemFramework::NodeWeight;
+ use DiemFramework::ProofOfFee;
use DiemFramework::DiemSystem;
use DiemFramework::TowerState;
use DiemFramework::Globals;
@@ -20,61 +20,70 @@ module EpochBoundary {
use DiemFramework::AutoPay;
use DiemFramework::Epoch;
use DiemFramework::DiemConfig;
- use DiemFramework::Audit;
use DiemFramework::DiemAccount;
use DiemFramework::Burn;
- use DiemFramework::FullnodeSubsidy;
- use DiemFramework::ValidatorUniverse;
- use DiemFramework::Debug::print;
- use DiemFramework::Testnet;
- use DiemFramework::StagingNet;
+ use DiemFramework::FullnodeSubsidy;
use DiemFramework::RecoveryMode;
- use DiemFramework::Cases;
use DiemFramework::Jail;
- use DiemFramework::Vouch;
+ use DiemFramework::TransactionFee;
use DiemFramework::MultiSigPayment;
use DiemFramework::DonorDirected;
+ //// V6 ////
+ // THIS IS TEMPORARY
+ // depends on the future "musical chairs" algo.
+ const MOCK_VAL_SIZE: u64 = 21;
+
+ // TODO: this will depend on an adjustment algo.
+ // const MOCK_BASELINE_CONSENSUS_FEES: u64 = 1000000;
+
+
// This function is called by block-prologue once after n blocks.
// Function code: 01. Prefix: 180001
public fun reconfigure(vm: &signer, height_now: u64) {
CoreAddresses::assert_vm(vm);
- let height_start = Epoch::get_timer_height_start(vm);
- print(&800100);
+
+ let height_start = Epoch::get_timer_height_start();
+ // print(&800100);
+
let (outgoing_compliant_set, _) =
DiemSystem::get_fee_ratio(vm, height_start, height_now);
- print(&800200);
+
+ // print(&800200);
// NOTE: This is "nominal" because it doesn't check
- let compliant_nodes_count = Vector::length(&outgoing_compliant_set);
- print(&800300);
+ // let compliant_nodes_count = Vector::length(&outgoing_compliant_set);
+ // print(&800300);
+
+ // TODO: subsidy units are fixed
+ // let (subsidy_units, nominal_subsidy_per) =
+ // Subsidy::calculate_subsidy(vm, compliant_nodes_count);
+ // print(&800400);
+
+ let (reward, _, _) = ProofOfFee::get_consensus_reward();
+ process_fullnodes(vm, reward);
+
+ // print(&800500);
+
+ process_validators(vm, reward, &outgoing_compliant_set);
+ // print(&800600);
+
+ // process the non performing nodes: jail
+ process_jail(vm, &outgoing_compliant_set);
- let (subsidy_units, nominal_subsidy_per) =
- Subsidy::calculate_subsidy(vm, compliant_nodes_count);
- print(&800400);
+ let proposed_set = propose_new_set(vm, &outgoing_compliant_set);
- process_fullnodes(vm, nominal_subsidy_per);
- print(&800500);
- process_validators(vm, subsidy_units, *&outgoing_compliant_set);
- print(&800600);
- let proposed_set = propose_new_set(vm, height_start, height_now);
- print(&800700);
// Update all slow wallet limits
DiemAccount::slow_wallet_epoch_drip(vm, Globals::get_unlock()); // todo
- print(&800800);
-
- if (!RecoveryMode::is_recovery()) {
- proof_of_burn(vm,nominal_subsidy_per, &proposed_set);
- print(&800900);
- };
+ // print(&801000);
root_service_billing(vm);
- print(&801000);
+ // print(&801000);
reset_counters(vm, proposed_set, outgoing_compliant_set, height_now);
- print(&801100);
+ // print(&801100);
}
@@ -116,136 +125,85 @@ module EpochBoundary {
}
fun process_validators(
- vm: &signer, subsidy_units: u64, outgoing_compliant_set: vector
+ vm: &signer, subsidy_units: u64, outgoing_compliant_set: &vector
) {
// Process outgoing validators:
// Distribute Transaction fees and subsidy payments to all outgoing validators
- if (Vector::is_empty(&outgoing_compliant_set)) return;
+ if (Vector::is_empty(outgoing_compliant_set)) return;
// don't pay while we are in recovery mode, since that creates
// a frontrunning opportunity
if (subsidy_units > 0 && !RecoveryMode::is_recovery()) {
- Subsidy::process_subsidy(vm, subsidy_units, &outgoing_compliant_set);
+ Subsidy::process_subsidy(vm, subsidy_units, outgoing_compliant_set);
};
- Subsidy::process_fees(vm, &outgoing_compliant_set);
- }
+ // after everyone is paid from the chain's Fee account
+ // we can burn the excess fees from the epoch
- fun propose_new_set(vm: &signer, height_start: u64, height_now: u64): vector
- {
- // Propose upcoming validator set:
- // Get validators we know to be in consensus correctly: Case1 and Case2
- // Only expand the amount of seats so that the new set has a max of 25%
- // unproven nodes. I.e. nodes that were not in the previous epoch and
- // we have stats on.
-
- // in emergency admin roles set the validator set
- // there may be a recovery set to be used.
- // if there is no rescue mission validators, just do usual procedure.
-
- if (RecoveryMode::is_recovery()) {
- let recovery_vals = RecoveryMode::get_debug_vals();
- if (Vector::length(&recovery_vals) > 0) return recovery_vals;
- };
-
- // Process all the jail terms of the previous validator set
- let previous_set = DiemSystem::get_val_set_addr();
-
- // Take advantage of this loop to get the expected size of
- // the validator set that the new set doesn't have
- // 25% of nodes that we don't know their current performance.
- let len_proven_nodes = 0;
+ Burn::epoch_burn_fees(vm);
+ }
+ fun process_jail(vm: &signer, outgoing_compliant_set: &vector) {
+ let all_previous_vals = DiemSystem::get_val_set_addr();
let i = 0;
- while (i < Vector::length(&previous_set)) {
- let addr = *Vector::borrow(&previous_set, i);
- let case = Cases::get_case(vm, addr, height_start, height_now);
+ while (i < Vector::length