Skip to content

Commit

Permalink
Merge branch 'develop' into ecpablo/token-pool-transfer-ownership-solana
Browse files Browse the repository at this point in the history
# Conflicts:
#	deployment/ccip/changeset/solana/cs_deploy_chain_test.go
  • Loading branch information
ecPablo committed Feb 27, 2025
2 parents 0e40040 + 6c0229e commit 927fd7e
Show file tree
Hide file tree
Showing 109 changed files with 6,634 additions and 1,074 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-penguins-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#added add exponential backoff retry to feeds.SyncNodeInfo()
5 changes: 5 additions & 0 deletions .changeset/swift-nails-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

go.mod update in core/scripts #updated
10 changes: 10 additions & 0 deletions .github/actions/goreleaser-build-sign-publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ inputs:
runs:
using: composite
steps:
# See https://github.com/orgs/community/discussions/25678#discussioncomment-5242449
- name: Delete unused tools to free up space
shell: bash
run: |
sudo rm -rf /opt/hostedtoolcache/CodeQL
sudo rm -rf /opt/hostedtoolcache/PyPy
sudo rm -rf /opt/hostedtoolcache/Python
sudo rm -rf /opt/hostedtoolcache/Ruby
sudo rm -rf /opt/hostedtoolcache/Java_*
- # We need QEMU to test the cross architecture builds after they're built.
name: Set up QEMU
uses: docker/setup-qemu-action@4574d27a4764455b42196d70a065bc6853246a25 # v3.4.0
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-publish-develop-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ jobs:
with:
persist-credentials: false
ref: ${{ env.CHECKOUT_REF }}
fetch-depth: 0
# nightly builds require a full clone for goreleaser to work
fetch-depth: ${{ needs.image-tag.outputs.release-type == 'nightly' && '0' || '1' }}

- name: Setup Github Token
id: token
Expand Down
9 changes: 7 additions & 2 deletions core/capabilities/ccip/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ func (l *launcher) processUpdate(ctx context.Context, updated map[registrysyncer
if err != nil {
return err
}
if len(newPlugins) == 0 {
// not a member of this DON.
continue
}

err = newPlugins.TransitionFrom(prevPlugins)
if err != nil {
Expand Down Expand Up @@ -314,7 +318,8 @@ func updateDON(
latestConfigs []ccipreader.OCR3ConfigWithMeta,
) (pluginRegistry, error) {
if !isMemberOfDON(don, p2pID) {
lggr.Infow("Not a member of this DON, skipping", "donId", don.ID, "p2pId", p2pID.String())
lggr.Infow("Not a member of this DON, skipping", "donID", don.ID, "p2pID", p2pID.String())
return nil, nil
}

newP := make(pluginRegistry)
Expand Down Expand Up @@ -349,7 +354,7 @@ func createDON(
configs []ccipreader.OCR3ConfigWithMeta,
) (pluginRegistry, error) {
if !isMemberOfDON(don, p2pID) && oracleCreator.Type() == cctypes.OracleTypePlugin {
lggr.Infow("Not a member of this DON and not a bootstrap node either, skipping", "donId", don.ID, "p2pId", p2pID.String())
lggr.Infow("Not a member of this DON and not a bootstrap node either, skipping", "donID", don.ID, "p2pID", p2pID.String())
return nil, nil
}
p := make(pluginRegistry)
Expand Down
139 changes: 79 additions & 60 deletions core/capabilities/ccip/ocrimpls/contract_transmitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,59 +18,76 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocr2key"
)

// ToCalldataFunc is a function that takes in the OCR3 report and signature data and processes them.
// It returns the contract name, method name, and arguments for the on-chain contract call.
// The ReportWithInfo bytes field is also decoded according to the implementation of this function,
// the commit and execute plugins have different representations for this data.
type ToCalldataFunc func(
rawReportCtx [2][32]byte,
report ocr3types.ReportWithInfo[[]byte],
rs, ss [][32]byte,
vs [32]byte,
) (any, error)
) (contract string, method string, args any, err error)

// NewToCommitCalldataFunc returns a ToCalldataFunc that is used to generate the calldata for the commit method.
// Multiple methods are accepted in order to allow for different methods to be called based on the report data.
// The Solana on-chain contract has two methods, one for the default commit and one for the price-only commit.
func NewToCommitCalldataFunc(defaultMethod, priceOnlyMethod string) ToCalldataFunc {
return func(
rawReportCtx [2][32]byte,
report ocr3types.ReportWithInfo[[]byte],
rs, ss [][32]byte,
vs [32]byte,
) (contract string, method string, args any, err error) {
// Note that the name of the struct field is very important, since the encoder used
// by the chainwriter uses mapstructure, which will use the struct field name to map
// to the argument name in the function call.
// If, for whatever reason, we want to change the field name, make sure to add a `mapstructure:"<arg_name>"` tag
// for that field.
var info ccipocr3.CommitReportInfo
if len(report.Info) != 0 {
var err error
info, err = ccipocr3.DecodeCommitReportInfo(report.Info)
if err != nil {
return "", "", nil, err
}
}

func ToCommitCalldata(
rawReportCtx [2][32]byte,
report ocr3types.ReportWithInfo[[]byte],
rs, ss [][32]byte,
vs [32]byte,
) (any, error) {
// Note that the name of the struct field is very important, since the encoder used
// by the chainwriter uses mapstructure, which will use the struct field name to map
// to the argument name in the function call.
// If, for whatever reason, we want to change the field name, make sure to add a `mapstructure:"<arg_name>"` tag
// for that field.
var info ccipocr3.CommitReportInfo
if len(report.Info) != 0 {
var err error
info, err = ccipocr3.DecodeCommitReportInfo(report.Info)
if err != nil {
return nil, err
method = defaultMethod
if priceOnlyMethod != "" && len(info.MerkleRoots) == 0 && len(info.TokenPrices) > 0 {
method = priceOnlyMethod
}
}

// WARNING: Be careful if you change the data types.
// Using a different type e.g. `type Foo [32]byte` instead of `[32]byte`
// will trigger undefined chainWriter behavior, e.g. transactions submitted with wrong arguments.
return struct {
ReportContext [2][32]byte
Report []byte
Rs [][32]byte
Ss [][32]byte
RawVs [32]byte
Info ccipocr3.CommitReportInfo
}{
ReportContext: rawReportCtx,
Report: report.Report,
Rs: rs,
Ss: ss,
RawVs: vs,
Info: info,
}, nil
// WARNING: Be careful if you change the data types.
// Using a different type e.g. `type Foo [32]byte` instead of `[32]byte`
// will trigger undefined chainWriter behavior, e.g. transactions submitted with wrong arguments.
return consts.ContractNameOffRamp,
method,
struct {
ReportContext [2][32]byte
Report []byte
Rs [][32]byte
Ss [][32]byte
RawVs [32]byte
Info ccipocr3.CommitReportInfo
}{
ReportContext: rawReportCtx,
Report: report.Report,
Rs: rs,
Ss: ss,
RawVs: vs,
Info: info,
}, nil
}
}

// ToExecCalldata is a ToCalldataFunc that is used to generate the calldata for the execute method.
func ToExecCalldata(
rawReportCtx [2][32]byte,
report ocr3types.ReportWithInfo[[]byte],
_, _ [][32]byte,
_ [32]byte,
) (any, error) {
) (contract string, method string, args any, err error) {
// Note that the name of the struct field is very important, since the encoder used
// by the chainwriter uses mapstructure, which will use the struct field name to map
// to the argument name in the function call.
Expand All @@ -85,28 +102,28 @@ func ToExecCalldata(
var err error
info, err = ccipocr3.DecodeExecuteReportInfo(report.Info)
if err != nil {
return nil, err
return "", "", nil, err
}
}

return struct {
ReportContext [2][32]byte
Report []byte
Info ccipocr3.ExecuteReportInfo
}{
ReportContext: rawReportCtx,
Report: report.Report,
Info: info,
}, nil
return consts.ContractNameOffRamp,
consts.MethodExecute,
struct {
ReportContext [2][32]byte
Report []byte
Info ccipocr3.ExecuteReportInfo
}{
ReportContext: rawReportCtx,
Report: report.Report,
Info: info,
}, nil
}

var _ ocr3types.ContractTransmitter[[]byte] = &ccipTransmitter{}

type ccipTransmitter struct {
cw commontypes.ContractWriter
fromAccount ocrtypes.Account
contractName string
method string
offrampAddress string
toCalldataFn ToCalldataFunc
}
Expand All @@ -119,28 +136,32 @@ func XXXNewContractTransmitterTestsOnly(
offrampAddress string,
toCalldataFn ToCalldataFunc,
) ocr3types.ContractTransmitter[[]byte] {
wrappedToCalldataFunc := func(rawReportCtx [2][32]byte,
report ocr3types.ReportWithInfo[[]byte],
rs, ss [][32]byte,
vs [32]byte) (string, string, any, error) {
_, _, args, err := toCalldataFn(rawReportCtx, report, rs, ss, vs)
return contractName, method, args, err
}
return &ccipTransmitter{
cw: cw,
fromAccount: fromAccount,
contractName: contractName,
method: method,
offrampAddress: offrampAddress,
toCalldataFn: toCalldataFn,
toCalldataFn: wrappedToCalldataFunc,
}
}

func NewCommitContractTransmitter(
cw commontypes.ContractWriter,
fromAccount ocrtypes.Account,
offrampAddress string,
defaultMethod, priceOnlyMethod string,
) ocr3types.ContractTransmitter[[]byte] {
return &ccipTransmitter{
cw: cw,
fromAccount: fromAccount,
contractName: consts.ContractNameOffRamp,
method: consts.MethodCommit,
offrampAddress: offrampAddress,
toCalldataFn: ToCommitCalldata,
toCalldataFn: NewToCommitCalldataFunc(defaultMethod, priceOnlyMethod),
}
}

Expand All @@ -152,8 +173,6 @@ func NewExecContractTransmitter(
return &ccipTransmitter{
cw: cw,
fromAccount: fromAccount,
contractName: consts.ContractNameOffRamp,
method: consts.MethodExecute,
offrampAddress: offrampAddress,
toCalldataFn: ToExecCalldata,
}
Expand Down Expand Up @@ -198,7 +217,7 @@ func (c *ccipTransmitter) Transmit(
}

// chain writer takes in the raw calldata and packs it on its own.
args, err := c.toCalldataFn(rawReportCtx, reportWithInfo, rs, ss, vs)
contract, method, args, err := c.toCalldataFn(rawReportCtx, reportWithInfo, rs, ss, vs)
if err != nil {
return fmt.Errorf("failed to generate call data: %w", err)
}
Expand All @@ -211,7 +230,7 @@ func (c *ccipTransmitter) Transmit(
return fmt.Errorf("failed to generate UUID: %w", err)
}
zero := big.NewInt(0)
if err := c.cw.SubmitTransaction(ctx, c.contractName, c.method, args, fmt.Sprintf("%s-%s-%s", c.contractName, c.offrampAddress, txID.String()), c.offrampAddress, &meta, zero); err != nil {
if err := c.cw.SubmitTransaction(ctx, contract, method, args, fmt.Sprintf("%s-%s-%s", contract, c.offrampAddress, txID.String()), c.offrampAddress, &meta, zero); err != nil {
return fmt.Errorf("failed to submit transaction thru chainwriter: %w", err)
}

Expand Down
5 changes: 3 additions & 2 deletions core/capabilities/ccip/ocrimpls/contract_transmitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ import (

"github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox"
"github.com/smartcontractkit/chainlink-common/pkg/utils/tests"
"github.com/smartcontractkit/chainlink-integrations/evm/heads"

"github.com/smartcontractkit/chainlink-ccip/pkg/consts"
"github.com/smartcontractkit/chainlink-integrations/evm/assets"
"github.com/smartcontractkit/chainlink-integrations/evm/client"
evmconfig "github.com/smartcontractkit/chainlink-integrations/evm/config"
"github.com/smartcontractkit/chainlink-integrations/evm/config/chaintype"
"github.com/smartcontractkit/chainlink-integrations/evm/config/toml"
"github.com/smartcontractkit/chainlink-integrations/evm/gas"
"github.com/smartcontractkit/chainlink-integrations/evm/heads"
"github.com/smartcontractkit/chainlink-integrations/evm/keystore"
"github.com/smartcontractkit/chainlink-integrations/evm/logpoller"
evmtestutils "github.com/smartcontractkit/chainlink-integrations/evm/testutils"
Expand Down Expand Up @@ -316,7 +317,7 @@ func newTestUniverse(t *testing.T, ks *keyringsAndSigners[[]byte]) *testUniverse
contractName,
methodTransmitWithSignatures,
ocr3HelperAddr.Hex(),
ocrimpls.ToCommitCalldata,
ocrimpls.NewToCommitCalldataFunc(consts.MethodCommit, ""),
)
transmitterWithoutSigs := ocrimpls.XXXNewContractTransmitterTestsOnly(
chainWriter,
Expand Down
5 changes: 5 additions & 0 deletions core/capabilities/ccip/oraclecreator/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ var plugins = map[string]plugin{
TokenDataEncoder: ccipsolana.NewSolanaTokenDataEncoder(),
GasEstimateProvider: ccipsolana.NewGasEstimateProvider(),
RMNCrypto: func(lggr logger.Logger) cciptypes.RMNCrypto { return nil },
PriceOnlyCommitFn: consts.MethodCommitPriceOnly,
},
}

Expand All @@ -94,6 +95,8 @@ type plugin struct {
TokenDataEncoder cciptypes.TokenDataEncoder
GasEstimateProvider cciptypes.EstimateProvider
RMNCrypto func(lggr logger.Logger) cciptypes.RMNCrypto
// PriceOnlyCommitFn optional method override for price only commit reports.
PriceOnlyCommitFn string
}

// pluginOracleCreator creates oracles that reference plugins running
Expand Down Expand Up @@ -354,6 +357,8 @@ func (i *pluginOracleCreator) createFactoryAndTransmitter(
transmitter = ocrimpls.NewCommitContractTransmitter(destChainWriter,
ocrtypes.Account(destFromAccounts[0]),
offrampAddrStr,
consts.MethodCommit,
plugins[chainFamily].PriceOnlyCommitFn,
)
} else if config.Config.PluginType == uint8(cctypes.PluginTypeCCIPExec) {
factory = execocr3.NewExecutePluginFactory(
Expand Down
6 changes: 2 additions & 4 deletions core/scripts/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/smartcontractkit/chainlink/core/scripts

go 1.24

toolchain go1.24.0
go 1.24.0

// Make sure we're working with the latest chainlink libs
replace github.com/smartcontractkit/chainlink/v2 => ../../
Expand Down Expand Up @@ -346,7 +344,7 @@ require (
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20250207205350-420ccacab78a // indirect
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250211162441-3d6cea220efb // indirect
github.com/smartcontractkit/chainlink-protos/job-distributor v0.9.0 // indirect
github.com/smartcontractkit/chainlink-protos/orchestrator v0.4.0 // indirect
github.com/smartcontractkit/chainlink-protos/orchestrator v0.5.0 // indirect
github.com/smartcontractkit/chainlink-protos/rmn/v1.6/go v0.0.0-20250131130834-15e0d4cde2a6 // indirect
github.com/smartcontractkit/chainlink-protos/svr v0.0.0-20250123084029-58cce9b32112 // indirect
github.com/smartcontractkit/chainlink-solana v1.1.2-0.20250213203720-e15b1333a14a // indirect
Expand Down
4 changes: 2 additions & 2 deletions core/scripts/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1107,8 +1107,8 @@ github.com/smartcontractkit/chainlink-integrations/evm v0.0.0-20250213145514-41d
github.com/smartcontractkit/chainlink-integrations/evm v0.0.0-20250213145514-41d874782c02/go.mod h1:7DbPnG0E39eZaX1CXKxRiJ1NOWHwTZYDWR9ys3kZZuU=
github.com/smartcontractkit/chainlink-protos/job-distributor v0.9.0 h1:hfMRj2ny6oNHd8w1rhJHdoX3YkoWJtCkBK6wTlCE4+c=
github.com/smartcontractkit/chainlink-protos/job-distributor v0.9.0/go.mod h1:/dVVLXrsp+V0AbcYGJo3XMzKg3CkELsweA/TTopCsKE=
github.com/smartcontractkit/chainlink-protos/orchestrator v0.4.0 h1:ZBat8EBvE2LpSQR9U1gEbRV6PfAkiFdINmQ8nVnXIAQ=
github.com/smartcontractkit/chainlink-protos/orchestrator v0.4.0/go.mod h1:m/A3lqD7ms/RsQ9BT5P2uceYY0QX5mIt4KQxT2G6qEo=
github.com/smartcontractkit/chainlink-protos/orchestrator v0.5.0 h1:xRgu/kMkxcY4LeDKMBhaXU4khgya7v2wyb4Sa5Nzb+Y=
github.com/smartcontractkit/chainlink-protos/orchestrator v0.5.0/go.mod h1:m/A3lqD7ms/RsQ9BT5P2uceYY0QX5mIt4KQxT2G6qEo=
github.com/smartcontractkit/chainlink-protos/rmn/v1.6/go v0.0.0-20250131130834-15e0d4cde2a6 h1:L6KJ4kGv/yNNoCk8affk7Y1vAY0qglPMXC/hevV/IsA=
github.com/smartcontractkit/chainlink-protos/rmn/v1.6/go v0.0.0-20250131130834-15e0d4cde2a6/go.mod h1:FRwzI3hGj4CJclNS733gfcffmqQ62ONCkbGi49s658w=
github.com/smartcontractkit/chainlink-protos/svr v0.0.0-20250123084029-58cce9b32112 h1:c77Gi/APraqwbBO8fbd/5JY2wW+MSIpYg8Uma9MEZFE=
Expand Down
Loading

0 comments on commit 927fd7e

Please sign in to comment.