Skip to content

Commit

Permalink
Merge branch 'auxpow'
Browse files Browse the repository at this point in the history
  • Loading branch information
domob1812 committed Aug 16, 2021
2 parents edbbdf1 + e61252d commit 8dcb420
Show file tree
Hide file tree
Showing 60 changed files with 1,283 additions and 423 deletions.
2 changes: 2 additions & 0 deletions contrib/builder-keys/keys.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ E944AE667CF960B1004BC32FCA662BE18B877A60 Andreas Schildbach (aschildbach)
590B7292695AFFA5B672CBB2E13FC145CD3F4304 Antoine Poinsot (darosior)
0AD83877C1F0CD1EE9BD660AD7CC770B81FD22A8 Ben Carman (benthecarman)
912FD3228387123DC97E0E57D5566241A0295FA9 BtcDrak (btcdrak)
04017A2A6D9A0CCDC81D8EC296AB007F1A7ED999 Carl Dong (dongcarl)
C519EBCF3B926298946783EFF6430754120EC2F4 Christian Decker (cdecker)
18AE2F798E0D239755DA4FD24B79F986CBDF8736 Chun Kuan Le (ken2812221)
101598DC823C1B5F9A6624ABA5E0907A0380E6C3 CoinForensics (CoinForensics)
Expand All @@ -21,6 +22,7 @@ D35176BE9264832E4ACA8986BF0792FBE95DC863 fivepiece (fivepiece)
01CDF4627A3B88AAE4A571C87588242FBE38D3A8 Gavin Andresen (gavinandresen)
D1DBF2C4B96F2DEBF4C16654410108112E7EA81F Hennadii Stepanov (hebasto)
A2FD494D0021AA9B4FA58F759102B7AE654A4A5A Ilyas Ridhuan (IlyasRidhuan)
2688F5A9A4BE0F295E921E8A25F27A38A47AD566 James O'Beirne (jamesob)
D3F22A3A4C366C2DCB66D3722DA9C5A7FA81EA35 Jarol Rodriguez (jarolrod)
7480909378D544EA6B6DCEB7535B12980BB8A4D3 Jeffri H Frontz (jhfrontz)
D3CC177286005BB8FF673294C5242A1AB3936517 jl2012 (jl2012)
Expand Down
16 changes: 0 additions & 16 deletions contrib/guix/guix-attest
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,6 @@ Hint: You may wish to remove the existing attestations and their signatures by
EOF
}

# Given a document with unix line endings (just <LF>) in stdin, make all lines
# end in <CR><LF> and make sure there's no trailing <LF> at the end of the file.
#
# This is necessary as cleartext signatures are calculated on text after their
# line endings are canonicalized.
#
# For more information:
# 1. https://security.stackexchange.com/a/104261
# 2. https://datatracker.ietf.org/doc/html/rfc4880#section-7.1
#
rfc4880_normalize_document() {
sed 's/$/\r/' | head -c -2
}

echo "Attesting to build outputs for version: '${VERSION}'"
echo ""

Expand All @@ -188,7 +174,6 @@ mkdir -p "$outsigdir"
cat "${noncodesigned_fragments[@]}" \
| sort -u \
| sort -k2 \
| rfc4880_normalize_document \
> "$temp_noncodesigned"
if [ -e noncodesigned.SHA256SUMS ]; then
# The SHA256SUMS already exists, make sure it's exactly what we
Expand Down Expand Up @@ -216,7 +201,6 @@ mkdir -p "$outsigdir"
cat "${sha256sum_fragments[@]}" \
| sort -u \
| sort -k2 \
| rfc4880_normalize_document \
> "$temp_all"
if [ -e all.SHA256SUMS ]; then
# The SHA256SUMS already exists, make sure it's exactly what we
Expand Down
6 changes: 6 additions & 0 deletions contrib/guix/guix-verify
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ verify() {
echo ""
echo "Hint: Either the signature is invalid or the public key is missing"
echo ""
failure=1
elif ! diff --report-identical "$compare_manifest" "$current_manifest" 1>&2; then
echo "ERR: The SHA256SUMS attestation in these two directories differ:"
echo " '${compare_manifest}'"
echo " '${current_manifest}'"
echo ""
failure=1
else
echo "Verified: '${current_manifest}'"
echo ""
Expand Down Expand Up @@ -166,3 +168,7 @@ if (( ${#all_noncodesigned[@]} + ${#all_all[@]} == 0 )); then
echo ""
exit 1
fi

if [ -n "$failure" ]; then
exit 1
fi
3 changes: 3 additions & 0 deletions doc/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ RPC
Tests
-----

- For the `regtest` network the BIP 66 (DERSIG) activation height was changed
from 1251 to 102. (#22632)

Credits
=======

Expand Down
23 changes: 6 additions & 17 deletions doc/release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,24 +271,10 @@ Non-codesigners: wait for Windows/macOS detached signatures:

( **Not in Namecoin yet.** ) Commit your signature for the signed macOS/Windows binaries:

Combine `all.SHA256SUMS` and `all.SHA256SUMS.asc` into a clear-signed
`SHA256SUMS.asc` message:

```sh
echo -e "-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA256\n\n$(cat all.SHA256SUMS)\n$(cat filename.txt.asc)" > SHA256SUMS.asc
```

Here's an equivalent, more readable command if you're confident that you won't
mess up whitespaces when copy-pasting:
Combine the `all.SHA256SUMS.asc` file from all signers into `SHA256SUMS.asc`:

```bash
cat << EOF > SHA256SUMS.asc
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
$(cat all.SHA256SUMS)
$(cat all.SHA256SUMS.asc)
EOF
cat "$VERSION"/*/all.SHA256SUMS.asc > SHA256SUMS.asc
```
namecoin-${VERSION}-aarch64-linux-gnu.tar.gz
namecoin-${VERSION}-arm-linux-gnueabihf.tar.gz
Expand All @@ -306,6 +292,7 @@ in debugging can run gitian to generate the files for themselves. To avoid
end-user confusion about which file to pick, as well as save storage
space *do not upload these to the bitcoincore.org server, nor put them in the torrent*.
- Upload to the bitcoincore.org server (`/var/www/bin/bitcoin-core-${VERSION}`):
1. The contents of `./bitcoin/guix-build-${VERSION}/output`, except for
`*-debug*` files.
Expand All @@ -315,7 +302,9 @@ space *do not upload these to the bitcoincore.org server, nor put them in the to
- Upload zips and installers, as well as `SHA256SUMS.asc` from last step, to the bitcoincore.org server
into `/var/www/bin/bitcoin-core-${VERSION}`
2. The combined clear-signed message you just created `SHA256SUMS.asc`
2. The `SHA256SUMS` file
3. The `SHA256SUMS.asc` combined signature file you just created
- Create a torrent of the `/var/www/bin/bitcoin-core-${VERSION}` directory such
that at the top level there is only one file: the `bitcoin-core-${VERSION}`
Expand Down
26 changes: 19 additions & 7 deletions src/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,16 @@ CAddrInfo CAddrMan::Select_(bool newOnly) const
}
}

#ifdef DEBUG_ADDRMAN
int CAddrMan::Check_()
int CAddrMan::Check_() const
{
AssertLockHeld(cs);

// Run consistency checks 1 in m_consistency_check_ratio times if enabled
if (m_consistency_check_ratio == 0) return 0;
if (insecure_rand.randrange(m_consistency_check_ratio) >= 1) return 0;

LogPrint(BCLog::ADDRMAN, "Addrman checks started: new %i, tried %i, total %u\n", nNew, nTried, vRandom.size());

std::unordered_set<int> setTried;
std::unordered_map<int, int> mapNew;

Expand All @@ -458,8 +463,10 @@ int CAddrMan::Check_()
return -4;
mapNew[n] = info.nRefCount;
}
if (mapAddr[info] != n)
const auto it{mapAddr.find(info)};
if (it == mapAddr.end() || it->second != n) {
return -5;
}
if (info.nRandomPos < 0 || (size_t)info.nRandomPos >= vRandom.size() || vRandom[info.nRandomPos] != n)
return -14;
if (info.nLastTry < 0)
Expand All @@ -478,10 +485,13 @@ int CAddrMan::Check_()
if (vvTried[n][i] != -1) {
if (!setTried.count(vvTried[n][i]))
return -11;
if (mapInfo[vvTried[n][i]].GetTriedBucket(nKey, m_asmap) != n)
const auto it{mapInfo.find(vvTried[n][i])};
if (it == mapInfo.end() || it->second.GetTriedBucket(nKey, m_asmap) != n) {
return -17;
if (mapInfo[vvTried[n][i]].GetBucketPosition(nKey, false, n) != i)
}
if (it->second.GetBucketPosition(nKey, false, n) != i) {
return -18;
}
setTried.erase(vvTried[n][i]);
}
}
Expand All @@ -492,8 +502,10 @@ int CAddrMan::Check_()
if (vvNew[n][i] != -1) {
if (!mapNew.count(vvNew[n][i]))
return -12;
if (mapInfo[vvNew[n][i]].GetBucketPosition(nKey, true, n) != i)
const auto it{mapInfo.find(vvNew[n][i])};
if (it == mapInfo.end() || it->second.GetBucketPosition(nKey, true, n) != i) {
return -19;
}
if (--mapNew[vvNew[n][i]] == 0)
mapNew.erase(vvNew[n][i]);
}
Expand All @@ -507,9 +519,9 @@ int CAddrMan::Check_()
if (nKey.IsNull())
return -16;

LogPrint(BCLog::ADDRMAN, "Addrman checks completed successfully\n");
return 0;
}
#endif

void CAddrMan::GetAddr_(std::vector<CAddress>& vAddr, size_t max_addresses, size_t max_pct, std::optional<Network> network) const
{
Expand Down
30 changes: 18 additions & 12 deletions src/addrman.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include <unordered_map>
#include <vector>

/** Default for -checkaddrman */
static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS{0};

/**
* Extended statistics about a CAddress
*/
Expand Down Expand Up @@ -124,8 +127,8 @@ class CAddrInfo : public CAddress
* attempt was unsuccessful.
* * Bucket selection is based on cryptographic hashing, using a randomly-generated 256-bit key, which should not
* be observable by adversaries.
* * Several indexes are kept for high performance. Defining DEBUG_ADDRMAN will introduce frequent (and expensive)
* consistency checks for the entire data structure.
* * Several indexes are kept for high performance. Setting m_consistency_check_ratio with the -checkaddrman
* configuration option will introduce (expensive) consistency checks for the entire data structure.
*/

//! total number of buckets for tried addresses
Expand Down Expand Up @@ -493,9 +496,12 @@ class CAddrMan
mapAddr.clear();
}

CAddrMan()
explicit CAddrMan(bool deterministic, int32_t consistency_check_ratio)
: insecure_rand{deterministic},
m_consistency_check_ratio{consistency_check_ratio}
{
Clear();
if (deterministic) nKey = uint256{1};
}

~CAddrMan()
Expand Down Expand Up @@ -637,13 +643,13 @@ class CAddrMan
//! secret key to randomize bucket select with
uint256 nKey;

//! Source of random numbers for randomization in inner loops
mutable FastRandomContext insecure_rand GUARDED_BY(cs);

//! A mutex to protect the inner data structures.
mutable Mutex cs;

private:
//! Source of random numbers for randomization in inner loops
mutable FastRandomContext insecure_rand GUARDED_BY(cs);

//! Serialization versions.
enum Format : uint8_t {
V0_HISTORICAL = 0, //!< historic format, before commit e6b343d88
Expand Down Expand Up @@ -698,6 +704,9 @@ class CAddrMan
//! Holds addrs inserted into tried table that collide with existing entries. Test-before-evict discipline used to resolve these collisions.
std::set<int> m_tried_collisions;

/** Perform consistency checks every m_consistency_check_ratio operations (if non-zero). */
const int32_t m_consistency_check_ratio;

//! Find an entry.
CAddrInfo* Find(const CNetAddr& addr, int *pnId = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs);

Expand Down Expand Up @@ -735,22 +744,19 @@ class CAddrMan
CAddrInfo SelectTriedCollision_() EXCLUSIVE_LOCKS_REQUIRED(cs);

//! Consistency check
void Check() const
EXCLUSIVE_LOCKS_REQUIRED(cs)
void Check() const EXCLUSIVE_LOCKS_REQUIRED(cs)
{
#ifdef DEBUG_ADDRMAN
AssertLockHeld(cs);

const int err = Check_();
if (err) {
LogPrintf("ADDRMAN CONSISTENCY CHECK FAILED!!! err=%i\n", err);
assert(false);
}
#endif
}

#ifdef DEBUG_ADDRMAN
//! Perform consistency check. Returns an error code or zero.
int Check_() const EXCLUSIVE_LOCKS_REQUIRED(cs);
#endif

/**
* Return all or many randomly selected addresses, optionally by network.
Expand Down
16 changes: 9 additions & 7 deletions src/bench/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static void AddrManAdd(benchmark::Bench& bench)
{
CreateAddresses();

CAddrMan addrman;
CAddrMan addrman(/* deterministic */ false, /* consistency_check_ratio */ 0);

bench.run([&] {
AddAddressesToAddrMan(addrman);
Expand All @@ -82,7 +82,7 @@ static void AddrManAdd(benchmark::Bench& bench)

static void AddrManSelect(benchmark::Bench& bench)
{
CAddrMan addrman;
CAddrMan addrman(/* deterministic */ false, /* consistency_check_ratio */ 0);

FillAddrMan(addrman);

Expand All @@ -94,7 +94,7 @@ static void AddrManSelect(benchmark::Bench& bench)

static void AddrManGetAddr(benchmark::Bench& bench)
{
CAddrMan addrman;
CAddrMan addrman(/* deterministic */ false, /* consistency_check_ratio */ 0);

FillAddrMan(addrman);

Expand All @@ -112,10 +112,12 @@ static void AddrManGood(benchmark::Bench& bench)
* we want to do the same amount of work in every loop iteration. */

bench.epochs(5).epochIterations(1);
const size_t addrman_count{bench.epochs() * bench.epochIterations()};

std::vector<CAddrMan> addrmans(bench.epochs() * bench.epochIterations());
for (auto& addrman : addrmans) {
FillAddrMan(addrman);
std::vector<std::unique_ptr<CAddrMan>> addrmans(addrman_count);
for (size_t i{0}; i < addrman_count; ++i) {
addrmans[i] = std::make_unique<CAddrMan>(/* deterministic */ false, /* consistency_check_ratio */ 0);
FillAddrMan(*addrmans[i]);
}

auto markSomeAsGood = [](CAddrMan& addrman) {
Expand All @@ -130,7 +132,7 @@ static void AddrManGood(benchmark::Bench& bench)

uint64_t i = 0;
bench.run([&] {
markSomeAsGood(addrmans.at(i));
markSomeAsGood(*addrmans.at(i));
++i;
});
}
Expand Down
35 changes: 34 additions & 1 deletion src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,29 @@ static void GetWalletBalances(UniValue& result)
result.pushKV("balances", balances);
}

/**
* GetProgressBar contructs a progress bar with 5% intervals.
*
* @param[in] progress The proportion of the progress bar to be filled between 0 and 1.
* @param[out] progress_bar String representation of the progress bar.
*/
static void GetProgressBar(double progress, std::string& progress_bar)
{
if (progress < 0 || progress > 1) return;

static constexpr double INCREMENT{0.05};
static const std::string COMPLETE_BAR{"\u2592"};
static const std::string INCOMPLETE_BAR{"\u2591"};

for (int i = 0; i < progress / INCREMENT; ++i) {
progress_bar += COMPLETE_BAR;
}

for (int i = 0; i < (1 - progress) / INCREMENT; ++i) {
progress_bar += INCOMPLETE_BAR;
}
}

/**
* ParseGetInfoResult takes in -getinfo result in UniValue object and parses it
* into a user friendly UniValue string to be printed on the console.
Expand Down Expand Up @@ -926,7 +949,17 @@ static void ParseGetInfoResult(UniValue& result)
std::string result_string = strprintf("%sChain: %s%s\n", BLUE, result["chain"].getValStr(), RESET);
result_string += strprintf("Blocks: %s\n", result["blocks"].getValStr());
result_string += strprintf("Headers: %s\n", result["headers"].getValStr());
result_string += strprintf("Verification progress: %.4f%%\n", result["verificationprogress"].get_real() * 100);

const double ibd_progress{result["verificationprogress"].get_real()};
std::string ibd_progress_bar;
// Display the progress bar only if IBD progress is less than 99%
if (ibd_progress < 0.99) {
GetProgressBar(ibd_progress, ibd_progress_bar);
// Add padding between progress bar and IBD progress
ibd_progress_bar += " ";
}

result_string += strprintf("Verification progress: %s%.4f%%\n", ibd_progress_bar, ibd_progress * 100);
result_string += strprintf("Difficulty: %s\n\n", result["difficulty"].getValStr());

result_string += strprintf(
Expand Down
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ class CRegTestParams : public CChainParams {
consensus.BIP16Height = 0;
consensus.BIP34Height = 2; // BIP34 activated on regtest (Block at height 1 not enforced for testing purposes)
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in functional tests)
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in functional tests)
consensus.BIP66Height = 102; // BIP66 activated on regtest (Block at height 101 and earlier not enforced for testing purposes)
consensus.CSVHeight = 432; // CSV activated on regtest (Used in rpc activation tests)
consensus.SegwitHeight = 0; // SEGWIT is always activated on regtest unless overridden
consensus.MinBIP9WarningHeight = 0;
Expand Down
Loading

0 comments on commit 8dcb420

Please sign in to comment.