@@ -238,7 +238,12 @@ func BuildSetOCR3ConfigArgsSolana(
238238 donID uint32 ,
239239 ccipHome * ccip_home.CCIPHome ,
240240 destSelector uint64 ,
241+ configType globals.ConfigType ,
241242) ([]MultiOCR3BaseOCRConfigArgsSolana , error ) {
243+ chainCfg , err := ccipHome .GetChainConfig (nil , destSelector )
244+ if err != nil {
245+ return nil , fmt .Errorf ("error getting chain config for chain selector %d it must be set before OCR3Config set up: %w" , destSelector , err )
246+ }
242247 ocr3Configs := make ([]MultiOCR3BaseOCRConfigArgsSolana , 0 )
243248 for _ , pluginType := range []types.PluginType {types .PluginTypeCCIPCommit , types .PluginTypeCCIPExec } {
244249 ocrConfig , err2 := ccipHome .GetAllConfigs (& bind.CallOpts {
@@ -248,15 +253,30 @@ func BuildSetOCR3ConfigArgsSolana(
248253 return nil , err2
249254 }
250255
251- // we expect only an active config and no candidate config.
252- if ocrConfig .ActiveConfig .ConfigDigest == [32 ]byte {} || ocrConfig .CandidateConfig .ConfigDigest != [32 ]byte {} {
253- return nil , fmt .Errorf ("invalid OCR3 config state, expected active config and no candidate config, donID: %d" , donID )
256+ fmt .Printf ("pluginType: %s, destSelector: %d, donID: %d, activeConfig digest: %x, candidateConfig digest: %x\n " ,
257+ pluginType .String (), destSelector , donID , ocrConfig .ActiveConfig .ConfigDigest , ocrConfig .CandidateConfig .ConfigDigest )
258+
259+ configForOCR3 := ocrConfig .ActiveConfig
260+ // we expect only an active config
261+ if configType == globals .ConfigTypeActive {
262+ if ocrConfig .ActiveConfig .ConfigDigest == [32 ]byte {} {
263+ return nil , fmt .Errorf ("invalid OCR3 config state, expected active config, donID: %d, activeConfig: %v, candidateConfig: %v" ,
264+ donID , hexutil .Encode (ocrConfig .ActiveConfig .ConfigDigest [:]), hexutil .Encode (ocrConfig .CandidateConfig .ConfigDigest [:]))
265+ }
266+ } else if configType == globals .ConfigTypeCandidate {
267+ if ocrConfig .CandidateConfig .ConfigDigest == [32 ]byte {} {
268+ return nil , fmt .Errorf ("invalid OCR3 config state, expected candidate config, donID: %d, activeConfig: %v, candidateConfig: %v" ,
269+ donID , hexutil .Encode (ocrConfig .ActiveConfig .ConfigDigest [:]), hexutil .Encode (ocrConfig .CandidateConfig .ConfigDigest [:]))
270+ }
271+ configForOCR3 = ocrConfig .CandidateConfig
272+ }
273+ if err := validateOCR3Config (destSelector , configForOCR3 .Config , & chainCfg ); err != nil {
274+ return nil , err
254275 }
255276
256- activeConfig := ocrConfig .ActiveConfig
257277 var signerAddresses [][20 ]byte
258278 var transmitterAddresses []solana.PublicKey
259- for _ , node := range activeConfig .Config .Nodes {
279+ for _ , node := range configForOCR3 .Config .Nodes {
260280 var signer [20 ]uint8
261281 if len (node .SignerKey ) != 20 {
262282 return nil , fmt .Errorf ("node signer key not 20 bytes long, got: %d" , len (node .SignerKey ))
@@ -268,9 +288,9 @@ func BuildSetOCR3ConfigArgsSolana(
268288 }
269289
270290 ocr3Configs = append (ocr3Configs , MultiOCR3BaseOCRConfigArgsSolana {
271- ConfigDigest : activeConfig .ConfigDigest ,
291+ ConfigDigest : configForOCR3 .ConfigDigest ,
272292 OCRPluginType : uint8 (pluginType ),
273- F : activeConfig .Config .FRoleDON ,
293+ F : configForOCR3 .Config .FRoleDON ,
274294 IsSignatureVerificationEnabled : pluginType == types .PluginTypeCCIPCommit ,
275295 Signers : signerAddresses ,
276296 Transmitters : transmitterAddresses ,
0 commit comments