From aebbbdcb9abfc810defa7dddbe3374f31c3f2b37 Mon Sep 17 00:00:00 2001 From: Bruce Riley Date: Thu, 29 Sep 2022 17:56:08 +0000 Subject: [PATCH] Code review rework --- node/cmd/guardiand/node.go | 2 +- node/pkg/watchers/evm/finalizers/arbitrum.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/node/cmd/guardiand/node.go b/node/cmd/guardiand/node.go index 33216a891..68432fa88 100644 --- a/node/cmd/guardiand/node.go +++ b/node/cmd/guardiand/node.go @@ -463,7 +463,7 @@ func runNode(cmd *cobra.Command, args []string) { *moonbeamContract = devnet.GanacheWormholeContractAddress.Hex() *neonContract = devnet.GanacheWormholeContractAddress.Hex() if *arbitrumContract == "" { - *neonContract = devnet.GanacheWormholeContractAddress.Hex() + *arbitrumContract = devnet.GanacheWormholeContractAddress.Hex() } } diff --git a/node/pkg/watchers/evm/finalizers/arbitrum.go b/node/pkg/watchers/evm/finalizers/arbitrum.go index b14b3704e..1a80e636d 100644 --- a/node/pkg/watchers/evm/finalizers/arbitrum.go +++ b/node/pkg/watchers/evm/finalizers/arbitrum.go @@ -52,10 +52,14 @@ func NewArbitrumFinalizer(logger *zap.Logger, connector connectors.Connector, cl } } +// IsBlockFinalized queries the NodeInfrastructure precompiled contract to see if the L2 (Arbitrum) block has appeared +// in an L1 (Ethereum) block. We don't really care what L2 block it appeared in, just that it has. func (a *ArbitrumFinalizer) IsBlockFinalized(ctx context.Context, block *connectors.NewBlock) (bool, error) { _, err := a.caller.FindBatchContainingBlock(ðBind.CallOpts{Context: ctx}, block.Number.Uint64()) if err != nil { - // "requested block 430842 is after latest on-chain block 430820 published in batch 4686" + // If it hasn't been published yet, the method returns an error, so we check for that and treat it as + // not finalized, rather than as an error. Here's what that looks like: + // "requested block 430842 is after latest on-chain block 430820 published in batch 4686" if strings.ContainsAny(err.Error(), "is after latest on-chain block") { return false, nil }