Skip to content

Commit

Permalink
Update OnRampAddress and Root handling to match upstream contract cha…
Browse files Browse the repository at this point in the history
…nges
  • Loading branch information
archseer committed Feb 26, 2025
1 parent 72919fb commit eea6fa4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
4 changes: 1 addition & 3 deletions core/capabilities/ccip/ccipsolana/executecodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"fmt"
"strings"

ethcommon "github.com/ethereum/go-ethereum/common"
agbinary "github.com/gagliardetto/binary"
"github.com/gagliardetto/solana-go"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/common"
Expand Down Expand Up @@ -112,7 +111,7 @@ func (e *ExecutePluginCodecV1) Encode(ctx context.Context, report cciptypes.Exec
TokenAmounts: tokenAmounts,
ExtraArgs: extraArgs,
// TODO: is this available?
OnRampAddress: ethcommon.LeftPadBytes(msg.Header.OnRamp, 64),
OnRampAddress: msg.Header.OnRamp,
}

// should only have an offchain token data if there are tokens as part of the message
Expand All @@ -131,7 +130,6 @@ func (e *ExecutePluginCodecV1) Encode(ctx context.Context, report cciptypes.Exec
Message: message,
OffchainTokenData: offChainTokenData,
Proofs: solanaProofs,
Root: chainReport.Root,
}

var buf bytes.Buffer
Expand Down
9 changes: 9 additions & 0 deletions core/capabilities/ccip/configs/solana/contract_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ func DestContractReaderConfig() (config.ContractReader, error) {
},
})

// Prepend custom type so it takes priority over the IDL
offRampIDL.Types = append([]solanacodec.IdlTypeDef{{
Name: "OnRampAddress",
Type: solanacodec.IdlTypeDefTy{
Kind: solanacodec.IdlTypeDefTyKindCustom,

Check failure on line 48 in core/capabilities/ccip/configs/solana/contract_reader.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests_integration)

undefined: solanacodec.IdlTypeDefTyKindCustom

Check failure on line 48 in core/capabilities/ccip/configs/solana/contract_reader.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_race_tests)

undefined: solanacodec.IdlTypeDefTyKindCustom

Check failure on line 48 in core/capabilities/ccip/configs/solana/contract_reader.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_fuzz)

undefined: solanacodec.IdlTypeDefTyKindCustom

Check failure on line 48 in core/capabilities/ccip/configs/solana/contract_reader.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

undefined: solanacodec.IdlTypeDefTyKindCustom
Codec: "onramp_address",

Check failure on line 49 in core/capabilities/ccip/configs/solana/contract_reader.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests_integration)

unknown field Codec in struct literal of type "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec".IdlTypeDefTy

Check failure on line 49 in core/capabilities/ccip/configs/solana/contract_reader.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_race_tests)

unknown field Codec in struct literal of type "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec".IdlTypeDefTy

Check failure on line 49 in core/capabilities/ccip/configs/solana/contract_reader.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_fuzz)

unknown field Codec in struct literal of type "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec".IdlTypeDefTy

Check failure on line 49 in core/capabilities/ccip/configs/solana/contract_reader.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

unknown field Codec in struct literal of type "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec".IdlTypeDefTy
},
}}, offRampIDL.Types...)

var routerIDL solanacodec.IDL
if err := json.Unmarshal([]byte(ccipRouterIDL), &routerIDL); err != nil {
return config.ContractReader{}, fmt.Errorf("unexpected error: invalid CCIP Router IDL, error: %w", err)
Expand Down
10 changes: 5 additions & 5 deletions deployment/ccip/changeset/solana/cs_add_remote_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"strconv"

"github.com/ethereum/go-ethereum/common"
"github.com/gagliardetto/solana-go"

"github.com/smartcontractkit/mcms"
Expand Down Expand Up @@ -162,11 +161,12 @@ func doAddRemoteChainToSolana(
}

for remoteChainSel, update := range updates {
var onRampBytes [64]byte
var onRampAddress solOffRamp.OnRampAddress
// var onRampBytes [64]byte
// already verified, skipping errcheck
addressBytes, _ := s.GetOnRampAddressBytes(remoteChainSel)
addressBytes = common.LeftPadBytes(addressBytes, 64)
copy(onRampBytes[:], addressBytes)
copy(onRampAddress.Bytes[:], addressBytes)
onRampAddress.Len = uint32(len(addressBytes))

// verified while loading state
fqRemoteChainPDA, _, _ := solState.FindFqDestChainPDA(remoteChainSel, feeQuoterID)
Expand Down Expand Up @@ -286,7 +286,7 @@ func doAddRemoteChainToSolana(

solOffRamp.SetProgramID(offRampID)
validSourceChainConfig := solOffRamp.SourceChainConfig{
OnRamp: [2][64]byte{onRampBytes, [64]byte{}},
OnRamp: [2]solOffRamp.OnRampAddress{onRampAddress, {}},
IsEnabled: update.EnabledAsSource,
}
if offRampUsingMCMS {
Expand Down
2 changes: 1 addition & 1 deletion deployment/ccip/changeset/testhelpers/test_assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ func ConfirmCommitWithExpectedSeqNumRangeSol(
select {
case commitEvent := <-sink:
// if merkle root is zero, it only contains price updates
if commitEvent.Report.MerkleRoot == [32]uint8{} {
if commitEvent.Report == nil {
t.Logf("Skipping CommitReportAccepted with only price updates")
continue
}
Expand Down

0 comments on commit eea6fa4

Please sign in to comment.