|
1 |
| -use crate::flowcontext::{ |
2 |
| - orphans::{OrphanBlocksPool, OrphanOutput}, |
3 |
| - process_queue::ProcessQueue, |
4 |
| - transactions::TransactionsSpread, |
| 1 | +use crate::{ |
| 2 | + flowcontext::{ |
| 3 | + orphans::{OrphanBlocksPool, OrphanOutput}, |
| 4 | + process_queue::ProcessQueue, |
| 5 | + transactions::TransactionsSpread, |
| 6 | + }, |
| 7 | + v7, |
5 | 8 | };
|
6 | 9 | use crate::{v5, v6};
|
7 | 10 | use async_trait::async_trait;
|
8 | 11 | use futures::future::join_all;
|
9 | 12 | use kaspa_addressmanager::AddressManager;
|
10 | 13 | use kaspa_connectionmanager::ConnectionManager;
|
11 |
| -use kaspa_consensus_core::api::{BlockValidationFuture, BlockValidationFutures}; |
12 | 14 | use kaspa_consensus_core::block::Block;
|
13 | 15 | use kaspa_consensus_core::config::Config;
|
14 | 16 | use kaspa_consensus_core::errors::block::RuleError;
|
15 | 17 | use kaspa_consensus_core::tx::{Transaction, TransactionId};
|
| 18 | +use kaspa_consensus_core::{ |
| 19 | + api::{BlockValidationFuture, BlockValidationFutures}, |
| 20 | + network::NetworkType, |
| 21 | +}; |
16 | 22 | use kaspa_consensus_notify::{
|
17 | 23 | notification::{Notification, PruningPointUtxoSetOverrideNotification},
|
18 | 24 | root::ConsensusNotificationRoot,
|
@@ -58,8 +64,8 @@ use tokio::sync::{
|
58 | 64 | use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
|
59 | 65 | use uuid::Uuid;
|
60 | 66 |
|
61 |
| -/// The P2P protocol version. Currently the only one supported. |
62 |
| -const PROTOCOL_VERSION: u32 = 6; |
| 67 | +/// The P2P protocol version. |
| 68 | +const PROTOCOL_VERSION: u32 = 7; |
63 | 69 |
|
64 | 70 | /// See `check_orphan_resolution_range`
|
65 | 71 | const BASELINE_ORPHAN_RESOLUTION_RANGE: u32 = 5;
|
@@ -776,10 +782,24 @@ impl ConnectionInitializer for FlowContext {
|
776 | 782 | debug!("protocol versions - self: {}, peer: {}", PROTOCOL_VERSION, peer_version.protocol_version);
|
777 | 783 |
|
778 | 784 | // Register all flows according to version
|
779 |
| - let (flows, applied_protocol_version) = match peer_version.protocol_version { |
780 |
| - v if v >= PROTOCOL_VERSION => (v6::register(self.clone(), router.clone()), PROTOCOL_VERSION), |
781 |
| - 5 => (v5::register(self.clone(), router.clone()), 5), |
782 |
| - v => return Err(ProtocolError::VersionMismatch(PROTOCOL_VERSION, v)), |
| 785 | + const CONNECT_ONLY_NEW_VERSIONS_THRESHOLD_MILLIS: u64 = 24 * 3600 * 1000; // one day in milliseconds |
| 786 | + let daa_threshold = CONNECT_ONLY_NEW_VERSIONS_THRESHOLD_MILLIS / self.config.target_time_per_block().before(); |
| 787 | + let sink_daa_score = self.consensus().unguarded_session().async_get_sink_daa_score_timestamp().await.daa_score; |
| 788 | + let connect_only_new_versions = self.config.net.network_type() != NetworkType::Testnet |
| 789 | + && self.config.crescendo_activation.is_active(sink_daa_score + daa_threshold); // activate the protocol version constraint daa_threshold blocks ahead of time |
| 790 | + |
| 791 | + let (flows, applied_protocol_version) = if connect_only_new_versions { |
| 792 | + match peer_version.protocol_version { |
| 793 | + v if v >= PROTOCOL_VERSION => (v7::register(self.clone(), router.clone()), PROTOCOL_VERSION), |
| 794 | + v => return Err(ProtocolError::VersionMismatch(PROTOCOL_VERSION, v)), |
| 795 | + } |
| 796 | + } else { |
| 797 | + match peer_version.protocol_version { |
| 798 | + v if v >= PROTOCOL_VERSION => (v7::register(self.clone(), router.clone()), PROTOCOL_VERSION), |
| 799 | + 6 => (v6::register(self.clone(), router.clone()), 6), |
| 800 | + 5 => (v5::register(self.clone(), router.clone()), 5), |
| 801 | + v => return Err(ProtocolError::VersionMismatch(PROTOCOL_VERSION, v)), |
| 802 | + } |
783 | 803 | };
|
784 | 804 |
|
785 | 805 | // Build and register the peer properties
|
|
0 commit comments