Open to work | ✯ https://xitter.cf/t.co/GIde268mPb | prev. @onchainheroes

mload(0x40)
Joined January 2015
New article: deriving the math behind Solady's 67-byte, 114-gas sqrt(x) from first principles. The Solady CLZ PR just merged! 🚀 github.com/Vectorized/solady… No magic multipliers Exactly 6 Babylonian iterations 1 floor correction Full derivation 👇
2
2
14
964
1/4 Answer: Version D1 is cheaper by 6 gas! 🎉 This behavior is caused by the Solidity compiler's internal "stack scheduling" heuristic during code generation. It seems counterintuitive to delay a revert check, but on the happy path, it makes a massive difference to stack layout. Here is exactly why:
Solidity Compiler Quiz Challenge Both functions calculate the exact same mathematical expression. Which version is cheaper on the happy path, and why? 👇 (Spoiler: This is used in `solady.fullMulDiv()`)
1
1
6
854
3/4 JUMPI pops condition + destination — whatever's left is exactly what the fall-through block opens with. Compare both snapshots right after JUMPI: D1 → [lo, rem, d, extra] all 4 live — SUB/DIV/ADD fire directly D2 → [b, a, d, lo] rem and extra don't exist yet In D2, MULMOD needs [a, b, d] on top. Block B opens with [b, a, d, lo]. Two ops fix it: DUP3 [d, b, a, d, lo] <--- copy d SWAP2 [a, b, d, d, lo] <--- reorder args for MULMOD
1
268
4/4 DUP3 + SWAP2 = 6 gas. Two opcodes. That's the entire delta. Solady already uses this in FixedPointMathLib.sol (fullMulDiv): r := mulmod(x, y, d) ← before check t := and(d, sub(0, d)) ← before check if iszero(...) { revert } Rule: batch intermediates before the revert check. One unified block → compiler plans the full layout. JUMPI in the middle → fall-through starts blind.
2
80
Solidity Compiler Quiz Challenge Both functions calculate the exact same mathematical expression. Which version is cheaper on the happy path, and why? 👇 (Spoiler: This is used in `solady.fullMulDiv()`)
2
1
2
1,135
New article: deriving the math behind Solady’s `cbrt(x)` implementation from first principles. What is the 0x90b5e5 constant actually doing? original implementation by @duncancmt * Why cube root needs magic multipliers * Why sqrt does not * Optimal Initial guess * Exactly 5 Newton Rashson iterations Full blog post: atarpara.github.io/solady-cb…
5
5
49
3,663
The quirk: Integer Babylonian iterations get stuck bouncing between floor and ceil forever if x+1 is a perfect square (like x=15). `sub(z, lt(div(x, z), z))` is the floor correction. It catches the cycle and subtracts 1.
1
1
146
Ethereum’s next major upgrade, “Fusaka”, goes live in less than 48 hours. I read all 13 EIPs being included so you don’t have to. So, here are 13 tweets (with diagrams) to explain the 13 upgrades in simple terms: 🧵
114
305
35
1,741
153,482
Hey @solidity_lang, the community is eagerly waiting for the Solidity Summit 2025 recordings! 🗓️ The speaker lineup looked amazing. Any ETA on when they’ll hit YouTube or anywhere else? Thanks!
1
3
264
If solady has a million fans then I am one of them If solady has ten fans then I am one of them If solady has only one fan then that is me If solady has no fans then that means I am no longer on earth If the world is against solady then I am against the world
If solady has a million fans then I am one of them If solady has ten fans then I am one of them If solady has only one fan then that is me If solady has no fans then that means I am no longer on earth If the world is against solady then I am against the world
5
557
A common Solidity optimization pattern is to pack variables into the minimum amount of storage slots. But what if you want to generalize to uint256s? Conditional packing is a pain. Enter Solady's optimized `LibZip.cdCompress`. Now 4x faster. So fast, it opens up new use cases.
35
19
5
301
24,650