feat(profitability): allow per-chain RELAYER_GAS_PADDING overrides#3489
feat(profitability): allow per-chain RELAYER_GAS_PADDING overrides#3489droplet-rl wants to merge 2 commits into
Conversation
The relayer pads every estimated gas cost by `RELAYER_GAS_PADDING` (2.5% in prod) before checking profitability. The padding is appropriate for EVM destinations where simulator output can diverge from actual fill, but it's overkill for chains where the gas-side input is governance- fixed (Tron energy price), and that extra cushion is exactly what's been flipping borderline Mainnet → Tron multicall fills to "unprofitable" even after the bandwidth accounting from across-protocol/sdk#1459 landed. Add a `RELAYER_GAS_PADDING_<chainId>` env override pattern, mirroring the existing `RELAYER_MIN_FILL_TIME_<chainId>` / `SEND_MESSAGE_RELAYS_ <chainId>` conventions: - `RelayerConfig.relayerGasPaddingOverrides`: parsed from `RELAYER_GAS_PADDING_<chainId>` env vars for every chain the relayer cares about. Stored as raw padding fractions (e.g. `0.015` for 1.5%). - `ProfitClient.chainGasPadding`: holds the already-folded `1 + pad` form, validated 0%–200% per entry. - `ProfitClient.resolveGasPadding(chainId)` returns the per-chain multiplier if configured, otherwise the global `gasPadding`. All three padding application sites (`estimateFillCost` per-fill, `update` gas-cost cache, the two log emissions) route through it. No behavior change for chains without an override. `yarn typecheck` + `yarn lint` clean.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 98c805fe8d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| : process.env["SEND_MESSAGE_RELAYS"] === "true"; | ||
| this.sendingMessageRelaysEnabled[chainId] = sendMessageRelays; | ||
|
|
||
| const gasPaddingOverride = process.env[`RELAYER_GAS_PADDING_${chainId}`]; |
There was a problem hiding this comment.
Document RELAYER_GAS_PADDING chain overrides
Adding RELAYER_GAS_PADDING_<chainId> here changes relayer configuration, but the commit does not update any README/AGENTS docs. /workspace/relayer/AGENTS.md explicitly says to keep relevant AGENTS.md and README.md files updated whenever configuration changes; without a src/relayer/README.md or src/clients/README.md entry, operators can only discover this chain-specific profitability knob by reading code, which makes production tuning easy to miss or misconfigure.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — added a 'Per-destination-chain gas padding' subsection to src/clients/README.md (commit 48919c8) covering the global default, the RELAYER_GAS_PADDING_<chainId> override, the 0%–200% validation, the Tron motivation, and a worked example, mirroring the existing RELAYER_GAS_MULTIPLIER policy docs in the same file. No src/relayer/README.md change — the knob lives entirely in the Profit Client, and src/relayer/README.md already routes profitability questions there via its quick index.
Add a "Per-destination-chain gas padding" section to src/clients/README.md covering the global RELAYER_GAS_PADDING default and the new RELAYER_GAS_PADDING_<chainId> override, including the 0%-200% validation, the Tron motivation, and a worked example. Addresses codex P2 review note on PR #3489 — AGENTS.md requires keeping module READMEs in sync with configuration changes.
|
@codex addressed your P2 review note on documenting the new
Inline reply posted on the original discussion. Please take another pass. |
|
Codex Review: Didn't find any major issues. 🚀 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Thanks — re-review confirms the docs commit ( |
Summary
Adds a `RELAYER_GAS_PADDING_` env override pattern so we can scale the relayer's gas-cost padding per destination chain, rather than carrying the same blanket cushion (currently 2.5%) for every route.
The global default exists to absorb estimation noise on EVM destinations where the actual fill can consume more gas than the simulator predicts. On Tron the simulator is essentially exact (energy is governance-fixed and bandwidth scales with serialized bytes, which we already model in sdk#1459) — the 2.5% cushion just adds margin the relayer never spends. That cushion is also the line item flipping borderline Mainnet → Tron multicall fills to "unprofitable" in the primary bot's check, even after the bandwidth fix landed (cross-ref: deposit `3986569` analysis in #devops).
Approach
Mirror the existing per-chain env conventions (`RELAYER_MIN_FILL_TIME_`, `SEND_MESSAGE_RELAYS_`):
No behavior change for chains without an override — every existing call resolves through `resolveGasPadding` to the same `this.gasPadding` value as before.
Followups (not in this PR)
Test plan
🤖 Generated with Claude Code