Skip to content

Commit d7413ff

Browse files
Merge dashpay#6047: backport: trivial 2024 06 05
76279c1 Merge bitcoin#25149: refactor: Add thread safety annotation to `BanMan::SweepBanned()` (MacroFake) 6269c6f Merge bitcoin#25053: Guard `#include <config/bitcoin-config.h>` (fanquake) d50f0b0 Merge bitcoin#24977: rpc: Explain active and internal in listdescriptors (fanquake) 3c44399 Merge bitcoin#24856: lint: Converting lint-assertions.sh to lint-assertions.py (laanwj) e9f5b4b Merge bitcoin#24213: refactor: use Span in random.* (laanwj) 7e0474a Merge bitcoin#24632: add `(none)` in -getinfo `Warnings:` if no warning returned (laanwj) 57e9b56 Merge bitcoin#24145: mempool: Clear vTxHashes when mapTx is cleared (laanwj) fe56d9b Merge bitcoin#24698: test: -peerblockfilters without -blockfilterindex raises an error (MarcoFalke) 3cabce6 Merge bitcoin#24472: fuzz: execute each file in dir without fuzz engine (MarcoFalke) f5116a7 Merge bitcoin-core/gui#549: refactor: use std::chrono for formatDurationStr() helper (Hennadii Stepanov) 3fa8158 Merge bitcoin#22317: doc: Highlight DNS requests part in tor.md (Andrew Chow) 72b62ed Merge bitcoin#23834: wallettool: Check that the dumpfile checksum is the correct size (laanwj) ee9b3cd Merge bitcoin#23979: test: wait for rather than assert presence of file in startupnotify test (MarcoFalke) 2ec5940 Merge bitcoin#23532: test: add functional test for -startupnotify (MarcoFalke) 5a31be9 Merge bitcoin#23812: test: fix intermittent failures in p2p_timeouts.py (MarcoFalke) 10828f5 Merge bitcoin#23733: fuzz: Move ISO8601 to one place (MarcoFalke) 7f39b5a Merge bitcoin#23635: test: Bump shellcheck version to 0.8.0 (fanquake) Pull request description: ## Issue being fixed or feature implemented Trivial batch of backports ## What was done? trivial backports ## How Has This Been Tested? Unit tests ran; waiting on CI ## Breaking Changes ## Checklist: _Go over all the following points, and put an `x` in all the boxes that apply._ - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [ ] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ Top commit has no ACKs. Tree-SHA512: a3f97003e6441468951b827b2c3ea607740e5b9d36b96c2f93e45e7fb4088ecf4d0a2b7038de050ca0e7d61379c364969f4a8caff98ec1cc69016f4114e64c6a
2 parents d441cda + 76279c1 commit d7413ff

37 files changed

+268
-118
lines changed

ci/lint/04_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ ${CI_RETRY_EXE} pip3 install vulture==2.3
1717
${CI_RETRY_EXE} pip3 install yq
1818
${CI_RETRY_EXE} pip3 install mypy==0.781
1919

20-
SHELLCHECK_VERSION=v0.7.2
20+
SHELLCHECK_VERSION=v0.8.0
2121
curl -sL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | tar --xz -xf - --directory /tmp/
2222
export PATH="/tmp/shellcheck-${SHELLCHECK_VERSION}:${PATH}"

contrib/guix/guix-clean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ check_tools cat mkdir make git guix
3434
#
3535
under_dir() {
3636
local path_residue
37-
path_residue="${2##${1}}"
37+
path_residue="${2##"${1}"}"
3838
if [ -z "$path_residue" ] || [ "$path_residue" = "$2" ]; then
3939
return 1
4040
else

doc/tor.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ outgoing connections, but more is possible.
3535
-onion=ip:port Set the proxy server to use for Tor onion services. You do not
3636
need to set this if it's the same as -proxy. You can use -onion=0
3737
to explicitly disable access to onion services.
38+
------------------------------------------------------------------
3839
Note: Only the -proxy option sets the proxy for DNS requests;
3940
with -onion they will not route over Tor, so use -proxy if you
4041
have privacy concerns.
42+
------------------------------------------------------------------
4143

4244
-listen When using -proxy, listening is disabled by default. If you want
4345
to manually configure an onion service (see section 3), you'll

src/addrdb.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ bool SerializeFileDB(const std::string& prefix, const fs::path& path, const Data
4242
{
4343
// Generate random temporary filename
4444
uint16_t randv = 0;
45-
GetRandBytes((unsigned char*)&randv, sizeof(randv));
45+
GetRandBytes({(unsigned char*)&randv, sizeof(randv)});
4646
std::string tmpfn = strprintf("%s.%04x", prefix, randv);
4747

4848
// open temp output file, and associate with CAutoFile

src/banman.cpp

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@
1616
BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t default_ban_time)
1717
: m_client_interface(client_interface), m_ban_db(std::move(ban_file)), m_default_ban_time(default_ban_time)
1818
{
19+
LoadBanlist();
20+
DumpBanlist();
21+
}
22+
23+
BanMan::~BanMan()
24+
{
25+
DumpBanlist();
26+
}
27+
28+
void BanMan::LoadBanlist()
29+
{
30+
LOCK(m_cs_banned);
31+
1932
if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist…").translated);
2033

2134
int64_t n_start = GetTimeMillis();
@@ -29,13 +42,6 @@ BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t
2942
m_banned = {};
3043
m_is_dirty = true;
3144
}
32-
33-
DumpBanlist();
34-
}
35-
36-
BanMan::~BanMan()
37-
{
38-
DumpBanlist();
3945
}
4046

4147
void BanMan::DumpBanlist()
@@ -183,23 +189,24 @@ void BanMan::GetBanned(banmap_t& banmap)
183189

184190
void BanMan::SweepBanned()
185191
{
192+
AssertLockHeld(m_cs_banned);
193+
186194
int64_t now = GetTime();
187195
bool notify_ui = false;
188-
{
189-
LOCK(m_cs_banned);
190-
banmap_t::iterator it = m_banned.begin();
191-
while (it != m_banned.end()) {
192-
CSubNet sub_net = (*it).first;
193-
CBanEntry ban_entry = (*it).second;
194-
if (!sub_net.IsValid() || now > ban_entry.nBanUntil) {
195-
m_banned.erase(it++);
196-
m_is_dirty = true;
197-
notify_ui = true;
198-
LogPrint(BCLog::NET, "Removed banned node address/subnet: %s\n", sub_net.ToString());
199-
} else
200-
++it;
196+
banmap_t::iterator it = m_banned.begin();
197+
while (it != m_banned.end()) {
198+
CSubNet sub_net = (*it).first;
199+
CBanEntry ban_entry = (*it).second;
200+
if (!sub_net.IsValid() || now > ban_entry.nBanUntil) {
201+
m_banned.erase(it++);
202+
m_is_dirty = true;
203+
notify_ui = true;
204+
LogPrint(BCLog::NET, "Removed banned node address/subnet: %s\n", sub_net.ToString());
205+
} else {
206+
++it;
201207
}
202208
}
209+
203210
// update UI
204211
if (notify_ui && m_client_interface) {
205212
m_client_interface->BannedListChanged();

src/banman.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ class BanMan
8181
void DumpBanlist();
8282

8383
private:
84+
void LoadBanlist() EXCLUSIVE_LOCKS_REQUIRED(!m_cs_banned);
8485
bool BannedSetIsDirty();
8586
//!set the "dirty" flag for the banlist
8687
void SetBannedSetDirty(bool dirty = true);
8788
//!clean unused entries (if bantime has expired)
88-
void SweepBanned();
89+
void SweepBanned() EXCLUSIVE_LOCKS_REQUIRED(m_cs_banned);
8990

9091
RecursiveMutex m_cs_banned;
9192
banmap_t m_banned GUARDED_BY(m_cs_banned);

src/bitcoin-cli.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,9 @@ static void ParseGetInfoResult(UniValue& result)
10481048
result_string += "\n";
10491049
}
10501050

1051-
result_string += strprintf("%sWarnings:%s %s", YELLOW, RESET, result["warnings"].getValStr());
1051+
const std::string warnings{result["warnings"].getValStr()};
1052+
result_string += strprintf("%sWarnings:%s %s", YELLOW, RESET, warnings.empty() ? "(none)" : warnings);
1053+
10521054
result.setStr(result_string);
10531055
}
10541056

src/bls/bls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void CBLSSecretKey::MakeNewKey()
6363
{
6464
unsigned char buf[SerSize];
6565
while (true) {
66-
GetStrongRandBytes(buf, sizeof(buf));
66+
GetStrongRandBytes({buf, sizeof(buf)});
6767
try {
6868
impl = bls::PrivateKey::FromBytes(bls::Bytes(reinterpret_cast<const uint8_t*>(buf), SerSize));
6969
break;

src/bls/bls_ies.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void CBLSIESMultiRecipientBlobs::InitEncrypt(size_t count)
9797
{
9898
ephemeralSecretKey.MakeNewKey();
9999
ephemeralPubKey = ephemeralSecretKey.GetPublicKey();
100-
GetStrongRandBytes(ivSeed.begin(), ivSeed.size());
100+
GetStrongRandBytes({ivSeed.begin(), ivSeed.size()});
101101

102102
uint256 iv = ivSeed;
103103
ivVector.resize(count);

src/dbwrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ const unsigned int CDBWrapper::OBFUSCATE_KEY_NUM_BYTES = 8;
224224
std::vector<unsigned char> CDBWrapper::CreateObfuscateKey() const
225225
{
226226
std::vector<uint8_t> ret(OBFUSCATE_KEY_NUM_BYTES);
227-
GetRandBytes(ret.data(), OBFUSCATE_KEY_NUM_BYTES);
227+
GetRandBytes(ret);
228228
return ret;
229229
}
230230

0 commit comments

Comments
 (0)