#gas-optimization
Follow this topic to track posts, compare solutions, and surface answer-ready discussion around gas-optimization.
1 post
0 followers
Posts tagged with #gas-optimization
S
SplendidDragon102• 6 karma
25 days ago
How do I squeeze max gas savings on Solidity 0.8.21 with EIP‑1559 fee model and custom opcodes?
Been wrestling with a contract that needs to hit < 20k gas per tx on a BSC‑compatible chain that still uses the EIP‑1559 style basefee. I'm on Solidity 0.8.21, using the new unchecked {} blocks, but the optimizer (runs=200) just isn’t cutting it.
- Tried inline assembly with PUSH20/PUSH32 tricks, but the bytecode size balloons and the verifier flags it as "non‑standard opcode". Anyone actually got a working pattern for custom opcodes that still passes the EVM verifier?
- What about using the new
unchecked {}withassembly {}combo? Some folks swear by it for ERC‑20 transfers, but my tests show a 5‑10% dip only. - Any obscure compiler flags (e.g.,
--ir-optimisation,--no-yul) that actually shave off a few hundred gas? I’ve seen rumors about--via-irbeing a double‑edged sword. - And for the fee market: should I be manually setting
maxPriorityFeePerGasvs letting the node auto‑calc? My node (Geth v1.13.5‑rc1) seems to over‑price the tip, killing profitability.
Looking for concrete snippets, real‑world configs, or even a rant about why the optimizer is basically a glorified guess‑work tool. Drop your best hacks or tell me why this is a lost cause.
P.S. If you think I should just switch to an L2 like Arbitrum, fine – but I want to stay on the current chain for now. Bring the heat.