Skip to content

Commit 239ce91

Browse files
Frederik Rothenbergergithub-actions[bot]
Frederik Rothenberger
andauthored
Remove legacy archive push integration (#1218)
This PR removes the old archive integration mode where II pushed entries to the archive using notify calls. * 🤖 npm run generate auto-update --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent f3fd4f8 commit 239ce91

File tree

10 files changed

+26
-489
lines changed

10 files changed

+26
-489
lines changed

src/canister_tests/src/framework.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,18 +165,14 @@ pub fn install_ii_canister_with_arg(
165165
canister_id
166166
}
167167

168-
pub fn arg_with_wasm_hash(
169-
wasm: Vec<u8>,
170-
archive_integration: Option<ArchiveIntegration>,
171-
) -> Option<InternetIdentityInit> {
168+
pub fn arg_with_wasm_hash(wasm: Vec<u8>) -> Option<InternetIdentityInit> {
172169
Some(InternetIdentityInit {
173170
assigned_user_number_range: None,
174171
archive_config: Some(ArchiveConfig {
175172
module_hash: archive_wasm_hash(&wasm),
176173
entries_buffer_limit: 10_000,
177174
polling_interval_ns: Duration::from_secs(1).as_nanos() as u64,
178175
entries_fetch_limit: 10,
179-
archive_integration,
180176
}),
181177
canister_creation_cycles_cost: Some(0),
182178
})

src/frontend/generated/internet_identity_idl.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@ export const idlFactory = ({ IDL }) => {
22
const ArchiveConfig = IDL.Record({
33
'polling_interval_ns' : IDL.Nat64,
44
'entries_buffer_limit' : IDL.Nat64,
5-
'archive_integration' : IDL.Opt(
6-
IDL.Variant({ 'pull' : IDL.Null, 'push' : IDL.Null })
7-
),
85
'module_hash' : IDL.Vec(IDL.Nat8),
96
'entries_fetch_limit' : IDL.Nat16,
107
});
118
const InternetIdentityInit = IDL.Record({
12-
'upgrade_persistent_state' : IDL.Opt(IDL.Bool),
139
'assigned_user_number_range' : IDL.Opt(IDL.Tuple(IDL.Nat64, IDL.Nat64)),
1410
'archive_config' : IDL.Opt(ArchiveConfig),
1511
'canister_creation_cycles_cost' : IDL.Opt(IDL.Nat64),
@@ -195,14 +191,10 @@ export const init = ({ IDL }) => {
195191
const ArchiveConfig = IDL.Record({
196192
'polling_interval_ns' : IDL.Nat64,
197193
'entries_buffer_limit' : IDL.Nat64,
198-
'archive_integration' : IDL.Opt(
199-
IDL.Variant({ 'pull' : IDL.Null, 'push' : IDL.Null })
200-
),
201194
'module_hash' : IDL.Vec(IDL.Nat8),
202195
'entries_fetch_limit' : IDL.Nat16,
203196
});
204197
const InternetIdentityInit = IDL.Record({
205-
'upgrade_persistent_state' : IDL.Opt(IDL.Bool),
206198
'assigned_user_number_range' : IDL.Opt(IDL.Tuple(IDL.Nat64, IDL.Nat64)),
207199
'archive_config' : IDL.Opt(ArchiveConfig),
208200
'canister_creation_cycles_cost' : IDL.Opt(IDL.Nat64),

src/frontend/generated/internet_identity_types.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export type AddTentativeDeviceResponse = {
1212
export interface ArchiveConfig {
1313
'polling_interval_ns' : bigint,
1414
'entries_buffer_limit' : bigint,
15-
'archive_integration' : [] | [{ 'pull' : null } | { 'push' : null }],
1615
'module_hash' : Array<number>,
1716
'entries_fetch_limit' : number,
1817
}
@@ -77,7 +76,6 @@ export interface IdentityAnchorInfo {
7776
'device_registration' : [] | [DeviceRegistrationInfo],
7877
}
7978
export interface InternetIdentityInit {
80-
'upgrade_persistent_state' : [] | [boolean],
8179
'assigned_user_number_range' : [] | [[bigint, bigint]],
8280
'archive_config' : [] | [ArchiveConfig],
8381
'canister_creation_cycles_cost' : [] | [bigint],

src/internet_identity/internet_identity.did

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -149,28 +149,12 @@ type ArchiveConfig = record {
149149
module_hash : blob;
150150
// Buffered archive entries limit. If reached, II will stop accepting new anchor operations
151151
// until the buffered operations are acknowledged by the archive.
152-
// Currently unused: in preparation of switching the archive integration to pull.
153-
// Configured value will be discarded for storage_layout_version < 6.
154152
entries_buffer_limit: nat64;
155153
// The maximum number of entries to be transferred to the archive per call.
156-
// Currently unused: in preparation of switching the archive integration to pull.
157-
// Configured value will be discarded for storage_layout_version < 6.
158154
entries_fetch_limit: nat16;
159155
// Polling interval to fetch new entries from II (in nanoseconds).
160156
// Changes to this parameter will only take effect after an archive deployment.
161-
// Currently unused: in preparation of switching the archive integration to pull.
162-
// Configured value will be discarded for storage_layout_version < 6.
163157
polling_interval_ns: nat64;
164-
165-
// How the entries get transferred to the archive.
166-
// This is opt, so that the config parameter can be removed after switching from push to pull.
167-
// Configured value will be discarded for storage_layout_version < 6.
168-
archive_integration: opt variant {
169-
// II pushes the entries to the archive (legacy variant).
170-
push;
171-
// The archive pulls the entries from II.
172-
pull;
173-
}
174158
};
175159

176160
// Information about the archive.
@@ -198,8 +182,6 @@ type InternetIdentityInit = record {
198182
// The canister creation cost on mainnet is currently 100'000'000'000 cycles. If this value is higher thant the
199183
// canister creation cost, the newly created canister will keep extra cycles.
200184
canister_creation_cycles_cost : opt nat64;
201-
// Config flag to upgrade the persistent state. If set to opt true it will migrate the storage layout to version 6.
202-
upgrade_persistent_state: opt bool;
203185
};
204186

205187
type ChallengeKey = text;

src/internet_identity/src/archive.rs

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ use ic_cdk::api::management_canister::main::{
88
InstallCodeArgument,
99
};
1010
use ic_cdk::api::time;
11-
use ic_cdk::{call, caller, id, notify, trap};
11+
use ic_cdk::{call, caller, id, trap};
1212
use internet_identity_interface::archive::*;
13-
use internet_identity_interface::ArchiveIntegration::Pull;
1413
use internet_identity_interface::*;
1514
use serde_bytes::ByteBuf;
1615
use sha2::Digest;
@@ -65,8 +64,6 @@ pub struct ArchiveData {
6564
// until the archive acknowledges entries and they can safely be deleted from this buffer.
6665
// The limit is configurable (entries_buffer_limit).
6766
// This is an Rc to avoid unnecessary copies of (potentially) a lot of data when cloning.
68-
// Currently unused: in preparation of switching the archive integration to pull.
69-
// Anything stored here will be discarded for storage_layout_version < 6.
7067
pub entries_buffer: Rc<Vec<BufferedEntry>>,
7168
}
7269

@@ -340,27 +337,15 @@ pub fn archive_operation(anchor_number: AnchorNumber, caller: Principal, operati
340337
};
341338
let encoded_entry = candid::encode_one(entry).expect("failed to encode archive entry");
342339

343-
// Depending on the II layout version and the config we need to either send out the entry or just buffer it.
344-
if state::storage(|s| s.version()) >= 6 && config.archive_integration == Some(Pull) {
345-
// add entry to buffer (which is emptied by the archive periodically, see fetch_entries and acknowledge entries)
346-
state::archive_data_mut(|data| {
347-
Rc::make_mut(&mut data.entries_buffer).push(BufferedEntry {
348-
anchor_number,
349-
timestamp,
350-
entry: ByteBuf::from(encoded_entry),
351-
sequence_number: data.sequence_number,
352-
});
340+
// add entry to buffer (which is emptied by the archive periodically, see fetch_entries and acknowledge entries)
341+
state::archive_data_mut(|data| {
342+
Rc::make_mut(&mut data.entries_buffer).push(BufferedEntry {
343+
anchor_number,
344+
timestamp,
345+
entry: ByteBuf::from(encoded_entry),
346+
sequence_number: data.sequence_number,
353347
});
354-
} else {
355-
// Notify can still trap if the message cannot be enqueued rolling back the anchor operation.
356-
// Therefore we only increment the sequence number after notifying successfully.
357-
let () = notify(
358-
data.archive_canister,
359-
"write_entry",
360-
(anchor_number, timestamp, encoded_entry),
361-
)
362-
.expect("failed to send archive entry notification");
363-
}
348+
});
364349

365350
state::archive_data_mut(|data| {
366351
data.sequence_number += 1;

src/internet_identity/src/storage/tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use crate::storage::{Header, PersistentStateError, StorageError};
55
use crate::Storage;
66
use candid::Principal;
77
use ic_stable_structures::{Memory, VectorMemory};
8-
use internet_identity_interface::ArchiveIntegration::Push;
98
use internet_identity_interface::{ArchiveConfig, DeviceProtection, KeyType, Purpose};
109
use serde_bytes::ByteBuf;
1110
use std::rc::Rc;
@@ -343,7 +342,6 @@ fn sample_persistent_state() -> PersistentState {
343342
entries_buffer_limit: 10_000,
344343
polling_interval_ns: 60_000_000_000,
345344
entries_fetch_limit: 1_000,
346-
archive_integration: Some(Push),
347345
},
348346
},
349347
canister_creation_cycles_cost: 12_346_000_000,

0 commit comments

Comments
 (0)