From 08ee398b956437759b0a21a3bfa1b5b1eee820a2 Mon Sep 17 00:00:00 2001 From: atarpara Date: Thu, 14 May 2026 11:44:09 +0530 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A5=A2=20Added=20Credit=20for=20cbrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/clz/FixedPointMathLib.sol | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/clz/FixedPointMathLib.sol b/src/utils/clz/FixedPointMathLib.sol index c3be70416..247915c33 100644 --- a/src/utils/clz/FixedPointMathLib.sol +++ b/src/utils/clz/FixedPointMathLib.sol @@ -801,10 +801,12 @@ library FixedPointMathLib { /// @dev Returns the cube root of `x`, rounded down. /// Credit to bout3fiddy and pcaversaccio under AGPLv3 license: /// https://github.com/pcaversaccio/snekmate/blob/main/src/snekmate/utils/math.vy + /// Credit to duncancmt + /// https://github.com/0xProject/0x-settler/blob/2577ae61a3ca26a5b37ef8769b05f05de5115e93/src/vendor/Cbrt.sol function cbrt(uint256 x) internal pure returns (uint256 z) { /// @solidity memory-safe-assembly assembly { - // Initial guess z โ‰ˆ c ยท 2๐žฅ where b = โŒŠlogโ‚‚(x)โŒ‹, q = โŒŠb / 3โŒ‹. The + // Initial guess z โ‰ˆ c ยท 2^q where b = โŒŠlogโ‚‚(x)โŒ‹, q = โŒŠb / 3โŒ‹. The // 8-bit fixed-point multipliers `c`: 144/128, 181/128, and 229/128 // are selected by `b mod 3` to balance each octave's worst-case // final error. This gives >98 bits of precision after only 5 From c55566532c89f121b8ecc6b278a88bb4bd39e498 Mon Sep 17 00:00:00 2001 From: atarpara Date: Thu, 14 May 2026 13:27:34 +0530 Subject: [PATCH 2/2] Fix gas-diff CI --- .github/workflows/ci.yml | 16 +++++++++++----- .github/workflows/gas-diff-comment.yml | 17 +++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dcd6cbf34..a17182776 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -143,15 +143,21 @@ jobs: with: foundry-profile: "post_osaka" id: gas_diff + - name: Save gas diff output - if: steps.gas_diff.outputs.markdown + env: + MARKDOWN: ${{ steps.gas_diff.outputs.markdown }} + PR_NUMBER: ${{ github.event.number }} + run: | mkdir -p ./gas-diff - echo "${{ steps.gas_diff.outputs.markdown }}" > ./gas-diff/comment.md - echo "${{ github.event.number }}" > ./gas-diff/pr-number.txt + printf '%s' "$PR_NUMBER" > gas-diff/pr-number.txt + if [ -n "$MARKDOWN" ]; then + printf '%s' "$MARKDOWN" > gas-diff/comment.md + fi + - name: Upload gas diff artifact - if: steps.gas_diff.outputs.markdown - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7.0.1 with: name: gas-diff path: gas-diff/ diff --git a/.github/workflows/gas-diff-comment.yml b/.github/workflows/gas-diff-comment.yml index 98bd25074..8c81c4176 100644 --- a/.github/workflows/gas-diff-comment.yml +++ b/.github/workflows/gas-diff-comment.yml @@ -14,22 +14,27 @@ jobs: pull-requests: write steps: - name: Download gas diff artifact - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v8.0.1 with: name: gas-diff github-token: ${{ secrets.GITHUB_TOKEN }} run-id: ${{ github.event.workflow_run.id }} + - name: Read PR number id: pr - run: echo "number=$(cat pr-number.txt)" >> $GITHUB_OUTPUT + run: echo "number=$(cat pr-number.txt)" >> "$GITHUB_OUTPUT" + - name: Read gas diff id: gas_diff run: | - if [ -f comment.md ]; then - echo "markdown<> $GITHUB_OUTPUT - cat comment.md >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + if [ -f comment.md ] && [ -s comment.md ]; then + { + echo "markdown<<__GASDIFF_EOF__" + cat comment.md + echo "__GASDIFF_EOF__" + } >> "$GITHUB_OUTPUT" fi + - name: Add gas diff to sticky comment uses: marocchino/sticky-pull-request-comment@v2 with: