Skip to content

Commit 5d025a2

Browse files
author
dimitris
authored
Minor generic offchain fixes (#769)
1 parent 27b2e9f commit 5d025a2

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

commit/merkleroot/observation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ type Observer interface {
292292
// NOTE: Make sure that caller supports the provided chains.
293293
ObserveMerkleRoots(ctx context.Context, ranges []plugintypes.ChainRange) []cciptypes.MerkleRootChain
294294

295-
// ObserveRMNRemoteCfg observes the RMN remote config for the given destination chain.
295+
// ObserveRMNRemoteCfg observes the RMN remote config from the configured destination chain.
296296
// Check implementation specific details to learn if external calls are made, if values are cached, etc...
297297
// NOTE: Make sure that caller supports the destination chain.
298298
ObserveRMNRemoteCfg(ctx context.Context) rmntypes.RemoteConfig

execute/plugin_functions.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ func validateCommitReportsReadingEligibility(
2828
supportedChains mapset.Set[cciptypes.ChainSelector],
2929
observedData exectypes.CommitObservations,
3030
) error {
31-
for chainSel := range observedData {
31+
for chainSel, observedDataOfChain := range observedData {
3232
if !supportedChains.Contains(chainSel) {
3333
return fmt.Errorf("observer not allowed to read from chain %d", chainSel)
3434
}
35-
for _, data := range observedData[chainSel] {
35+
for _, data := range observedDataOfChain {
3636
if data.SourceChain != chainSel {
3737
return fmt.Errorf("invalid observed data, key=%d but data chain=%d",
3838
chainSel, data.SourceChain)
@@ -140,12 +140,12 @@ func validateMessagesConformToCommitReports(
140140

141141
msgsCount := 0
142142
for chain, report := range observedData {
143-
for _, data := range report {
144-
msgsMap, ok := observedMsgs[chain]
145-
if !ok {
146-
return fmt.Errorf("no messages observed for chain %d, while report was observed", chain)
147-
}
143+
msgsMap, ok := observedMsgs[chain]
144+
if !ok {
145+
return fmt.Errorf("no messages observed for chain %d, while report was observed", chain)
146+
}
148147

148+
for _, data := range report {
149149
for seqNum := data.SequenceNumberRange.Start(); seqNum <= data.SequenceNumberRange.End(); seqNum++ {
150150
_, ok = msgsMap[seqNum]
151151
if !ok {

pkg/reader/ccip.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,7 @@ func (r *ccipChainReader) CommitReportsGTETimestamp(
196196
"ts", ts,
197197
"limit", limit*2)
198198

199-
reports, err := r.processCommitReports(iter, ts, limit)
200-
if err != nil {
201-
return nil, err
202-
}
199+
reports := r.processCommitReports(iter, ts, limit)
203200

204201
lggr.Debugw("decoded commit reports", "reports", reports)
205202

@@ -234,9 +231,11 @@ func (r *ccipChainReader) queryCommitReports(
234231
)
235232
}
236233

234+
// processCommitReports decodes the commit reports from the query results
235+
// and returns the ones that can be properly parsed and validated.
237236
func (r *ccipChainReader) processCommitReports(
238237
iter []types.Sequence, ts time.Time, limit int,
239-
) ([]plugintypes2.CommitPluginReportWithMeta, error) {
238+
) []plugintypes2.CommitPluginReportWithMeta {
240239
lggr := r.lggr
241240
reports := make([]plugintypes2.CommitPluginReportWithMeta, 0)
242241
for _, item := range iter {
@@ -254,14 +253,17 @@ func (r *ccipChainReader) processCommitReports(
254253
}
255254
allMerkleRoots := append(ev.BlessedMerkleRoots, ev.UnblessedMerkleRoots...)
256255
blessedMerkleRoots, unblessedMerkleRoots := r.processMerkleRoots(allMerkleRoots, isBlessed)
256+
257257
priceUpdates, err := r.processPriceUpdates(ev.PriceUpdates)
258258
if err != nil {
259-
return nil, err
259+
lggr.Errorw("failed to process price updates", "err", err, "priceUpdates", ev.PriceUpdates)
260+
continue
260261
}
261262

262263
blockNum, err := strconv.ParseUint(item.Head.Height, 10, 64)
263264
if err != nil {
264-
return nil, fmt.Errorf("failed to parse block number %s: %w", item.Head.Height, err)
265+
lggr.Errorw("failed to parse block number", "blockNum", item.Head.Height, "err", err)
266+
continue
265267
}
266268

267269
reports = append(reports, plugintypes2.CommitPluginReportWithMeta{
@@ -278,9 +280,9 @@ func (r *ccipChainReader) processCommitReports(
278280
lggr.Debugw("decoded commit reports", "reports", reports)
279281

280282
if len(reports) < limit {
281-
return reports, nil
283+
return reports
282284
}
283-
return reports[:limit], nil
285+
return reports[:limit]
284286
}
285287

286288
func (r *ccipChainReader) processMerkleRoots(
@@ -514,6 +516,8 @@ func (r *ccipChainReader) MsgsBetweenSeqNums(
514516
if err != nil {
515517
return nil, fmt.Errorf("get onRamp address after query: %w", err)
516518
}
519+
520+
// Ensure the onRamp address hasn't changed during the query.
517521
if !bytes.Equal(onRampAddress, onRampAddressAfterQuery) {
518522
return nil, fmt.Errorf("onRamp address has changed from %s to %s", onRampAddress, onRampAddressAfterQuery)
519523
}

0 commit comments

Comments
 (0)