Skip to content

Commit 83316db

Browse files
authored
Merge pull request #43 from aeternity/vote_transactions
Describe different vote types
2 parents 8817fd4 + 3a245a8 commit 83316db

File tree

1 file changed

+135
-72
lines changed

1 file changed

+135
-72
lines changed

Periodically-Syncing-HyperChains.md

Lines changed: 135 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -814,115 +814,178 @@ The main objectives of this proposal are:
814814

815815
#### BFT Voting Process
816816

817-
The BFT voting process involves three main phases: Proposal, Voting, and Finalization. Each phase leverages vote transactions to encode necessary information, enabling producers to communicate and reach consensus.
817+
##### Vote types
818+
1. **Fork**: a vote on which fork to follow
819+
2. **Speed of chain**: vote on the speed of the chain using the epoch delta length (positive to slow down, negative to speed up).
820+
821+
The BFT voting process involves three main phases: Proposal, Voting, and Finalization. Each phase utilizes vote transactions to communicate and reach consensus.
818822

819823
1. **Proposal Phase**:
820-
- At the end of each epoch, a designated producer (i.e., the last leader) initiates the fork selection process by broadcasting a "Fork Proposal" vote transaction.
821-
- The transaction is added to the vote pool, making it visible to all validators.
824+
- At the end of each epoch, a designated producer (i.e., the last leader) initiates the fork selection process by broadcasting:
825+
- A Fork Proposal transaction.
826+
- A Speed of Chain Proposal transaction (for proposing changes to epoch length).
827+
- The proposal transactions are added to the vote pool, making them visible to all validators.
822828

823829
2. **Voting Phase**:
824-
- Producers monitor the vote pool for "Fork Proposal" vote transactions. Upon detecting a proposal, they verify the details and decide whether to support the proposed fork.
825-
- Producers create "Vote" transactions, which are also vote transactions with fields indicating their vote for the proposed fork. These vote transactions are broadcast to the network and added to the vote pool.
830+
- Producers monitor the vote pool for incoming proposal transactions.
831+
- Upon detecting valid proposals, they verify the contents and broadcast their Vote transactions indicating support for:
832+
- The proposed fork.
833+
- The proposed epoch length delta.
826834

827835
3. **Finalization Phase**:
828-
- If producers observes that a particular fork has received more than two-thirds of the total stake in votes, they generate a "Commit" vote, indicating their support for the final decision.
829-
- Once a quorum is reached, the leader creates a "Finalize" contract call transaction on chain to confirm the chosen fork.
836+
- If a proposal gathers support from more than two-thirds of the total stake, producers generate a Commit vote.
837+
- Once a quorum is reached:
838+
- The current leader creates a Finalize contract call on-chain for the fork (finalize_epoch).
839+
- The leader also finalizes the epoch delta using finalize_epoch_length if applicable.
830840

831841
#### Detailed Transaction Encoding
832842

833-
1. **Fork Proposal Transaction**
843+
1. **Proposal transactions**
844+
1. ***Fork Proposal Transaction***
845+
846+
A Fork Proposal transaction is a standard vote transaction with a minimal amount, sent from the producer to themselves, containing the proposal details in the fields.
847+
848+
**Structure of Fork Proposal Transaction:**
849+
```plaintext
850+
voter_id: ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...
851+
epoch:42
852+
type:1
853+
data:
854+
block_hash:abc123def456ghi789
855+
signature:sg_7bf3c4e5d62a8e...
856+
```
834857

835-
A Fork Proposal transaction is a standard vote transaction with a minimal amount, sent from the producer to themselves, containing the proposal details in the fields.
858+
- **Voter Id**: The public address of the proposing producer.
859+
- **Epoch**: The epoch number for which the proposal is made.
860+
- **Type**: `1` indicates the transaction is a fork proposal.
861+
- **Block Hash**: The hash of the proposed fork head.
862+
- **Signature**: The producer’s digital signature to ensure authenticity.
836863

837-
**Structure of Fork Proposal Transaction:**
864+
2. **Speed of Chain Proposal Transaction**
838865

839-
```plaintext
840-
voter_id: ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...
841-
epoch:42
842-
type:1
843-
data:
844-
block_hash:abc123def456ghi789
845-
block_height:100000
846-
signature:sg_7bf3c4e5d62a8e...
847-
justification:Chosen for stability
848-
```
849-
- **Voter Id**: The public address of the proposing producer.
850-
- **Epoch**: The epoch number for which the proposal is made.
851-
- **Type**: `1` indicates the transaction is a fork proposal.
852-
- **Block Hash**: The hash of the proposed fork head.
853-
- **Block Height**: The block height of the proposed fork. (Maybe not necessary given epoch)
854-
- **Signature**: The producer’s digital signature to ensure authenticity.
855-
- **Justification**: Optional reasoning for selecting the fork.
866+
A Speed of Chain Proposal transaction is a standard vote transaction with a minimal amount, sent from the producer to themselves, containing the proposal details in the fields.
856867

868+
**Structure of Speed of Chain Proposal Transaction:**
869+
870+
```plaintext
871+
voter_id: ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...
872+
epoch:42
873+
type:4
874+
data:
875+
epoch_length_delta:2
876+
signature:sg_7bf3c4e5d62a8e...
877+
```
878+
879+
- **Voter Id**: The public address of the proposing producer.
880+
- **Epoch**: The epoch number for which the proposal is made.
881+
- **Type**: `4` indicates the transaction is a Speed of Chain Proposal Transaction.
882+
- **Signature**: The producer’s digital signature to ensure authenticity.
857883

858884
2. **Voting and Commit Transactions**
859885

860-
Producers use spend transactions to cast their votes and commit to the final decision. Each transaction includes an encoded payload specifying the vote or commit.
886+
Producers use vote transactions to cast their votes and commit to the final decision. Each transaction includes an payload specifying the vote or commit.
861887

862888
They also vote on adjusting the next epoch length see [Epochs](#epochs).
863889

864-
**Vote Payload Example:**
865-
866-
```plaintext
867-
voter_id: ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...
868-
epoch:42
869-
type:2
870-
data:
871-
block_hash:abc123def456ghi789
872-
epoch_length_delta:2
873-
signature:sg_7bf3c4e5d62a8e...
874-
```
875-
876-
- **Voter Id**: The public address of the proposing producer.
877-
- **Epoch**: The epoch number being voted on.
878-
- **Type**: `2` indicates the transaction is a vote.
879-
- **Block Hash**: The block hash for which the vote is cast.
880-
- **Epoch length adjustment**: +/- N blocks. Increase or decrease the next cycle epoch length.
881-
- **Signature**: The digital signature of the producer.
882-
883-
**Commit Payload Example:**
884-
885-
```plaintext
886-
voter_id: ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...
887-
epoch:42
888-
type:3
889-
data:
890-
block_hash:abc123def456ghi789
891-
epoch_length_delta:2
892-
signature:sg_7bf3c4e5d62a8e...
893-
```
894-
895-
- **Type**: `3` indicates the transaction is a commit.
896-
- **Other fields**: Same as the vote transaction.
890+
**Fork Vote Payload Example:**
891+
892+
```plaintext
893+
voter_id: ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...
894+
epoch:42
895+
type:2
896+
data:
897+
block_hash:abc123def456ghi789
898+
signature:sg_7bf3c4e5d62a8e...
899+
```
900+
901+
- **Voter Id**: The public address of the proposing producer.
902+
- **Epoch**: The epoch number being voted on.
903+
- **Type**: `2` indicates the transaction is a vote.
904+
- **Block Hash**: The block hash for which the vote is cast.
905+
- **Signature**: The digital signature of the producer.
906+
907+
908+
**Speed of Chain Vote Payload Example:**
909+
910+
```plaintext
911+
voter_id: ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...
912+
epoch:42
913+
type:5
914+
data:
915+
epoch_length_delta:2
916+
signature:sg_7bf3c4e5d62a8e...
917+
```
918+
919+
- **Voter Id**: The public address of the proposing producer.
920+
- **Epoch**: The epoch number being voted on.
921+
- **Type**: `5` indicates the transaction is a vote.
922+
- **Epoch length adjustment**: +/- N blocks. Increase or decrease the next cycle epoch length.
923+
- **Signature**: The digital signature of the producer.
924+
925+
**Fork Commit Payload Example:**
926+
927+
```plaintext
928+
voter_id: ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...
929+
epoch:42
930+
type:3
931+
data:
932+
block_hash:abc123def456ghi789
933+
signature:sg_7bf3c4e5d62a8e...
934+
```
935+
936+
- **Type**: `3` indicates the transaction is a commit.
937+
- **Other fields**: Same as the fork vote transaction.
938+
939+
**Speed of Chain Commit Payload Example:**
940+
941+
```plaintext
942+
voter_id: ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...
943+
epoch:42
944+
type:6
945+
data:
946+
epoch_length_delta:2
947+
signature:sg_7bf3c4e5d62a8e...
948+
```
949+
950+
- **Type**: `6` indicates the transaction is a commit.
951+
- **Other fields**: Same as the speed of chain vote transaction.
897952
898953
Producers create and broadcast these transactions, using the transaction pool to share their votes and commits.
899954
900955
3. **Finalization Process**
901956
902-
- Once the current producer detects that a quorum has been reached (two-thirds of the total stake), the leader generate a `finalize_epoch` call transaction on chain.
903-
- This transaction is a call to the leader election contract that confirms the chosen fork.
904-
- After finalization, the validators update their local states to reflect the newly chosen fork and continue with the next epoch. Ignoring any fork they previously thought was good.
957+
- Once the current producer detects that a quorum has been reached (two-thirds of the total stake), the leader generates a `finalize_epoch` call transaction on chain in the case of a fork vote or `finalize_epoch_length` in the case of a epoch delta vote.
958+
- These transactions are calls to leader election contract that confirms the chosen fork and/or epoch delta.
959+
- After finalization, the validators update their local states to reflect the newly chosen fork, adjust the epoch length and continue with the next epoch. Ignoring any fork they previously thought was good.
905960
906961
907962
1. **Detecting Quorum**:
908-
- Each producer monitors the transaction pool for incoming "Vote" transactions. When a producer observes that a fork has received votes representing at least two-thirds of the total stake, it concludes that a quorum has been reached for that fork.
963+
- Each producer monitors the transaction pool for incoming "Vote" transactions. When a producer observes that a proposal has received votes representing at least two-thirds of the total stake, it concludes that a quorum has been reached for that proposal.
909964
910-
2. **Creating the "Finalize" Transaction**:
911-
- Once a quorum is detected, the leader creates a "Finalize" transaction. This is an on chain contract
965+
2. **Creating the "Finalize" Transactions**:
966+
- Once a quorum is detected for the fork proposal, the leader creates a "Finalize" transaction. This is an on chain contract
912967
call to the election contract `finalize_epoch`.
913968
- The arguments are:
914969
- **Epoch**: The epoch number for which the finalization is being done.
915970
- **Chosen Fork**: The block hash of the chosen fork.
916-
- **new_epoch_length**: The length of the next epoch calculated by multiplying submitted deltas
917-
by staking percentage rounded towards 0 + current length.
918-
- **pc_root_hash**: The root hash at PC the given PC height that is used as seed for leader election.
971+
- **pc_root_hash**: The root hash at PC the given PC height that is used as seed for leader election.
919972
- **Producer**: The address of the producer creating the finalization transaction.
920973
- **Votes Proof**: A list of votes from other producers, each containing their transaction payloads.
921974
- The block hash they voted for.
922-
- The epoch length deltas.
923975
- The producer’s address.
924976
- The producer’s signature.
925-
- The call is obviously signed by the producer creating the finalization transaction to ensure authenticity, as with any transaction/contract call. This is the same leader that is
977+
- Once a quorum is detected for the chain speed proposal, the leader creates a "Finalize" transaction. This is an on chain contract
978+
call to the election contract `finalize_epoch_length`.
979+
- The arguments are:
980+
- **Epoch**: The epoch number for which the finalization is being done.
981+
- **new_epoch_length**: The length of the next epoch calculated adding proposed delta to the current length.
982+
- **pc_root_hash**: The root hash at PC the given PC height that is used as seed for leader election.
983+
- **Producer**: The address of the producer creating the finalization transaction.
984+
- **Votes Proof**: A list of votes from other producers, each containing their transaction payloads.
985+
- The epoch length delta they voted for.
986+
- The producer’s address.
987+
- The producer’s signature.
988+
- The calls are obviously signed by the producer creating the finalization transactions to ensure authenticity, as with any transaction/contract call. This is the same leader that is
926989
producing the block so the transaction will not be refused. A correct call should give a reward.
927990
an illegal call can be challenged and result in a penalty.
928991

0 commit comments

Comments
 (0)