Skip to content

Commit 5179ba0

Browse files
Fix threshold and protocol version for v6
Co-authored-by: Michael Sutton <mikisiton2@gmail.com>
1 parent ebfb4cb commit 5179ba0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

protocol/flows/src/flow_context.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -779,11 +779,11 @@ impl ConnectionInitializer for FlowContext {
779779
debug!("protocol versions - self: {}, peer: {}", PROTOCOL_VERSION, peer_version.protocol_version);
780780

781781
// Register all flows according to version
782-
const CONNECT_ONLY_NEW_VERSIONS_THRESHOLD_MILLIS: u64 = 24 * 3600 * 3600 * 1000;
783-
let threshold = CONNECT_ONLY_NEW_VERSIONS_THRESHOLD_MILLIS / self.config.target_time_per_block().before();
782+
const CONNECT_ONLY_NEW_VERSIONS_THRESHOLD_MILLIS: u64 = 24 * 3600 * 1000; // one day in milliseconds
783+
let daa_threshold = CONNECT_ONLY_NEW_VERSIONS_THRESHOLD_MILLIS / self.config.target_time_per_block().before();
784784
let sink_daa_score = self.consensus().unguarded_session().async_get_sink_daa_score_timestamp().await.daa_score;
785-
let connect_only_new_versions = self.config.net.is_mainnet() && self.config.crescendo_activation.is_active(sink_daa_score)
786-
|| self.config.crescendo_activation.is_within_range_before_activation(sink_daa_score, threshold).is_some();
785+
let connect_only_new_versions =
786+
self.config.net.is_mainnet() && self.config.crescendo_activation.is_active(sink_daa_score + daa_threshold); // activate the protocol version constraint daa_threshold blocks ahead of time
787787

788788
let (flows, applied_protocol_version) = if connect_only_new_versions {
789789
match peer_version.protocol_version {
@@ -793,7 +793,7 @@ impl ConnectionInitializer for FlowContext {
793793
} else {
794794
match peer_version.protocol_version {
795795
v if v >= PROTOCOL_VERSION => (v7::register(self.clone(), router.clone()), PROTOCOL_VERSION),
796-
6 => (v6::register(self.clone(), router.clone()), PROTOCOL_VERSION),
796+
6 => (v6::register(self.clone(), router.clone()), 6),
797797
5 => (v5::register(self.clone(), router.clone()), 5),
798798
v => return Err(ProtocolError::VersionMismatch(PROTOCOL_VERSION, v)),
799799
}

0 commit comments

Comments
 (0)