les/catalyst/api: add support for ExchangeTransitionConfigurationV1 (#25752)
This method is missing in light client mode and breaks consensus clients that require a valid response.
This commit is contained in:
parent
3db4a13230
commit
1d2f5cf610
|
@ -22,6 +22,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core/beacon"
|
||||
"github.com/ethereum/go-ethereum/les"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
|
@ -189,3 +190,31 @@ func (api *ConsensusAPI) setCanonical(newHead common.Hash) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ExchangeTransitionConfigurationV1 checks the given configuration against
|
||||
// the configuration of the node.
|
||||
func (api *ConsensusAPI) ExchangeTransitionConfigurationV1(config beacon.TransitionConfigurationV1) (*beacon.TransitionConfigurationV1, error) {
|
||||
log.Trace("Engine API request received", "method", "ExchangeTransitionConfiguration", "ttd", config.TerminalTotalDifficulty)
|
||||
if config.TerminalTotalDifficulty == nil {
|
||||
return nil, errors.New("invalid terminal total difficulty")
|
||||
}
|
||||
|
||||
ttd := api.les.BlockChain().Config().TerminalTotalDifficulty
|
||||
if ttd == nil || ttd.Cmp(config.TerminalTotalDifficulty.ToInt()) != 0 {
|
||||
log.Warn("Invalid TTD configured", "geth", ttd, "beacon", config.TerminalTotalDifficulty)
|
||||
return nil, fmt.Errorf("invalid ttd: execution %v consensus %v", ttd, config.TerminalTotalDifficulty)
|
||||
}
|
||||
|
||||
if config.TerminalBlockHash != (common.Hash{}) {
|
||||
if hash := api.les.BlockChain().GetCanonicalHash(uint64(config.TerminalBlockNumber)); hash == config.TerminalBlockHash {
|
||||
return &beacon.TransitionConfigurationV1{
|
||||
TerminalTotalDifficulty: (*hexutil.Big)(ttd),
|
||||
TerminalBlockHash: config.TerminalBlockHash,
|
||||
TerminalBlockNumber: config.TerminalBlockNumber,
|
||||
}, nil
|
||||
}
|
||||
return nil, fmt.Errorf("invalid terminal block hash")
|
||||
}
|
||||
|
||||
return &beacon.TransitionConfigurationV1{TerminalTotalDifficulty: (*hexutil.Big)(ttd)}, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue