Skip to content

Commit 6013c50

Browse files
authored
Merge pull request #40 from aeternity/vote_transactions
Change BFT description
2 parents de863b6 + 2ce5352 commit 6013c50

File tree

1 file changed

+46
-30
lines changed

1 file changed

+46
-30
lines changed

Periodically-Syncing-HyperChains.md

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -858,43 +858,48 @@ A Byzantine Fault Tolerant (BFT) voting mechanism is proposed to allow producers
858858

859859
The main objectives of this proposal are:
860860

861-
1. **Utilize Existing Mechanisms**: Implement the BFT voting process using existing transaction types (spend transactions) to avoid protocol changes.
862-
2. **Ensure Security and Decentralization**: Provide a secure method for producers to propose and vote on forks without relying on centralized authorities.
863-
3. **Maintain Efficiency**: Use minimal overhead to keep transaction costs low while ensuring robust consensus.
861+
1. **Ensure Security and Decentralization**: Provide a secure method for producers to propose and vote on forks without relying on centralized authorities.
862+
2. **Maintain Efficiency**: Use minimal overhead to keep transaction costs low while ensuring robust consensus.
864863

865864
#### BFT Voting Process
866865

867-
The BFT voting process involves three main phases: Proposal, Voting, and Finalization. Each phase leverages spend transactions to encode necessary information, enabling producers to communicate and reach consensus.
866+
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.
868867

869868
1. **Proposal Phase**:
870-
- At the end of each epoch, a designated producer (e.g., the last leader) initiates the fork selection process by broadcasting a "Fork Proposal" transaction. This transaction is a standard spend transaction with an encoded payload that contains the details of the proposed fork.
871-
- The transaction is added to the transaction pool, making it visible to all validators.
869+
- 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.
870+
- The transaction is added to the vote pool, making it visible to all validators.
872871

873872
2. **Voting Phase**:
874-
- Producers monitor the transaction pool for "Fork Proposal" transactions. Upon detecting a proposal, they verify the details and decide whether to support the proposed fork.
875-
- Producers create "Vote" transactions, which are also spend transactions with an encoded payload indicating their vote for a particular fork. These transactions are broadcast to the network and added to the transaction pool.
873+
- 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.
874+
- 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.
876875

877876
3. **Finalization Phase**:
878-
- If producers observes that a particular fork has received more than two-thirds of the total stake in votes, they generate a "Commit" transaction, indicating their support for the final decision.
879-
- Once a quorum is reached, the leader create a "Finalize" transactions to confirm the chosen fork. The finalization messages are broadcast to the network, signaling that consensus has been reached.
877+
- 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.
878+
- Once a quorum is reached, the leader creates a "Finalize" contract call transaction on chain to confirm the chosen fork.
880879

881880
#### Detailed Transaction Encoding
882881

883882
1. **Fork Proposal Transaction**
884883

885-
A Fork Proposal transaction is a standard spend transaction with a minimal amount, sent from the producer to themselves, containing the proposal details in the payload.
884+
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.
886885

887886
**Structure of Fork Proposal Transaction:**
888887

889888
```plaintext
890-
fork_proposal|epoch:42|block_hash:abc123def456ghi789|block_height:100000|producer:ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...|signature:sg_7bf3c4e5d62a8e...|justification:Chosen for stability
889+
voter_id: ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...
890+
epoch:42
891+
type:1
892+
data:
893+
block_hash:abc123def456ghi789
894+
block_height:100000
895+
signature:sg_7bf3c4e5d62a8e...
896+
justification:Chosen for stability
891897
```
892-
893-
- **Type**: `"fork_proposal"` indicates the transaction is a fork proposal.
898+
- **Voter Id**: The public address of the proposing producer.
894899
- **Epoch**: The epoch number for which the proposal is made.
900+
- **Type**: `1` indicates the transaction is a fork proposal.
895901
- **Block Hash**: The hash of the proposed fork head.
896902
- **Block Height**: The block height of the proposed fork. (Maybe not necessary given epoch)
897-
- **Producer**: The public address of the proposing producer.
898903
- **Signature**: The producer’s digital signature to ensure authenticity.
899904
- **Justification**: Optional reasoning for selecting the fork.
900905

@@ -903,35 +908,47 @@ The BFT voting process involves three main phases: Proposal, Voting, and Finaliz
903908

904909
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.
905910

906-
Thy also vote on adjusting the next epoch length see [Epochs](#epochs).
911+
They also vote on adjusting the next epoch length see [Epochs](#epochs).
907912

908913
**Vote Payload Example:**
909914

910915
```plaintext
911-
vote|epoch:42|block_hash:abc123def456ghi789|epoch_length_delta:+2|producer:ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...|signature:sg_7bf3c4e5d62a8e...
916+
voter_id: ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...
917+
epoch:42
918+
type:2
919+
data:
920+
block_hash:abc123def456ghi789
921+
epoch_length_delta:2
922+
signature:sg_7bf3c4e5d62a8e...
912923
```
913924

914-
- **Type**: `"vote"` indicates the transaction is a vote.
925+
- **Voter Id**: The public address of the proposing producer.
915926
- **Epoch**: The epoch number being voted on.
927+
- **Type**: `2` indicates the transaction is a vote.
916928
- **Block Hash**: The block hash for which the vote is cast.
917929
- **Epoch length adjustment**: +/- N blocks. Increase or decrease the next cycle epoch length.
918-
- **Producer**: The address of the voting producer.
919930
- **Signature**: The digital signature of the producer.
920931

921932
**Commit Payload Example:**
922933

923934
```plaintext
924-
commit|epoch:42|block_hash:abc123def456ghi789|producer:ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...|signature:sg_7bf3c4e5d62a8e...
935+
voter_id: ak_2cFaGrYvPgsEwMhDPXXrTj2CsW6XrA...
936+
epoch:42
937+
type:3
938+
data:
939+
block_hash:abc123def456ghi789
940+
epoch_length_delta:2
941+
signature:sg_7bf3c4e5d62a8e...
925942
```
926943

927-
- **Type**: `"commit"` indicates the transaction is a commit.
944+
- **Type**: `3` indicates the transaction is a commit.
928945
- **Other fields**: Same as the vote transaction.
929946

930947
Producers create and broadcast these transactions, using the transaction pool to share their votes and commits.
931948

932949
3. **Finalization Process**
933950

934-
- 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.
951+
- 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.
935952
- This transaction is a call to the leader election contract that confirms the chosen fork.
936953
- 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.
937954

@@ -940,7 +957,7 @@ The BFT voting process involves three main phases: Proposal, Voting, and Finaliz
940957
- 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.
941958

942959
2. **Creating the "Finalize" Transaction**:
943-
- Once a quorum is detected, the leader creates a "Finalize" transaction. This is a contract
960+
- Once a quorum is detected, the leader creates a "Finalize" transaction. This is an on chain contract
944961
call to the election contract `finalize_epoch`.
945962
- The arguments are:
946963
- **Epoch**: The epoch number for which the finalization is being done.
@@ -971,25 +988,24 @@ To implement a robust BFT voting mechanism, it's essential to establish clear ru
971988

972989
##### Setting Timeouts
973990

974-
We can define timeouts for each phase of the voting process. These timeouts should be possible to configure
975-
(within some bounds) when initializing a hyperchain.
991+
The timeouts for each phase of the voting process is the child block time.
976992
When calculation the leader schedule for one epoch we also calculate 5 more leaders past the last leader.
977993
If the last leader doesn't start the voting in time the next leader can start the voting instead.
978994

979-
- **Proposal Timeout**: A predefined period (e.g., 10 seconds) within which validators can submit their fork proposals. After this period, no new proposals are accepted.
995+
- **Proposal Timeout**: A predefined period (i.e., child block time) within which the leader can submit it's fork proposal. After this period, no proposal is accepted.
980996

981-
- **Voting Timeout**: A defined period (e.g., 30 seconds) for validators to submit their votes for a fork proposal. This time window allows all validators to observe the proposals and cast their votes. The timeout duration can be set based on the expected network latency and block production time.
997+
- **Voting Timeout**: A defined period (i.e., child block time) for validators to submit their votes for a fork proposal. This time window allows all validators to observe the proposals and cast their votes.
982998

983-
- **Finalization Timeout**: A specified period (e.g., 20 seconds) after the voting phase ends, within which a validator must create and broadcast the "Finalize" transaction. If no finalization occurs within this period, the network takes predefined corrective actions. (The new leader in the next epoch just runs with his preferred fork.)
999+
- **Finalization Timeout**: A specified period (i.e., child block time) after the voting phase ends, within which a validator must create and broadcast the "Finalize" transaction. If no finalization occurs within this period, the network takes predefined corrective actions. (The new leader in the next epoch just runs with his preferred fork.)
9841000

9851001
##### Handling Scenarios Where a Majority is Not Reached
986-
If a quorum (two-thirds of the total stake) is not reached within the voting timeout the next leader in the current epoch .
1002+
If a quorum (two-thirds of the total stake) is not reached within the voting timeout the next leader in the current epoch.
9871003

9881004
##### Handling Minority Vote in Finalization
9891005

9901006
If a validator ignores some votes and attempts to create a minority vote in the finalization process, the following steps can be taken:
9911007

992-
- **Reject Invalid Finalization Transactions**: Validators must verify the "Finalize" transaction against the recorded votes in the transaction pool. If the transaction does not include votes representing at least two-thirds of the total stake, it is considered invalid, and validators should ignore it.
1008+
- **Reject Invalid Finalization Transactions**: Validators must verify the "Finalize" transaction against the recorded votes in the vote pool. If the transaction does not include votes representing at least two-thirds of the total stake, it is considered invalid, and validators should ignore it.
9931009

9941010
- **Slashing Penalties for Malicious Behavior**: If a validator is found to have created a minority "Finalize" transaction deliberately (i.e., one that lacks sufficient proof of a majority), they can be penalized through slashing. This involves reducing the validator's stake (the deposit in the election contract) and if the
9951011
deposit is less than the minimum temporarily banning them from participating in future consensus rounds.

0 commit comments

Comments
 (0)