Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions core/capabilities/ccip/ccipaptos/executecodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/aptos-labs/aptos-go-sdk"
"github.com/aptos-labs/aptos-go-sdk/bcs"

"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"

cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
Expand All @@ -15,16 +16,16 @@ import (
// ExecutePluginCodecV1 is a codec for encoding and decoding execute plugin reports.
// Compatible with ccip_offramp::offramp version 1.6.0
type ExecutePluginCodecV1 struct {
extraDataCodec ccipocr3.ExtraDataCodec
extraDataCodec ccipocr3.ExtraDataCodecBundle
}

func NewExecutePluginCodecV1(extraDataCodec ccipocr3.ExtraDataCodec) *ExecutePluginCodecV1 {
func NewExecutePluginCodecV1(extraDataCodec ccipocr3.ExtraDataCodecBundle) *ExecutePluginCodecV1 {
return &ExecutePluginCodecV1{
extraDataCodec: extraDataCodec,
}
}

func (e *ExecutePluginCodecV1) Encode(ctx context.Context, report cciptypes.ExecutePluginReport) ([]byte, error) {
func (e *ExecutePluginCodecV1) Encode(ctx context.Context, report ccipocr3.ExecutePluginReport) ([]byte, error) {
if len(report.ChainReports) == 0 {
return nil, nil
}
Expand Down
2 changes: 1 addition & 1 deletion core/capabilities/ccip/ccipaptos/executecodec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func TestExecutePluginCodecV1(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
codec := NewExecutePluginCodecV1(registeredMockExtraDataCodecMap)
codec := NewExecutePluginCodecV1(ccipocr3.ExtraDataCodecMap(registeredMockExtraDataCodecMap))
// randomExecuteReport now uses the new encoding internally
report := tc.report(randomExecuteReport(t, tc.chainSelector, tc.gasLimit, tc.destGasAmount))
bytes, err := codec.Encode(ctx, report)
Expand Down
5 changes: 3 additions & 2 deletions core/capabilities/ccip/ccipaptos/msghasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"

"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"

"github.com/smartcontractkit/chainlink-ccip/pkg/logutil"
Expand All @@ -31,7 +32,7 @@ var (
// Compatible with ccip::offramp version 1.6.0
type MessageHasherV1 struct {
lggr logger.Logger
extraDataCodec ccipocr3.ExtraDataCodec
extraDataCodec ccipocr3.ExtraDataCodecBundle
}

type any2AptosTokenTransfer struct {
Expand All @@ -42,7 +43,7 @@ type any2AptosTokenTransfer struct {
Amount *big.Int
}

func NewMessageHasherV1(lggr logger.Logger, extraDataCodec ccipocr3.ExtraDataCodec) *MessageHasherV1 {
func NewMessageHasherV1(lggr logger.Logger, extraDataCodec ccipocr3.ExtraDataCodecBundle) *MessageHasherV1 {
return &MessageHasherV1{
lggr: lggr,
extraDataCodec: extraDataCodec,
Expand Down
2 changes: 1 addition & 1 deletion core/capabilities/ccip/ccipaptos/pluginconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

// initializePluginConfig returns a PluginConfig for Aptos chains.
func initializePluginConfigFunc(chainselFamily string) ccipcommon.InitFunction {
return func(lggr logger.Logger, extraDataCodec ccipocr3.ExtraDataCodec) ccipcommon.PluginConfig {
return func(lggr logger.Logger, extraDataCodec ccipocr3.ExtraDataCodecBundle) ccipcommon.PluginConfig {
var cwProvider ccipcommon.ChainRWProvider
var transmitterFactory types.ContractTransmitterFactory
var msgHasher ccipocr3.MessageHasher
Expand Down
7 changes: 4 additions & 3 deletions core/capabilities/ccip/ccipevm/executecodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
chainsel "github.com/smartcontractkit/chain-selectors"

"github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_0/offramp"
cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
Expand All @@ -19,10 +20,10 @@ import (
// - "OffRamp 1.6.0"
type ExecutePluginCodecV1 struct {
executeReportMethodInputs abi.Arguments
extraDataCodec ccipocr3.ExtraDataCodec
extraDataCodec ccipocr3.ExtraDataCodecBundle
}

func NewExecutePluginCodecV1(extraDataCodec ccipocr3.ExtraDataCodec) *ExecutePluginCodecV1 {
func NewExecutePluginCodecV1(extraDataCodec ccipocr3.ExtraDataCodecBundle) *ExecutePluginCodecV1 {
abiParsed, err := abi.JSON(strings.NewReader(offramp.OffRampABI))
if err != nil {
panic(fmt.Errorf("parse multi offramp abi: %s", err))
Expand All @@ -38,7 +39,7 @@ func NewExecutePluginCodecV1(extraDataCodec ccipocr3.ExtraDataCodec) *ExecutePlu
}
}

func (e *ExecutePluginCodecV1) Encode(ctx context.Context, report cciptypes.ExecutePluginReport) ([]byte, error) {
func (e *ExecutePluginCodecV1) Encode(ctx context.Context, report ccipocr3.ExecutePluginReport) ([]byte, error) {
evmReport := make([]offramp.InternalExecutionReport, 0, len(report.ChainReports))

for _, chainReport := range report.ChainReports {
Expand Down
9 changes: 5 additions & 4 deletions core/capabilities/ccip/ccipevm/executecodec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
chainsel "github.com/smartcontractkit/chain-selectors"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_0/message_hasher"
"github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_0/offramp"
"github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_0/report_codec"
Expand All @@ -22,9 +26,6 @@ import (
"github.com/smartcontractkit/chainlink-evm/pkg/utils"
"github.com/smartcontractkit/chainlink/v2/core/capabilities/ccip/common/mocks"
"github.com/smartcontractkit/chainlink/v2/core/internal/testutils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)

var randomExecuteReport = func(t *testing.T, d *testSetupData, chainSelector uint64, gasLimit *big.Int, destGasAmount uint32) cciptypes.ExecutePluginReport {
Expand Down Expand Up @@ -187,7 +188,7 @@ func TestExecutePluginCodecV1(t *testing.T) {

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
edc := ccipocr3.ExtraDataCodec(registeredMockExtraDataCodecMap)
edc := ccipocr3.ExtraDataCodecMap(registeredMockExtraDataCodecMap)
codec := NewExecutePluginCodecV1(edc)
report := tc.report(randomExecuteReport(t, d, tc.chainSelector, tc.gasLimit, tc.destGasAmount))
bytes, err := codec.Encode(ctx, report)
Expand Down
5 changes: 3 additions & 2 deletions core/capabilities/ccip/ccipevm/gas_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math"

"github.com/pkg/errors"

"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"

cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
Expand Down Expand Up @@ -34,14 +35,14 @@ const (
DestGasOverhead = 300_000 // Commit and Exec costs
)

func NewGasEstimateProvider(codec ccipocr3.ExtraDataCodec) EstimateProvider {
func NewGasEstimateProvider(codec ccipocr3.ExtraDataCodecBundle) EstimateProvider {
return EstimateProvider{
extraDataCodec: codec,
}
}

type EstimateProvider struct {
extraDataCodec ccipocr3.ExtraDataCodec
extraDataCodec ccipocr3.ExtraDataCodecBundle
}

// CalculateMerkleTreeGas estimates the merkle tree gas based on number of requests
Expand Down
2 changes: 1 addition & 1 deletion core/capabilities/ccip/ccipevm/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func ABITypeOrPanic(t string) abi.Type {

// CCIPMsgToAny2EVMMessage converts a ccipocr3.Message object to an offramp.InternalAny2EVMRampMessage object.
// These are typically used to create the execution report for EVM.
func CCIPMsgToAny2EVMMessage(msg ccipocr3.Message, codec ccipocr3.ExtraDataCodec) (offramp.InternalAny2EVMRampMessage, error) {
func CCIPMsgToAny2EVMMessage(msg ccipocr3.Message, codec ccipocr3.ExtraDataCodecBundle) (offramp.InternalAny2EVMRampMessage, error) {
var tokenAmounts []offramp.InternalAny2EVMTokenTransfer
for _, rta := range msg.TokenAmounts {
decodedMap, err := codec.DecodeTokenAmountDestExecData(rta.DestExecData, msg.Header.SourceChainSelector)
Expand Down
5 changes: 3 additions & 2 deletions core/capabilities/ccip/ccipevm/manualexeclib/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"

"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"

"github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_0/offramp"
Expand All @@ -22,7 +23,7 @@ func GetMessageHashes(
lggr logger.Logger,
onrampAddress common.Address,
ccipMessageSentEvents []onramp.OnRampCCIPMessageSent,
extraDataCodec ccipocr3.ExtraDataCodec,
extraDataCodec ccipocr3.ExtraDataCodecBundle,
) ([][32]byte, error) {
msgHasher := ccipevm.NewMessageHasherV1(
lggr,
Expand Down Expand Up @@ -107,7 +108,7 @@ func CreateExecutionReport(
ccipMessageSentEvents []onramp.OnRampCCIPMessageSent,
hashes [][32]byte,
flags *big.Int,
extraDataCodec ccipocr3.ExtraDataCodec,
extraDataCodec ccipocr3.ExtraDataCodecBundle,
) (offramp.InternalExecutionReport, error) {
var any2EVMs []offramp.InternalAny2EVMRampMessage
for _, event := range ccipMessageSentEvents {
Expand Down
5 changes: 3 additions & 2 deletions core/capabilities/ccip/ccipevm/msghasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
chainsel "github.com/smartcontractkit/chain-selectors"

"github.com/smartcontractkit/chainlink-ccip/chains/evm/gobindings/generated/v1_6_0/message_hasher"
"github.com/smartcontractkit/chainlink-ccip/pkg/logutil"
cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
Expand Down Expand Up @@ -47,10 +48,10 @@ var (
// - "OnRamp 1.6.0"
type MessageHasherV1 struct {
lggr logger.Logger
extraDataCodec ccipocr3.ExtraDataCodec
extraDataCodec ccipocr3.ExtraDataCodecBundle
}

func NewMessageHasherV1(lggr logger.Logger, extraDataCodec ccipocr3.ExtraDataCodec) *MessageHasherV1 {
func NewMessageHasherV1(lggr logger.Logger, extraDataCodec ccipocr3.ExtraDataCodecBundle) *MessageHasherV1 {
return &MessageHasherV1{
lggr: lggr,
extraDataCodec: extraDataCodec,
Expand Down
2 changes: 1 addition & 1 deletion core/capabilities/ccip/ccipevm/msghasher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
"github.com/stretchr/testify/require"
)

var extraDataCodec = ccipocr3.ExtraDataCodec(map[string]ccipocr3.SourceChainExtraDataCodec{
var extraDataCodec = ccipocr3.ExtraDataCodecMap(map[string]ccipocr3.SourceChainExtraDataCodec{
chainsel.FamilyAptos: ccipaptos.ExtraDataDecoder{},
chainsel.FamilyEVM: ExtraDataDecoder{},
chainsel.FamilySolana: ccipsolana.ExtraDataDecoder{},
Expand Down
3 changes: 2 additions & 1 deletion core/capabilities/ccip/ccipevm/pluginconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package ccipevm

import (
chainsel "github.com/smartcontractkit/chain-selectors"

"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"

"github.com/smartcontractkit/chainlink-common/pkg/logger"
Expand All @@ -13,7 +14,7 @@ import (
const defaultCommitGasLimit = 500_000

// InitializePluginConfig returns a PluginConfig for EVM chains.
func InitializePluginConfig(lggr logger.Logger, extraDataCodec ccipocr3.ExtraDataCodec) ccipcommon.PluginConfig {
func InitializePluginConfig(lggr logger.Logger, extraDataCodec ccipocr3.ExtraDataCodecBundle) ccipcommon.PluginConfig {
return ccipcommon.PluginConfig{
CommitPluginCodec: NewCommitPluginCodecV1(),
ExecutePluginCodec: NewExecutePluginCodecV1(extraDataCodec),
Expand Down
4 changes: 2 additions & 2 deletions core/capabilities/ccip/ccipnoop/executecodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
// Compatible with:
// - "OffRamp 1.6.0-dev"
type ExecutePluginCodecV1 struct {
extraDataCodec ccipocr3.ExtraDataCodec
extraDataCodec ccipocr3.ExtraDataCodecBundle
}

func NewExecutePluginCodecV1(extraDataCodec ccipocr3.ExtraDataCodec) *ExecutePluginCodecV1 {
func NewExecutePluginCodecV1(extraDataCodec ccipocr3.ExtraDataCodecBundle) *ExecutePluginCodecV1 {
return &ExecutePluginCodecV1{
extraDataCodec: extraDataCodec,
}
Expand Down
4 changes: 2 additions & 2 deletions core/capabilities/ccip/ccipnoop/gas_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
)

func NewGasEstimateProvider(codec ccipocr3.ExtraDataCodec) ccipocr3.EstimateProvider {
func NewGasEstimateProvider(codec ccipocr3.ExtraDataCodecBundle) ccipocr3.EstimateProvider {
return estimateProvider{
extraDataCodec: codec,
}
}

type estimateProvider struct {
extraDataCodec ccipocr3.ExtraDataCodec
extraDataCodec ccipocr3.ExtraDataCodecBundle
}

// CalculateMerkleTreeGas is not implemented
Expand Down
4 changes: 2 additions & 2 deletions core/capabilities/ccip/ccipnoop/msghasher.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
// - "OnRamp 1.6.0-dev"
type MessageHasherV1 struct {
lggr logger.Logger
extraDataCodec ccipocr3.ExtraDataCodec
extraDataCodec ccipocr3.ExtraDataCodecBundle
}

func NewMessageHasherV1(lggr logger.Logger, extraDataCodec ccipocr3.ExtraDataCodec) *MessageHasherV1 {
func NewMessageHasherV1(lggr logger.Logger, extraDataCodec ccipocr3.ExtraDataCodecBundle) *MessageHasherV1 {
return &MessageHasherV1{
lggr: lggr,
extraDataCodec: extraDataCodec,
Expand Down
2 changes: 1 addition & 1 deletion core/capabilities/ccip/ccipnoop/pluginconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// NewPluginConfig returns a pluginConfig .
func NewPluginConfig(lggr logger.Logger, extraDataCodec ccipocr3.ExtraDataCodec) ccipcommon.PluginConfig {
func NewPluginConfig(lggr logger.Logger, extraDataCodec ccipocr3.ExtraDataCodecBundle) ccipcommon.PluginConfig {
return ccipcommon.PluginConfig{
CommitPluginCodec: NewCommitPluginCodecV1(),
ExecutePluginCodec: NewExecutePluginCodecV1(extraDataCodec),
Expand Down
9 changes: 5 additions & 4 deletions core/capabilities/ccip/ccipsolana/executecodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

agbinary "github.com/gagliardetto/binary"
"github.com/gagliardetto/solana-go"

"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/latest/ccip_offramp"
cciptypes "github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
Expand All @@ -20,16 +21,16 @@ import (
// Compatible with:
// - "OffRamp 1.6.0-dev"
type ExecutePluginCodecV1 struct {
extraDataCodec ccipocr3.ExtraDataCodec
extraDataCodec ccipocr3.ExtraDataCodecBundle
}

func NewExecutePluginCodecV1(extraDataCodec ccipocr3.ExtraDataCodec) *ExecutePluginCodecV1 {
func NewExecutePluginCodecV1(extraDataCodecBundle ccipocr3.ExtraDataCodecBundle) *ExecutePluginCodecV1 {
return &ExecutePluginCodecV1{
extraDataCodec: extraDataCodec,
extraDataCodec: extraDataCodecBundle,
}
}

func (e *ExecutePluginCodecV1) Encode(ctx context.Context, report cciptypes.ExecutePluginReport) ([]byte, error) {
func (e *ExecutePluginCodecV1) Encode(ctx context.Context, report ccipocr3.ExecutePluginReport) ([]byte, error) {
if len(report.ChainReports) == 0 {
// OCR3 runs in a constant loop and will produce empty reports, so we need to handle this case
// return an empty report, CCIP will discard it on ShouldAcceptAttestedReport/ShouldTransmitAcceptedReport
Expand Down
6 changes: 3 additions & 3 deletions core/capabilities/ccip/ccipsolana/executecodec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func TestExecutePluginCodecV1(t *testing.T) {
chainsel.FamilySolana: mockExtraDataCodec,
}

edc := ccipocr3.ExtraDataCodec(registeredMockExtraDataCodecMap)
edc := ccipocr3.ExtraDataCodecMap(registeredMockExtraDataCodecMap)
cd := NewExecutePluginCodecV1(edc)

for _, tc := range testCases {
Expand Down Expand Up @@ -269,7 +269,7 @@ func Test_DecodingExecuteReport(t *testing.T) {
err = onChainReport.MarshalWithEncoder(encoder)
require.NoError(t, err)

edc := ccipocr3.ExtraDataCodec(registeredMockExtraDataCodecMap)
edc := ccipocr3.ExtraDataCodecMap(registeredMockExtraDataCodecMap)
executeCodec := NewExecutePluginCodecV1(edc)
decode, err := executeCodec.Decode(testutils.Context(t), buf.Bytes())
require.NoError(t, err)
Expand All @@ -286,7 +286,7 @@ func Test_DecodingExecuteReport(t *testing.T) {

t.Run("decode Borsh encoded execute report", func(t *testing.T) {
ocrReport := randomExecuteReport(t, 124615329519749607)
edc := ccipocr3.ExtraDataCodec(registeredMockExtraDataCodecMap)
edc := ccipocr3.ExtraDataCodecMap(registeredMockExtraDataCodecMap)
cd := NewExecutePluginCodecV1(edc)
encodedReport, err := cd.Encode(testutils.Context(t), ocrReport)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions core/capabilities/ccip/ccipsolana/gas_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ const (
DestGasOverhead = 350_000 // Commit and Exec costs
)

func NewGasEstimateProvider(codec ccipocr3.ExtraDataCodec) EstimateProvider {
func NewGasEstimateProvider(codec ccipocr3.ExtraDataCodecBundle) EstimateProvider {
return EstimateProvider{
extraDataCodec: codec,
}
}

type EstimateProvider struct {
extraDataCodec ccipocr3.ExtraDataCodec
extraDataCodec ccipocr3.ExtraDataCodecBundle
}

// CalculateMerkleTreeGas is not implemented
Expand Down
4 changes: 2 additions & 2 deletions core/capabilities/ccip/ccipsolana/gas_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func Test_calculateMessageMaxGas(t *testing.T) {
}
// Set the source chain selector to be EVM for now
msg.Header.SourceChainSelector = ccipocr3.ChainSelector(chainsel.SOLANA_TESTNET.Selector)
edc := ccipocr3.ExtraDataCodec(map[string]ccipocr3.SourceChainExtraDataCodec{
edc := ccipocr3.ExtraDataCodecMap(map[string]ccipocr3.SourceChainExtraDataCodec{
chainsel.FamilyEVM: ccipevm.ExtraDataDecoder{},
chainsel.FamilySolana: ExtraDataDecoder{},
})
Expand Down Expand Up @@ -100,7 +100,7 @@ func TestCalculateMaxGas(t *testing.T) {
}

msg.Header.SourceChainSelector = ccipocr3.ChainSelector(chainsel.SOLANA_TESTNET.Selector)
edc := ccipocr3.ExtraDataCodec(map[string]ccipocr3.SourceChainExtraDataCodec{
edc := ccipocr3.ExtraDataCodecMap(map[string]ccipocr3.SourceChainExtraDataCodec{
chainsel.FamilyEVM: ccipevm.ExtraDataDecoder{},
chainsel.FamilySolana: ExtraDataDecoder{},
})
Expand Down
Loading
Loading