Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions packages/icrc-ledger-types/src/icrc154/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use candid::CandidType;
use candid::types::number::Nat;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, CandidType, Deserialize, Serialize)]
pub struct PauseArgs {
pub reason: Option<String>,
pub created_at_time: u64,
}

#[derive(Clone, Debug, CandidType, Deserialize, Serialize)]
pub struct UnpauseArgs {
pub reason: Option<String>,
pub created_at_time: u64,
}

#[derive(Clone, Debug, CandidType, Deserialize, Serialize)]
pub struct DeactivateArgs {
pub reason: Option<String>,
pub created_at_time: u64,
}

#[derive(Clone, Debug, CandidType, Deserialize, Serialize)]
pub enum PauseError {
Unauthorized { message: String },
AlreadyPaused { message: String },
AlreadyDeactivated { message: String },
Duplicate { duplicate_of: Nat },
GenericError { error_code: Nat, message: String },
}

#[derive(Clone, Debug, CandidType, Deserialize, Serialize)]
pub enum UnpauseError {
Unauthorized { message: String },
NotPaused { message: String },
AlreadyDeactivated { message: String },
Duplicate { duplicate_of: Nat },
GenericError { error_code: Nat, message: String },
}

#[derive(Clone, Debug, CandidType, Deserialize, Serialize)]
pub enum DeactivateError {
Unauthorized { message: String },
AlreadyDeactivated { message: String },
Duplicate { duplicate_of: Nat },
GenericError { error_code: Nat, message: String },
}
1 change: 1 addition & 0 deletions packages/icrc-ledger-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod icrc103;
pub mod icrc106;
pub mod icrc107;
pub mod icrc124;
pub mod icrc154;
pub mod icrc2;
pub mod icrc21;
pub mod icrc3;
4 changes: 2 additions & 2 deletions rs/ledger_suite/icrc1/archive/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ic_base_types::CanisterId;
use ic_icrc1::blocks::encoded_block_to_generic_block;
use ic_ledger_core::block::{BlockType, EncodedBlock};
use ic_ledger_suite_state_machine_tests::{
check_icrc3_supported_block_types, test_http_request_decoding_quota,
check_icrc3_supported_block_types_ext, test_http_request_decoding_quota,
};
use ic_state_machine_tests::{StateMachine, WasmResult};
use icrc_ledger_types::icrc::generic_value::ICRC3Value;
Expand Down Expand Up @@ -359,5 +359,5 @@ fn test_archive_http_request_decoding_quota() {
fn test_icrc3_supported_block_types() {
let setup = Setup::default();

check_icrc3_supported_block_types(&setup.state_machine, setup.archive_id, true);
check_icrc3_supported_block_types_ext(&setup.state_machine, setup.archive_id, true, false);
}
26 changes: 13 additions & 13 deletions rs/ledger_suite/icrc1/ledger/canbench_results/canbench_u256.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,70 @@ benches:
bench_icrc1_transfers:
total:
calls: 1
instructions: 54321762048
instructions: 54491238395
heap_increase: 264
stable_memory_increase: 256
scopes:
icrc103_get_allowances:
calls: 1
instructions: 6379512
instructions: 6379538
heap_increase: 0
stable_memory_increase: 0
icrc1_transfer:
calls: 1
instructions: 12861149246
instructions: 12927451546
heap_increase: 32
stable_memory_increase: 0
icrc2_approve:
calls: 1
instructions: 19351589334
instructions: 19382509154
heap_increase: 29
stable_memory_increase: 128
icrc2_transfer_from:
calls: 1
instructions: 21399244033
instructions: 21477262663
heap_increase: 3
stable_memory_increase: 0
icrc3_get_blocks:
calls: 1
instructions: 8714386
instructions: 8714812
heap_increase: 0
stable_memory_increase: 0
post_upgrade:
calls: 1
instructions: 351355822
instructions: 345728772
heap_increase: 71
stable_memory_increase: 0
pre_upgrade:
calls: 1
instructions: 149736744
instructions: 148895740
heap_increase: 129
stable_memory_increase: 128
upgrade:
calls: 1
instructions: 501095237
instructions: 494627254
heap_increase: 200
stable_memory_increase: 128
bench_upgrade_baseline:
total:
calls: 1
instructions: 8692613
instructions: 8695301
heap_increase: 258
stable_memory_increase: 128
scopes:
post_upgrade:
calls: 1
instructions: 8612221
instructions: 8613042
heap_increase: 129
stable_memory_increase: 0
pre_upgrade:
calls: 1
instructions: 77539
instructions: 79335
heap_increase: 129
stable_memory_increase: 128
upgrade:
calls: 1
instructions: 8691705
instructions: 8694393
heap_increase: 258
stable_memory_increase: 128
version: 0.4.1
22 changes: 11 additions & 11 deletions rs/ledger_suite/icrc1/ledger/canbench_results/canbench_u64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ benches:
bench_icrc1_transfers:
total:
calls: 1
instructions: 51916218646
instructions: 52110539550
heap_increase: 263
stable_memory_increase: 256
scopes:
Expand All @@ -13,17 +13,17 @@ benches:
stable_memory_increase: 0
icrc1_transfer:
calls: 1
instructions: 12202452553
instructions: 12272395213
heap_increase: 34
stable_memory_increase: 0
icrc2_approve:
calls: 1
instructions: 18460191000
instructions: 18492811180
heap_increase: 25
stable_memory_increase: 128
icrc2_transfer_from:
calls: 1
instructions: 20560777002
instructions: 20643585966
heap_increase: 3
stable_memory_increase: 0
icrc3_get_blocks:
Expand All @@ -33,39 +33,39 @@ benches:
stable_memory_increase: 0
post_upgrade:
calls: 1
instructions: 342204504
instructions: 351454807
heap_increase: 72
stable_memory_increase: 0
pre_upgrade:
calls: 1
instructions: 149977921
instructions: 148926118
heap_increase: 129
stable_memory_increase: 128
upgrade:
calls: 1
instructions: 492185166
instructions: 500383666
heap_increase: 201
stable_memory_increase: 128
bench_upgrade_baseline:
total:
calls: 1
instructions: 8689429
instructions: 8699772
heap_increase: 258
stable_memory_increase: 128
scopes:
post_upgrade:
calls: 1
instructions: 8607828
instructions: 8616474
heap_increase: 129
stable_memory_increase: 0
pre_upgrade:
calls: 1
instructions: 78677
instructions: 80374
heap_increase: 129
stable_memory_increase: 128
upgrade:
calls: 1
instructions: 8688521
instructions: 8698864
heap_increase: 258
stable_memory_increase: 128
version: 0.4.1
48 changes: 48 additions & 0 deletions rs/ledger_suite/icrc1/ledger/ledger.did
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,48 @@ type GetIndexPrincipalError = variant {
}
};

type PauseArgs = record {
reason : opt text;
created_at_time : nat64
};

type UnpauseArgs = record {
reason : opt text;
created_at_time : nat64
};

type DeactivateArgs = record {
reason : opt text;
created_at_time : nat64
};

type PauseError = variant {
Unauthorized : record { message : text };
AlreadyPaused : record { message : text };
AlreadyDeactivated : record { message : text };
Duplicate : record { duplicate_of : nat };
GenericError : record { error_code : nat; message : text }
};

type UnpauseError = variant {
Unauthorized : record { message : text };
NotPaused : record { message : text };
AlreadyDeactivated : record { message : text };
Duplicate : record { duplicate_of : nat };
GenericError : record { error_code : nat; message : text }
};

type DeactivateError = variant {
Unauthorized : record { message : text };
AlreadyDeactivated : record { message : text };
Duplicate : record { duplicate_of : nat };
GenericError : record { error_code : nat; message : text }
};

type PauseResult = variant { Ok : nat; Err : PauseError };
type UnpauseResult = variant { Ok : nat; Err : UnpauseError };
type DeactivateResult = variant { Ok : nat; Err : DeactivateError };

service : (ledger_arg : LedgerArg) -> {
archives : () -> (vec ArchiveInfo) query;
get_transactions : (GetTransactionsRequest) -> (GetTransactionsResponse) query;
Expand Down Expand Up @@ -591,5 +633,11 @@ service : (ledger_arg : LedgerArg) -> {

icrc106_get_index_principal : () -> (GetIndexPrincipalResult) query;

icrc154_pause : (PauseArgs) -> (PauseResult);
icrc154_unpause : (UnpauseArgs) -> (UnpauseResult);
icrc154_deactivate : (DeactivateArgs) -> (DeactivateResult);
icrc154_is_paused : () -> (bool) query;
icrc154_is_deactivated : () -> (bool) query;

is_ledger_ready : () -> (bool) query
}
23 changes: 23 additions & 0 deletions rs/ledger_suite/icrc1/ledger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,11 @@ pub struct Ledger {

#[serde(default = "wasm_token_type")]
pub token_type: String,

#[serde(default)]
paused: bool,
#[serde(default)]
deactivated: bool,
}

#[derive(Clone, Eq, PartialEq, Debug, CandidType, Deserialize, Serialize)]
Expand Down Expand Up @@ -716,6 +721,8 @@ impl Ledger {
ledger_version: LEDGER_VERSION,
index_principal,
token_type: wasm_token_type(),
paused: false,
deactivated: false,
};

if ledger.fee_collector.as_ref().map(|fc| fc.fee_collector) == Some(ledger.minting_account)
Expand Down Expand Up @@ -859,6 +866,22 @@ impl Ledger {
MAX_TAKE_ALLOWANCES
}

pub fn is_paused(&self) -> bool {
self.paused
}

pub fn is_deactivated(&self) -> bool {
self.deactivated
}

pub fn set_paused(&mut self, paused: bool) {
self.paused = paused;
}

pub fn set_deactivated(&mut self, deactivated: bool) {
self.deactivated = deactivated;
}

pub fn metadata(&self) -> Vec<(MetadataKey, Value)> {
let mut records: Vec<(MetadataKey, Value)> = self
.metadata
Expand Down
Loading
Loading