Skip to content

Commit

Permalink
Add types for Retirement Report
Browse files Browse the repository at this point in the history
  • Loading branch information
samsondav committed Oct 16, 2024
1 parent 87939ad commit 066f071
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
19 changes: 18 additions & 1 deletion pkg/types/llo/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -35,15 +36,23 @@ 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
)

var ReportFormats = []ReportFormat{
ReportFormatEVMPremiumLegacy,
ReportFormatJSON,
ReportFormatRetirement,
}

func (rf ReportFormat) String() string {
Expand All @@ -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)
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -302,3 +315,7 @@ type ChannelDefinitionCache interface {
Definitions() ChannelDefinitions
services.Service
}

type ShouldRetireCache interface {
ShouldRetire(digest ocr2types.ConfigDigest) (bool, error)
}
12 changes: 11 additions & 1 deletion pkg/types/provider_llo.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 066f071

Please sign in to comment.