Skip to main content

More on Computations and Computation Blocks

As mentioned in the overview, Underlying smart contracts are computations in Coinweb.

A computation block is a specialization of a computation with added functionality regarding inter-shard communication and query processing.

One computation block implements the smart contract system for WebAssembly, a separate computation block implements the tokenization platform, and a third implements the non-custodial staking. Additional computation blocks for new VMs or functionality might be added in the future.

Computation blocks are trusted, meaning they are allowed to do things that smart contracts themselves are not allowed to do. For example, use claims and CPU without worrying about gas costs.

CWEB tokens can be deposited into and withdrawn from computation-blocks.

Each computation-block has 1 instance per Coinweb shard (for betanet, one per Bitcoin, Litecoin, Ethereum …etc); Each instance might behave differently over the different networks, or it can be disabled for some networks. For example, staking can be enabled only for eth and MetaverseX, and it works differently between them.

Computation-block user interaction

An end-user has 3 ways to influence a computation block:

  1. Custom action on L1-blockchain. The computation-block is able to see transactions and smart contract events from L1, and react to them. This is how the custodial staking computation block is influenced.

  2. L2-transactions without CWEB. The user can issue l2-transactions with a custom payload that's interpreted by the computation-block. Doing so does not require CWEB BUT, the computation-block ensures the following:

    • Network fees are paid

    • Broadcaster fees are paid

    • Double spend is prevented and, if detected, penalties are imposed.

  3. L2-transactions with CWEB. A user can issue a transaction and pay the network and broadcaster fees in addition to whatever fees are imposed by the Computation Block.

An end-user can query a computation-block using the coinweb-lib. This query will not modify the state of the computation block nor incur any fees.

A computation block keeps an internal balance of user funds. This balance:

  • Is transparent to the rest of the system.

  • Does not create any new CWEB.

  • Can be used to pay user network and broadcaster fees in CWEB.

  • Does not need to be kept in CWEB. For example, a computation-block might use its own token, futures, shares, or a combination of all of this or some other mechanism.

The maximum CWEB a computation-block can issue to its users is:

«computation-block initial balance» + «CWEB sent to the computation-block» - «network fee used by the computation block».

There's no hard rule on how much a computation block can charge in fees, but it is recommended that:

  • it will be proportionally small, but always greater than zero.

  • it will increase with the amount of work required.

Technically speaking, transactions that reach computation-blocks can not fail (in the transactional sense), they always reach step_compute even if valid_tx returns "invalid". The reason for this is so the computation-block can implement better error reports and anti-double spend mechanisms. In some cases, if the CWEB funding of the l2-transaction fails before reaching the computation-block the UserMsg won't be visible by step_compute