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

Cappl 3 ph #15125

Closed
wants to merge 68 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
dad2833
Trigger build with CRON & KVSTORE standard capability binaries
justinkaseman Oct 7, 2024
95dbcca
@chainlink.contracts release v1.3.0 (#14812)
chainchad Nov 5, 2024
8800b27
fix: arm64 builds with goreleaser 2.4.x (#15110)
erikburt Nov 5, 2024
70df806
CCIP-4105: adds OZ AccessControl support to the registry module (#15067)
RensR Nov 5, 2024
c3b5d37
Remove shallow checkout for changeset detection (#15113)
HenryNguyen5 Nov 5, 2024
9ac0d6b
removing dot seperator in path (#15120)
patrickhuie19 Nov 5, 2024
645858a
Add workflows
cedric-cordenier Nov 5, 2024
13474d1
Add workflows
cedric-cordenier Nov 5, 2024
cf987bf
Add missing workflows extra_files
cedric-cordenier Nov 5, 2024
5f7884a
Try optional copy tmp/workflows
justinkaseman Nov 5, 2024
96b0cfc
trigger build
justinkaseman Nov 5, 2024
0d7ff26
Create dummy registry
cedric-cordenier Nov 6, 2024
c8d7b2f
Update workflow
cedric-cordenier Nov 6, 2024
17680cf
give hardcoded workflow a name + id
justinkaseman Nov 6, 2024
fe4e07c
Merge branch 'develop' into CAPPL-3-ph
cedric-cordenier Nov 7, 2024
444ffa0
Bump common
cedric-cordenier Nov 7, 2024
399ed46
Correct logger
cedric-cordenier Nov 7, 2024
235d85b
Incorporate KeyId into workflow
cedric-cordenier Nov 7, 2024
a98566c
compress binary
cedric-cordenier Nov 7, 2024
a69ca05
GetUnfinished fix
cedric-cordenier Nov 7, 2024
3fc7c0d
feat: implement timeout
agparadiso Nov 7, 2024
8351987
Trivial fixes
cedric-cordenier Nov 8, 2024
9bcfd92
Update workflow
cedric-cordenier Nov 8, 2024
bdb71f5
WIP
cedric-cordenier Nov 4, 2024
9057057
WIP
cedric-cordenier Nov 4, 2024
f2913f4
Merge branch 'develop' into CAPPL-3-ph
cedric-cordenier Nov 10, 2024
372e7f5
Correct length for owner
cedric-cordenier Nov 11, 2024
3af0eaf
Merge branch 'develop' into CAPPL-3-ph
cedric-cordenier Nov 11, 2024
25958e3
Update common
cedric-cordenier Nov 11, 2024
a23cfa3
Update common
cedric-cordenier Nov 11, 2024
9210653
Merge branch 'develop' into CAPPL-3-ph
cedric-cordenier Nov 11, 2024
cd5d456
Update workflow
cedric-cordenier Nov 11, 2024
b7ad741
Merge branch 'develop' into CAPPL-3-ph
cedric-cordenier Nov 11, 2024
3b809eb
Update common
cedric-cordenier Nov 12, 2024
4f895fc
Update common
cedric-cordenier Nov 12, 2024
6881be9
Remove extra replace, with a more targeted one. (#15018)
cgruber Nov 11, 2024
8471920
Merge branch 'develop' into CAPPL-3-ph
cedric-cordenier Nov 12, 2024
b877917
Log out the WorkflowPublicKey
cedric-cordenier Nov 13, 2024
d7ae86c
Merge branch 'develop' into CAPPL-3-ph
cedric-cordenier Nov 13, 2024
79f982c
Merge branch 'develop' into CAPPL-3-ph
cedric-cordenier Nov 13, 2024
611cc4b
Merge branch 'develop' into CAPPL-3-ph
cedric-cordenier Nov 14, 2024
dcb9784
Bump common
cedric-cordenier Nov 14, 2024
195189f
Merge branch 'develop' into CAPPL-3-ph
cedric-cordenier Nov 15, 2024
2b3af8b
Bump common
cedric-cordenier Nov 15, 2024
510bfc0
Update workflow name
cedric-cordenier Nov 18, 2024
54faaf4
Add second workflow
cedric-cordenier Nov 20, 2024
58b51f9
Update registry to run two workflows; add updated workflows
cedric-cordenier Nov 20, 2024
30bb2f9
Update artifacts
cedric-cordenier Nov 20, 2024
0bcb61f
Merge branch 'develop' into CAPPL-3-ph
cedric-cordenier Nov 20, 2024
13034bd
Update go.sum
cedric-cordenier Nov 20, 2024
43ac99c
Update workflows
cedric-cordenier Nov 20, 2024
c5f0bf1
Update PoR workflow with timestamp adjustment
cedric-cordenier Nov 20, 2024
d65ddec
Update workflows
cedric-cordenier Nov 21, 2024
2c79077
merge develop
justinkaseman Nov 21, 2024
93b05ee
Revert "chore(workflows): stub out event handlers (#15313)"
justinkaseman Nov 21, 2024
1608708
Revert "feat(workflows): adds registry syncer (#15277)"
justinkaseman Nov 21, 2024
630193a
Update hardcoded wasm workflows
justinkaseman Nov 21, 2024
f5e6fe5
Update workflows
cedric-cordenier Nov 22, 2024
22c235a
One more update
cedric-cordenier Nov 22, 2024
cc98bbd
One more update
cedric-cordenier Nov 22, 2024
9214ffc
Update hardcoded workflow with CLI generated binary
justinkaseman Nov 26, 2024
7856854
Revert "feat(workflows/handler): adds all event handlers (#15400)"
justinkaseman Nov 27, 2024
2a691fe
Revert "feat(handler): implements handle workflow registered event (#…
justinkaseman Nov 27, 2024
4af21d5
Revert "feat(workflows): adds orm methods for managing specs (#15356)"
justinkaseman Nov 27, 2024
aafd7bd
Revert "chore(workflows): stub out event handlers (#15313)"
justinkaseman Nov 27, 2024
68401d8
Revert "feat(workflows): adds registry syncer (#15277)"
justinkaseman Nov 27, 2024
f8a7688
Merge branch 'develop' into CAPPL-3-ph
justinkaseman Nov 27, 2024
4da22ce
Revert "[CAPPL-316] implement FetchFunc (#15424)"
justinkaseman Nov 27, 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
6 changes: 6 additions & 0 deletions .goreleaser.develop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ dockers:
extra_files:
- tmp/libs
- tmp/plugins
- tmp/workflows
build_flag_templates:
- --platform=linux/amd64
- --pull
Expand Down Expand Up @@ -121,6 +122,7 @@ dockers:
extra_files:
- tmp/libs
- tmp/plugins
- tmp/workflows
build_flag_templates:
- --platform=linux/arm64
- --pull
Expand Down Expand Up @@ -149,6 +151,7 @@ dockers:
- '{{ .Env.IMG_PRE }}/ccip:sha-{{ .ShortCommit }}-amd64'
extra_files:
- tmp/libs
- tmp/workflows
- ccip/config
build_flag_templates:
- --platform=linux/amd64
Expand Down Expand Up @@ -176,6 +179,7 @@ dockers:
extra_files:
- tmp/libs
- tmp/plugins
- tmp/workflows
- ccip/config
build_flag_templates:
- --platform=linux/amd64
Expand Down Expand Up @@ -205,6 +209,7 @@ dockers:
- '{{ .Env.IMG_PRE }}/ccip:sha-{{ .ShortCommit }}-arm64'
extra_files:
- tmp/libs
- tmp/workflows
- ccip/config
build_flag_templates:
- --platform=linux/arm64
Expand All @@ -231,6 +236,7 @@ dockers:
extra_files:
- tmp/libs
- tmp/plugins
- tmp/workflows
- ccip/config
build_flag_templates:
- --platform=linux/arm64
Expand Down
15 changes: 0 additions & 15 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -579,21 +579,6 @@ packages:
github.com/smartcontractkit/chainlink/v2/core/services/registrysyncer:
interfaces:
ORM:
github.com/smartcontractkit/chainlink/v2/core/services/workflows/syncer:
interfaces:
ORM:
ContractReader:
config:
mockname: "Mock{{ .InterfaceName }}"
filename: contract_reader_mock.go
inpackage: true
dir: "{{ .InterfaceDir }}"
Handler:
config:
mockname: "Mock{{ .InterfaceName }}"
filename: handler_mock.go
inpackage: true
dir: "{{ .InterfaceDir }}"
github.com/smartcontractkit/chainlink/v2/core/capabilities/targets:
interfaces:
ContractValueGetter:
Empty file added config.yaml
Empty file.
2 changes: 1 addition & 1 deletion contracts/gas-snapshots/ccip.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -765,4 +765,4 @@ USDCTokenPool_releaseOrMint:test_TokenMaxCapacityExceeded_Revert() (gas: 47231)
USDCTokenPool_releaseOrMint:test_UnlockingUSDCFailed_Revert() (gas: 95315)
USDCTokenPool_setDomains:test_InvalidDomain_Revert() (gas: 66437)
USDCTokenPool_setDomains:test_OnlyOwner_Revert() (gas: 11314)
USDCTokenPool_supportsInterface:test_SupportsInterface_Success() (gas: 10107)
USDCTokenPool_supportsInterface:test_SupportsInterface_Success() (gas: 10107)
1 change: 1 addition & 0 deletions core/capabilities/compute/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ func (c *Compute) createFetcher() func(ctx context.Context, req *wasmpb.FetchReq
headersReq[k] = v.String()
}

fmt.Printf("LEN: %s, %d", req.Body, len(req.Body))
payloadBytes, err := json.Marshal(ghcapabilities.Request{
URL: req.Url,
Method: req.Method,
Expand Down
3 changes: 3 additions & 0 deletions core/chainlink.goreleaser.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ COPY ./chainlink /usr/local/bin/
# Copy native libs if cgo is enabled
COPY ./tmp/libs /usr/local/bin/libs

# Copy workflows
COPY ./tm[p]/workflow[s] /usr/local/workflows

# Copy plugins if exist and enable them
# https://stackoverflow.com/questions/70096208/dockerfile-copy-folder-if-it-exists-conditional-copy/70096420#70096420
COPY ./tm[p]/plugin[s]/ /usr/local/bin/
Expand Down
6 changes: 6 additions & 0 deletions core/cmd/shell_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,12 @@ func (s *Shell) runNode(c *cli.Context) error {
if err2 != nil {
return errors.Wrap(err2, "failed to ensure workflow key")
}
keys, err := app.GetKeyStore().Workflow().GetAll()
if err != nil {
lggr.Errorf("WorkflowPublicKey: failed to get keys")
} else {
lggr.Infof("WorkflowPublicKey: %s", keys[0].PublicKeyString())
}
}

err2 := app.GetKeyStore().CSA().EnsureKey(rootCtx)
Expand Down
11 changes: 8 additions & 3 deletions core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,6 @@ func NewApplication(opts ApplicationOpts) (Application, error) {

// TODO: wire this up to config so we only instantiate it
// if a workflow registry address is provided.
workflowRegistrySyncer := syncer.NewNullWorkflowRegistrySyncer()
srvcs = append(srvcs, workflowRegistrySyncer)

var externalPeerWrapper p2ptypes.PeerWrapper
if cfg.Capabilities().Peering().Enabled() {
var dispatcher remotetypes.Dispatcher
Expand Down Expand Up @@ -475,6 +472,14 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
webhookJobRunner = delegates[job.Webhook].(*webhook.Delegate).WebhookJobRunner()
)

workflowRegistrySyncer := &syncer.WorkflowRegistry{
DS: opts.DS,
Logger: globalLogger.Named("WorkflowRegistrySyncer"),
Store: workflowORM,
Registry: opts.CapabilitiesRegistry,
}
srvcs = append(srvcs, workflowRegistrySyncer)

delegates[job.Workflow] = workflows.NewDelegate(
globalLogger,
opts.CapabilitiesRegistry,
Expand Down
8 changes: 4 additions & 4 deletions core/services/gateway/handlers/capabilities/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@

const (
// NOTE: more methods will go here. HTTP trigger/action/target; etc.
MethodWebAPITarget = "web_api_target"
MethodWebAPITrigger = "web_api_trigger"
MethodComputeAction = "compute_action"
MethodWorkflowSyncer = "workflow_syncer"
MethodWebAPITarget = "web_api_target"
MethodWebAPITrigger = "web_api_trigger"
MethodComputeAction = "compute_action"
)

type handler struct {
Expand Down Expand Up @@ -77,6 +76,7 @@
// returns message to be sent back to the capability node
func (h *handler) sendHTTPMessageToClient(ctx context.Context, req network.HTTPRequest, msg *api.Message) (*api.Message, error) {
var payload Response
fmt.Printf("req: %v, %d", req)

Check failure on line 79 in core/services/gateway/handlers/capabilities/handler.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_race_tests)

fmt.Printf format %d reads arg #2, but call has 1 arg

Check failure on line 79 in core/services/gateway/handlers/capabilities/handler.go

View workflow job for this annotation

GitHub Actions / Core Tests (go_core_tests)

fmt.Printf format %d reads arg #2, but call has 1 arg
resp, err := h.httpClient.Send(ctx, req)
if err != nil {
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions core/services/gateway/network/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package network
import (
"bytes"
"context"
"fmt"
"io"
"net/http"
"strings"
Expand Down Expand Up @@ -67,6 +68,7 @@ func (c *httpClient) Send(ctx context.Context, req HTTPRequest) (*HTTPResponse,
}
defer resp.Body.Close()

fmt.Printf("bytes: %d", c.config.MaxResponseBytes)
reader := http.MaxBytesReader(nil, resp.Body, int64(c.config.MaxResponseBytes))
body, err := io.ReadAll(reader)
if err != nil {
Expand Down
42 changes: 9 additions & 33 deletions core/services/job/job_orm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/relay"
"github.com/smartcontractkit/chainlink/v2/core/services/vrf/vrfcommon"
"github.com/smartcontractkit/chainlink/v2/core/services/webhook"
"github.com/smartcontractkit/chainlink/v2/core/services/workflows/syncer"
"github.com/smartcontractkit/chainlink/v2/core/testdata/testspecs"
"github.com/smartcontractkit/chainlink/v2/core/utils/testutils/heavyweight"
)
Expand Down Expand Up @@ -1874,7 +1873,6 @@ func Test_ORM_FindJobByWorkflow(t *testing.T) {
c.ID = s.ID
c.Workflow = pkgworkflows.WFYamlSpec(t, "workflow99", addr1) // insert with mismatched name
c.SpecType = job.YamlSpec
c.SecretsID = s.SecretsID
return mustInsertWFJob(t, o, &c)
},
},
Expand All @@ -1894,40 +1892,29 @@ func Test_ORM_FindJobByWorkflow(t *testing.T) {
var c job.WorkflowSpec
c.ID = s.ID
c.Workflow = pkgworkflows.WFYamlSpec(t, "workflow03", addr2) // insert with mismatched owner
c.SecretsID = s.SecretsID
return mustInsertWFJob(t, o, &c)
},
},
wantErr: true,
},
}

for i, tt := range tests {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
ctx := testutils.Context(t)
ks := cltest.NewKeyStore(t, tt.fields.ds)

secretsORM := syncer.NewWorkflowRegistryDS(tt.fields.ds, logger.TestLogger(t))

sid, err := secretsORM.Create(ctx, "some-url.com", fmt.Sprintf("some-hash-%d", i), "some-contentz")
require.NoError(t, err)
tt.args.spec.SecretsID = sql.NullInt64{Int64: sid, Valid: true}

pipelineORM := pipeline.NewORM(tt.fields.ds, logger.TestLogger(t), configtest.NewTestGeneralConfig(t).JobPipeline().MaxSuccessfulRuns())
bridgesORM := bridges.NewORM(tt.fields.ds)
o := NewTestORM(t, tt.fields.ds, pipelineORM, bridgesORM, ks)

var wantJobID int32
if tt.args.before != nil {
wantJobID = tt.args.before(t, o, tt.args.spec)
}

ctx := testutils.Context(t)
gotJ, err := o.FindJobIDByWorkflow(ctx, *tt.args.spec)
if (err != nil) != tt.wantErr {
t.Errorf("orm.FindJobByWorkflow() error = %v, wantErr %v", err, tt.wantErr)
return
}

if err == nil {
assert.Equal(t, wantJobID, gotJ, "mismatch job id")
}
Expand All @@ -1949,36 +1936,25 @@ func Test_ORM_FindJobByWorkflow_Multiple(t *testing.T) {
bridges.NewORM(db),
cltest.NewKeyStore(t, db))
ctx := testutils.Context(t)
secretsORM := syncer.NewWorkflowRegistryDS(db, logger.TestLogger(t))

var sids []int64
for i := 0; i < 3; i++ {
sid, err := secretsORM.Create(ctx, "some-url.com", fmt.Sprintf("some-hash-%d", i), "some-contentz")
require.NoError(t, err)
sids = append(sids, sid)
}

wfYaml1 := pkgworkflows.WFYamlSpec(t, "workflow00", addr1)
s1 := job.WorkflowSpec{
Workflow: wfYaml1,
SpecType: job.YamlSpec,
SecretsID: sql.NullInt64{Int64: sids[0], Valid: true},
Workflow: wfYaml1,
SpecType: job.YamlSpec,
}
wantJobID1 := mustInsertWFJob(t, o, &s1)

wfYaml2 := pkgworkflows.WFYamlSpec(t, "workflow01", addr1)
s2 := job.WorkflowSpec{
Workflow: wfYaml2,
SpecType: job.YamlSpec,
SecretsID: sql.NullInt64{Int64: sids[1], Valid: true},
Workflow: wfYaml2,
SpecType: job.YamlSpec,
}
wantJobID2 := mustInsertWFJob(t, o, &s2)

wfYaml3 := pkgworkflows.WFYamlSpec(t, "workflow00", addr2)
s3 := job.WorkflowSpec{
Workflow: wfYaml3,
SpecType: job.YamlSpec,
SecretsID: sql.NullInt64{Int64: sids[2], Valid: true},
Workflow: wfYaml3,
SpecType: job.YamlSpec,
}
wantJobID3 := mustInsertWFJob(t, o, &s3)

Expand Down Expand Up @@ -2016,7 +1992,7 @@ func mustInsertWFJob(t *testing.T, orm job.ORM, s *job.WorkflowSpec) int32 {
}

err = orm.CreateJob(ctx, &j)
require.NoError(t, err, "failed to insert job with wf spec %+v %s", s, err)
require.NoError(t, err, "failed to insert job with wf spec %v %s", s, s.Workflow)
return j.ID
}

Expand Down
25 changes: 6 additions & 19 deletions core/services/job/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package job

import (
"context"
"database/sql"
"database/sql/driver"
"encoding/json"
"fmt"
Expand Down Expand Up @@ -869,30 +868,18 @@ const (
DefaultSpecType = ""
)

type WorkflowSpecStatus string

const (
WorkflowSpecStatusActive WorkflowSpecStatus = "active"
WorkflowSpecStatusPaused WorkflowSpecStatus = "paused"
WorkflowSpecStatusDefault WorkflowSpecStatus = ""
)

type WorkflowSpec struct {
ID int32 `toml:"-"`
Workflow string `toml:"workflow"` // the raw representation of the workflow
Config string `toml:"config" db:"config"` // the raw representation of the config
// fields derived from the yaml spec, used for indexing the database
// note: i tried to make these private, but translating them to the database seems to require them to be public
WorkflowID string `toml:"-" db:"workflow_id"` // Derived. Do not modify. the CID of the workflow.
WorkflowOwner string `toml:"-" db:"workflow_owner"` // Derived. Do not modify. the owner of the workflow.
WorkflowName string `toml:"-" db:"workflow_name"` // Derived. Do not modify. the name of the workflow.
Status WorkflowSpecStatus `db:"status"`
BinaryURL string `db:"binary_url"`
ConfigURL string `db:"config_url"`
SecretsID sql.NullInt64 `db:"secrets_id"`
CreatedAt time.Time `toml:"-"`
UpdatedAt time.Time `toml:"-"`
SpecType WorkflowSpecType `toml:"spec_type" db:"spec_type"`
WorkflowID string `toml:"-" db:"workflow_id"` // Derived. Do not modify. the CID of the workflow.
WorkflowOwner string `toml:"-" db:"workflow_owner"` // Derived. Do not modify. the owner of the workflow.
WorkflowName string `toml:"-" db:"workflow_name"` // Derived. Do not modify. the name of the workflow.
CreatedAt time.Time `toml:"-"`
UpdatedAt time.Time `toml:"-"`
SpecType WorkflowSpecType `toml:"spec_type" db:"spec_type"`
sdkWorkflow *sdk.WorkflowSpec
rawSpec []byte
config []byte
Expand Down
4 changes: 2 additions & 2 deletions core/services/job/orm.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ func (o *orm) CreateJob(ctx context.Context, jb *Job) error {
case Stream:
// 'stream' type has no associated spec, nothing to do here
case Workflow:
sql := `INSERT INTO workflow_specs (workflow, workflow_id, workflow_owner, workflow_name, binary_url, config_url, secrets_id, created_at, updated_at, spec_type, config)
VALUES (:workflow, :workflow_id, :workflow_owner, :workflow_name, :binary_url, :config_url, :secrets_id, NOW(), NOW(), :spec_type, :config)
sql := `INSERT INTO workflow_specs (workflow, workflow_id, workflow_owner, workflow_name, created_at, updated_at, spec_type, config)
VALUES (:workflow, :workflow_id, :workflow_owner, :workflow_name, NOW(), NOW(), :spec_type, :config)
RETURNING id;`
specID, err := tx.prepareQuerySpecID(ctx, sql, jb.WorkflowSpec)
if err != nil {
Expand Down
Loading
Loading