Improving the Cycle Management Experience

@Severin Is it correct to assume that the same issue with the CMC not accepting ICRC transfers for burns exists for notify_mint_cycles?

Additionally, why doesn’t notify_top_up or notify_mint_cycles return the ledger block index for the ICP burn? It seems like notify_mint_cycles returns the block index of the cycle ledger deposit, but not the block index of the ICP burn transaction.

type NotifyMintCyclesSuccess = record {
  // Cycles ledger block index of deposit
  block_index : nat;
  // Amount of cycles that were minted and deposited to the cycles ledger
  minted : nat;
  // New balance of the cycles ledger account
  balance : nat;
};

Correct. The functions all use the same validation function to check the memo.

When I created notify_mint_cycles I just copied the other functions’ return values. Why the others don’t expose it I can’t say for sure, but I would suspect because it’s an implementation detail that those ICP get burned. Honest question: why would you even care about that burn TX?

To be able to show it to users via a block link to the dashboard (proof of burn). CMC burns show up as a type “Burn” ICP transaction on the ICP dashboard.

1 Like

@Severin I have a strange error where when I use deps pull or I use the latest release for cycles-ledger I get a did file that has a service, but doesn’t have the init args in the definition. Thus when I try to install the canister it has the init args function as export const init = ({ IDL }) => { return []; }; when it should be something like ie(evmrpc)

export const init = ({ IDL }) => {
  const Regex = IDL.Text;
  const LogFilter = IDL.Variant({
    'ShowAll' : IDL.Null,
    'HideAll' : IDL.Null,
    'ShowPattern' : Regex,
    'HidePattern' : Regex,
  });
  const InstallArgs = IDL.Record({
    'logFilter' : IDL.Opt(LogFilter),
    'demo' : IDL.Opt(IDL.Bool),
    'manageApiKeys' : IDL.Opt(IDL.Vec(IDL.Principal)),
  });
  return [InstallArgs];
};

I’m guessing maybe this was handcrafted?

Anyway…it seems to mess up pic.js when I try to install the cycles ledger and i get

 Error from Canister um5iw-rqaaa-aaaaq-qaaba-cai: Canister called `ic0.trap` with message: failed to decode call arguments: Custom(Cannot parse header 4449444c0001

    Caused by:
        binary parser error: index at byte offset 6).
    Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: http://internetcomputer.org/docs/current/references/execution-errors#trapped-explicitly

with the args being passed in of Uint8Array(6) [ 68, 73, 68, 76, 0, 1 ] which looks way too short for #Init({max_records_per…

I had to manually change it to:

export const init = ({ IDL }) => { 

  const ChangeIndexId = IDL.Variant({
    'SetTo' : IDL.Principal,
    'Unset' : IDL.Null
  });

  const UpgradeArgs = IDL.Record({ 
    'change_index_id' : ChangeIndexId,
    'max_blocks_per_request': IDL.Opt(IDL.Nat64) });

  const InitArgs = IDL.Record({
    'index_id' : IDL.Opt(IDL.Nat),
    'max_blocks_per_request' : IDL.Nat64,
  });

  const InstallArgs = IDL.Variant({
    "Upgrade" : IDL.Opt(UpgradeArgs),
    "Init" : InitArgs,
  });
  return [InstallArgs]; 
};

…this works, but gets over written whenever I do generate so I had to move it to another directory which is just annoying.

I think the .did file needs to have the service line changed to:

service :  (LedgerArgs) -> {

https://dashboard.internetcomputer.org/canister/um5iw-rqaaa-aaaaq-qaaba-cai

Info that I came across when trying to figure this out:

  • cycles-ledger.did does contain the init args
  • dfx deps seems to work just fine. It puts the correct argument in deps/init.json and installing the cycles ledger via dfx deps + dfx deploy works
  • The init argument gets stripped somewhere in this block (part of dfx build). get_service_idl_path docstring says Path to the candid file which contains no init types.
  • dfx seems to strip init types by default. That is surprising to me

Everything seems to be working ‘as intended’, but that’s obviously a weird answer in this case. I’ll ask the people that know more about this and get back to you @skilesare

Just out of curiosity: why do you need bindings to include the init arguments? dfx deps is supposed to handle installation for you AFAIU

1 Like

Pic.js requires you set up your environment during setup.

As a result I need to point to the wasm and then use setupCanister to instantiate.

(I tried to install the cycle ledger using dfx after installing the nns and then exporting the state as described in the pic.js docs, but since dfx puts everything in the same sub net, when I ran the state it couldn’t find the right place to route the request to the cycle ledger. What I think happened is that the cycle ledger was installed with a canister Id outside the nns range and pocket ic didn’t know how to resolve the fact that something outside that range was in the nns subnet.)

As a result of the above, I use the nns state but then install the cycle ledger and evm rock manually before each of my tests(which increases test time).

Perhaps a good bit of this gets resolved if/when over ic becomes the default replica and I can specify subnets in the dfx file and then export state for integration tests.

Cc @NathanosDev

An upgrade proposal for the cycles ledger has been submitted, with a refund bug fix.

3 Likes

Discussion thread for proposal 136213 to upgrade the cycles-ledger.

2 Likes