-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23d2915
commit 24f82fc
Showing
22 changed files
with
873 additions
and
877 deletions.
There are no files selected for viewing
This file contains 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
Submodule prb-math
deleted from
77fa88
This file contains 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 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,46 +1,46 @@ | ||
// SPDX-License-Identifier: CAL | ||
pragma solidity ^0.8.18; | ||
// // SPDX-License-Identifier: CAL | ||
// pragma solidity ^0.8.18; | ||
|
||
import {UD60x18, avg} from "prb-math/UD60x18.sol"; | ||
import {Operand} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; | ||
import {Pointer} from "rain.solmem/lib/LibPointer.sol"; | ||
import {InterpreterStateNP} from "../../state/LibInterpreterStateNP.sol"; | ||
import {IntegrityCheckStateNP} from "../../integrity/LibIntegrityCheckNP.sol"; | ||
// import {UD60x18, avg} from "prb-math/UD60x18.sol"; | ||
// import {Operand} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; | ||
// import {Pointer} from "rain.solmem/lib/LibPointer.sol"; | ||
// import {InterpreterStateNP} from "../../state/LibInterpreterStateNP.sol"; | ||
// import {IntegrityCheckStateNP} from "../../integrity/LibIntegrityCheckNP.sol"; | ||
|
||
/// @title LibOpAvg | ||
/// @notice Opcode for the average of two decimal 18 fixed point numbers. | ||
library LibOpAvg { | ||
function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) { | ||
// There must be two inputs and one output. | ||
return (2, 1); | ||
} | ||
// /// @title LibOpAvg | ||
// /// @notice Opcode for the average of two decimal 18 fixed point numbers. | ||
// library LibOpAvg { | ||
// function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) { | ||
// // There must be two inputs and one output. | ||
// return (2, 1); | ||
// } | ||
|
||
/// avg | ||
/// 18 decimal fixed point average of two numbers. | ||
function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) { | ||
uint256 a; | ||
uint256 b; | ||
assembly ("memory-safe") { | ||
a := mload(stackTop) | ||
stackTop := add(stackTop, 0x20) | ||
b := mload(stackTop) | ||
} | ||
a = UD60x18.unwrap(avg(UD60x18.wrap(a), UD60x18.wrap(b))); | ||
// /// avg | ||
// /// 18 decimal fixed point average of two numbers. | ||
// function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) { | ||
// uint256 a; | ||
// uint256 b; | ||
// assembly ("memory-safe") { | ||
// a := mload(stackTop) | ||
// stackTop := add(stackTop, 0x20) | ||
// b := mload(stackTop) | ||
// } | ||
// a = UD60x18.unwrap(avg(UD60x18.wrap(a), UD60x18.wrap(b))); | ||
|
||
assembly ("memory-safe") { | ||
mstore(stackTop, a) | ||
} | ||
return stackTop; | ||
} | ||
// assembly ("memory-safe") { | ||
// mstore(stackTop, a) | ||
// } | ||
// return stackTop; | ||
// } | ||
|
||
/// Gas intensive reference implementation of avg for testing. | ||
function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs) | ||
internal | ||
pure | ||
returns (uint256[] memory) | ||
{ | ||
uint256[] memory outputs = new uint256[](1); | ||
outputs[0] = UD60x18.unwrap(avg(UD60x18.wrap(inputs[0]), UD60x18.wrap(inputs[1]))); | ||
return outputs; | ||
} | ||
} | ||
// /// Gas intensive reference implementation of avg for testing. | ||
// function referenceFn(InterpreterStateNP memory, Operand, uint256[] memory inputs) | ||
// internal | ||
// pure | ||
// returns (uint256[] memory) | ||
// { | ||
// uint256[] memory outputs = new uint256[](1); | ||
// outputs[0] = UD60x18.unwrap(avg(UD60x18.wrap(inputs[0]), UD60x18.wrap(inputs[1]))); | ||
// return outputs; | ||
// } | ||
// } |
This file contains 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,43 @@ | ||
// SPDX-License-Identifier: CAL | ||
pragma solidity ^0.8.18; | ||
// // SPDX-License-Identifier: CAL | ||
// pragma solidity ^0.8.18; | ||
|
||
import {UD60x18, ceil} from "prb-math/UD60x18.sol"; | ||
import {Operand} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; | ||
import {Pointer} from "rain.solmem/lib/LibPointer.sol"; | ||
import {InterpreterStateNP} from "../../state/LibInterpreterStateNP.sol"; | ||
import {IntegrityCheckStateNP} from "../../integrity/LibIntegrityCheckNP.sol"; | ||
// import {UD60x18, ceil} from "prb-math/UD60x18.sol"; | ||
// import {Operand} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; | ||
// import {Pointer} from "rain.solmem/lib/LibPointer.sol"; | ||
// import {InterpreterStateNP} from "../../state/LibInterpreterStateNP.sol"; | ||
// import {IntegrityCheckStateNP} from "../../integrity/LibIntegrityCheckNP.sol"; | ||
|
||
/// @title LibOpCeil | ||
/// @notice Opcode for the ceiling of an decimal 18 fixed point number. | ||
library LibOpCeil { | ||
function integrity(IntegrityCheckStateNP 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 an decimal 18 fixed point number. | ||
// library LibOpCeil { | ||
// function integrity(IntegrityCheckStateNP memory, Operand) internal pure returns (uint256, uint256) { | ||
// // There must be one inputs and one output. | ||
// return (1, 1); | ||
// } | ||
|
||
/// ceil | ||
/// 18 decimal fixed point ceiling of a number. | ||
function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) { | ||
uint256 a; | ||
assembly ("memory-safe") { | ||
a := mload(stackTop) | ||
} | ||
a = UD60x18.unwrap(ceil(UD60x18.wrap(a))); | ||
// /// ceil | ||
// /// 18 decimal fixed point ceiling of a number. | ||
// function run(InterpreterStateNP memory, Operand, Pointer stackTop) internal pure returns (Pointer) { | ||
// uint256 a; | ||
// assembly ("memory-safe") { | ||
// a := mload(stackTop) | ||
// } | ||
// a = UD60x18.unwrap(ceil(UD60x18.wrap(a))); | ||
|
||
assembly ("memory-safe") { | ||
mstore(stackTop, a) | ||
} | ||
return stackTop; | ||
} | ||
// assembly ("memory-safe") { | ||
// mstore(stackTop, a) | ||
// } | ||
// return stackTop; | ||
// } | ||
|
||
/// Gas intensive reference implementation of ceil for testing. | ||
function referenceFn(InterpreterStateNP 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; | ||
} | ||
} | ||
// /// Gas intensive reference implementation of ceil for testing. | ||
// function referenceFn(InterpreterStateNP 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; | ||
// } | ||
// } |
Oops, something went wrong.