Skip to content

fix: Increase fee limit to compensate for EIP-150 gas attenuation#1139

Open
nvsriram wants to merge 5 commits into
mainfrom
fix/CCIP-11515-eip150-gas-forwarding
Open

fix: Increase fee limit to compensate for EIP-150 gas attenuation#1139
nvsriram wants to merge 5 commits into
mainfrom
fix/CCIP-11515-eip150-gas-forwarding

Conversation

@nvsriram
Copy link
Copy Markdown
Collaborator

@nvsriram nvsriram commented May 29, 2026

Description

The executionGasLimit is currently used as the destination transaction fee limit. However, it does not account for EIP-150 forwarding at most ~63/64 gas with each external call.

This PR compensates for this attenuation by adding a buffer ($\left\lceil{\frac{64}{63} \left\lceil{\frac{64}{63}L}\right\rceil}\right\rceil - L$, where $L$ is the ccipReceiveGasLimit) to account for the two external calls made by the OffRamp (Router -> Receiver).

Testing

  • Updated contract transmitter tests to verify fee limit includes this new buffer
  • Added coverage where executionGasLimit and ccipReceiveGasLimit differ

@nvsriram nvsriram requested a review from a team as a code owner May 29, 2026 15:51
@github-actions
Copy link
Copy Markdown

👋 nvsriram, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

@nvsriram
Copy link
Copy Markdown
Collaborator Author

nvsriram commented May 29, 2026

Derivation for buffer

  • Let $L$ be the intended ccipReceiveGasLimit
  • Let $L_{router}$ be the gas required at Router so that the Receiver gets $L$
  • Let $L_{offRamp}$ be the gas required at OffRamp so that the Router gets $L_{router}$

EIP-150 forwards at most $\frac{63}{64}$ of available gas at each CALL boundary. On inverting, this means the caller must have at least $\left\lceil\frac{64}{63}L\right\rceil$ to ensure callee receives $L$

Working backwards from Receiver to OffRamp:

$$L_{router} = \left\lceil\frac{64}{63} L\right\rceil$$ $$L_{offRamp} = \left\lceil\frac{64}{63} L_{router}\right\rceil = \left\lceil\frac{64}{63}\left\lceil\frac{64}{63} L\right\rceil\right\rceil$$

Therefore the additional gas required is:

$$L_{offRamp} - L = \left\lceil\frac{64}{63} \left\lceil\frac{64}{63} L\right\rceil\right\rceil - L$$

@nvsriram nvsriram marked this pull request as draft May 29, 2026 17:21
@nvsriram nvsriram force-pushed the fix/CCIP-11515-eip150-gas-forwarding branch from 45cdeb7 to 335c17f Compare May 29, 2026 22:47
@nvsriram nvsriram marked this pull request as ready for review June 1, 2026 02:38
// eip150ForwardingGasBuffer returns the extra gas needed to compensate for EIP-150
// gas attenuation across the OffRamp -> Router -> Receiver call path.
// It computes ceil(((64^2 - 63^2) / 63^2) * L), where L is the ccipReceive gas limit.
func eip150ForwardingGasBuffer(ccipReceiveGasLimit uint32) uint64 {
Copy link
Copy Markdown
Collaborator

@RensR RensR Jun 1, 2026

Choose a reason for hiding this comment

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

Could we add a simple unit tests that asserts something like this?

ccipReceiveGasLimit := 200_000
withBuffer := eip150ForwardingGasBuffer(ccipReceiveGasLimit)

assert(floor(withBuffer / 64 * 63 / 64 * 63),  ccipReceiveGasLimit)

All of the current tests don't test this code, just that the function is being called.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Code coverage report:

Package main fix/CCIP-11515-eip150-gas-forwarding Diff
github.com/smartcontractkit/chainlink-ccv/aggregator 49.35% 49.31% -0.04%
github.com/smartcontractkit/chainlink-ccv/bootstrap 54.14% 54.14% +0.00%
github.com/smartcontractkit/chainlink-ccv/cli 65.13% 65.13% +0.00%
github.com/smartcontractkit/chainlink-ccv/cmd 15.54% 15.54% +0.00%
github.com/smartcontractkit/chainlink-ccv/common 56.54% 56.54% +0.00%
github.com/smartcontractkit/chainlink-ccv/executor 45.97% 45.97% +0.00%
github.com/smartcontractkit/chainlink-ccv/indexer 37.68% 37.68% +0.00%
github.com/smartcontractkit/chainlink-ccv/integration 45.59% 46.13% +0.54%
github.com/smartcontractkit/chainlink-ccv/pkg 84.62% 84.62% +0.00%
github.com/smartcontractkit/chainlink-ccv/pricer 0.00% 0.00% +0.00%
github.com/smartcontractkit/chainlink-ccv/protocol 63.06% 63.06% +0.00%
github.com/smartcontractkit/chainlink-ccv/verifier 34.49% 34.49% +0.00%
Total 46.50% 46.50% +0.00%

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