Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document parallel evm funnel delay/confirmationDepth #39

Merged
merged 4 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions docs/home/300-react-to-events/3-funnel-types/200-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ presyncStepSize: number
```

**Note:** These do *not* default to the value in the corresponding
*environment configuration if not provided. Paima only defaults to the values in
*the ENV file when the entire config file is missing.
environment configuration if not provided. Paima only defaults to the values in
the ENV file when the entire config file is missing.

All the variables except `funnelBlockGroupSize` have the same purpose and
default values as they have in the environment configuration. Please refer to
Expand All @@ -60,6 +60,17 @@ default values as they have in the environment configuration. Please refer to
`funnelBlockGroupSize` it's used to control how many blocks are fetched in a
single request per network, which helps if a network has a lower rate limit.

For `evm-other` there are also some optional settings:

```js
delay: number
confirmationDepth: number
```

The [parallel evm funnel](./500-parallel-evm-funnel.mdx#delayed-network) page
has more details on the meaning of these values, but a guideline is to set the
delay to a value greater than `confirmationDepth * networkBlockProductionSpeed`.

## Example

```yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Merge from "./parallel-evm-funnel-merge.svg";
import MergeDelayed from "./parallel-evm-funnel-merge-delayed.svg";
import ParallelToMain from "./parallel-to-main.svg";
import DataAddition from "./parallel-data-addition.svg";
import Finalized from "./parallel-finalized.svg";
Expand Down Expand Up @@ -40,17 +41,35 @@ Note that it is possible that there are no blocks to merge at a certain point (i

<Merge className="img-full" style={{ height: "auto" }} />

### Delayed network

If the `delay` settings is used, the parallel chain is delayed by this amount of
seconds. In that case the chart above becomes something like the following (with
a delay of 60 seconds).

<MergeDelayed className="img-full" style={{ height: "auto" }} />

This has the effect that no events newer than `current time - delay` will be
processed by the funnel (relative to the main chain's latest synced block).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably explain when to use this vs confirmationDepth (possibly in a common document referenced by multiple funnels like some kind of new meta category for funnel types in the docs that talks about funnel concepts in general as opposed to concrete funnels)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, but first I guess we may also want to change the carp's funnel config, since now it's different than these (it doesn't have delay).

But it's not really a vs thing I believe. In general I would choose the confirmation parameter and then choose the delay accordingly so that it makes progress without waiting for block production all the time. Technically you can set only a delay, but I'm not sure there is actually a use-case for this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a ping that we still need to do something about this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some refactoring and added a page for parallel funnels, which now encompasses all of the funnels that synchronize other chains. I think the term is probably generic enough. And also moved a big chunk of the common sections there, including the diagrams. And then I also added some guidelines for the usage of delay and confirmationDepth.


## Finalizing blocks

We cannot go back in time to add information to old blocks that have already been parsed by the game's state machine.
Therefore, it means that a block can only be considered finalized and ready to be given to the state machine once we're certain we have all the information for all chains being monitored.
The only way for us to know that we have all the information for a block is if the latest timestamp of all networks we're monitoring is more recent (not equal since some networks have multiple blocks with the same timestamp) than the timestamp of the main chain block timestamp we're looking at.
The only way for us to know that we have all the information for a block is if the _latest_ timestamp of all networks we're monitoring is more recent (not equal since some networks have multiple blocks with the same timestamp) than the timestamp of the main chain block timestamp we're looking at.

*Note*: this behavior helps protect apps built with Paima from getting in a bad state. If an RPC you're connecting to for a network gets stuck, it should stop block production for the entire application.
Otherwise, it can break determinism because your node (that is missing events from the parallel chain RPC that is stuck) will see a different block history from somebody else running a node connecting to a properly functioning RPC for that parallel chain.

<Finalized className="img-full" style={{ height: "auto" }} />

### Probabilistic finality

If `confirmationDepth` is set, then the above applies with the difference that
the _latest_ timestamp becomes the timestamp of the block at the height of
`latestBlock.height - confirmationDepth`. In practice this means that the
network should also be delayed to compensate for this.

## Performance implications

Leveraging parallel funnels has multiple performance implications. In some cases the performance impact can be mitigated by [emulated blocks](./400-stable-tick-rate-funnel.mdx),
Expand Down
Loading
Loading