Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/gas-diff-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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<<EOF" >> $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:
Expand Down
4 changes: 3 additions & 1 deletion src/utils/clz/FixedPointMathLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down