diff --git a/src/protocol.h b/src/protocol.h index 8b0c25db42..c2eb3a2247 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -408,7 +408,13 @@ public: READWRITE(nVersion); } if ((s.GetType() & SER_DISK) || - (nVersion >= CADDR_TIME_VERSION && !(s.GetType() & SER_GETHASH))) { + (nVersion != INIT_PROTO_VERSION && !(s.GetType() & SER_GETHASH))) { + // The only time we serialize a CAddress object without nTime is in + // the initial VERSION messages which contain two CAddress records. + // At that point, the serialization version is INIT_PROTO_VERSION. + // After the version handshake, serialization version is >= + // MIN_PEER_PROTO_VERSION and all ADDR messages are serialized with + // nTime. READWRITE(obj.nTime); } if (nVersion & ADDRV2_FORMAT) { diff --git a/src/version.h b/src/version.h index 456b44d784..c8aa41bf0e 100644 --- a/src/version.h +++ b/src/version.h @@ -22,10 +22,6 @@ static const int MIN_PEER_PROTO_VERSION = 70215; //! minimum proto version of masternode to accept in DKGs static const int MIN_MASTERNODE_PROTO_VERSION = 70221; -//! nTime field added to CAddress, starting with this version; -//! if possible, avoid requesting addresses nodes older than this -static const int CADDR_TIME_VERSION = 31402; - //! protocol version is included in MNAUTH starting with this version static const int MNAUTH_NODE_VER_VERSION = 70218; diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index b4c12ac655..a878f95a50 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -255,7 +255,7 @@ class CAddress: self.ip = "0.0.0.0" self.port = 0 - def deserialize(self, f, with_time=True): + def deserialize(self, f, *, with_time=True): """Deserialize from addrv1 format (pre-BIP155)""" if with_time: # VERSION messages serialize CAddress objects without time @@ -267,7 +267,7 @@ class CAddress: self.ip = socket.inet_ntoa(f.read(4)) self.port = struct.unpack(">H", f.read(2))[0] - def serialize(self, with_time=True): + def serialize(self, *, with_time=True): """Serialize in addrv1 format (pre-BIP155)""" assert self.net == self.NET_IPV4 r = b"" @@ -1371,10 +1371,10 @@ class msg_version: self.nServices = struct.unpack("