[ethereum/go-ethereum] contracts: add checkpoint registrar smart contract (#16842)

rjl493456442 commented on this pull request.

> + for {
+ select {
+ case event := checkpoint.SectionIdx {
+ log.Info(“Receive new checkpoint event”, “section”, event.Index, “hash”, common.Hash(event.CheckpointHash).Hex(),
+ “grantor”, event.Grantor.Hex())
+ announcement[event.Index.Uint64()] = common.Hash(event.CheckpointHash)
+ }
+ case head := section height + 256) cht root and bloom trie root have not been calculated, the generated checkpoint will mismatch the hash attached in announcement. So that server will try to generate a stable checkpoint and match the hash in the next few blocks until indexer finishes calculation.

And for order should be:
– indexer calculates and generates unstable checkpoint
– admin fetches and register the unstable checkpoint
– server receives checkpoint announcement
– persist stable checkpoint

If we subscribe events from indexer, the logic will only be triggered every 32768 blocks. And for the usual case, `new section event` will be received early than `unstable checkpoint announcement`. So that we can not update stable checkpoint asap

This post was last modified on July 11, 2018, 7:46 am