Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing chain dependencies from NewCommitServices construct #1361

Merged
merged 49 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
62e4ebb
WIP; moved DynamicPriceGetterClient initialization to delegate from N…
patrickhuie19 Aug 24, 2024
be11827
WIP; contract readers added as field to DynamicPriceGetter and sketch…
patrickhuie19 Aug 25, 2024
db741df
fix test usage of NewDynamicPriceGetter
patrickhuie19 Aug 26, 2024
1b54a20
WIP: added contract reader config and bindings
patrickhuie19 Aug 26, 2024
2324aaa
added debug image for smoke tests with delve and minor WIP steps towa…
patrickhuie19 Sep 2, 2024
8d48404
WIP use of CR for decimals results
patrickhuie19 Sep 3, 2024
12f8336
expose delve port
Tofel Sep 3, 2024
bddf006
fixing bug in build_ccip_debug_image make command naming
patrickhuie19 Sep 3, 2024
b722a32
Adding install-chainlink-delve make command
patrickhuie19 Sep 3, 2024
7c339fa
minor fix to last commit
patrickhuie19 Sep 3, 2024
34b527f
updated debug Dockerfile with delve installed in final image
patrickhuie19 Sep 3, 2024
0f7919a
run cl node container with dlv
Tofel Sep 3, 2024
366678f
use full dlv path
Tofel Sep 3, 2024
cbe3edf
try another path
Tofel Sep 3, 2024
51d6b40
chainlink starts with dlv
Tofel Sep 3, 2024
12c08b3
changing final image for debug Dockerfile to golang:1.22-bullseye
patrickhuie19 Sep 4, 2024
86d76bb
udpated TestDynamicPriceGetterWithEmptyInput to use CR mocks
patrickhuie19 Sep 4, 2024
261d655
using GetEndpointFromPort in integration tests
patrickhuie19 Sep 6, 2024
adac213
fixed panic in Test_CLOSpecApprovalFlow_dynamicPriceGetter
patrickhuie19 Sep 15, 2024
01679b4
bumping CTF
patrickhuie19 Sep 15, 2024
ca39bad
bumping go.mod
patrickhuie19 Sep 15, 2024
8907d7d
Merge branch 'ccip-develop' into feature/commit-init-no-evm
patrickhuie19 Sep 15, 2024
7d7ce5d
undoing mod bumps
patrickhuie19 Sep 15, 2024
227f336
bumping only CTF in integration-tests module
patrickhuie19 Sep 15, 2024
52c76de
Test_CLOSpecApprovalFlow_dynamicPriceGetter passes
patrickhuie19 Sep 16, 2024
669a292
fixed TestDynamicPriceGetterWithEmptyInput
patrickhuie19 Sep 16, 2024
2e31c05
Merge branch 'ccip-develop' into feature/commit-init-no-evm
patrickhuie19 Sep 16, 2024
87adf08
updating to use LatestRound CR + lint
patrickhuie19 Sep 16, 2024
5a46504
reverting entrypoint to not use dlv binary
patrickhuie19 Sep 16, 2024
5e379a2
fixed overwriting of results struct by ChainReader, identified potent…
patrickhuie19 Sep 16, 2024
807211d
fixed conflicting contract names with indexed bindings. confirmed non…
patrickhuie19 Sep 16, 2024
25d5921
fixed map iteration bug in Test_CLOSpecApprovalFlow_dynamicPriceGetter
patrickhuie19 Sep 17, 2024
7345eed
fixed TestDynamicPriceGetterWithEmptyInput again
patrickhuie19 Sep 17, 2024
db2aa5f
cleaned up hanging legacy evm batch call code from evm pricegetter'
patrickhuie19 Sep 18, 2024
a9622fb
cleaned up legacy clients in newServicesCommit
patrickhuie19 Sep 18, 2024
5666f17
minor fix
patrickhuie19 Sep 18, 2024
4aeb68c
lint
patrickhuie19 Sep 18, 2024
ff89cd7
lint
patrickhuie19 Sep 18, 2024
cf3ed67
clarifying comments
patrickhuie19 Sep 18, 2024
6cec7f1
cleaning up delve entrypoint integ tests and minor refactoring for cl…
patrickhuie19 Sep 18, 2024
0b5b79d
using job spec to determine the number of contract addresses per chai…
patrickhuie19 Sep 19, 2024
bf0e31c
wrapping errors, exporting OffchainAggregator metadata vars
patrickhuie19 Sep 23, 2024
db4ec4c
Merge branch 'ccip-develop' into feature/commit-init-no-evm
patrickhuie19 Sep 24, 2024
f1a505c
fixing import cycle
patrickhuie19 Sep 24, 2024
b323a8b
Try different runner for e2e test
lukaszcl Sep 26, 2024
6007b86
Revert "Try different runner for e2e test"
lukaszcl Sep 26, 2024
c5f3590
Feature/commit init no evm lf tests (#1470)
lukaszcl Sep 26, 2024
a1ad4db
Merge branch 'ccip-develop' into feature/commit-init-no-evm
patrickhuie19 Sep 26, 2024
aab6be2
Merge branch 'ccip-develop' into feature/commit-init-no-evm
patrickhuie19 Sep 26, 2024
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
4 changes: 4 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ install-chainlink: operator-ui ## Install the chainlink binary.
install-chainlink-cover: operator-ui ## Install the chainlink binary with cover flag.
go install -cover $(GOFLAGS) .

.PHONY: install-chainlink-delve
install-chainlink-delve: operator-ui ## Install the chainlink binary.
go install $(GOFLAGS) -gcflags "all=-N -l" .
Comment on lines +51 to +53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this? It doesn't seem to have anything to do with delve

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -gcflags "all=-N -l" portion of this compiles the binary in a way that allows a debugger to step through.


.PHONY: chainlink
chainlink: ## Build the chainlink binary.
go build $(GOFLAGS) .
Expand Down
97 changes: 97 additions & 0 deletions core/chainlink.debug.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Build image: Chainlink binary
patrickhuie19 marked this conversation as resolved.
Show resolved Hide resolved
FROM golang:1.22-bullseye as buildgo
RUN go version
WORKDIR /chainlink

COPY GNUmakefile package.json ./
COPY tools/bin/ldflags ./tools/bin/

ADD go.mod go.sum ./
RUN go mod download

# Env vars needed for chainlink build
ARG COMMIT_SHA

# Build chainlink bin with cover flag https://go.dev/doc/build-cover#FAQ
ARG GO_COVER_FLAG=false

COPY . .

RUN apt-get update && apt-get install -y jq

# Build the golang binary
RUN if [ "$GO_COVER_FLAG" = "true" ]; then \
make install-chainlink-cover; \
else \
make install-chainlink-delve; \
fi

# Link LOOP Plugin source dirs with simple names
RUN go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-feeds | xargs -I % ln -s % /chainlink-feeds
RUN go list -m -f "{{.Dir}}" github.com/smartcontractkit/chainlink-solana | xargs -I % ln -s % /chainlink-solana

# Build image: Plugins
FROM golang:1.22-bullseye as buildplugins
RUN go version

WORKDIR /chainlink-feeds
COPY --from=buildgo /chainlink-feeds .
RUN go install ./cmd/chainlink-feeds

WORKDIR /chainlink-solana
COPY --from=buildgo /chainlink-solana .
RUN go install ./pkg/solana/cmd/chainlink-solana

# Final image: ubuntu with chainlink binary
FROM golang:1.22-bullseye

ARG CHAINLINK_USER=root
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y ca-certificates gnupg lsb-release curl

# Install Postgres for CLI tools, needed specifically for DB backups
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |tee /etc/apt/sources.list.d/pgdg.list \
&& apt-get update && apt-get install -y postgresql-client-16 \
&& apt-get clean all \
&& rm -rf /var/lib/apt/lists/*

COPY --from=buildgo /go/bin/chainlink /usr/local/bin/

# Install (but don't enable) LOOP Plugins
COPY --from=buildplugins /go/bin/chainlink-feeds /usr/local/bin/
COPY --from=buildplugins /go/bin/chainlink-solana /usr/local/bin/

# Dependency of CosmWasm/wasmd
COPY --from=buildgo /go/pkg/mod/github.com/\!cosm\!wasm/wasmvm@v*/internal/api/libwasmvm.*.so /usr/lib/
RUN chmod 755 /usr/lib/libwasmvm.*.so

RUN if [ ${CHAINLINK_USER} != root ]; then \
useradd --uid 14933 --create-home ${CHAINLINK_USER}; \
fi
USER ${CHAINLINK_USER}
WORKDIR /home/${CHAINLINK_USER}
RUN mkdir -p go
# explicit set the cache dir. needed so both root and non-root user has an explicit location
ENV XDG_CACHE_HOME /home/${CHAINLINK_USER}/.cache
RUN mkdir -p ${XDG_CACHE_HOME}

# Set up env and dir for go coverage profiling https://go.dev/doc/build-cover#FAQ
ARG GO_COVER_DIR="/var/tmp/go-coverage"
ENV GOCOVERDIR=${GO_COVER_DIR}
RUN mkdir -p $GO_COVER_DIR

# Install dlv
ENV GOPATH=/home/${CHAINLINK_USER}/go
ENV PATH=$PATH:$GOPATH/bin
RUN go install github.com/go-delve/delve/cmd/dlv@latest

EXPOSE 6688
ENTRYPOINT ["chainlink"]

HEALTHCHECK CMD curl -f http://localhost:6688/health || exit 1

# Delve port
EXPOSE 40000

CMD ["dlv", "exec", "/usr/local/bin/chainlink", "--accept-multiclient", "--headless", "--listen=0.0.0.0:40000", "--api-version=2", "--", "local", "node"]
92 changes: 80 additions & 12 deletions core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@ import (
"fmt"
"log"
"strconv"
"strings"
"time"

"gopkg.in/guregu/null.v4"

cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip"
"github.com/smartcontractkit/chainlink-common/pkg/types/core"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config"

"github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"google.golang.org/grpc"
"gopkg.in/guregu/null.v4"

chainselectors "github.com/smartcontractkit/chain-selectors"
"github.com/smartcontractkit/libocr/commontypes"
libocr2 "github.com/smartcontractkit/libocr/offchainreporting2plus"
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types"
ocrtypes "github.com/smartcontractkit/libocr/offchainreporting2plus/types"
"google.golang.org/grpc"

ocr2keepers20 "github.com/smartcontractkit/chainlink-automation/pkg/v2"
ocr2keepers20config "github.com/smartcontractkit/chainlink-automation/pkg/v2/config"
Expand All @@ -38,10 +35,11 @@ import (
"github.com/smartcontractkit/chainlink-common/pkg/loop/reportingplugins/ocr3"
"github.com/smartcontractkit/chainlink-common/pkg/sqlutil"
"github.com/smartcontractkit/chainlink-common/pkg/types"
cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip"
"github.com/smartcontractkit/chainlink-common/pkg/types/core"
llotypes "github.com/smartcontractkit/chainlink-common/pkg/types/llo"
"github.com/smartcontractkit/chainlink-common/pkg/utils/mailbox"
datastreamsllo "github.com/smartcontractkit/chainlink-data-streams/llo"

"github.com/smartcontractkit/chainlink/v2/core/bridges"
"github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm"
coreconfig "github.com/smartcontractkit/chainlink/v2/core/config"
Expand All @@ -52,8 +50,11 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/chaintype"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/ocr2key"
"github.com/smartcontractkit/chainlink/v2/core/services/llo"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/ccipcommit"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/ccipexec"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config"
ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/functions"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/generic"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/liquiditymanager"
Expand All @@ -63,7 +64,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/median"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/mercury"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper"

"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/autotelemetry21"
ocr2keeper21core "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/core"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/validate"
Expand All @@ -79,8 +79,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/synchronization"
"github.com/smartcontractkit/chainlink/v2/core/services/telemetry"
"github.com/smartcontractkit/chainlink/v2/plugins"

ccipconfig "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config"
)

type ErrJobSpecNoRelayer struct {
Expand Down Expand Up @@ -1618,7 +1616,77 @@ func (d *Delegate) newServicesCCIPCommit(ctx context.Context, lggr logger.Sugare
MetricsRegisterer: prometheus.WrapRegistererWith(map[string]string{"job_name": jb.Name.ValueOrZero()}, prometheus.DefaultRegisterer),
}

return ccipcommit.NewCommitServices(ctx, d.ds, srcProvider, dstProvider, d.legacyChains, jb, lggr, d.pipelineRunner, oracleArgsNoPlugin, d.isNewlyCreatedJob, int64(srcChainID), dstChainID, logError)
var priceGetter ccip.AllTokensPriceGetter
withPipeline := strings.Trim(pluginJobSpecConfig.TokenPricesUSDPipeline, "\n\t ") != ""
if withPipeline {
priceGetter, err = ccip.NewPipelineGetter(pluginJobSpecConfig.TokenPricesUSDPipeline, d.pipelineRunner, jb.ID, jb.ExternalJobID, jb.Name.ValueOrZero(), lggr)
if err != nil {
return nil, fmt.Errorf("creating pipeline price getter: %w", err)
}
} else {
// Use dynamic price getter.
if pluginJobSpecConfig.PriceGetterConfig == nil {
return nil, fmt.Errorf("priceGetterConfig is nil")
}

// Configure contract readers for all chains specified in the aggregator configurations.
// Some lanes (e.g. Wemix/Kroma) requires other clients than source and destination, since they use feeds from other chains.
aggregatorChainsToContracts := make(map[uint64][]common.Address)
for _, aggCfg := range pluginJobSpecConfig.PriceGetterConfig.AggregatorPrices {
if _, ok := aggregatorChainsToContracts[aggCfg.ChainID]; !ok {
aggregatorChainsToContracts[aggCfg.ChainID] = make([]common.Address, 0)
}

aggregatorChainsToContracts[aggCfg.ChainID] = append(aggregatorChainsToContracts[aggCfg.ChainID], aggCfg.AggregatorContractAddress)
}

contractReaders := map[uint64]types.ContractReader{}

for chainID, aggregatorContracts := range aggregatorChainsToContracts {
relayID := types.RelayID{Network: spec.Relay, ChainID: strconv.FormatUint(chainID, 10)}
relay, rerr := d.RelayGetter.Get(relayID)
if rerr != nil {
return nil, fmt.Errorf("get relay by id=%v: %w", relayID, err)
}

contractsConfig := make(map[string]evmrelaytypes.ChainContractReader, len(aggregatorContracts))
for i := range aggregatorContracts {
contractsConfig[fmt.Sprintf("%v_%v", ccip.OFFCHAIN_AGGREGATOR, i)] = evmrelaytypes.ChainContractReader{
ContractABI: ccip.OffChainAggregatorABI,
Configs: map[string]*evmrelaytypes.ChainReaderDefinition{
"decimals": { // CR consumers choose an alias
ChainSpecificName: "decimals",
},
"latestRoundData": {
ChainSpecificName: "latestRoundData",
},
},
}
}
contractReaderConfig := evmrelaytypes.ChainReaderConfig{
Contracts: contractsConfig,
}

contractReaderConfigJsonBytes, jerr := json.Marshal(contractReaderConfig)
if jerr != nil {
return nil, fmt.Errorf("marshal contract reader config: %w", jerr)
}

contractReader, cerr := relay.NewContractReader(ctx, contractReaderConfigJsonBytes)
if cerr != nil {
return nil, fmt.Errorf("new ccip commit contract reader %w", cerr)
}

contractReaders[chainID] = contractReader
}

priceGetter, err = ccip.NewDynamicPriceGetter(*pluginJobSpecConfig.PriceGetterConfig, contractReaders)
if err != nil {
return nil, fmt.Errorf("creating dynamic price getter: %w", err)
}
}
Comment on lines +1619 to +1687
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to wrap this in a function similar to d.ccipCommitGetDstProvider and d.ccipCommitGetSrcProvider above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


return ccipcommit.NewCommitServices(ctx, d.ds, srcProvider, dstProvider, priceGetter, jb, lggr, d.pipelineRunner, oracleArgsNoPlugin, d.isNewlyCreatedJob, int64(srcChainID), dstChainID, logError)
}

func newCCIPCommitPluginBytes(isSourceProvider bool, sourceStartBlock uint64, destStartBlock uint64) config.CommitPluginConfig {
Expand Down
47 changes: 1 addition & 46 deletions core/services/ocr2/plugins/ccip/ccipcommit/initializers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ package ccipcommit
import (
"context"
"encoding/json"
"fmt"
"math/big"
"strings"
"time"

"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/pricegetter"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/rpclib"

"github.com/Masterminds/semver/v3"
"github.com/ethereum/go-ethereum/common"
libocr2 "github.com/smartcontractkit/libocr/offchainreporting2plus"
Expand All @@ -27,7 +22,6 @@ import (
db "github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdb"

"github.com/smartcontractkit/chainlink/v2/core/chains/evm/txmgr"
"github.com/smartcontractkit/chainlink/v2/core/chains/legacyevm"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/job"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip"
Expand All @@ -48,7 +42,7 @@ var defaultNewReportingPluginRetryConfig = ccipdata.RetryConfig{
MaxRetries: (6 * 4) + 10,
}

func NewCommitServices(ctx context.Context, ds sqlutil.DataSource, srcProvider commontypes.CCIPCommitProvider, dstProvider commontypes.CCIPCommitProvider, chainSet legacyevm.LegacyChainContainer, jb job.Job, lggr logger.Logger, pr pipeline.Runner, argsNoPlugin libocr2.OCR2OracleArgs, new bool, sourceChainID int64, destChainID int64, logError func(string)) ([]job.ServiceCtx, error) {
func NewCommitServices(ctx context.Context, ds sqlutil.DataSource, srcProvider commontypes.CCIPCommitProvider, dstProvider commontypes.CCIPCommitProvider, priceGetter ccip.AllTokensPriceGetter, jb job.Job, lggr logger.Logger, pr pipeline.Runner, argsNoPlugin libocr2.OCR2OracleArgs, new bool, sourceChainID int64, destChainID int64, logError func(string)) ([]job.ServiceCtx, error) {
spec := jb.OCR2OracleSpec

var pluginConfig ccipconfig.CommitPluginJobSpecConfig
Expand All @@ -75,45 +69,6 @@ func NewCommitServices(ctx context.Context, ds sqlutil.DataSource, srcProvider c
commitStoreReader = ccip.NewProviderProxyCommitStoreReader(srcCommitStore, dstCommitStore)
commitLggr := lggr.Named("CCIPCommit").With("sourceChain", sourceChainID, "destChain", destChainID)

var priceGetter pricegetter.AllTokensPriceGetter
withPipeline := strings.Trim(pluginConfig.TokenPricesUSDPipeline, "\n\t ") != ""
if withPipeline {
priceGetter, err = pricegetter.NewPipelineGetter(pluginConfig.TokenPricesUSDPipeline, pr, jb.ID, jb.ExternalJobID, jb.Name.ValueOrZero(), lggr)
if err != nil {
return nil, fmt.Errorf("creating pipeline price getter: %w", err)
}
} else {
// Use dynamic price getter.
if pluginConfig.PriceGetterConfig == nil {
return nil, fmt.Errorf("priceGetterConfig is nil")
}

// Build price getter clients for all chains specified in the aggregator configurations.
// Some lanes (e.g. Wemix/Kroma) requires other clients than source and destination, since they use feeds from other chains.
priceGetterClients := map[uint64]pricegetter.DynamicPriceGetterClient{}
for _, aggCfg := range pluginConfig.PriceGetterConfig.AggregatorPrices {
chainID := aggCfg.ChainID
// Retrieve the chain.
chain, _, err2 := ccipconfig.GetChainByChainID(chainSet, chainID)
if err2 != nil {
return nil, fmt.Errorf("retrieving chain for chainID %d: %w", chainID, err2)
}
caller := rpclib.NewDynamicLimitedBatchCaller(
lggr,
chain.Client(),
rpclib.DefaultRpcBatchSizeLimit,
rpclib.DefaultRpcBatchBackOffMultiplier,
rpclib.DefaultMaxParallelRpcCalls,
)
priceGetterClients[chainID] = pricegetter.NewDynamicPriceGetterClient(caller)
}

priceGetter, err = pricegetter.NewDynamicPriceGetter(*pluginConfig.PriceGetterConfig, priceGetterClients)
if err != nil {
return nil, fmt.Errorf("creating dynamic price getter: %w", err)
}
}

offRampReader, err := dstProvider.NewOffRampReader(ctx, pluginConfig.OffRamp)
if err != nil {
return nil, err
Expand Down
21 changes: 19 additions & 2 deletions core/services/ocr2/plugins/ccip/exportinternal.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import (
"math/big"
"time"

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

"github.com/ethereum/go-ethereum/common"
"github.com/google/uuid"

"github.com/smartcontractkit/chainlink-common/pkg/types/ccip"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/client"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas"
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/logpoller"
"github.com/smartcontractkit/chainlink/v2/core/internal/gethwrappers2/generated/offchainaggregator"
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/config"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipcalc"
Expand All @@ -21,8 +25,13 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/ccipdata/v1_2_0"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/pricegetter"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/internal/rpclib"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
)

const OFFCHAIN_AGGREGATOR = "OffchainAggregator"
const DECIMALS_METHOD_NAME = "decimals"
const LATEST_ROUND_DATA_METHOD_NAME = "latestRoundData"

func GenericAddrToEvm(addr ccip.Address) (common.Address, error) {
return ccipcalc.GenericAddrToEvm(addr)
}
Expand Down Expand Up @@ -71,12 +80,18 @@ type DynamicPriceGetterClient = pricegetter.DynamicPriceGetterClient

type DynamicPriceGetter = pricegetter.DynamicPriceGetter

type AllTokensPriceGetter = pricegetter.AllTokensPriceGetter

func NewPipelineGetter(source string, runner pipeline.Runner, jobID int32, externalJobID uuid.UUID, name string, lggr logger.Logger) (*pricegetter.PipelineGetter, error) {
return pricegetter.NewPipelineGetter(source, runner, jobID, externalJobID, name, lggr)
}

func NewDynamicPriceGetterClient(batchCaller rpclib.EvmBatchCaller) DynamicPriceGetterClient {
return pricegetter.NewDynamicPriceGetterClient(batchCaller)
}

func NewDynamicPriceGetter(cfg config.DynamicPriceGetterConfig, evmClients map[uint64]DynamicPriceGetterClient) (*DynamicPriceGetter, error) {
return pricegetter.NewDynamicPriceGetter(cfg, evmClients)
func NewDynamicPriceGetter(cfg config.DynamicPriceGetterConfig, contractReaders map[uint64]types.ContractReader) (*DynamicPriceGetter, error) {
return pricegetter.NewDynamicPriceGetter(cfg, contractReaders)
}

func NewDynamicLimitedBatchCaller(
Expand Down Expand Up @@ -133,3 +148,5 @@ func NewCommitOffchainConfig(
) ccip.CommitOffchainConfig {
return ccipdata.NewCommitOffchainConfig(gasPriceDeviationPPB, gasPriceHeartBeat, tokenPriceDeviationPPB, tokenPriceHeartBeat, inflightCacheExpiry, priceReportingDisabled)
}

const OffChainAggregatorABI = offchainaggregator.OffchainAggregatorABI
Loading
Loading