Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
aec4a1a
handle incorrect blocks, don't schedule timer if bad block
maciejdfinity Sep 29, 2025
21a9c3b
clippy
maciejdfinity Sep 29, 2025
3468b19
Merge branch 'master' into maciej-index-badblock
maciejdfinity Sep 30, 2025
725b25b
stop sync with error
maciejdfinity Oct 1, 2025
e933990
handle append blocks failure
maciejdfinity Oct 1, 2025
08af8d7
use results
maciejdfinity Oct 1, 2025
6d211a8
change more options to results
maciejdfinity Oct 1, 2025
6f952f8
don't stop timer if failed to contact ledger or archive
maciejdfinity Oct 1, 2025
d73981b
remove fn used only once
maciejdfinity Oct 1, 2025
2e45d61
sync_status
maciejdfinity Oct 1, 2025
d378089
clippy
maciejdfinity Oct 1, 2025
e6c5881
fix did file
maciejdfinity Oct 1, 2025
b2da603
Merge branch 'master' into maciej-index-badblock
maciejdfinity Oct 6, 2025
5ba27fc
Merge branch 'master' into maciej-index-badblock
maciejdfinity Oct 7, 2025
3ada932
extract test function
maciejdfinity Oct 7, 2025
5021c78
Merge branch 'master' into maciej-index-badblock
maciejdfinity Oct 7, 2025
969915d
improve test
maciejdfinity Oct 8, 2025
5c87f33
add fee to mint and burn operations
maciejdfinity Oct 8, 2025
a1b89d5
Merge branch 'master' into maciej-index-badblock
maciejdfinity Oct 8, 2025
ae50181
fix test ledger wasm constant
maciejdfinity Oct 8, 2025
52912bf
build fix
maciejdfinity Oct 8, 2025
c773910
fix comment
maciejdfinity Oct 8, 2025
d0d5270
build fix
maciejdfinity Oct 8, 2025
99d0cbc
clippy
maciejdfinity Oct 8, 2025
2c5ed9a
Merge branch 'master' into maciej-index-badblock
maciejdfinity Oct 8, 2025
436fd3a
build fix
maciejdfinity Oct 8, 2025
08f0ea6
build fix
maciejdfinity Oct 8, 2025
74099c8
Merge branch 'master' into maciej-index-badblock
maciejdfinity Oct 8, 2025
f870f33
add archiving
maciejdfinity Oct 8, 2025
9f46c51
clippy
maciejdfinity Oct 8, 2025
1381cd3
clippy
maciejdfinity Oct 8, 2025
acdeb6a
extract common code
maciejdfinity Oct 8, 2025
fe7daff
extract test fn
maciejdfinity Oct 8, 2025
18bdd28
extract test fn
maciejdfinity Oct 8, 2025
8df190d
use tx.fee when calculating effective fee
maciejdfinity Oct 9, 2025
d97a06a
add fee to icrc3 transaction
maciejdfinity Oct 9, 2025
21556e2
build fix
maciejdfinity Oct 9, 2025
d9cfb0f
add fee to icrc3 schema
maciejdfinity Oct 9, 2025
f2629e6
revert to trap in case of impossible state
maciejdfinity Oct 9, 2025
2c57ea9
remove asserts
maciejdfinity Oct 9, 2025
e5f024d
return error if burn or mint fee while applying tx
maciejdfinity Oct 9, 2025
7e0c8f0
Revert "return error if burn or mint fee while applying tx"
maciejdfinity Oct 9, 2025
0a18a5f
burn or mint fee error
maciejdfinity Oct 9, 2025
1065e30
build fix
maciejdfinity Oct 9, 2025
507ed64
add mint and burn fees to rosetta
maciejdfinity Oct 9, 2025
6e65bdf
clippy
maciejdfinity Oct 10, 2025
a2f3b2e
fix did files
maciejdfinity Oct 10, 2025
b3839b6
Merge branch 'master' into maciej-index-badblock
maciejdfinity Oct 10, 2025
88720cd
fix operation index
maciejdfinity Oct 10, 2025
65b2af2
Merge branch 'master' into maciej-index-badblock
maciejdfinity Oct 10, 2025
fc4097f
test rosetta fee handling
maciejdfinity Oct 10, 2025
a43043a
add fee to mint and burn in some strategies
maciejdfinity Oct 13, 2025
d40113e
add fee to other strategies
maciejdfinity Oct 13, 2025
861ee31
add mint and burn fees to schema
maciejdfinity Oct 13, 2025
7403aa0
test mint burn fee rejected by ledgers
maciejdfinity Oct 13, 2025
5987385
rename tests
maciejdfinity Oct 13, 2025
7369c7f
burn and mint fee unit tests
maciejdfinity Oct 13, 2025
8b1b57b
move sync status to status
maciejdfinity Oct 14, 2025
cf49e9c
test comment
maciejdfinity Oct 14, 2025
a9d5828
buildifier fix
maciejdfinity Oct 14, 2025
716937a
remove sync_status, check /logs for error
maciejdfinity Oct 15, 2025
26ceb2d
build fix
maciejdfinity Oct 15, 2025
736f897
clippy
maciejdfinity Oct 15, 2025
1ec96cd
return error, stop sync in one place
maciejdfinity Oct 15, 2025
bc1f6f2
fix did file
maciejdfinity Oct 15, 2025
6c22dcd
formatting
maciejdfinity Oct 15, 2025
890bf68
make timer id non optional
maciejdfinity Oct 15, 2025
a947d71
test if indexing was stopped
maciejdfinity Oct 15, 2025
1bdb8b1
remove prev hash
maciejdfinity Oct 15, 2025
eccae33
remove redundant test
maciejdfinity Oct 15, 2025
21f6e64
verify no errors in logs
maciejdfinity Oct 15, 2025
b25a745
typo
maciejdfinity Oct 15, 2025
ced0cac
Merge branch 'master' into maciej-index-badblock
maciejdfinity Oct 15, 2025
69b77b8
update icrc-ledger-types changelog
maciejdfinity Oct 15, 2025
3aaaff4
log info about stopping the timer
maciejdfinity Oct 15, 2025
85aca11
remove fee from mint and burn tx strategies
maciejdfinity Oct 17, 2025
e6b5fe1
list all operation fields explicitly
maciejdfinity Oct 17, 2025
f9e160c
Merge branch 'master' into maciej-index-badblock
maciejdfinity Oct 17, 2025
accc77b
Merge branch 'master' into maciej-index-badblock
maciejdfinity Oct 17, 2025
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/icrc-ledger-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- `try_from_subaccount_to_principal` that returns an error rather than panicking if the subaccount is not a valid Principal.
- add optional fee to `Mint` and `Burn` icrc3 operations.

## 0.1.11

Expand Down
2 changes: 2 additions & 0 deletions packages/icrc-ledger-types/src/icrc3/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ pub fn validate(block: &Value) -> Result<(), ValuePredicateFailures> {
icrc1_common.clone(),
item("op", Required, is(Value::text("burn"))),
item("from", Required, is_account.clone()),
item("fee", Optional, is_amount.clone()),
]);
let is_icrc1_mint = and(vec![
icrc1_common.clone(),
item("op", Required, is(Value::text("mint"))),
item("to", Required, is_account.clone()),
item("fee", Optional, is_amount.clone()),
]);
let is_icrc2_approve = and(vec![
icrc1_common.clone(),
Expand Down
2 changes: 2 additions & 0 deletions packages/icrc-ledger-types/src/icrc3/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub struct Mint {
pub to: Account,
pub memo: Option<Memo>,
pub created_at_time: Option<u64>,
pub fee: Option<Nat>,
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
Expand All @@ -31,6 +32,7 @@ pub struct Burn {
pub spender: Option<Account>,
pub memo: Option<Memo>,
pub created_at_time: Option<u64>,
pub fee: Option<Nat>,
}

#[derive(CandidType, Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
Expand Down
8 changes: 8 additions & 0 deletions rs/ethereum/cketh/minter/tests/ckerc20.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ mod withdraw_erc20 {
.unwrap(),
})),
created_at_time: None,
fee: None,
});

let balance_after_withdrawal = ckerc20.cketh.balance_of(caller);
Expand Down Expand Up @@ -485,6 +486,7 @@ mod withdraw_erc20 {
withdrawal_id: cketh_burn_index.into(),
})),
created_at_time: None,
fee: None,
});
}

Expand Down Expand Up @@ -725,6 +727,7 @@ mod withdraw_erc20 {
.unwrap(),
})),
created_at_time: None,
fee: None,
})
.call_ckerc20_ledger_get_transaction(
deposit_params.token().ledger_canister_id,
Expand All @@ -744,6 +747,7 @@ mod withdraw_erc20 {
.unwrap(),
})),
created_at_time: None,
fee: None,
});

let expected_cketh_balance_after_withdrawal =
Expand Down Expand Up @@ -873,6 +877,7 @@ mod withdraw_erc20 {
tx_hash: DEFAULT_CKERC20_WITHDRAWAL_TRANSACTION_HASH.parse().unwrap(),
})),
created_at_time: None,
fee: None,
});
}
}
Expand Down Expand Up @@ -1361,6 +1366,7 @@ fn should_deposit_ckerc20() {
log_index: params.transaction_data().log_index.into(),
})),
created_at_time: None,
fee: None,
});
}
}
Expand Down Expand Up @@ -1454,6 +1460,7 @@ fn should_deposit_cketh_and_ckerc20() {
log_index: cketh_params.transaction_data().log_index.into(),
})),
created_at_time: None,
fee: None,
})
.call_ckerc20_ledger_get_transaction(params.token().ledger_canister_id, 0_u8)
.expect_mint(Mint {
Expand All @@ -1465,6 +1472,7 @@ fn should_deposit_cketh_and_ckerc20() {
log_index: params.transaction_data().log_index.into(),
})),
created_at_time: None,
fee: None,
});
}
}
Expand Down
5 changes: 5 additions & 0 deletions rs/ethereum/cketh/minter/tests/cketh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ fn should_deposit_and_withdraw() {
log_index: DEFAULT_DEPOSIT_LOG_INDEX.into(),
})),
created_at_time: None,
fee: None,
})
.call_ledger_approve_minter(account.owner, EXPECTED_BALANCE, account.subaccount)
.expect_ok(1)
Expand Down Expand Up @@ -124,6 +125,7 @@ fn should_deposit_and_withdraw() {
to_address: destination.parse().unwrap(),
})),
created_at_time: None,
fee: None,
});
assert_eq!(cketh.balance_of(account), Nat::from(0_u8));

Expand Down Expand Up @@ -454,6 +456,7 @@ fn should_reimburse() {
log_index: DEFAULT_DEPOSIT_LOG_INDEX.into(),
})),
created_at_time: None,
fee: None,
})
.call_ledger_approve_minter(caller, EXPECTED_BALANCE, None)
.expect_ok(1);
Expand Down Expand Up @@ -493,6 +496,7 @@ fn should_reimburse() {
to_address: destination.parse().unwrap(),
})),
created_at_time: None,
fee: None,
});

assert_eq!(cketh.balance_of(caller), Nat::from(0_u8));
Expand Down Expand Up @@ -543,6 +547,7 @@ fn should_reimburse() {
tx_hash: failed_tx_hash.parse().unwrap(),
})),
created_at_time: None,
fee: None,
})
.assert_has_unique_events_in_order(&vec![
EventPayload::AcceptedEthWithdrawalRequest {
Expand Down
6 changes: 5 additions & 1 deletion rs/ledger_suite/common/ledger_canister_core/src/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::archive::{ArchivingGuardError, FailedToArchiveBlocks, LedgerArchiving
use ic_ledger_core::balances::{BalanceError, Balances, BalancesStore};
use ic_ledger_core::block::{BlockIndex, BlockType, EncodedBlock, FeeCollector};
use ic_ledger_core::timestamp::TimeStamp;
use ic_ledger_core::tokens::TokensType;
use ic_ledger_core::tokens::{TokensType, Zero};
use ic_ledger_hash_of::HashOf;

#[derive(Debug, Deserialize, Serialize)]
Expand All @@ -34,6 +34,7 @@ pub enum TxApplyError<Tokens> {
ExpiredApproval { now: TimeStamp },
AllowanceChanged { current_allowance: Tokens },
SelfApproval,
BurnOrMintFee,
}

impl<Tokens> From<BalanceError<Tokens>> for TxApplyError<Tokens> {
Expand Down Expand Up @@ -264,6 +265,9 @@ where
TransferError::AllowanceChanged { current_allowance }
}
TxApplyError::SelfApproval => TransferError::SelfApproval,
TxApplyError::BurnOrMintFee => TransferError::BadFee {
expected_fee: L::Tokens::zero(),
},
})?;

let fee_collector = ledger.fee_collector().cloned();
Expand Down
8 changes: 8 additions & 0 deletions rs/ledger_suite/icp/ledger/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,14 @@ fn test_mint_burn() {
ic_ledger_suite_state_machine_tests::test_mint_burn(ledger_wasm(), encode_init_args);
}

#[test]
fn test_mint_burn_fee_rejected() {
ic_ledger_suite_state_machine_tests::test_mint_burn_fee_rejected(
ledger_wasm(),
encode_init_args,
);
}

#[test]
fn test_anonymous_transfers() {
ic_ledger_suite_state_machine_tests::test_anonymous_transfers(ledger_wasm(), encode_init_args);
Expand Down
6 changes: 4 additions & 2 deletions rs/ledger_suite/icrc1/archive/archive.did
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ type Burn = record {
memo : opt vec nat8;
created_at_time : opt nat64;
amount : nat;
spender : opt Account
spender : opt Account;
fee : opt nat
};

type Mint = record {
to : Account;
memo : opt vec nat8;
created_at_time : opt nat64;
amount : nat
amount : nat;
fee : opt nat
};

type Transfer = record {
Expand Down
2 changes: 2 additions & 0 deletions rs/ledger_suite/icrc1/archive/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ fn test_icrc3_get_blocks() {
Operation::Mint {
to: Account::from(Principal::anonymous()),
amount: Tokens::from(1_000_000_000u64),
fee: None,
},
);
let blockid0 = block_with_id(0, block0.clone());
Expand Down Expand Up @@ -259,6 +260,7 @@ fn test_icrc3_get_blocks_number_of_blocks_limit() {
operation: Operation::Mint {
to: Account::from(Principal::anonymous()),
amount: Tokens::from(amount as u64),
fee: None,
},
created_at_time: None,
memo: None,
Expand Down
6 changes: 4 additions & 2 deletions rs/ledger_suite/icrc1/index-ng/index-ng.did
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,16 @@ type Burn = record {
memo : opt vec nat8;
created_at_time : opt nat64;
amount : Tokens;
spender : opt Account
spender : opt Account;
fee : opt nat
};

type Mint = record {
to : Account;
memo : opt vec nat8;
created_at_time : opt nat64;
amount : Tokens
amount : Tokens;
fee : opt nat
};

type Transfer = record {
Expand Down
Loading
Loading