Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gitferry committed Nov 17, 2024
1 parent 988d610 commit 8732f15
Showing 1 changed file with 32 additions and 23 deletions.
55 changes: 32 additions & 23 deletions docs/send-finality-vote.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,51 @@
Finality providers submit votes to finalize blocks on the consumer chain.
This document specifies the process of submitting finality votes.

## Internal State
## Submission Process

The finality provider maintains two critical persistent states:
### Internal State

- Last voted height
- Last processed height
The finality provider maintains a persistent state variable `lastVotedHeight`
to track the most recent height where a finality vote was successfully submitted
This is to prevent voting for a previously voted height.

### Last voted height
### Bootstrapping

Tracks the most recent height for which a finality vote was successfully
submitted. This prevents duplicate voting on previously voted heights.
To determine the initial processing height `startHeight`:

### Last processed height
1. Query consumer chain for:
- `lastFinalizedHeight` (defaults to `0` if no blocks are finalized)
- `finalityActivationHeight`
- `lastVotedHeightRemote` (defaults to `0` if no votes exist)

Tracks the most recent height for which a voting decision was made
(whether the decision was to vote or not).
By definition, `LastProcessedHeight >= LastVotedHeight` always holds.
2. Synchronize local state:
- Verify local `lastVotedHeight` >= `lastVotedHeightRemote`
- If verification fails, update local state to match remote

## Submission Process
3. Calculate starting height based on reward distribution policy:
- If rewards are available for already finalized blocks:

### Bootstrapping
```go
startHeight = max(lastVotedHeight + 1, finalityActivationHeight)
```

- If rewards are only for unfinalized blocks:

To determine the initial processing height:
```go
startHeight = max(lastFinalizedHeight + 1, finalityActivationHeight)
```

1. Query consumer chain for `lastFinalizedHeight` (`0` if no finalized blocks)
2. Query consumer chain for `finalityActivationHeight`:
3. Query `lastVotedHeightRemote` from consumer chain (`0` if no votes are sent)
4. Synchronize local state:
- Ensure local `lastVotedHeight` and `lastProcessedHeight``lastVotedHeightRemote`
5. Begin processing at:
- `max(lastProcessedHeight + 1, lastFinalizedHeight + 1, finalityActivationHeight)`
The choice between using `lastVotedHeight` or `lastFinalizedHeight` depends on
the consumer chain's reward distribution mechanism.
Use `lastVotedHeight` if the chain allows collecting rewards for already
finalized blocks. Otherwise, use `lastFinalizedHeight` to only process
unfinalized blocks.
### Normal Submission Loop
After the finality provider is bootstraped, it continuously monitors for
new blocks. For each new block, it performs these validation checks:
After the finality provider is bootstrap, it continuously monitors for
new blocks from a trusted full node of the consumer chain.
For each new block, it performs these validation checks:
1. Block hasn't been previously processed
2. Block height exceeds finality activation height
Expand Down

0 comments on commit 8732f15

Please sign in to comment.