From 348e7d37eb75c954b6e23bd07a7d0309b9b40819 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Sun, 26 Jan 2025 22:54:12 +0400 Subject: [PATCH] wip --- .gas-snapshot | 8 ++--- flake.nix | 2 +- foundry.toml | 2 +- lib/rain.interpreter.interface | 2 +- script/BuildPointers.sol | 23 ++++++------- script/Deploy.sol | 16 ++++------ ...ol => RainterpreterExpressionDeployer.sol} | 16 +++++----- src/concrete/RainterpreterStore.sol | 6 ++-- src/error/ErrDeploy.sol | 2 +- ...nterpreterExpressionDeployer.pointers.sol} | 0 .../ExpressionDeployerNPConstants.sol | 2 +- .../state/LibInterpreterStateDataContract.sol | 4 +-- test/abstract/OpTest.sol | 32 +++++++++---------- ...reterExpressionDeployerDeploymentTest.sol} | 20 ++++++------ ...c165.t.sol => Rainterpreter.ierc165.t.sol} | 0 ...ers.t.sol => Rainterpreter.pointers.t.sol} | 0 ...t.sol => Rainterpreter.stateOverlay.t.sol} | 6 ++-- ...erpreterNPE2.t.sol => Rainterpreter.t.sol} | 0 ...preterExpressionDeployer.deployCheck.t.sol | 26 +++++++++++++++ ...ExpressionDeployer.describedByMetaV1.t.sol | 25 +++++++++++++++ ...terpreterExpressionDeployer.ierc165.t.sol} | 18 +++++------ ...ainterpreterExpressionDeployer.meta.t.sol} | 14 ++++---- ...erExpressionDeployerNPE2.deployCheck.t.sol | 28 ---------------- ...essionDeployerNPE2.describedByMetaV1.t.sol | 27 ---------------- .../RainterpreterReferenceExtern.intInc.t.sol | 4 +-- test/src/lib/op/evm/LibOpChainIdNP.t.sol | 2 +- 26 files changed, 134 insertions(+), 151 deletions(-) rename src/concrete/{RainterpreterExpressionDeployerNPE2.sol => RainterpreterExpressionDeployer.sol} (93%) rename src/generated/{RainterpreterExpressionDeployerNPE2.pointers.sol => RainterpreterExpressionDeployer.pointers.sol} (100%) rename test/abstract/{RainterpreterExpressionDeployerNPE2DeploymentTest.sol => RainterpreterExpressionDeployerDeploymentTest.sol} (85%) rename test/src/concrete/{RainterpreterNPE2.ierc165.t.sol => Rainterpreter.ierc165.t.sol} (100%) rename test/src/concrete/{RainterpreterNPE2.pointers.t.sol => Rainterpreter.pointers.t.sol} (100%) rename test/src/concrete/{RainterpreterNPE2.stateOverlay.t.sol => Rainterpreter.stateOverlay.t.sol} (94%) rename test/src/concrete/{RainterpreterNPE2.t.sol => Rainterpreter.t.sol} (100%) create mode 100644 test/src/concrete/RainterpreterExpressionDeployer.deployCheck.t.sol create mode 100644 test/src/concrete/RainterpreterExpressionDeployer.describedByMetaV1.t.sol rename test/src/concrete/{RainterpreterExpressionDeployerNPE2.ierc165.t.sol => RainterpreterExpressionDeployer.ierc165.t.sol} (68%) rename test/src/concrete/{RainterpreterExpressionDeployerNPE2.meta.t.sol => RainterpreterExpressionDeployer.meta.t.sol} (50%) delete mode 100644 test/src/concrete/RainterpreterExpressionDeployerNPE2.deployCheck.t.sol delete mode 100644 test/src/concrete/RainterpreterExpressionDeployerNPE2.describedByMetaV1.t.sol diff --git a/.gas-snapshot b/.gas-snapshot index fc84d4fc0..975b64f42 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -535,10 +535,10 @@ LibParseUnexpectedRightParenTest:testParseUnexpectedRightParen() (gas: 41612) LibParseUnexpectedRightParenTest:testParseUnexpectedRightParenNested() (gas: 47269) LibSubParseSubParserExternTest:testLibSubParseSubParserExtern(address,uint8,uint8,uint8,uint16,uint8) (runs: 2049, μ: 13169, ~: 13112) LibSubParseSubParserExternTest:testLibSubParseSubParserExternConstantsHeightOverflow(address,uint256,uint8,uint8,uint16,uint8) (runs: 2049, μ: 7949, ~: 7689) -RainterpreterExpressionDeployerNPE2DeployCheckTest:testRainterpreterExpressionDeployerDeployNoEIP1820() (gas: 7050191) -RainterpreterExpressionDeployerNPE2DescribedByMetaV1Test:testRainterpreterExpressionDeployerNPE2DescribedByMetaV1Happy() (gas: 7057837) -RainterpreterExpressionDeployerNPE2IERC165Test:testRainterpreterExpressionDeployerNPE2IERC165(bytes4) (runs: 2049, μ: 7057632, ~: 7057632) -RainterpreterExpressionDeployerNPE2MetaTest:testRainterpreterExpressionDeployerNPE2ExpectedConstructionMetaHash() (gas: 6178) +RainterpreterExpressionDeployerDeployCheckTest:testRainterpreterExpressionDeployerDeployNoEIP1820() (gas: 7050191) +RainterpreterExpressionDeployerDescribedByMetaV1Test:testRainterpreterExpressionDeployerDescribedByMetaV1Happy() (gas: 7057837) +RainterpreterExpressionDeployerIERC165Test:testRainterpreterExpressionDeployerIERC165(bytes4) (runs: 2049, μ: 7057632, ~: 7057632) +RainterpreterExpressionDeployerMetaTest:testRainterpreterExpressionDeployerExpectedConstructionMetaHash() (gas: 6178) RainterpreterIERC165Test:testRainterpreterIERC165(bytes4) (runs: 2049, μ: 1516943, ~: 1516943) RainterpreterPointersTest:testOpcodeFunctionPointers() (gas: 1517849) RainterpreterStateOverlayTest:testStateOverlayGet() (gas: 52978) diff --git a/flake.nix b/flake.nix index 73acbc135..299673365 100644 --- a/flake.nix +++ b/flake.nix @@ -30,7 +30,7 @@ -t cbor \ -e deflate \ -l none \ - -o meta/RainterpreterExpressionDeployerNPE2.rain.meta \ + -o meta/RainterpreterExpressionDeployer.rain.meta \ ; rain meta build \ diff --git a/foundry.toml b/foundry.toml index aafc599c6..8196e9193 100644 --- a/foundry.toml +++ b/foundry.toml @@ -27,7 +27,7 @@ fs_permissions = [ { access = "write", path = "./deployments/latest/RainterpreterParserNPE2" }, { access = "write", path = "./deployments/latest/RainterpreterStore" }, { access = "write", path = "./deployments/latest/Rainterpreter" }, - { access = "write", path = "./deployments/latest/RainterpreterExpressionDeployerNPE2" } + { access = "write", path = "./deployments/latest/RainterpreterExpressionDeployer" } ] remappings = [ diff --git a/lib/rain.interpreter.interface b/lib/rain.interpreter.interface index 3c7662f4f..a302fe20d 160000 --- a/lib/rain.interpreter.interface +++ b/lib/rain.interpreter.interface @@ -1 +1 @@ -Subproject commit 3c7662f4f249c5efd2d3112c195a2a81ada45b39 +Subproject commit a302fe20d192d00cc052df4db75a0156a224fe48 diff --git a/script/BuildPointers.sol b/script/BuildPointers.sol index 4ab216b11..f1f1564e0 100644 --- a/script/BuildPointers.sol +++ b/script/BuildPointers.sol @@ -6,9 +6,9 @@ import {Rainterpreter} from "src/concrete/Rainterpreter.sol"; import {RainterpreterStore} from "src/concrete/RainterpreterStore.sol"; import {RainterpreterParserNPE2, PARSE_META_BUILD_DEPTH} from "src/concrete/RainterpreterParserNPE2.sol"; import { - RainterpreterExpressionDeployerNPE2, - RainterpreterExpressionDeployerNPE2ConstructionConfigV2 -} from "src/concrete/RainterpreterExpressionDeployerNPE2.sol"; + RainterpreterExpressionDeployer, + RainterpreterExpressionDeployerConstructionConfigV2 +} from "src/concrete/RainterpreterExpressionDeployer.sol"; import { RainterpreterReferenceExtern, LibRainterpreterReferenceExtern, @@ -23,10 +23,7 @@ contract BuildPointers is Script { Rainterpreter interpreter = new Rainterpreter(); LibFs.buildFileForContract( - vm, - address(interpreter), - "Rainterpreter", - LibCodeGen.opcodeFunctionPointersConstantString(vm, interpreter) + vm, address(interpreter), "Rainterpreter", LibCodeGen.opcodeFunctionPointersConstantString(vm, interpreter) ); } @@ -51,18 +48,16 @@ contract BuildPointers is Script { ); } - function buildRainterpreterExpressionDeployerNPE2Pointers() internal { + function buildRainterpreterExpressionDeployerPointers() internal { Rainterpreter interpreter = new Rainterpreter(); RainterpreterStore store = new RainterpreterStore(); RainterpreterParserNPE2 parser = new RainterpreterParserNPE2(); - RainterpreterExpressionDeployerNPE2 deployer = new RainterpreterExpressionDeployerNPE2( - RainterpreterExpressionDeployerNPE2ConstructionConfigV2( - address(interpreter), address(store), address(parser) - ) + RainterpreterExpressionDeployer deployer = new RainterpreterExpressionDeployer( + RainterpreterExpressionDeployerConstructionConfigV2(address(interpreter), address(store), address(parser)) ); - string memory name = "RainterpreterExpressionDeployerNPE2"; + string memory name = "RainterpreterExpressionDeployer"; LibFs.buildFileForContract( vm, @@ -104,7 +99,7 @@ contract BuildPointers is Script { buildRainterpreterPointers(); buildRainterpreterStorePointers(); buildRainterpreterParserNPE2Pointers(); - buildRainterpreterExpressionDeployerNPE2Pointers(); + buildRainterpreterExpressionDeployerPointers(); buildRainterpreterReferenceExternPointers(); } } diff --git a/script/Deploy.sol b/script/Deploy.sol index 363da2a16..e1be1a4d2 100644 --- a/script/Deploy.sol +++ b/script/Deploy.sol @@ -6,9 +6,9 @@ import {RainterpreterStore} from "../src/concrete/RainterpreterStore.sol"; import {Rainterpreter} from "../src/concrete/Rainterpreter.sol"; import {RainterpreterParserNPE2} from "../src/concrete/RainterpreterParserNPE2.sol"; import { - RainterpreterExpressionDeployerNPE2, - RainterpreterExpressionDeployerNPE2ConstructionConfigV2 -} from "../src/concrete/RainterpreterExpressionDeployerNPE2.sol"; + RainterpreterExpressionDeployer, + RainterpreterExpressionDeployerConstructionConfigV2 +} from "../src/concrete/RainterpreterExpressionDeployer.sol"; import {IMetaBoardV1_2} from "rain.metadata/interface/unstable/IMetaBoardV1_2.sol"; import {LibDescribedByMeta} from "rain.metadata/lib/LibDescribedByMeta.sol"; @@ -18,7 +18,7 @@ import {LibDescribedByMeta} from "rain.metadata/lib/LibDescribedByMeta.sol"; contract Deploy is Script { function run() external { uint256 deployerPrivateKey = vm.envUint("DEPLOYMENT_KEY"); - bytes memory constructionMeta = vm.readFileBinary("meta/RainterpreterExpressionDeployerNPE2.rain.meta"); + bytes memory constructionMeta = vm.readFileBinary("meta/RainterpreterExpressionDeployer.rain.meta"); IMetaBoardV1_2 metaboard = IMetaBoardV1_2(vm.envAddress("DEPLOY_METABOARD_ADDRESS")); vm.startBroadcast(deployerPrivateKey); @@ -32,14 +32,12 @@ contract Deploy is Script { Rainterpreter interpreter = new Rainterpreter(); vm.writeFile("deployments/latest/Rainterpreter", vm.toString(address(interpreter))); - RainterpreterExpressionDeployerNPE2 deployer = new RainterpreterExpressionDeployerNPE2( - RainterpreterExpressionDeployerNPE2ConstructionConfigV2( - address(interpreter), address(store), address(parser) - ) + RainterpreterExpressionDeployer deployer = new RainterpreterExpressionDeployer( + RainterpreterExpressionDeployerConstructionConfigV2(address(interpreter), address(store), address(parser)) ); LibDescribedByMeta.emitForDescribedAddress(metaboard, deployer, constructionMeta); - vm.writeFile("deployments/latest/RainterpreterExpressionDeployerNPE2", vm.toString(address(deployer))); + vm.writeFile("deployments/latest/RainterpreterExpressionDeployer", vm.toString(address(deployer))); vm.stopBroadcast(); } diff --git a/src/concrete/RainterpreterExpressionDeployerNPE2.sol b/src/concrete/RainterpreterExpressionDeployer.sol similarity index 93% rename from src/concrete/RainterpreterExpressionDeployerNPE2.sol rename to src/concrete/RainterpreterExpressionDeployer.sol index 973b47d23..0e43bfc75 100644 --- a/src/concrete/RainterpreterExpressionDeployerNPE2.sol +++ b/src/concrete/RainterpreterExpressionDeployer.sol @@ -30,7 +30,7 @@ import {STORE_BYTECODE_HASH} from "./RainterpreterStore.sol"; import { INTEGRITY_FUNCTION_POINTERS, DESCRIBED_BY_META_HASH -} from "../generated/RainterpreterExpressionDeployerNPE2.pointers.sol"; +} from "../generated/RainterpreterExpressionDeployer.pointers.sol"; import {IIntegrityToolingV1} from "rain.sol.codegen/interface/IIntegrityToolingV1.sol"; import {IParserV1View} from "rain.interpreter.interface/interface/deprecated/IParserV1View.sol"; @@ -39,14 +39,14 @@ import {IParserV1View} from "rain.interpreter.interface/interface/deprecated/IPa /// known bytecode. /// @param store The `IInterpreterStoreV2`. MUST match known bytecode. /// @param parser The `IParserV1View`. MUST match known bytecode. -struct RainterpreterExpressionDeployerNPE2ConstructionConfigV2 { +struct RainterpreterExpressionDeployerConstructionConfigV2 { address interpreter; address store; address parser; } -/// @title RainterpreterExpressionDeployerNPE2 -contract RainterpreterExpressionDeployerNPE2 is +/// @title RainterpreterExpressionDeployer +contract RainterpreterExpressionDeployer is IDescribedByMetaV1, IParserV2, IParserPragmaV1, @@ -64,7 +64,7 @@ contract RainterpreterExpressionDeployerNPE2 is IInterpreterStoreV2 public immutable iStore; IParserV1View public immutable iParser; - constructor(RainterpreterExpressionDeployerNPE2ConstructionConfigV2 memory config) { + constructor(RainterpreterExpressionDeployerConstructionConfigV2 memory config) { // Set the immutables. IInterpreterV4 interpreter = IInterpreterV4(config.interpreter); IInterpreterStoreV2 store = IInterpreterStoreV2(config.store); @@ -110,9 +110,9 @@ contract RainterpreterExpressionDeployerNPE2 is /// @inheritdoc IParserV2 function parse2(bytes memory data) external view virtual override returns (bytes memory) { - (bytes memory bytecode, uint256[] memory constants) = iParser.parse(data); + (bytes memory bytecode, bytes32[] memory constants) = iParser.parse(data); - uint256 size = LibInterpreterStateDataContract.serializeSizeNP(bytecode, constants); + uint256 size = LibInterpreterStateDataContract.serializeSize(bytecode, constants); bytes memory serialized; Pointer cursor; assembly ("memory-safe") { @@ -121,7 +121,7 @@ contract RainterpreterExpressionDeployerNPE2 is mstore(serialized, size) cursor := add(serialized, 0x20) } - LibInterpreterStateDataContract.unsafeSerializeNP(cursor, bytecode, constants); + LibInterpreterStateDataContract.unsafeSerialize(cursor, bytecode, constants); bytes memory io = LibIntegrityCheckNP.integrityCheck2(INTEGRITY_FUNCTION_POINTERS, bytecode, constants); // Nothing is done with IO in IParserV2. diff --git a/src/concrete/RainterpreterStore.sol b/src/concrete/RainterpreterStore.sol index b52c9573d..f207ae1c1 100644 --- a/src/concrete/RainterpreterStore.sol +++ b/src/concrete/RainterpreterStore.sol @@ -28,13 +28,13 @@ contract RainterpreterStore is IInterpreterStoreV3, ERC165 { /// callers cannot attack each other /// 1. StateNamespace is caller-provided namespace so that expressions cannot /// attack each other - /// 2. `uint256` is expression-provided key - /// 3. `uint256` is expression-provided value + /// 2. `bytes32` is expression-provided key + /// 3. `bytes32` is expression-provided value /// /// tiers 0 and 1 are both embodied in the `FullyQualifiedNamespace`. // Slither doesn't like the leading underscore. //solhint-disable-next-line private-vars-leading-underscore - mapping(FullyQualifiedNamespace fullyQualifiedNamespace => mapping(uint256 key => uint256 value)) internal sStore; + mapping(FullyQualifiedNamespace fullyQualifiedNamespace => mapping(bytes32 key => bytes32 value)) internal sStore; /// @inheritdoc ERC165 function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { diff --git a/src/error/ErrDeploy.sol b/src/error/ErrDeploy.sol index ac2ed502a..34fa2d32d 100644 --- a/src/error/ErrDeploy.sol +++ b/src/error/ErrDeploy.sol @@ -11,7 +11,7 @@ contract ErrDeploy {} /// address upon construction. error UnexpectedPointers(bytes actualPointers); -/// Thrown when the `RainterpreterExpressionDeployerNPE2` is constructed with +/// Thrown when the `RainterpreterExpressionDeployer` is constructed with /// unknown interpreter bytecode. /// @param expectedBytecodeHash The bytecode hash that was expected at the /// interpreter address upon construction. diff --git a/src/generated/RainterpreterExpressionDeployerNPE2.pointers.sol b/src/generated/RainterpreterExpressionDeployer.pointers.sol similarity index 100% rename from src/generated/RainterpreterExpressionDeployerNPE2.pointers.sol rename to src/generated/RainterpreterExpressionDeployer.pointers.sol diff --git a/src/lib/constants/ExpressionDeployerNPConstants.sol b/src/lib/constants/ExpressionDeployerNPConstants.sol index a04788424..214640e34 100644 --- a/src/lib/constants/ExpressionDeployerNPConstants.sol +++ b/src/lib/constants/ExpressionDeployerNPConstants.sol @@ -1,4 +1,4 @@ // SPDX-License-Identifier: CAL pragma solidity ^0.8.18; -string constant EXPRESSION_DEPLOYER_NP_META_PATH = "meta/RainterpreterExpressionDeployerNPE2.rain.meta"; +string constant EXPRESSION_DEPLOYER_NP_META_PATH = "meta/RainterpreterExpressionDeployer.rain.meta"; diff --git a/src/lib/state/LibInterpreterStateDataContract.sol b/src/lib/state/LibInterpreterStateDataContract.sol index 4d2e87ea3..e0cbd672b 100644 --- a/src/lib/state/LibInterpreterStateDataContract.sol +++ b/src/lib/state/LibInterpreterStateDataContract.sol @@ -13,14 +13,14 @@ import {InterpreterState} from "./LibInterpreterState.sol"; library LibInterpreterStateDataContract { using LibBytes for bytes; - function serializeSizeNP(bytes memory bytecode, bytes32[] memory constants) internal pure returns (uint256 size) { + function serializeSize(bytes memory bytecode, bytes32[] memory constants) internal pure returns (uint256 size) { unchecked { // bytecode length + constants length * 0x20 + 0x40 for both the bytecode and constants length words. size = bytecode.length + constants.length * 0x20 + 0x40; } } - function unsafeSerializeNP(Pointer cursor, bytes memory bytecode, bytes32[] memory constants) internal pure { + function unsafeSerialize(Pointer cursor, bytes memory bytecode, bytes32[] memory constants) internal pure { unchecked { // Copy constants into place with length. assembly ("memory-safe") { diff --git a/test/abstract/OpTest.sol b/test/abstract/OpTest.sol index b3941ae74..95f02dc13 100644 --- a/test/abstract/OpTest.sol +++ b/test/abstract/OpTest.sol @@ -7,8 +7,7 @@ import {MemoryKV} from "rain.lib.memkv/lib/LibMemoryKV.sol"; import {LibUint256Array} from "rain.solmem/lib/LibUint256Array.sol"; import {LibPointer, Pointer} from "rain.solmem/lib/LibPointer.sol"; -import {RainterpreterExpressionDeployerNPE2DeploymentTest} from - "./RainterpreterExpressionDeployerNPE2DeploymentTest.sol"; +import {RainterpreterExpressionDeployerDeploymentTest} from "./RainterpreterExpressionDeployerDeploymentTest.sol"; import {LibInterpreterState, InterpreterState} from "../../src/lib/state/LibInterpreterState.sol"; import {IntegrityCheckState, LibIntegrityCheckNP} from "../../src/lib/integrity/LibIntegrityCheckNP.sol"; @@ -19,8 +18,9 @@ import { OperandV2, IInterpreterV4, SourceIndexV2, - IInterpreterStoreV2, - EvalV4 + IInterpreterStoreV3, + EvalV4, + StackItem } from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol"; import {FullyQualifiedNamespace, StateNamespace} from "rain.interpreter.interface/interface/IInterpreterStoreV2.sol"; import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV3.sol"; @@ -29,7 +29,7 @@ import {LibNamespace} from "rain.interpreter.interface/lib/ns/LibNamespace.sol"; uint256 constant PRE = uint256(keccak256(abi.encodePacked("pre"))); uint256 constant POST = uint256(keccak256(abi.encodePacked("post"))); -abstract contract OpTest is RainterpreterExpressionDeployerNPE2DeploymentTest { +abstract contract OpTest is RainterpreterExpressionDeployerDeploymentTest { using LibInterpreterState for InterpreterState; using LibUint256Array for uint256[]; using LibPointer for Pointer; @@ -62,20 +62,20 @@ abstract contract OpTest is RainterpreterExpressionDeployerNPE2DeploymentTest { } function opTestDefaultIngegrityCheckState() internal pure returns (IntegrityCheckState memory) { - return IntegrityCheckState(0, 0, 0, new uint256[](0), 0, ""); + return IntegrityCheckState(0, 0, 0, new bytes32[](0), 0, ""); } function opTestDefaultInterpreterState() internal view returns (InterpreterState memory) { return InterpreterState( new Pointer[](0), - new uint256[](0), + new bytes32[](0), 0, MemoryKV.wrap(0), // Treat ourselves as the sender as we eval internally to directly // test the opcode logic. LibNamespace.qualifyNamespace(StateNamespace.wrap(0), address(this)), - IInterpreterStoreV2(address(iStore)), - new uint256[][](0), + IInterpreterStoreV3(address(iStore)), + new bytes32[][](0), "", "" ); @@ -84,13 +84,13 @@ abstract contract OpTest is RainterpreterExpressionDeployerNPE2DeploymentTest { function opReferenceCheckIntegrity( function(IntegrityCheckState memory, OperandV2) view returns (uint256, uint256) integrityFn, OperandV2 operand, - uint256[] memory constants, + bytes32[] memory constants, uint256[] memory inputs ) internal view returns (uint256) { IntegrityCheckState memory integrityState = LibIntegrityCheckNP.newState("", 0, constants); (uint256 calcInputs, uint256 calcOutputs) = integrityFn(integrityState, operand); assertEq(calcInputs, inputs.length, "inputs length"); - assertEq(calcInputs, uint256((OperandV2.unwrap(operand) >> 0x10) & 0x0F), "operand inputs"); + assertEq(calcInputs, uint256((OperandV2.unwrap(operand) >> 0x10) & bytes32(uint256(0x0F))), "operand inputs"); assertEq(calcOutputs, uint256(OperandV2.unwrap(operand) >> 0x14), "operand outputs"); return calcOutputs; } @@ -190,19 +190,19 @@ abstract contract OpTest is RainterpreterExpressionDeployerNPE2DeploymentTest { function parseAndEval(bytes memory rainString, uint256[][] memory context) internal view - returns (uint256[] memory, uint256[] memory) + returns (StackItem[] memory, bytes32[] memory) { bytes memory bytecode = iDeployer.parse2(rainString); - (uint256[] memory stack, uint256[] memory kvs) = iInterpreter.eval4( + (StackItem[] memory stack, bytes32[] memory kvs) = iInterpreter.eval4( EvalV4({ store: iStore, namespace: LibNamespace.qualifyNamespace(StateNamespace.wrap(0), address(this)), bytecode: bytecode, sourceIndex: SourceIndexV2.wrap(0), context: context, - inputs: new uint256[](0), - stateOverlay: new uint256[](0) + inputs: new StackItem[](0), + stateOverlay: new bytes32[](0) }) ); return (stack, kvs); @@ -211,7 +211,7 @@ abstract contract OpTest is RainterpreterExpressionDeployerNPE2DeploymentTest { /// 90%+ of the time we don't need to pass a context. This overloads a /// simplified interface to parse and eval. function parseAndEval(bytes memory rainString) internal view returns (uint256[] memory, uint256[] memory) { - return parseAndEval(rainString, LibContext.build(new uint256[][](0), new SignedContextV1[](0))); + return parseAndEval(rainString, LibContext.build(new bytes32[][](0), new SignedContextV1[](0))); } function checkHappy(bytes memory rainString, uint256 expectedValue, string memory errString) internal view { diff --git a/test/abstract/RainterpreterExpressionDeployerNPE2DeploymentTest.sol b/test/abstract/RainterpreterExpressionDeployerDeploymentTest.sol similarity index 85% rename from test/abstract/RainterpreterExpressionDeployerNPE2DeploymentTest.sol rename to test/abstract/RainterpreterExpressionDeployerDeploymentTest.sol index 758ddb0fa..262381a0e 100644 --- a/test/abstract/RainterpreterExpressionDeployerNPE2DeploymentTest.sol +++ b/test/abstract/RainterpreterExpressionDeployerDeploymentTest.sol @@ -13,24 +13,22 @@ import { PARSE_META_BUILD_DEPTH, PARSER_BYTECODE_HASH } from "src/concrete/RainterpreterParserNPE2.sol"; -import { - Rainterpreter, OPCODE_FUNCTION_POINTERS, INTERPRETER_BYTECODE_HASH -} from "src/concrete/Rainterpreter.sol"; +import {Rainterpreter, OPCODE_FUNCTION_POINTERS, INTERPRETER_BYTECODE_HASH} from "src/concrete/Rainterpreter.sol"; import { DESCRIBED_BY_META_HASH, INTEGRITY_FUNCTION_POINTERS, - RainterpreterExpressionDeployerNPE2ConstructionConfigV2, - RainterpreterExpressionDeployerNPE2 -} from "../../src/concrete/RainterpreterExpressionDeployerNPE2.sol"; + RainterpreterExpressionDeployerConstructionConfigV2, + RainterpreterExpressionDeployer +} from "../../src/concrete/RainterpreterExpressionDeployer.sol"; import {LibAllStandardOpsNP} from "src/lib/op/LibAllStandardOpsNP.sol"; import {LibGenParseMeta} from "rain.sol.codegen/lib/LibGenParseMeta.sol"; /// @title RainterpreterExpressionDeployerNPD2DeploymentTest -/// Tests that the RainterpreterExpressionDeployerNPE2 meta is correct. Also +/// Tests that the RainterpreterExpressionDeployer meta is correct. Also /// tests basic functionality of the `IParserV1View` interface implementation. -abstract contract RainterpreterExpressionDeployerNPE2DeploymentTest is Test { +abstract contract RainterpreterExpressionDeployerDeploymentTest is Test { //solhint-disable-next-line private-vars-leading-underscore - RainterpreterExpressionDeployerNPE2 internal immutable iDeployer; + RainterpreterExpressionDeployer internal immutable iDeployer; //solhint-disable-next-line private-vars-leading-underscore Rainterpreter internal immutable iInterpreter; //solhint-disable-next-line private-vars-leading-underscore @@ -89,8 +87,8 @@ abstract contract RainterpreterExpressionDeployerNPE2DeploymentTest is Test { revert("unexpected parse meta"); } - iDeployer = new RainterpreterExpressionDeployerNPE2( - RainterpreterExpressionDeployerNPE2ConstructionConfigV2( + iDeployer = new RainterpreterExpressionDeployer( + RainterpreterExpressionDeployerConstructionConfigV2( address(iInterpreter), address(iStore), address(iParser) ) ); diff --git a/test/src/concrete/RainterpreterNPE2.ierc165.t.sol b/test/src/concrete/Rainterpreter.ierc165.t.sol similarity index 100% rename from test/src/concrete/RainterpreterNPE2.ierc165.t.sol rename to test/src/concrete/Rainterpreter.ierc165.t.sol diff --git a/test/src/concrete/RainterpreterNPE2.pointers.t.sol b/test/src/concrete/Rainterpreter.pointers.t.sol similarity index 100% rename from test/src/concrete/RainterpreterNPE2.pointers.t.sol rename to test/src/concrete/Rainterpreter.pointers.t.sol diff --git a/test/src/concrete/RainterpreterNPE2.stateOverlay.t.sol b/test/src/concrete/Rainterpreter.stateOverlay.t.sol similarity index 94% rename from test/src/concrete/RainterpreterNPE2.stateOverlay.t.sol rename to test/src/concrete/Rainterpreter.stateOverlay.t.sol index da2e791ff..6f425f1a6 100644 --- a/test/src/concrete/RainterpreterNPE2.stateOverlay.t.sol +++ b/test/src/concrete/Rainterpreter.stateOverlay.t.sol @@ -1,14 +1,14 @@ // SPDX-License-Identifier: CAL pragma solidity =0.8.25; -import {RainterpreterExpressionDeployerNPE2DeploymentTest} from - "test/abstract/RainterpreterExpressionDeployerNPE2DeploymentTest.sol"; +import {RainterpreterExpressionDeployerDeploymentTest} from + "test/abstract/RainterpreterExpressionDeployerDeploymentTest.sol"; 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, PackedFloat} from "rain.math.float/lib/LibDecimalFloat.sol"; -contract RainterpreterStateOverlayTest is RainterpreterExpressionDeployerNPE2DeploymentTest { +contract RainterpreterStateOverlayTest is RainterpreterExpressionDeployerDeploymentTest { /// Show that state overlay can prewarm a get. function testStateOverlayGet() external view { bytes memory bytecode = iDeployer.parse2("_: get(9);"); diff --git a/test/src/concrete/RainterpreterNPE2.t.sol b/test/src/concrete/Rainterpreter.t.sol similarity index 100% rename from test/src/concrete/RainterpreterNPE2.t.sol rename to test/src/concrete/Rainterpreter.t.sol diff --git a/test/src/concrete/RainterpreterExpressionDeployer.deployCheck.t.sol b/test/src/concrete/RainterpreterExpressionDeployer.deployCheck.t.sol new file mode 100644 index 000000000..7ea8f0d18 --- /dev/null +++ b/test/src/concrete/RainterpreterExpressionDeployer.deployCheck.t.sol @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: CAL +pragma solidity =0.8.25; + +import {Test} from "forge-std/Test.sol"; + +import { + RainterpreterExpressionDeployer, + RainterpreterExpressionDeployerConstructionConfigV2 +} from "src/concrete/RainterpreterExpressionDeployer.sol"; +import {RainterpreterStore} from "src/concrete/RainterpreterStore.sol"; +import {RainterpreterParserNPE2} from "src/concrete/RainterpreterParserNPE2.sol"; +import {Rainterpreter} from "src/concrete/Rainterpreter.sol"; + +/// @title RainterpreterExpressionDeployerDeployCheckTest +/// Test that the RainterpreterExpressionDeployer deploy check reverts if the +/// passed config does not match expectations. +contract RainterpreterExpressionDeployerDeployCheckTest is Test { + /// Test the deployer can deploy if everything is valid. + function testRainterpreterExpressionDeployerDeployNoEIP1820() external { + new RainterpreterExpressionDeployer( + RainterpreterExpressionDeployerConstructionConfigV2( + address(new Rainterpreter()), address(new RainterpreterStore()), address(new RainterpreterParserNPE2()) + ) + ); + } +} diff --git a/test/src/concrete/RainterpreterExpressionDeployer.describedByMetaV1.t.sol b/test/src/concrete/RainterpreterExpressionDeployer.describedByMetaV1.t.sol new file mode 100644 index 000000000..e40e35597 --- /dev/null +++ b/test/src/concrete/RainterpreterExpressionDeployer.describedByMetaV1.t.sol @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: CAL +pragma solidity =0.8.25; + +import {Test} from "forge-std/Test.sol"; +import { + RainterpreterExpressionDeployer, + RainterpreterExpressionDeployerConstructionConfigV2 +} from "src/concrete/RainterpreterExpressionDeployer.sol"; +import {Rainterpreter} from "src/concrete/Rainterpreter.sol"; +import {RainterpreterStore} from "src/concrete/RainterpreterStore.sol"; +import {RainterpreterParserNPE2} from "src/concrete/RainterpreterParserNPE2.sol"; +import {EXPRESSION_DEPLOYER_NP_META_PATH} from "src/lib/constants/ExpressionDeployerNPConstants.sol"; + +contract RainterpreterExpressionDeployerDescribedByMetaV1Test is Test { + function testRainterpreterExpressionDeployerDescribedByMetaV1Happy() external { + bytes memory describedByMeta = vm.readFileBinary(EXPRESSION_DEPLOYER_NP_META_PATH); + RainterpreterExpressionDeployer deployer = new RainterpreterExpressionDeployer( + RainterpreterExpressionDeployerConstructionConfigV2( + address(new Rainterpreter()), address(new RainterpreterStore()), address(new RainterpreterParserNPE2()) + ) + ); + + assertEq(keccak256(describedByMeta), deployer.describedByMetaV1()); + } +} diff --git a/test/src/concrete/RainterpreterExpressionDeployerNPE2.ierc165.t.sol b/test/src/concrete/RainterpreterExpressionDeployer.ierc165.t.sol similarity index 68% rename from test/src/concrete/RainterpreterExpressionDeployerNPE2.ierc165.t.sol rename to test/src/concrete/RainterpreterExpressionDeployer.ierc165.t.sol index 9dbc1c0a0..24cfbe3ab 100644 --- a/test/src/concrete/RainterpreterExpressionDeployerNPE2.ierc165.t.sol +++ b/test/src/concrete/RainterpreterExpressionDeployer.ierc165.t.sol @@ -5,9 +5,9 @@ import {Test} from "forge-std/Test.sol"; import {IERC165} from "openzeppelin-contracts/contracts/utils/introspection/IERC165.sol"; import { - RainterpreterExpressionDeployerNPE2, - RainterpreterExpressionDeployerNPE2ConstructionConfigV2 -} from "src/concrete/RainterpreterExpressionDeployerNPE2.sol"; + RainterpreterExpressionDeployer, + RainterpreterExpressionDeployerConstructionConfigV2 +} from "src/concrete/RainterpreterExpressionDeployer.sol"; import {IParserPragmaV1} from "rain.interpreter.interface/interface/IParserPragmaV1.sol"; import {IParserV2} from "rain.interpreter.interface/interface/IParserV2.sol"; import {IDescribedByMetaV1} from "rain.metadata/interface/IDescribedByMetaV1.sol"; @@ -15,19 +15,17 @@ import {Rainterpreter} from "src/concrete/Rainterpreter.sol"; import {RainterpreterParserNPE2} from "src/concrete/RainterpreterParserNPE2.sol"; import {RainterpreterStore} from "src/concrete/RainterpreterStore.sol"; -contract RainterpreterExpressionDeployerNPE2IERC165Test is Test { +contract RainterpreterExpressionDeployerIERC165Test is Test { /// Test that ERC165 is implemented for all interfaces. - function testRainterpreterExpressionDeployerNPE2IERC165(bytes4 badInterfaceId) external { + function testRainterpreterExpressionDeployerIERC165(bytes4 badInterfaceId) external { vm.assume(badInterfaceId != type(IERC165).interfaceId); vm.assume(badInterfaceId != type(IDescribedByMetaV1).interfaceId); vm.assume(badInterfaceId != type(IParserV2).interfaceId); vm.assume(badInterfaceId != type(IParserPragmaV1).interfaceId); - RainterpreterExpressionDeployerNPE2 deployer = new RainterpreterExpressionDeployerNPE2( - RainterpreterExpressionDeployerNPE2ConstructionConfigV2( - address(new Rainterpreter()), - address(new RainterpreterStore()), - address(new RainterpreterParserNPE2()) + RainterpreterExpressionDeployer deployer = new RainterpreterExpressionDeployer( + RainterpreterExpressionDeployerConstructionConfigV2( + address(new Rainterpreter()), address(new RainterpreterStore()), address(new RainterpreterParserNPE2()) ) ); assertTrue(deployer.supportsInterface(type(IERC165).interfaceId)); diff --git a/test/src/concrete/RainterpreterExpressionDeployerNPE2.meta.t.sol b/test/src/concrete/RainterpreterExpressionDeployer.meta.t.sol similarity index 50% rename from test/src/concrete/RainterpreterExpressionDeployerNPE2.meta.t.sol rename to test/src/concrete/RainterpreterExpressionDeployer.meta.t.sol index 08e29fb3a..17d832091 100644 --- a/test/src/concrete/RainterpreterExpressionDeployerNPE2.meta.t.sol +++ b/test/src/concrete/RainterpreterExpressionDeployer.meta.t.sol @@ -1,18 +1,18 @@ // SPDX-License-Identifier: CAL pragma solidity =0.8.25; -import {RainterpreterExpressionDeployerNPE2DeploymentTest} from - "test/abstract/RainterpreterExpressionDeployerNPE2DeploymentTest.sol"; -import {DESCRIBED_BY_META_HASH} from "src/concrete/RainterpreterExpressionDeployerNPE2.sol"; +import {RainterpreterExpressionDeployerDeploymentTest} from + "test/abstract/RainterpreterExpressionDeployerDeploymentTest.sol"; +import {DESCRIBED_BY_META_HASH} from "src/concrete/RainterpreterExpressionDeployer.sol"; -/// @title RainterpreterExpressionDeployerNPE2MetaTest -/// Tests that the RainterpreterExpressionDeployerNPE2 meta is correct. Also +/// @title RainterpreterExpressionDeployerMetaTest +/// Tests that the RainterpreterExpressionDeployer meta is correct. Also /// tests basic functionality of the `IParserV1View` interface implementation, except /// parsing which is tested more extensively elsewhere. -contract RainterpreterExpressionDeployerNPE2MetaTest is RainterpreterExpressionDeployerNPE2DeploymentTest { +contract RainterpreterExpressionDeployerMetaTest is RainterpreterExpressionDeployerDeploymentTest { /// Test that the expected construction meta hash can be read from the /// deployer. - function testRainterpreterExpressionDeployerNPE2ExpectedConstructionMetaHash() external view { + function testRainterpreterExpressionDeployerExpectedConstructionMetaHash() external view { bytes32 actualConstructionMetaHash = iDeployer.describedByMetaV1(); assertEq(actualConstructionMetaHash, DESCRIBED_BY_META_HASH); } diff --git a/test/src/concrete/RainterpreterExpressionDeployerNPE2.deployCheck.t.sol b/test/src/concrete/RainterpreterExpressionDeployerNPE2.deployCheck.t.sol deleted file mode 100644 index 464c3e300..000000000 --- a/test/src/concrete/RainterpreterExpressionDeployerNPE2.deployCheck.t.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: CAL -pragma solidity =0.8.25; - -import {Test} from "forge-std/Test.sol"; - -import { - RainterpreterExpressionDeployerNPE2, - RainterpreterExpressionDeployerNPE2ConstructionConfigV2 -} from "src/concrete/RainterpreterExpressionDeployerNPE2.sol"; -import {RainterpreterStore} from "src/concrete/RainterpreterStore.sol"; -import {RainterpreterParserNPE2} from "src/concrete/RainterpreterParserNPE2.sol"; -import {Rainterpreter} from "src/concrete/Rainterpreter.sol"; - -/// @title RainterpreterExpressionDeployerNPE2DeployCheckTest -/// Test that the RainterpreterExpressionDeployerNPE2 deploy check reverts if the -/// passed config does not match expectations. -contract RainterpreterExpressionDeployerNPE2DeployCheckTest is Test { - /// Test the deployer can deploy if everything is valid. - function testRainterpreterExpressionDeployerDeployNoEIP1820() external { - new RainterpreterExpressionDeployerNPE2( - RainterpreterExpressionDeployerNPE2ConstructionConfigV2( - address(new Rainterpreter()), - address(new RainterpreterStore()), - address(new RainterpreterParserNPE2()) - ) - ); - } -} diff --git a/test/src/concrete/RainterpreterExpressionDeployerNPE2.describedByMetaV1.t.sol b/test/src/concrete/RainterpreterExpressionDeployerNPE2.describedByMetaV1.t.sol deleted file mode 100644 index 88e06206f..000000000 --- a/test/src/concrete/RainterpreterExpressionDeployerNPE2.describedByMetaV1.t.sol +++ /dev/null @@ -1,27 +0,0 @@ -// SPDX-License-Identifier: CAL -pragma solidity =0.8.25; - -import {Test} from "forge-std/Test.sol"; -import { - RainterpreterExpressionDeployerNPE2, - RainterpreterExpressionDeployerNPE2ConstructionConfigV2 -} from "src/concrete/RainterpreterExpressionDeployerNPE2.sol"; -import {Rainterpreter} from "src/concrete/Rainterpreter.sol"; -import {RainterpreterStore} from "src/concrete/RainterpreterStore.sol"; -import {RainterpreterParserNPE2} from "src/concrete/RainterpreterParserNPE2.sol"; -import {EXPRESSION_DEPLOYER_NP_META_PATH} from "src/lib/constants/ExpressionDeployerNPConstants.sol"; - -contract RainterpreterExpressionDeployerNPE2DescribedByMetaV1Test is Test { - function testRainterpreterExpressionDeployerNPE2DescribedByMetaV1Happy() external { - bytes memory describedByMeta = vm.readFileBinary(EXPRESSION_DEPLOYER_NP_META_PATH); - RainterpreterExpressionDeployerNPE2 deployer = new RainterpreterExpressionDeployerNPE2( - RainterpreterExpressionDeployerNPE2ConstructionConfigV2( - address(new Rainterpreter()), - address(new RainterpreterStore()), - address(new RainterpreterParserNPE2()) - ) - ); - - assertEq(keccak256(describedByMeta), deployer.describedByMetaV1()); - } -} diff --git a/test/src/concrete/RainterpreterReferenceExtern.intInc.t.sol b/test/src/concrete/RainterpreterReferenceExtern.intInc.t.sol index e74cec22d..89974484a 100644 --- a/test/src/concrete/RainterpreterReferenceExtern.intInc.t.sol +++ b/test/src/concrete/RainterpreterReferenceExtern.intInc.t.sol @@ -70,9 +70,7 @@ contract RainterpreterReferenceExternIntIncTest is OpTest { /// Directly test the subparsing of the reference extern opcode. /// forge-config: default.fuzz.runs = 100 - function testRainterpreterReferenceExternIntIncSubParseKnownWord(uint16 constantsHeight, bytes1 ioByte) - external - { + function testRainterpreterReferenceExternIntIncSubParseKnownWord(uint16 constantsHeight, bytes1 ioByte) external { // Extern "only" supports up to constant height of 0xFF. constantsHeight = uint16(bound(constantsHeight, 0, 0xFF)); RainterpreterReferenceExtern subParser = new RainterpreterReferenceExtern(); diff --git a/test/src/lib/op/evm/LibOpChainIdNP.t.sol b/test/src/lib/op/evm/LibOpChainIdNP.t.sol index 24e6de964..0755e2f1d 100644 --- a/test/src/lib/op/evm/LibOpChainIdNP.t.sol +++ b/test/src/lib/op/evm/LibOpChainIdNP.t.sol @@ -14,7 +14,7 @@ pragma solidity =0.8.25; // // import {Rainterpreter} from "src/concrete/Rainterpreter.sol"; // // import {RainterpreterStore, FullyQualifiedNamespace} from "src/concrete/RainterpreterStore.sol"; -// // import {RainterpreterExpressionDeployerNPE2} from "src/concrete/RainterpreterExpressionDeployerNPE2.sol"; +// // import {RainterpreterExpressionDeployer} from "src/concrete/RainterpreterExpressionDeployer.sol"; // // import { // // Operand, IInterpreterV4, SourceIndexV2 // // } from "rain.interpreter.interface/interface/unstable/IInterpreterV4.sol";