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
5 changes: 5 additions & 0 deletions .changeset/fuzzy-falcons-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

#removed Removed support for the Webhook job. Database tables and the front end related logic have not been removed, but jobs will no longer start.
4 changes: 0 additions & 4 deletions .mockery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,6 @@ packages:
mockname: "Mock{{ .InterfaceName | camelcase }}"
interfaces:
MonitoringEndpointGenerator:
github.com/smartcontractkit/chainlink/v2/core/services/webhook:
interfaces:
ExternalInitiatorManager:
HTTPClient:
github.com/smartcontractkit/chainlink/v2/core/sessions:
interfaces:
BasicAdminUsersORM:
Expand Down
36 changes: 17 additions & 19 deletions core/cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/periodicbackup"
"github.com/smartcontractkit/chainlink/v2/core/services/pg"
"github.com/smartcontractkit/chainlink/v2/core/services/versioning"
"github.com/smartcontractkit/chainlink/v2/core/services/webhook"
workflowsmonitoring "github.com/smartcontractkit/chainlink/v2/core/services/workflows/monitoring"
"github.com/smartcontractkit/chainlink/v2/core/services/workflows/syncer"
"github.com/smartcontractkit/chainlink/v2/core/sessions"
Expand Down Expand Up @@ -288,24 +287,23 @@ func (n ChainlinkAppFactory) NewApplication(ctx context.Context, cfg chainlink.G
}

return chainlink.NewApplication(ctx, chainlink.ApplicationOpts{
Opts: creOpts,
Config: cfg,
DS: ds,
KeyStore: keyStore,
Logger: appLggr,
Registerer: appRegisterer,
AuditLogger: auditLogger,
ExternalInitiatorManager: webhook.NewExternalInitiatorManager(ds, unrestrictedClient),
Version: static.Version,
VersionTag: static.VersionTag,
DockerTag: dockerTag,
RestrictedHTTPClient: clhttp.NewRestrictedClient(cfg.Database(), appLggr),
UnrestrictedHTTPClient: unrestrictedClient,
SecretGenerator: chainlink.FilePersistedSecretGenerator{},
GRPCOpts: grpcOpts,
MercuryPool: mercuryPool,
RetirementReportCache: retirement.NewRetirementReportCache(appLggr, ds),
LLOTransmissionReaper: llo.NewTransmissionReaper(ds, appLggr, cfg.Mercury().Transmitter().ReaperFrequency(), cfg.Mercury().Transmitter().ReaperMaxAge()),
Opts: creOpts,
Config: cfg,
DS: ds,
KeyStore: keyStore,
Logger: appLggr,
Registerer: appRegisterer,
AuditLogger: auditLogger,
Version: static.Version,
VersionTag: static.VersionTag,
DockerTag: dockerTag,
RestrictedHTTPClient: clhttp.NewRestrictedClient(cfg.Database(), appLggr),
UnrestrictedHTTPClient: unrestrictedClient,
SecretGenerator: chainlink.FilePersistedSecretGenerator{},
GRPCOpts: grpcOpts,
MercuryPool: mercuryPool,
RetirementReportCache: retirement.NewRetirementReportCache(appLggr, ds),
LLOTransmissionReaper: llo.NewTransmissionReaper(ds, appLggr, cfg.Mercury().Transmitter().ReaperFrequency(), cfg.Mercury().Transmitter().ReaperMaxAge()),
})
}

Expand Down
2 changes: 1 addition & 1 deletion core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ ListenIP = '0.0.0.0' # Default
DisplayName = "cre-workflow-1-chainlinklabs" # Example

[JobPipeline]
# ExternalInitiatorsEnabled enables the External Initiator feature. If disabled, `webhook` jobs can ONLY be initiated by a logged-in user. If enabled, `webhook` jobs can be initiated by a whitelisted external initiator.
# ExternalInitiatorsEnabled Unused: used to enables the External Initiator feature for legacy webhook job runs via external initiators
ExternalInitiatorsEnabled = false # Default
# MaxRunDuration is the maximum time allowed for a single job run. If it takes longer, it will exit early and be marked errored. If set to zero, disables the time limit completely.
MaxRunDuration = '10m' # Default
Expand Down
81 changes: 17 additions & 64 deletions core/internal/cltest/cltest.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"net/url"
"os"
"reflect"
"strconv"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -71,7 +72,6 @@ import (
"github.com/smartcontractkit/chainlink-common/keystore/corekeys/vrfkey"
"github.com/smartcontractkit/chainlink-data-streams/mercury/wsrpc"
"github.com/smartcontractkit/chainlink-data-streams/mercury/wsrpc/cache"
"github.com/smartcontractkit/chainlink/v2/core/auth"
"github.com/smartcontractkit/chainlink/v2/core/bridges"
"github.com/smartcontractkit/chainlink/v2/core/capabilities"
remotetypes "github.com/smartcontractkit/chainlink/v2/core/capabilities/remote/types"
Expand All @@ -92,10 +92,8 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/pg"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
"github.com/smartcontractkit/chainlink/v2/core/services/standardcapabilities"
"github.com/smartcontractkit/chainlink/v2/core/services/webhook"
wftypes "github.com/smartcontractkit/chainlink/v2/core/services/workflows/types"
clsessions "github.com/smartcontractkit/chainlink/v2/core/sessions"
"github.com/smartcontractkit/chainlink/v2/core/static"
"github.com/smartcontractkit/chainlink/v2/core/store/models"
"github.com/smartcontractkit/chainlink/v2/core/web"
webauth "github.com/smartcontractkit/chainlink/v2/core/web/auth"
Expand Down Expand Up @@ -258,10 +256,6 @@ func NewApplicationWithConfigAndKey(t testing.TB, c chainlink.GeneralConfig, fla
return app
}

const (
UseRealExternalInitiatorManager = "UseRealExternalInitiatorManager"
)

// NewApplicationWithConfig creates a New TestApplication with specified test config.
// This should only be used in full integration tests. For controller tests, see NewApplicationEVMDisabled.
func NewApplicationWithConfig(t testing.TB, cfg chainlink.GeneralConfig, flagsAndDeps ...any) *TestApplication {
Expand Down Expand Up @@ -361,21 +355,10 @@ func NewApplicationWithConfig(t testing.TB, cfg chainlink.GeneralConfig, flagsAn
ds := sqlutil.WrapDataSource(db, lggr, sqlutil.TimeoutHook(cfg.Database().DefaultQueryTimeout))

var ethClient evmclient.Client
var externalInitiatorManager webhook.ExternalInitiatorManager
externalInitiatorManager = &webhook.NullExternalInitiatorManager{}
var useRealExternalInitiatorManager bool

for _, flag := range flagsAndDeps {
switch dep := flag.(type) {
case evmclient.Client:
if dep, ok := flag.(evmclient.Client); ok {
ethClient = dep
case webhook.ExternalInitiatorManager:
externalInitiatorManager = dep
default:
switch flag {
case UseRealExternalInitiatorManager:
externalInitiatorManager = webhook.NewExternalInitiatorManager(ds, clhttptest.NewTestLocalOnlyHTTPClient())
}
}
}

Expand Down Expand Up @@ -434,19 +417,18 @@ func NewApplicationWithConfig(t testing.TB, cfg chainlink.GeneralConfig, flagsAn
Logger: lggr,
// Don't use global registry here since otherwise multiple apps can create name conflicts.
// Could also potentially give a mock registry to test prometheus.
Registerer: prometheus.NewRegistry(),
AuditLogger: auditLogger,
CloseLogger: lggr.Sync,
ExternalInitiatorManager: externalInitiatorManager,
RestrictedHTTPClient: c,
UnrestrictedHTTPClient: c,
SecretGenerator: MockSecretGenerator{},
MercuryPool: mercuryPool,
NewOracleFactoryFn: newOracleFactoryFn,
RetirementReportCache: retirement.NewRetirementReportCache(lggr, ds),
LLOTransmissionReaper: llo.NewTransmissionReaper(ds, lggr, cfg.Mercury().Transmitter().ReaperFrequency(), cfg.Mercury().Transmitter().ReaperMaxAge()),
EVMFactoryConfigFn: evmFactoryConfigFn,
DonTimeStore: dontime.NewStore(dontime.DefaultRequestTimeout),
Registerer: prometheus.NewRegistry(),
AuditLogger: auditLogger,
CloseLogger: lggr.Sync,
RestrictedHTTPClient: c,
UnrestrictedHTTPClient: c,
SecretGenerator: MockSecretGenerator{},
MercuryPool: mercuryPool,
NewOracleFactoryFn: newOracleFactoryFn,
RetirementReportCache: retirement.NewRetirementReportCache(lggr, ds),
LLOTransmissionReaper: llo.NewTransmissionReaper(ds, lggr, cfg.Mercury().Transmitter().ReaperFrequency(), cfg.Mercury().Transmitter().ReaperMaxAge()),
EVMFactoryConfigFn: evmFactoryConfigFn,
DonTimeStore: dontime.NewStore(dontime.DefaultRequestTimeout),
})

require.NoError(t, err)
Expand All @@ -467,10 +449,6 @@ func NewApplicationWithConfig(t testing.TB, cfg chainlink.GeneralConfig, flagsAn
srvr.Start()
ta.Server = srvr

if !useRealExternalInitiatorManager {
app.ExternalInitiatorManager = externalInitiatorManager
}

return ta
}

Expand Down Expand Up @@ -984,42 +962,17 @@ func AwaitJobActive(t testing.TB, jobSpawner job.Spawner, jobID int32, waitFor t
}, waitFor, 100*time.Millisecond)
}

func CreateJobRunViaExternalInitiatorV2(
t testing.TB,
app *TestApplication,
jobID uuid.UUID,
eia auth.Token,
body string,
) webpresenters.PipelineRunResource {
t.Helper()

headers := make(map[string]string)
headers[static.ExternalInitiatorAccessKeyHeader] = eia.AccessKey
headers[static.ExternalInitiatorSecretHeader] = eia.Secret

url := app.Server.URL + "/v2/jobs/" + jobID.String() + "/runs"
bodyBuf := bytes.NewBufferString(body)
resp, cleanup := UnauthenticatedPost(t, url, bodyBuf, headers)
defer cleanup()
AssertServerResponse(t, resp, 200)
var pr webpresenters.PipelineRunResource
ParseJSONAPIResponse(t, resp, &pr)

// assert.Equal(t, j.ID, pr.JobSpecID)
return pr
}

func CreateJobRunViaUser(
func CreateJobRunViaUserByID(
t testing.TB,
app *TestApplication,
jobID uuid.UUID,
jobID int32,
body string,
) webpresenters.PipelineRunResource {
t.Helper()

bodyBuf := bytes.NewBufferString(body)
client := app.NewHTTPClient(nil)
resp, cleanup := client.Post("/v2/jobs/"+jobID.String()+"/runs", bodyBuf)
resp, cleanup := client.Post("/v2/jobs/"+strconv.Itoa(int(jobID))+"/runs", bodyBuf)
defer cleanup()
AssertServerResponse(t, resp, 200)
var pr webpresenters.PipelineRunResource
Expand Down
9 changes: 7 additions & 2 deletions core/internal/cltest/job_factories.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func MinimalOCRNonBootstrapSpec(contractAddress, transmitterAddress types.EIP55A
return fmt.Sprintf(minimalOCRNonBootstrapTemplate, contractAddress, testutils.FixtureChainID.String(), peerID, transmitterAddress.Hex(), keyBundleID)
}

func MustInsertWebhookSpec(t *testing.T, ds sqlutil.DataSource) (job.Job, job.WebhookSpec) {
func MustInsertWebhookSpec(t *testing.T, ds sqlutil.DataSource, externalJobID ...uuid.UUID) (job.Job, job.WebhookSpec) {
ctx := testutils.Context(t)
jobORM, pipelineORM := getORMs(t, ds)
webhookSpec := job.WebhookSpec{}
Expand All @@ -52,8 +52,13 @@ func MustInsertWebhookSpec(t *testing.T, ds sqlutil.DataSource) (job.Job, job.We
pipelineSpecID, err := pipelineORM.CreateSpec(ctx, pSpec, 0)
require.NoError(t, err)

extID := uuid.New()
if len(externalJobID) > 0 {
extID = externalJobID[0]
}

createdJob := job.Job{WebhookSpecID: &webhookSpec.ID, WebhookSpec: &webhookSpec, SchemaVersion: 1, Type: "webhook",
ExternalJobID: uuid.New(), PipelineSpecID: pipelineSpecID}
ExternalJobID: extID, PipelineSpecID: pipelineSpecID}
require.NoError(t, jobORM.InsertJob(ctx, &createdJob))

return createdJob, webhookSpec
Expand Down
Loading
Loading