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
1,170 changes: 591 additions & 579 deletions .gas-snapshot

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/rain.interpreter.interface
4 changes: 2 additions & 2 deletions src/generated/Rainterpreter.pointers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
pragma solidity =0.8.25;

/// @dev Hash of the known bytecode.
bytes32 constant BYTECODE_HASH = bytes32(0xdd238e0260bb1f2da6c93cc8c68e5f35a2ac83feac46242e5310ae80bf9f37e2);
bytes32 constant BYTECODE_HASH = bytes32(0x3067cd3ea6ed3bd416a94f05994e24197fbea237f58ebb54c31c455c02c9c578);

/// @dev The function pointers known to the interpreter for dynamic dispatch.
/// By setting these as a constant they can be inlined into the interpreter
/// and loaded at eval time for very low gas (~100) due to the compiler
/// optimising it to a single `codecopy` to build the in memory bytes array.
bytes constant OPCODE_FUNCTION_POINTERS =
hex"08240856087a0a060acf0ae10af30b0c0b300b640b750b860c280c470d050db50e390f7b10ae0d0511a7125912fb137313841395139513a61411151c159b15b415c8162716401659169216bd16d616ef17161729178b17d91827187518c318d1191f196d199e19ac19ba19c81a161a471a951ac61b141b411b8f1c85";
hex"0831086308870a130adc0aee0b000b190b3d0b710b820b930c350c540d120dc20e460f8810bb0d1211b4126613081380139113a213a213b3141e152915a815c115d51634164d1666169f16ca16e316fc17231736179817e61834188218d018de192c197a19ab19b919c719d51a231a541a851ad31b041b351b831bb01bfe1cf4";
6 changes: 3 additions & 3 deletions src/generated/RainterpreterExpressionDeployer.pointers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
pragma solidity =0.8.25;

/// @dev Hash of the known bytecode.
bytes32 constant BYTECODE_HASH = bytes32(0xedc85dfac63f4681b2d5ffb348c7796f7a3fdbe6de22aab8244b0bade2783426);
bytes32 constant BYTECODE_HASH = bytes32(0xe31030f8cd9295c31787bc462f4a710eb6ffd3b3acc358eb126ef96540cd56b4);

/// @dev The hash of the meta that describes the contract.
bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0x71a0d06f6c91b15436b0558882e812cfeabb78c20dc1490287a2a0d59541ef4b);
bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xd80b1ab409ece8a0cc8b7cf98b80d67805b2cfdafeeee1797fdb999edd8ba1dd);

/// @dev The function pointers for the integrity check fns.
bytes constant INTEGRITY_FUNCTION_POINTERS =
hex"0ea80f260f8a1104110e110e11181121113c11e211e2123e12b612c3110e111812c3110e1118110e110e110e1118110411041104110412cd12f2130c110e110e12cd110e110e12c31118110e110e12c3110413161316131613161316111813161330110411181118111813161104131611041330110e13301118130c";
hex"0eb80f360f9a1114111e111e11281131114c11f211f2124e12c612d3111e112812d3111e1128111e111e111e1128111411141114111412dd1302131c111e111e12dd111e111e12d31128111e111e12d311141326132613261326132611281326134011141128112811281326111411141326111411141340111e13401128131c";
8 changes: 4 additions & 4 deletions src/generated/RainterpreterParser.pointers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
pragma solidity =0.8.25;

/// @dev Hash of the known bytecode.
bytes32 constant BYTECODE_HASH = bytes32(0xf5b705e7eaebf246c1a369b2dfc297bd3023ddedb809a4733e0966f3398e4332);
bytes32 constant BYTECODE_HASH = bytes32(0x81b9d86cfe33dbfd1bfc4f9fcbe240b785ffac59ee86533e175590c227f8538d);

/// @dev The parse meta that is used to lookup word definitions.
/// The structure of the parse meta is:
Expand All @@ -29,7 +29,7 @@ bytes32 constant BYTECODE_HASH = bytes32(0xf5b705e7eaebf246c1a369b2dfc297bd3023d
/// bit count of the previous bloom filter. If we reach the end of the bloom
/// filters then we have a miss.
bytes constant PARSE_META =
hex"027d32482901a416101c2a01b8024080020111206043108201222060060071004a8800000000000000000800200000000000000000000000000000000000000000000034ee31ff1e4c42622cd999cd146aa9391a378a701bca041513bfc04d2dd959ad31ac0034053824512b8fb9fe39530a92378e9cbd1096c4d004ea67600a2aa235194d56371c05a7650cd5a68e233f227012f1ac932480073416d4a5b3159bd3ec068483ae35f6dc5d27f0c0a632a6feff219677b933db58d401d4fa88030cae020885d59f368413023067b4531d4070aa1fc9b66f2540ab0f2a5a53d8115fb3680ff7e328293977d317686f5c3abd3f5f024641b928630c0709f14a300b1ec71b2fa3832322792a603b5d96b73d7b8cf22653f8d13c33bccc0d403ded0791b7eb002ddffc0e1abd702ece1fe238f61a8018beccb0204507bb";
hex"02192ac782060c081806c6c1900010012220200283045069400114680901208401260000000000000000000000000000000000000000001000000000000000000000202c49b09d200441910d1e98a7329c08461fd6ea18118eba9713065d3029ab10ec04ac72c00e7ff5a23fae0c8706fb9c253ec7bc2333acb2941b0b5fc712fec72836e7c86c18d295ed35d9a6c50063d58d34dd44c9261df07b3acb6609012ba09831d9776c0c6cbb422f6d6b2403ae6396082c4e962787daec2841d78a16172ab51a5b8f1d1c2d57c43cca85c615f871180f48502f25b9d38d0be7f2e71ef1ff4d19d140c23d1a1e3510abcc6405b702d7020f038b2a93067d220df2ef07ee624a214143471482e75b1d60aa350a3d21ff174c80cb30cc4a6a3b023c042ba9578e370cdb6909a046dc39d89c342ed4e3cf233bc325389b388724b25e682d7b09ff";

/// @dev The build depth of the parser meta.

Expand All @@ -39,11 +39,11 @@ uint8 constant PARSE_META_BUILD_DEPTH = 2;
/// These positional indexes all map to the same indexes looked up in the parse
/// meta.
bytes constant OPERAND_HANDLER_FUNCTION_POINTERS =
hex"1a8d1a8d1a8d1b621c791c791c791b621b621a8d1a8d1a8d1c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791c791a8d1c791c79";
hex"1a9d1a9d1a9d1b721c891c891c891b721b721a9d1a9d1a9d1c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891c891a9d1c891c89";

/// @dev Every two bytes is a function pointer for a literal parser.
/// Literal dispatches are determined by the first byte(s) of the literal
/// rather than a full word lookup, and are done with simple conditional
/// jumps as the possibilities are limited compared to the number of words we
/// have.
bytes constant LITERAL_PARSER_FUNCTION_POINTERS = hex"15d51807184a18e8";
bytes constant LITERAL_PARSER_FUNCTION_POINTERS = hex"15e51817185a18f8";
40 changes: 29 additions & 11 deletions src/lib/op/LibAllStandardOps.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ import {LibOpInv} from "./math/LibOpInv.sol";
// import {LibOpLn} from "./math/LibOpLn.sol";
// import {LibOpLog10} from "./math/LibOpLog10.sol";
import {LibOpMax} from "./math/LibOpMax.sol";
import {LibOpMaxValue} from "./math/LibOpMaxValue.sol";
import {LibOpMaxNegativeValue} from "./math/LibOpMaxNegativeValue.sol";
import {LibOpMaxPositiveValue} from "./math/LibOpMaxPositiveValue.sol";
import {LibOpMin} from "./math/LibOpMin.sol";
import {LibOpMinValue} from "./math/LibOpMinValue.sol";
import {LibOpMinNegativeValue} from "./math/LibOpMinNegativeValue.sol";
import {LibOpMinPositiveValue} from "./math/LibOpMinPositiveValue.sol";
import {LibOpMod} from "./math/LibOpMod.sol";
// import {LibOpLog2} from "./math/LibOpLog2.sol";
import {LibOpPow} from "./math/LibOpPow.sol";
Expand All @@ -110,7 +112,7 @@ import {LibParseLiteralHex} from "../parse/literal/LibParseLiteralHex.sol";
import {LibParseLiteralSubParseable} from "../parse/literal/LibParseLiteralSubParseable.sol";

/// @dev Number of ops currently provided by `AllStandardOps`.
uint256 constant ALL_STANDARD_OPS_LENGTH = 62;
uint256 constant ALL_STANDARD_OPS_LENGTH = 64;

/// @title LibAllStandardOps
/// @notice Every opcode available from the core repository laid out as a single
Expand Down Expand Up @@ -286,14 +288,22 @@ library LibAllStandardOps {
// AuthoringMetaV2("log10", "Base 10 logarithm log10(x). Errors if the number is zero."),
AuthoringMetaV2("max", "Finds the maximum number from all inputs."),
AuthoringMetaV2(
"max-value",
"max-negative-value",
"The maximum representable float value that is negative. This is the largest number that can be represented that is still less than zero."
),
AuthoringMetaV2(
"max-positive-value",
"The maximum representable float value. This is so large that it is effectively infinity. Almost all numbers that you could possibly subtract from it will be ignored as a rounding error."
),
AuthoringMetaV2("min", "Finds the minimum number from all inputs."),
AuthoringMetaV2(
"min-value",
"min-negative-value",
"The minimum representable float value. This is so small that it is effectively negative infinity. Almost all numbers that you could possibly add to it will be ignored as a rounding error."
),
AuthoringMetaV2(
"min-positive-value",
"The minimum positive representable float value. This is the smallest number that can be represented that is still greater than zero."
),
// AuthoringMetaV2("mod", "Modulos the first number by all other numbers. Errors if any divisor is zero."),
AuthoringMetaV2("mul", "Multiplies all numbers together."),
AuthoringMetaV2("power", "Raises the first number to the power of the second number."),
Expand Down Expand Up @@ -484,11 +494,15 @@ library LibAllStandardOps {
// LibParseOperand.handleOperandDisallowed,
// max
LibParseOperand.handleOperandDisallowed,
// max-value
// max-negative-value
LibParseOperand.handleOperandDisallowed,
// max-positive-value
LibParseOperand.handleOperandDisallowed,
// min
LibParseOperand.handleOperandDisallowed,
// min-value
// min-negative-value
LibParseOperand.handleOperandDisallowed,
// min-positive-value
LibParseOperand.handleOperandDisallowed,
// // mod
// LibParseOperand.handleOperandDisallowed,
Expand Down Expand Up @@ -601,9 +615,11 @@ library LibAllStandardOps {
// LibOpLog2.integrity,
// LibOpLog10.integrity,
LibOpMax.integrity,
LibOpMaxValue.integrity,
LibOpMaxNegativeValue.integrity,
LibOpMaxPositiveValue.integrity,
LibOpMin.integrity,
LibOpMinValue.integrity,
LibOpMinNegativeValue.integrity,
LibOpMinPositiveValue.integrity,
// LibOpMod.integrity,
LibOpMul.integrity,
LibOpPow.integrity,
Expand Down Expand Up @@ -710,9 +726,11 @@ library LibAllStandardOps {
// LibOpLog2.run,
// LibOpLog10.run,
LibOpMax.run,
LibOpMaxValue.run,
LibOpMaxNegativeValue.run,
LibOpMaxPositiveValue.run,
LibOpMin.run,
LibOpMinValue.run,
LibOpMinNegativeValue.run,
LibOpMinPositiveValue.run,
// LibOpMod.run,
LibOpMul.run,
LibOpPow.run,
Expand Down
37 changes: 37 additions & 0 deletions src/lib/op/math/LibOpMaxNegativeValue.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: CAL
pragma solidity ^0.8.18;

import {IntegrityCheckState} from "../../integrity/LibIntegrityCheck.sol";
import {OperandV2, StackItem} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol";
import {InterpreterState} from "../../state/LibInterpreterState.sol";
import {Pointer} from "rain.solmem/lib/LibPointer.sol";
import {Float, LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @title LibOpMaxNegativeValue
/// Exposes the maximum negative representable float value as a Rainlang opcode.
library LibOpMaxNegativeValue {
using LibDecimalFloat for Float;

function integrity(IntegrityCheckState memory, OperandV2) internal pure returns (uint256, uint256) {
return (0, 1);
}

function run(InterpreterState memory, OperandV2, Pointer stackTop) internal pure returns (Pointer) {
Float value = LibDecimalFloat.FLOAT_MAX_NEGATIVE_VALUE;
assembly ("memory-safe") {
stackTop := sub(stackTop, 0x20)
mstore(stackTop, value)
}
return stackTop;
}

function referenceFn(InterpreterState memory, OperandV2, StackItem[] memory)
internal
pure
returns (StackItem[] memory)
{
StackItem[] memory outputs = new StackItem[](1);
outputs[0] = StackItem.wrap(Float.unwrap(LibDecimalFloat.packLossless(-1, type(int32).min)));
return outputs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ import {InterpreterState} from "../../state/LibInterpreterState.sol";
import {Pointer} from "rain.solmem/lib/LibPointer.sol";
import {Float, LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @title LibOpMaxValue
/// @title LibOpMaxPositiveValue
/// Exposes the maximum representable float value as a Rainlang opcode.
library LibOpMaxValue {
library LibOpMaxPositiveValue {
using LibDecimalFloat for Float;

function integrity(IntegrityCheckState memory, OperandV2) internal pure returns (uint256, uint256) {
return (0, 1);
}

function run(InterpreterState memory, OperandV2, Pointer stackTop) internal pure returns (Pointer) {
Float value = LibDecimalFloat.FLOAT_MAX_VALUE;
Float value = LibDecimalFloat.FLOAT_MAX_POSITIVE_VALUE;
assembly ("memory-safe") {
stackTop := sub(stackTop, 0x20)
mstore(stackTop, value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {InterpreterState} from "../../state/LibInterpreterState.sol";
import {Pointer} from "rain.solmem/lib/LibPointer.sol";
import {Float, LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @title LibOpMinValue
/// @title LibOpMinNegativeValue
/// Exposes the minimum representable float value as a Rainlang opcode.
library LibOpMinValue {
library LibOpMinNegativeValue {
using LibDecimalFloat for Float;

function integrity(IntegrityCheckState memory, OperandV2) internal pure returns (uint256, uint256) {
Expand Down
37 changes: 37 additions & 0 deletions src/lib/op/math/LibOpMinPositiveValue.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: CAL
pragma solidity ^0.8.18;

import {IntegrityCheckState} from "../../integrity/LibIntegrityCheck.sol";
import {OperandV2, StackItem} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol";
import {InterpreterState} from "../../state/LibInterpreterState.sol";
import {Pointer} from "rain.solmem/lib/LibPointer.sol";
import {Float, LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @title LibOpMinPositiveValue
/// Exposes the minimum positive representable float value as a Rainlang opcode.
library LibOpMinPositiveValue {
using LibDecimalFloat for Float;

function integrity(IntegrityCheckState memory, OperandV2) internal pure returns (uint256, uint256) {
return (0, 1);
}

function run(InterpreterState memory, OperandV2, Pointer stackTop) internal pure returns (Pointer) {
Float value = LibDecimalFloat.FLOAT_MIN_POSITIVE_VALUE;
assembly ("memory-safe") {
stackTop := sub(stackTop, 0x20)
mstore(stackTop, value)
}
return stackTop;
}

function referenceFn(InterpreterState memory, OperandV2, StackItem[] memory)
internal
pure
returns (StackItem[] memory)
{
StackItem[] memory outputs = new StackItem[](1);
outputs[0] = StackItem.wrap(Float.unwrap(LibDecimalFloat.packLossless(1, type(int32).min)));
return outputs;
}
}
Loading
Loading