-
Notifications
You must be signed in to change notification settings - Fork 38
ICRC-3 refinement #199
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
base: main
Are you sure you want to change the base?
ICRC-3 refinement #199
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the ICRC-3 specification to clarify how ICRC-1 and ICRC-2 blocks should be handled, specifically establishing that these legacy blocks must not include a btype field and providing concrete examples of account representation.
- Explicitly requires ICRC-1/ICRC-2 blocks to omit the
btypefield, maintaining backward compatibility - Adds detailed examples of account representation as arrays with owner principal and optional subaccount
- Updates the burn block schema to align with the legacy format requirements
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…eraction with other standards
Co-authored-by: Andrea Cerulli <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're currently writing some (internal) libraries for ICRC3, would be great to have this merged!
Request: would be great to have a test suite which can just be a list of valid blocks.
I.e. burn, 1burn, mint, 1mint, etc. (maybe separated by generic/legacy).
Thanks for the work!
Thanks for the comments! Could you be a bit more specific about the form of such a test suite? According to the current version of the standard there should be no |
|
Hi @bogwar, sorry the It seems that currently we are going to need to support both legacy and the new block log types. As this gets somewhat confusing, it would be nice to have a test suite with examples of each of these Personally I don't need these anymore, but it was a lot of work to construct tests which cover all possible flavors of block types. In the end we just ran the indexer against an SNS ledger to battle test it. |
|
Thanks for your time and work on this @bogwar! We're working toward supporting ICRC3 on non-ledger canisters, and your updates make the event log design clearer and more suitable for generic use cases. |
|
I don't want to block this PR from being merged but while applying ICRC-3 to our internal event log I encountered some 'blockers'.
|
|
Thanks Quint! On extending Value: Principals / bools: Tuples with optionals:
I’d suggest we keep Value unchanged and add a non-normative “Common Encodings” section with these recommendations (principal→Blob, bool→Nat 0/1, options in tuples via tags). That preserves minimalism while giving interoperable guidance. WDYT? |
|
@q-uint Hi Quint, can you please take a look? I've added a non-normative section with encodings. |
| - "2approve" for `icrc2_approve` blocks | ||
|
|
||
|
|
||
| ### Account Type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i still think it would be valuable to have a Principal variant in the Value. this way there is no ambiguity on how to interpret arrays
gregorydemay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @bogwar For revamping this! Some understanding questions and minor comments. Happy to discuss offline if that helps.
| | Block i | | Block i+1 | | ||
| ├─────────────────────────┤ ├─────────────────────────┤ | ||
| ◄──| phash = hash(Block i-1) |◄─────────| phash = hash(Block i) | | ||
| | ... | | ... | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the diagram maybe mention the other mandatory fields (like ts)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The focus of the diagram is on the chaining aspect; I would keep it like this.
|
|
||
| Typed blocks that **do not** represent method calls (e.g., upgrade markers, maintenance events, migration records, or system actions) MAY omit the `tx` field entirely and therefore MAY omit `tx.op`. | ||
|
|
||
| Legacy ICRC-1/2 blocks continue to use their historical operation names (`"xfer"`, `"mint"`, `"burn"`, `"approve"`), and are exempt from namespacing requirements. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| If a block represents the result of a **standardized user-initiated method call**, then: | ||
|
|
||
| - The block **SHOULD** include a `tx` field. | ||
| - For user-initiated blocks, a namespaced `tx.op` **SHOULD** be included (see above). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understanding question: what's the difference betweentx.op and btype? Is-it because a btype block could be produced by several user endpoints?
| which fields affect the meaning of the block and how extra fields are to be | ||
| treated (e.g., ignored by generic interpreters). | ||
|
|
||
| 3. Derive pre-fee state transition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand this part (also apply fee below), which seems ledger specific (it talks about fees) but that whole section ( Semantics of Blocks: Evaluation Model) should be domain-agnostic way, no?
|
|
||
| ### `icrc3_get_blocks` | ||
| Returns blocks for one or more requested ranges from the canonical block log. | ||
| Blocks that are no longer stored locally by the producer are returned indirectly via archive callbacks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is-it correct that the callback is not-necessarily an ICRC-3 compliant method?
| - pre-fee state transition, | ||
| - fee payer (if applicable), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems ledger specific
| - **Describe how fees are handled**, if the block type involves fees: | ||
| - The standard **SHOULD** specify the **effective fee** (the fee that is | ||
| actually charged), where this is well-defined. | ||
| - The standard **SHOULD** specify the **fee payer**, as an expression | ||
| resolvable from fields in the block, where this is possible. | ||
| - If applicable, the standard **MAY** reference ICRC-107 to specify **where | ||
| the fee goes** (e.g., burned, sent to a collector, etc.). | ||
| - If some fee-related aspects are intentionally left implementation- or | ||
| ledger-defined, the standard SHOULD say so explicitly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems ledger specific
| ### Note on Fees | ||
|
|
||
| ICRC-3 standardizes how fees are recorded in blocks, but it does not prescribe how fees are | ||
| calculated or collected. | ||
|
|
||
| - Every standard that introduces a block type involving fees **SHOULD** specify who the | ||
| fee payer is and, where possible, how the effective fee is determined, so that | ||
| responsibility is unambiguous. | ||
| - Where this cannot be expressed generically (for example, because the policy is | ||
| intentionally ledger-defined), the standard SHOULD state that the fee payer and/or | ||
| fee amount are implementation- or ledger-specific. | ||
| - The rules for interpreting the amount and destination of fees MAY be delegated to | ||
| ICRC-107 (Fee Handling in Blocks). Ledgers that do not yet implement ICRC-107 MAY | ||
| still produce valid ICRC-3 blocks, but their fee behavior will remain | ||
| implementation-specific until aligned with ICRC-107. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems ledger specific
| An ICRC-3 compatible producer canister MUST expose an endpoint listing all the supported block types via the endpoint `icrc3_supported_block_types`. | ||
|
|
||
| - For **typed** blocks, the producer canister MUST only produce blocks whose `"btype"` value is included in this list. | ||
| - For **legacy** ICRC-1/2 blocks (no `"btype"`), the producer canister MUST include the conventional identifiers (e.g., `"1xfer"`, `"2approve"`) in this list to advertise support, even though the blocks themselves do not carry a `"btype"` field. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment as above, I don't see in which standard those are specified.
|
|
||
|
|
||
|
|
||
| ## [ICRC-1](../ICRC-1/README.md) and [ICRC-2](../ICRC-2/README.md) Block Schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understanding question: why are we trying to retrofit our ICRC-1 and ICRC-2 implementations into the new ICRC-3 standard? Why not just say that the ledger X is ICRC-3 compliant starting block b and verifying past blocks < b involves knowing the implementation (which is needed anyway and describe din this section but should not maybe be part of ICRC-3)
Proposed change to ICRC-3 based on this proposal