foundry-rs / forge-std

Forge Standard Library is a collection of helpful contracts for use with forge and foundry. It leverages forge's cheatcodes to make writing tests easier and faster, while improving the UX of cheatcodes. For more in-depth usage examples checkout the tests.
Apache License 2.0
846 stars 333 forks source link

Feature request: block gas limits for most popular chains #535

Closed PaulRBerg closed 7 months ago

PaulRBerg commented 7 months ago

Block gas limits can influence the configuration of smart contracts. For example, the MAX_SEGMENT_COUNT in Sablier is influenced by them.

Thus, it would be handy if Forge Std offered the block gas limits of the most popular chains (Ethereum, Arbitrum, Optmism, etc.) as fields in the Chain struct.

mds1 commented 7 months ago

For L1 chains, block gas limits are soft consensus parameters with no easy visibility, so I'm hesitant to add them since they're likely become out of date.

For OP Stack chains, you can read this value for a given chain by calling the gasLimit getter on the L1 SystemConfig contract. For example with OP Mainnet, the L1 SystemConfig contract address can be found here, and you can call

$ cast call 0x229047fed2591dbec1eF1118d64F7aF3dB9EB290 "gasLimit()(uint256)"
30000000

Arbitrum stack chains may expose this value similarly but I'm unsure offhand

PaulRBerg commented 7 months ago

Ok, in this case it makes sense to close this issue.

Thanks for your guidance on reading the gas limit on OP Stack chains. Didn't know about the gasLimit getter.