1
1
//! The module contains implementations of the 'ArtifactClient' trait for all
2
2
//! P2P clients that require consensus over their artifacts.
3
3
4
- use ic_constants:: { MAX_INGRESS_TTL , PERMITTED_DRIFT_AT_ARTIFACT_MANAGER } ;
5
4
use ic_interfaces:: {
6
5
artifact_manager:: ArtifactClient ,
7
6
artifact_pool:: {
8
7
ArtifactPoolError , PriorityFnAndFilterProducer , ReplicaVersionMismatch , ValidatedPoolReader ,
9
8
} ,
10
- time_source:: TimeSource ,
11
9
} ;
12
- use ic_logger:: { debug, ReplicaLogger } ;
13
10
use ic_types:: {
14
11
artifact:: * ,
15
12
artifact_kind:: * ,
@@ -123,35 +120,24 @@ impl<
123
120
124
121
/// The ingress `ArtifactClient` to be managed by the `ArtifactManager`.
125
122
pub struct IngressClient < Pool , T > {
126
- /// The time source.
127
- time_source : Arc < dyn TimeSource > ,
128
123
/// The ingress pool, protected by a read-write lock and automatic reference
129
124
/// counting.
130
125
pool : Arc < RwLock < Pool > > ,
131
-
132
- /// The logger.
133
- log : ReplicaLogger ,
134
-
135
126
priority_fn_and_filter : T ,
136
-
137
127
#[ allow( dead_code) ]
138
128
malicious_flags : MaliciousFlags ,
139
129
}
140
130
141
131
impl < Pool , T > IngressClient < Pool , T > {
142
132
/// The constructor creates an `IngressClient` instance.
143
133
pub fn new (
144
- time_source : Arc < dyn TimeSource > ,
145
134
pool : Arc < RwLock < Pool > > ,
146
135
priority_fn_and_filter : T ,
147
- log : ReplicaLogger ,
148
136
malicious_flags : MaliciousFlags ,
149
137
) -> Self {
150
138
Self {
151
- time_source,
152
139
pool,
153
140
priority_fn_and_filter,
154
- log,
155
141
malicious_flags,
156
142
}
157
143
}
@@ -162,46 +148,6 @@ impl<
162
148
T : PriorityFnAndFilterProducer < IngressArtifact , Pool > + ' static ,
163
149
> ArtifactClient < IngressArtifact > for IngressClient < Pool , T >
164
150
{
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
-
205
151
/// The method checks if the ingress pool contains an ingress message with
206
152
/// the given ID.
207
153
fn has_artifact ( & self , msg_id : & IngressMessageId ) -> bool {
0 commit comments