Skip to content

WIP: adding resource managers for triggers#657

Draft
patrickhuie19 wants to merge 6 commits into
mainfrom
feat/shared-2709
Draft

WIP: adding resource managers for triggers#657
patrickhuie19 wants to merge 6 commits into
mainfrom
feat/shared-2709

Conversation

@patrickhuie19

Copy link
Copy Markdown
Contributor

cron already carried the SHARED-2709 local `replace` stack for
chainlink-common and chainlink-protos/metering/go; its sibling modules
(http_trigger, chain_capabilities/evm, integration_tests) pinned the same
versions but lacked the replaces, so they resolved a different module state
than cron. Add the same replace directives (depth-adjusted) to keep the
local stack consistent across all four modules. No version pins bumped.
@cl-sonarqube-production

Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 75%)

See analysis details on SonarQube

Phase 3 of the delta-based metering redesign. Replaces the RESERVE/RELEASE
emitter model with signed-delta UPDATE records built on the new
chainlink-common resourcemanager API.

All three producers (cron, http_trigger, chain_capabilities/evm):
- Emit only METER_ACTION_UPDATE via EmitDelta (register=+N, unregister=-N);
  RESERVE/RELEASE are never emitted.
- Delete all process-lifecycle (graceful-close) emissions; the Meterable is
  deregistered from the ResourceManager first on shutdown, and billing releases
  a resource by its absence from the next snapshot.
- Store the workflow OWNER (never a resolved org) in durable state; org is
  resolved at emit time via orgresolver.ResolveOrEmpty and in snapshots via a
  shared CachingOrgResolver whose Start/Close are wired into each service.
- Adopt the Phase 2 helpers: ConfigFromEnv, NewBaseIdentity,
  WithWorkflowDonFallback, ResolveOrEmpty, NewCaching. event_id is stamped by
  the ResourceManager per emission (producers never set it).
- Resolve the authoritative CapDONID once and feed the single value to both the
  metering identity and the events.KeyDonID labeler.

EVM: shared physical filters are billed once via a derived 0<->1 refcount
(+addressCount on activation, -addressCount on release), computed atomically
under the store lock; snapshots dedup to one entry per physicalFilterID with
"lowest triggerID's owner" attribution; the store write is synchronous before
the delta emission and cleanUpStaleFilters gains a minimum-age guard.

Cron: emitMeterRecord derives don_id/owner from stored trigger state and shares
utilization construction with GetUtilization; the callback closes the
resurrection window with an atomic WriteIfPresent.

HTTP: upsertWorkflow atomically returns the evicted workflow, removing the
RegisterWorkflow pre-read TOCTOU; same-ID re-register emits nothing, version
update emits -1/+1; RM start failure now logs-and-continues (fail-open, uniform
with EVM).

Tests updated for delta semantics (signed values, no shutdown emissions, EVM
0<->1 dedup, unique event_ids, cll-meter domain, shared CapDONID). go.mod/go.sum
pick up the forced transitive node-platform resolution required to build against
the local chainlink-common replace.
… producers

The common EmitDelta/EmitUsage now require a producer-supplied event_id. Each
trigger producer derives it via resourcemanager.EventID from the DON-aggregated
request that drove the delta, so every capability-DON node emits the identical
value for the same logical (un)register. The remote trigger publisher invokes
RegisterTrigger/UnregisterTrigger with the mode-aggregated request (byte-identical
on every node), so the request fields are DON-consistent.

- cron: EventID("cron-register"/"cron-unregister", workflowID, triggerID).
- http: EventID("http-register"/"http-unregister", workflowID); version updates
  change the workflowID so their +1/-1 pairs are distinct; unregister hashes
  symmetrically with register.
- evm: EventID("evm-activate"/"evm-release", workflowID, triggerID) from the
  RegisterLogTrigger/UnregisterLogTrigger request; physicalFilterID stays the
  resource_id (not the event_id).

Also scrubs stale "UUID" wording from the event_id docs and aligns each module's
metering pin to the merged chainlink-common pin (local replace intact).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant