Updated Updating CHT (markdown)

Ivan Daniluk 2018-01-16 13:51:15 +01:00
parent 10a14ecc61
commit 1962afe990
2 changed files with 70 additions and 34 deletions

70
Updating-CHT-BloomTrie.md Normal file

@ -0,0 +1,70 @@
Proof by construction.
## Generate CHT/BloomTrie:
1. Clone https://github.com/ethereum/go-ethereum
2. Run `make`
3. Run full node: `build/bin/geth --testnet --syncmode "full" --lightserv 90 --cache 512 console`
4. Wait until it synchronizes (if unsure, check the latest block number with http://ropsten.etherscan.io for example)
5. Find two log lines starting with **"Storing CHT"** and **"Storing BloomTrie"**.
Example output:
```
INFO [01-16|13:37:34] Storing CHT idx=71 sectionHead=196bbde833b65a00668ebfd41e2250252ca341b43f33719637ff9b7b0c6fb6c7 root=4d3108bf5334e1eee0d0940b43b69f532012640961f658cf5e42930dbebefba9
INFO [01-16|13:37:40] Storing BloomTrie section=71 sectionHead=196bbde833b65a00668ebfd41e2250252ca341b43f33719637ff9b7b0c6fb6c7 root=dcd1f171503b19970b37a851498c1eeac4744bfb26df9d67ab360818f3d37ba4 compression ratio=0.059
```
6. Write down 4 values (example, based on output above):
* Section Index: **71** (`idx=`)
* Section Head: **196bbde833b65a00668ebfd41e2250252ca341b43f33719637ff9b7b0c6fb6c7** (`sectionHead=`)
* CHT Root: **4d3108bf5334e1eee0d0940b43b69f532012640961f658cf5e42930dbebefba9** (`root=` from the "Storing CHT" line)
* BloomTrie Root: **dcd1f171503b19970b37a851498c1eeac4744bfb26df9d67ab360818f3d37ba4** (`root=` from the "Storing BloomTrie" line)
## Update CHT:
1. Update https://github.com/status-im/status-go/blob/develop/geth-patches/0006-latest-cht.patch with the new values
2. Example from the output above:
```diff
diff --git a/light/postprocess.go b/light/postprocess.go
index e7e51388..dc6562be 100644
--- a/light/postprocess.go
+++ b/light/postprocess.go
@@ -66,12 +66,20 @@ var (
chtRoot: common.HexToHash("6f56dc61936752cc1f8c84b4addabdbe6a1c19693de3f21cb818362df2117f03"),
bloomTrieRoot: common.HexToHash("aca7d7c504d22737242effc3fdc604a762a0af9ced898036b5986c3a15220208"),
}
+
+ statusRopstenCheckpoint = trustedCheckpoint{
+ name: "Ropsten testnet",
+ sectionIdx: 74,
+ sectionHead: common.HexToHash("196bbde833b65a00668ebfd41e2250252ca341b43f33719637ff9b7b0c6fb6c7"),
+ chtRoot: common.HexToHash("4d3108bf5334e1eee0d0940b43b69f532012640961f658cf5e42930dbebefba9"),
+ bloomTrieRoot: common.HexToHash("dcd1f171503b19970b37a851498c1eeac4744bfb26df9d67ab360818f3d37ba4"),
+ }
)
// trustedCheckpoints associates each known checkpoint with the genesis hash of the chain it belongs to
var trustedCheckpoints = map[common.Hash]trustedCheckpoint{
params.MainnetGenesisHash: mainnetCheckpoint,
- params.TestnetGenesisHash: ropstenCheckpoint,
+ params.TestnetGenesisHash: statusRopstenCheckpoint,
}
var (
```
2. TBD: apply patches to the `status-im/go-ethereum`
3. TBD: update vendored dependency using `dep` command
## How to avoid running full sync on you localhost?
1. Go to machine called `miner1`,
2. Run `service stop geth` to stop currently running geth,
3. Run a container:
```
docker run -d --name full-geth -i -p 30303:30303 -v /mnt/ethereum/custom-full:/root/.ethereum ethereum/client-go:v1.7.2 --testnet --syncmode "full" --cache 512 --verbosity 5 --lightserv 90
```
`/mnt/ethereum/custom-full` directory has previously downloaded chain-data files,
4. Grep for CHT logs: `docker logs --since=30s -f full-geth 2>&1 | grep -e "INFO\|CHT"`,
5. When you get the newest CHT number, stop `full-geth` container and remove it,
6. Bring back the stopped geth service: `service start geth`.

@ -1,34 +0,0 @@
Proof by construction.
## Generate CHT:
1. Clone https://github.com/ethereum/go-ethereum
2. Change `log.Trace` to `log.Error` in https://github.com/ethereum/go-ethereum/blob/bf1e2631281e1e439533f2abcf1e99a7b2f9552a/les/server.go#L403
3. Run `make`
4. Run full node: `build/bin/geth --testnet --syncmode "full" --lightserv 90 --cache 512 console`
5. Wait until it synchronises and find error messages like "Generated CHT" with the needed values
## Update CHT:
1. Update https://github.com/status-im/status-go/blob/9463d3843aa237d5ddc79f3cc2187a422d4065b3/static/config/cht.json with the new values
2. Run `make generate` to include the new static file to `bindata.go`
3. Update `geth/params/config_test.go` and `geth/params/testdata/config.*.json` with the new values
4. Run `make`
5. Run `build/bin/statusd --networkid 3 les` on all available networks and ensure block synchronisation starts from block number `number * 4096`
6. Commit and file a PR
If anyone knows a better way, we'd be extremely grateful if you shared it.
## How to avoid running full sync on you localhost?
1. Go to machine called `miner1`,
2. Run `service stop geth` to stop currently running geth,
3. Run a container:
```
docker run -d --name full-geth -i -p 30303:30303 -v /mnt/ethereum/custom-full:/root/.ethereum ethereum/client-go:v1.7.2 --testnet --syncmode "full" --cache 512 --verbosity 5 --lightserv 90
```
`/mnt/ethereum/custom-full` directory has previously downloaded chain-data files,
4. Grep for CHT logs: `docker logs --since=30s -f full-geth 2>&1 | grep -e "INFO\|CHT"`,
5. When you get the newest CHT number, stop `full-geth` container and remove it,
6. Bring back the stopped geth service: `service start geth`.