Skip to content

Commit

Permalink
fix remappings for float math
Browse files Browse the repository at this point in the history
  • Loading branch information
thedavidmeister committed Sep 12, 2024
1 parent f391e15 commit e595b15
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 15 deletions.
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ remappings = [
"rain.sol.codegen/=lib/rain.sol.codegen/src/",
"rain.solmem/=lib/rain.interpreter.interface/lib/rain.solmem/src/",
"openzeppelin-contracts/=lib/rain.interpreter.interface/lib/openzeppelin-contracts/",
"rain.math.float/=lib/rain.math.float/src/",
]

[fuzz]
Expand Down
2 changes: 1 addition & 1 deletion src/concrete/extern/RainterpreterReferenceExternNPE2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
INTEGRITY_FUNCTION_POINTERS,
OPCODE_FUNCTION_POINTERS
} from "../../generated/RainterpreterReferenceExternNPE2.pointers.sol";
import {LibDecimalFloat} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @dev The number of subparser functions available to the parser. This is NOT
/// 1:1 with the number of opcodes provided by the extern component of this
Expand Down
2 changes: 1 addition & 1 deletion src/lib/extern/reference/op/LibExternOpIntIncNPE2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.25;
import {Operand} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol";
import {LibSubParse} from "../../../parse/LibSubParse.sol";
import {IInterpreterExternV3} from "rain.interpreter.interface/interface/IInterpreterExternV3.sol";
import {LibDecimalFloat} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @dev Opcode index of the extern increment opcode. Needs to be manually kept
/// in sync with the extern opcode function pointers. Definitely write tests for
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parse/LibParseOperand.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {CMASK_OPERAND_END, CMASK_WHITESPACE, CMASK_OPERAND_START} from "./LibPar
import {ParseState, OPERAND_VALUES_LENGTH, FSM_YANG_MASK} from "./LibParseState.sol";
import {LibParseError} from "./LibParseError.sol";
import {LibParseInterstitial} from "./LibParseInterstitial.sol";
import {LibDecimalFloat} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

library LibParseOperand {
using LibParseError for ParseState;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/parse/literal/LibParseLiteralDecimal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from "../LibParseCMask.sol";
import {LibParseError} from "../LibParseError.sol";
import {LibParse} from "../LibParse.sol";
import {LibDecimalFloatImplementation, LibDecimalFloat} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {LibDecimalFloatImplementation, LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @dev The default is 18 decimal places for a fractional number.
uint256 constant DECIMAL_SCALE = 18;
Expand Down
2 changes: 1 addition & 1 deletion test/src/concrete/RainterpreterNPE2.stateOverlay.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {RainterpreterExpressionDeployerNPE2DeploymentTest} from
import {FullyQualifiedNamespace, StateNamespace} from "rain.interpreter.interface/interface/IInterpreterStoreV2.sol";
import {EvalV4, SourceIndexV2} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol";
import {LibNamespace} from "rain.interpreter.interface/lib/ns/LibNamespace.sol";
import {LibDecimalFloat} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

contract RainterpreterNPE2StateOverlayTest is RainterpreterExpressionDeployerNPE2DeploymentTest {
/// Show that state overlay can prewarm a get.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {LibExtern} from "src/lib/extern/LibExtern.sol";
import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol";
import {OPCODE_EXTERN} from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol";
import {ExternDispatchConstantsHeightOverflow} from "src/error/ErrSubParse.sol";
import {LibDecimalFloat} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";
import {CURRENT_COMPATIBILITY} from "src/lib/parse/LibSubParse.sol";

contract RainterpreterReferenceExternNPE2IntIncTest is OpTest {
Expand Down
2 changes: 1 addition & 1 deletion test/src/lib/op/00/LibOpConstantNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {IInterpreterStoreV2} from "rain.interpreter.interface/interface/IInterpr
import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV3.sol";
import {LibOperand} from "test/lib/operand/LibOperand.sol";
import {BadOpOutputsLength} from "src/error/ErrIntegrity.sol";
import {LibDecimalFloat} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @title LibOpConstantNPTest
/// @notice Test the runtime and integrity time logic of LibOpConstantNP.
Expand Down
8 changes: 8 additions & 0 deletions test/src/lib/op/00/LibOpContextNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ contract LibOpContextNPTest is OpTest {

/// Directly test the runtime logic of LibOpContextNP. This tests that the
/// values in the context matrix can be pushed to the stack via. the operand.
/// forge-config: default.fuzz.runs = 100
function testOpContextNPRun(uint256[][] memory context, uint256 i, uint256 j) external view {
InterpreterStateNP memory state = opTestDefaultInterpreterState();
state.context = context;
Expand All @@ -52,6 +53,7 @@ contract LibOpContextNPTest is OpTest {

/// Directly test the reference logic of LibOpContextNP. This tests that the
/// runtime logic will revert if the indexes are OOB. Tests that i is OOB.
/// forge-config: default.fuzz.runs = 100
function testOpContextNPRunOOBi(uint256[][] memory context, uint256 i, uint256 j) external {
InterpreterStateNP memory state = opTestDefaultInterpreterState();
state.context = context;
Expand All @@ -68,6 +70,7 @@ contract LibOpContextNPTest is OpTest {

/// Directly test the reference logic of LibOpContextNP. This tests that the
/// runtime logic will revert if the indexes are OOB. Tests that j is OOB.
/// forge-config: default.fuzz.runs = 100
function testOpContextNPRunOOBj(uint256[][] memory context, uint256 i, uint256 j) external {
InterpreterStateNP memory state = opTestDefaultInterpreterState();
state.context = context;
Expand All @@ -85,6 +88,7 @@ contract LibOpContextNPTest is OpTest {
}

/// Test the eval of context opcode parsed from a string. This tests 0 0.
/// forge-config: default.fuzz.runs = 100
function testOpContextNPEval00(uint256[][] memory context) external view {
vm.assume(context.length > 0);
vm.assume(context[0].length > 0);
Expand All @@ -108,6 +112,7 @@ contract LibOpContextNPTest is OpTest {
}

/// Test the eval of context opcode parsed from a string. This tests 0 1.
/// forge-config: default.fuzz.runs = 100
function testOpContextNPEval01(uint256[][] memory context) external view {
vm.assume(context.length > 0);
vm.assume(context[0].length > 1);
Expand All @@ -130,6 +135,7 @@ contract LibOpContextNPTest is OpTest {
}

/// Test the eval of context opcode parsed from a string. This tests 1 0.
/// forge-config: default.fuzz.runs = 100
function testOpContextNPEval10(uint256[][] memory context) external view {
vm.assume(context.length > 1);
vm.assume(context[1].length > 0);
Expand All @@ -153,6 +159,7 @@ contract LibOpContextNPTest is OpTest {
}

/// Test the eval of context opcode parsed from a string. This tests 1 1.
/// forge-config: default.fuzz.runs = 100
function testOpContextNPEval11(uint256[][] memory context) external view {
vm.assume(context.length > 1);
vm.assume(context[1].length > 1);
Expand All @@ -176,6 +183,7 @@ contract LibOpContextNPTest is OpTest {
}

/// Test the eval of context opcode parsed from a string. This tests OOB i.
/// forge-config: default.fuzz.runs = 100
function testOpContextNPEvalOOBi(uint256[] memory context0) external {
uint256[][] memory context = new uint256[][](1);
context[0] = context0;
Expand Down
2 changes: 1 addition & 1 deletion test/src/lib/op/00/LibOpExternNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import {IERC165} from "openzeppelin-contracts/contracts/utils/introspection/IERC165.sol";
import {LibOperand} from "test/lib/operand/LibOperand.sol";
import {LibUint256Array} from "rain.solmem/lib/LibUint256Array.sol";
import {LibDecimalFloat} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @title LibOpExternNPTest
/// @notice Test the runtime and integrity time logic of LibOpExternNP.
Expand Down
2 changes: 1 addition & 1 deletion test/src/lib/op/00/LibOpStackNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {OpTest, PRE, POST} from "test/abstract/OpTest.sol";
import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV3.sol";
import {LibOperand} from "test/lib/operand/LibOperand.sol";
import {BadOpOutputsLength} from "src/error/ErrIntegrity.sol";
import {LibDecimalFloat} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @title LibOpStackNPTest
/// @notice Test the runtime and integrity time logic of LibOpStackNP.
Expand Down
2 changes: 1 addition & 1 deletion test/src/lib/op/call/LibOpCallNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {LibBytecode, SourceIndexOutOfBounds} from "rain.interpreter.interface/li
import {BadOpInputsLength} from "src/lib/integrity/LibIntegrityCheckNP.sol";
import {STACK_TRACER} from "src/lib/state/LibInterpreterStateNP.sol";
import {LibOperand} from "test/lib/operand/LibOperand.sol";
import {LibDecimalFloat} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @title LibOpCallNPTest
/// @notice Test the LibOpCallNP library that includes the "call" word.
Expand Down
2 changes: 1 addition & 1 deletion test/src/lib/op/crypto/LibOpHashNP.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreter
import {LibIntegrityCheckNP, IntegrityCheckStateNP} from "src/lib/integrity/LibIntegrityCheckNP.sol";
import {InterpreterStateNP, LibInterpreterStateNP} from "src/lib/state/LibInterpreterStateNP.sol";
import {LibOperand} from "test/lib/operand/LibOperand.sol";
import {LibDecimalFloat} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @title LibOpHashNPTest
/// @notice Test the runtime and integrity time logic of LibOpHashNP.
Expand Down
2 changes: 1 addition & 1 deletion test/src/lib/parse/LibParse.literalIntegerDecimal.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {DecimalLiteralOverflow} from "src/lib/parse/literal/LibParseLiteral.sol"
import {LibParse, UnexpectedRHSChar, UnexpectedRightParen} from "src/lib/parse/LibParse.sol";
import {LibBytecode} from "rain.interpreter.interface/lib/bytecode/LibBytecode.sol";
import {ParseState} from "src/lib/parse/LibParseState.sol";
import {LibDecimalFloat} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @title LibParseLiteralIntegerDecimalTest
/// Tests parsing integer literal decimal values.
Expand Down
2 changes: 1 addition & 1 deletion test/src/lib/parse/LibParse.namedLHS.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {Operand, LibParseOperand} from "src/lib/parse/LibParseOperand.sol";
import {LibConvert} from "rain.lib.typecast/LibConvert.sol";
import {LibAllStandardOpsNP} from "src/lib/op/LibAllStandardOpsNP.sol";
import {LibGenParseMeta} from "rain.sol.codegen/lib/LibGenParseMeta.sol";
import {LibDecimalFloat} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol";

/// @title LibParseNamedLHSTest
contract LibParseNamedLHSTest is Test {
Expand Down
4 changes: 2 additions & 2 deletions test/src/lib/parse/LibParseOperand.parseOperand.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {LibMetaFixture} from "test/lib/parse/LibMetaFixture.sol";
import {LibLiteralString} from "test/lib/literal/LibLiteralString.sol";
import {OperandValuesOverflow, UnclosedOperand} from "src/error/ErrParse.sol";
import {LibParseLiteral} from "src/lib/parse/literal/LibParseLiteral.sol";
import {LibDecimalFloat, LibDecimalFloatImplementation} from "rain.math.float/src/lib/LibDecimalFloat.sol";
import {SIGNED_NORMALIZED_MAX} from "rain.math.float/src/lib/implementation/LibDecimalFloatImplementation.sol";
import {LibDecimalFloat, LibDecimalFloatImplementation} from "rain.math.float/lib/LibDecimalFloat.sol";
import {SIGNED_NORMALIZED_MAX} from "rain.math.float/lib/implementation/LibDecimalFloatImplementation.sol";

contract LibParseOperandParseOperandTest is Test {
using LibBytes for bytes;
Expand Down

0 comments on commit e595b15

Please sign in to comment.