NNS Update: October 19, 2023: enabling ICRC-2 on the ICP ledger

The FI Team submitted the upgrade canister proposal 125315 today, 2023-10-19. DFINITY plans to vote on this proposal on Monday, 2023-10-23.

Proposals Submitted

## Proposal to Upgrade the Ledger Canister
Proposer: DFINITY Foundation
Git Hash: 98eb213581b239c3829eee7076bea74acad9937b
New Wasm Hash: aca61e669e737133b552d0f1ddafc40299f3260daf8f57e352774b17aa82bbc1
Upgrade Args Hash: b6f581562717441791d1d7b490b17a499a51f2ac337b6e5d8d02d21ea7f3765b
Target canister: ryjl3-tyaaa-aaaaa-aaaba-cai
Previous ledger proposal: https://dashboard.internetcomputer.org/proposal/123775


## Motivation

Enable the ICRC-2 endpoints on the canister.

## Release Notes

$ git log --format="%C(auto) %h %s" 11584a62947ccebd0db3a51b0b6f8399c235aba6..98eb213581b239c3829eee7076bea74acad9937b --  ./rs/rosetta-api/ledger_canister/ledger ./rs/rosetta-api/icp_ledger/src ./rs/rosetta-api/ledger_core ./rs/rosetta-api/ledger_canister_core ./packages/icrc-ledger_types
 c0379f185f chore(icrc): icrc2: test arrival_queue for allowances is the same size as allowances map
 a95ed52069 fix(icrc): update arrive_at time in the arrival_queue for approvals
 51dafe5b6c Make transaction hashes backwards compatible
 f70aae269c Chore: Fix remaining typos in ic/rs folder.
 c41bc484dd Merge branch 'rumenov/updjejfhfh' into 'master'
 1fa41bdfce chore: upgrade the prost, tonic and pprof versions
 def91661e9 feat(icp_ledger): add account_identifier endpoint
 bfa88bb37c feat(icp_ledger): switch icp and icrc1 ledgers to use BTreeMap for account balances
 dcf13de946 chore: Clean up unused deps, part 2
 decc21be7e feat(icp_ledger): Add transfer_from endpoint to the ICP ledger
 6a69eb719d feat(FI-878): prune approvals according to their age
 1fe1b9c1c0 chore(FI-870): clean up approvals expiration_queue
 e948a3b74d feat(FI-851): [ICRC1 Ledger] Impl ledger env for state machine
 0acc754dc0 feat(FI-855): ICP ledger: use spender in the Transfer operation instead of TransferFrom operation
 5b0ac829a3 feat(FI-853): Add approve and allowance endpoints to the ICP ledger
 9ea2080fa5 Merge branch 'maciej-approve-limit' into 'master'
 e215e5645c feat(FI-821): limit the number of approvals
 c1791a23a4 refactor(crypto): CRP-2135 rename crate `ic-crypto-sha` to `ic-crypto-sha2`
 448dc3d19c chore(icrc1): parameterize the ledger impl over token type
 3855fbb623 chore: bump rust to 1.71

## Wasm Verification

Verify that the hash of the gzipped WASM matches the proposed hash.

git fetch
git checkout 98eb213581b239c3829eee7076bea74acad9937b
./gitlab-ci/container/build-ic.sh -c
sha256sum ./artifacts/canisters/ledger-canister_notify-method.wasm.gz

## Argument Verification

didc encode -d rs/rosetta-api/icp_ledger/ledger.did -t '(LedgerCanisterPayload)' '(variant { Upgrade = opt record { feature_flags = opt record {icrc2 = true} } })' | xxd -r -p > ~/ledger_arg.bin
sha256sum ~/ledger_arg.bin

Seems like a big deal. Low key post. Reason to celebrate? Well done.


What’s the use, can people who know how to talk about it?What can I do after icrc_2 is enabled?

You can approve a canister or principle to spend your ICP tokens. It really improves the flow of commerce because the the canister can take your tokens in the same atomic action as the service it provides.

Currently you have to deposit your tokens in the canister and the canister has to implement a refund mechanism to handle errors…it won’t know about your deposit, so it becomes a three step dance.


The proposal was accepted, the ICRC-2 endpoints are now available!



I’m curious if there is an error in the ledger canister archive DID file not being updated with the new struct for approve transactions?

Ledger version of Approve

  Approve : record {
    fee : Tokens;
    from : vec nat8;
    allowance_e8s : int;
    allowance : Tokens;
    expected_allowance : opt Tokens;
    expires_at : opt TimeStamp;
    spender : vec nat8;

Archive (qjdve-lqaaa-aaaaa-aaaeq-cai) version of Approve

    Approve : record {
        from : AccountIdentifier;
        spender : AccountIdentifier;
        allowance_e8s : int;
        fee : Tokens;
        expires_at : opt Timestamp;

Our 221Bravo ICP index canister has just hit a wall as “allowance : Tokens;” is not present in the data returned from block 6981590. I’m wondering if allowance should be opt Token to allow the archive canister to upgrade… or whether there is actually two types of approve blocks (old and new)?

Will the difference in structs/ records cause issues when sending new style approve txs to the archive canister? What record type should I use when fetching data from the ICP ledger to ensure I can get archive + current blocks.


Now,Can $chat $hot …
connect to centralized exchanges?

1 Like

We are going to upgrade the archive to fix this. Thanks for reporting it @NS01 .


The first archive is fixed @NS01 but in the weekend the ICP Ledger spawned a second one and that one is also with the old interface. There is a proposal that closes tomorrow to fix the interface of the new archive too.

Oh man…now I need to go check my code to make sure I handled multiple archives. :grimacing: Might be worth a PSA. I know a lot of code out there handled the deposit flow and may have only assumed one archive canister.

1 Like

I’m hoping that the design we’ve got will work with either now. I’ll keep an eye on it to see if it hits a brick wall.

Thanks for the heads up :slight_smile:

1 Like