Auto merge of #4849 - str4d:lint-fixes, r=str4d

Lint fixes

Fixes most lints currently reported by `test/lint/lint-all.sh`.

Includes changes cherry-picked from the following upstream PRs:
- bitcoin/bitcoin#8700
- bitcoin/bitcoin#8840
- bitcoin/bitcoin#9867
  - We backported the second commit in zcash/zcash#3146
- bitcoin/bitcoin#10771
- bitcoin/bitcoin#11394
- bitcoin/bitcoin#11649
- bitcoin/bitcoin#17329
- bitcoin/bitcoin#19258
This commit is contained in:
Homu 2020-11-10 01:42:15 +00:00
commit caed4adf50
69 changed files with 262 additions and 151 deletions

View File

@ -1,5 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash
export LC_ALL=C
set -exo pipefail
# Debian 9
docker build . -f Dockerfile-build-python.apt --build-arg FROMBASEOS=debian --build-arg FROMBASEOS_BUILD_TAG=9 -t electriccoinco/zcashd-build-debian9
docker push electriccoinco/zcashd-build-debian9

View File

@ -1,5 +1,6 @@
#!/bin/bash
#!/usr/bin/env bash
export LC_ALL=C
set -eo pipefail
if [[ ${1} == "--version" ]];then

View File

@ -1,4 +1,7 @@
#!/bin/bash
# Copyright (c) 2013 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
if [ -d "$1" ]; then
cd "$1" || exit 1

View File

@ -314,6 +314,39 @@ Source code organization
#endif // ZCASH_FOO_BAR_H
```
Subtrees
----------
Several parts of the repository are subtrees of software maintained elsewhere.
Some of these are maintained by active developers of Zcash or Bitcoin Core, in which case changes should probably go
directly upstream without being PRed directly against the project. They will be merged back in the next
subtree merge.
Others are external projects without a tight relationship with our project. Changes to these should also
be sent upstream, but bugfixes may also be prudent to PR against Zcash and/or Bitcoin Core so that they can be integrated
quickly. Cosmetic changes should be purely taken upstream.
There is a tool in `test/lint/git-subtree-check.sh` ([instructions](../test/lint#git-subtree-checksh)) to check a subtree directory for consistency with
its upstream repository.
Current subtrees include:
- src/leveldb
- Upstream at https://github.com/google/leveldb ; Maintained by Google, but
open important PRs to Core to avoid delay.
- **Note**: Follow the instructions in [Upgrading LevelDB](#upgrading-leveldb) when
merging upstream changes to the LevelDB subtree.
- src/secp256k1
- Upstream at https://github.com/bitcoin-core/secp256k1/ ; actively maintained by Core contributors.
- src/crypto/ctaes
- Upstream at https://github.com/bitcoin-core/ctaes ; actively maintained by Core contributors.
- src/univalue
- Upstream at https://github.com/bitcoin-core/univalue ; actively maintained by Core contributors, deviates from upstream https://github.com/jgarzik/univalue
Scripted diffs
--------------

View File

@ -19,7 +19,7 @@ class ForkNotifyTest(BitcoinTestFramework):
def setup_network(self):
self.nodes = []
self.alert_filename = os.path.join(self.options.tmpdir, "alert.txt")
with open(self.alert_filename, 'w'):
with open(self.alert_filename, 'w', encoding='utf8'):
pass # Just open then close to create zero-length file
self.nodes.append(start_node(0, self.options.tmpdir,
["-blockversion=2", "-alertnotify=echo %s >> \"" + self.alert_filename + "\""]))
@ -41,7 +41,7 @@ class ForkNotifyTest(BitcoinTestFramework):
self.nodes[1].generate(1)
self.sync_all()
with open(self.alert_filename, 'r') as f:
with open(self.alert_filename, 'r', encoding='utf8') as f:
alert_text = f.read()
if len(alert_text) == 0:
@ -53,7 +53,7 @@ class ForkNotifyTest(BitcoinTestFramework):
self.nodes[1].generate(1)
self.sync_all()
with open(self.alert_filename, 'r') as f:
with open(self.alert_filename, 'r', encoding='utf8') as f:
alert_text2 = f.read()
if alert_text != alert_text2:

View File

@ -17,7 +17,7 @@ class HardForkDetectionTest(BitcoinTestFramework):
def setup_network(self):
self.nodes = []
self.alert_filename = os.path.join(self.options.tmpdir, "alert.txt")
with open(self.alert_filename, 'w'):
with open(self.alert_filename, 'w', encoding='utf8'):
pass # Just open then close to create zero-length file
self.nodes.append(start_node(0, self.options.tmpdir,
["-blockversion=2", "-alertnotify=echo %s >> \"" + self.alert_filename + "\""]))
@ -48,7 +48,7 @@ class HardForkDetectionTest(BitcoinTestFramework):
self.assert_safemode_on("We do not appear to fully agree with our peers!")
# Check that an -alertnotify was triggered.
with open(self.alert_filename, 'r') as f:
with open(self.alert_filename, 'r', encoding='utf8') as f:
alert_text = f.read()
if len(alert_text) == 0:

View File

@ -28,7 +28,7 @@ class HTTPBasicsTest (BitcoinTestFramework):
#Append rpcauth to zcash.conf before initialization
rpcauth = "rpcauth=rt:93648e835a54c573682c2eb19f882535$7681e9c5b74bdd85e78166031d2058e1069b3ed7ed967c93fc63abba06f31144"
rpcauth2 = "rpcauth=rt2:f8607b1a88861fac29dfccf9b52ff9f$ff36a0c23c8c62b4846112e50fa888416e94c17bfd4c42f88fd8f55ec6a3137e"
with open(os.path.join(self.options.tmpdir+"/node0", "zcash.conf"), 'a') as f:
with open(os.path.join(self.options.tmpdir+"/node0", "zcash.conf"), 'a', encoding='utf8') as f:
f.write(rpcauth+"\n")
f.write(rpcauth2+"\n")

View File

@ -98,7 +98,7 @@ class SaplingRewindTest(BitcoinTestFramework):
except:
logpath = self.options.tmpdir + "/node2/regtest/debug.log"
found = False
with open(logpath, 'r') as f:
with open(logpath, 'r', encoding='utf8') as f:
for line in f:
# Search for the rollback message in the debug log, and ensure that it has the
# correct expected rollback length.

View File

@ -45,7 +45,7 @@ class AuthServiceProxyWrapper(object):
rpc_method = self.auth_service_proxy_instance._service_name
if self.coverage_logfile:
with open(self.coverage_logfile, 'a+') as f:
with open(self.coverage_logfile, 'a+', encoding='utf8') as f:
f.write("%s\n" % rpc_method)
return return_val
@ -95,7 +95,7 @@ def write_all_rpc_commands(dirname, node):
if line and not line.startswith('='):
commands.add("%s\n" % line.split()[0])
with open(filename, 'w') as f:
with open(filename, 'w', encoding='utf8') as f:
f.writelines(list(commands))
return True

View File

@ -56,7 +56,7 @@ def netstat(typ='tcp'):
To get pid of all network process running on system, you must run this script
as superuser
'''
with open('/proc/net/'+typ,'r') as f:
with open('/proc/net/'+typ,'r',encoding='utf8') as f:
content = f.readlines()
content.pop(0)
result = []

View File

@ -138,7 +138,7 @@ def initialize_datadir(dirname, n):
datadir = os.path.join(dirname, "node"+str(n))
if not os.path.isdir(datadir):
os.makedirs(datadir)
with open(os.path.join(datadir, "zcash.conf"), 'w') as f:
with open(os.path.join(datadir, "zcash.conf"), 'w', encoding='utf8') as f:
f.write("regtest=1\n")
f.write("showmetrics=0\n")
f.write("rpcuser=rt\n")
@ -600,7 +600,7 @@ def check_node_log(self, node_number, line_to_check, stop_node = True):
self.nodes[node_number].stop()
bitcoind_processes[node_number].wait()
logpath = self.options.tmpdir + "/node" + str(node_number) + "/regtest/debug.log"
with open(logpath, "r") as myfile:
with open(logpath, "r", encoding="utf8") as myfile:
logdata = myfile.readlines()
for (n, logline) in enumerate(logdata):
if line_to_check in logline:

View File

@ -57,7 +57,7 @@ class WalletImportExportTest (BitcoinTestFramework):
# Helper functions
def parse_wallet_file(dump_path):
file_lines = open(dump_path, "r").readlines()
file_lines = open(dump_path, "r", encoding="utf8").readlines()
# We expect information about the HDSeed and fingerpring in the header
assert_true("HDSeed" in file_lines[4], "Expected HDSeed")
assert_true("fingerprint" in file_lines[4], "Expected fingerprint")

View File

@ -1,4 +1,6 @@
#!/bin/bash
#!/usr/bin/env bash
export LC_ALL=C
set -u

View File

@ -747,7 +747,7 @@ class ZcashNode(object):
cli_args.append('-testnet=1')
cli_args.append('getblockcount')
devnull = open('/dev/null', 'w+')
devnull = open('/dev/null', 'w+', encoding='utf8')
if os.getenv('PYTHON_DEBUG', ''):
print('start_node: zcashd started, calling zcash-cli -rpcwait getblockcount')
subprocess.check_call(cli_args, stdout=devnull)

View File

@ -303,7 +303,7 @@ class DependsVersionGetter:
def current_version(self):
mk_file_path = os.path.join(SOURCE_ROOT, "depends", "packages", safe_depends(self.name) + ".mk")
mk_file = open(mk_file_path, 'r').read()
mk_file = open(mk_file_path, 'r', encoding='utf8').read()
regexp_whitelist = [
"package\)_version=(\d+)\.(\d+)\.(\d+)$",
@ -329,7 +329,7 @@ class DependsVersionGetter:
class LevelDbVersionGetter:
def current_version(self):
header_path = os.path.join(SOURCE_ROOT, "src", "leveldb", "include", "leveldb", "db.h")
header_contents = open(header_path, 'r').read()
header_contents = open(header_path, 'r', encoding='utf8').read()
match = re.search("kMajorVersion\s*=\s*(\d+);\s*.*kMinorVersion\s*=\s*(\d+);\s*$", header_contents, re.MULTILINE)
if match:
@ -340,7 +340,7 @@ class LevelDbVersionGetter:
class UnivalueVersionGetter:
def current_version(self):
configure_path = os.path.join(SOURCE_ROOT, "src", "univalue", "configure.ac")
configure_contents = open(configure_path, 'r').read()
configure_contents = open(configure_path, 'r', encoding='utf8').read()
match = re.search("AC_INIT.*univalue.*\[(\d+)\.(\d+)\.(\d+)\]", configure_contents)
if match:
@ -357,7 +357,7 @@ class PostponedUpdates():
"postponed-updates.txt"
)
file = open(postponedlist_path, 'r')
file = open(postponedlist_path, 'r', encoding='utf8')
for line in file.readlines():
stripped = re.sub('#.*$', '', line).strip()
if stripped != "":

View File

@ -3,8 +3,8 @@
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef ASYNCRPCOPERATION_H
#define ASYNCRPCOPERATION_H
#ifndef ZCASH_ASYNCRPCOPERATION_H
#define ZCASH_ASYNCRPCOPERATION_H
#include <string>
#include <atomic>
@ -149,5 +149,5 @@ private:
int64_t creation_time_;
};
#endif /* ASYNCRPCOPERATION_H */
#endif // ZCASH_ASYNCRPCOPERATION_H

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef ASYNCRPCQUEUE_H
#define ASYNCRPCQUEUE_H
#ifndef ZCASH_ASYNCRPCQUEUE_H
#define ZCASH_ASYNCRPCQUEUE_H
#include "asyncrpcoperation.h"
@ -65,6 +65,4 @@ private:
std::vector<std::thread> workers_;
};
#endif
#endif // ZCASH_ASYNCRPCQUEUE_H

View File

@ -236,19 +236,19 @@ FullStepRow<WIDTH>::FullStepRow(const unsigned char* hashIn, size_t hInLen,
}
template<size_t WIDTH> template<size_t W>
FullStepRow<WIDTH>::FullStepRow(const FullStepRow<W>& a, const FullStepRow<W>& b, size_t len, size_t lenIndices, int trim) :
FullStepRow<WIDTH>::FullStepRow(const FullStepRow<W>& a, const FullStepRow<W>& b, size_t len, size_t lenIndices, int lenTrim) :
StepRow<WIDTH> {a}
{
assert(len+lenIndices <= W);
assert(len-trim+(2*lenIndices) <= WIDTH);
for (int i = trim; i < len; i++)
hash[i-trim] = a.hash[i] ^ b.hash[i];
assert(len-lenTrim+(2*lenIndices) <= WIDTH);
for (int i = lenTrim; i < len; i++)
hash[i-lenTrim] = a.hash[i] ^ b.hash[i];
if (a.IndicesBefore(b, len, lenIndices)) {
std::copy(a.hash+len, a.hash+len+lenIndices, hash+len-trim);
std::copy(b.hash+len, b.hash+len+lenIndices, hash+len-trim+lenIndices);
std::copy(a.hash+len, a.hash+len+lenIndices, hash+len-lenTrim);
std::copy(b.hash+len, b.hash+len+lenIndices, hash+len-lenTrim+lenIndices);
} else {
std::copy(b.hash+len, b.hash+len+lenIndices, hash+len-trim);
std::copy(a.hash+len, a.hash+len+lenIndices, hash+len-trim+lenIndices);
std::copy(b.hash+len, b.hash+len+lenIndices, hash+len-lenTrim);
std::copy(a.hash+len, a.hash+len+lenIndices, hash+len-lenTrim+lenIndices);
}
}
@ -303,19 +303,19 @@ TruncatedStepRow<WIDTH>::TruncatedStepRow(const unsigned char* hashIn, size_t hI
}
template<size_t WIDTH> template<size_t W>
TruncatedStepRow<WIDTH>::TruncatedStepRow(const TruncatedStepRow<W>& a, const TruncatedStepRow<W>& b, size_t len, size_t lenIndices, int trim) :
TruncatedStepRow<WIDTH>::TruncatedStepRow(const TruncatedStepRow<W>& a, const TruncatedStepRow<W>& b, size_t len, size_t lenIndices, int lenTrim) :
StepRow<WIDTH> {a}
{
assert(len+lenIndices <= W);
assert(len-trim+(2*lenIndices) <= WIDTH);
for (int i = trim; i < len; i++)
hash[i-trim] = a.hash[i] ^ b.hash[i];
assert(len-lenTrim+(2*lenIndices) <= WIDTH);
for (int i = lenTrim; i < len; i++)
hash[i-lenTrim] = a.hash[i] ^ b.hash[i];
if (a.IndicesBefore(b, len, lenIndices)) {
std::copy(a.hash+len, a.hash+len+lenIndices, hash+len-trim);
std::copy(b.hash+len, b.hash+len+lenIndices, hash+len-trim+lenIndices);
std::copy(a.hash+len, a.hash+len+lenIndices, hash+len-lenTrim);
std::copy(b.hash+len, b.hash+len+lenIndices, hash+len-lenTrim+lenIndices);
} else {
std::copy(b.hash+len, b.hash+len+lenIndices, hash+len-trim);
std::copy(a.hash+len, a.hash+len+lenIndices, hash+len-trim+lenIndices);
std::copy(b.hash+len, b.hash+len+lenIndices, hash+len-lenTrim);
std::copy(a.hash+len, a.hash+len+lenIndices, hash+len-lenTrim+lenIndices);
}
}

View File

@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef BITCOIN_EQUIHASH_H
#define BITCOIN_EQUIHASH_H
#ifndef ZCASH_CRYPTO_EQUIHASH_H
#define ZCASH_CRYPTO_EQUIHASH_H
#include <memory>
#include <vector>
@ -129,7 +129,7 @@ public:
FullStepRow(const FullStepRow<WIDTH>& a) : StepRow<WIDTH> {a} { }
template<size_t W>
FullStepRow(const FullStepRow<W>& a, const FullStepRow<W>& b, size_t len, size_t lenIndices, int trim);
FullStepRow(const FullStepRow<W>& a, const FullStepRow<W>& b, size_t len, size_t lenIndices, int lenTrim);
FullStepRow& operator=(const FullStepRow<WIDTH>& a);
inline bool IndicesBefore(const FullStepRow<WIDTH>& a, size_t len, size_t lenIndices) const { return memcmp(hash+len, a.hash+len, lenIndices) < 0; }
@ -159,7 +159,7 @@ public:
TruncatedStepRow(const TruncatedStepRow<WIDTH>& a) : StepRow<WIDTH> {a} { }
template<size_t W>
TruncatedStepRow(const TruncatedStepRow<W>& a, const TruncatedStepRow<W>& b, size_t len, size_t lenIndices, int trim);
TruncatedStepRow(const TruncatedStepRow<W>& a, const TruncatedStepRow<W>& b, size_t len, size_t lenIndices, int lenTrim);
TruncatedStepRow& operator=(const TruncatedStepRow<WIDTH>& a);
inline bool IndicesBefore(const TruncatedStepRow<WIDTH>& a, size_t len, size_t lenIndices) const { return memcmp(hash+len, a.hash+len, lenIndices) < 0; }
@ -290,4 +290,4 @@ inline bool EhOptimisedSolveUncancellable(unsigned int n, unsigned int k, const
}
#endif // ENABLE_MINING
#endif // BITCOIN_EQUIHASH_H
#endif // ZCASH_CRYPTO_EQUIHASH_H

View File

@ -2,6 +2,9 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef ZCASH_EXPERIMENTAL_FEATURES_H
#define ZCASH_EXPERIMENTAL_FEATURES_H
#include <string>
#include <vector>
#include <boost/optional.hpp>
@ -14,3 +17,5 @@ extern bool fExperimentalLightWalletd;
boost::optional<std::string> InitExperimentalMode();
std::vector<std::string> GetExperimentalFeatures();
#endif // ZCASH_EXPERIMENTAL_FEATURES_H

View File

@ -1,3 +1,6 @@
#ifndef ZCASH_GTEST_JSON_TEST_VECTORS_H
#define ZCASH_GTEST_JSON_TEST_VECTORS_H
#include <gtest/gtest.h>
#include "utilstrencodings.h"
@ -49,3 +52,5 @@ void expect_test_vector(T& v, const U& expected)
ASSERT_TRUE(memcmp(&*ss1.begin(), &*ss2.begin(), ss1.size()) == 0);
#endif
}
#endif // ZCASH_GTEST_JSON_TEST_VECTORS_H

View File

@ -12,7 +12,6 @@
#include "ui_interface.h"
#include "crypto/hmac_sha256.h"
#include <stdio.h>
#include "utilstrencodings.h"
#include <boost/algorithm/string.hpp> // boost::trim
#include <boost/foreach.hpp> //BOOST_FOREACH

View File

@ -20,7 +20,7 @@
#include "httpserver.h"
#include "httprpc.h"
#include "key.h"
#ifdef ENABLE_MINING
#if defined(ENABLE_MINING) || defined(ENABLE_WALLET)
#include "key_io.h"
#endif
#include "main.h"
@ -41,7 +41,6 @@
#include "utilmoneystr.h"
#include "validationinterface.h"
#ifdef ENABLE_WALLET
#include "key_io.h"
#include "wallet/wallet.h"
#include "wallet/walletdb.h"
#endif

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef MEMPOOLLIMIT_H
#define MEMPOOLLIMIT_H
#ifndef ZCASH_MEMPOOL_LIMIT_H
#define ZCASH_MEMPOOL_LIMIT_H
#include <map>
#include <set>
@ -126,4 +126,4 @@ public:
};
#endif // MEMPOOLLIMIT_H
#endif // ZCASH_MEMPOOL_LIMIT_H

View File

@ -2,6 +2,9 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef ZCASH_METRICS_H
#define ZCASH_METRICS_H
#include "uint256.h"
#include "consensus/params.h"
@ -111,3 +114,5 @@ const std::string METRICS_ART =
"  :@888@XXX@888:  tt \n"
"   \n"
"   ";
#endif // ZCASH_METRICS_H

View File

@ -1,6 +1,9 @@
// Equihash solver
// Copyright (c) 2016-2016 John Tromp, The Zcash developers
#ifndef ZCASH_POW_TROMP_EQUI_H
#define ZCASH_POW_TROMP_EQUI_H
#ifdef __APPLE__
#include "pow/tromp/osx_barrier.h"
#endif
@ -98,3 +101,5 @@ int verify(u32 indices[PROOFSIZE], const BLAKE2bState *ctx) {
uchar hash[WN/8];
return verifyrec(ctx, indices, hash, WK);
}
#endif // ZCASH_POW_TROMP_EQUI_H

View File

@ -18,6 +18,9 @@
// the i*n 0s, each bucket having 4 * 2^RESTBITS slots,
// twice the number of subtrees expected to land there.
#ifndef ZCASH_POW_TROMP_EQUI_MINER_H
#define ZCASH_POW_TROMP_EQUI_MINER_H
#include "pow/tromp/equi.h"
#include <stdio.h>
#include <stdlib.h>
@ -644,3 +647,5 @@ void *worker(void *vp) {
pthread_exit(NULL);
return 0;
}
#endif // ZCASH_POW_TROMP_EQUI_MINER_H

View File

@ -1,3 +1,6 @@
#ifndef ZCASH_POW_TROMP_OSX_BARRIER_H
#define ZCASH_POW_TROMP_OSX_BARRIER_H
#ifdef __APPLE__
#ifndef PTHREAD_BARRIER_H_
@ -68,3 +71,5 @@ int pthread_barrier_wait(pthread_barrier_t *barrier)
#endif // PTHREAD_BARRIER_H_
#endif // __APPLE__
#endif // ZCASH_POW_TROMP_OSX_BARRIER_H

View File

@ -1,5 +1,5 @@
#ifndef LIBRUSTZCASH_INCLUDE_H_
#define LIBRUSTZCASH_INCLUDE_H_
#ifndef ZCASH_RUST_INCLUDE_LIBRUSTZCASH_H
#define ZCASH_RUST_INCLUDE_LIBRUSTZCASH_H
#include "rust/types.h"
@ -375,4 +375,4 @@ extern "C" {
}
#endif
#endif // LIBRUSTZCASH_INCLUDE_H_
#endif // ZCASH_RUST_INCLUDE_LIBRUSTZCASH_H

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef BLAKE2B_INCLUDE_H_
#define BLAKE2B_INCLUDE_H_
#ifndef ZCASH_RUST_INCLUDE_RUST_BLAKE2B_H
#define ZCASH_RUST_INCLUDE_RUST_BLAKE2B_H
#include <stddef.h>
@ -56,4 +56,4 @@ void blake2b_finalize(
}
#endif
#endif // BLAKE2B_INCLUDE_H_
#endif // ZCASH_RUST_INCLUDE_RUST_BLAKE2B_H

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef ED25519_INCLUDE_H_
#define ED25519_INCLUDE_H_
#ifndef ZCASH_RUST_INCLUDE_RUST_ED25519_H
#define ZCASH_RUST_INCLUDE_RUST_ED25519_H
#include "ed25519/types.h"
@ -56,4 +56,4 @@ bool ed25519_verify(
}
#endif
#endif // ED25519_INCLUDE_H_
#endif // ZCASH_RUST_INCLUDE_RUST_ED25519_H

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef RUST_ED25519_TYPES_H_
#define RUST_ED25519_TYPES_H_
#ifndef ZCASH_RUST_INCLUDE_RUST_ED25519_TYPES_H
#define ZCASH_RUST_INCLUDE_RUST_ED25519_TYPES_H
#ifndef __cplusplus
#include <assert.h>
@ -53,4 +53,4 @@ static_assert(
alignof(Ed25519Signature) == 1,
"Ed25519Signature struct alignment is not 1");
#endif // RUST_ED25519_TYPES_H_
#endif // ZCASH_RUST_INCLUDE_RUST_ED25519_TYPES_H

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef RUST_TYPES_H_
#define RUST_TYPES_H_
#ifndef ZCASH_RUST_INCLUDE_RUST_TYPES_H
#define ZCASH_RUST_INCLUDE_RUST_TYPES_H
#include <stdint.h>
@ -13,4 +13,4 @@ typedef uint16_t codeunit;
typedef uint8_t codeunit;
#endif
#endif // RUST_TYPES_H_
#endif // ZCASH_RUST_INCLUDE_RUST_TYPES_H

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef TRACING_INCLUDE_H_
#define TRACING_INCLUDE_H_
#ifndef ZCASH_RUST_INCLUDE_TRACING_H
#define ZCASH_RUST_INCLUDE_TRACING_H
#include "rust/types.h"
#include "tracing/map.h"
@ -338,4 +338,4 @@ public:
/// target MUST be a static constant, and MUST be valid UTF-8 string.
#define TracingTrace(...) TracingLog("trace", __VA_ARGS__)
#endif // TRACING_INCLUDE_H_
#endif // ZCASH_RUST_INCLUDE_TRACING_H

View File

@ -26,8 +26,8 @@
* prior written authorization from the authors.
*/
#ifndef MAP_H_INCLUDED
#define MAP_H_INCLUDED
#ifndef ZCASH_RUST_INCLUDE_TRACING_MAP_H
#define ZCASH_RUST_INCLUDE_TRACING_MAP_H
#define EVAL0(...) __VA_ARGS__
#define EVAL1(...) EVAL0(EVAL0(EVAL0(__VA_ARGS__)))
@ -67,4 +67,4 @@
*/
#define MAP_LIST(f, ...) EVAL(MAP_LIST1(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0))
#endif
#endif // ZCASH_RUST_INCLUDE_TRACING_MAP_H

View File

@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef BITCOIN_ZCASHCONSENSUS_H
#define BITCOIN_ZCASHCONSENSUS_H
#ifndef BITCOIN_SCRIPT_ZCASHCONSENSUS_H
#define BITCOIN_SCRIPT_ZCASHCONSENSUS_H
#include <stdint.h>
@ -67,4 +67,4 @@ EXPORT_SYMBOL unsigned int zcashconsensus_version();
#undef EXPORT_SYMBOL
#endif // BITCOIN_ZCASHCONSENSUS_H
#endif // BITCOIN_SCRIPT_ZCASHCONSENSUS_H

View File

@ -3,8 +3,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_TEST_RANDOM_H
#define BITCOIN_TEST_RANDOM_H
#ifndef BITCOIN_TEST_TEST_RANDOM_H
#define BITCOIN_TEST_TEST_RANDOM_H
#include "random.h"

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef TRANSACTION_BUILDER_H
#define TRANSACTION_BUILDER_H
#ifndef ZCASH_TRANSACTION_BUILDER_H
#define ZCASH_TRANSACTION_BUILDER_H
#include "coins.h"
#include "consensus/params.h"
@ -157,4 +157,4 @@ private:
std::array<size_t, ZC_NUM_JS_OUTPUTS>& outputMap);
};
#endif /* TRANSACTION_BUILDER_H */
#endif // ZCASH_TRANSACTION_BUILDER_H

View File

@ -1,5 +1,5 @@
#ifndef UINT252_H
#define UINT252_H
#ifndef ZCASH_UINT252_H
#define ZCASH_UINT252_H
#include <vector>
#include "uint256.h"
@ -47,4 +47,4 @@ public:
friend inline bool operator==(const uint252& a, const uint252& b) { return a.contents == b.contents; }
};
#endif
#endif // ZCASH_UINT252_H

View File

@ -20,10 +20,7 @@ base_blob<BITS>::base_blob(const std::vector<unsigned char>& vch)
template <unsigned int BITS>
std::string base_blob<BITS>::GetHex() const
{
char psz[sizeof(data) * 2 + 1];
for (unsigned int i = 0; i < sizeof(data); i++)
sprintf(psz + i * 2, "%02x", data[sizeof(data) - i - 1]);
return std::string(psz, psz + sizeof(data) * 2);
return HexStr(std::reverse_iterator<const uint8_t*>(data + sizeof(data)), std::reverse_iterator<const uint8_t*>(data));
}
template <unsigned int BITS>

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef ZCASH_UTIL_TEST_H
#define ZCASH_UTIL_TEST_H
#ifndef ZCASH_UTILTEST_H
#define ZCASH_UTILTEST_H
#include "key_io.h"
#include "wallet/wallet.h"
@ -68,4 +68,4 @@ CWalletTx GetValidSaplingReceive(const Consensus::Params& consensusParams,
const libzcash::SaplingExtendedSpendingKey &sk,
CAmount value);
#endif // ZCASH_UTIL_TEST_H
#endif // ZCASH_UTILTEST_H

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef ASYNCRPCOPERATION_COMMON_H
#define ASYNCRPCOPERATION_COMMON_H
#ifndef ZCASH_WALLET_ASYNCRPCOPERATION_COMMON_H
#define ZCASH_WALLET_ASYNCRPCOPERATION_COMMON_H
#include "primitives/transaction.h"
#include "univalue.h"
@ -28,4 +28,4 @@ UniValue SendTransaction(CTransaction& tx, boost::optional<CReserveKey&> reserve
*/
std::pair<CTransaction, UniValue> SignSendRawTransaction(UniValue obj, boost::optional<CReserveKey&> reservekey, bool testmode);
#endif /* ASYNCRPCOPERATION_COMMON_H */
#endif // ZCASH_WALLET_ASYNCRPCOPERATION_COMMON_H

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef ASYNCRPCOPERATION_MERGETOADDRESS_H
#define ASYNCRPCOPERATION_MERGETOADDRESS_H
#ifndef ZCASH_WALLET_ASYNCRPCOPERATION_MERGETOADDRESS_H
#define ZCASH_WALLET_ASYNCRPCOPERATION_MERGETOADDRESS_H
#include "amount.h"
#include "asyncrpcoperation.h"
@ -193,4 +193,4 @@ public:
};
#endif /* ASYNCRPCOPERATION_MERGETOADDRESS_H */
#endif // ZCASH_WALLET_ASYNCRPCOPERATION_MERGETOADDRESS_H

View File

@ -1,3 +1,6 @@
#ifndef ZCASH_WALLET_ASYNCRPCOPERATION_SAPLINGMIGRATION_H
#define ZCASH_WALLET_ASYNCRPCOPERATION_SAPLINGMIGRATION_H
#include "amount.h"
#include "asyncrpcoperation.h"
#include "univalue.h"
@ -32,3 +35,5 @@ private:
CAmount chooseAmount(const CAmount& availableFunds);
};
#endif // ZCASH_WALLET_ASYNCRPCOPERATION_SAPLINGMIGRATION_H

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef ASYNCRPCOPERATION_SENDMANY_H
#define ASYNCRPCOPERATION_SENDMANY_H
#ifndef ZCASH_WALLET_ASYNCRPCOPERATION_SENDMANY_H
#define ZCASH_WALLET_ASYNCRPCOPERATION_SENDMANY_H
#include "asyncrpcoperation.h"
#include "amount.h"
@ -221,4 +221,4 @@ public:
};
#endif /* ASYNCRPCOPERATION_SENDMANY_H */
#endif // ZCASH_WALLET_ASYNCRPCOPERATION_SENDMANY_H

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef ASYNCRPCOPERATION_SHIELDCOINBASE_H
#define ASYNCRPCOPERATION_SHIELDCOINBASE_H
#ifndef ZCASH_WALLET_ASYNCRPCOPERATION_SHIELDCOINBASE_H
#define ZCASH_WALLET_ASYNCRPCOPERATION_SHIELDCOINBASE_H
#include "asyncrpcoperation.h"
#include "amount.h"
@ -143,5 +143,5 @@ public:
};
#endif /* ASYNCRPCOPERATION_SHIELDCOINBASE_H */
#endif // ZCASH_WALLET_ASYNCRPCOPERATION_SHIELDCOINBASE_H

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef ZCASH_PAYMENTDISCLOSURE_H
#define ZCASH_PAYMENTDISCLOSURE_H
#ifndef ZCASH_WALLET_PAYMENTDISCLOSURE_H
#define ZCASH_WALLET_PAYMENTDISCLOSURE_H
#include "uint256.h"
#include "clientversion.h"
@ -164,4 +164,4 @@ struct PaymentDisclosure {
typedef std::pair<PaymentDisclosureKey, PaymentDisclosureInfo> PaymentDisclosureKeyInfo;
#endif // ZCASH_PAYMENTDISCLOSURE_H
#endif // ZCASH_WALLET_PAYMENTDISCLOSURE_H

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef ZCASH_PAYMENTDISCLOSUREDB_H
#define ZCASH_PAYMENTDISCLOSUREDB_H
#ifndef ZCASH_WALLET_PAYMENTDISCLOSUREDB_H
#define ZCASH_WALLET_PAYMENTDISCLOSUREDB_H
#include <wallet/paymentdisclosure.h>
@ -39,4 +39,4 @@ public:
};
#endif // ZCASH_PAYMENTDISCLOSUREDB_H
#endif // ZCASH_WALLET_PAYMENTDISCLOSUREDB_H

View File

@ -1,5 +1,5 @@
#ifndef ZC_ZCASH_H_
#define ZC_ZCASH_H_
#ifndef ZCASH_ZCASH_ZCASH_H
#define ZCASH_ZCASH_ZCASH_H
#define ZC_NUM_JS_INPUTS 2
#define ZC_NUM_JS_OUTPUTS 2
@ -27,4 +27,4 @@
#define ZC_SAPLING_ENCCIPHERTEXT_SIZE (ZC_SAPLING_ENCPLAINTEXT_SIZE + NOTEENCRYPTION_AUTH_BYTES)
#define ZC_SAPLING_OUTCIPHERTEXT_SIZE (ZC_SAPLING_OUTPLAINTEXT_SIZE + NOTEENCRYPTION_AUTH_BYTES)
#endif // ZC_ZCASH_H_
#endif // ZCASH_ZCASH_ZCASH_H

View File

@ -2,8 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .
#ifndef ZCASH_ZIP32_H
#define ZCASH_ZIP32_H
#ifndef ZCASH_ZCASH_ADDRESS_ZIP32_H
#define ZCASH_ZCASH_ADDRESS_ZIP32_H
#include "serialize.h"
#include "support/allocators/secure.h"
@ -136,4 +136,4 @@ struct SaplingExtendedSpendingKey {
}
#endif // ZCASH_ZIP32_H
#endif // ZCASH_ZCASH_ADDRESS_ZIP32_H

View File

@ -3,8 +3,8 @@ Zcash uses SHA256Compress as a PRF for various components
within the zkSNARK circuit.
*/
#ifndef ZC_PRF_H_
#define ZC_PRF_H_
#ifndef ZCASH_ZCASH_PRF_H
#define ZCASH_ZCASH_PRF_H
#include "uint256.h"
#include "uint252.h"
@ -33,4 +33,4 @@ const char PRF_ESK_TAG = 5;
std::array<unsigned char, 11> default_diversifier(const uint256& sk);
#endif // ZC_PRF_H_
#endif // ZCASH_ZCASH_PRF_H

View File

@ -1,5 +1,5 @@
#ifndef ZC_UTIL_H_
#define ZC_UTIL_H_
#ifndef ZCASH_ZCASH_UTIL_H
#define ZCASH_ZCASH_UTIL_H
#include <vector>
#include <cstdint>
@ -8,4 +8,4 @@ std::vector<unsigned char> convertIntToVectorLE(const uint64_t val_int);
std::vector<bool> convertBytesVectorToVector(const std::vector<unsigned char>& bytes);
uint64_t convertVectorToInt(const std::vector<bool>& v);
#endif // ZC_UTIL_H_
#endif // ZCASH_ZCASH_UTIL_H

View File

@ -1,5 +1,5 @@
#ifndef BENCHMARKS_H
#define BENCHMARKS_H
#ifndef ZCASH_ZCBENCHMARKS_H
#define ZCASH_ZCBENCHMARKS_H
#include <sys/time.h>
#include <stdlib.h>
@ -25,4 +25,4 @@ extern double benchmark_create_sapling_output();
extern double benchmark_verify_sapling_spend();
extern double benchmark_verify_sapling_output();
#endif
#endif // ZCASH_ZCBENCHMARKS_H

View File

@ -16,6 +16,12 @@ maintained:
* for `src/univalue`: https://github.com/bitcoin-core/univalue.git (branch master)
* for `src/crypto/ctaes`: https://github.com/bitcoin-core/ctaes.git (branch master)
To do so, add the upstream repository as remote:
```
git remote add --fetch secp256k1 https://github.com/bitcoin-core/secp256k1.git
```
Usage: `git-subtree-check.sh DIR (COMMIT)`
`COMMIT` may be omitted, in which case `HEAD` is used.

View File

@ -1,7 +1,11 @@
#!/bin/sh
# Copyright (c) 2015 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
export LC_ALL=C
DIR="$1"
# Strip trailing / from directory path (in case it was added by autocomplete)
DIR="${1%/}"
COMMIT="$2"
if [ -z "$COMMIT" ]; then
COMMIT=HEAD
@ -16,7 +20,7 @@ find_latest_squash()
sub=
git log --grep="^git-subtree-dir: $dir/*\$" \
--pretty=format:'START %H%n%s%n%n%b%nEND%n' "$COMMIT" |
while read a b junk; do
while read a b _; do
case "$a" in
START) sq="$b" ;;
git-subtree-mainline:) main="$b" ;;
@ -39,21 +43,17 @@ find_latest_squash()
done
}
# find latest subtree update
latest_squash="$(find_latest_squash "$DIR")"
if [ -z "$latest_squash" ]; then
echo "ERROR: $DIR is not a subtree" >&2
exit 2
fi
set $latest_squash
old=$1
rev=$2
if [ "d$(git cat-file -t $rev 2>/dev/null)" != dcommit ]; then
echo "ERROR: subtree commit $rev unavailable. Fetch/update the subtree repository" >&2
exit 2
fi
tree_subtree=$(git show -s --format="%T" $rev)
echo "$DIR in $COMMIT was last updated to upstream commit $rev (tree $tree_subtree)"
# get the tree in the current commit
tree_actual=$(git ls-tree -d "$COMMIT" "$DIR" | head -n 1)
if [ -z "$tree_actual" ]; then
echo "FAIL: subtree directory $DIR not found in $COMMIT" >&2
@ -67,9 +67,30 @@ if [ "d$tree_actual_type" != "dtree" ]; then
echo "FAIL: subtree directory $DIR is not a tree in $COMMIT" >&2
exit 1
fi
if [ "$tree_actual_tree" != "$tree_subtree" ]; then
git diff-tree $tree_actual_tree $tree_subtree >&2
echo "FAIL: subtree directory tree doesn't match subtree commit tree" >&2
# get the tree at the time of the last subtree update
tree_commit=$(git show -s --format="%T" $old)
echo "$DIR in $COMMIT was last updated in commit $old (tree $tree_commit)"
# ... and compare the actual tree with it
if [ "$tree_actual_tree" != "$tree_commit" ]; then
git diff $tree_commit $tree_actual_tree >&2
echo "FAIL: subtree directory was touched without subtree merge" >&2
exit 1
fi
# get the tree in the subtree commit referred to
if [ "d$(git cat-file -t $rev 2>/dev/null)" != dcommit ]; then
echo "subtree commit $rev unavailable: cannot compare. Did you add and fetch the remote?" >&2
exit
fi
tree_subtree=$(git show -s --format="%T" $rev)
echo "$DIR in $COMMIT was last updated to upstream commit $rev (tree $tree_subtree)"
# ... and compare the actual tree with it
if [ "$tree_actual_tree" != "$tree_subtree" ]; then
echo "FAIL: subtree update commit differs from upstream tree!" >&2
exit 1
fi
echo "GOOD"

View File

@ -12,7 +12,7 @@ HEADER_ID_PREFIX="ZCASH_"
HEADER_ID_PREFIX_UPSTREAM="BITCOIN_"
HEADER_ID_SUFFIX="_H"
REGEXP_EXCLUDE_FILES_WITH_PREFIX="src/(leveldb/|secp256k1/|univalue/)"
REGEXP_EXCLUDE_FILES_WITH_PREFIX="src/(crypto/ctaes/|leveldb/|secp256k1/|tinyformat.h|univalue/)"
EXIT_CODE=0
for HEADER_FILE in $(git ls-files -- "*.h" | grep -vE "^${REGEXP_EXCLUDE_FILES_WITH_PREFIX}")

View File

@ -1,5 +1,6 @@
#!/usr/bin/env bash
export LC_ALL=C
set -eu -o pipefail
AFL_HARDEN=1

View File

@ -1,5 +1,6 @@
#!/usr/bin/env bash
export LC_ALL=C
set -eu -o pipefail
for d in src/fuzzing/*/ ; do

View File

@ -1,5 +1,6 @@
#!/usr/bin/env bash
export LC_ALL=C
set -eu -o pipefail
for d in src/fuzzing/*/ ; do

View File

@ -1,5 +1,6 @@
#!/usr/bin/env bash
export LC_ALL=C
set -exu -o pipefail
for d in src/fuzzing/*/ ; do

View File

@ -1,7 +1,8 @@
#!/bin/bash
#!/usr/bin/env bash
## Usage:
## ./zcutil/build-debian-package.sh
export LC_ALL=C
set -e
set -x

View File

@ -1,5 +1,6 @@
#!/usr/bin/env bash
export LC_ALL=C
set -eu -o pipefail
set +x

View File

@ -1,6 +1,8 @@
#!/bin/sh
# Copyright (c) 2020 The Zcash developers
export LC_ALL=C
rm -f src/Makefile
rm -f src/Makefile.in
rm -f doc/man/Makefile

View File

@ -1,9 +1,10 @@
#!/bin/bash
#!/usr/bin/env bash
#
# Warning: This deletes tags on "origin", so point that at the right target!
#
# Note: It doesn't delete any local tags.
export LC_ALL=C
set -exu -o pipefail
ZCASH_TAG_RGX='^v[0-9]+.[0-9]+.[0-9]+.z[0-9]+'
@ -14,7 +15,7 @@ i=0
for nonzctag in $(git ls-remote origin \
| grep refs/tags/ \
| grep -v '\^{}$' \
| sed 's,^.*refs/tags/,,'\
| sed 's,^.*refs/tags/,,' \
| grep -Ev "$ZCASH_TAG_RGX"
)
do

View File

@ -1,6 +1,8 @@
#!/bin/sh
# Copyright (c) 2020 The Zcash developers
export LC_ALL=C
zcutil/clean.sh
rm -rf depends/*-*-*

View File

@ -1,5 +1,6 @@
#!/bin/bash
#!/usr/bin/env bash
export LC_ALL=C
set -eu
if [[ "$OSTYPE" == "darwin"* ]]; then
@ -8,8 +9,9 @@ else
PARAMS_DIR="$HOME/.zcash-params"
fi
SPROUT_PKEY_NAME='sprout-proving.key'
SPROUT_VKEY_NAME='sprout-verifying.key'
# Commented out because these are unused; see below.
#SPROUT_PKEY_NAME='sprout-proving.key'
#SPROUT_VKEY_NAME='sprout-verifying.key'
SAPLING_SPEND_NAME='sapling-spend.params'
SAPLING_OUTPUT_NAME='sapling-output.params'
SAPLING_SPROUT_GROTH16_NAME='sprout-groth16.params'

View File

@ -1,5 +1,6 @@
#!/usr/bin/env bash
export LC_ALL=C
set -eu -o pipefail
usage() {

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python3
#!/usr/bin/env python3
import os
import re
@ -595,14 +595,14 @@ class PathPatcher (object):
def __enter__(self):
logging.debug('Patching %r', self._path)
self._inf = open(self._path, 'r')
self._inf = open(self._path, 'r', encoding='utf8')
self._outf = StringIO()
return (self._inf, self._outf)
def __exit__(self, et, ev, tb):
if (et, ev, tb) == (None, None, None):
self._inf.close()
with open(self._path, 'w') as f:
with open(self._path, 'w', encoding='utf8') as f:
f.write(self._outf.getvalue())

View File

@ -1,4 +1,4 @@
#! /usr/bin/env python3
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re, os, os.path