Skip to content
Merged
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
10 changes: 10 additions & 0 deletions .github/workflows/cre-local-env-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,14 @@ jobs:
# Compile and deploy TS workflow
go run . env workflow deploy --compile -n tsworkflow -w examples/workflows/ts/cron/index.ts -c examples/workflows/ts/cron/config.json

- name: Build capability binaries for swap
shell: bash
env:
GOPRIVATE: "github.com/smartcontractkit/*"
run: |
mkdir -p core/scripts/cre/environment/binaries
GOBIN=$(pwd)/core/scripts/cre/environment/binaries go tool loopinstall plugins/plugins.private.yaml

- name: Swap cron capability
shell: bash
working-directory: core/scripts/cre/environment
Expand All @@ -224,6 +232,8 @@ jobs:
- name: Swap CL node image
shell: bash
working-directory: core/scripts/cre/environment
env:
CTF_CHAINLINK_IMAGE: "${{ secrets.QA_AWS_ACCOUNT_NUMBER }}.dkr.ecr.${{ secrets.QA_AWS_REGION }}.amazonaws.com/chainlink:${{ github.event_name == 'pull_request' && format('nightly-{0}-plugins', steps.set-date.outputs.date) || inputs.chainlink_image_tag }}"
run: |
go run . env swap nodes

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cre-regression-system-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ jobs:
# Start CRE with the appropriate contracts version (i.e. Workflow/CapabilityRegistry)
if [[ "${CRE_VERSION}" == "v1" ]]; then
echo "Starting CRE with explicit v1 contracts for test: '${TEST_NAME}' and configs: '${CTF_CONFIGS}'"
go run . env start --with-plugins-docker-image "${CTF_CHAINLINK_IMAGE}" --with-contracts-version v1
go run . env start --with-contracts-version v1
else
echo "Starting CRE with default v2 contracts for test: '${TEST_NAME}' and configs: '${CTF_CONFIGS}'"
go run . env start --with-plugins-docker-image "${CTF_CHAINLINK_IMAGE}"
go run . env start
fi

exit_code=$?
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cre-system-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ jobs:
# Do not remove Docker containers on error to allow log collection
if [[ "${CRE_VERSION}" == "v1" ]]; then
echo "Starting CRE with explicit v1 contracts for test: '${TEST_NAME}'"
go run . env start --with-plugins-docker-image "${CTF_CHAINLINK_IMAGE}" --with-contracts-version v1 --cleanup-on-error=false
go run . env start --with-contracts-version v1 --cleanup-on-error=false
else
echo "Starting CRE with default v2 contracts for test: '${TEST_NAME}'"
go run . env start --with-plugins-docker-image "${CTF_CHAINLINK_IMAGE}" --cleanup-on-error=false
go run . env start --cleanup-on-error=false
fi

exit_code=$?
Expand Down
181 changes: 72 additions & 109 deletions core/scripts/cre/environment/README.md

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions core/scripts/cre/environment/configs/capability_defaults.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[capability_configs.consensus]
binary_path = "./binaries/consensus"
binary_name = "consensus"

# Global values for consensus are optional - uses empty jobspec config by default
[capability_configs.consensus.values]
Expand All @@ -10,14 +10,14 @@
# CustomField = "value" # Add custom fields if needed

[capability_configs.cron]
binary_path = "./binaries/cron"
binary_name = "cron"

# Global config for cron is optional - uses empty config by default
[capability_configs.cron.values]
# CustomField = "value" # Add custom fields if needed

[capability_configs.custom-compute]
# No binary_path needed - this is a built-in capability, it doesn't exist as a separate binary
# No binary_name needed - this is a built-in capability, it doesn't exist as a separate binary

[capability_configs.custom-compute.values]
NumWorkers = 3
Expand All @@ -27,7 +27,7 @@
PerSenderBurst = 5

[capability_configs.log-event-trigger]
binary_path = "./binaries/log-event-trigger"
binary_name = "log-event-trigger"

[capability_configs.log-event-trigger.values]
LookbackBlocks = 2000 # Default lookback blocks
Expand All @@ -38,7 +38,7 @@
[capability_configs.evm]
# Defaults for the EVM capability
# These are merged with per-DON chain_overrides
binary_path = "./binaries/evm"
binary_name = "evm"

[capability_configs.evm.values]
LogTriggerPollInterval = 1500000000 # 1.5s in nanoseconds
Expand All @@ -50,7 +50,7 @@
# NodeAddress = "0x0000000000000000000000000000000000000000"

[capability_configs.read-contract]
binary_path = "./binaries/readcontract"
binary_name = "readcontract"

[capability_configs.read-contract.values]
NetworkFamily = "evm" # EVM is the only supported family
Expand All @@ -74,10 +74,10 @@
# CustomField = "value" # Add custom fields if needed

[capability_configs.http-action]
binary_path = "./binaries/http_action"
binary_name = "http_action"

[capability_configs.solana]
binary_path = "./binaries/solana"
binary_name = "solana"

[capability_configs.http-action.values]
# HTTP Action capability configuration
Expand All @@ -92,7 +92,7 @@
OutgoingPerSenderRPS = 10

[capability_configs.http-trigger]
binary_path = "./binaries/http_trigger"
binary_name = "http_trigger"

[capability_configs.http-trigger.values]
# HTTP Trigger capability configuration
Expand All @@ -106,7 +106,7 @@
OutgoingPerSenderRPS = 10

[capability_configs.write-evm]
# No binary_path needed - this is a built-in capability, it doesn't exist as a separate binary
# No binary_name needed - this is a built-in capability, it doesn't exist as a separate binary

[capability_configs.write-evm.values]
# EVM Workflow configuration for write capabilities
Expand Down Expand Up @@ -139,7 +139,7 @@
Local = true

[capability_configs.mock]
binary_path = "./binaries/mock"
binary_name = "mock"

[capability_configs.mock.values]
Port = 7777 # Default port for mock service
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@
GasLimitDefault = 700_000
AcceptanceTimeout = '60s'

# Override binary path for a capability
# Override binary name for a capability (path is DefaultCapabilitiesDir + binary_name)
[nodesets.capability_configs.read-contract-1337]
binary_path = "/some-other/binary_path"
binary_name = "readcontract"
# values = {} # Add any required values here

# [nodesets.capability_configs.http-action]
# binary_path = ""
# binary_name = "http_action"
# [nodesets.capability_configs.http-action.values]
# IncomingGlobalBurst = 20

Expand Down
5 changes: 0 additions & 5 deletions core/scripts/cre/environment/configs/setup.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ local_image = "billing-platform-service:local-cre"
local_image = "billing-platform-service:local-cre"
ecr_image = "{{.ECR}}/billing-platform-service:1.36.1"

[capabilities]
target_path = "./binaries"
# add "install-plugins-public" to also locally compile and copy public plugins (be aware chainlink-cosmos might fail due to issues with cross-compile)
make_commands = ["install-plugins-private", "install-plugins-local"]

[observability]
repository = "https://github.com/smartcontractkit/chainlink-observability"
branch = "main"
Expand Down
82 changes: 16 additions & 66 deletions core/scripts/cre/environment/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ func startCmd() *cobra.Command {
return errors.Wrap(err, "failed to set default CTF configs")
}

if withPluginsDockerImage != "" {
envConfig := os.Getenv("CTF_CONFIGS")
split := strings.Split(envConfig, ",")
effectiveConfig := split[len(split)-1]
return fmt.Errorf("with-plugins-docker-image flag is no longer supported. Set Docker image in TOML config instead (%s) for each nodeset under the [nodesets.nodesets.node_specs.node.image] field", effectiveConfig)
}

cleanUpErr := envconfig.RemoveAllEnvironmentStateDir(relativePathToRepoRoot)
if cleanUpErr != nil {
return errors.Wrap(cleanUpErr, "failed to clean up environment state files")
Expand Down Expand Up @@ -284,7 +291,7 @@ func startCmd() *cobra.Command {
}

// This will not work with remote images that require authentication, but it will catch early most of the issues with missing env setup
if err := ensureDockerImagesExist(cmdContext, framework.L, in, withPluginsDockerImage); err != nil {
if err := ensureDockerImagesExist(cmdContext, framework.L, in); err != nil {
return err
}
} else {
Expand Down Expand Up @@ -321,10 +328,6 @@ func startCmd() *cobra.Command {
return errors.Wrap(err, "failed to validate test configuration")
}

if err := validateWorkflowTriggerAndCapabilities(in, withExampleFlag, exampleWorkflowTrigger, withPluginsDockerImage); err != nil {
return errors.Wrap(err, "either cron binary path must be set in TOML config (%s) or you must use Docker image with all capabilities included and passed via withPluginsDockerImageFlag")
}

topologySummary, _, topErr := generateTopologyArtifactsForLoadedConfig(in)
if topErr != nil {
framework.L.Warn().Err(topErr).Msg("failed to generate topology visualization artifacts")
Expand All @@ -337,12 +340,12 @@ func startCmd() *cobra.Command {
ExtraAllowedPorts: append(extraAllowedGatewayPorts, in.Fake.Port, in.FakeHTTP.Port),
ExtraAllowedIPsCIDR: []string{"0.0.0.0/0"},
}
output, startErr := StartCLIEnvironment(cmdContext, relativePathToRepoRoot, in, withPluginsDockerImage, nil, features, nil, envDependencies, gatewayWhitelistConfig)
output, startErr := StartCLIEnvironment(cmdContext, relativePathToRepoRoot, in, nil, features, nil, envDependencies, gatewayWhitelistConfig)
if startErr != nil {
fmt.Fprintf(os.Stderr, "Error: %s\n", startErr)
fmt.Fprintf(os.Stderr, "Stack trace: %s\n", string(debug.Stack()))

dxErr := trackStartup(false, hasBuiltDockerImage(in, withPluginsDockerImage), in.Infra.Type, ptr.Ptr(strings.SplitN(startErr.Error(), "\n", 1)[0]), ptr.Ptr(false))
dxErr := trackStartup(false, hasBuiltDockerImage(in), in.Infra.Type, ptr.Ptr(strings.SplitN(startErr.Error(), "\n", 1)[0]), ptr.Ptr(false))
if dxErr != nil {
fmt.Fprintf(os.Stderr, "failed to track startup: %s\n", dxErr)
}
Expand Down Expand Up @@ -370,7 +373,7 @@ func startCmd() *cobra.Command {
fmt.Fprintf(os.Stderr, "failed to create CRE CLI settings file: %s. You need to create it manually.", sErr)
}

dxErr := trackStartup(true, hasBuiltDockerImage(in, withPluginsDockerImage), output.CreEnvironment.Provider.Type, nil, nil)
dxErr := trackStartup(true, hasBuiltDockerImage(in), output.CreEnvironment.Provider.Type, nil, nil)
if dxErr != nil {
fmt.Fprintf(os.Stderr, "failed to track startup: %s\n", dxErr)
}
Expand Down Expand Up @@ -510,7 +513,7 @@ func startCmd() *cobra.Command {
cmd.Flags().IntSliceVarP(&extraAllowedGatewayPorts, "extra-allowed-gateway-ports", "e", []int{}, "Extra allowed ports for outgoing connections from the Gateway Connector (e.g. 8080,8081)")
cmd.Flags().BoolVarP(&withExampleFlag, "with-example", "x", false, "Deploys and registers example workflow")
cmd.Flags().DurationVarP(&exampleWorkflowTimeout, "example-workflow-timeout", "u", 5*time.Minute, "Time to wait until example workflow succeeds (e.g. 10s, 1m, 1h)")
cmd.Flags().StringVarP(&withPluginsDockerImage, "with-plugins-docker-image", "p", "", "Docker image to use (must have all capabilities included)")
cmd.Flags().StringVarP(&withPluginsDockerImage, "with-plugins-docker-image", "p", "", "DEPRECATED:Docker image to use (set Docker image in TOML config instead)")
cmd.Flags().StringVarP(&exampleWorkflowTrigger, "example-workflow-trigger", "y", "web-trigger", "Trigger for example workflow to deploy (web-trigger or cron)")
cmd.Flags().BoolVarP(&withBeholder, "with-beholder", "b", false, "Deploy Beholder (Chip Ingress + Red Panda)")
cmd.Flags().BoolVarP(&withDashboards, "with-dashboards", "d", false, "Deploy Observability Stack and Grafana Dashboards")
Expand Down Expand Up @@ -678,7 +681,6 @@ func StartCLIEnvironment(
cmdContext context.Context,
relativePathToRepoRoot string,
in *envconfig.Config,
withPluginsDockerImageFlag string,
capabilities []cre.InstallableCapability, // Deprecated: use Features instead
features cre.Features,
extraJobSpecFunctions []cre.JobSpecFn,
Expand All @@ -687,17 +689,6 @@ func StartCLIEnvironment(
) (*creenv.SetupOutput, error) {
testLogger := framework.L

// unset DockerFilePath and DockerContext as we cannot use them with existing images
if withPluginsDockerImageFlag != "" {
for setIdx := range in.NodeSets {
for nodeIdx := range in.NodeSets[setIdx].NodeSpecs {
in.NodeSets[setIdx].NodeSpecs[nodeIdx].Node.Image = withPluginsDockerImageFlag
in.NodeSets[setIdx].NodeSpecs[nodeIdx].Node.DockerContext = ""
in.NodeSets[setIdx].NodeSpecs[nodeIdx].Node.DockerFilePath = ""
}
}
}

if in.JD.CSAEncryptionKey == "" {
// generate a new key
key, keyErr := ecdsa.GenerateKey(crypto.S256(), rand.Reader)
Expand All @@ -719,7 +710,6 @@ func StartCLIEnvironment(
Provider: *in.Infra,
S3ProviderInput: in.S3ProviderInput,
CapabilityConfigs: in.CapabilityConfigs,
CopyCapabilityBinaries: withPluginsDockerImageFlag == "", // do not copy any binaries to the containers, if we are using plugins image (they already have them)
Capabilities: capabilities,
JobSpecFactoryFunctions: extraJobSpecFunctions,
StageGen: initLocalCREStageGen(in),
Expand Down Expand Up @@ -791,23 +781,16 @@ func setDefaultCtfConfigs() error {
return nil
}

func hasBuiltDockerImage(in *envconfig.Config, withPluginsDockerImageFlag string) bool {
if withPluginsDockerImageFlag != "" {
return false
}

hasBuilt := false

func hasBuiltDockerImage(in *envconfig.Config) bool {
for _, nodeset := range in.NodeSets {
for _, nodeSpec := range nodeset.NodeSpecs {
if nodeSpec.Node != nil && nodeSpec.Node.DockerFilePath != "" {
hasBuilt = true
break
return true
}
}
}

return hasBuilt
return false
}

func oneLineErrorMessage(errOrPanic any) string {
Expand All @@ -831,33 +814,6 @@ func initDxTracker() {
}
}

func validateWorkflowTriggerAndCapabilities(in *envconfig.Config, withExampleFlag bool, workflowTrigger, withPluginsDockerImageFlag string) error {
if withExampleFlag && workflowTrigger == WorkflowTriggerCron {
// assume it has cron binary if we are using plugins image
if withPluginsDockerImageFlag != "" {
return nil
}

// otherwise, make sure we have cron binary path set in TOML config
if in.CapabilityConfigs == nil {
return errors.New("capability configs is not set in TOML config")
}

cronCapConfig, ok := in.CapabilityConfigs[cre.CronCapability]
if !ok {
return errors.New("cron capability config is not set in TOML config")
}

if cronCapConfig.BinaryPath == "" {
return errors.New("cron binary path must be set in TOML config")
}

return nil
}

return nil
}

func ensureDockerIsRunning(ctx context.Context) error {
dockerClient, dockerClientErr := client.NewClientWithOpts(client.WithAPIVersionNegotiation())
if dockerClientErr != nil {
Expand All @@ -871,7 +827,7 @@ func ensureDockerIsRunning(ctx context.Context) error {
return nil
}

func ensureDockerImagesExist(ctx context.Context, logger zerolog.Logger, in *envconfig.Config, withPluginsDockerImageFlag string) error {
func ensureDockerImagesExist(ctx context.Context, logger zerolog.Logger, in *envconfig.Config) error {
// Skip checks in CI environment
if os.Getenv("CI") == "true" {
return nil
Expand All @@ -883,12 +839,6 @@ func ensureDockerImagesExist(ctx context.Context, logger zerolog.Logger, in *env
return nil
}

if withPluginsDockerImageFlag != "" {
if err := ensureDockerImageExists(ctx, logger, withPluginsDockerImageFlag); err != nil {
return errors.Wrapf(err, "Plugins image '%s' not found. Make sure it exists locally", withPluginsDockerImageFlag)
}
}

if in.JD != nil {
if err := ensureDockerImageExists(ctx, logger, in.JD.Image); err != nil {
return errors.Wrapf(err, "Job Distributor image '%s' not found. Make sure it exists locally or run 'go run . env setup' to pull it and other dependencies that also might be missing", in.JD.Image)
Expand Down
Loading
Loading