From b93154796f6bb9b35ef91b148520b0b014c8c287 Mon Sep 17 00:00:00 2001 From: wwestgarth Date: Thu, 25 Apr 2024 16:41:36 +0100 Subject: [PATCH] feat: add a check on node started that EVM chain RPC nodes are configured properly --- CHANGELOG.md | 1 + core/evtforward/engine.go | 8 +++++++ core/evtforward/ethereum/config.go | 1 + core/evtforward/ethereum/filterer.go | 32 ++++++++++++++++++++++++++++ 4 files changed, 42 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d64a697ab31..a01e76a1c04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ - [11158](https://github.com/vegaprotocol/vega/issues/11158) - resolve the quote asset for fee estimation in spot market. - [11143](https://github.com/vegaprotocol/vega/issues/11143) - Add support for new asset proposal in batch governance proposal - [11182](https://github.com/vegaprotocol/vega/issues/11182) - Remove reduce only restriction on spot markets stop orders. +- [11153](https://github.com/vegaprotocol/vega/issues/11153) - Add check on start-up that bridge `RPC-endpoints` are functional. ### 🐛 Fixes diff --git a/core/evtforward/engine.go b/core/evtforward/engine.go index c439ed3d746..1dc0a16095d 100644 --- a/core/evtforward/engine.go +++ b/core/evtforward/engine.go @@ -139,6 +139,10 @@ func (e *Engine) SetupEthereumEngine( e.ethEngine.UpdateStakingStartingBlock(e.stakingStartingBlock) } + if err := filterer.VerifyClient(context.Background()); err != nil { + return err + } + e.Start() return nil @@ -204,6 +208,10 @@ func (e *Engine) SetupSecondaryEthereumEngine( e.ethEngine.UpdateStakingStartingBlock(e.stakingStartingBlock) } + if err := filterer.VerifyClient(context.Background()); err != nil { + return err + } + e.Start() return nil diff --git a/core/evtforward/ethereum/config.go b/core/evtforward/ethereum/config.go index e19f8ad828d..8d92a5fa1b8 100644 --- a/core/evtforward/ethereum/config.go +++ b/core/evtforward/ethereum/config.go @@ -34,6 +34,7 @@ type Config struct { MaxEthereumBlocks uint64 `long:"max-ethereum-blocks"` PollEventRetryDuration encoding.Duration ChainID string + SkipClientVerification bool } func NewDefaultConfig() Config { diff --git a/core/evtforward/ethereum/filterer.go b/core/evtforward/ethereum/filterer.go index 94b92dbf247..f9868eb2445 100644 --- a/core/evtforward/ethereum/filterer.go +++ b/core/evtforward/ethereum/filterer.go @@ -248,6 +248,38 @@ func (f *LogFilterer) FilterMultisigControlEvents(ctx context.Context, startAt, } } +// VerifyClient checks that the configured RPC node is able to properly query contract logs. +func (f *LogFilterer) VerifyClient(ctx context.Context) error { + if f.cfg.SkipClientVerification { + f.log.Warn("skipping client verification", logging.String("chain-id", f.chainID)) + return nil + } + + f.log.Info("verifying forwarder client", + logging.String("chain-id", f.chainID), + logging.String("multisig-address", f.multiSigControl.HexAddress()), + logging.Uint64("deployment-height", f.multiSigControl.DeploymentBlockHeight()), + ) + query := f.newMultisigControlQuery( + f.multiSigControl.DeploymentBlockHeight(), + f.multiSigControl.DeploymentBlockHeight()+1, + ) + + // we expect logs for the multisig at its deployment height, if the filter call fails + // or we don't find any logs then the Vega node isn't talking to a reliable RPC node + // or is pointing to the wrong chain. + logs, err := f.client.FilterLogs(ctx, query) + if err != nil { + return fmt.Errorf("please check your RPC node - failed to query contract logs: %w", err) + } + + if len(logs) == 0 { + return fmt.Errorf("please check your RPC node - found no contract logs") + } + + return nil +} + func (f *LogFilterer) filterLogs(ctx context.Context, query eth.FilterQuery) []ethtypes.Log { var logs []ethtypes.Log