-
Notifications
You must be signed in to change notification settings - Fork 51
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
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 be11827
WIP; contract readers added as field to DynamicPriceGetter and sketch…
patrickhuie19 db741df
fix test usage of NewDynamicPriceGetter
patrickhuie19 1b54a20
WIP: added contract reader config and bindings
patrickhuie19 2324aaa
added debug image for smoke tests with delve and minor WIP steps towa…
patrickhuie19 8d48404
WIP use of CR for decimals results
patrickhuie19 12f8336
expose delve port
Tofel bddf006
fixing bug in build_ccip_debug_image make command naming
patrickhuie19 b722a32
Adding install-chainlink-delve make command
patrickhuie19 7c339fa
minor fix to last commit
patrickhuie19 34b527f
updated debug Dockerfile with delve installed in final image
patrickhuie19 0f7919a
run cl node container with dlv
Tofel 366678f
use full dlv path
Tofel cbe3edf
try another path
Tofel 51d6b40
chainlink starts with dlv
Tofel 12c08b3
changing final image for debug Dockerfile to golang:1.22-bullseye
patrickhuie19 86d76bb
udpated TestDynamicPriceGetterWithEmptyInput to use CR mocks
patrickhuie19 261d655
using GetEndpointFromPort in integration tests
patrickhuie19 adac213
fixed panic in Test_CLOSpecApprovalFlow_dynamicPriceGetter
patrickhuie19 01679b4
bumping CTF
patrickhuie19 ca39bad
bumping go.mod
patrickhuie19 8907d7d
Merge branch 'ccip-develop' into feature/commit-init-no-evm
patrickhuie19 7d7ce5d
undoing mod bumps
patrickhuie19 227f336
bumping only CTF in integration-tests module
patrickhuie19 52c76de
Test_CLOSpecApprovalFlow_dynamicPriceGetter passes
patrickhuie19 669a292
fixed TestDynamicPriceGetterWithEmptyInput
patrickhuie19 2e31c05
Merge branch 'ccip-develop' into feature/commit-init-no-evm
patrickhuie19 87adf08
updating to use LatestRound CR + lint
patrickhuie19 5a46504
reverting entrypoint to not use dlv binary
patrickhuie19 5e379a2
fixed overwriting of results struct by ChainReader, identified potent…
patrickhuie19 807211d
fixed conflicting contract names with indexed bindings. confirmed non…
patrickhuie19 25d5921
fixed map iteration bug in Test_CLOSpecApprovalFlow_dynamicPriceGetter
patrickhuie19 7345eed
fixed TestDynamicPriceGetterWithEmptyInput again
patrickhuie19 db2aa5f
cleaned up hanging legacy evm batch call code from evm pricegetter'
patrickhuie19 a9622fb
cleaned up legacy clients in newServicesCommit
patrickhuie19 5666f17
minor fix
patrickhuie19 4aeb68c
lint
patrickhuie19 ff89cd7
lint
patrickhuie19 cf3ed67
clarifying comments
patrickhuie19 6cec7f1
cleaning up delve entrypoint integ tests and minor refactoring for cl…
patrickhuie19 0b5b79d
using job spec to determine the number of contract addresses per chai…
patrickhuie19 bf0e31c
wrapping errors, exporting OffchainAggregator metadata vars
patrickhuie19 db4ec4c
Merge branch 'ccip-develop' into feature/commit-init-no-evm
patrickhuie19 f1a505c
fixing import cycle
patrickhuie19 b323a8b
Try different runner for e2e test
lukaszcl 6007b86
Revert "Try different runner for e2e test"
lukaszcl c5f3590
Feature/commit init no evm lf tests (#1470)
lukaszcl a1ad4db
Merge branch 'ccip-develop' into feature/commit-init-no-evm
patrickhuie19 aab6be2
Merge branch 'ccip-develop' into feature/commit-init-no-evm
patrickhuie19 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
@@ -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" | ||
|
@@ -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" | ||
|
@@ -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" | ||
|
@@ -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 { | ||
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to wrap this in a function similar to There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.