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
1 change: 0 additions & 1 deletion .github/workflows/cre-local-env-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ jobs:
go run . env swap nodes

- name: Execute example PoR workflow
if: false # TODO: Migrate example test to V2 and run here (DX-3233)
shell: bash
working-directory: core/scripts/cre/environment
run: |
Expand Down
51 changes: 16 additions & 35 deletions core/scripts/cre/environment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,9 @@ Builds that access private repositories require `GITHUB_TOKEN` to be set (e.g. `
# while in core/scripts/cre/environment
go run . env start [--auto-setup]

# to start environment with an example workflow web API-based workflow
# to start environment with the PoR v2 cron example workflow
go run . env start --with-example

# to start environment with an example workflow cron-based workflow (requires cron capability in your image)
go run . env start --with-example --example-workflow-trigger cron

# to start environment with local Beholder
go run . env start --with-beholder

Expand All @@ -209,7 +206,6 @@ Optional parameters:
- `-x`: Registers an example PoR workflow using CRE CLI and verifies it executed successfuly
- `-s`: Time to wait for example workflow to execute successfuly (defaults to `5m`)
- `-p`: **DEPRECATED** Use `image` in TOML config instead. See [Using a pre-built Chainlink image](#using-a-pre-built-chainlink-image).
- `-y`: Trigger for example workflow to deploy (web-trigger or cron). Default: `web-trigger`. **Important!** `cron` trigger requires the Chainlink image to include the cron capability (built from source or a pre-built image with plugins).
- `--with-contracts-version`: Version of workflow/capability registries to use (`v2` by default, use `v1` explicitly for legacy coverage)

## Purging environment state
Expand Down Expand Up @@ -434,12 +430,12 @@ go run . workflow delete-all [flags]
go run . workflow delete-all
```

### `workflow deploy-and-verify-example`
Deploys and verifies the example workflow.
### `workflow run-por-example`
Deploys and verifies the PoR v2 cron example workflow.

**Usage:**
```bash
go run . workflow deploy-and-verify-example
go run . workflow run-por-example
```

This command uses default values and is useful for testing the workflow deployment process.
Expand Down Expand Up @@ -886,58 +882,43 @@ The environment includes several example workflows located in `core/scripts/cre/
- **`v2/node-mode/`**: Node mode workflow example
- **`v2/http/`**: HTTP-based workflow example

#### V1 Workflows
- **`v1/proof-of-reserve/cron-based/`**: Cron-based proof-of-reserve workflow
- **`v1/proof-of-reserve/web-trigger-based/`**: Web API trigger-based proof-of-reserve workflow
- **`v2/proof-of-reserve/cron-based/`**: Cron-based proof-of-reserve workflow example

### Deployable Example Workflows

The following workflows can be deployed using the `workflow deploy-and-verify-example` command:
The following workflow can be deployed using the `workflow run-por-example` command:

#### Proof-of-Reserve Workflows
Both proof-of-reserve workflows execute a proof-of-reserve-like scenario with the following steps:
#### Proof-of-Reserve Workflow
The proof-of-reserve workflow executes a proof-of-reserve-like scenario with the following steps:
- Call external HTTP API and fetch value of test asset
- Reach consensus on that value
- Write that value in the consumer contract on chain

**Usage:**
```bash
go run . workflow deploy-and-verify-example [flags]
go run . workflow run-por-example [flags]
```

**Key flags:**
- `-y, --example-workflow-trigger`: Trigger type (`web-trigger` or `cron`, default: `web-trigger`)
- `-u, --example-workflow-timeout`: Time to wait for workflow execution (default: `5m`)
- `-g, --gateway-url`: Gateway URL for web API trigger (default: `http://localhost:5002`)
- `-d, --don-id`: DON ID for web API trigger (default: `vault`)
- `-d, --workflow-don-id`: Workflow DON ID from the registry (default: `1`)
- `-w, --workflow-registry-address`: Workflow registry address (default: `0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0`)
- `-r, --rpc-url`: RPC URL (default: `http://localhost:8545`)

**Examples:**
```bash
# Deploy cron-based proof-of-reserve workflow
go run . workflow deploy-and-verify-example -y cron
# Deploy the PoR v2 cron example
go run . workflow run-por-example

# Deploy web-trigger-based proof-of-reserve workflow with custom timeout
go run . workflow deploy-and-verify-example -y web-trigger -u 10m
# Deploy the PoR v2 cron example with custom timeout
go run . workflow run-por-example -u 10m
```

#### Cron-based Workflow
- **Trigger**: Every 30 seconds on a schedule
- **Behavior**: Keeps executing until paused or deleted
- **Requirements**: External `cron` capability binary (must be manually compiled or downloaded and configured in TOML)
- **Source**: [`examples/workflows/v1/proof-of-reserve/cron-based/main.go`](./examples/workflows/v1/proof-of-reserve/cron-based/main.go)

#### Web API Trigger-based Workflow
- **Trigger**: Only when a precisely crafted and cryptographically signed request is made to the gateway node
- **Behavior**: Triggers workflow **once** and only if:
- Sender is whitelisted in the workflow
- Topic is whitelisted in the workflow
- **Source**: [`examples/workflows/v1/proof-of-reserve/web-trigger-based/main.go`](./examples/workflows/v1/proof-of-reserve/web-trigger-based/main.go)

**Note**: You might see multiple attempts to trigger and verify the workflow when running the example. This is expected and could happen because:
- Topic hasn't been registered yet (nodes haven't downloaded the workflow yet)
- Consensus wasn't reached in time
- **Source**: [`examples/workflows/v2/proof-of-reserve/cron-based/main.go`](./examples/workflows/v2/proof-of-reserve/cron-based/main.go)

### Manual Workflow Deployment

Expand Down Expand Up @@ -2121,4 +2102,4 @@ Once installed, configure it by running:
gh auth login
```

For GH CLI to be used by the environment to download the CRE CLI you must have access to [smartcontract/dev-platform](https://github.com/smartcontractkit/dev-platform) repository.
For GH CLI to be used by the environment to download the CRE CLI you must have access to [smartcontract/dev-platform](https://github.com/smartcontractkit/dev-platform) repository.
3 changes: 1 addition & 2 deletions core/scripts/cre/environment/completions.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ func buildCommandTree() *CompletionNode {
{Text: "--with-example", Description: "Deploys and registers example workflow (default: false)"},
{Text: "--example-workflow-timeout", Description: "Time to wait until example workflow succeeds (e.g. 10s, 1m, 1h) (default: 5m)"},
{Text: "--with-plugins-docker-image", Description: "Docker image to use (must have all capabilities included)"},
{Text: "--example-workflow-trigger", Description: "Trigger for example workflow to deploy (web-trigger or cron) (default: web-trigger)"},
{Text: "--with-beholder", Description: "Deploys Beholder (Chip Ingress + Red Panda) (default: false)"},
{Text: "--with-dashboards", Description: "Deploys Observability Stack and Grafana Dashboards (default: false)"},
{Text: "--with-billing", Description: "Deploys Billing Platform Service (default: false)"},
Expand Down Expand Up @@ -296,7 +295,7 @@ func buildCommandTree() *CompletionNode {
// ENV WORKFLOW - workflow management
workflowNode := &CompletionNode{
Suggestions: []prompt.Suggest{
{Text: "deploy-and-verify-example", Description: "Deploy and verify example workflow"},
{Text: "run-por-example", Description: "Deploy and verify the PoR v2 cron example workflow"},
{Text: "delete", Description: "Delete a specific workflow"},
{Text: "delete-all", Description: "Delete all workflows"},
{Text: "compile", Description: "Compile a workflow specification"},
Expand Down
16 changes: 1 addition & 15 deletions core/scripts/cre/environment/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ var (
provisioningStartTime time.Time
)

const (
WorkflowTriggerWebTrigger = "web-trigger"
WorkflowTriggerCron = "cron"
)

var EnvironmentCmd = &cobra.Command{
Use: "env",
Short: "Environment commands",
Expand Down Expand Up @@ -216,7 +211,6 @@ func startCmd() *cobra.Command {
var (
extraAllowedGatewayPorts []int
withExampleFlag bool
exampleWorkflowTrigger string
exampleWorkflowTimeout time.Duration
withPluginsDockerImage string
withContractsVersion string
Expand Down Expand Up @@ -460,9 +454,6 @@ func startCmd() *cobra.Command {
return errors.New("no gateway connector configurations found")
}

// use first gateway for example workflow
gatewayURL := fmt.Sprintf("%s://%s:%d%s", output.GatewayConnectors.Configurations[0].Incoming.Protocol, output.GatewayConnectors.Configurations[0].Incoming.Host, output.GatewayConnectors.Configurations[0].Incoming.ExternalPort, output.GatewayConnectors.Configurations[0].Incoming.Path)

fmt.Print(libformat.PurpleText("\nRegistering and verifying example workflow\n\n"))
workflowRegistryAddress := libcontracts.MustGetAddressFromDataStore(output.CreEnvironment.CldfEnvironment.DataStore, output.CreEnvironment.Blockchains[0].ChainSelector(), keystone_changeset.WorkflowRegistry.String(), output.CreEnvironment.ContractVersions[keystone_changeset.WorkflowRegistry.String()], "")

Expand All @@ -478,11 +469,7 @@ func startCmd() *cobra.Command {
return errors.New("no workflow DON found")
}

workflowDON, wErr := output.Dons.OneDonWithFlag(cre.WorkflowDON)
if wErr != nil {
return errors.Wrap(wErr, "failed to get workflow DON")
}
deployErr := deployAndVerifyExampleWorkflow(cmdContext, registryChainOut.CtfOutput().Nodes[0].ExternalHTTPUrl, gatewayURL, workflowDON.Name, workflowDonID, exampleWorkflowTimeout, exampleWorkflowTrigger, workflowRegistryAddress, semver.MustParse(withContractsVersion))
deployErr := deployAndVerifyExampleWorkflow(cmdContext, registryChainOut.CtfOutput().Nodes[0].ExternalHTTPUrl, workflowDonID, exampleWorkflowTimeout, workflowRegistryAddress, semver.MustParse(withContractsVersion))
if deployErr != nil {
fmt.Printf("Failed to deploy and verify example workflow: %s\n", deployErr)
}
Expand Down Expand Up @@ -514,7 +501,6 @@ func startCmd() *cobra.Command {
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", "", "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")
cmd.Flags().BoolVar(&withObs, "with-observability", false, "Start Observability Stack")
Expand Down
Loading
Loading