Skip to content

Commit 9c4741b

Browse files
committed
cre-1601: shard orchestrator plugin for delegate
1 parent 3688afc commit 9c4741b

File tree

14 files changed

+2378
-2
lines changed

14 files changed

+2378
-2
lines changed

pkg/types/plugin.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ const (
1616
GenericPlugin OCR2PluginType = "plugin"
1717
OCR3Capability OCR2PluginType = "ocr3-capability"
1818
VaultPlugin OCR2PluginType = "vault-plugin"
19-
DonTimePlugin OCR2PluginType = "dontime"
20-
SecureMint OCR2PluginType = "securemint"
19+
DonTimePlugin OCR2PluginType = "dontime"
20+
ShardOrchestratorPlugin OCR2PluginType = "shardorchestrator"
21+
SecureMint OCR2PluginType = "securemint"
2122

2223
CCIPCommit OCR2PluginType = "ccip-commit"
2324
CCIPExecution OCR2PluginType = "ccip-execution"
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package shardorchestrator
2+
3+
import (
4+
"context"
5+
6+
"github.com/smartcontractkit/chainlink-common/pkg/logger"
7+
"github.com/smartcontractkit/chainlink-common/pkg/services"
8+
"github.com/smartcontractkit/chainlink-common/pkg/types/core"
9+
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types"
10+
)
11+
12+
const (
13+
defaultMaxPhaseOutputBytes = 1000000 // 1 MB
14+
defaultMaxReportCount = 1
15+
defaultBatchSize = 100
16+
)
17+
18+
var _ core.OCR3ReportingPluginFactory = &Factory{}
19+
20+
type Factory struct {
21+
store *Store
22+
config *ConsensusConfig
23+
lggr logger.Logger
24+
25+
services.StateMachine
26+
}
27+
28+
// NewFactory creates a factory for the shard orchestrator consensus plugin
29+
func NewFactory(s *Store, lggr logger.Logger, cfg *ConsensusConfig) (*Factory, error) {
30+
if cfg == nil {
31+
cfg = &ConsensusConfig{
32+
MinShardCount: 1,
33+
MaxShardCount: 10,
34+
BatchSize: defaultBatchSize,
35+
}
36+
}
37+
return &Factory{
38+
store: s,
39+
config: cfg,
40+
lggr: logger.Named(lggr, "ShardOrchestratorFactory"),
41+
}, nil
42+
}
43+
44+
func (o *Factory) NewReportingPlugin(_ context.Context, config ocr3types.ReportingPluginConfig) (ocr3types.ReportingPlugin[[]byte], ocr3types.ReportingPluginInfo, error) {
45+
plugin, err := NewPlugin(o.store, config, o.lggr, o.config)
46+
pluginInfo := ocr3types.ReportingPluginInfo{
47+
Name: "Shard Orchestrator Consensus Plugin",
48+
Limits: ocr3types.ReportingPluginLimits{
49+
MaxQueryLength: defaultMaxPhaseOutputBytes,
50+
MaxObservationLength: defaultMaxPhaseOutputBytes,
51+
MaxOutcomeLength: defaultMaxPhaseOutputBytes,
52+
MaxReportLength: defaultMaxPhaseOutputBytes,
53+
MaxReportCount: defaultMaxReportCount,
54+
},
55+
}
56+
return plugin, pluginInfo, err
57+
}
58+
59+
func (o *Factory) Start(ctx context.Context) error {
60+
return o.StartOnce("ShardOrchestratorPlugin", func() error {
61+
return nil
62+
})
63+
}
64+
65+
func (o *Factory) Close() error {
66+
return o.StopOnce("ShardOrchestratorPlugin", func() error {
67+
return nil
68+
})
69+
}
70+
71+
func (o *Factory) Name() string { return o.lggr.Name() }
72+
73+
func (o *Factory) HealthReport() map[string]error {
74+
return map[string]error{o.Name(): o.Healthy()}
75+
}

pkg/workflows/shardorchestrator/pb/arbiter.pb.go

Lines changed: 297 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)