-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ccip-5315 ocr params defaults (#16573)
* changes * updates * fix lint * fix pointer error * go import * fix integration-in-memory pipeline * another fix * revert * use test configs * fox crib * add required config * all required config * another try * more fixes * fixes * CCIP-5315 Removing globally shared OCR params and relying on structs instead (#16585) * Replacing with Mergo * Replacing with Mergo * go.mod --------- Co-authored-by: Mateusz Sekara <[email protected]>
- Loading branch information
1 parent
5ead332
commit b804a37
Showing
14 changed files
with
413 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package globals | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
|
||
"dario.cat/mergo" | ||
|
||
"github.com/smartcontractkit/chainlink/deployment/common/types" | ||
) | ||
|
||
// Intention of this file is to be a single source of the truth for OCR3 parameters used by CCIP plugins. | ||
// | ||
// Assumptions: | ||
// - Although, some values are similar between Commit and Execute, we should keep them separate, because | ||
// these plugins have different requirements and characteristics. This way we can avoid misconfiguration | ||
// by accidentally changing parameter for one plugin while adjusting it for the other | ||
// - OCR3 parameters are chain agnostic and should be reused across different chains. There might be some use cases | ||
// for overrides to accommodate specific chain characteristics (e.g. Ethereum). | ||
// However, for most of the cases we should strive to rely on defaults under CommitOCRParams and ExecOCRParams. | ||
// This makes the testing process much easier and increase our confidence that the configuration is safe to use. | ||
// - The fewer overrides the better. Introducing new overrides should be done with caution and only if there's a strong | ||
// justification for it. Moreover, it requires detailed chaos / load testing to ensure that the new parameters are safe to use | ||
// and meet CCIP SLOs | ||
// - Single params must not be stored under const or exposed outside of this file to limit the risk of | ||
// accidental configuration or partial configuration | ||
// - MaxDurations should be set on the latencies observed on various environments using p99 OCR3 latencies | ||
// These values should be specific to the plugin type and should not depend on the chain family | ||
// or the environment in which plugin runs | ||
var ( | ||
// CommitOCRParams represents the default OCR3 parameters for all chains (beside Ethereum, see CommitOCRParamsForEthereum). | ||
// Most of the intervals here should be generic enough (and chain agnostic) to be reused across different chains. | ||
CommitOCRParams = types.OCRParameters{ | ||
DeltaProgress: 120 * time.Second, | ||
DeltaResend: 30 * time.Second, | ||
DeltaInitial: 20 * time.Second, | ||
DeltaRound: 15 * time.Second, | ||
DeltaGrace: 5 * time.Second, | ||
DeltaCertifiedCommitRequest: 10 * time.Second, | ||
// TransmissionDelayMultiplier overrides DeltaStage | ||
DeltaStage: 25 * time.Second, | ||
Rmax: 3, | ||
MaxDurationQuery: 7 * time.Second, | ||
MaxDurationObservation: 13 * time.Second, | ||
MaxDurationShouldAcceptAttestedReport: 5 * time.Second, | ||
MaxDurationShouldTransmitAcceptedReport: 10 * time.Second, | ||
} | ||
|
||
// CommitOCRParamsForEthereum represents a dedicated set of OCR3 parameters for Ethereum. | ||
// It's driven by the fact that Ethereum block time is slow (12 seconds) and chain is considered | ||
// more expensive to other EVM compatible chains | ||
CommitOCRParamsForEthereum = withOverrides( | ||
CommitOCRParams, | ||
types.OCRParameters{ | ||
DeltaRound: 90 * time.Second, | ||
DeltaStage: 60 * time.Second, | ||
}, | ||
) | ||
) | ||
|
||
var ( | ||
// ExecOCRParams represents the default OCR3 parameters for all chains (beside Ethereum, see ExecOCRParamsForEthereum). | ||
ExecOCRParams = types.OCRParameters{ | ||
DeltaProgress: 100 * time.Second, | ||
DeltaResend: 30 * time.Second, | ||
DeltaInitial: 20 * time.Second, | ||
DeltaRound: 15 * time.Second, | ||
DeltaGrace: 5 * time.Second, | ||
DeltaCertifiedCommitRequest: 10 * time.Second, | ||
// TransmissionDelayMultiplier overrides DeltaStage | ||
DeltaStage: 25 * time.Second, | ||
Rmax: 3, | ||
// MaxDurationQuery is set to very low value, because Execution plugin doesn't use Query | ||
MaxDurationQuery: 200 * time.Millisecond, | ||
MaxDurationObservation: 13 * time.Second, | ||
MaxDurationShouldAcceptAttestedReport: 5 * time.Second, | ||
MaxDurationShouldTransmitAcceptedReport: 10 * time.Second, | ||
} | ||
|
||
// ExecOCRParamsForEthereum represents a dedicated set of OCR3 parameters for Ethereum. | ||
// Similarly to Commit, it's here to accommodate Ethereum specific characteristics | ||
ExecOCRParamsForEthereum = withOverrides( | ||
ExecOCRParams, | ||
types.OCRParameters{ | ||
DeltaRound: 90 * time.Second, | ||
DeltaStage: 60 * time.Second, | ||
}, | ||
) | ||
) | ||
|
||
func withOverrides(base types.OCRParameters, overrides types.OCRParameters) types.OCRParameters { | ||
outcome := base | ||
if err := mergo.Merge(&outcome, overrides, mergo.WithOverride); err != nil { | ||
panic(fmt.Sprintf("error while building an OCR config %v", err)) | ||
} | ||
return outcome | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package globals | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_MergeWithOverrides(t *testing.T) { | ||
assert.Equal(t, ExecOCRParams.DeltaProgress, ExecOCRParamsForEthereum.DeltaProgress) | ||
assert.Equal(t, ExecOCRParams.DeltaResend, ExecOCRParamsForEthereum.DeltaResend) | ||
assert.Equal(t, ExecOCRParams.DeltaInitial, ExecOCRParamsForEthereum.DeltaInitial) | ||
assert.Equal(t, ExecOCRParams.DeltaGrace, ExecOCRParamsForEthereum.DeltaGrace) | ||
assert.Equal(t, ExecOCRParams.DeltaCertifiedCommitRequest, ExecOCRParamsForEthereum.DeltaCertifiedCommitRequest) | ||
assert.Equal(t, ExecOCRParams.MaxDurationQuery, ExecOCRParamsForEthereum.MaxDurationQuery) | ||
assert.Equal(t, ExecOCRParams.MaxDurationObservation, ExecOCRParamsForEthereum.MaxDurationObservation) | ||
assert.Equal(t, ExecOCRParams.MaxDurationShouldAcceptAttestedReport, ExecOCRParamsForEthereum.MaxDurationShouldAcceptAttestedReport) | ||
assert.Equal(t, ExecOCRParams.MaxDurationShouldTransmitAcceptedReport, ExecOCRParamsForEthereum.MaxDurationShouldTransmitAcceptedReport) | ||
assert.Equal(t, ExecOCRParams.MaxDurationQuery, ExecOCRParamsForEthereum.MaxDurationQuery) | ||
|
||
assert.Equal(t, 90*time.Second, ExecOCRParamsForEthereum.DeltaRound) | ||
assert.Equal(t, 60*time.Second, ExecOCRParamsForEthereum.DeltaStage) | ||
assert.Equal(t, 200*time.Millisecond, ExecOCRParams.MaxDurationQuery) | ||
assert.Equal(t, 200*time.Millisecond, ExecOCRParamsForEthereum.MaxDurationQuery) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.