Skip to content

Commit 75b8319

Browse files
committed
use V2 PoR workflow as example
1 parent 86045e7 commit 75b8319

11 files changed

Lines changed: 137 additions & 676 deletions

File tree

.github/workflows/cre-local-env-tests.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ jobs:
244244
go run . env swap nodes
245245
246246
- name: Execute example PoR workflow
247-
if: false # TODO: Migrate example test to V2 and run here (DX-3233)
248247
shell: bash
249248
working-directory: core/scripts/cre/environment
250249
run: |

core/scripts/cre/environment/README.md

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,9 @@ Builds that access private repositories require `GITHUB_TOKEN` to be set (e.g. `
186186
# while in core/scripts/cre/environment
187187
go run . env start [--auto-setup]
188188

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

192-
# to start environment with an example workflow cron-based workflow (requires cron capability in your image)
193-
go run . env start --with-example --example-workflow-trigger cron
194-
195192
# to start environment with local Beholder
196193
go run . env start --with-beholder
197194

@@ -209,7 +206,6 @@ Optional parameters:
209206
- `-x`: Registers an example PoR workflow using CRE CLI and verifies it executed successfuly
210207
- `-s`: Time to wait for example workflow to execute successfuly (defaults to `5m`)
211208
- `-p`: **DEPRECATED** Use `image` in TOML config instead. See [Using a pre-built Chainlink image](#using-a-pre-built-chainlink-image).
212-
- `-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).
213209
- `--with-contracts-version`: Version of workflow/capability registries to use (`v2` by default, use `v1` explicitly for legacy coverage)
214210

215211
## Purging environment state
@@ -434,12 +430,12 @@ go run . workflow delete-all [flags]
434430
go run . workflow delete-all
435431
```
436432

437-
### `workflow deploy-and-verify-example`
438-
Deploys and verifies the example workflow.
433+
### `workflow run-por-example`
434+
Deploys and verifies the PoR v2 cron example workflow.
439435

440436
**Usage:**
441437
```bash
442-
go run . workflow deploy-and-verify-example
438+
go run . workflow run-por-example
443439
```
444440

445441
This command uses default values and is useful for testing the workflow deployment process.
@@ -886,58 +882,43 @@ The environment includes several example workflows located in `core/scripts/cre/
886882
- **`v2/node-mode/`**: Node mode workflow example
887883
- **`v2/http/`**: HTTP-based workflow example
888884
889-
#### V1 Workflows
890-
- **`v1/proof-of-reserve/cron-based/`**: Cron-based proof-of-reserve workflow
891-
- **`v1/proof-of-reserve/web-trigger-based/`**: Web API trigger-based proof-of-reserve workflow
885+
- **`v2/proof-of-reserve/cron-based/`**: Cron-based proof-of-reserve workflow example
892886
893887
### Deployable Example Workflows
894888
895-
The following workflows can be deployed using the `workflow deploy-and-verify-example` command:
889+
The following workflow can be deployed using the `workflow run-por-example` command:
896890
897-
#### Proof-of-Reserve Workflows
898-
Both proof-of-reserve workflows execute a proof-of-reserve-like scenario with the following steps:
891+
#### Proof-of-Reserve Workflow
892+
The proof-of-reserve workflow executes a proof-of-reserve-like scenario with the following steps:
899893
- Call external HTTP API and fetch value of test asset
900894
- Reach consensus on that value
901895
- Write that value in the consumer contract on chain
902896
903897
**Usage:**
904898
```bash
905-
go run . workflow deploy-and-verify-example [flags]
899+
go run . workflow run-por-example [flags]
906900
```
907901
908902
**Key flags:**
909-
- `-y, --example-workflow-trigger`: Trigger type (`web-trigger` or `cron`, default: `web-trigger`)
910903
- `-u, --example-workflow-timeout`: Time to wait for workflow execution (default: `5m`)
911-
- `-g, --gateway-url`: Gateway URL for web API trigger (default: `http://localhost:5002`)
912-
- `-d, --don-id`: DON ID for web API trigger (default: `vault`)
904+
- `-d, --workflow-don-id`: Workflow DON ID from the registry (default: `1`)
913905
- `-w, --workflow-registry-address`: Workflow registry address (default: `0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0`)
914906
- `-r, --rpc-url`: RPC URL (default: `http://localhost:8545`)
915907
916908
**Examples:**
917909
```bash
918-
# Deploy cron-based proof-of-reserve workflow
919-
go run . workflow deploy-and-verify-example -y cron
910+
# Deploy the PoR v2 cron example
911+
go run . workflow run-por-example
920912
921-
# Deploy web-trigger-based proof-of-reserve workflow with custom timeout
922-
go run . workflow deploy-and-verify-example -y web-trigger -u 10m
913+
# Deploy the PoR v2 cron example with custom timeout
914+
go run . workflow run-por-example -u 10m
923915
```
924916
925917
#### Cron-based Workflow
926918
- **Trigger**: Every 30 seconds on a schedule
927919
- **Behavior**: Keeps executing until paused or deleted
928920
- **Requirements**: External `cron` capability binary (must be manually compiled or downloaded and configured in TOML)
929-
- **Source**: [`examples/workflows/v1/proof-of-reserve/cron-based/main.go`](./examples/workflows/v1/proof-of-reserve/cron-based/main.go)
930-
931-
#### Web API Trigger-based Workflow
932-
- **Trigger**: Only when a precisely crafted and cryptographically signed request is made to the gateway node
933-
- **Behavior**: Triggers workflow **once** and only if:
934-
- Sender is whitelisted in the workflow
935-
- Topic is whitelisted in the workflow
936-
- **Source**: [`examples/workflows/v1/proof-of-reserve/web-trigger-based/main.go`](./examples/workflows/v1/proof-of-reserve/web-trigger-based/main.go)
937-
938-
**Note**: You might see multiple attempts to trigger and verify the workflow when running the example. This is expected and could happen because:
939-
- Topic hasn't been registered yet (nodes haven't downloaded the workflow yet)
940-
- Consensus wasn't reached in time
921+
- **Source**: [`examples/workflows/v2/proof-of-reserve/cron-based/main.go`](./examples/workflows/v2/proof-of-reserve/cron-based/main.go)
941922
942923
### Manual Workflow Deployment
943924
@@ -2121,4 +2102,4 @@ Once installed, configure it by running:
21212102
gh auth login
21222103
```
21232104
2124-
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.
2105+
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.

core/scripts/cre/environment/completions.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ func buildCommandTree() *CompletionNode {
244244
{Text: "--with-example", Description: "Deploys and registers example workflow (default: false)"},
245245
{Text: "--example-workflow-timeout", Description: "Time to wait until example workflow succeeds (e.g. 10s, 1m, 1h) (default: 5m)"},
246246
{Text: "--with-plugins-docker-image", Description: "Docker image to use (must have all capabilities included)"},
247-
{Text: "--example-workflow-trigger", Description: "Trigger for example workflow to deploy (web-trigger or cron) (default: web-trigger)"},
248247
{Text: "--with-beholder", Description: "Deploys Beholder (Chip Ingress + Red Panda) (default: false)"},
249248
{Text: "--with-dashboards", Description: "Deploys Observability Stack and Grafana Dashboards (default: false)"},
250249
{Text: "--with-billing", Description: "Deploys Billing Platform Service (default: false)"},
@@ -296,7 +295,7 @@ func buildCommandTree() *CompletionNode {
296295
// ENV WORKFLOW - workflow management
297296
workflowNode := &CompletionNode{
298297
Suggestions: []prompt.Suggest{
299-
{Text: "deploy-and-verify-example", Description: "Deploy and verify example workflow"},
298+
{Text: "run-por-example", Description: "Deploy and verify the PoR v2 cron example workflow"},
300299
{Text: "delete", Description: "Delete a specific workflow"},
301300
{Text: "delete-all", Description: "Delete all workflows"},
302301
{Text: "compile", Description: "Compile a workflow specification"},

core/scripts/cre/environment/environment/environment.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,6 @@ var (
7070
provisioningStartTime time.Time
7171
)
7272

73-
const (
74-
WorkflowTriggerWebTrigger = "web-trigger"
75-
WorkflowTriggerCron = "cron"
76-
)
77-
7873
var EnvironmentCmd = &cobra.Command{
7974
Use: "env",
8075
Short: "Environment commands",
@@ -216,7 +211,6 @@ func startCmd() *cobra.Command {
216211
var (
217212
extraAllowedGatewayPorts []int
218213
withExampleFlag bool
219-
exampleWorkflowTrigger string
220214
exampleWorkflowTimeout time.Duration
221215
withPluginsDockerImage string
222216
withContractsVersion string
@@ -460,9 +454,6 @@ func startCmd() *cobra.Command {
460454
return errors.New("no gateway connector configurations found")
461455
}
462456

463-
// use first gateway for example workflow
464-
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)
465-
466457
fmt.Print(libformat.PurpleText("\nRegistering and verifying example workflow\n\n"))
467458
workflowRegistryAddress := libcontracts.MustGetAddressFromDataStore(output.CreEnvironment.CldfEnvironment.DataStore, output.CreEnvironment.Blockchains[0].ChainSelector(), keystone_changeset.WorkflowRegistry.String(), output.CreEnvironment.ContractVersions[keystone_changeset.WorkflowRegistry.String()], "")
468459

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

481-
workflowDON, wErr := output.Dons.OneDonWithFlag(cre.WorkflowDON)
482-
if wErr != nil {
483-
return errors.Wrap(wErr, "failed to get workflow DON")
484-
}
485-
deployErr := deployAndVerifyExampleWorkflow(cmdContext, registryChainOut.CtfOutput().Nodes[0].ExternalHTTPUrl, gatewayURL, workflowDON.Name, workflowDonID, exampleWorkflowTimeout, exampleWorkflowTrigger, workflowRegistryAddress, semver.MustParse(withContractsVersion))
472+
deployErr := deployAndVerifyExampleWorkflow(cmdContext, registryChainOut.CtfOutput().Nodes[0].ExternalHTTPUrl, workflowDonID, exampleWorkflowTimeout, workflowRegistryAddress, semver.MustParse(withContractsVersion))
486473
if deployErr != nil {
487474
fmt.Printf("Failed to deploy and verify example workflow: %s\n", deployErr)
488475
}
@@ -514,7 +501,6 @@ func startCmd() *cobra.Command {
514501
cmd.Flags().BoolVarP(&withExampleFlag, "with-example", "x", false, "Deploys and registers example workflow")
515502
cmd.Flags().DurationVarP(&exampleWorkflowTimeout, "example-workflow-timeout", "u", 5*time.Minute, "Time to wait until example workflow succeeds (e.g. 10s, 1m, 1h)")
516503
cmd.Flags().StringVarP(&withPluginsDockerImage, "with-plugins-docker-image", "p", "", "DEPRECATED:Docker image to use (set Docker image in TOML config instead)")
517-
cmd.Flags().StringVarP(&exampleWorkflowTrigger, "example-workflow-trigger", "y", "web-trigger", "Trigger for example workflow to deploy (web-trigger or cron)")
518504
cmd.Flags().BoolVarP(&withBeholder, "with-beholder", "b", false, "Deploy Beholder (Chip Ingress + Red Panda)")
519505
cmd.Flags().BoolVarP(&withDashboards, "with-dashboards", "d", false, "Deploy Observability Stack and Grafana Dashboards")
520506
cmd.Flags().BoolVar(&withObs, "with-observability", false, "Start Observability Stack")

0 commit comments

Comments
 (0)