Loop durations shouldn't be based on arbitrary numbers, but based on multipliers of known "constants" (or approximate constants).
Constants we can use:
- Ethereum average block time
- Cosmos average block time
These values are hardcoded into the Peggy parameters in the genesis.
Loops:
Eth Oracle
Retrieves events from Ethereum and sends them over to Cosmos. This one should be run slower than the average Eth block time. I suggest 2x or 3x. Edit: I'll put this a bit higher, 5x for now to reduce the number of calls to the geth node. If it's to slow we can just modify it again.
Batch Requester
Takes whatever is in the outgoing tx pool and creates a batch; the batch will only be created if it's more profitable than the one that's already waiting in the batch queue. This should be the slowest loop, given that all validators will be calling it and the outgoing TX pool is one for the entire network. It should be a multiplier of the Cosmos average block time because that's were TX are created. I suggest we start with a value like 60x (5m) and see how it goes.
I assume we'll endup using a much higher value like 120x (10m) or 240x (20m). I don't know how to estimate with a technical method but when you have 200 (unsynchronized) validators calling this endpoint, the amount of calls this endpoint will receive is much higher than the individual amount of times.
Eth Signer
This gets any unsigned batches and signs them. This should be based on the cosmos block time, we should allow at least 1 block to pass before re-checking. I suggest 2x.
Relayer
For this one we want to allow at least 1 Eth block to pass between calls.
Faster checking means a validator could be more competitive while trying to be the first to detect the contract state changes and sending new batches; but that would be at the expense of possibly more invalid TXs and more RPC calls to the Ethereum node and the Cosmos node.
Proposal
Given that the only loop that could provide with some competitive advantage is the Relayer loop we should consider adding a flag to modify this one with a default value of 3x. Could be something like: --relayer-loop-multiplier=1.2
The other loops can be hardcoded as multiples of the base times.
EDIT:
We need to have --requester-loop-multiplier
to make e2e tests go faster. A sensible default for a network would be 60 blocks (5m) but for a e2e test we want this to go as fast as possible.
On production, this flag won't have much use, although we might want to adjust it from time to time according to the number of TXs.
Low volume of TXs: means fewer TXs in the outgoing pool; we might want to make this value larger so we don't create too many small batches.
High volume of TXs: means more TXs in the outgoing pool; we might want to make this value smaller so we don't let too many TXs pile up in the outgoing pool.
For Admin Use