Skip to content

Commit

Permalink
feat: add a check on node started that EVM chain RPC nodes are config…
Browse files Browse the repository at this point in the history
…ured properly
  • Loading branch information
wwestgarth committed Apr 25, 2024
1 parent b4941ac commit b931547
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions core/evtforward/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions core/evtforward/ethereum/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Config struct {
MaxEthereumBlocks uint64 `long:"max-ethereum-blocks"`
PollEventRetryDuration encoding.Duration
ChainID string
SkipClientVerification bool
}

func NewDefaultConfig() Config {
Expand Down
32 changes: 32 additions & 0 deletions core/evtforward/ethereum/filterer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b931547

Please sign in to comment.