threefoldtech / tfchain

Threefold Chain.
Apache License 2.0
15 stars 11 forks source link

Decouple the current billing index from best block-number #931

Open sameh-farouk opened 10 months ago

sameh-farouk commented 10 months ago

Describe the bug

Currently, all network validators are required to have offchain worker enabled. This is because we depend on the best block number in retrieval contracts ids from the billing shards. Skipping subsets of contracts in the billing cycle can occur in cases such as:

My suggestion is to store the current index in the smart contract pallet storage and increment it upon every successful billing cycle.

By decoupling the current billing index from best block-number we would ensure that all contracts billing are handled as long as there is at least one validator have offcahin worker enabled on the network and configured correctly .

if this implemented, The only side effect for less offchain workers would be prelonged cycle (less workers = more time) but this would be better than no billing done at all.

This is primarily an improvement to enable better error tolerance, but we can also plan and proceed in parallel with a more comprehensive redesign that involve zos nodes, gateways, and other components responsible for triggering the billing instead of the offchain workers if needed.

sameh-farouk commented 9 months ago

I want to add that the motivation here beside better operation error tolerance, that I don't want to make a critical feature (contracts billing) depends on one option passed to the tfchain binary specially if we still plan to launch the validators program. As alternative maybe we could enforce enabling the offchain worker from the code.

sameh-farouk commented 3 months ago

This can be done using the approach suggested here https://github.com/threefoldtech/tfchain/issues/932#issuecomment-1954991279