-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move] change data structure for tracking miner proofs used in Carpe …
…payments (#890) * scaffold new struct to count global proofs TowerCounter * update Migration to include a migration from TowerState to TowerCounter * change the Migration Tick from end of epoch to every round 3, after upgrade (round 2) * add test for epoch resetting proof count * hardened test for fullnode subsidy in base case * test for tower counter state migration * test for on the fly migration * add notes/comments on block prologue * divide by zero protection in FullnodeSubsidy * meta test for checking we can destroy state when mocking migration cases * create a separate module for repetitive mocks, Mock.move * create test case for mixed validator cases * legibility of comparison of proofs produced vs threshold * add preflight check docs * create future move tests for prod epoch changes * patch tests and add upgrade documentation * passing tests for fullnode_reconfig
- Loading branch information
1 parent
0b2f290
commit 9d34378
Showing
29 changed files
with
1,347 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Some fixutres are complex and are repeatedly needed | ||
|
||
address 0x1 { | ||
module Mock { | ||
use 0x1::DiemSystem; | ||
use 0x1::TowerState; | ||
use 0x1::Vector; | ||
use 0x1::Stats; | ||
use 0x1::Cases; | ||
|
||
public fun mock_case_1(vm: &signer, addr: address){ | ||
// 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); | ||
|
||
// mock the consensus votes for the address | ||
let voters = Vector::empty<address>(); | ||
Vector::push_back<address>(&mut voters, addr); | ||
|
||
// Overwrite the statistics to mock that all have been validating. | ||
let i = 1; | ||
while (i < 16) { | ||
// Mock the validator doing work for 15 blocks, and stats being updated. | ||
Stats::process_set_votes(vm, &voters); | ||
i = i + 1; | ||
}; | ||
|
||
// TODO: careful that the range of heights is within the test | ||
assert(Cases::get_case(vm, addr, 0 , 1000) == 1, 777703); | ||
|
||
} | ||
|
||
|
||
// did not do enough mining, but did validate. | ||
public fun mock_case_2(vm: &signer, addr: address){ | ||
// 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); | ||
|
||
// mock the consensus votes for the address | ||
let voters = Vector::empty<address>(); | ||
Vector::push_back<address>(&mut voters, addr); | ||
|
||
// Overwrite the statistics to mock that all have been validating. | ||
let i = 1; | ||
while (i < 16) { | ||
// Mock the validator doing work for 15 blocks, and stats being updated. | ||
Stats::process_set_votes(vm, &voters); | ||
i = i + 1; | ||
}; | ||
|
||
// TODO: careful that the range of heights is within the test | ||
assert(Cases::get_case(vm, addr, 0 , 1000) == 2, 777706); | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.