Skip to content

Commit

Permalink
Update token reporting threshold (#970)
Browse files Browse the repository at this point in the history
## Motivation


## Solution
  • Loading branch information
matYang committed Jun 5, 2024
1 parent 3bfcf80 commit 11ae30d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-turtles-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ccip": patch
---

#updated token price reporting observation threshold to improve safety duringphased rollout
8 changes: 4 additions & 4 deletions core/services/ocr2/plugins/ccip/ccipcommit/ocr2.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@ func extractObservationData(lggr logger.Logger, f int, observations []ccip.Commi

tokenPrices = make(map[cciptypes.Address][]*big.Int)
for token, tokenPriceObservations := range tokenPriceObservations {
// Token price is dropped if there are not enough valid observations. Depending on rollout status of job specs,
// it is possible for different nodes in the DON to observe different tokens. We can conclude a token should indeed
// be observed if there are at least f+1 valid observations.
if len(tokenPriceObservations) <= f {
// Token price is dropped if there are not enough valid observations. With a threshold of 2*(f-1) + 1, we achieve a balance between safety and liveness.
// During phased-rollout where some honest nodes may not have started observing the token yet, it requires 5 malicious node with 1 being the leader to successfully alter price.
// During regular operation, it requires 3 malicious nodes with 1 being the leader to temporarily delay price update for the token.
if len(tokenPriceObservations) < (2*(f-1) + 1) {
lggr.Warnf("Skipping token %s due to not enough valid observations: #obs=%d, f=%d", string(token), len(tokenPriceObservations), f)
continue
}
Expand Down
24 changes: 12 additions & 12 deletions core/services/ocr2/plugins/ccip/ccipcommit/ocr2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,9 @@ func TestCommitReportingPlugin_extractObservationData(t *testing.T) {
expError: false,
},
{
name: "tolerate 1 unsupported token with f=1",
name: "tolerate 1 unsupported token with f=2",
commitObservations: []ccip.CommitObservation{ob1, ob2, obWithUnsupportedToken},
f: 1,
f: 2,
expIntervals: []cciptypes.CommitStoreInterval{validInterval, validInterval, zeroInterval},
expGasPriceObs: []*big.Int{ob1.SourceGasPriceUSD, ob2.SourceGasPriceUSD, obWithUnsupportedToken.SourceGasPriceUSD},
expTokenPriceObs: map[cciptypes.Address][]*big.Int{
Expand All @@ -753,22 +753,22 @@ func TestCommitReportingPlugin_extractObservationData(t *testing.T) {
expError: false,
},
{
name: "tolerate mis-matched token observations with f=1",
commitObservations: []ccip.CommitObservation{ob1, obWithNilTokenPrice, obEmpty},
f: 1,
name: "tolerate mis-matched token observations with f=2",
commitObservations: []ccip.CommitObservation{ob1, obWithNilTokenPrice, obWithNilTokenPrice},
f: 2,
expIntervals: []cciptypes.CommitStoreInterval{validInterval, zeroInterval, zeroInterval},
expGasPriceObs: []*big.Int{ob1.SourceGasPriceUSD, obWithNilTokenPrice.SourceGasPriceUSD},
expGasPriceObs: []*big.Int{ob1.SourceGasPriceUSD, obWithNilTokenPrice.SourceGasPriceUSD, obWithNilTokenPrice.SourceGasPriceUSD},
expTokenPriceObs: map[cciptypes.Address][]*big.Int{
token1: {token1Price, token1Price},
token1: {token1Price, token1Price, token1Price},
},
expError: false,
},
{
name: "tolerate all tokens filtered out with f=1",
commitObservations: []ccip.CommitObservation{ob1, obMissingTokenPrices},
f: 1,
expIntervals: []cciptypes.CommitStoreInterval{validInterval, zeroInterval},
expGasPriceObs: []*big.Int{ob1.SourceGasPriceUSD, obMissingTokenPrices.SourceGasPriceUSD},
name: "tolerate all tokens filtered out with f=2",
commitObservations: []ccip.CommitObservation{ob1, obMissingTokenPrices, obMissingTokenPrices},
f: 2,
expIntervals: []cciptypes.CommitStoreInterval{validInterval, zeroInterval, zeroInterval},
expGasPriceObs: []*big.Int{ob1.SourceGasPriceUSD, obMissingTokenPrices.SourceGasPriceUSD, obMissingTokenPrices.SourceGasPriceUSD},
expTokenPriceObs: map[cciptypes.Address][]*big.Int{},
expError: false,
},
Expand Down

0 comments on commit 11ae30d

Please sign in to comment.