@@ -20,57 +20,90 @@ import (
2020// https://github.com/smartcontractkit/chainlink-ccip/blob/7cae1b8434dd376eb70f2ddaace43093982f3a57/chains/solana/contracts/programs/rmn-remote/src/state.rs#L20-L27
2121var globalCurseValue = []byte {1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 }
2222
23- // getOffRampStaticConfig retrieves static configuration for the off-ramp contract
24- func (a * SolanaAccessor ) getOffRampStaticConfig (ctx context.Context ) (ccipocr3.OffRampStaticChainConfig , error ) {
23+ // getOffRampConfig retrieves static, dynamic, commitOCR3, and execOCR3 configurations for the off-ramp contract
24+ func (a * SolanaAccessor ) getOffRampConfig (ctx context.Context ) (ccipocr3.OfframpConfig , error ) {
2525 offrampAddr , err := a .getBinding (consts .ContractNameOffRamp )
2626 if err != nil {
27- return ccipocr3.OffRampStaticChainConfig {}, fmt .Errorf ("failed to get binding for offramp: %w" , err )
27+ return ccipocr3.OfframpConfig {}, fmt .Errorf ("failed to get binding for offramp: %w" , err )
2828 }
2929
3030 config , err := a .getOfframpConfig (ctx , offrampAddr )
3131 if err != nil {
32- return ccipocr3.OffRampStaticChainConfig {}, err
32+ return ccipocr3.OfframpConfig {}, err
3333 }
3434
3535 offrampRefAddress , err := a .getOfframpReferenceAddresses (ctx , offrampAddr )
3636 if err != nil {
37- return ccipocr3.OffRampStaticChainConfig {}, err
37+ return ccipocr3.OfframpConfig {}, err
3838 }
3939
40- return ccipocr3.OffRampStaticChainConfig {
40+ staticConfig := ccipocr3.OffRampStaticChainConfig {
4141 ChainSelector : ccipocr3 .ChainSelector (config .SvmChainSelector ),
4242 GasForCallExactCheck : 0 ,
4343 RmnRemote : offrampRefAddress .RmnRemote .Bytes (),
4444 TokenAdminRegistry : []byte {}, // PDA dependent on the token address
4545 NonceManager : offrampRefAddress .Router .Bytes (),
46- }, nil
47- }
46+ }
4847
49- // getOffRampDynamicConfig retrieves dynamic configuration for the off-ramp contract
50- func ( a * SolanaAccessor ) getOffRampDynamicConfig ( ctx context. Context ) (ccipocr3. OffRampDynamicChainConfig , error ) {
51- offrampAddr , err := a . getBinding ( consts . ContractNameOffRamp )
52- if err != nil {
53- return ccipocr3. OffRampDynamicChainConfig {}, fmt . Errorf ( "failed to get binding for offramp: %w" , err )
48+ dynamicConfig := ccipocr3. OffRampDynamicChainConfig {
49+ FeeQuoter : offrampRefAddress . FeeQuoter . Bytes (),
50+ PermissionLessExecutionThresholdSeconds : uint32 ( config . EnableManualExecutionAfter ), // nolint:gosec // G115: value validated to be within uint32 max above
51+ IsRMNVerificationDisabled : true ,
52+ MessageInterceptor : [] byte {}, // expected to be empty for solana
5453 }
5554
56- config , err := a .getOfframpConfig (ctx , offrampAddr )
57- if err != nil {
58- return ccipocr3.OffRampDynamicChainConfig {}, err
55+ commitConfig := config .Ocr3 [0 ]
56+ commitOCR3Config := ccipocr3.OCRConfigResponse {
57+ OCRConfig : ccipocr3.OCRConfig {
58+ ConfigInfo : ccipocr3.ConfigInfo {
59+ ConfigDigest : commitConfig .ConfigInfo .ConfigDigest ,
60+ F : commitConfig .ConfigInfo .F ,
61+ N : commitConfig .ConfigInfo .N ,
62+ IsSignatureVerificationEnabled : commitConfig .ConfigInfo .IsSignatureVerificationEnabled == 1 ,
63+ },
64+ Signers : convertSignersType (commitConfig .Signers ),
65+ Transmitters : convertTransmittersType (commitConfig .Transmitters ),
66+ },
5967 }
6068
61- offrampRefAddress , err := a .getOfframpReferenceAddresses (ctx , offrampAddr )
62- if err != nil {
63- return ccipocr3.OffRampDynamicChainConfig {}, err
69+ executeConfig := config .Ocr3 [1 ]
70+ executeOCR3Config := ccipocr3.OCRConfigResponse {
71+ OCRConfig : ccipocr3.OCRConfig {
72+ ConfigInfo : ccipocr3.ConfigInfo {
73+ ConfigDigest : executeConfig .ConfigInfo .ConfigDigest ,
74+ F : executeConfig .ConfigInfo .F ,
75+ N : executeConfig .ConfigInfo .N ,
76+ IsSignatureVerificationEnabled : executeConfig .ConfigInfo .IsSignatureVerificationEnabled == 1 ,
77+ },
78+ Signers : convertSignersType (executeConfig .Signers ),
79+ Transmitters : convertTransmittersType (executeConfig .Transmitters ),
80+ },
6481 }
6582
66- return ccipocr3.OffRampDynamicChainConfig {
67- FeeQuoter : offrampRefAddress . FeeQuoter . Bytes () ,
68- PermissionLessExecutionThresholdSeconds : uint32 ( config . EnableManualExecutionAfter ), // TODO: is this conversion dangerous?
69- IsRMNVerificationDisabled : true ,
70- MessageInterceptor : [] byte {} ,
83+ return ccipocr3.OfframpConfig {
84+ CommitLatestOCRConfig : commitOCR3Config ,
85+ ExecLatestOCRConfig : executeOCR3Config ,
86+ StaticConfig : staticConfig ,
87+ DynamicConfig : dynamicConfig ,
7188 }, nil
7289}
7390
91+ func convertSignersType (signers [16 ][20 ]uint8 ) [][]byte {
92+ newSigners := make ([][]byte , 0 , len (signers ))
93+ for _ , signer := range signers {
94+ newSigners = append (newSigners , signer [:])
95+ }
96+ return newSigners
97+ }
98+
99+ func convertTransmittersType (transmitters [16 ][32 ]uint8 ) [][]byte {
100+ newTransmitters := make ([][]byte , 0 , len (transmitters ))
101+ for _ , transmitter := range transmitters {
102+ newTransmitters = append (newTransmitters , transmitter [:])
103+ }
104+ return newTransmitters
105+ }
106+
74107// getOffRampSourceChainConfigs retrieves source chain configurations from the off-ramp contract
75108func (a * SolanaAccessor ) getOffRampSourceChainConfigs (ctx context.Context , sourceChainSelectors []ccipocr3.ChainSelector ) (map [ccipocr3.ChainSelector ]ccipocr3.SourceChainConfig , error ) {
76109 offrampAddr , err := a .getBinding (consts .ContractNameOffRamp )
0 commit comments