flyq
June 13, 2021, 8:59am
1
I found that ledger canister has some interfaces that use protobuf for canister interface:
/// See caveats of use on send_dfx
#[export_name = "canister_query account_balance_dfx"]
fn account_balance_dfx_() {
over(candid_one, |AccountBalanceArgs { account }| {
account_balance(account)
})
}
#[export_name = "canister_query total_supply_pb"]
fn total_supply_() {
over(protobuf, |_: TotalSupplyArgs| total_supply())
}
/// Get multiple blocks by *offset into the container* (not BlockHeight) and
/// length. Note that this simply iterates the blocks available in the Ledger
/// without taking into account the archive. For example, if the ledger contains
/// blocks with heights [100, 199] then iter_blocks(0, 1) will return the block
/// with height 100.
#[export_name = "canister_query iter_blocks_pb"]
fn iter_blocks_() {
over(protobuf, |IterBlocksArgs { start, length }| {
I guess this is done for efficiency.
But currently dfx and motoko canister only support candid-based interface calls, and cannot call this protobuf-based interface:
The Replica returned an error: code 4, message: "IC0503: Canister ryjl3-tyaaa-aaaaa-aaaba-cai trapped explicitly: Panicked at 'Deserialization Failed: "failed to decode Protobuf message: unexpected end group tag"', /home/peter/ic/rs/rust_canisters/dfn_core/src/endpoint.rs:34:41"
So will motoko canister/dfx support protobuf?
1 Like
wang
June 14, 2021, 6:44am
2
Related: https://twitter.com/floatfloatboat/status/1399955112915726345?s=19
It seems like if you want to integrate the registry from a motoko canister, you’ll have to build protobufs yourself
2 Likes
Plus Motoko doesn’t even allow you to send “raw” IC messages, i.e. it only talks Candid.
You see, Candid is the official interop language for the Internet Computer, but not the only one. Or something like that…
2 Likes
icme
February 24, 2025, 10:08pm
4
@claudio ran into this recently trying to fetch subnet information from the nns registry canister
I’m looking to replicate some of the ic-admin tool functionalities from a canister, to eliminate the need to run off-chain crons to collect various data.
Specifically, the get-subnet-list and get-subnet commands.
I noticed that the ic-admin tool calls a get_value endpoint on the registry canister that accepts different keys, but that this endpoint’s arguments are protobuf encoded, and the endpoint isn’t explicitly documented in the candid.
Are there any plans to expose open candid interfaces …
Looks like there may have been some ideas to implement this on the canister level in 2022, but not sure if that went anywhere…
We’ve talked some about a protobuf library for motoko, but the general consensus has been to migrate toward candid and add candid interfaces for the few protobuf functions that are out there. I don’t understand the slowness in adding these endpoints, but hopefully they are coming soon. The big outstanding ones that I know about are:
Ledger
-getting Block detail
-getting archive index
Ledger Archive
-getting Block detail
Governance
-getting the XDR ratio
1 Like
I think all the protobuff stuff was retired a while ago wasn’t it?