Skip to content

Instantly share code, notes, and snippets.

@cryptozeny
Created January 1, 2019 17:32
Show Gist options
  • Save cryptozeny/11bdcf84ef119c976f1586858542e088 to your computer and use it in GitHub Desktop.
Save cryptozeny/11bdcf84ef119c976f1586858542e088 to your computer and use it in GitHub Desktop.
negativeTimeAttack_test
// Copyright (c) 2015-2017 The Bitcoin Core developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chain.h>
#include <chainparams.h>
#include <pow.h>
#include <random.h>
#include <util.h>
#include <test/test_bitcoin.h>
#include <boost/test/unit_test.hpp>
#include <ctime> // unix_timestamp()
#include <iostream> // unix_timestamp()
BOOST_FIXTURE_TEST_SUITE(pow_tests, BasicTestingSetup)
static CBlockIndex GetBlockIndex(CBlockIndex *pindexPrev, int64_t nTimeInterval, uint32_t nBits) {
CBlockIndex block;
block.pprev = pindexPrev;
block.nHeight = pindexPrev->nHeight + 1;
block.nTime = pindexPrev->nTime + nTimeInterval;
block.nBits = nBits;
block.nChainWork = pindexPrev->nChainWork + GetBlockProof(block);
return block;
}
/* BEGIN - GETDIFFICULTY */
/* Calculate the difficulty for a given block index,
* or the block index of the given chain.
*/
double GetDifficulty(const CChain& chain, const CBlockIndex* blockindex)
{
if (blockindex == nullptr)
{
if (chain.Tip() == nullptr)
return 1.0;
else
blockindex = chain.Tip();
}
int nShift = (blockindex->nBits >> 24) & 0xff;
double dDiff =
(double)0x0000ffff / (double)(blockindex->nBits & 0x00ffffff);
while (nShift < 29)
{
dDiff *= 256.0;
nShift++;
}
while (nShift > 29)
{
dDiff /= 256.0;
nShift--;
}
return dDiff;
}
// CChain CreateChainWithNbits(uint32_t nbits)
// {
// CBlockIndex* block_index = new CBlockIndex();
// block_index->nHeight = 0;
// block_index->nTime = 1541009400;
// block_index->nBits = 0x1f07fffe;
// CChain chain;
// chain.SetTip(block_index);
// return chain;
// }
CBlockIndex* CreateBlockIndexWithNbits(uint32_t nbits)
{
CBlockIndex* block_index = new CBlockIndex();
block_index->nHeight = 0;
block_index->nTime = 1541009400;
block_index->nBits = 0x1f07fffe;
return block_index;
}
CChain CreateChainWithNbits(uint32_t nbits)
{
CBlockIndex* block_index = CreateBlockIndexWithNbits(nbits);
CChain chain;
chain.SetTip(block_index);
return chain;
}
long int unix_timestamp()
{
time_t t = std::time(0);
long int now = static_cast<long int> (t);
return now;
}
BOOST_AUTO_TEST_CASE(negativeTimeAttack_test) {
// Copyright (c) 2018 cryptozeny of the Sugarchain Core developers
const auto chainParams = CreateChainParams(CBaseChainParams::MAIN);
const Consensus::Params &mainnetParams = chainParams->GetConsensus();
// int maxBlockIndex = 2147483647 / 1024;
int maxBlockIndex = INT_MAX / 1024;
std::vector<CBlockIndex> blocks(maxBlockIndex);
// Block counter.
int i = 0;
// powLimit
const arith_uint256 powLimit = UintToArith256(chainParams->GetConsensus().powLimit);
uint32_t powLimitBits = powLimit.GetCompact();
// SetCompact
// https://en.bitcoin.it/wiki/Difficulty
// https://en.bitcoin.it/wiki/Target
arith_uint256 powLimitFromBits;
uint32_t nBits = powLimitBits;
bool fNegative;
bool fOverflow;
powLimitFromBits.SetCompact((unsigned)powLimitBits, &fNegative, &fOverflow); // powLimitBits == 0x1f07ffff
// BEGIN - Check nBits
// arith_uint256 left = UintToArith256(uint256S("0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
arith_uint256 left = powLimit;
uint32_t leftBits = left.GetCompact();
// arith_uint256 right = UintToArith256(uint256S("0007ffff00000000000000000000000000000000000000000000000000000000"));
arith_uint256 right = powLimitFromBits;
uint32_t rightBits = right.GetCompact();
powLimitFromBits.SetCompact((unsigned)powLimitBits, &fNegative, &fOverflow); // powLimitBits == 0x1f07ffff
BOOST_CHECK_EQUAL( leftBits, rightBits ); // 0x1f07ffff
// Genesis Block.
blocks[0] = CBlockIndex();
blocks[0].nHeight = 0;
blocks[0].nTime = 1541009400;
blocks[0].nBits = 0x1f07fffe;
blocks[0].nChainWork = GetBlockProof(blocks[0]);
// Make First Block
blocks[1] = GetBlockIndex(&blocks[0], 15, nBits); // 15 is the first interval
// Init Difficulty
CChain chain = CreateChainWithNbits(nBits); // 0x1f07fffe
double initDifficulty = (double)GetDifficulty(chain, &blocks[0 + 1]);
double currentDifficulty = (double)initDifficulty;
double currentDifficultyRatio = (double)currentDifficulty / (double)initDifficulty;
printf("\n\n\n\n\n\n\n\n\n\n");
printf("*** Show mainnetParams\n");
printf("T = %ld\n", mainnetParams.nPowTargetSpacing);
printf("N = %ld\n", mainnetParams.difficultyAveragingWindowSize);
printf("powLimit =\n");
printf("%s\n", powLimit.ToString().c_str()); // 0x1f07ffff
printf("%s\n", powLimitFromBits.GetHex().c_str()); // 0x1f07ffff
printf("\n");
sleep(1);
// Get Current Timestamp
long int getCurrentTimestamp = unix_timestamp();
// Get Genesis Interval
// int interval = 1541009400;
long int genesisInterval = getCurrentTimestamp - 1541009400;
int interval;
// Print
printf("*** Check Genesis\n");
printf("%-7s %-13s %-13s %-24s %-7s %-14s\n", "Block", "Target(uint)", "Target(hex)", "Diff(double)", "Diff(%)", "Interval");
printf("%-7d %-13u %-13x %-24.16g %-7.3f %-14d\n", i, (unsigned)nBits, (unsigned)nBits, (double)currentDifficulty, (double)currentDifficultyRatio, (int)genesisInterval);
// printf("%-7s %s\n", "", powLimitFromBits.ToString().c_str());
printf("\n");
sleep(1);
// BEGIN - First Window
// Attack Interval
interval = 15;
printf("*** First Window\n");
printf("%-7s %-13s %-13s %-24s %-7s %-14s\n", "Block", "Target(uint)", "Target(hex)", "Diff(double)", "Diff(%)", "Interval");
sleep(1);
for (i = 1; i <= 200+0; i++) {
// Check pindexLast is NOT nullptr!
BOOST_CHECK( &blocks[i - 1] != nullptr );
assert( &blocks[i - 1] != nullptr);
// nBits
nBits = DarkGravityWave(&blocks[i - 1], NULL, chainParams->GetConsensus());
powLimitFromBits.SetCompact((unsigned)nBits, &fNegative, &fOverflow);
// Calculate Current Block
blocks[i] = GetBlockIndex(&blocks[i - 1], interval, nBits); // 0 is Interval
// Make Next Block
blocks[i + 1] = GetBlockIndex(&blocks[i + 0], interval, nBits); // 0 is Interval
// GetDifficulty from Next Block
chain = CreateChainWithNbits((unsigned)nBits);
currentDifficulty = (double)GetDifficulty(chain, &blocks[i + 1]);
currentDifficultyRatio = (double)currentDifficulty / (double)initDifficulty;
// Print
printf("%-7d %-13u %-13x %-24.16g %-7.3f %-14d\n", i, (unsigned)nBits, (unsigned)nBits, (double)currentDifficulty, (double)currentDifficultyRatio, (int)interval);
// printf("%-7s %s\n", "", powLimitFromBits.ToString().c_str());
// Check
BOOST_CHECK_EQUAL( nBits, powLimitBits ); // 0x1f07ffff
BOOST_CHECK_EQUAL( currentDifficulty, initDifficulty ); // 1.907323166912278e-06
}
printf("\n*** First Window Filled\n");
sleep(1);
// END - First Window
// BEGIN - ATTACK
// Attack Interval
// interval = -9999;
printf("\n*** ATTACK: NegativeRandom\n");
printf("%-7s %-13s %-13s %-24s %-7s %-14s\n", "Block", "Target(uint)", "Target(hex)", "Diff(double)", "Diff(%)", "Interval");
sleep(1);
for (i = i + 1; i <= 200+9999; i++) {
// Check pindexLast is NOT nullptr!
BOOST_CHECK( &blocks[i - 1] != nullptr );
assert( &blocks[i - 1] != nullptr);
// Changing Attack Interval
int varInterval;
// output = min + (rand() % static_cast<int>(max - min + 1))
int min = -15;
int max = 15;
varInterval = min + (rand() % static_cast<int>(max - min + 1));
// nBits
nBits = DarkGravityWave(&blocks[i - 1], NULL, chainParams->GetConsensus());
powLimitFromBits.SetCompact((unsigned)nBits, &fNegative, &fOverflow);
// Calculate Current Block
blocks[i] = GetBlockIndex(&blocks[i - 1], varInterval, nBits); // 0 is Interval
// Make Next Block
blocks[i + 1] = GetBlockIndex(&blocks[i + 0], varInterval, nBits); // 0 is Interval
// GetDifficulty from Next Block
chain = CreateChainWithNbits((unsigned)nBits);
currentDifficulty = (double)GetDifficulty(chain, &blocks[i + 1]);
currentDifficultyRatio = (double)currentDifficulty / (double)initDifficulty;
// Print
printf("%-7d %-13u %-13x %-24.16g %-7.3f %-14d\n", i, (unsigned)nBits, (unsigned)nBits, (double)currentDifficulty, (double)currentDifficultyRatio, (int)varInterval);
// printf("%-7s %s\n", "", powLimitFromBits.ToString().c_str());
// Break Test If Fully Restored
// if ( (unsigned)nBits == powLimitBits && (double)currentDifficulty == initDifficulty) {
if ( (double)currentDifficultyRatio >= 2.0 ) {
printf("\n*** currentDifficultyRatio >= 2.0\n");
sleep(1);
break;
}
}
// Check
// BOOST_CHECK_EQUAL( nBits, 486619892 ); // 1d013af4
BOOST_CHECK( currentDifficultyRatio >= 2.0 );
// BOOST_CHECK_EQUAL( nBits, 504667824 ); // 1e149eb0
// BOOST_CHECK_EQUAL( currentDifficulty, 0.00018943813991848115 );
// Print
printf("\n*** ATTACK: NegativeRandom is finished\n");
sleep(1);
// END - ATTACK
// BEGIN - DEFENSE
// Attack Interval
// interval = 0;
printf("\n*** DEFENSE: Random\n");
printf("%-7s %-13s %-13s %-24s %-7s %-14s\n", "Block", "Target(uint)", "Target(hex)", "Diff(double)", "Diff(%)", "Interval");
sleep(1);
for (i = i + 1; i <= 200+9999+9999; i++) {
// Check pindexLast is NOT nullptr!
BOOST_CHECK( &blocks[i - 1] != nullptr );
assert( &blocks[i - 1] != nullptr);
// Changing Attack Interval
int varInterval;
// output = min + (rand() % static_cast<int>(max - min + 1))
int min = -15;
int max = 150;
varInterval = min + (rand() % static_cast<int>(max - min + 1));
// nBits
nBits = DarkGravityWave(&blocks[i - 1], NULL, chainParams->GetConsensus());
powLimitFromBits.SetCompact((unsigned)nBits, &fNegative, &fOverflow);
// Calculate Current Block
blocks[i] = GetBlockIndex(&blocks[i - 1], varInterval, nBits); // 0 is Interval
// Make Next Block
blocks[i + 1] = GetBlockIndex(&blocks[i + 0], varInterval, nBits); // 0 is Interval
// GetDifficulty from Next Block
chain = CreateChainWithNbits((unsigned)nBits);
currentDifficulty = (double)GetDifficulty(chain, &blocks[i + 1]);
currentDifficultyRatio = (double)currentDifficulty / (double)initDifficulty;
// Print
printf("%-7d %-13u %-13x %-24.16g %-7.3f %-14d\n", i, (unsigned)nBits, (unsigned)nBits, (double)currentDifficulty, (double)currentDifficultyRatio, (int)varInterval);
// printf("%-7s %s\n", "", powLimitFromBits.ToString().c_str());
// Break Test If Fully Restored
if ( (unsigned)nBits == powLimitBits && (double)currentDifficulty == initDifficulty) {
printf("\n*** currentDifficulty == initDifficulty\n");
sleep(1);
break;
}
}
// Check
BOOST_CHECK_EQUAL( nBits, powLimitBits ); // 0x1f07ffff
BOOST_CHECK_EQUAL( currentDifficulty, initDifficulty ); // 1.907323166912278e-06
// Print
printf("\n*** DEFENSE: Random is finished\n");
sleep(1);
// END - DEFENSE
}
/*
BOOST_AUTO_TEST_CASE(h4x3rotab_test)
{
// Copyright (c) 2017-2018 h4x3rotab of the Bitcoin Gold
const auto chainParams = CreateChainParams(CBaseChainParams::MAIN);
std::vector<CBlockIndex> blocks(805); // (N * 4) + 5 = (200 * 4) + 5 = 805
for (int i = 0; i < 805; i++) {
blocks[i].pprev = i ? &blocks[i - 1] : nullptr;
blocks[i].nHeight = i;
blocks[i].nTime = 1541009400 + i * chainParams->GetConsensus().nPowTargetSpacing; // block:0
blocks[i].nBits = 0x1f07ffff; // block:0 // 0x1f07ffff = 520617983
blocks[i].nChainWork = i ? blocks[i - 1].nChainWork + GetBlockProof(blocks[i - 1]) : arith_uint256(0);
}
int bits = Lwma3CalculateNextWorkRequired(&blocks.back(), chainParams->GetConsensus());
BOOST_CHECK_EQUAL(bits, 0x1f07fffe); // 0x1f07fffe = 520617983(0x1f07ffff) - 1 = 520617982
}
*/
/*
BOOST_AUTO_TEST_CASE(ishikawa_test) {
// Copyright (c) 2018 ishikawa-pss9 of the Susucoin Core developers
const auto chainParams = CreateChainParams(CBaseChainParams::MAIN);
std::vector<CBlockIndex> blocks(3000);
const arith_uint256 powLimit = UintToArith256(chainParams->GetConsensus().powLimit);
// uint32_t powLimitBits = powLimit.GetCompact();
arith_uint256 currentPow = powLimit >> 4;
uint32_t initialBits = currentPow.GetCompact();
// Genesis block.
blocks[0] = CBlockIndex();
blocks[0].nHeight = 0;
blocks[0].nTime = 1541009400;
blocks[0].nBits = initialBits;
blocks[0].nChainWork = GetBlockProof(blocks[0]);
// Block counter.
size_t i;
// Create the first window for lwma, with blocks every 10 minutes.
// consensus.difficultyAveragingWindowSize = 200;
// N=200 for T=15: Lwma3CalculateNextWorkRequired
for (i = 1; i < 202; i++) {
blocks[i] = GetBlockIndex(&blocks[i - 1], 600, initialBits); // 0x1f07ffff
}
uint32_t nBits =
Lwma3CalculateNextWorkRequired(&blocks[201], chainParams->GetConsensus());
// For the first window, with 10 minutes between blocks, the difficulty should be low.
BOOST_CHECK_EQUAL( nBits, 0x1f02ffff ); // 520421370
// Add one block far in the future.
blocks[i] = GetBlockIndex(&blocks[i - 1], 6000, nBits);
// The difficulty is now a somewhat lower.
nBits = Lwma3CalculateNextWorkRequired(&blocks[i++], chainParams->GetConsensus());
BOOST_CHECK_EQUAL( nBits, 0x1f031333 ); // 520295219
// Add another block with a normal timestamp.
blocks[i] = GetBlockIndex(&blocks[i - 1], 2 * 600 - 6000, nBits);
nBits = Lwma3CalculateNextWorkRequired(&blocks[i++], chainParams->GetConsensus());
// The difficulty is now just a little bit lower, again.
BOOST_CHECK_EQUAL( nBits, 0x1f031f09 ); // 520298249
// And another block with a regular timestamp.
blocks[i] = GetBlockIndex(&blocks[i - 1], 600, nBits);
// The difficulty has lowered yet again, by a fraction.
nBits = Lwma3CalculateNextWorkRequired(&blocks[i++], chainParams->GetConsensus());
BOOST_CHECK_EQUAL( nBits, 0x1f032ade ); // 520301278
// Simulate a hash attack, add a window with very low increase.
for ( int j = 0; j < 10; j++ ) {
// first, add one block with 0.125 second interval
blocks[i] = GetBlockIndex(&blocks[i - 1], 0.125, nBits);
nBits = Lwma3CalculateNextWorkRequired(&blocks[i++], chainParams->GetConsensus());
// then add 20 more with zero second interval
for ( int k = 0; k < 20; k++ ) {
blocks[i] = GetBlockIndex(&blocks[i - 1], 0, nBits);
nBits = Lwma3CalculateNextWorkRequired(&blocks[i++], chainParams->GetConsensus());
}
// and do that ten times. That gives us 200 block window with very high frequency
// of blocks.
}
// The difficulty is now significantly higher.
BOOST_CHECK_EQUAL( nBits, 0x1e2eaf51 ); // 506376017
// Add one more block with a significant delay.
blocks[i] = GetBlockIndex(&blocks[i - 1], 4 * 3600, nBits);
// The difficulty has lowered significantly.
nBits = Lwma3CalculateNextWorkRequired(&blocks[i++], chainParams->GetConsensus());
BOOST_CHECK_EQUAL( nBits, 0x1e577959 ); // 509049177
// One more block with little less delay.
blocks[i] = GetBlockIndex(&blocks[i - 1], 2 * 3600, nBits);
// The difficulty has lowered again.
nBits = Lwma3CalculateNextWorkRequired(&blocks[i++], chainParams->GetConsensus());
BOOST_CHECK_EQUAL( nBits, 0x1e7f90f4 ); // 511676660
}
*/
BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test)
{
const auto chainParams = CreateChainParams(CBaseChainParams::MAIN);
std::vector<CBlockIndex> blocks(10000);
for (int i = 0; i < 10000; i++) {
blocks[i].pprev = i ? &blocks[i - 1] : nullptr;
blocks[i].nHeight = i;
blocks[i].nTime = 1269211443 + i * chainParams->GetConsensus().nPowTargetSpacing;
blocks[i].nBits = 0x207fffff; /* target 0x7fffff000... */
blocks[i].nChainWork = i ? blocks[i - 1].nChainWork + GetBlockProof(blocks[i - 1]) : arith_uint256(0);
}
for (int j = 0; j < 1000; j++) {
CBlockIndex *p1 = &blocks[InsecureRandRange(10000)];
CBlockIndex *p2 = &blocks[InsecureRandRange(10000)];
CBlockIndex *p3 = &blocks[InsecureRandRange(10000)];
int64_t tdiff = GetBlockProofEquivalentTime(*p1, *p2, *p3, chainParams->GetConsensus());
BOOST_CHECK_EQUAL(tdiff, p1->GetBlockTime() - p2->GetBlockTime());
}
}
BOOST_AUTO_TEST_SUITE_END()
$ ./src/test/test_sugarchain test_bitcoin --log_level=test_suite --run_test=pow_tests
Running 2 test cases...
Entering test suite "Sugarchain Test Suite"
Entering test suite "pow_tests"
Entering test case "negativeTimeAttack_test"
*** Show mainnetParams
T = 15
N = 200
powLimit =
0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
0007ffff00000000000000000000000000000000000000000000000000000000
*** Check Genesis
Block Target(uint) Target(hex) Diff(double) Diff(%) Interval
0 520617983 1f07ffff 1.907323166912278e-06 1.000 5354230
*** First Window
Block Target(uint) Target(hex) Diff(double) Diff(%) Interval
1 520617983 1f07ffff 1.907323166912278e-06 1.000 15
2 520617983 1f07ffff 1.907323166912278e-06 1.000 15
3 520617983 1f07ffff 1.907323166912278e-06 1.000 15
4 520617983 1f07ffff 1.907323166912278e-06 1.000 15
5 520617983 1f07ffff 1.907323166912278e-06 1.000 15
6 520617983 1f07ffff 1.907323166912278e-06 1.000 15
7 520617983 1f07ffff 1.907323166912278e-06 1.000 15
8 520617983 1f07ffff 1.907323166912278e-06 1.000 15
9 520617983 1f07ffff 1.907323166912278e-06 1.000 15
10 520617983 1f07ffff 1.907323166912278e-06 1.000 15
11 520617983 1f07ffff 1.907323166912278e-06 1.000 15
12 520617983 1f07ffff 1.907323166912278e-06 1.000 15
13 520617983 1f07ffff 1.907323166912278e-06 1.000 15
14 520617983 1f07ffff 1.907323166912278e-06 1.000 15
15 520617983 1f07ffff 1.907323166912278e-06 1.000 15
16 520617983 1f07ffff 1.907323166912278e-06 1.000 15
17 520617983 1f07ffff 1.907323166912278e-06 1.000 15
18 520617983 1f07ffff 1.907323166912278e-06 1.000 15
19 520617983 1f07ffff 1.907323166912278e-06 1.000 15
20 520617983 1f07ffff 1.907323166912278e-06 1.000 15
21 520617983 1f07ffff 1.907323166912278e-06 1.000 15
22 520617983 1f07ffff 1.907323166912278e-06 1.000 15
23 520617983 1f07ffff 1.907323166912278e-06 1.000 15
24 520617983 1f07ffff 1.907323166912278e-06 1.000 15
25 520617983 1f07ffff 1.907323166912278e-06 1.000 15
26 520617983 1f07ffff 1.907323166912278e-06 1.000 15
27 520617983 1f07ffff 1.907323166912278e-06 1.000 15
28 520617983 1f07ffff 1.907323166912278e-06 1.000 15
29 520617983 1f07ffff 1.907323166912278e-06 1.000 15
30 520617983 1f07ffff 1.907323166912278e-06 1.000 15
31 520617983 1f07ffff 1.907323166912278e-06 1.000 15
32 520617983 1f07ffff 1.907323166912278e-06 1.000 15
33 520617983 1f07ffff 1.907323166912278e-06 1.000 15
34 520617983 1f07ffff 1.907323166912278e-06 1.000 15
35 520617983 1f07ffff 1.907323166912278e-06 1.000 15
36 520617983 1f07ffff 1.907323166912278e-06 1.000 15
37 520617983 1f07ffff 1.907323166912278e-06 1.000 15
38 520617983 1f07ffff 1.907323166912278e-06 1.000 15
39 520617983 1f07ffff 1.907323166912278e-06 1.000 15
40 520617983 1f07ffff 1.907323166912278e-06 1.000 15
41 520617983 1f07ffff 1.907323166912278e-06 1.000 15
42 520617983 1f07ffff 1.907323166912278e-06 1.000 15
43 520617983 1f07ffff 1.907323166912278e-06 1.000 15
44 520617983 1f07ffff 1.907323166912278e-06 1.000 15
45 520617983 1f07ffff 1.907323166912278e-06 1.000 15
46 520617983 1f07ffff 1.907323166912278e-06 1.000 15
47 520617983 1f07ffff 1.907323166912278e-06 1.000 15
48 520617983 1f07ffff 1.907323166912278e-06 1.000 15
49 520617983 1f07ffff 1.907323166912278e-06 1.000 15
50 520617983 1f07ffff 1.907323166912278e-06 1.000 15
51 520617983 1f07ffff 1.907323166912278e-06 1.000 15
52 520617983 1f07ffff 1.907323166912278e-06 1.000 15
53 520617983 1f07ffff 1.907323166912278e-06 1.000 15
54 520617983 1f07ffff 1.907323166912278e-06 1.000 15
55 520617983 1f07ffff 1.907323166912278e-06 1.000 15
56 520617983 1f07ffff 1.907323166912278e-06 1.000 15
57 520617983 1f07ffff 1.907323166912278e-06 1.000 15
58 520617983 1f07ffff 1.907323166912278e-06 1.000 15
59 520617983 1f07ffff 1.907323166912278e-06 1.000 15
60 520617983 1f07ffff 1.907323166912278e-06 1.000 15
61 520617983 1f07ffff 1.907323166912278e-06 1.000 15
62 520617983 1f07ffff 1.907323166912278e-06 1.000 15
63 520617983 1f07ffff 1.907323166912278e-06 1.000 15
64 520617983 1f07ffff 1.907323166912278e-06 1.000 15
65 520617983 1f07ffff 1.907323166912278e-06 1.000 15
66 520617983 1f07ffff 1.907323166912278e-06 1.000 15
67 520617983 1f07ffff 1.907323166912278e-06 1.000 15
68 520617983 1f07ffff 1.907323166912278e-06 1.000 15
69 520617983 1f07ffff 1.907323166912278e-06 1.000 15
70 520617983 1f07ffff 1.907323166912278e-06 1.000 15
71 520617983 1f07ffff 1.907323166912278e-06 1.000 15
72 520617983 1f07ffff 1.907323166912278e-06 1.000 15
73 520617983 1f07ffff 1.907323166912278e-06 1.000 15
74 520617983 1f07ffff 1.907323166912278e-06 1.000 15
75 520617983 1f07ffff 1.907323166912278e-06 1.000 15
76 520617983 1f07ffff 1.907323166912278e-06 1.000 15
77 520617983 1f07ffff 1.907323166912278e-06 1.000 15
78 520617983 1f07ffff 1.907323166912278e-06 1.000 15
79 520617983 1f07ffff 1.907323166912278e-06 1.000 15
80 520617983 1f07ffff 1.907323166912278e-06 1.000 15
81 520617983 1f07ffff 1.907323166912278e-06 1.000 15
82 520617983 1f07ffff 1.907323166912278e-06 1.000 15
83 520617983 1f07ffff 1.907323166912278e-06 1.000 15
84 520617983 1f07ffff 1.907323166912278e-06 1.000 15
85 520617983 1f07ffff 1.907323166912278e-06 1.000 15
86 520617983 1f07ffff 1.907323166912278e-06 1.000 15
87 520617983 1f07ffff 1.907323166912278e-06 1.000 15
88 520617983 1f07ffff 1.907323166912278e-06 1.000 15
89 520617983 1f07ffff 1.907323166912278e-06 1.000 15
90 520617983 1f07ffff 1.907323166912278e-06 1.000 15
91 520617983 1f07ffff 1.907323166912278e-06 1.000 15
92 520617983 1f07ffff 1.907323166912278e-06 1.000 15
93 520617983 1f07ffff 1.907323166912278e-06 1.000 15
94 520617983 1f07ffff 1.907323166912278e-06 1.000 15
95 520617983 1f07ffff 1.907323166912278e-06 1.000 15
96 520617983 1f07ffff 1.907323166912278e-06 1.000 15
97 520617983 1f07ffff 1.907323166912278e-06 1.000 15
98 520617983 1f07ffff 1.907323166912278e-06 1.000 15
99 520617983 1f07ffff 1.907323166912278e-06 1.000 15
100 520617983 1f07ffff 1.907323166912278e-06 1.000 15
101 520617983 1f07ffff 1.907323166912278e-06 1.000 15
102 520617983 1f07ffff 1.907323166912278e-06 1.000 15
103 520617983 1f07ffff 1.907323166912278e-06 1.000 15
104 520617983 1f07ffff 1.907323166912278e-06 1.000 15
105 520617983 1f07ffff 1.907323166912278e-06 1.000 15
106 520617983 1f07ffff 1.907323166912278e-06 1.000 15
107 520617983 1f07ffff 1.907323166912278e-06 1.000 15
108 520617983 1f07ffff 1.907323166912278e-06 1.000 15
109 520617983 1f07ffff 1.907323166912278e-06 1.000 15
110 520617983 1f07ffff 1.907323166912278e-06 1.000 15
111 520617983 1f07ffff 1.907323166912278e-06 1.000 15
112 520617983 1f07ffff 1.907323166912278e-06 1.000 15
113 520617983 1f07ffff 1.907323166912278e-06 1.000 15
114 520617983 1f07ffff 1.907323166912278e-06 1.000 15
115 520617983 1f07ffff 1.907323166912278e-06 1.000 15
116 520617983 1f07ffff 1.907323166912278e-06 1.000 15
117 520617983 1f07ffff 1.907323166912278e-06 1.000 15
118 520617983 1f07ffff 1.907323166912278e-06 1.000 15
119 520617983 1f07ffff 1.907323166912278e-06 1.000 15
120 520617983 1f07ffff 1.907323166912278e-06 1.000 15
121 520617983 1f07ffff 1.907323166912278e-06 1.000 15
122 520617983 1f07ffff 1.907323166912278e-06 1.000 15
123 520617983 1f07ffff 1.907323166912278e-06 1.000 15
124 520617983 1f07ffff 1.907323166912278e-06 1.000 15
125 520617983 1f07ffff 1.907323166912278e-06 1.000 15
126 520617983 1f07ffff 1.907323166912278e-06 1.000 15
127 520617983 1f07ffff 1.907323166912278e-06 1.000 15
128 520617983 1f07ffff 1.907323166912278e-06 1.000 15
129 520617983 1f07ffff 1.907323166912278e-06 1.000 15
130 520617983 1f07ffff 1.907323166912278e-06 1.000 15
131 520617983 1f07ffff 1.907323166912278e-06 1.000 15
132 520617983 1f07ffff 1.907323166912278e-06 1.000 15
133 520617983 1f07ffff 1.907323166912278e-06 1.000 15
134 520617983 1f07ffff 1.907323166912278e-06 1.000 15
135 520617983 1f07ffff 1.907323166912278e-06 1.000 15
136 520617983 1f07ffff 1.907323166912278e-06 1.000 15
137 520617983 1f07ffff 1.907323166912278e-06 1.000 15
138 520617983 1f07ffff 1.907323166912278e-06 1.000 15
139 520617983 1f07ffff 1.907323166912278e-06 1.000 15
140 520617983 1f07ffff 1.907323166912278e-06 1.000 15
141 520617983 1f07ffff 1.907323166912278e-06 1.000 15
142 520617983 1f07ffff 1.907323166912278e-06 1.000 15
143 520617983 1f07ffff 1.907323166912278e-06 1.000 15
144 520617983 1f07ffff 1.907323166912278e-06 1.000 15
145 520617983 1f07ffff 1.907323166912278e-06 1.000 15
146 520617983 1f07ffff 1.907323166912278e-06 1.000 15
147 520617983 1f07ffff 1.907323166912278e-06 1.000 15
148 520617983 1f07ffff 1.907323166912278e-06 1.000 15
149 520617983 1f07ffff 1.907323166912278e-06 1.000 15
150 520617983 1f07ffff 1.907323166912278e-06 1.000 15
151 520617983 1f07ffff 1.907323166912278e-06 1.000 15
152 520617983 1f07ffff 1.907323166912278e-06 1.000 15
153 520617983 1f07ffff 1.907323166912278e-06 1.000 15
154 520617983 1f07ffff 1.907323166912278e-06 1.000 15
155 520617983 1f07ffff 1.907323166912278e-06 1.000 15
156 520617983 1f07ffff 1.907323166912278e-06 1.000 15
157 520617983 1f07ffff 1.907323166912278e-06 1.000 15
158 520617983 1f07ffff 1.907323166912278e-06 1.000 15
159 520617983 1f07ffff 1.907323166912278e-06 1.000 15
160 520617983 1f07ffff 1.907323166912278e-06 1.000 15
161 520617983 1f07ffff 1.907323166912278e-06 1.000 15
162 520617983 1f07ffff 1.907323166912278e-06 1.000 15
163 520617983 1f07ffff 1.907323166912278e-06 1.000 15
164 520617983 1f07ffff 1.907323166912278e-06 1.000 15
165 520617983 1f07ffff 1.907323166912278e-06 1.000 15
166 520617983 1f07ffff 1.907323166912278e-06 1.000 15
167 520617983 1f07ffff 1.907323166912278e-06 1.000 15
168 520617983 1f07ffff 1.907323166912278e-06 1.000 15
169 520617983 1f07ffff 1.907323166912278e-06 1.000 15
170 520617983 1f07ffff 1.907323166912278e-06 1.000 15
171 520617983 1f07ffff 1.907323166912278e-06 1.000 15
172 520617983 1f07ffff 1.907323166912278e-06 1.000 15
173 520617983 1f07ffff 1.907323166912278e-06 1.000 15
174 520617983 1f07ffff 1.907323166912278e-06 1.000 15
175 520617983 1f07ffff 1.907323166912278e-06 1.000 15
176 520617983 1f07ffff 1.907323166912278e-06 1.000 15
177 520617983 1f07ffff 1.907323166912278e-06 1.000 15
178 520617983 1f07ffff 1.907323166912278e-06 1.000 15
179 520617983 1f07ffff 1.907323166912278e-06 1.000 15
180 520617983 1f07ffff 1.907323166912278e-06 1.000 15
181 520617983 1f07ffff 1.907323166912278e-06 1.000 15
182 520617983 1f07ffff 1.907323166912278e-06 1.000 15
183 520617983 1f07ffff 1.907323166912278e-06 1.000 15
184 520617983 1f07ffff 1.907323166912278e-06 1.000 15
185 520617983 1f07ffff 1.907323166912278e-06 1.000 15
186 520617983 1f07ffff 1.907323166912278e-06 1.000 15
187 520617983 1f07ffff 1.907323166912278e-06 1.000 15
188 520617983 1f07ffff 1.907323166912278e-06 1.000 15
189 520617983 1f07ffff 1.907323166912278e-06 1.000 15
190 520617983 1f07ffff 1.907323166912278e-06 1.000 15
191 520617983 1f07ffff 1.907323166912278e-06 1.000 15
192 520617983 1f07ffff 1.907323166912278e-06 1.000 15
193 520617983 1f07ffff 1.907323166912278e-06 1.000 15
194 520617983 1f07ffff 1.907323166912278e-06 1.000 15
195 520617983 1f07ffff 1.907323166912278e-06 1.000 15
196 520617983 1f07ffff 1.907323166912278e-06 1.000 15
197 520617983 1f07ffff 1.907323166912278e-06 1.000 15
198 520617983 1f07ffff 1.907323166912278e-06 1.000 15
199 520617983 1f07ffff 1.907323166912278e-06 1.000 15
200 520617983 1f07ffff 1.907323166912278e-06 1.000 15
*** First Window Filled
*** ATTACK: NegativeRandom
Block Target(uint) Target(hex) Diff(double) Diff(%) Interval
202 520615361 1f07f5c1 1.916909781585764e-06 1.005 -5
203 520611840 1f07e800 1.929935966084597e-06 1.012 -10
204 520607424 1f07d6c0 1.94652567352945e-06 1.021 -12
205 520602634 1f07c40a 1.964845897164168e-06 1.030 -8
206 520598519 1f07b3f7 1.980862086733246e-06 1.039 4
207 520596485 1f07ac05 1.988875534689378e-06 1.043 3
208 520594277 1f07a365 1.997648215195817e-06 1.047 -8
209 520590139 1f07933b 2.014299206980333e-06 1.056 -3
210 520586847 1f07865f 2.027745540840305e-06 1.063 2
211 520584418 1f077ce2 2.037782575900281e-06 1.068 7
212 520582855 1f0776c7 2.044293861936379e-06 1.072 14
213 520582510 1f07756e 2.045736703962934e-06 1.073 -2
214 520579381 1f076935 2.058916254796705e-06 1.079 8
215 520577969 1f0763b1 2.06491945908803e-06 1.083 -9
216 520573599 1f07529f 2.083722629804226e-06 1.092 15
217 520573376 1f0751c0 2.084691338415063e-06 1.093 -10
218 520568822 1f073ff6 2.104672741990414e-06 1.103 14
219 520568404 1f073e54 2.106525993265202e-06 1.104 14
220 520568004 1f073cc4 2.108302497977975e-06 1.105 -11
221 520563259 1f072a3b 2.12960719053873e-06 1.117 -8
222 520559000 1f071998 2.149099816917408e-06 1.127 -4
223 520555422 1f070b9e 2.165753588082407e-06 1.135 -14
224 520550101 1f06f6d5 2.191003037238719e-06 1.149 -2
225 520546836 1f06ea14 2.206789824802351e-06 1.157 13
226 520546167 1f06e777 2.210052669035004e-06 1.159 13
227 520545507 1f06e4e3 2.213281087027402e-06 1.160 -13
228 520540348 1f06d0bc 2.238845323005243e-06 1.174 -13
229 520535155 1f06bc73 2.265181457872504e-06 1.188 4
230 520532884 1f06b394 2.276894498963855e-06 1.194 -1
231 520529755 1f06a75b 2.29323266166032e-06 1.202 15
232 520529372 1f06a5dc 2.295248627904538e-06 1.203 -3
233 520525899 1f06984b 2.313692272406571e-06 1.213 7
234 520524125 1f06915d 2.323228084564324e-06 1.218 -10
235 520519432 1f067f08 2.348837639313888e-06 1.231 -2
236 520516089 1f0671f9 2.367427351331432e-06 1.241 12
237 520515145 1f066e49 2.37273013154839e-06 1.244 7
238 520513351 1f066747 2.382873410803964e-06 1.249 -15
239 520507783 1f065187 2.414914598166418e-06 1.266 -11
240 520502873 1f063e59 2.443892841510978e-06 1.281 -14
241 520497444 1f062924 2.476754661845848e-06 1.299 2
242 520494733 1f061e8d 2.493497460860064e-06 1.307 9
243 520493219 1f0618a3 2.502946616867959e-06 1.312 15
244 520492728 1f0616b8 2.506026437004896e-06 1.314 13
245 520491899 1f06137b 2.511243614967585e-06 1.317 1
246 520489030 1f060846 2.529468098395123e-06 1.326 -12
247 520483943 1f05f467 2.562440559981082e-06 1.343 11
248 520482735 1f05efaf 2.570397161238173e-06 1.348 5
249 520480524 1f05e70c 2.585088828137926e-06 1.355 -14
250 520475098 1f05d1da 2.621865488935395e-06 1.375 7
251 520473194 1f05ca6a 2.635019792491496e-06 1.382 9
252 520471636 1f05c454 2.645882259646869e-06 1.387 -8
253 520467219 1f05b313 2.677170458608807e-06 1.404 -13
254 520461948 1f059e7c 2.715490319702099e-06 1.424 9
255 520460355 1f059843 2.727288137509068e-06 1.430 5
256 520458104 1f058f78 2.744134983894255e-06 1.439 -15
257 520452507 1f05799b 2.786940035871079e-06 1.461 6
258 520450397 1f05715d 2.803425673634045e-06 1.470 5
259 520448130 1f056882 2.821356701701692e-06 1.479 -15
260 520442537 1f0552a9 2.866591774507404e-06 1.503 -6
261 520438423 1f054297 2.900801913429866e-06 1.521 -14
262 520432988 1f052d5c 2.947268845746253e-06 1.545 15
263 520432341 1f052ad5 2.952899765863773e-06 1.548 6
264 520430223 1f05228f 2.97148443129656e-06 1.558 9
265 520428593 1f051c31 2.98594714557293e-06 1.566 -11
266 520423676 1f0508fc 3.030440454606151e-06 1.589 -13
267 520418420 1f04f474 3.079491325590155e-06 1.615 3
268 520415784 1f04ea28 3.104694186715859e-06 1.628 9
269 520414135 1f04e3b7 3.12067114555637e-06 1.636 -13
270 520408903 1f04cf47 3.172469968023989e-06 1.663 5
271 520406590 1f04c63e 3.1959217537279e-06 1.676 10
272 520405096 1f04c068 3.211254788731334e-06 1.684 3
273 520402471 1f04b627 3.238554744428589e-06 1.698 -3
274 520398873 1f04a819 3.27673691402346e-06 1.718 7
275 520396886 1f04a056 3.298211488541632e-06 1.729 0
276 520393778 1f049432 3.332371622459653e-06 1.747 13
277 520392754 1f049032 3.343781946013608e-06 1.753 11
278 520391414 1f048af6 3.358831986010041e-06 1.761 -7
279 520387198 1f047a7e 3.407079819595565e-06 1.786 0
280 520384092 1f046e5c 3.443521058178961e-06 1.805 10
281 520382581 1f046875 3.461532240202633e-06 1.815 -15
282 520377112 1f045318 3.5283284684384e-06 1.850 -8
283 520372745 1f044209 3.583545331504279e-06 1.879 15
284 520372014 1f043f2e 3.592957484643241e-06 1.884 -13
285 520366888 1f042b28 3.660373441429242e-06 1.919 -15
286 520361445 1f0415e5 3.734784224071565e-06 1.958 4
287 520358982 1f040c46 3.769459154312468e-06 1.976 -15
288 520353567 1f03f71f 3.848004360667167e-06 2.017 4
*** currentDifficultyRatio >= 2.0
*** ATTACK: NegativeRandom is finished
*** DEFENSE: Random
Block Target(uint) Target(hex) Diff(double) Diff(%) Interval
289 520351111 1f03ed87 3.884718222368306e-06 2.037 132
290 520368518 1f043186 3.638663357412934e-06 1.908 63
291 520375262 1f044bde 3.551510982188679e-06 1.862 22
292 520375629 1f044d4d 3.546887881911438e-06 1.860 79
293 520384747 1f0470eb 3.435771535610383e-06 1.801 65
294 520391721 1f048c29 3.355372003056581e-06 1.759 35
295 520394079 1f04955f 3.329032405998134e-06 1.745 115
296 520408639 1f04ce3f 3.175129281206242e-06 1.665 12
297 520407516 1f04c9dc 3.186491432065954e-06 1.671 45
298 520411358 1f04d8de 3.14795204088288e-06 1.650 1
299 520408531 1f04cdd3 3.176218467485945e-06 1.665 139
300 520426580 1f051454 3.004003620513264e-06 1.575 75
301 520435018 1f05354a 2.929740073042281e-06 1.536 140
302 520453224 1f057c68 2.78138209321927e-06 1.458 -12
303 520448577 1f056a41 2.817802985256853e-06 1.477 89
304 520459023 1f05930f 2.73723196262783e-06 1.435 139
305 520477036 1f05d96c 2.608610479498454e-06 1.368 113
306 520491204 1f0610c4 2.515634254432458e-06 1.319 102
307 520503733 1f0641b5 2.438767089825888e-06 1.279 80
308 520512991 1f0665df 2.384919307911942e-06 1.250 38
309 520515981 1f06718d 2.368032824303344e-06 1.242 73
310 520524172 1f06918c 2.322974431120289e-06 1.218 136
311 520541799 1f06d667 2.231595729577658e-06 1.170 121
312 520557299 1f0712f3 2.156985052320493e-06 1.131 125
313 520573444 1f075204 2.084395852011759e-06 1.093 57
314 520579544 1f0769d8 2.058225496885729e-06 1.079 30
315 520581601 1f0771e1 2.049548049745212e-06 1.075 139
316 520599858 1f07b932 1.975621917905607e-06 1.036 137
317 520617983 1f07ffff 1.907323166912278e-06 1.000 126
*** currentDifficulty == initDifficulty
*** DEFENSE: Random is finished
Leaving test case "negativeTimeAttack_test"; testing time: 510162mks
Entering test case "GetBlockProofEquivalentTime_test"
Leaving test case "GetBlockProofEquivalentTime_test"; testing time: 11459mks
Leaving test suite "pow_tests"
Leaving test suite "Sugarchain Test Suite"
*** No errors detected
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment