Skip to content

Commit

Permalink
remove account trimming init and upgrade args
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejdfinity committed Dec 4, 2024
1 parent 43e3e63 commit 813da56
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 40 deletions.
1 change: 0 additions & 1 deletion rs/ledger_suite/icrc1/index-ng/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ fn upgrade_ledger(
change_fee_collector,
max_memo_length: None,
feature_flags: None,
accounts_overflow_trim_quantity: None,
change_archive_options: None,
}));
env.upgrade_canister(ledger_id, ledger_wasm(), Encode!(&args).unwrap())
Expand Down
3 changes: 0 additions & 3 deletions rs/ledger_suite/icrc1/ledger/ledger.did
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ type InitArgs = record {
metadata : vec record { text; MetadataValue };
initial_balances : vec record { Account; nat };
feature_flags : opt FeatureFlags;
maximum_number_of_accounts : opt nat64;
accounts_overflow_trim_quantity : opt nat64;
archive_options : record {
num_blocks_to_archive : nat64;
max_transactions_per_response : opt nat64;
Expand Down Expand Up @@ -144,7 +142,6 @@ type UpgradeArgs = record {
change_fee_collector : opt ChangeFeeCollector;
max_memo_length : opt nat16;
feature_flags : opt FeatureFlags;
accounts_overflow_trim_quantity: opt nat64;
change_archive_options : opt ChangeArchiveOptions;
};

Expand Down
22 changes: 2 additions & 20 deletions rs/ledger_suite/icrc1/ledger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ impl InitArgsBuilder {
},
max_memo_length: None,
feature_flags: None,
maximum_number_of_accounts: None,
accounts_overflow_trim_quantity: None,
})
}

Expand Down Expand Up @@ -267,8 +265,6 @@ pub struct InitArgs {
pub archive_options: ArchiveOptions,
pub max_memo_length: Option<u16>,
pub feature_flags: Option<FeatureFlags>,
pub maximum_number_of_accounts: Option<u64>,
pub accounts_overflow_trim_quantity: Option<u64>,
}

#[derive(Clone, Eq, PartialEq, Debug, CandidType, Deserialize)]
Expand Down Expand Up @@ -344,8 +340,6 @@ pub struct UpgradeArgs {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub feature_flags: Option<FeatureFlags>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub accounts_overflow_trim_quantity: Option<u64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub change_archive_options: Option<ChangeArchiveOptions>,
}

Expand Down Expand Up @@ -644,8 +638,6 @@ impl Ledger {
fee_collector_account,
max_memo_length,
feature_flags,
maximum_number_of_accounts,
accounts_overflow_trim_quantity,
}: InitArgs,
now: TimeStamp,
) -> Self {
Expand Down Expand Up @@ -680,14 +672,8 @@ impl Ledger {
.collect(),
max_memo_length: max_memo_length.unwrap_or(DEFAULT_MAX_MEMO_LENGTH),
feature_flags: feature_flags.unwrap_or_default(),
maximum_number_of_accounts: maximum_number_of_accounts
.unwrap_or_else(|| MAX_ACCOUNTS.try_into().unwrap())
.try_into()
.unwrap(),
accounts_overflow_trim_quantity: accounts_overflow_trim_quantity
.unwrap_or_else(|| ACCOUNTS_OVERFLOW_TRIM_QUANTITY.try_into().unwrap())
.try_into()
.unwrap(),
maximum_number_of_accounts: MAX_ACCOUNTS.try_into().unwrap(),
accounts_overflow_trim_quantity: ACCOUNTS_OVERFLOW_TRIM_QUANTITY.try_into().unwrap(),
ledger_version: LEDGER_VERSION,
};

Expand Down Expand Up @@ -935,10 +921,6 @@ impl Ledger {
}
self.feature_flags = feature_flags;
}
if let Some(accounts_overflow_trim_quantity) = args.accounts_overflow_trim_quantity {
self.accounts_overflow_trim_quantity =
accounts_overflow_trim_quantity.try_into().unwrap();
}
if let Some(change_archive_options) = args.change_archive_options {
let mut maybe_archive = self.blockchain.archive.write().expect(
"BUG: should be unreachable since upgrade has exclusive write access to the ledger",
Expand Down
2 changes: 0 additions & 2 deletions rs/ledger_suite/icrc1/ledger/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ fn default_init_args() -> InitArgs {
},
max_memo_length: None,
feature_flags: None,
maximum_number_of_accounts: None,
accounts_overflow_trim_quantity: None,
}
}

Expand Down
14 changes: 0 additions & 14 deletions rs/ledger_suite/icrc1/ledger/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,6 @@ fn encode_init_args(args: ic_ledger_suite_state_machine_tests::InitArgs) -> Ledg
},
max_memo_length: None,
feature_flags: args.feature_flags,
maximum_number_of_accounts: args.maximum_number_of_accounts,
accounts_overflow_trim_quantity: args.accounts_overflow_trim_quantity,
})
}

Expand Down Expand Up @@ -754,8 +752,6 @@ fn test_icrc2_feature_flag_doesnt_disable_icrc2_endpoints() {
},
max_memo_length: None,
feature_flags: Some(FeatureFlags { icrc2: false }),
maximum_number_of_accounts: None,
accounts_overflow_trim_quantity: None,
}))
.unwrap();
let ledger_id = env
Expand Down Expand Up @@ -930,8 +926,6 @@ fn test_icrc3_get_archives() {
},
max_memo_length: None,
feature_flags: None,
maximum_number_of_accounts: None,
accounts_overflow_trim_quantity: None,
});
let args = Encode!(&args).unwrap();
let ledger_id = env
Expand Down Expand Up @@ -1007,8 +1001,6 @@ fn test_icrc3_get_blocks() {
},
max_memo_length: None,
feature_flags: None,
maximum_number_of_accounts: None,
accounts_overflow_trim_quantity: None,
});
let args = Encode!(&args).unwrap();
let ledger_id = env
Expand Down Expand Up @@ -1283,8 +1275,6 @@ fn test_icrc3_get_blocks_number_of_blocks_limit() {
},
max_memo_length: None,
feature_flags: None,
maximum_number_of_accounts: None,
accounts_overflow_trim_quantity: None,
});

let args = Encode!(&args).unwrap();
Expand Down Expand Up @@ -1719,8 +1709,6 @@ mod verify_written_blocks {
},
max_memo_length: None,
feature_flags: Some(FeatureFlags { icrc2: true }),
maximum_number_of_accounts: None,
accounts_overflow_trim_quantity: None,
});

let args = Encode!(&ledger_arg_init).unwrap();
Expand Down Expand Up @@ -1937,8 +1925,6 @@ mod incompatible_token_type_upgrade {
},
max_memo_length: None,
feature_flags: Some(FeatureFlags { icrc2: false }),
maximum_number_of_accounts: None,
accounts_overflow_trim_quantity: None,
}))
.unwrap()
}
Expand Down

0 comments on commit 813da56

Please sign in to comment.