Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump protocol and disconnect peers not updated within 50 blocks of su… #416

Merged
merged 1 commit into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ class CMainParams : public CChainParams {
nLastPOWBlock = 2000000;
nHeightSupplyCreationStop = 9816000; //Should create very close to 300m coins at this time
nTimeEnforceWeightReduction = 1548619029; //Stake weight must be reduced for higher denominations
nHeightProtocolBumpEnforcement = 86350; // 50 blocks before superblock

/** RingCT/Stealth **/
nDefaultRingSize = 11;
Expand Down
2 changes: 2 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class CChainParams
int HeightSupplyCreationStop() const { return nHeightSupplyCreationStop; }
int ProofOfFullNodeRounds() const {return nProofOfFullNodeRounds; }
int EnforceWeightReductionTime() const { return nTimeEnforceWeightReduction; }
int HeightProtocolBumpEnforcement() const { return nHeightProtocolBumpEnforcement; }
int MaxHeaderRequestWithoutPoW() const { return nMaxHeaderRequestWithoutPoW; }

protected:
Expand Down Expand Up @@ -187,6 +188,7 @@ class CChainParams

//Time and height enforcements
int nTimeEnforceWeightReduction;
int nHeightProtocolBumpEnforcement; // the height a new protobump is enforced

//Settings that are not chain critical, but should not be edited unless the person changing understands the consequence
int nMaxHeaderRequestWithoutPoW;
Expand Down
16 changes: 15 additions & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,10 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
return false;
}

int nMinPeerVersion = MIN_PEER_PROTO_VERSION;
int nMinPeerVersion = MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT;
if (chainActive.Height() > Params().HeightProtocolBumpEnforcement()) {
nMinPeerVersion = MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;
}
if (Params().NetworkIDString() == "test")
nMinPeerVersion = MIN_PEER_PROTO_VERSION_TESTNET;
if (nVersion < nMinPeerVersion)
Expand Down Expand Up @@ -2125,6 +2128,17 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
return false;
}

if (chainActive.Height() > Params().HeightProtocolBumpEnforcement() && pfrom->nVersion < MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT) {
// disconnect from peers older than this proto version
LogPrint(BCLog::NET, "peer=%d using obsolete version %i; disconnecting\n", pfrom->GetId(), pfrom->nVersion);
if (enable_bip61) {
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT)));
}
pfrom->fDisconnect = true;
return false;
}

// At this point, the outgoing message serialization version can't change.
const CNetMsgMaker msgMaker(pfrom->GetSendVersion());

Expand Down
5 changes: 3 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* network protocol versioning
*/

static const int PROTOCOL_VERSION = 70022;
static const int PROTOCOL_VERSION = 70023;

//! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;
Expand All @@ -18,7 +18,8 @@ static const int INIT_PROTO_VERSION = 209;
static const int GETHEADERS_VERSION = 31800;

//! disconnect from peers older than this proto version
static const int MIN_PEER_PROTO_VERSION = 70020;
static const int MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT = 70020;
static const int MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT = 70023;
static const int MIN_PEER_PROTO_VERSION_TESTNET = 70021;

//! nTime field added to CAddress, starting with this version;
Expand Down