mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#22570: Ignore banlist.dat
This commit is contained in:
parent
c3b4b6746a
commit
b89963abf2
@ -56,7 +56,6 @@ Subdirectory | File(s) | Description
|
||||
`./` | `anchors.dat` | Anchor IP address database, created on shutdown and deleted at startup. Anchors are last known outgoing block-relay-only peers that are tried to re-connect to on startup
|
||||
`evodb/` | |special txes and quorums database
|
||||
`llmq/` | |quorum signatures database
|
||||
`./` | `banlist.dat` | Stores the addresses/subnets of banned nodes (deprecated). `dashd` or `dash-qt` no longer save the banlist to this file, but read it on startup if `banlist.json` is not present.
|
||||
`./` | `banlist.json` | Stores the addresses/subnets of banned nodes.
|
||||
`./` | `dash.conf` | User-defined [configuration settings](dash-conf.md) for `dashd` or `dash-qt`. File is not written to by the software and must be created manually. Path can be specified by `-conf` option
|
||||
`./` | `dashd.pid` | Stores the process ID (PID) of `dashd` or `dash-qt` while running; created at start and deleted on shutdown; can be specified by `-pid` option
|
||||
@ -116,6 +115,7 @@ These subdirectories and files are no longer used by Dash Core:
|
||||
|
||||
Path | Description | Repository notes
|
||||
---------------|-------------|-----------------
|
||||
`banlist.dat` | Stores the addresses/subnets of banned nodes; completely ignored and superseded by `banlist.json` in 20.0 | [PR #5574](https://github.com/dashpay/dash/pull/5574)
|
||||
`blktree/` | Blockchain index; replaced by `blocks/index/` in [0.8.0](https://github.com/dash/dash/blob/master/doc/release-notes/release-notes-0.8.0.md#improvements) | [PR #2231](https://github.com/dash/dash/pull/2231), [`8fdc94cc`](https://github.com/dash/dash/commit/8fdc94cc8f0341e96b1edb3a5b56811c0b20bd15)
|
||||
`coins/` | Unspent transaction output database; replaced by `chainstate/` in 0.8.0 | [PR #2231](https://github.com/dash/dash/pull/2231), [`8fdc94cc`](https://github.com/dash/dash/commit/8fdc94cc8f0341e96b1edb3a5b56811c0b20bd15)
|
||||
`blkindex.dat` | Blockchain index BDB database; replaced by {`chainstate/`, `blocks/index/`, `blocks/revNNNNN.dat`<sup>[\[2\]](#note2)</sup>} in 0.8.0 | [PR #1677](https://github.com/dash/dash/pull/1677)
|
||||
|
@ -198,16 +198,15 @@ bool CBanDB::Write(const banmap_t& banSet)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CBanDB::Read(banmap_t& banSet, bool& dirty)
|
||||
bool CBanDB::Read(banmap_t& banSet)
|
||||
{
|
||||
// If the JSON banlist does not exist, then try to read the non-upgraded banlist.dat.
|
||||
if (!fs::exists(m_banlist_json)) {
|
||||
// If this succeeds then we need to flush to disk in order to create the JSON banlist.
|
||||
dirty = true;
|
||||
return DeserializeFileDB(m_banlist_dat, banSet, CLIENT_VERSION);
|
||||
if (fs::exists(m_banlist_dat)) {
|
||||
LogPrintf("banlist.dat ignored because it can only be read by " PACKAGE_NAME " version 19.x. Remove %s to silence this warning.\n", m_banlist_dat);
|
||||
}
|
||||
// If the JSON banlist does not exist, then recreate it
|
||||
if (!fs::exists(m_banlist_json)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dirty = false;
|
||||
|
||||
std::map<std::string, util::SettingsValue> settings;
|
||||
std::vector<std::string> errors;
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
static bool Read(CAddrMan& addr, CDataStream& ssPeers);
|
||||
};
|
||||
|
||||
/** Access to the banlist databases (banlist.json and banlist.dat) */
|
||||
/** Access to the banlist database (banlist.json) */
|
||||
class CBanDB
|
||||
{
|
||||
private:
|
||||
@ -95,11 +95,9 @@ public:
|
||||
* Read the banlist from disk.
|
||||
* @param[out] banSet The loaded list. Set if `true` is returned, otherwise it is left
|
||||
* in an undefined state.
|
||||
* @param[out] dirty Indicates whether the loaded list needs flushing to disk. Set if
|
||||
* `true` is returned, otherwise it is left in an undefined state.
|
||||
* @return true on success
|
||||
*/
|
||||
bool Read(banmap_t& banSet, bool& dirty);
|
||||
bool Read(banmap_t& banSet);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,7 @@ BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t
|
||||
if (m_client_interface) m_client_interface->InitMessage(_("Loading banlist...").translated);
|
||||
|
||||
int64_t n_start = GetTimeMillis();
|
||||
if (m_ban_db.Read(m_banned, m_is_dirty)) {
|
||||
if (m_ban_db.Read(m_banned)) {
|
||||
SweepBanned(); // sweep out unused entries
|
||||
|
||||
LogPrint(BCLog::NET, "Loaded %d banned node addresses/subnets %dms\n", m_banned.size(),
|
||||
|
@ -89,7 +89,7 @@ private:
|
||||
|
||||
RecursiveMutex m_cs_banned;
|
||||
banmap_t m_banned GUARDED_BY(m_cs_banned);
|
||||
bool m_is_dirty GUARDED_BY(m_cs_banned);
|
||||
bool m_is_dirty GUARDED_BY(m_cs_banned){false};
|
||||
CClientUIInterface* m_client_interface = nullptr;
|
||||
CBanDB m_ban_db;
|
||||
const int64_t m_default_ban_time;
|
||||
|
@ -41,8 +41,7 @@ static constexpr int ADDRV2_FORMAT = 0x20000000;
|
||||
* over all enum values and also `GetExtNetwork()` "extends" this enum by
|
||||
* introducing standalone constants starting from `NET_MAX`.
|
||||
*/
|
||||
enum Network
|
||||
{
|
||||
enum Network {
|
||||
/// Addresses from these networks are not publicly routable on the global Internet.
|
||||
NET_UNROUTABLE = 0,
|
||||
|
||||
@ -72,16 +71,14 @@ enum Network
|
||||
/// Prefix of an IPv6 address when it contains an embedded IPv4 address.
|
||||
/// Used when (un)serializing addresses in ADDRv1 format (pre-BIP155).
|
||||
static const std::array<uint8_t, 12> IPV4_IN_IPV6_PREFIX{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF
|
||||
};
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF};
|
||||
|
||||
/// Prefix of an IPv6 address when it contains an embedded TORv2 address.
|
||||
/// Used when (un)serializing addresses in ADDRv1 format (pre-BIP155).
|
||||
/// Such dummy IPv6 addresses are guaranteed to not be publicly routable as they
|
||||
/// fall under RFC4193's fc00::/7 subnet allocated to unique-local addresses.
|
||||
static const std::array<uint8_t, 6> TORV2_IN_IPV6_PREFIX{
|
||||
0xFD, 0x87, 0xD8, 0x7E, 0xEB, 0x43
|
||||
};
|
||||
0xFD, 0x87, 0xD8, 0x7E, 0xEB, 0x43};
|
||||
|
||||
/// Prefix of an IPv6 address when it contains an embedded "internal" address.
|
||||
/// Used when (un)serializing addresses in ADDRv1 format (pre-BIP155).
|
||||
@ -216,6 +213,7 @@ class CNetAddr
|
||||
// peers in AddrMan bucketing based on the AS infrastructure.
|
||||
// The ip->AS mapping depends on how asmap is constructed.
|
||||
uint32_t GetMappedAS(const std::vector<bool> &asmap) const;
|
||||
|
||||
std::vector<unsigned char> GetGroup(const std::vector<bool> &asmap) const;
|
||||
std::vector<unsigned char> GetAddrBytes() const;
|
||||
int GetReachabilityFrom(const CNetAddr *paddrPartner = nullptr) const;
|
||||
@ -517,24 +515,6 @@ class CSubNet
|
||||
friend bool operator==(const CSubNet& a, const CSubNet& b);
|
||||
friend bool operator!=(const CSubNet& a, const CSubNet& b) { return !(a == b); }
|
||||
friend bool operator<(const CSubNet& a, const CSubNet& b);
|
||||
|
||||
SERIALIZE_METHODS(CSubNet, obj)
|
||||
{
|
||||
READWRITE(obj.network);
|
||||
if (obj.network.IsIPv4()) {
|
||||
// Before commit 102867c587f5f7954232fb8ed8e85cda78bb4d32, CSubNet used the last 4 bytes of netmask
|
||||
// to store the relevant bytes for an IPv4 mask. For compatibility reasons, keep doing so in
|
||||
// serialized form.
|
||||
unsigned char dummy[12] = {0};
|
||||
READWRITE(dummy);
|
||||
READWRITE(MakeSpan(obj.netmask).first(4));
|
||||
} else {
|
||||
READWRITE(obj.netmask);
|
||||
}
|
||||
READWRITE(obj.valid);
|
||||
// Mark invalid if the result doesn't pass sanity checking.
|
||||
SER_READ(obj, if (obj.valid) obj.valid = obj.SanityCheck());
|
||||
}
|
||||
};
|
||||
|
||||
/** A combination of a network address (CNetAddr) and a (TCP) port */
|
||||
|
@ -43,8 +43,7 @@ FUZZ_TARGET_INIT(banman, initialize_banman)
|
||||
|
||||
const bool start_with_corrupted_banlist{fuzzed_data_provider.ConsumeBool()};
|
||||
if (start_with_corrupted_banlist) {
|
||||
const std::string sfx{fuzzed_data_provider.ConsumeBool() ? ".dat" : ".json"};
|
||||
assert(WriteBinaryFile(banlist_file.string() + sfx,
|
||||
assert(WriteBinaryFile(banlist_file.string() + ".json",
|
||||
fuzzed_data_provider.ConsumeRandomLengthString()));
|
||||
} else {
|
||||
const bool force_read_and_write_to_err{fuzzed_data_provider.ConsumeBool()};
|
||||
@ -93,6 +92,5 @@ FUZZ_TARGET_INIT(banman, initialize_banman)
|
||||
});
|
||||
}
|
||||
}
|
||||
fs::remove(banlist_file.string() + ".dat");
|
||||
fs::remove(banlist_file.string() + ".json");
|
||||
}
|
||||
|
@ -143,17 +143,6 @@ FUZZ_TARGET_DESERIALIZE(script_deserialize, {
|
||||
CScript script;
|
||||
DeserializeFromFuzzingInput(buffer, script);
|
||||
})
|
||||
FUZZ_TARGET_DESERIALIZE(subnet_deserialize, {
|
||||
CSubNet sub_net_1;
|
||||
DeserializeFromFuzzingInput(buffer, sub_net_1, INIT_PROTO_VERSION);
|
||||
AssertEqualAfterSerializeDeserialize(sub_net_1, INIT_PROTO_VERSION);
|
||||
CSubNet sub_net_2;
|
||||
DeserializeFromFuzzingInput(buffer, sub_net_2, INIT_PROTO_VERSION | ADDRV2_FORMAT);
|
||||
AssertEqualAfterSerializeDeserialize(sub_net_2, INIT_PROTO_VERSION | ADDRV2_FORMAT);
|
||||
CSubNet sub_net_3;
|
||||
DeserializeFromFuzzingInput(buffer, sub_net_3);
|
||||
AssertEqualAfterSerializeDeserialize(sub_net_3, INIT_PROTO_VERSION | ADDRV2_FORMAT);
|
||||
})
|
||||
FUZZ_TARGET_DESERIALIZE(tx_in_deserialize, {
|
||||
CTxIn tx_in;
|
||||
DeserializeFromFuzzingInput(buffer, tx_in);
|
||||
|
Loading…
Reference in New Issue
Block a user