Skip to content

Commit 4b0e555

Browse files
rumenovadamspofford-dfinity
authored andcommitted
fix: decrease the ingress expiry default to 3 min (#601)
1 parent 16c068d commit 4b0e555

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## Unreleased
1010

11+
* Make ingress_expiry required and set the default value to 3 min.
1112
* Changed `BasicIdentity`'s implmentation from `ring` to `ed25519-consensus`.
1213
* Added `AgentBuilder::with_max_polling_time` to config the maximum time to wait for a response from the replica.
1314
* `DelegatedIdentity::new` now checks the delegation chain. The old behavior is available under `new_unchecked`.

ic-agent/src/agent/agent_config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct AgentConfig {
1616
/// See [`with_identity`](super::AgentBuilder::with_identity).
1717
pub identity: Arc<dyn Identity>,
1818
/// See [`with_ingress_expiry`](super::AgentBuilder::with_ingress_expiry).
19-
pub ingress_expiry: Option<Duration>,
19+
pub ingress_expiry: Duration,
2020
/// See [`with_http_client`](super::AgentBuilder::with_http_client).
2121
pub client: Option<Client>,
2222
/// See [`with_route_provider`](super::AgentBuilder::with_route_provider).
@@ -40,7 +40,7 @@ impl Default for AgentConfig {
4040
Self {
4141
nonce_factory: Arc::new(NonceFactory::random()),
4242
identity: Arc::new(AnonymousIdentity {}),
43-
ingress_expiry: None,
43+
ingress_expiry: Duration::from_secs(3 * 60),
4444
client: None,
4545
http_service: None,
4646
verify_query_signatures: true,

ic-agent/src/agent/agent_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ fn make_untimed_agent(url: &str) -> Agent {
3737
Agent::builder()
3838
.with_url(url)
3939
.with_verify_query_signatures(false)
40-
.with_ingress_expiry(Some(Duration::from_secs(u32::MAX as _)))
40+
.with_ingress_expiry(Duration::from_secs(u32::MAX as _))
4141
.build()
4242
.unwrap()
4343
}
4444

4545
fn make_certifying_agent(url: &str) -> Agent {
4646
Agent::builder()
4747
.with_url(url)
48-
.with_ingress_expiry(Some(Duration::from_secs(u32::MAX as _)))
48+
.with_ingress_expiry(Duration::from_secs(u32::MAX as _))
4949
.build()
5050
.unwrap()
5151
}

ic-agent/src/agent/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ impl AgentBuilder {
7373
/// The timestamp corresponding to this duration may be rounded in order to reduce
7474
/// cache misses. The current implementation rounds to the nearest minute if the
7575
/// expiry is more than a minute, but this is not guaranteed.
76-
pub fn with_ingress_expiry(mut self, ingress_expiry: Option<std::time::Duration>) -> Self {
76+
pub fn with_ingress_expiry(mut self, ingress_expiry: std::time::Duration) -> Self {
7777
self.config.ingress_expiry = ingress_expiry;
7878
self
7979
}

ic-agent/src/agent/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl Agent {
177177
Ok(Agent {
178178
nonce_factory: config.nonce_factory,
179179
identity: config.identity,
180-
ingress_expiry: config.ingress_expiry.unwrap_or(DEFAULT_INGRESS_EXPIRY),
180+
ingress_expiry: config.ingress_expiry,
181181
root_key: Arc::new(RwLock::new(IC_ROOT_KEY.to_vec())),
182182
client: config.http_service.unwrap_or_else(|| {
183183
Arc::new(Retry429Logic {
@@ -1189,8 +1189,6 @@ impl Agent {
11891189
}
11901190
}
11911191

1192-
const DEFAULT_INGRESS_EXPIRY: Duration = Duration::from_secs(240);
1193-
11941192
// Checks if a principal is contained within a list of principal ranges
11951193
// A range is a tuple: (low: Principal, high: Principal), as described here: https://internetcomputer.org/docs/current/references/ic-interface-spec#state-tree-subnet
11961194
fn principal_is_within_ranges(principal: &Principal, ranges: &[(Principal, Principal)]) -> bool {

0 commit comments

Comments
 (0)