Skip to content

Commit

Permalink
Updating example to 5 epochs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Stenman committed Nov 25, 2024
1 parent a977f3b commit 66ebdc0
Show file tree
Hide file tree
Showing 2 changed files with 208 additions and 139 deletions.
38 changes: 25 additions & 13 deletions Periodically-Syncing-HyperChains.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,48 +166,52 @@ Once a leader is chosen, there is a deterministic way to choose subsequent leade

```mermaid
sequenceDiagram
participant S as Stakeholder/Validator
participant S as Staker (an account address)
participant V as Validator (a node)
participant CC as Child Chain
participant PC as Parent Chain
rect rgb(10,60,10)
note over CC: Staking epoch 1
note over PC: PE(1)
loop for each stakeholder
S->>CC: Stake for Block production epoch
S->>CC: Stake for Block production epoch 4
end
Note left of CC: Stakeholders influence future CC epoch 3 election through staking
Note left of CC: Stakeholders influence future CC epoch 4 election through staking
end
rect rgb(20,80,20)
note over CC: Entropy epoch 2
note over PC: PE(2)
loop for each stakeholder
S->>CC: Stake for Block production epoch
end
Note left of CC: Stakeholders influence future CC epoch 3 election through staking
S->>CC: Stake for Block production epoch 5, next cycle
Note left of CC: (In the next cycle stakeholders influence future CC epoch 5 election through staking)
end
rect rgb(30,100,30)
note over CC: Election epoch 3
note over PC: PE(3)
S->>CC: Validate block
note over CC: Transactions
Note over PC: Finality Zone
S->>CC: Stake for Block production epoch 6, next next cycle
PC->>CC: Seed for Leader Election
end
rect rgb(40,120,40)
note over CC: Block production epoch 4
note over PC: PE(4)
S->>CC: New leaders from epoch 1 stake
V->>CC: New leaders from epoch 1 stake
loop for each validator
V->>CC: Validate block
S->>CC: Stake for Block production epoch 7, next next next cycle
note over CC: Transactions
end
end
rect rgb(50,140,50)
note over CC: Payout epoch 5
note over PC: PE(5)
S->>CC: New leaders from epoch 1 stake
V->>CC: New leaders from epoch 2 stake
CC->>S: Payout of rewards
S->>CC: Stake for Block production epoch 8, next next next next cycle
end
```
Expand Down Expand Up @@ -606,36 +610,42 @@ The start of the chain looks as follows (wait until parent start height is final

epoch 1 (CE<sub>1</sub>):
- **Staking epoch** use the configured stake
- **Entropy Epoch** no actions
- **Leader Election Epoch** ensure finality of `parent_start_height`
- **Block Producer Epoch** use the schedule based upon configured stake s<sub>0</sub> and `parent_start_height` for entropy
- **Payout Epoch** no actions

epoch 2 (CE<sub>2</sub>):
- **Staking epoch** staking distribution s<sub>1</sub> from staking during block producing epoch CE<sub>1</sub>
- **Entropy Epoch** no actions
- **Leader Election Epoch** ensure finality of `parent_start_height`
- **Block Producer Epoch** use the schedule based upon configured stake s<sub>0</sub> and `parent_start_height` for entropy
- **Payout Epoch** use results of CE<sub>1</sub> block production epoch

epoch 3 (CE<sub>3</sub>):
- **Staking epoch** staking distribution s<sub>2</sub> from staking during block producing CE<sub>2</sub>
- **Entropy Epoch** no actions
- **Leader Election Epoch** ensure finality of **first hash of PE<sub>1</sub>** (which is `parent_start height`)
- **Block Producer Epoch** use the schedule based upon configured stake s<sub>0</sub> and `parent_start_height` for entropy
- **Payout Epoch** use results of CE<sub>2</sub>* block production epoch

epoch 4 (CE<sub>4</sub>):
- **Staking epoch** staking distribution s<sub>3</sub> from staking during block producing epoch CE<sub>3</sub>
- **Entropy Epoch** no actions
- **Leader Election Epoch** ensure finality of **first block of PE<sub>2</sub>**
- **Block Producer Epoch** use the schedule based upon configured stake s<sub>0</sub> and **first hash of PE<sub>1</sub>** for entropy
- **Payout Epoch** use results of CE<sub>3</sub> block production epoch

epoch 5 (CE<sub>5</sub>):
- **Staking epoch** staking distribution s<sub>4</sub> from staking during block producing CE<sub>4</sub>
- **Entropy Epoch** no actions
- **Leader Election Epoch** ensure finality of **first block of PE<sub>3</sub>**
- **Block Producer Epoch** use the schedule based upon configured stake s<sub>0</sub> and **first block of PE<sub>2</sub>** for entropy
- **Payout Epoch** use results of CE<sub>4</sub> block production epoch

epoch 6 (CE<sub>6</sub>):
- **Staking epoch** staking distribution s<sub>5</sub> from staking during block producing CE<sub>5</sub>
- **Entropy Epoch** no actions
- **Leader Election Epoch** ensure finality of **first block of PE<sub>4</sub>**
- **Block Producer Epoch** use the schedule based upon **s<sub>1</sub>** and **first block of PE<sub>3</sub>** for entropy
- **Payout Epoch** use results of epoch 5 block production epoch
Expand All @@ -644,8 +654,9 @@ and for the Nth epoch:

epoch N (CE<sub>n</sub>):
- **Staking epoch** staking distribution s<sub>max(n-1, 0)</sub> from staking during block producing CE<sub>max(n-1, 0)</sub>
- **Entropy Epoch** no actions
- **Leader Election Epoch** ensure finality of **first block of PE<sub>max(n-1, 0)</sub>**
- **Block Producer Epoch** use the schedule based upon **s<sub>max(n-5, 0)</sub>** and **first block of PE<sub>max(n-3, 0)</sub>** for entropy
- **Block Producer Epoch** use the schedule based upon **s<sub>max(n-3, 0)</sub>** and **first block of PE<sub>max(n-3, 0)</sub>** for entropy
- **Payout Epoch** use results of epoch n-1 block production epoch


Expand All @@ -657,6 +668,7 @@ tokens staked for the upcoming block production epoch.
schedule using a hash from the parent chain and the `tokens_at_stake` data for all eligible staking contracts.
- The leader election contract stores each validator's `tokens_at_stake`.

See [staking.md](staking.md) for details (to be worked in here).

During the block production epoch, blocks are considered valid only if they are produced by validators who have at least the `tokens_at_stake` in (their deposit in the election contract + their token balance in the staking contract) and at least `MINIMUM_STAKE` deposited in the election contract. (A penalty could bring your balance
below `MINIMUM_STAKE`.)
Expand Down
Loading

0 comments on commit 66ebdc0

Please sign in to comment.