Skip to content

Billing: Shared gasmeter for cre:workflow:gas usage records - #813

Open
DylanTinianov wants to merge 1 commit into
mainfrom
CRE-6781-gasmeter-common
Open

DylanTinianov wants to merge 1 commit into
mainfrom
CRE-6781-gasmeter-common

Conversation

@DylanTinianov

@DylanTinianov DylanTinianov commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Part of CRE-6781. Extracts the gas usage emission that #804 duplicated in the EVM and Solana plugins into chain_capabilities/common/gasmeter, so every chain-write capability emits the same record and log line.

What

gasmeter.New(lggr, meteringCfg, chainSelector, capabilityDonID) returns nil unless MeterRecordsEnabled (the host's [Metering] gate, shared with durable resource metering). It builds the ResourceManager (snapshots off) and the identity: service chain-write, pool cre:workflow:gas, pool id cre:workflow:gas:<chain_selector>, DON id when known. Logs an error if the LOOP has no durable emitter.

(*Meter).Emit(ctx, metadata, txHash, fee) emits one METER_ACTION_USAGE record per chain write: resource type cre:workflow:gas:<chain_selector>, value in wei/lamports (EmitUsageValue), ResourceId <workflow_id>:<execution_id>, EventId = tx hash. Logs Emitted capability usage meter record (executionID, eventID, resourceType, value, orgID, txHash), the billing reconciler's contract line. A nil meter is a no-op; Start/Close delegate to the ResourceManager.

…e emission

One package for every chain-write capability: builds the usage ResourceManager
and identity from the LOOP metering config (gated by MeterRecordsEnabled,
snapshots off, DON id when known) and emits one METER_ACTION_USAGE record per
chain write keyed by tx hash, logging the reconciler contract line. Replaces the
copies in the EVM and Solana plugins (capabilities #804) and is what Stellar and
Aptos will use.

Bumps chainlink-common to main (29594528) for the workflow usage contract.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
DylanTinianov added a commit that referenced this pull request Oct 7, 2026
Replaces the duplicated ResourceManager wiring, emit function and tests in the
EVM and Solana plugins with chain_capabilities/common/gasmeter (#813). Each
plugin now builds one gasmeter.Meter from the LOOP metering config and calls
Emit at its fee-resolved point. Pins the common module to the #813 branch
until it merges.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@DylanTinianov DylanTinianov changed the title chain_capabilities/common: shared gasmeter for cre:workflow:gas usage records Billing: Shared gasmeter for cre:workflow:gas usage records Oct 7, 2026
@DylanTinianov DylanTinianov self-assigned this Oct 7, 2026
@cl-sonarqube-production

Copy link
Copy Markdown

resourcemanager.NewBaseIdentity(cfg.DeploymentIdentity, resourcemanager.EmittingServiceChainWrite, ""),
resourceType,
)
if capabilityDonID != 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a donID of 0 could be valid, no? Or you want the contract for callers of New to be they set 0 if they don't know the capabilityDonID?

I think if its the latter, we'd benefit most from assuming callers do know the capabilityDonID, or by making capabilityDonID a pointer.

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.

2 participants