Skip to content

Commit f26509b

Browse files
committed
PoS: Update checkpoints.md
- Update code blocks - Minor fixes
1 parent 83c6ff8 commit f26509b

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

docs/pos/architecture/heimdall/checkpoints.md

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)