Skip to content

Commit

Permalink
Merge pull request ethereum#118 from etclabscore/fix/les-cht-defaults
Browse files Browse the repository at this point in the history
Fix/les cht defaults
  • Loading branch information
meowsbits authored Jan 9, 2020
2 parents bf0a296 + b700148 commit ae6ee79
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
15 changes: 12 additions & 3 deletions les/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ import (
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params/confp"
"github.com/ethereum/go-ethereum/params/types/goethereum"
"github.com/ethereum/go-ethereum/params/types/multigeth"
"github.com/ethereum/go-ethereum/params/vars"
"github.com/ethereum/go-ethereum/rpc"
)
Expand Down Expand Up @@ -109,7 +110,11 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) {

checkpoint := config.Checkpoint
if checkpoint == nil {
checkpoint = params.TrustedCheckpoints[genesisHash]
if p, ok := chainConfig.(*multigeth.MultiGethChainConfig); ok {
checkpoint = p.TrustedCheckpoint
} else if p, ok := chainConfig.(*goethereum.ChainConfig); ok {
checkpoint = p.TrustedCheckpoint
}
}
// Note: NewLightChain adds the trusted checkpoint so it needs an ODR with
// indexers already set but not started yet
Expand All @@ -122,7 +127,11 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) {
// Set up checkpoint oracle.
oracle := config.CheckpointOracle
if oracle == nil {
oracle = params.CheckpointOracles[genesisHash]
if p, ok := chainConfig.(*multigeth.MultiGethChainConfig); ok {
oracle = p.TrustedCheckpointOracle
} else if p, ok := chainConfig.(*goethereum.ChainConfig); ok {
oracle = p.TrustedCheckpointOracle
}
}
leth.oracle = newCheckpointOracle(oracle, leth.localCheckpoint)

Expand Down
9 changes: 7 additions & 2 deletions les/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ import (
"github.com/ethereum/go-ethereum/p2p/discv5"
"github.com/ethereum/go-ethereum/p2p/enode"
"github.com/ethereum/go-ethereum/p2p/enr"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params/types/goethereum"
"github.com/ethereum/go-ethereum/params/types/multigeth"
"github.com/ethereum/go-ethereum/params/vars"
"github.com/ethereum/go-ethereum/rpc"
)
Expand Down Expand Up @@ -95,7 +96,11 @@ func NewLesServer(e *eth.Ethereum, config *eth.Config) (*LesServer, error) {
// Set up checkpoint oracle.
oracle := config.CheckpointOracle
if oracle == nil {
oracle = params.CheckpointOracles[e.BlockChain().Genesis().Hash()]
if p, ok := e.BlockChain().Config().(*multigeth.MultiGethChainConfig); ok {
oracle = p.TrustedCheckpointOracle
} else if p, ok := e.BlockChain().Config().(*goethereum.ChainConfig); ok {
oracle = p.TrustedCheckpointOracle
}
}
srv.oracle = newCheckpointOracle(oracle, srv.localCheckpoint)

Expand Down
18 changes: 0 additions & 18 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,6 @@ var (
GoerliGenesisHash = common.HexToHash("0xbf7e331f7f7c1dd2e05159666b3bf8bc7a8a3a9eb1d518969eab529dd9b88c1a")
)

// TrustedCheckpoints associates each known checkpoint with the genesis hash of
// the chain it belongs to.
var TrustedCheckpoints = map[common.Hash]*ctypes.TrustedCheckpoint{
MainnetGenesisHash: MainnetTrustedCheckpoint,
TestnetGenesisHash: TestnetTrustedCheckpoint,
RinkebyGenesisHash: RinkebyTrustedCheckpoint,
GoerliGenesisHash: GoerliTrustedCheckpoint,
}

// CheckpointOracles associates each known checkpoint oracles with the genesis hash of
// the chain it belongs to.
var CheckpointOracles = map[common.Hash]*ctypes.CheckpointOracleConfig{
MainnetGenesisHash: MainnetCheckpointOracle,
TestnetGenesisHash: TestnetCheckpointOracle,
RinkebyGenesisHash: RinkebyCheckpointOracle,
GoerliGenesisHash: GoerliCheckpointOracle,
}

var (
// MainnetChainConfig is the chain parameters to run a node on the main network.
MainnetChainConfig = &goethereum.ChainConfig{
Expand Down

0 comments on commit ae6ee79

Please sign in to comment.