mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 20:42:59 +01:00
Merge #11512: Use GetDesireableServiceFlags in seeds, dnsseeds, fixing static seed adding
2b839ab
Update chainparams comment for more info on service bits per dnsseed (Matt Corallo)62e7642
Fall back to oneshot for DNS Seeds which don't support filtering. (Matt Corallo)51ae766
Use GetDesireableServiceFlags in static seeds, document this. (Matt Corallo)fb6f6b1
bluematt's testnet-seed now supports x9 (and is just a static list) (Matt Corallo) Pull request description:4440710
broke inserting entries into addrman from dnsseeds which did not support service bits, as well as static seeds. Static seeds were already being filtered by UA for 0.13.1+ (ie NODE_WITNESS), so simply changing the default service bits to include NODE_WITNESS (and updating docs appropriately) is sufficient. For DNS Seeds, not supporting NODE_WITNESS is no longer useful, so instead use non-filtering seeds as oneshot hosts irrespective of named proxy. I've set my testnet-seed to also support x9, though because it is simply a static host, it may be useful to leave the support off so that it is used as a oneshot to get addresses from a live node instead. I'm fine with either. Tree-SHA512: 3f17d4d2b0b84d876981c962d2b44cb0c8f95f52c56a48c6b35fd882f6d7a40805f320ec452985a1c0b34aebddb1922709156c3ceccd1b9f8363fd7cb537d21d
This commit is contained in:
parent
88197c7414
commit
94e99441c5
@ -331,8 +331,13 @@ public:
|
|||||||
assert(consensus.hashGenesisBlock == uint256S("0x00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6"));
|
assert(consensus.hashGenesisBlock == uint256S("0x00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6"));
|
||||||
assert(genesis.hashMerkleRoot == uint256S("0xe0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7"));
|
assert(genesis.hashMerkleRoot == uint256S("0xe0028eb9648db56b1ac77cf090b99048a8007e2bb64b68f092c03c7f56a662c7"));
|
||||||
|
|
||||||
vSeeds.emplace_back("dnsseed.dash.org", true);
|
// Note that of those which support the service bits prefix, most only support a subset of
|
||||||
vSeeds.emplace_back("dnsseed.dashdot.io", true);
|
// possible options.
|
||||||
|
// This is fine at runtime as we'll fall back to using them as a oneshot if they dont support the
|
||||||
|
// service bits we want, but we should get them updated to support all service bits wanted by any
|
||||||
|
// release ASAP to avoid it where possible.
|
||||||
|
vSeeds.emplace_back("dnsseed.dash.org");
|
||||||
|
vSeeds.emplace_back("dnsseed.dashdot.io");
|
||||||
|
|
||||||
// Dash addresses start with 'X'
|
// Dash addresses start with 'X'
|
||||||
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,76);
|
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,76);
|
||||||
@ -510,7 +515,7 @@ public:
|
|||||||
|
|
||||||
vSeeds.clear();
|
vSeeds.clear();
|
||||||
// nodes with support for servicebits filtering should be at the top
|
// nodes with support for servicebits filtering should be at the top
|
||||||
vSeeds.emplace_back("testnet-seed.dashdot.io", true);
|
vSeeds.emplace_back("testnet-seed.dashdot.io"); // Just a static list of stable node(s), only supports x9
|
||||||
|
|
||||||
// Testnet Dash addresses start with 'y'
|
// Testnet Dash addresses start with 'y'
|
||||||
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,140);
|
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,140);
|
||||||
|
@ -14,12 +14,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct CDNSSeedData {
|
|
||||||
std::string host;
|
|
||||||
bool supportsServiceBitsFiltering;
|
|
||||||
CDNSSeedData(const std::string &strHost, bool supportsServiceBitsFilteringIn) : host(strHost), supportsServiceBitsFiltering(supportsServiceBitsFilteringIn) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SeedSpec6 {
|
struct SeedSpec6 {
|
||||||
uint8_t addr[16];
|
uint8_t addr[16];
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
@ -78,7 +72,8 @@ public:
|
|||||||
bool AllowMultiplePorts() const { return fAllowMultiplePorts; }
|
bool AllowMultiplePorts() const { return fAllowMultiplePorts; }
|
||||||
/** Return the BIP70 network string (main, test or regtest) */
|
/** Return the BIP70 network string (main, test or regtest) */
|
||||||
std::string NetworkIDString() const { return strNetworkID; }
|
std::string NetworkIDString() const { return strNetworkID; }
|
||||||
const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
|
/** Return the list of hostnames to look up for DNS seeds */
|
||||||
|
const std::vector<std::string>& DNSSeeds() const { return vSeeds; }
|
||||||
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
|
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
|
||||||
int ExtCoinType() const { return nExtCoinType; }
|
int ExtCoinType() const { return nExtCoinType; }
|
||||||
const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
|
const std::vector<SeedSpec6>& FixedSeeds() const { return vFixedSeeds; }
|
||||||
@ -103,7 +98,7 @@ protected:
|
|||||||
CMessageHeader::MessageStartChars pchMessageStart;
|
CMessageHeader::MessageStartChars pchMessageStart;
|
||||||
int nDefaultPort;
|
int nDefaultPort;
|
||||||
uint64_t nPruneAfterHeight;
|
uint64_t nPruneAfterHeight;
|
||||||
std::vector<CDNSSeedData> vSeeds;
|
std::vector<std::string> vSeeds;
|
||||||
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
|
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
|
||||||
int nExtCoinType;
|
int nExtCoinType;
|
||||||
std::string strNetworkID;
|
std::string strNetworkID;
|
||||||
|
26
src/net.cpp
26
src/net.cpp
@ -148,7 +148,7 @@ static std::vector<CAddress> convertSeed6(const std::vector<SeedSpec6> &vSeedsIn
|
|||||||
for (const auto& seed_in : vSeedsIn) {
|
for (const auto& seed_in : vSeedsIn) {
|
||||||
struct in6_addr ip;
|
struct in6_addr ip;
|
||||||
memcpy(&ip, seed_in.addr, sizeof(ip));
|
memcpy(&ip, seed_in.addr, sizeof(ip));
|
||||||
CAddress addr(CService(ip, seed_in.port), NODE_NETWORK);
|
CAddress addr(CService(ip, seed_in.port), GetDesirableServiceFlags(NODE_NONE));
|
||||||
addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
|
addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
|
||||||
vSeedsOut.push_back(addr);
|
vSeedsOut.push_back(addr);
|
||||||
}
|
}
|
||||||
@ -1723,18 +1723,6 @@ void MapPort(bool)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static std::string GetDNSHost(const CDNSSeedData& data, ServiceFlags* requiredServiceBits)
|
|
||||||
{
|
|
||||||
//use default host for non-filter-capable seeds or if we use the default service bits (NODE_NETWORK)
|
|
||||||
if (!data.supportsServiceBitsFiltering || *requiredServiceBits == NODE_NETWORK) {
|
|
||||||
*requiredServiceBits = NODE_NETWORK;
|
|
||||||
return data.host;
|
|
||||||
}
|
|
||||||
|
|
||||||
return strprintf("x%x.%s", *requiredServiceBits, data.host);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CConnman::ThreadDNSAddressSeed()
|
void CConnman::ThreadDNSAddressSeed()
|
||||||
{
|
{
|
||||||
// goal: only query DNS seeds if address need is acute
|
// goal: only query DNS seeds if address need is acute
|
||||||
@ -1757,22 +1745,22 @@ void CConnman::ThreadDNSAddressSeed()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<CDNSSeedData> &vSeeds = Params().DNSSeeds();
|
const std::vector<std::string> &vSeeds = Params().DNSSeeds();
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
LogPrintf("Loading addresses from DNS seeds (could take a while)\n");
|
LogPrintf("Loading addresses from DNS seeds (could take a while)\n");
|
||||||
|
|
||||||
for (const CDNSSeedData &seed : vSeeds) {
|
for (const std::string &seed : vSeeds) {
|
||||||
if (interruptNet) {
|
if (interruptNet) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (HaveNameProxy()) {
|
if (HaveNameProxy()) {
|
||||||
AddOneShot(seed.host);
|
AddOneShot(seed);
|
||||||
} else {
|
} else {
|
||||||
std::vector<CNetAddr> vIPs;
|
std::vector<CNetAddr> vIPs;
|
||||||
std::vector<CAddress> vAdd;
|
std::vector<CAddress> vAdd;
|
||||||
ServiceFlags requiredServiceBits = GetDesirableServiceFlags(NODE_NONE);
|
ServiceFlags requiredServiceBits = GetDesirableServiceFlags(NODE_NONE);
|
||||||
std::string host = GetDNSHost(seed, &requiredServiceBits);
|
std::string host = strprintf("x%x.%s", requiredServiceBits, seed);
|
||||||
CNetAddr resolveSource;
|
CNetAddr resolveSource;
|
||||||
if (!resolveSource.SetInternal(host)) {
|
if (!resolveSource.SetInternal(host)) {
|
||||||
continue;
|
continue;
|
||||||
@ -1788,6 +1776,10 @@ void CConnman::ThreadDNSAddressSeed()
|
|||||||
found++;
|
found++;
|
||||||
}
|
}
|
||||||
addrman.Add(vAdd, resolveSource);
|
addrman.Add(vAdd, resolveSource);
|
||||||
|
} else {
|
||||||
|
// We now avoid directly using results from DNS Seeds which do not support service bit filtering,
|
||||||
|
// instead using them as a oneshot to get nodes with our desired service bits.
|
||||||
|
AddOneShot(seed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,15 @@ enum ServiceFlags : uint64_t {
|
|||||||
* unless they set NODE_NETWORK_LIMITED and we are out of IBD, in which
|
* unless they set NODE_NETWORK_LIMITED and we are out of IBD, in which
|
||||||
* case NODE_NETWORK_LIMITED suffices).
|
* case NODE_NETWORK_LIMITED suffices).
|
||||||
*
|
*
|
||||||
* Thus, generally, avoid calling with peerServices == NODE_NONE.
|
* Thus, generally, avoid calling with peerServices == NODE_NONE, unless
|
||||||
|
* state-specific flags must absolutely be avoided. When called with
|
||||||
|
* peerServices == NODE_NONE, the returned desirable service flags are
|
||||||
|
* guaranteed to not change dependant on state - ie they are suitable for
|
||||||
|
* use when describing peers which we know to be desirable, but for which
|
||||||
|
* we do not have a confirmed set of service flags.
|
||||||
|
*
|
||||||
|
* If the NODE_NONE return value is changed, contrib/seeds/makeseeds.py
|
||||||
|
* should be updated appropriately to filter for the same nodes.
|
||||||
*/
|
*/
|
||||||
static ServiceFlags GetDesirableServiceFlags(ServiceFlags services) {
|
static ServiceFlags GetDesirableServiceFlags(ServiceFlags services) {
|
||||||
return ServiceFlags(NODE_NETWORK);
|
return ServiceFlags(NODE_NETWORK);
|
||||||
|
Loading…
Reference in New Issue
Block a user