node/evm: Fix shadowed variable in Optimism case (#3390)

* EVM Watcher: Fix shadowed variable in Optimism case

* move metric setter into special case
This commit is contained in:
Ben Guidarelli 2023-09-22 13:08:16 -04:00 committed by GitHub
parent 5e8cb3e377
commit 3ecc620eed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -289,7 +289,7 @@ func (w *Watcher) Run(parentCtx context.Context) error {
} else if w.chainID == vaa.ChainIDOptimism && !w.unsafeDevMode { } else if w.chainID == vaa.ChainIDOptimism && !w.unsafeDevMode {
// This only supports Bedrock mode // This only supports Bedrock mode
useFinalizedBlocks = true useFinalizedBlocks = true
safeBlocksSupported := true safeBlocksSupported = true
logger.Info("using finalized blocks, will publish safe blocks") logger.Info("using finalized blocks, will publish safe blocks")
baseConnector, err := connectors.NewEthereumConnector(timeout, w.networkName, w.url, w.contract, logger) baseConnector, err := connectors.NewEthereumConnector(timeout, w.networkName, w.url, w.contract, logger)
if err != nil { if err != nil {
@ -631,7 +631,6 @@ func (w *Watcher) Run(parentCtx context.Context) error {
zap.Stringer("current_blockhash", currentHash), zap.Stringer("current_blockhash", currentHash),
zap.Bool("is_safe_block", ev.Safe), zap.Bool("is_safe_block", ev.Safe),
zap.String("eth_network", w.networkName)) zap.String("eth_network", w.networkName))
currentEthHeight.WithLabelValues(w.networkName).Set(float64(ev.Number.Int64()))
readiness.SetReady(w.readinessSync) readiness.SetReady(w.readinessSync)
p2p.DefaultRegistry.SetNetworkStats(w.chainID, &gossipv1.Heartbeat_Network{ p2p.DefaultRegistry.SetNetworkStats(w.chainID, &gossipv1.Heartbeat_Network{
Height: ev.Number.Int64(), Height: ev.Number.Int64(),
@ -646,6 +645,7 @@ func (w *Watcher) Run(parentCtx context.Context) error {
} else { } else {
atomic.StoreUint64(&currentBlockNumber, blockNumberU) atomic.StoreUint64(&currentBlockNumber, blockNumberU)
atomic.StoreUint64(&w.latestFinalizedBlockNumber, blockNumberU) atomic.StoreUint64(&w.latestFinalizedBlockNumber, blockNumberU)
currentEthHeight.WithLabelValues(w.networkName).Set(float64(ev.Number.Int64()))
} }
for key, pLock := range w.pending { for key, pLock := range w.pending {