Skip to content

Updating CHT BloomTrie

Ivan Daniluk edited this page Mar 2, 2018 · 4 revisions

CHT/BloomTries values are used for faster synchronization in LES (Light Ethereum Service), but at the present moment we have to regenerate the values manually from time to time.

Generate CHT/BloomTrie:

  1. Clone https://github.com/ethereum/go-ethereum
  2. Run make
  3. Run full node: build/bin/geth --testnet --syncmode "full" --cache 512
  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
  1. 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 --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 (
  1. TBD: apply patches to the status-im/go-ethereum
  2. 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,

  1. Grep for CHT logs: docker logs --since=30s -f full-geth 2>&1 | grep -e "INFO\|CHT",
  2. When you get the newest CHT number, stop full-geth container and remove it,
  3. Bring back the stopped geth service: service start geth.