Skip to content

Commit

Permalink
FIXED: added hardcoded checkpoints, ignore dynamic checkpoints at low…
Browse files Browse the repository at this point in the history
…er chain height than hardcoded checkpoints
  • Loading branch information
RyanLucchese committed Apr 6, 2020
1 parent b471792 commit 86ff0af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
20 changes: 17 additions & 3 deletions core/energi_checkpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ func newCheckpointManager() *checkpointManager {
}

func (cm *checkpointManager) setup(chain CheckpointChain) {
genesis_hash := chain.GetHeaderByNumber(0).Hash()

if checkpoints, ok := energi_params.EnergiCheckpoints[genesis_hash]; ok {
if checkpoints, ok := energi_params.EnergiCheckpoints[params.MainnetGenesisHash]; ok {
for k, v := range checkpoints {
cm.addCheckpoint(
chain,
Expand Down Expand Up @@ -172,6 +170,22 @@ func (cm *checkpointManager) addCheckpoint(
}

if !local {
// ignore checkpoints which occur before the latest local checkpoint
var maxHardcodedCheckpoint uint64
for maxHardcodedCheckpoint = range energi_params.EnergiCheckpoints[params.MainnetGenesisHash] {
break
}
for n := range energi_params.EnergiCheckpoints[params.MainnetGenesisHash] {
if n > maxHardcodedCheckpoint {
maxHardcodedCheckpoint = n
}
}

if (cp.Number <= maxHardcodedCheckpoint) {
//log.Info("Ignoring checkpoint which occurs before latest checkpoint at", "block", maxHardcodedCheckpoint)
return nil
}

// TODO: proper validation and use of future checkpoints
if len(sigs) == 0 {
log.Warn("Checkpoint: missing signatures",
Expand Down
5 changes: 4 additions & 1 deletion energi/params/checkpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import (

// map Genesis to map of checkpoints
var EnergiCheckpoints = map[common.Hash]map[uint64]common.Hash{
eth_params.MainnetGenesisHash: {},
eth_params.MainnetGenesisHash: map[uint64]common.Hash{
uint64(38283): common.HexToHash("0xbcdaf97b5fa9041b34afcee7ffa85ce88e8e1a9eada2855b5e3ee55b8153f70d"),
uint64(38284): common.HexToHash("0x2a724c7ae36f26b61f5702b0b2099c37061b105b619f250991b573e8d32d63a0"),
},
eth_params.TestnetGenesisHash: {},
}

0 comments on commit 86ff0af

Please sign in to comment.