Skip to content

Commit 167e10a

Browse files
Merge branch 'main' into feature/INFOPLAT-2786-chip-ingress-add-register-schema-rpc
2 parents a20e8a6 + 8fa1bdd commit 167e10a

File tree

9 files changed

+93
-97
lines changed

9 files changed

+93
-97
lines changed

pkg/capabilities/consensus/ocr3/datafeeds/securemint_aggregator.go

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,20 @@ type secureMintReport struct {
6868
Mintable *big.Int `json:"mintable"`
6969
}
7070

71+
type wrappedMintReport struct {
72+
Report secureMintReport `json:"report"`
73+
SolanaAccountContext solana.AccountMetaSlice `json:"solanaAccountContext,omitempty"`
74+
}
75+
7176
// chainSelector represents the chain selector type, mimics the ChainSelector type in the SM plugin repo
7277
type chainSelector uint64
7378

74-
type SolanaConfig struct {
75-
// Add Solana-specific configuration fields here
76-
AccountContext solana.AccountMetaSlice `mapstructure:"remaining_accounts"`
77-
}
78-
7979
// SecureMintAggregatorConfig is the config for the SecureMint aggregator.
8080
// This aggregator is designed to pick out reports for a specific chain selector.
8181
type SecureMintAggregatorConfig struct {
8282
// TargetChainSelector is the chain selector to look for
8383
TargetChainSelector chainSelector `mapstructure:"targetChainSelector"`
8484
DataID [16]byte `mapstructure:"dataID"`
85-
Solana SolanaConfig `mapstructure:"solana"`
8685
}
8786

8887
// ToMap converts the SecureMintAggregatorConfig to a values.Map, which is suitable for the
@@ -104,15 +103,16 @@ type SecureMintAggregator struct {
104103
}
105104

106105
type chainReportFormatter interface {
107-
packReport(lggr logger.Logger, report *secureMintReport) (*values.Map, error)
106+
packReport(lggr logger.Logger, report *wrappedMintReport) (*values.Map, error)
108107
}
109108

110109
type evmReportFormatter struct {
111110
targetChainSelector chainSelector
112111
dataID [16]byte
113112
}
114113

115-
func (f *evmReportFormatter) packReport(lggr logger.Logger, report *secureMintReport) (*values.Map, error) {
114+
func (f *evmReportFormatter) packReport(lggr logger.Logger, wreport *wrappedMintReport) (*values.Map, error) {
115+
report := wreport.Report
116116
smReportAsAnswer, err := packSecureMintReportIntoUint224ForEVM(report.Mintable, report.Block)
117117
if err != nil {
118118
return nil, fmt.Errorf("failed to pack secure mint report for evm into uint224: %w", err)
@@ -147,10 +147,10 @@ func newEVMReportFormatter(chainSelector chainSelector, config SecureMintAggrega
147147
type solanaReportFormatter struct {
148148
targetChainSelector chainSelector
149149
dataID [16]byte
150-
onReportAccounts solana.AccountMetaSlice
151150
}
152151

153-
func (f *solanaReportFormatter) packReport(lggr logger.Logger, report *secureMintReport) (*values.Map, error) {
152+
func (f *solanaReportFormatter) packReport(lggr logger.Logger, wreport *wrappedMintReport) (*values.Map, error) {
153+
report := wreport.Report
154154
// pack answer
155155
smReportAsAnswer, err := packSecureMintReportIntoU128ForSolana(report.Mintable, report.Block)
156156
if err != nil {
@@ -160,9 +160,10 @@ func (f *solanaReportFormatter) packReport(lggr logger.Logger, report *secureMin
160160

161161
// hash account contexts
162162
var accounts = make([]byte, 0)
163-
for _, acc := range f.onReportAccounts {
163+
for _, acc := range wreport.SolanaAccountContext {
164164
accounts = append(accounts, acc.PublicKey[:]...)
165165
}
166+
lggr.Debugf("accounts length: %d", len(wreport.SolanaAccountContext))
166167
accountContextHash := sha256.Sum256(accounts)
167168
lggr.Debugw("calculated account context hash", "accountContextHash", accountContextHash)
168169

@@ -191,7 +192,7 @@ func (f *solanaReportFormatter) packReport(lggr logger.Logger, report *secureMin
191192
}
192193

193194
func newSolanaReportFormatter(chainSelector chainSelector, config SecureMintAggregatorConfig) chainReportFormatter {
194-
return &solanaReportFormatter{targetChainSelector: chainSelector, onReportAccounts: config.Solana.AccountContext, dataID: config.DataID}
195+
return &solanaReportFormatter{targetChainSelector: chainSelector, dataID: config.DataID}
195196
}
196197

197198
// chainReportFormatterBuilder is a function that returns a chainReportFormatter for a given chain selector and config
@@ -291,9 +292,14 @@ func (a *SecureMintAggregator) Aggregate(lggr logger.Logger, previousOutcome *ty
291292
return outcome, nil
292293
}
293294

295+
type ObsWithCtx struct {
296+
Event capabilities.OCRTriggerEvent `mapstructure:"event"`
297+
Solana solana.AccountMetaSlice `mapstructure:"solana"`
298+
}
299+
294300
// extractAndValidateReports extracts OCRTriggerEvent from observations and validates them
295-
func (a *SecureMintAggregator) extractAndValidateReports(lggr logger.Logger, observations map[ocrcommon.OracleID][]values.Value, previousOutcome *types.AggregationOutcome) ([]*secureMintReport, error) {
296-
var validReports []*secureMintReport
301+
func (a *SecureMintAggregator) extractAndValidateReports(lggr logger.Logger, observations map[ocrcommon.OracleID][]values.Value, previousOutcome *types.AggregationOutcome) ([]*wrappedMintReport, error) {
302+
var validReports []*wrappedMintReport
297303
var foundMatchingChainSelector bool
298304

299305
for nodeID, nodeObservations := range observations {
@@ -302,18 +308,20 @@ func (a *SecureMintAggregator) extractAndValidateReports(lggr logger.Logger, obs
302308
for _, observation := range nodeObservations {
303309
lggr.Debugw("processing observation", "observation", observation)
304310

305-
// Extract OCRTriggerEvent from the observation
306-
triggerEvent := &capabilities.OCRTriggerEvent{}
307-
if err := observation.UnwrapTo(triggerEvent); err != nil {
311+
// Extract OCRTriggerEvent from the observations
312+
313+
obsWithContext := &ObsWithCtx{}
314+
315+
if err := observation.UnwrapTo(obsWithContext); err != nil {
308316
lggr.Warnw("could not unwrap OCRTriggerEvent", "err", err, "observation", observation)
309317
continue
310318
}
311319

312-
lggr.Debugw("triggerEvent", "triggerEvent", triggerEvent)
320+
lggr.Debugw("Obs with context", "obs with ctx", obsWithContext)
313321

314322
// Deserialize the ReportWithInfo
315323
var reportWithInfo ocr3types.ReportWithInfo[chainSelector]
316-
if err := json.Unmarshal(triggerEvent.Report, &reportWithInfo); err != nil {
324+
if err := json.Unmarshal(obsWithContext.Event.Report, &reportWithInfo); err != nil {
317325
lggr.Errorw("failed to unmarshal ReportWithInfo", "err", err)
318326
continue
319327
}
@@ -333,8 +341,12 @@ func (a *SecureMintAggregator) extractAndValidateReports(lggr logger.Logger, obs
333341
lggr.Errorw("failed to unmarshal secureMintReport", "err", err)
334342
continue
335343
}
344+
report := &wrappedMintReport{
345+
Report: innerReport,
346+
SolanaAccountContext: obsWithContext.Solana,
347+
}
336348

337-
validReports = append(validReports, &innerReport)
349+
validReports = append(validReports, report)
338350
}
339351
}
340352

@@ -348,7 +360,7 @@ func (a *SecureMintAggregator) extractAndValidateReports(lggr logger.Logger, obs
348360
}
349361

350362
// createOutcome creates the final aggregation outcome which can be sent to the KeystoneForwarder
351-
func (a *SecureMintAggregator) createOutcome(lggr logger.Logger, report *secureMintReport) (*types.AggregationOutcome, error) {
363+
func (a *SecureMintAggregator) createOutcome(lggr logger.Logger, report *wrappedMintReport) (*types.AggregationOutcome, error) {
352364
lggr = logger.Named(lggr, "SecureMintAggregator")
353365
lggr.Debugw("createOutcome called", "report", report)
354366

@@ -369,12 +381,12 @@ func (a *SecureMintAggregator) createOutcome(lggr logger.Logger, report *secureM
369381
reportsProto := values.Proto(wrappedReport)
370382

371383
// Store the sequence number in metadata for next round
372-
metadata := []byte{byte(report.SeqNr)} // Simple metadata for now
384+
metadata := []byte{byte(report.Report.SeqNr)} // Simple metadata for now
373385

374386
aggOutcome := &types.AggregationOutcome{
375387
EncodableOutcome: reportsProto.GetMapValue(),
376388
Metadata: metadata,
377-
LastSeenAt: report.SeqNr,
389+
LastSeenAt: report.Report.SeqNr,
378390
ShouldReport: true, // Always report since we found and verified the target report
379391
}
380392

@@ -385,9 +397,8 @@ func (a *SecureMintAggregator) createOutcome(lggr logger.Logger, report *secureM
385397
// parseSecureMintConfig parses the user-facing, type-less, SecureMint aggregator config into the internal typed config.
386398
func parseSecureMintConfig(config values.Map) (SecureMintAggregatorConfig, error) {
387399
type rawConfig struct {
388-
TargetChainSelector string `mapstructure:"targetChainSelector"`
389-
DataID string `mapstructure:"dataID"`
390-
Solana SolanaConfig `mapstructure:"solana"`
400+
TargetChainSelector string `mapstructure:"targetChainSelector"`
401+
DataID string `mapstructure:"dataID"`
391402
}
392403

393404
var rawCfg rawConfig
@@ -420,18 +431,9 @@ func parseSecureMintConfig(config values.Map) (SecureMintAggregatorConfig, error
420431
return SecureMintAggregatorConfig{}, fmt.Errorf("dataID must be 16 bytes, got %d", len(decodedDataID))
421432
}
422433

423-
if len(rawCfg.Solana.AccountContext) > 0 {
424-
for _, acc := range rawCfg.Solana.AccountContext {
425-
if acc.PublicKey == [32]byte{} {
426-
return SecureMintAggregatorConfig{}, errors.New("solana account context public key must not be all zeros")
427-
}
428-
}
429-
}
430-
431434
parsedConfig := SecureMintAggregatorConfig{
432435
TargetChainSelector: chainSelector(sel),
433436
DataID: [16]byte(decodedDataID),
434-
Solana: rawCfg.Solana,
435437
}
436438

437439
return parsedConfig, nil

pkg/capabilities/consensus/ocr3/datafeeds/securemint_aggregator_test.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
185185
Block: 1000,
186186
Mintable: big.NewInt(99),
187187
},
188+
accCtx: solana.AccountMetaSlice{&solana.AccountMeta{PublicKey: acc1}, &solana.AccountMeta{PublicKey: acc2}},
188189
},
189190
{
190191
chainSelector: bnbTestnetChainSelector,
@@ -195,6 +196,7 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
195196
Block: 1100,
196197
Mintable: big.NewInt(200),
197198
},
199+
accCtx: solana.AccountMetaSlice{&solana.AccountMeta{PublicKey: acc1}, &solana.AccountMeta{PublicKey: acc2}},
198200
},
199201
}),
200202
f: 1,
@@ -336,14 +338,6 @@ func TestSecureMintAggregatorConfig_Validation(t *testing.T) {
336338
expectError: true,
337339
errorMsg: "dataID must be 16 bytes",
338340
},
339-
{
340-
name: "solana account context with invalid public key",
341-
chainSelector: "1",
342-
dataID: "0x01c508f42b0201320000000000000000",
343-
solanaAccounts: solana.AccountMetaSlice{&solana.AccountMeta{PublicKey: [32]byte{}}},
344-
expectError: true,
345-
errorMsg: "solana account context public key must not be all zeros",
346-
},
347341
}
348342

349343
for _, tt := range tests {
@@ -373,7 +367,6 @@ func TestSecureMintAggregatorConfig_Validation(t *testing.T) {
373367
require.NoError(t, err)
374368
assert.Equal(t, tt.expectedChainSelector, aggregator.(*SecureMintAggregator).config.TargetChainSelector)
375369
assert.Equal(t, tt.expectedDataID, aggregator.(*SecureMintAggregator).config.DataID)
376-
assert.Equal(t, tt.solanaAccounts, aggregator.(*SecureMintAggregator).config.Solana.AccountContext)
377370
})
378371
}
379372
}
@@ -384,6 +377,7 @@ type ocrTriggerEventData struct {
384377
chainSelector chainSelector
385378
seqNr uint64
386379
report *secureMintReport
380+
accCtx solana.AccountMetaSlice
387381
}
388382

389383
func createSecureMintObservations(t *testing.T, events []ocrTriggerEventData) map[ocrcommon.OracleID][]values.Value {
@@ -421,10 +415,12 @@ func createSecureMintObservations(t *testing.T, events []ocrTriggerEventData) ma
421415
},
422416
}
423417

424-
// Wrap in values.Value
425-
val, err := values.Wrap(triggerEvent)
418+
// wrap with account context if present
419+
val, err := values.Wrap(map[string]any{
420+
"event": triggerEvent,
421+
"solana": event.accCtx,
422+
})
426423
require.NoError(t, err)
427-
428424
oracleObservations = append(oracleObservations, val)
429425
}
430426

pkg/capabilities/consensus/ocr3/ocr3cap/ocr3cap_common-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"encoder": {
4848
"type": "string",
49-
"enum": ["EVM", "ValueMap"]
49+
"enum": ["EVM","Borsh","ValueMap"]
5050
},
5151
"encoder_config": {
5252
"type": "object",

pkg/capabilities/consensus/ocr3/ocr3cap/ocr3cap_common_generated.go

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

pkg/settings/cresettings/defaults.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"WorkflowLimit": "200",
33
"WorkflowRegistrationQueueLimit": "20",
44
"WorkflowExecutionConcurrencyLimit": "50",
5-
"HTTPTrigger": {
6-
"AuthRateLimit": "100rps:-1"
7-
},
5+
"GatewayUnauthenticatedRequestRateLimit": "100rps:-1",
6+
"GatewayUnauthenticatedRequestRateLimitPerIP": "1rps:-1",
7+
"GatewayIncomingPayloadSizeLimit": "10kb",
88
"PerOrg": {
99
"WorkflowDeploymentRateLimit": "every1m0s:1",
1010
"ZeroBalancePruningTimeout": "24h0m0s"
@@ -37,10 +37,7 @@
3737
"RateLimit": "every30s:1"
3838
},
3939
"HTTPTrigger": {
40-
"RateLimit": "every30s:3",
41-
"AuthRateLimit": "1rps:-1",
42-
"IncomingPayloadSizeLimit": "10kb",
43-
"OutgoingPayloadSizeLimit": "-1b"
40+
"RateLimit": "every30s:3"
4441
},
4542
"LogTrigger": {
4643
"RateLimit": "every10s:-1",
@@ -53,7 +50,8 @@
5350
"RateLimit": "every30s:3",
5451
"ResponseSizeLimit": "10kb",
5552
"ConnectionTimeout": "10s",
56-
"RequestSizeLimit": "100kb"
53+
"RequestSizeLimit": "100kb",
54+
"CacheAgeLimit": "10m0s"
5755
},
5856
"ChainWrite": {
5957
"RateLimit": "every30s:3",

pkg/settings/cresettings/defaults.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
WorkflowLimit = '200'
22
WorkflowRegistrationQueueLimit = '20'
33
WorkflowExecutionConcurrencyLimit = '50'
4-
5-
[HTTPTrigger]
6-
AuthRateLimit = '100rps:-1'
4+
GatewayUnauthenticatedRequestRateLimit = '100rps:-1'
5+
GatewayUnauthenticatedRequestRateLimitPerIP = '1rps:-1'
6+
GatewayIncomingPayloadSizeLimit = '10kb'
77

88
[PerOrg]
99
WorkflowDeploymentRateLimit = 'every1m0s:1'
@@ -39,9 +39,6 @@ RateLimit = 'every30s:1'
3939

4040
[PerWorkflow.HTTPTrigger]
4141
RateLimit = 'every30s:3'
42-
AuthRateLimit = '1rps:-1'
43-
IncomingPayloadSizeLimit = '10kb'
44-
OutgoingPayloadSizeLimit = '-1b'
4542

4643
[PerWorkflow.LogTrigger]
4744
RateLimit = 'every10s:-1'
@@ -55,6 +52,7 @@ RateLimit = 'every30s:3'
5552
ResponseSizeLimit = '10kb'
5653
ConnectionTimeout = '10s'
5754
RequestSizeLimit = '100kb'
55+
CacheAgeLimit = '10m0s'
5856

5957
[PerWorkflow.ChainWrite]
6058
RateLimit = 'every30s:3'

0 commit comments

Comments
 (0)