Skip to content

Commit

Permalink
Catalyst modifications for bolt
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinlesceller committed Nov 22, 2023
1 parent 1515d0d commit 918af18
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions eth/catalyst/api.go
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/blockcypher/go-ethereum/beacon/engine"
"github.com/blockcypher/go-ethereum/common"
"github.com/blockcypher/go-ethereum/common/hexutil"
"github.com/blockcypher/go-ethereum/core/rawdb"
"github.com/blockcypher/go-ethereum/core/types"
"github.com/blockcypher/go-ethereum/eth"
"github.com/blockcypher/go-ethereum/eth/downloader"
Expand Down Expand Up @@ -311,7 +310,7 @@ func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payl
PayloadID: id,
}
}
if rawdb.ReadCanonicalHash(api.eth.ChainDb(), block.NumberU64()) != update.HeadBlockHash {
if api.eth.BlockChain().GetHeaderByNumber(block.NumberU64()).Hash() != update.HeadBlockHash {
// Block is not canonical, set head.
if latestValid, err := api.eth.BlockChain().SetCanonical(block); err != nil {
return engine.ForkChoiceResponse{PayloadStatus: engine.PayloadStatusV1{Status: engine.INVALID, LatestValidHash: &latestValid}}, err
Expand Down Expand Up @@ -339,7 +338,7 @@ func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payl
if finalBlock == nil {
log.Warn("Final block not available in database", "hash", update.FinalizedBlockHash)
return engine.STATUS_INVALID, engine.InvalidForkChoiceState.With(errors.New("final block not available in database"))
} else if rawdb.ReadCanonicalHash(api.eth.ChainDb(), finalBlock.NumberU64()) != update.FinalizedBlockHash {
} else if api.eth.BlockChain().GetHeaderByNumber(finalBlock.NumberU64()).Hash() != update.FinalizedBlockHash {
log.Warn("Final block not in canonical chain", "number", block.NumberU64(), "hash", update.HeadBlockHash)
return engine.STATUS_INVALID, engine.InvalidForkChoiceState.With(errors.New("final block not in canonical chain"))
}
Expand All @@ -353,7 +352,7 @@ func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payl
log.Warn("Safe block not available in database")
return engine.STATUS_INVALID, engine.InvalidForkChoiceState.With(errors.New("safe block not available in database"))
}
if rawdb.ReadCanonicalHash(api.eth.ChainDb(), safeBlock.NumberU64()) != update.SafeBlockHash {
if api.eth.BlockChain().GetHeaderByNumber(safeBlock.NumberU64()).Hash() != update.SafeBlockHash {
log.Warn("Safe block not in canonical chain")
return engine.STATUS_INVALID, engine.InvalidForkChoiceState.With(errors.New("safe block not in canonical chain"))
}
Expand Down

0 comments on commit 918af18

Please sign in to comment.