-
Notifications
You must be signed in to change notification settings - Fork 2
2025 08 11 int #397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
2025 08 11 int #397
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1046e2e
int
thedavidmeister 91e4373
ceil op
thedavidmeister 40777df
ceil
thedavidmeister 67f36e1
fix test
thedavidmeister 11059d8
fix tests
thedavidmeister 65e3d81
Update src/lib/op/math/LibOpCeil.sol
thedavidmeister 7833a5c
fix tests
thedavidmeister cd0f52b
Merge branch '2025-08-11-int' of github.com:rainlanguage/rain.interpr…
thedavidmeister 294bd0f
lint
thedavidmeister c541098
fix headroom
thedavidmeister 041a714
test case
thedavidmeister 6bc106a
test cases
thedavidmeister 8f45075
test cases
thedavidmeister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Submodule rain.interpreter.interface
updated
from 0c8a59 to 78a0e5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,47 @@ | ||
| // SPDX-License-Identifier: CAL | ||
| pragma solidity ^0.8.18; | ||
|
|
||
| // import {UD60x18, ceil} from "prb-math/UD60x18.sol"; | ||
| // import {OperandV2} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; | ||
| // import {Pointer} from "rain.solmem/lib/LibPointer.sol"; | ||
| // import {InterpreterState} from "../../state/LibInterpreterState.sol"; | ||
| // import {IntegrityCheckState} from "../../integrity/LibIntegrityCheck.sol"; | ||
| import {OperandV2, StackItem} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; | ||
| import {Pointer} from "rain.solmem/lib/LibPointer.sol"; | ||
| import {InterpreterState} from "../../state/LibInterpreterState.sol"; | ||
| import {IntegrityCheckState} from "../../integrity/LibIntegrityCheck.sol"; | ||
| import {Float, LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol"; | ||
|
|
||
| // /// @title LibOpCeil | ||
| // /// @notice Opcode for the ceiling of an decimal 18 fixed point number. | ||
| // library LibOpCeil { | ||
| // function integrity(IntegrityCheckState memory, Operand) internal pure returns (uint256, uint256) { | ||
| // // There must be one inputs and one output. | ||
| // return (1, 1); | ||
| // } | ||
| /// @title LibOpCeil | ||
| /// @notice Opcode for the ceiling of a decimal floating point number. | ||
| library LibOpCeil { | ||
| using LibDecimalFloat for Float; | ||
|
|
||
| // /// ceil | ||
| // /// 18 decimal fixed point ceiling of a number. | ||
| // function run(InterpreterState memory, Operand, Pointer stackTop) internal pure returns (Pointer) { | ||
| // uint256 a; | ||
| // assembly ("memory-safe") { | ||
| // a := mload(stackTop) | ||
| // } | ||
| // a = UD60x18.unwrap(ceil(UD60x18.wrap(a))); | ||
| function integrity(IntegrityCheckState memory, OperandV2) internal pure returns (uint256, uint256) { | ||
| // There must be one input and one output. | ||
| return (1, 1); | ||
| } | ||
|
|
||
| // assembly ("memory-safe") { | ||
| // mstore(stackTop, a) | ||
| // } | ||
| // return stackTop; | ||
| // } | ||
| /// ceil | ||
| /// decimal floating point ceiling of a number. | ||
| function run(InterpreterState memory, OperandV2, Pointer stackTop) internal pure returns (Pointer) { | ||
| Float a; | ||
| assembly ("memory-safe") { | ||
| a := mload(stackTop) | ||
| } | ||
| a = a.ceil(); | ||
|
|
||
| // /// Gas intensive reference implementation of ceil for testing. | ||
| // function referenceFn(InterpreterState memory, Operand, uint256[] memory inputs) | ||
| // internal | ||
| // pure | ||
| // returns (uint256[] memory) | ||
| // { | ||
| // uint256[] memory outputs = new uint256[](1); | ||
| // outputs[0] = UD60x18.unwrap(ceil(UD60x18.wrap(inputs[0]))); | ||
| // return outputs; | ||
| // } | ||
| // } | ||
| assembly ("memory-safe") { | ||
| mstore(stackTop, a) | ||
| } | ||
| return stackTop; | ||
| } | ||
|
|
||
| /// Gas intensive reference implementation of ceil for testing. | ||
| function referenceFn(InterpreterState memory, OperandV2, StackItem[] memory inputs) | ||
| internal | ||
| pure | ||
| returns (StackItem[] memory) | ||
| { | ||
| Float a = Float.wrap(StackItem.unwrap(inputs[0])); | ||
| a = a.ceil(); | ||
| StackItem[] memory outputs = new StackItem[](1); | ||
| outputs[0] = StackItem.wrap(Float.unwrap(a)); | ||
| return outputs; | ||
| } | ||
|
thedavidmeister marked this conversation as resolved.
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.