Repository navigation
Billing: Emit gas MeterRecords for EVM + Solana chain writes - #804
Open
DylanTinianov wants to merge 7 commits into
Open
DylanTinianov wants to merge 7 commits into
DylanTinianov wants to merge 7 commits into
Conversation
…ana (CRE-6781, CRE-6782) When the host sets [Metering].CapabilityUsageEnabled (CL_CAPABILITY_USAGE_ENABLED in the LOOP env), the EVM and Solana plugins build a ResourceManager on the LOOP's durable emitter and emit one METER_ACTION_USAGE record per chain write at the point where the fee is already resolved for the legacy metering metadata: - resource type cre:workflow:gas:<chain_selector>, value in wei / lamports (EmitUsageValue, no int64 truncation) - Utilization.ResourceId "<workflow_id>:<execution_id>", EventId = tx hash (EVM) or tx signature (Solana): identical on every node that observes the write - Identity.Service chain-write, DON id = capability DON id when known Independent of MeterRecordsEnabled. Each emission logs "Emitted capability usage meter record" (executionID, eventID, resourceType, value, orgID, txHash), a contract for the billing reconciler, covered by unit tests in both plugins. Logs a warning at start-up if the LOOP has no durable emitter configured, since records would then be dropped fail-open. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
product-security-plaid-production
Bot
requested review from
george-dorin,
justinkaseman and
silaslenihan
September 29, 2026 17:59
DylanTinianov
marked this pull request as draft
September 29, 2026 18:27
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The metering lifecycle, deterministic billing fields, fail-open behavior, and large-value handling are implemented consistently and covered by focused tests.
Review effort: Balanced
Findings: None
What changed in this PR
Adds capability-usage gas metering for EVM and Solana writes while preserving legacy response metadata.
Changes:
- Wires resource managers from LOOP metering configuration.
- Emits deterministic gas usage records and reconciliation logs.
- Adds unit coverage and updates dependencies.
| File | Description |
|---|---|
chain_capabilities/solana/main.go |
Configures and manages Solana usage metering. |
chain_capabilities/solana/go.sum |
Updates dependency checksums. |
chain_capabilities/solana/go.mod |
Adds direct metering dependencies. |
chain_capabilities/solana/actions/write_report.go |
Emits gas records after fee resolution. |
chain_capabilities/solana/actions/gas_usage_test.go |
Tests Solana record content and logging. |
chain_capabilities/solana/actions/actions.go |
Adds usage-meter configuration to Solana actions. |
chain_capabilities/evm/main.go |
Configures and manages EVM usage metering. |
chain_capabilities/evm/go.sum |
Updates dependency checksums. |
chain_capabilities/evm/go.mod |
Adds direct metering dependencies. |
chain_capabilities/evm/actions/write_report.go |
Emits gas records from resolved transaction fees. |
chain_capabilities/evm/actions/gas_usage_test.go |
Tests EVM record content and logging. |
chain_capabilities/evm/actions/actions.go |
Adds usage-meter configuration to EVM actions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Identity.ResourcePool "cre:workflow:gas" and ResourcePoolID "cre:workflow:gas:<chain_selector>", derived via resourcemanager.WithWorkflowUsagePool from the plugin's chain selector, matching the Billing <-> Decentralized stack contract. Bumps chainlink-common. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…bilityUsageEnabled chainlink-common #2428 dropped the separate CapabilityUsageEnabled flag per review: usage records share the host's [Metering].MeterRecordsEnabled gate with durable resource metering. The EVM and Solana plugins now build the gas usage ResourceManager from MeteringConfig when MeterRecordsEnabled is set, snapshots off. Bumps chainlink-common to main (29594528, includes #2428) in both modules. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…mon to main (29594528, includes #2428)
DylanTinianov
marked this pull request as ready for review
October 7, 2026 15:47
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>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
DylanTinianov
marked this pull request as draft
October 7, 2026 16:42
DylanTinianov
marked this pull request as ready for review
October 7, 2026 16:44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Emits
cre:workflow:gasusage MeterRecords for EVM and Solana chain writes (CRE-6781, CRE-6782). Uses the sharedchain_capabilities/common/gasmeterpackage from #813 (merge first; the plugins pin that branch until it lands, then re-bump) on top of chainlink-common #2428 (merged).What
When the host sets
[Metering].MeterRecordsEnabled(CL_METER_RECORDS_ENABLEDin the LOOP env; the same gate as durable resource metering, no separate flag), the EVM and Solana plugins build agasmeter.Meter(ResourceManager on the LOOP's durable emitter) and callEmitonce per chain write, at the point where the fee is already resolved for the legacy metering metadata.cre:workflow:gas:<chain_selector>EmitUsageValue, no int64 truncationResourceId<workflow_id>:<execution_id>EventIdIdentity.Servicechain-writeIdentity.ResourcePool/ResourcePoolIdcre:workflow:gas/ the resource typeDon.DonIdOrgIdBehaviour:
Emitted capability usage meter record(executionID, eventID, resourceType, value, orgID, txHash), a contract for the billing reconciler