Skip to content

Commit fc405fa

Browse files
committed
PoS: review update
1 parent 3099a36 commit fc405fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+580
-607
lines changed

docs/pos/architecture/bor/commands.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -35,84 +35,84 @@ bor attach .bor/data/bor.ipc <command>
3535
| `heimdalld unsafe-reset-all` | Resets the database in case of issues. |
3636
| `curl localhost:26657/status` | Provides comprehensive information about Heimdall. |
3737

38-
## Node Management Commands
38+
## Node management commands
3939

4040
| Description | Command |
4141
| ------------------------------------- | ---------------------------------------------- |
42-
| **Locate Heimdall genesis file** | `$CONFIGPATH/heimdall/config/genesis.json` |
43-
| **Locate heimdall-config.toml** | `/etc/heimdall/config/heimdall-config.toml` |
44-
| **Locate config.toml** | `/etc/heimdall/config/config.toml` |
45-
| **Locate heimdall-seeds.txt** | `$CONFIGPATH/heimdall/heimdall-seeds.txt` |
46-
| **Start Heimdall** | `$ sudo service heimdalld start` |
47-
| **Start Heimdall rest-server** | `$ sudo service heimdalld-rest-server start` |
48-
| **Start Heimdall bridge-server** | `$ sudo service heimdalld-bridge start` |
49-
| **Locate Bor genesis file** | `$CONFIGPATH/bor/genesis.json` |
50-
| **Start Bor** | `sudo service bor start` |
51-
| **Retrieve Heimdall logs** | `/var/log/matic-logs/` |
52-
| **Check Heimdall logs** | `tail -f heimdalld.log` |
53-
| **Check Heimdall rest-server logs** | `tail -f heimdalld-rest-server.log` |
54-
| **Check Heimdall bridge logs** | `tail -f heimdalld-bridge.log` |
55-
| **Check Bor logs** | `tail -f bor.log` |
56-
57-
## Useful Configuration Commands
58-
59-
### Sync Status of Heimdall
42+
| Locate Heimdall genesis file | `$CONFIGPATH/heimdall/config/genesis.json` |
43+
| Locate heimdall-config.toml | `/etc/heimdall/config/heimdall-config.toml` |
44+
| Locate config.toml | `/etc/heimdall/config/config.toml` |
45+
| Locate heimdall-seeds.txt | `$CONFIGPATH/heimdall/heimdall-seeds.txt` |
46+
| Start Heimdall | `$ sudo service heimdalld start` |
47+
| Start Heimdall rest-server | `$ sudo service heimdalld-rest-server start` |
48+
| Start Heimdall bridge-server | `$ sudo service heimdalld-bridge start` |
49+
| Locate Bor genesis file | `$CONFIGPATH/bor/genesis.json` |
50+
| Start Bor | `sudo service bor start` |
51+
| Retrieve Heimdall logs | `/var/log/matic-logs/` |
52+
| Check Heimdall logs | `tail -f heimdalld.log` |
53+
| Check Heimdall rest-server logs | `tail -f heimdalld-rest-server.log` |
54+
| Check Heimdall bridge logs | `tail -f heimdalld-bridge.log` |
55+
| Check Bor logs | `tail -f bor.log` |
56+
57+
## Useful configuration commands
58+
59+
### Sync Heimdall status
6060

6161
To check if Heimdall is synced, run:
6262

6363
```bash
6464
curl http://localhost:26657/status
6565
```
6666

67-
### Latest Block Height on Heimdall
67+
### Latest block height on Heimdall
6868

6969
To check the latest block height on Heimdall, run:
7070

7171
```bash
7272
curl localhost:26657/status
7373
```
7474

75-
### Latest Block Height on Bor
75+
### Latest block height on Bor
7676

7777
To check the latest block height on Bor, use:
7878

7979
```bash
8080
curl http://<your ip>:8545 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0", "id":1, "method":"bor_getSigners", "params":["0x98b3ea"]}'
8181
```
8282

83-
### Cleanup: Deleting Remnants of Heimdall and Bor
83+
### Cleanup: Deleting remnants of Heimdall and Bor
8484

85-
##### For Linux package:
85+
##### For Linux package
8686

8787
```bash
8888
sudo dpkg -i matic-bor
8989
sudo rm -rf /etc/bor
9090
```
9191

92-
##### For Binaries:
92+
##### For binaries
9393

9494
```bash
9595
sudo rm -rf /etc/bor
9696
sudo rm /etc/heimdall
9797
```
9898

99-
### Terminate Bor Process
99+
### Terminate Bor process
100100

101-
##### For Linux:
101+
##### For Linux package
102102

103103
```bash
104104
ps -aux | grep bor
105105
sudo kill -9 <PID>
106106
```
107107

108-
##### For Binaries:
108+
##### For binaries
109109

110110
```bash
111111
cd CS-2003/bor
112112
bash stop.sh
113113
```
114114

115-
### Retrieve Latest Peer Details
115+
### Retrieve latest peer details
116116

117117
To retrieve the latest peer details, run:
118118

@@ -124,16 +124,16 @@ admin.peers.forEach(function(value){
124124
exit
125125
```
126126

127-
### Stop Heimdall and Bor Services
127+
### Stop Heimdall and Bor services
128128

129-
##### For Linux packages:
129+
##### For Linux packages
130130

131131
```bash
132132
sudo service heimdalld stop
133133
sudo service bor stop
134134
```
135135

136-
##### For Binaries:
136+
##### For binaries
137137

138138
```bash
139139
pkill heimdalld
@@ -142,16 +142,16 @@ cd CS-2001/bor
142142
bash stop.sh
143143
```
144144

145-
### Remove Heimdall and Bor Directories
145+
### Remove Heimdall and Bor directories
146146

147-
##### For Linux packages:
147+
##### For Linux packages
148148

149149
```bash
150150
sudo rm -rf /etc/heimdall/*
151151
sudo rm -rf /etc/bor/*
152152
```
153153

154-
##### For Binaries:
154+
##### For binaries
155155

156156
```bash
157157
sudo rm -rf /var/lib/heimdalld/

docs/pos/architecture/bor/index.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff 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.
22

3-
## Proposers and Producers Selection
3+
## Proposers and producers selection
44

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.
66

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.
88

9-
#### Selection Process
9+
#### Selection process
1010

1111
1. Validators are given slots proportionally according to their stake.
1212
2. Using historical Ethereum block data as seed, we shuffle this array.
1313
3. Now depending on Producer count*(maintained by validator's governance)*, validators are taken from the top.
1414
4. Using this validator set and Tendermint's proposer selection algorithm, we choose a producer for every sprint on Bor.
1515

16-
## Detailed Mechanics of Bor Consensus
16+
## Detailed mechanics of Bor consensus
1717

18-
### Validators in Polygon's Proof-of-Stake System
18+
### Validators in Polygon's Proof-of-Stake system
1919

2020
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.
2121

22-
### Span: Defining Validator Sets and Voting Power
22+
### Span: Defining validator sets and voting power
2323

2424
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.
2525

26-
### Sprint: Single Block Producer Selection within a Span
26+
### Sprint: Single block producer selection within a span
2727

2828
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.
2929

30-
### Block Authorization by Producers
30+
### Block authorization by producers
3131

3232
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.
3333

3434
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`).
3535

36-
#### Handling Out-of-Turn Signing
36+
#### Handling out-of-turn signing
3737

3838
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.
3939

40-
#### Wiggle Time: Delay before Backup Production
40+
#### Wiggle time: Delay before backup production
4141

4242
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.
4343

44-
#### Resolving Forks with Difficulty Metrics
44+
#### Resolving forks with difficulty metrics
4545

4646
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.
4747

48-
### View Change and Span Commitment
48+
### View change and span commitment
4949

5050
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.
5151

52-
### State Synchronization with the Ethereum Chain
52+
### State synchronization with the Ethereum chain
5353

5454
Bor features a mechanism to relay specific events from the Ethereum chain to Bor. This involves:
5555

docs/pos/architecture/bor/state-sync.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff 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.
22

33
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.
44

@@ -8,7 +8,7 @@ This is the flow required from dapps / users to work with state-sync:
88

99
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)
1010
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.
1212
4. Once `state-sync` transaction on Heimdall has been included in a block, it is added to pending state-sync list.
1313
5. After every sprint on `bor`, the Bor node fetches the pending state-sync events from Heimdall via an API call.
1414
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 (
5555
);
5656
```
5757
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.
5959
6060
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)
6161
@@ -85,10 +85,10 @@ System call is helpful to change state to contract without making any transactio
8585
8686
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).
8787
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):
8989
9090
```jsx
9191
keccak256("matic-bor-receipt-" + block number + block hash)
9292
```
9393
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 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 transaction in `transactionRoot` or `receiptRoot`.

docs/pos/architecture/heimdall/authentication.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Use the following command to print account related data into Heimdall:
9191
heimdalld show-account
9292
```
9393

94-
Expected Result:
94+
Expected result:
9595

9696
```json
9797
{
@@ -102,13 +102,13 @@ Expected Result:
102102

103103
### Account and coin details
104104

105-
To display account details, coins, sequence and account number;
105+
To display account details, coins, sequence and account number:
106106

107107
```bash
108108
heimdallcli query auth account 0x68243159a498cf20d945cf3E4250918278BA538E --trust-node
109109
```
110110

111-
Expected Result:
111+
Expected result:
112112

113113
```json
114114
address: 0x68243159a498cf20d945cf3e4250918278ba538e
@@ -129,7 +129,7 @@ Use the following command to print all params:
129129
heimdallcli query auth params
130130
```
131131

132-
Expected Result:
132+
Expected result:
133133

134134
```go
135135
max_memo_characters: 256

docs/pos/architecture/heimdall/balance-transfers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Heimdall's `bank` module handles balance transfers between accounts. This module corresponds to the `bank` module from cosmos-sdk.
1+
Heimdall's `bank` module handles balance transfers between accounts. This module corresponds to the `bank` module from the Cosmos SDK.
22

33
## Messages
44

docs/pos/architecture/heimdall/chain-management.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Use the following command to print all params:
4747
heimdallcli query chainmanager params --trust-node
4848
```
4949

50-
### Expected result
50+
Expected result:
5151

5252
```yaml
5353
tx_confirmation_time: 12s

docs/pos/architecture/heimdall/checkpoints.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ Expected Result:
189189
checkpoint_buffer_time: 16m40s
190190
```
191191
192-
### Send Checkpoint
192+
### Send checkpoint
193193
194194
Following command sends checkpoint transaction on Heimdall:
195195

docs/pos/architecture/heimdall/governance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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).
22

33
## Overview
44

docs/pos/architecture/heimdall/heimdall-and-bor.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Expected output:
157157
}
158158
```
159159

160-
### Query span by id
160+
### Query span by ID
161161

162162
```bash
163163
heimdallcli query bor span --span-id <span-id> --chain-id <heimdall-chain-id>
@@ -167,7 +167,7 @@ It prints the result in same format as above.
167167

168168
### Parameters
169169

170-
To print all params;
170+
Use the following command to print all params:
171171

172172
```go
173173
heimdalldcli query bor params

docs/pos/architecture/heimdall/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Heimdall is the heart of the Polygon PoS network. It performs the following func
55
- Manages validators
66
- Handles block producer selection
77
- Facilitates spans
8-
- Orchestrates the state-sync mechanism between Ethereum and Matic
8+
- Orchestrates the state sync mechanism between Ethereum and Polygon PoS
99
- Addresses other essential aspects of the system
1010

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 *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)
1212

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 Cosmos SDK but primarily utilizes a customized version of it, following a similar pattern.

0 commit comments

Comments
 (0)