Is it possible to have conditional message routing?
Currently, there is a routing table with canister id to subnet, used by the stream builder.
Perhaps canister ids can point to a bit more advanced routing config stored in the same place and used by the stream builder.
Example routing config:
Intermediary destination: 2sqpr-ciaaa-aaaaq-aaaoq-cai
Key selectors:
- H(icrc1_balance_of.inputs.account.owner)
- H(icrc1_transfer.caller)
- …
Where H(v) → 0 - 65535 (With the option to have a few different transforming functions)
Routing table:
Range | Subnet | Destination canister Id |
---|---|---|
0-12000 | 2fq7c-slacv-26cgz… | iywa7-ayaaa-aaaaf-aemga-cai |
12000-32000 | 3hhby-wmtmw-umt4t… | 4ijyc-kiaaa-aaaaf-aaaja-cai |
32000-65535 | 5kdm2-62fc6-fwnja… | 6hsbt-vqaaa-aaaaf-aaafq-cai |
(With the option to also have a routing table with text ranges like a-b, b-e, e-z in case you want ordered split)
This way you can start with one canister, perhaps one ledger, or an asset canister, and then move its contents to multiple canisters and replace it with a router, while everything keeps working (dexes, wallets, etc) without additional changes in them.
Controllers should be able to update the routing config. This will allow them to migrate some of the data from one canister to more. Ex: 0-12000 goes to 3 canisters 0-4000, 4000-9000 and 9000-12000.
This should eliminate the need for a cluster to create client libraries for frontends and each CDK.
An IC call to the Intermediary destination which was previously occupied by a canister ‘2sqpr-ciaaa-aaaaq-aaaoq-cai’ will get routed to another subnet / canister id
People who may be interested and have worked on multi-canister ledgers/ databases @timo @icme @senior.joinu . Maybe this feature will be helpful? It will be pretty useful to me.
Source https://medium.com/dfinity/ic-internals-the-xnet-protocol-for-subnets-c4035dac7d2c
@roman-kashitsyn
The registry canister maintains the assignment of nodes to physical machines, and the Network Nervous System governs all the changes to the registry.
To do its job, the stream builder needs the mapping from canister identifiers to subnet identifiers, the routing table . The routing table comes from the registry and changes over time. To ensure determinism, each block pins the registry version that the state machine is using for message processing.
Messages start their journey in the output queues of canisters hosted on the source subnet. The subnet sorts these messages based on the destination subnet and interleaves them into flat message streams (one stream per destination subnet)
Source <internetcomputer.org>
The API boundary node allows IC native applications to directly call the canister smart contracts. In this case, the boundary node simply routes the API canister calls to the right subnet. Hence, no trust is required between the user and the boundary node.