Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard for index discovery from ledgers #106

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Conversation

bogwar
Copy link

@bogwar bogwar commented Oct 30, 2024

A standard to allow for the discovery of the index canister from the corresponding ledger. This standard will exist in draft form only since we will work on a proper ICRC standard for index canisters (which will include discoverability).
A secondary goal for the standard is to document the interface of the current index canister.

@bogwar bogwar changed the title get git number for the discover index standard Standard for index discovery from ledgers Nov 7, 2024
ICRCs/ICRC-106/ICRC-106.md Outdated Show resolved Hide resolved

## 3. Index Canister Interface

The index canister associated with the ledger SHOULD implement the following minimal Candid interface:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the semantic difference between SHOULD and MUST in this document?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MUST is more stringent than SHOULD -- see RFC2119

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

## 4. Implementation Considerations

Implementers should ensure that:
- The `icrc106:index_principal` metadata entry accurately reflects the principal of the associated index canister.
Copy link

@aterga aterga Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of implies that the index should be deployed before the ledger, right?

But then the suggested Index API that has

ledger_id: () -> (principal) query;

makes it impossible to comply with this standard in the state in which Index is already deployed but the Ledger isn't.

Should we maybe consider:

ledger_id: () -> (record { opt principal }) query;

or maybe

ledger_id: () -> (LedgerIdResult) query;

?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The metadata could be updated after the index is deployed, at which point the principal of the index would be known, no?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'm just pointing out that this requirement would be temporarily violated before both are deployed.

I don't see any severe practical issues w.r.t. this, though.

ICRCs/ICRC-106/ICRC-106.md Outdated Show resolved Hide resolved
ICRCs/ICRC-106/ICRC-106.md Outdated Show resolved Hide resolved
num_blocks_synced : BlockIndex;
};

service : {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what is the reason that some standardized functions are called with the standard in the prefix (e.g., icrc2_transfer_from), while others are not.

Probably this is used when it's necessary to disambiguate new functions from priorly existing ones.

I wonder if it would be a better convention to always have standard functions prefixed with the standard name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The index interface doesn't follow a standard, so the methods don't have this name spacing

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I wonder, should there be a note saying explicitly which canisters in the Ledger suite this standard is specifying? I now suppose it's the Ledger itself, and not the Index.

service : {
get_account_transactions: (GetAccountTransactionsArgs) -> (GetTransactionsResult) query;
ledger_id: () -> (principal) query;
list_subaccounts : (ListSubaccountsArgs) -> (vec SubAccount) query;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ListSubaccountsArgs type takes start, but how does the client know how to get subsequent pages? I guess they should set start to the last value form the privious response.

Should this be documented in the https://github.com/dfinity/ICRC/blob/43d368ba79d30e850a422fd693b827b528c26ff1/ICRCs/ICRC-106/ICRC-106.md#list_subaccounts section?

ICRCs/ICRC-106/ICRC-106.md Outdated Show resolved Hide resolved

type Transaction = record {
burn : opt Burn;
kind : text;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imho, this field is redundant, since the kind can be deduced from the optional fields.

A slightly better way to encode this would be to have the specific kinds exclusive. Right now, a valid instance of this type could be both mint and burn, right?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
kind : text;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we're just pinning the current interface of the index canisters, so for completeness we include all of the record fields

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood, thanks

kind : text;
mint : opt Mint;
approve : opt Approve;
timestamp : nat64;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
timestamp : nat64;
timestamp_seconds : nat64;

type Burn = record {
from : Account;
memo : opt vec nat8;
created_at_time : opt nat64;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
created_at_time : opt nat64;
created_at_timestamp_seconds : opt nat64;

fee : opt nat;
from : Account;
memo : opt vec nat8;
created_at_time : opt nat64;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
created_at_time : opt nat64;
created_at_timestamp_seconds : opt nat64;

fee : opt nat;
from : Account;
memo : opt vec nat8;
created_at_time : opt nat64;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
created_at_time : opt nat64;
created_at_timestamp_seconds : opt nat64;

created_at_time : opt nat64;
amount : nat;
expected_allowance : opt nat;
expires_at : opt nat64;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expires_at : opt nat64;
expires_at_timestamp_seconds : opt nat64;


type Transfer = record {
to : Account;
fee : opt nat;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fee : opt nat;
fee : opt Tokens;

from : Account;
memo : opt vec nat8;
created_at_time : opt nat64;
amount : nat;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
amount : nat;
amount : Tokens;

};

type Approve = record {
fee : opt nat;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fee : opt nat;
fee : opt Tokens;

type Approve = record {
fee : opt nat;
from : Account;
memo : opt vec nat8;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious, why not

Suggested change
memo : opt vec nat8;
memo : opt blob;

from : Account;
memo : opt vec nat8;
created_at_time : opt nat64;
amount : nat;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
amount : nat;
amount : Tokens;

memo : opt vec nat8;
created_at_time : opt nat64;
amount : nat;
expected_allowance : opt nat;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expected_allowance : opt nat;
expected_allowance : opt Tokens;

bogwar and others added 4 commits November 19, 2024 23:43
Co-authored-by: Arshavir Ter-Gabrielyan <[email protected]>
Co-authored-by: Arshavir Ter-Gabrielyan <[email protected]>
Co-authored-by: Arshavir Ter-Gabrielyan <[email protected]>
@aterga
Copy link

aterga commented Nov 20, 2024

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants