Cost of running a chain fusion canister

Hi community, running the canister that supports my project ReTransICP is more costly than I anticipated. I noticed the canister keeps running out of cycles, and tested that is consumes roughly 1.5TC per day. This includes:

  • scanning roughly 17000 Gnosis blocks for 1 event
  • executing 70 transactions on the gnosis chain (gnosis tx cost is paid separately, but each transactions needs a threshold signature by the canister)

While the price of cycles varies, I found an estimate of roughly 1.36USD/TC, which means the canister consumes around 2 USD/day, which is more than I expected.

How can I understand these costs better? Are there ways to reduce them?

2 Likes

Hey @malteish,

If you’re looking for an automated, easy to set up tool to better understand your production cycles costs while keeping your application topped up I recommend looking into CycleOps. Here’s some onboarding documentation that will get you set up with cycles topups, memory email alerts, and more in just ~10 minutes

If your want to evaluate what individual parts of your code might be costing you the most in terms of cycles costs, Paying for resources in cycles | Internet Computer has documentation on the specific cycle costs per operation. Specifically, I’d recommend looking into the threshold signing and HTTP outcall costs. You can also use instruction counter/cycles balance APIs in your code in order to better understand the expensive operations in your APIs.

Any more details regarding this? That sounds like going over a lot of data for a single event.

I am following the chain fusion approach: The canister scans all new blocks. Gnosis chain has a block time of roughly 5 seconds, so it creates 17000 blocks per day. When I say “1 event” I mean: “1 topic that is emitted by 1 smart contract”, so I narrow the scope down as far as possible already. This event was emitted 70 times during the day in question, which resulted in the 70 transactions mentioned above.

I welcome suggestions but don’t see how I can streamline further. If scanning of blocks is expensive, that would be a valuable lesson for me. It could mean chain fusion has a higher baseline cost on gnosis than on ethereum mainnet, because of the higher block speed.

Thanks for pointing towards cycleOps, which I already use. It didn’t teach me anything though, so I am left simply having to pay the price.

Will look into the cycles API!

1 Like

What CDK are you using? In Azle or Rust for example you can use the performance counter to measure instruction use even across await boundaries. Combine that info with this: https://internetcomputer.org/docs/current/developer-docs/gas-cost

1 Like

I am using Rust: GitHub - malteish/ReTransICP: Recurring on-chain transactions made easy through Internet Computer Protocol