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: docs/pos/architecture/bor/index.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,55 +1,55 @@
1
-
Bor is an integral component of the Polygon network that operates based on principles derived from the Clique consensus protocol, detailed in [EIP-225](https://eips.ethereum.org/EIPS/eip-225). This consensus model is characterized by predefined block producers who collectively participate in a voting process to appoint new producers, taking turns in block generation.
1
+
Bor is an integral component of the Polygon network that operates based on principles derived from the *Clique consensus protocol*, detailed in [EIP-225](https://eips.ethereum.org/EIPS/eip-225). This consensus model is characterized by predefined block producers who collectively participate in a voting process to appoint new producers, taking turns in block generation.
2
2
3
-
## Proposers and Producers Selection
3
+
## Proposers and producers selection
4
4
5
-
Block Producers for the Bor layer are a committee selected from the validator pool on the basis of their stake, which happens at regular intervals and is shuffled periodically. These intervals are decided by the Validator's governance with regard to dynasty and network.
5
+
Block producers for the Bor layer are a committee selected from the validator pool on the basis of their stake, which happens at regular intervals and is shuffled periodically. These intervals are decided by the validator's governance with regard to dynasty and network.
6
6
7
-
The ratio of Stake/Staking power specifies the probability to be selected as a member of the block producer committee.
7
+
The ratio of stake/staking power specifies the probability to be selected as a member of the block producer committee.
8
8
9
-
#### Selection Process
9
+
#### Selection process
10
10
11
11
1. Validators are given slots proportionally according to their stake.
12
12
2. Using historical Ethereum block data as seed, we shuffle this array.
13
13
3. Now depending on Producer count*(maintained by validator's governance)*, validators are taken from the top.
14
14
4. Using this validator set and Tendermint's proposer selection algorithm, we choose a producer for every sprint on Bor.
15
15
16
-
## Detailed Mechanics of Bor Consensus
16
+
## Detailed mechanics of Bor consensus
17
17
18
-
### Validators in Polygon's Proof-of-Stake System
18
+
### Validators in Polygon's Proof-of-Stake system
19
19
20
20
In Polygon's Proof-of-Stake (PoS) framework, participants can stake MATIC tokens on a designated Ethereum smart contract, known as the "staking contract," to become validators. Active validators on Heimdall are eligible for selection as block producers through the Bor module.
21
21
22
-
### Span: Defining Validator Sets and Voting Power
22
+
### Span: Defining validator sets and voting power
23
23
24
24
A span is a defined set of blocks, during which a specific subset of validators is selected from the broader validator pool. Heimdall provides intricate details of each span through its span-details APIs. Within a span, each validator is assigned a certain voting power. The probability of a validator being chosen as a block producer is directly proportional to their voting power. The selection algorithm for block producers is borrowed from Tendermint's consensus protocol.
25
25
26
-
### Sprint: Single Block Producer Selection within a Span
26
+
### Sprint: Single block producer selection within a span
27
27
28
28
Within a span, a sprint is a smaller subset of blocks. For each sprint, only one block producer is selected to generate blocks. The size of a sprint is a fraction of the overall span size. Bor also designates backup producers, ready to step in if the primary producer is unable to fulfill its role.
29
29
30
-
### Block Authorization by Producers
30
+
### Block authorization by producers
31
31
32
32
Block producers in Bor are also referred to as signers. To authorize a block, a producer signs the block's hash, encompassing all components of the block header except the signature itself. This signature is generated using the `secp256k1` elliptic curve algorithm and is appended to the `extraData` field of the block header.
33
33
34
34
Each block is assigned a difficulty level. Blocks signed in-turn (by the designated producer) are given a higher difficulty (`DIFF_INTURN`) compared to out-of-turn signatures (`DIFF_NOTURN`).
35
35
36
-
#### Handling Out-of-Turn Signing
36
+
#### Handling out-of-turn signing
37
37
38
38
Bor selects multiple backup producers to address situations where the designated producer fails to generate a block. This failure could be due to various reasons, including technical issues, intentional withholding, or other disruptions. The backup mechanism is activated based on a sequential order of validators and a predefined delay known as the "wiggle" time.
39
39
40
-
#### Wiggle Time: Delay before Backup Production
40
+
#### Wiggle time: Delay before backup production
41
41
42
42
Wiggle time is the predefined delay a backup producer waits before starting to generate a block. This delay is calculated based on the last block's production time and a variable parameter known as `Period`. The wiggle time is dynamically adjusted based on the position of the backup producer in the validator sequence relative to the designated producer's position.
43
43
44
-
#### Resolving Forks with Difficulty Metrics
44
+
#### Resolving forks with difficulty metrics
45
45
46
46
The potential for forks arises when backup producers generate blocks due to delays in block propagation. Bor addresses this by selecting the fork with the highest cumulative difficulty, reflecting the sequence of in-turn block production. The difficulty of a block is determined based on the validator's turn to produce the block, with in-turn production assigned the highest difficulty.
47
47
48
-
### View Change and Span Commitment
48
+
### View change and span commitment
49
49
50
50
At the end of each span, Bor undergoes a view change, fetching new producers for the subsequent span. This involves an HTTP call to the Heimdall node to retrieve new span data and a `commitSpan` call to the `BorValidatorSet` genesis contract. Block headers in Bor are also structured to include producer bytes, aiding in the fast-syncing process.
51
51
52
-
### State Synchronization with the Ethereum Chain
52
+
### State synchronization with the Ethereum chain
53
53
54
54
Bor features a mechanism to relay specific events from the Ethereum chain to Bor. This involves:
Copy file name to clipboardExpand all lines: docs/pos/architecture/bor/state-sync.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
`State Sync` is the native mechanism for a user in the Polygon PoS chain to read the latest Ethereum data.
1
+
`State sync` is the native mechanism for a user in the Polygon PoS chain to read the latest Ethereum data.
2
2
3
3
Validators on the Heimdall layer pickup the [StateSynced](https://github.com/maticnetwork/contracts/blob/a4c26d59ca6e842af2b8d2265be1da15189e29a4/contracts/root/stateSyncer/StateSender.sol#L24) event and pass it on to the Bor layer.
4
4
@@ -8,7 +8,7 @@ This is the flow required from dapps / users to work with state-sync:
8
8
9
9
1. Call the smart contract function present here: [https://github.com/maticnetwork/contracts/blob/19163ddecf91db17333859ae72dd73c91bee6191/contracts/root/stateSyncer/StateSender.sol#L33](https://github.com/maticnetwork/contracts/blob/19163ddecf91db17333859ae72dd73c91bee6191/contracts/root/stateSyncer/StateSender.sol#L33)
10
10
2. Which emits an event called `StateSynced(uint256 indexed id, address indexed contractAddress, bytes data);`
11
-
3. All the validators on the Heimdall chain receive this event and one of them, whoever wishes to get the tx fees for state sync sends this transaction to Heimdall.
11
+
3. All the validators on the Heimdall chain receive this event and one of them, whoever wishes to get the transaction fees for state sync sends this transaction to Heimdall.
12
12
4. Once `state-sync` transaction on Heimdall has been included in a block, it is added to pending state-sync list.
13
13
5. After every sprint on `bor`, the Bor node fetches the pending state-sync events from Heimdall via an API call.
14
14
6. The receiver contract inherits `IStateReceiver` interface, and custom logic of decoding the data bytes and performing any action sits inside `onStateReceive` function: [https://github.com/maticnetwork/genesis-contracts/blob/master/contracts/IStateReceiver.sol](https://github.com/maticnetwork/genesis-contracts/blob/master/contracts/IStateReceiver.sol)
@@ -55,7 +55,7 @@ event StateSynced (
55
55
);
56
56
```
57
57
58
-
Once the `StateSynced` event is emitted on the `stateSender` contract on Ethereum, Heimdall listens to those events and adds to the Heimdall state after 2/3+ validators agree on the.
58
+
Once the `StateSynced` event is emitted on the `stateSender` contract on Ethereum, Heimdall listens to those events and adds to the Heimdall state after $2/3+$ validators agree on the.
59
59
60
60
After every sprint (currently 16 blocks on Bor), Bor fetches a new state-sync record and updates the state using a `system` call. Here is the code for the same: [https://github.com/maticnetwork/bor/blob/6f0f08daecaebbff44cf18bee558fc3796d41832/consensus/bor/genesis_contracts_client.go#L51](https://github.com/maticnetwork/bor/blob/6f0f08daecaebbff44cf18bee558fc3796d41832/consensus/bor/genesis_contracts_client.go#L51)
61
61
@@ -85,10 +85,10 @@ System call is helpful to change state to contract without making any transactio
85
85
86
86
Events emitted by system calls are handled in a different way than normal logs. Here is the code: [https://github.com/maticnetwork/bor/pull/90](https://github.com/maticnetwork/bor/pull/90).
87
87
88
-
Bor produces a new tx / receipt just for the client which includes all the logs for state-sync. Tx hash is derived from block number and block hash (last block at that sprint):
88
+
Bor produces a new transaction/receipt just for the client which includes all the logs for state-sync. Transaction hash is derived from block number and block hash (last block at that sprint):
89
89
90
90
```jsx
91
91
keccak256("matic-bor-receipt-"+ block number + block hash)
92
92
```
93
93
94
-
This doesn't change any consensus logic, only client changes. `eth_getBlockByNumber`, `eth_getTransactionReceipt`, and `eth_getLogs` include state-sync logs with derived. Note that the bloom filter on the block doesn't include inclusion for state-sync logs. It also doesn't include derived tx in `transactionRoot` or `receiptRoot`.
94
+
This doesn't change any consensus logic, only client changes. `eth_getBlockByNumber`, `eth_getTransactionReceipt`, and `eth_getLogs` include statesync logs with derived. Note that the bloom filter on the block doesn't include inclusion for statesync logs. It also doesn't include derived transaction in `transactionRoot` or `receiptRoot`.
Copy file name to clipboardExpand all lines: docs/pos/architecture/heimdall/governance.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
Heimdall's governance operates identically to the Cosmos-sdk `x/gov` module, as detailed in [Cosmos-sdk documentation](https://docs.cosmos.network/main/build/modules/gov).
1
+
Heimdall's governance operates identically to the Cosmos SDK `x/gov` module, as detailed in [Cosmos SDK documentation](https://docs.cosmos.network/main/build/modules/gov).
Copy file name to clipboardExpand all lines: docs/pos/architecture/heimdall/index.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,9 @@ Heimdall is the heart of the Polygon PoS network. It performs the following func
5
5
- Manages validators
6
6
- Handles block producer selection
7
7
- Facilitates spans
8
-
- Orchestrates the state-sync mechanism between Ethereum and Matic
8
+
- Orchestrates the statesync mechanism between Ethereum and Polygon PoS
9
9
- Addresses other essential aspects of the system
10
10
11
-
It uses the *Cosmos-SDK* and a forked version of Tendermint, called *Peppermint*. Here is the Peppermint source: [https://github.com/maticnetwork/tendermint/tree/peppermint](https://github.com/maticnetwork/tendermint/tree/peppermint)
11
+
It uses the *CosmosSDK* and a forked version of Tendermint, called *Peppermint*. Here is the Peppermint source: [https://github.com/maticnetwork/tendermint/tree/peppermint](https://github.com/maticnetwork/tendermint/tree/peppermint)
12
12
13
-
Heimdall removes certain modules from Cosmos-SDK but primarily utilizes a customized version of it, following a similar pattern.
13
+
Heimdall removes certain modules from CosmosSDK but primarily utilizes a customized version of it, following a similar pattern.
0 commit comments