@@ -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
7277type 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.
8181type 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
106105type chainReportFormatter interface {
107- packReport (lggr logger.Logger , report * secureMintReport ) (* values.Map , error )
106+ packReport (lggr logger.Logger , report * wrappedMintReport ) (* values.Map , error )
108107}
109108
110109type 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
147147type 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
193194func 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.
386398func 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
0 commit comments