Skip to content

Add transmission attempt gas limit assertion with user provided value - #766

Open
Unheilbar wants to merge 6 commits into
mainfrom
add_onchain_gas_missmatch_check
Open

Unheilbar wants to merge 6 commits into
mainfrom
add_onchain_gas_missmatch_check

Conversation

@Unheilbar

Copy link
Copy Markdown
Contributor

No description provided.

@Unheilbar
Unheilbar marked this pull request as ready for review September 15, 2026 21:07
@Unheilbar
Unheilbar requested review from a team as code owners September 15, 2026 21:07
silaslenihan
silaslenihan previously approved these changes Sep 18, 2026
WriteReportInsufficientGasRetry struct {
basic commoncapbeholder.MetricsCapBasic
}
WriteReportGasMismatch struct {

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.

are we planning to add monitoring or alerting around this ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, In a follow up

Comment thread chain_capabilities/evm/monitoring/metrics.go
// The minimum amount of gas that the receiver contract must get to process the forwarder report. This is the default value used when the user doesn't specify a gas limit when invoking WriteReport.
ReceiverGasMinimum uint64 `json:"receiverGasMinimum"`
ReceiverGasMinimum uint64 `json:"receiverGasMinimum"`
// Safety margin, in gas, added on top of the forwarder contract's internal gas reservation

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.

you will need a corresponding CLD PR to be able to pass this through job specs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will do in follow up with bumped capability in core and updated regression e2e test

Comment thread chain_capabilities/evm/internal/contracts/cre_forwarder.go Outdated
// limit minus the forwarder's gas overhead, or the configured receiver gas minimum when no
// explicit limit was provided.
func (e *WriteReport) estimateReceiverGasBudget(request *evm.WriteReportRequest) uint64 {
receiverGasBudget := e.ReceiverGasMinimum + e.forwarderGasOverhead

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.

how come we add forwarderGasOverhead to receiverGasBudget here ?
i might be missing something.
from my understanding, receiverGasBudget is the gas that the receiver has available to use. Not being able to understand why we add forwarderGas into that ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There are two options:

  1. User did not provide Gas, then the value we provide is forwarderGasOverhead + receiverGasMinimum. Because we want to cover our internal forwarder logic + some gas for receiver execution(the constants are aligned with what we have on chain)
  2. User provided gas, further in the code you can see calculations for this case

Comment thread chain_capabilities/evm/actions/write_report.go
@cl-sonarqube-production

Copy link
Copy Markdown

Comment on lines -425 to +481
receiverGasBudget = request.GasConfig.GasLimit - contracts.ForwarderContractLogicGasCost
receiverGasBudget = request.GasConfig.GasLimit - e.forwarderGasOverhead

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.

Thinking about this again, shouldn't we keep contracts.ForwarderContractLogicGasCost around for backwards compatibility? Otherwise forwarderGasOverhead won't include a ForwarderGasOverheadMargin since this change introduces that field.

The other option is separately introducing ForwarderGasOverheadMargin, setting it on whichever chains need it, then adding this new logic to replace contracts.ForwarderContractLogicGasCost

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.

4 participants