You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Periodically-Syncing-HyperChains.md
+46-30Lines changed: 46 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -858,43 +858,48 @@ A Byzantine Fault Tolerant (BFT) voting mechanism is proposed to allow producers
858
858
859
859
The main objectives of this proposal are:
860
860
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.
864
863
865
864
#### BFT Voting Process
866
865
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.
868
867
869
868
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.
872
871
873
872
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.
876
875
877
876
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.
880
879
881
880
#### Detailed Transaction Encoding
882
881
883
882
1.**Fork Proposal Transaction**
884
883
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.
886
885
887
886
**Structure of Fork Proposal Transaction:**
888
887
889
888
```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
891
897
```
892
-
893
-
-**Type**: `"fork_proposal"` indicates the transaction is a fork proposal.
898
+
-**Voter Id**: The public address of the proposing producer.
894
899
-**Epoch**: The epoch number for which the proposal is made.
900
+
-**Type**: `1` indicates the transaction is a fork proposal.
895
901
-**Block Hash**: The hash of the proposed fork head.
896
902
-**Block Height**: The block height of the proposed fork. (Maybe not necessary given epoch)
897
-
-**Producer**: The public address of the proposing producer.
898
903
-**Signature**: The producer’s digital signature to ensure authenticity.
899
904
-**Justification**: Optional reasoning for selecting the fork.
900
905
@@ -903,35 +908,47 @@ The BFT voting process involves three main phases: Proposal, Voting, and Finaliz
903
908
904
909
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.
905
910
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).
-**Type**: `"commit"` indicates the transaction is a commit.
944
+
-**Type**: `3` indicates the transaction is a commit.
928
945
-**Other fields**: Same as the vote transaction.
929
946
930
947
Producers create and broadcast these transactions, using the transaction pool to share their votes and commits.
931
948
932
949
3.**Finalization Process**
933
950
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.
935
952
- This transaction is a call to the leader election contract that confirms the chosen fork.
936
953
- 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.
937
954
@@ -940,7 +957,7 @@ The BFT voting process involves three main phases: Proposal, Voting, and Finaliz
940
957
- 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.
941
958
942
959
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
944
961
call to the election contract `finalize_epoch`.
945
962
- The arguments are:
946
963
-**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
971
988
972
989
##### Setting Timeouts
973
990
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.
976
992
When calculation the leader schedule for one epoch we also calculate 5 more leaders past the last leader.
977
993
If the last leader doesn't start the voting in time the next leader can start the voting instead.
978
994
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.
980
996
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.
982
998
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.)
984
1000
985
1001
##### 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.
987
1003
988
1004
##### Handling Minority Vote in Finalization
989
1005
990
1006
If a validator ignores some votes and attempts to create a minority vote in the finalization process, the following steps can be taken:
991
1007
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.
993
1009
994
1010
-**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
995
1011
deposit is less than the minimum temporarily banning them from participating in future consensus rounds.
0 commit comments