From 066f071f8e93b8ab4a6436b5f1905d29bf1d54ff Mon Sep 17 00:00:00 2001 From: Sam Davies Date: Thu, 19 Sep 2024 14:26:26 -0400 Subject: [PATCH] Add types for Retirement Report --- pkg/types/llo/types.go | 19 ++++++++++++++++++- pkg/types/provider_llo.go | 12 +++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/pkg/types/llo/types.go b/pkg/types/llo/types.go index 8aec019d03..3951afa4ae 100644 --- a/pkg/types/llo/types.go +++ b/pkg/types/llo/types.go @@ -8,6 +8,7 @@ import ( "math" "github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types" + ocr2types "github.com/smartcontractkit/libocr/offchainreporting2plus/types" "github.com/smartcontractkit/chainlink-common/pkg/services" ) @@ -35,8 +36,15 @@ const ( // NOTE: Only add something here if you actually need it, because it has to // be supported forever and can't be changed + + // ReportFormatEVMPremiumLegacy maintains compatibility with the legacy + // Mercury v0.3 report format ReportFormatEVMPremiumLegacy ReportFormat = 1 - ReportFormatJSON ReportFormat = 2 + // ReportFormatJSON is a simple JSON format for reference and debugging + ReportFormatJSON ReportFormat = 2 + // ReportFormatRetirement is a special "capstone" report format to indicate + // a retired OCR instance, and handover crucial information to a new one + ReportFormatRetirement ReportFormat = 3 _ ReportFormat = math.MaxUint32 // reserved ) @@ -44,6 +52,7 @@ const ( var ReportFormats = []ReportFormat{ ReportFormatEVMPremiumLegacy, ReportFormatJSON, + ReportFormatRetirement, } func (rf ReportFormat) String() string { @@ -52,6 +61,8 @@ func (rf ReportFormat) String() string { return "evm_premium_legacy" case ReportFormatJSON: return "json" + case ReportFormatRetirement: + return "retirement" default: return fmt.Sprintf("unknown(%d)", rf) } @@ -63,6 +74,8 @@ func ReportFormatFromString(s string) (ReportFormat, error) { return ReportFormatEVMPremiumLegacy, nil case "json": return ReportFormatJSON, nil + case "retirement": + return ReportFormatRetirement, nil default: return 0, fmt.Errorf("unknown report format: %q", s) } @@ -302,3 +315,7 @@ type ChannelDefinitionCache interface { Definitions() ChannelDefinitions services.Service } + +type ShouldRetireCache interface { + ShouldRetire(digest ocr2types.ConfigDigest) (bool, error) +} diff --git a/pkg/types/provider_llo.go b/pkg/types/provider_llo.go index db5817607b..6fc8a5ccf3 100644 --- a/pkg/types/provider_llo.go +++ b/pkg/types/provider_llo.go @@ -1,11 +1,21 @@ package types import ( + ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types" + "github.com/smartcontractkit/chainlink-common/pkg/types/llo" ) +type LLOConfigProvider interface { + OffchainConfigDigester() ocrtypes.OffchainConfigDigester + // One instance will be run per config tracker + ContractConfigTrackers() []ocrtypes.ContractConfigTracker +} + type LLOProvider interface { - ConfigProvider + Service + LLOConfigProvider + ShouldRetireCache() llo.ShouldRetireCache ContractTransmitter() llo.Transmitter ChannelDefinitionCache() llo.ChannelDefinitionCache }