chore: update gas limit constant and configure linting rules#76
Conversation
- Renamed and updated `BLOCK_GAS_LIMIT` to `PER_TRANSACTION_GAS_LIMIT` in line with EIP-7825. - Added granular linting configuration in `foundry.toml`, including severity levels and exclusions.
WalkthroughAdds lint configuration to foundry.toml, bumps package version to 0.6.3, and updates DeployFacet.s.sol to use a per-transaction gas limit (1 << 24 per EIP-7825) instead of a block gas limit during deployment batch checks and warnings. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant BD as BatchDeployer
participant DF as DeployFacet
participant EVM as Network/EVM
Dev->>BD: Start deployment batch
BD->>DF: estimateBatchGas(contracts)
DF->>EVM: Simulate gas for batch
EVM-->>DF: gasEstimate
note over DF: Compare gasEstimate to PER_TRANSACTION_GAS_LIMIT (1<<24)
alt gasEstimate <= per-transaction limit
DF-->>BD: ok
BD->>EVM: send deployment tx
EVM-->>BD: receipt
else gasEstimate > per-transaction limit
DF-->>BD: warn("exceeds per-transaction limit: 16,777,216")
BD->>Dev: surface warning / adjust batch
end
rect rgba(230, 245, 255, 0.5)
note right of DF: Updated control: per-transaction limit replaces block-wide limit
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10–15 minutes Poem
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
foundry.toml (1)
24-27: Verify Foundry lint config support and scope exclusions
Runforge --versionandforge configin your local environment to confirm that Foundry recognizes the[lint]section withseverityandexclude_lints. Rather than globally excludingerc20-unchecked-transfer, use inline or file-level ignores (e.g.// forge-ignore-erc20-unchecked-transfer) to avoid hiding genuine issues.scripts/common/DeployFacet.s.sol (3)
19-19: Make the limit self-documenting and linter-friendly.Optional: use a decimal literal to avoid relying on the excluded
incorrect-shiftlint and document both forms.- uint256 internal constant PER_TRANSACTION_GAS_LIMIT = 1 << 24; // gas limit per EIP-7825 + // 16,777,216 gas per EIP-7825 (1 << 24) + uint256 internal constant PER_TRANSACTION_GAS_LIMIT = 16_777_216;
101-111: Avoid stale hardcoded number and warn only on threshold crossing.Precompute the per-add estimate, emit the warning once when crossing the threshold, and format the limit dynamically from the constant.
- // estimate gas cost for this deployment - batchGasEstimate += estimateDeploymentGas(bytecode); - - // check if adding this contract would exceed per-transaction gas limit - if (batchGasEstimate > PER_TRANSACTION_GAS_LIMIT) { - warn( - string.concat( - "DeployFacet: Adding contract ", - name, - " may exceed per-transaction gas limit 16,777,216. Deploy current batch first." - ) - ); - } + // estimate gas cost for this deployment + uint256 est = estimateDeploymentGas(bytecode); + // warn once when crossing the limit to avoid log spam + if (batchGasEstimate <= PER_TRANSACTION_GAS_LIMIT && batchGasEstimate + est > PER_TRANSACTION_GAS_LIMIT) { + warn( + string.concat( + "DeployFacet: Adding contract ", + name, + " would exceed per-transaction gas limit ", + PER_TRANSACTION_GAS_LIMIT.toString(), + ". Deploy current batch first." + ) + ); + } + batchGasEstimate += est;
18-24: Make PER_TRANSACTION_GAS_LIMIT chain-aware
Consider reading an optional environment variable (e.g. PER_TX_GAS_LIMIT) or applying a configurable safety margin (e.g. 95% of the current chain’s block gas limit) instead of the hardcoded 1<<24 to avoid OOG errors on networks with lower per-transaction ceilings.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (3)
foundry.toml(1 hunks)package.json(1 hunks)scripts/common/DeployFacet.s.sol(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Foundry project
🔇 Additional comments (1)
package.json (1)
3-3: Version bump looks good.No issues spotted with the 0.6.3 increment.
BLOCK_GAS_LIMITtoPER_TRANSACTION_GAS_LIMITin line with EIP-7825.foundry.toml, including severity levels and exclusions.Summary by CodeRabbit
Refactor
Chores