Skip to content

Commit 2e85b1f

Browse files
committed
chore: remove the expiry check in the artifact manager
1 parent 467b9f2 commit 2e85b1f

File tree

4 files changed

+0
-73
lines changed

4 files changed

+0
-73
lines changed

rs/artifact_manager/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ use ic_interfaces::{
113113
ingress_pool::ChangeSet as IngressChangeSet,
114114
time_source::{SysTimeSource, TimeSource},
115115
};
116-
use ic_logger::ReplicaLogger;
117116
use ic_metrics::MetricsRegistry;
118117
use ic_types::{artifact::*, artifact_kind::*, malicious_flags::MaliciousFlags};
119118
use prometheus::{histogram_opts, labels, Histogram};
@@ -319,7 +318,6 @@ pub fn create_ingress_handlers<
319318
ingress_handler: Arc<
320319
dyn ChangeSetProducer<PoolIngress, ChangeSet = IngressChangeSet> + Send + Sync,
321320
>,
322-
log: ReplicaLogger,
323321
metrics_registry: MetricsRegistry,
324322
malicious_flags: MaliciousFlags,
325323
) -> (ArtifactClientHandle<IngressArtifact>, Box<dyn JoinGuard>) {
@@ -335,10 +333,8 @@ pub fn create_ingress_handlers<
335333
ArtifactClientHandle::<IngressArtifact> {
336334
sender,
337335
pool_reader: Box::new(pool_readers::IngressClient::new(
338-
time_source.clone(),
339336
ingress_pool,
340337
priority_fn_and_filter_producer,
341-
log,
342338
malicious_flags,
343339
)),
344340
time_source,

rs/artifact_manager/src/pool_readers.rs

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
//! The module contains implementations of the 'ArtifactClient' trait for all
22
//! P2P clients that require consensus over their artifacts.
33
4-
use ic_constants::{MAX_INGRESS_TTL, PERMITTED_DRIFT_AT_ARTIFACT_MANAGER};
54
use ic_interfaces::{
65
artifact_manager::ArtifactClient,
76
artifact_pool::{
87
ArtifactPoolError, PriorityFnAndFilterProducer, ReplicaVersionMismatch, ValidatedPoolReader,
98
},
10-
time_source::TimeSource,
119
};
12-
use ic_logger::{debug, ReplicaLogger};
1310
use ic_types::{
1411
artifact::*,
1512
artifact_kind::*,
@@ -123,35 +120,24 @@ impl<
123120

124121
/// The ingress `ArtifactClient` to be managed by the `ArtifactManager`.
125122
pub struct IngressClient<Pool, T> {
126-
/// The time source.
127-
time_source: Arc<dyn TimeSource>,
128123
/// The ingress pool, protected by a read-write lock and automatic reference
129124
/// counting.
130125
pool: Arc<RwLock<Pool>>,
131-
132-
/// The logger.
133-
log: ReplicaLogger,
134-
135126
priority_fn_and_filter: T,
136-
137127
#[allow(dead_code)]
138128
malicious_flags: MaliciousFlags,
139129
}
140130

141131
impl<Pool, T> IngressClient<Pool, T> {
142132
/// The constructor creates an `IngressClient` instance.
143133
pub fn new(
144-
time_source: Arc<dyn TimeSource>,
145134
pool: Arc<RwLock<Pool>>,
146135
priority_fn_and_filter: T,
147-
log: ReplicaLogger,
148136
malicious_flags: MaliciousFlags,
149137
) -> Self {
150138
Self {
151-
time_source,
152139
pool,
153140
priority_fn_and_filter,
154-
log,
155141
malicious_flags,
156142
}
157143
}
@@ -162,46 +148,6 @@ impl<
162148
T: PriorityFnAndFilterProducer<IngressArtifact, Pool> + 'static,
163149
> ArtifactClient<IngressArtifact> for IngressClient<Pool, T>
164150
{
165-
/// The method checks whether the given signed ingress bytes constitutes a
166-
/// valid singed ingress message.
167-
///
168-
/// To this end, the method converts the signed bytes into a `SignedIngress`
169-
/// message (if possible) and verifies that the message expiry time is
170-
/// neither in the past nor too far in the future.
171-
fn check_artifact_acceptance(&self, msg: &SignedIngress) -> Result<(), ArtifactPoolError> {
172-
#[cfg(feature = "malicious_code")]
173-
{
174-
if self.malicious_flags.maliciously_disable_ingress_validation {
175-
return Ok(());
176-
}
177-
}
178-
179-
let time_now = self.time_source.get_relative_time();
180-
// We account for a bit of drift here and accept messages with a bit longer
181-
// than `MAX_INGRESS_TTL` time-to-live into the ingress pool.
182-
// The purpose is to be a bit more permissive than the HTTP handler when the
183-
// ingress was first accepted because here the ingress may have come
184-
// from the network.
185-
let time_plus_ttl = time_now + MAX_INGRESS_TTL + PERMITTED_DRIFT_AT_ARTIFACT_MANAGER;
186-
let msg_expiry_time = msg.expiry_time();
187-
if msg_expiry_time < time_now {
188-
Err(ArtifactPoolError::MessageExpired)
189-
} else if msg_expiry_time > time_plus_ttl {
190-
debug!(
191-
self.log,
192-
"check_artifact_acceptance";
193-
ingress_message.message_id => format!("{}", msg.id()),
194-
ingress_message.reason => "message_expiry_too_far_in_future",
195-
ingress_message.expiry_time => Some(msg_expiry_time.as_nanos_since_unix_epoch()),
196-
ingress_message.batch_time => Some(time_now.as_nanos_since_unix_epoch()),
197-
ingress_message.batch_time_plus_ttl => Some(time_plus_ttl.as_nanos_since_unix_epoch())
198-
);
199-
Err(ArtifactPoolError::MessageExpiryTooLong)
200-
} else {
201-
Ok(())
202-
}
203-
}
204-
205151
/// The method checks if the ingress pool contains an ingress message with
206152
/// the given ID.
207153
fn has_artifact(&self, msg_id: &IngressMessageId) -> bool {

rs/constants/src/lib.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,6 @@ pub const PERMITTED_DRIFT: Duration = Duration::from_secs(60);
2020
/// of rejecting them right away.
2121
pub const PERMITTED_DRIFT_AT_VALIDATOR: Duration = Duration::from_secs(30);
2222

23-
/// Duration added to `MAX_INGRESS_TTL` when checking the max allowed expiry
24-
/// at the artifact manager when it receives ingress from http_handler or p2p.
25-
/// The purpose is to account for time drift between subnet nodes.
26-
///
27-
/// Together with `PERMITTED_DRIFT_AT_VALIDATOR` we give some leeway to
28-
/// accommodate possible time drift both between the user client and a subnet
29-
/// node, and between subnet nodes.
30-
///
31-
/// Note that when a blockmaker creates a payload, it will only choose from
32-
/// its ingress pool based on MAX_INGRESS_TTL. So time drift considerations
33-
/// may lead to more messages being admitted to the ingress pool, but
34-
/// shouldn't impact other parts of the system.
35-
pub const PERMITTED_DRIFT_AT_ARTIFACT_MANAGER: Duration = Duration::from_secs(60);
36-
3723
/// The maximum number of messages that can be present in the ingress history
3824
/// at any one time.
3925
///

rs/replica/setup_ic_network/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ fn setup_artifact_manager(
399399
Arc::clone(&artifact_pools.ingress_pool),
400400
ingress_prioritizer,
401401
ingress_manager,
402-
replica_logger.clone(),
403402
metrics_registry.clone(),
404403
malicious_flags.clone(),
405404
);

0 commit comments

Comments
 (0)