Skip to content

Commit 7eadbcd

Browse files
authored
Merge pull request 0xPolygon#322 from 0xPolygon/remove-pos-slashing-references
PoS: Update staking manager doc
2 parents c9fe2cd + 36ec84b commit 7eadbcd

File tree

4 files changed

+20
-34
lines changed

4 files changed

+20
-34
lines changed

docs/img/pos/checkpoint.png

88.8 KB
Loading

docs/img/pos/checkpoint.svg

Lines changed: 0 additions & 3 deletions
This file was deleted.

docs/pos/architecture/heimdall/checkpoints.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type CheckpointBlockHeader struct {
3232

3333
#### Root hash calculation
3434

35-
![Root Hash Image](../../../img/pos/checkpoint.svg)
35+
![Root Hash Image](../../../img/pos/checkpoint.png)
3636

3737
The `RootHash` is calculated as a Merkle hash of Bor block hashes from `StartBlock` to `EndBlock`. The process involves hashing each block's number, time, transaction hash, and receipt hash, then creating a Merkle root of these hashes.
3838

@@ -83,44 +83,41 @@ rootHash := tree.Root().Hash
8383
`AccountRootHash` is the hash of the validator account-related information that needs to pass to the Ethereum chain at each checkpoint.
8484

8585
```jsx
86-
eachAccountHash := keccak256([validator id, withdraw fee, slash amount])
86+
eachAccountHash := keccak256([validator id, withdraw fee])
8787
```
8888

8989
Pseudocode for the account root hash for `1` to `n` Bor blocks:
9090

9191
```go
92-
B(1) := keccak256([validator id, withdraw fee, slash amount])
93-
B(2) := keccak256([validator id, withdraw fee, slash amount])
92+
B(1) := keccak256([validator id, withdraw fee])
93+
B(2) := keccak256([validator id, withdraw fee])
9494
.
9595
.
9696
.
97-
B(n) := keccak256([validator id, withdraw fee, slash amount])
97+
B(n) := keccak256([validator id, withdraw fee])
9898

9999
// account root hash is Merkle root of all block hash
100100
checkpoint's account root hash = Merkel[B(1), B(2), ....., B(n)]
101101
```
102102
103-
Golang code for the account hash can be found here: [https://github.com/maticnetwork/heimdall/blob/develop/types/dividend-account.go#L91-L101](https://github.com/maticnetwork/heimdall/blob/develop/types/dividend-account.go#L91-L101)
103+
Golang code for the account hash can be found here: [https://github.com/maticnetwork/heimdall/blob/develop/types/dividend-account.go](https://github.com/maticnetwork/heimdall/blob/develop/types/dividend-account.go)
104104
105105
```go
106-
// DividendAccount contains Fee, Slashed amount
106+
// DividendAccount contains burned Fee amount
107107
type DividendAccount struct {
108-
ID DividendAccountID `json:"ID"`
109-
FeeAmount string `json:"feeAmount"` // string representation of big.Int
110-
SlashedAmount string `json:"slashedAmount"` // string representation of big.Int
108+
User HeimdallAddress `json:"user"`
109+
FeeAmount string `json:"feeAmount"` // string representation of big.Int
111110
}
112111
113-
// calculate hash for particular account
112+
// CalculateHash hashes the values of a DividendAccount
114113
func (da DividendAccount) CalculateHash() ([]byte, error) {
115-
fee, _ := big.NewInt(0).SetString(da.FeeAmount, 10)
116-
slashAmount, _ := big.NewInt(0).SetString(da.SlashedAmount, 10)
117-
divAccountHash := crypto.Keccak256(appendBytes32(
118-
new(big.Int).SetUint64(uint64(da.ID)).Bytes(),
119-
fee.Bytes(),
120-
slashAmount.Bytes(),
121-
))
122-
123-
return divAccountHash, nil
114+
fee, _ := big.NewInt(0).SetString(da.FeeAmount, 10)
115+
divAccountHash := crypto.Keccak256(appendBytes32(
116+
da.User.Bytes(),
117+
fee.Bytes(),
118+
))
119+
120+
return divAccountHash, nil
124121
}
125122
```
126123

docs/pos/reference/contracts/stakingmanager.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,14 @@ PIP4 introduced the concept of showcasing validator performance for community vi
2525

2626
## Methods and variables
2727

28-
!!!caution
29-
Slashing Implementation
30-
31-
`jail`, `unJail`, and `slash` functions are not used currently as part of the slashing implementation.
32-
33-
3428
### validatorThreshold
3529

3630
It stores the maximum number of validators accepted by the system, also called slots.
3731

3832
### AccountStateRoot
3933

4034
- For various accounting done on Heimdall for validators and delegator, account root is submitted while submitting the `checkpoint`.
41-
- accRoot is used while `claimRewards` and `unStakeClaim`.
35+
- `accRoot` is used while `claimRewards` and `unStakeClaim`.
4236

4337
### stake / stakeFor
4438

@@ -76,9 +70,7 @@ function stakeFor(
7670
```solidity
7771
function unstakeClaim(uint256 validatorId) public;
7872
```
79-
80-
- After `unstaking`, validators are put into withdrawal period so that they can be slashed, if any fraud found after `unstaking`, for past frauds.
81-
- Once `WITHDRAWAL_DELAY` period is served, validators can call this function and do settlement with `stakeManager` (get rewards if any, get staked tokens back, burn NFT, etc).
73+
Once `WITHDRAWAL_DELAY` period is served, validators can call this function and do settlement with `stakeManager` (get rewards if any, get staked tokens back, burn NFT, etc).
8274

8375
### restake
8476

@@ -127,7 +119,7 @@ function claimFee(
127119

128120
This method is used to withdraw fees from Heimdall. `accountStateRoot` is updated on each checkpoint, so that validators can provide proof of inclusion in this root for account on Heimdall and withdraw fee.
129121

130-
Note that `accountStateRoot` is re-written to prevent exits on multiple checkpoints (for old root and save accounting on `stakeManager`). `accumSlashedAmount` is unused at the moment and will be used for slashing on Heimdall if needed.
122+
Note that `accountStateRoot` is re-written to prevent exits on multiple checkpoints (for old root and save accounting on `stakeManager`).
131123

132124
### StakingNFT
133125

0 commit comments

Comments
 (0)