feat: enable multi fork version

Signed-off-by: Isma <71719097+Doozers@users.noreply.github.com>
This commit is contained in:
Isma 2024-01-19 14:45:28 +01:00 committed by mortimr
parent 9c0f1971fe
commit a114f5d0ce

View file

@ -120,7 +120,6 @@ type CachedBlockSimulation struct {
} }
func NewMonitoringEngine(pt *toolkit.PluginToolkit, rdb *redis.Client, eth2 eth2client.Service, beaconEndpoint string, errChan chan error) *MonitoringEngine { func NewMonitoringEngine(pt *toolkit.PluginToolkit, rdb *redis.Client, eth2 eth2client.Service, beaconEndpoint string, errChan chan error) *MonitoringEngine {
return &MonitoringEngine{ return &MonitoringEngine{
ptk: pt, ptk: pt,
backend: pt.Backend.(*eth.EthAPIBackend), backend: pt.Backend.(*eth.EthAPIBackend),
@ -151,6 +150,7 @@ func (me *MonitoringEngine) update(ctx context.Context, parent *types.Block) {
Coinbase: parent.Coinbase(), Coinbase: parent.Coinbase(),
BaseFee: eip1559.CalcBaseFee(me.chainConfig, parent.Header()), BaseFee: eip1559.CalcBaseFee(me.chainConfig, parent.Header()),
Difficulty: parent.Difficulty(), Difficulty: parent.Difficulty(),
// should stay nil on pre-cancun chains
ExcessBlobGas: parent.ExcessBlobGas(), ExcessBlobGas: parent.ExcessBlobGas(),
} }
me.coinbase = parent.Coinbase() me.coinbase = parent.Coinbase()
@ -348,9 +348,16 @@ func (me *MonitoringEngine) startHeadListener(ctx context.Context) {
continue continue
} }
newHighestFinalized := res.Data.Deneb.Message.Body.ExecutionPayload.BlockNumber var blockHeight uint64
if me.chainConfig.CancunTime != nil {
blockHeight = res.Data.Deneb.Message.Body.ExecutionPayload.BlockNumber
} else {
blockHeight = res.Data.Capella.Message.Body.ExecutionPayload.BlockNumber
}
newHighestFinalized := blockHeight
if highestFinalized == 0 { if highestFinalized == 0 {
highestFinalized = res.Data.Deneb.Message.Body.ExecutionPayload.BlockNumber highestFinalized = blockHeight
me.ptk.Logger.Info("Finalized head was updated", "number", highestFinalized) me.ptk.Logger.Info("Finalized head was updated", "number", highestFinalized)
} else if newHighestFinalized > highestFinalized { } else if newHighestFinalized > highestFinalized {
me.ptk.Logger.Info("Updating finalized head", "from", highestFinalized, "to", newHighestFinalized) me.ptk.Logger.Info("Updating finalized head", "from", highestFinalized, "to", newHighestFinalized)