From e658c60ed32aa7dce6d19e71b4fcc990a85247d0 Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Thu, 26 Jun 2025 20:57:56 +0400 Subject: [PATCH 1/6] bump up rain.interpreter.interface --- lib/rain.interpreter.interface | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rain.interpreter.interface b/lib/rain.interpreter.interface index 9be375932..70d9fae47 160000 --- a/lib/rain.interpreter.interface +++ b/lib/rain.interpreter.interface @@ -1 +1 @@ -Subproject commit 9be375932095192a9c825e1cd24a6ebed6d979a9 +Subproject commit 70d9fae479072d0dad154ba203fd9b6c17d553b2 From ab409fdc21e598dd303357bbffae3a021b2df776 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Fri, 27 Jun 2025 17:58:43 +0400 Subject: [PATCH 2/6] fix tests --- src/generated/RainterpreterParser.pointers.sol | 6 +++--- src/generated/RainterpreterReferenceExtern.pointers.sol | 2 +- src/lib/parse/literal/LibParseLiteralDecimal.sol | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/generated/RainterpreterParser.pointers.sol b/src/generated/RainterpreterParser.pointers.sol index a6d3eb8a9..9efe1a552 100644 --- a/src/generated/RainterpreterParser.pointers.sol +++ b/src/generated/RainterpreterParser.pointers.sol @@ -10,7 +10,7 @@ pragma solidity =0.8.25; /// @dev Hash of the known bytecode. -bytes32 constant BYTECODE_HASH = bytes32(0x64d3b24310b8f7838754a2e0ea53adc927b408d2833e035f136d8f4b098062ee); +bytes32 constant BYTECODE_HASH = bytes32(0xc946075010fcd74db1bae56b019611755126bc2d81cbad430c717d8cdb3fe8ea); /// @dev The parse meta that is used to lookup word definitions. /// The structure of the parse meta is: @@ -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"1d281d281d281dfd1f141f141f141dfd1dfd1d281d281d281f141f141f141f141f141f141f141f141f141f141f141f141f141f14"; + hex"1d2a1d2a1d2a1dff1f161f161f161dff1dff1d2a1d2a1d2a1f161f161f161f161f161f161f161f161f161f161f161f161f161f16"; /// @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"17641a2c1a5d1b37"; +bytes constant LITERAL_PARSER_FUNCTION_POINTERS = hex"17641a2c1a6f1b49"; diff --git a/src/generated/RainterpreterReferenceExtern.pointers.sol b/src/generated/RainterpreterReferenceExtern.pointers.sol index b782bcc4e..7f1f3f044 100644 --- a/src/generated/RainterpreterReferenceExtern.pointers.sol +++ b/src/generated/RainterpreterReferenceExtern.pointers.sol @@ -10,7 +10,7 @@ pragma solidity =0.8.25; /// @dev Hash of the known bytecode. -bytes32 constant BYTECODE_HASH = bytes32(0x1fd4838aae3e51a69748bb83ba24ca1ebb19b455fca57703d4e064f7cd1f8cb4); +bytes32 constant BYTECODE_HASH = bytes32(0x7b5907d0b2f536b128609b225838c03faa69a5b27831862d6132b6e8a1a6c633); /// @dev The hash of the meta that describes the contract. bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xadf71693c6ecf3fd560904bc46973d1b6e651440d15366673f9b3984749e7c16); diff --git a/src/lib/parse/literal/LibParseLiteralDecimal.sol b/src/lib/parse/literal/LibParseLiteralDecimal.sol index a720947cc..173777dbe 100644 --- a/src/lib/parse/literal/LibParseLiteralDecimal.sol +++ b/src/lib/parse/literal/LibParseLiteralDecimal.sol @@ -5,6 +5,7 @@ pragma solidity ^0.8.18; import {ParseState} from "../LibParseState.sol"; import {LibParseError} from "../LibParseError.sol"; import {LibParseDecimalFloat, Float} from "rain.math.float/lib/parse/LibParseDecimalFloat.sol"; +import {LibDecimalFloat} from "rain.math.float/lib/LibDecimalFloat.sol"; library LibParseLiteralDecimal { using LibParseError for ParseState; @@ -14,8 +15,8 @@ library LibParseLiteralDecimal { pure returns (uint256, bytes32) { - (bytes4 errorSelector, uint256 cursor, Float float) = LibParseDecimalFloat.parseDecimalFloatPacked(start, end); + (bytes4 errorSelector, uint256 cursor, int256 signedCoefficient, int256 exponent) = LibParseDecimalFloat.parseDecimalFloatInline(start, end); state.handleErrorSelector(cursor, errorSelector); - return (cursor, Float.unwrap(float)); + return (cursor, Float.unwrap(LibDecimalFloat.packLossless(signedCoefficient, exponent))); } } From 7836df5f66158549cfe2ad914a0a9561bde66c2a Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Fri, 27 Jun 2025 18:11:24 +0400 Subject: [PATCH 3/6] fix formatting --- src/lib/parse/literal/LibParseLiteralDecimal.sol | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/parse/literal/LibParseLiteralDecimal.sol b/src/lib/parse/literal/LibParseLiteralDecimal.sol index 173777dbe..de32f2d51 100644 --- a/src/lib/parse/literal/LibParseLiteralDecimal.sol +++ b/src/lib/parse/literal/LibParseLiteralDecimal.sol @@ -15,7 +15,8 @@ library LibParseLiteralDecimal { pure returns (uint256, bytes32) { - (bytes4 errorSelector, uint256 cursor, int256 signedCoefficient, int256 exponent) = LibParseDecimalFloat.parseDecimalFloatInline(start, end); + (bytes4 errorSelector, uint256 cursor, int256 signedCoefficient, int256 exponent) = + LibParseDecimalFloat.parseDecimalFloatInline(start, end); state.handleErrorSelector(cursor, errorSelector); return (cursor, Float.unwrap(LibDecimalFloat.packLossless(signedCoefficient, exponent))); } From c7d1af1775975d6990a8dbb7c22e073446e94df7 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Mon, 30 Jun 2025 20:13:40 +0400 Subject: [PATCH 4/6] lower optimisations to match ob --- foundry.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/foundry.toml b/foundry.toml index 82c1439f0..0728935b5 100644 --- a/foundry.toml +++ b/foundry.toml @@ -17,7 +17,10 @@ evm_version = "paris" # These settings should be used for snapshots optimizer = true -optimizer_runs = 1000000 +# set to match rain.orderbook +# this is a bit low, was set to 1000000 previously but this caused deployment +# code size cap to be hit. +optimizer_runs = 9000 bytecode_hash = "none" cbor_metadata = false From 84646b65dd6173b2fc9dab0f2a4f7d7d0ae517f3 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Mon, 30 Jun 2025 20:21:36 +0400 Subject: [PATCH 5/6] rebuild pointers --- src/generated/Rainterpreter.pointers.sol | 4 ++-- .../RainterpreterExpressionDeployer.pointers.sol | 4 ++-- src/generated/RainterpreterParser.pointers.sol | 6 +++--- src/generated/RainterpreterReferenceExtern.pointers.sol | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/generated/Rainterpreter.pointers.sol b/src/generated/Rainterpreter.pointers.sol index aeb644e4b..b3f65383f 100644 --- a/src/generated/Rainterpreter.pointers.sol +++ b/src/generated/Rainterpreter.pointers.sol @@ -10,11 +10,11 @@ pragma solidity =0.8.25; /// @dev Hash of the known bytecode. -bytes32 constant BYTECODE_HASH = bytes32(0xefcfefcefb6fa663971d96cbfbaa11029a0f8c1943627e482242d6ce89513a85); +bytes32 constant BYTECODE_HASH = bytes32(0x7faf8cf6d8b3a928f0062e69c4e90827ded0d7c0710793da3e8013a478fa0d6f); /// @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"06fb074b078d09550a3c0a4e0a600a790abb0b0d0b1e0b2f0bd10c0e0cbd0d410d700d9f0d9f0dce0e5b0e740e880ed70f26100d"; + hex"06dd070f073308bf0988099a09ac09c509e90a1d0a2e0a3f0ae10b000baf0c330c440c550c550c660cf30d0c0d200d330d640e4b"; diff --git a/src/generated/RainterpreterExpressionDeployer.pointers.sol b/src/generated/RainterpreterExpressionDeployer.pointers.sol index 6859c7f72..cb4a51adf 100644 --- a/src/generated/RainterpreterExpressionDeployer.pointers.sol +++ b/src/generated/RainterpreterExpressionDeployer.pointers.sol @@ -10,11 +10,11 @@ pragma solidity =0.8.25; /// @dev Hash of the known bytecode. -bytes32 constant BYTECODE_HASH = bytes32(0x58e5063e0d51b94680c94ae84925fddc67196d9785ecc94febfbf2083743e7b6); +bytes32 constant BYTECODE_HASH = bytes32(0xd7bab49001d4f6a0a14d12ce980e2fc70e1209f83a32610c9b81d42d7a3f329a); /// @dev The hash of the meta that describes the contract. bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0x753e622d85a935a93bb6a40e985c0fc4532d6d824b94170d13aa78bae1564127); /// @dev The function pointers for the integrity check fns. bytes constant INTEGRITY_FUNCTION_POINTERS = - hex"0dc40e420ea61020102a102a1034103d105810fe10fe115a11d2102a1034102010201020102011df102a102a10201020103411df"; + hex"0d880e060e6a0fe40fee0fee0ff81001101c10c210c2111e11960fee0ff80fe40fe40fe40fe411a30fee0fee0fe40fe40ff811a3"; diff --git a/src/generated/RainterpreterParser.pointers.sol b/src/generated/RainterpreterParser.pointers.sol index 9efe1a552..2ea1801f7 100644 --- a/src/generated/RainterpreterParser.pointers.sol +++ b/src/generated/RainterpreterParser.pointers.sol @@ -10,7 +10,7 @@ pragma solidity =0.8.25; /// @dev Hash of the known bytecode. -bytes32 constant BYTECODE_HASH = bytes32(0xc946075010fcd74db1bae56b019611755126bc2d81cbad430c717d8cdb3fe8ea); +bytes32 constant BYTECODE_HASH = bytes32(0xdbb372dd8305b720e1b126663dde9d1afab61ac0b77adf279f1bd6815e155d5b); /// @dev The parse meta that is used to lookup word definitions. /// The structure of the parse meta is: @@ -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"1d2a1d2a1d2a1dff1f161f161f161dff1dff1d2a1d2a1d2a1f161f161f161f161f161f161f161f161f161f161f161f161f161f16"; + hex"196a196a196a1a3f1b561b561b561a3f1a3f196a196a196a1b561b561b561b561b561b561b561b561b561b561b561b561b561b56"; /// @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"17641a2c1a6f1b49"; +bytes constant LITERAL_PARSER_FUNCTION_POINTERS = hex"14b216e4172717c5"; diff --git a/src/generated/RainterpreterReferenceExtern.pointers.sol b/src/generated/RainterpreterReferenceExtern.pointers.sol index 7f1f3f044..2e1fa0aa9 100644 --- a/src/generated/RainterpreterReferenceExtern.pointers.sol +++ b/src/generated/RainterpreterReferenceExtern.pointers.sol @@ -10,7 +10,7 @@ pragma solidity =0.8.25; /// @dev Hash of the known bytecode. -bytes32 constant BYTECODE_HASH = bytes32(0x7b5907d0b2f536b128609b225838c03faa69a5b27831862d6132b6e8a1a6c633); +bytes32 constant BYTECODE_HASH = bytes32(0x168110fff91a799133a1d57d94ae612b831f264a5b1853d89eba5d5154ebc941); /// @dev The hash of the meta that describes the contract. bytes32 constant DESCRIBED_BY_META_HASH = bytes32(0xadf71693c6ecf3fd560904bc46973d1b6e651440d15366673f9b3984749e7c16); @@ -48,17 +48,17 @@ bytes constant SUB_PARSER_WORD_PARSERS = hex"075307750784079407a5"; /// @dev Every two bytes is a function pointer for an operand handler. /// These positional indexes all map to the same indexes looked up in the parse /// meta. -bytes constant OPERAND_HANDLER_FUNCTION_POINTERS = hex"0d4e0d930d4e0d4e0d4e"; +bytes constant OPERAND_HANDLER_FUNCTION_POINTERS = hex"0d300d750d300d300d30"; /// @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"0d1f"; +bytes constant LITERAL_PARSER_FUNCTION_POINTERS = hex"0d01"; /// @dev The function pointers for the integrity check fns. -bytes constant INTEGRITY_FUNCTION_POINTERS = hex"0bca"; +bytes constant INTEGRITY_FUNCTION_POINTERS = hex"0bac"; /// @dev The function pointers known to the interpreter for dynamic dispatch. /// By setting these as a constant they can be inlined into the interpreter From 8fca90cd1662ec3abcdc5a13d6f20aa2ba0abfb3 Mon Sep 17 00:00:00 2001 From: 0xgleb Date: Tue, 1 Jul 2025 14:24:55 +0400 Subject: [PATCH 6/6] fix aet version mismatch --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/dispair/src/lib.rs | 2 +- crates/parser/src/error.rs | 2 +- crates/parser/src/v2.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 04e93c9e1..9b7cd9ab3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -266,7 +266,7 @@ dependencies = [ [[package]] name = "alloy-ethers-typecast" version = "0.2.0" -source = "git+https://github.com/rainlanguage/alloy-ethers-typecast?rev=f7b5bfd0687f16c77dbfdd4905b2434793fa7885#f7b5bfd0687f16c77dbfdd4905b2434793fa7885" +source = "git+https://github.com/rainlanguage/alloy-ethers-typecast?rev=bcc3a04394aefe191fef4ae8e6e94381a419c99a#bcc3a04394aefe191fef4ae8e6e94381a419c99a" dependencies = [ "alloy", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index ac52a8d39..9f5b16820 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ tracing = "0.1.37" tracing-subscriber = "0.3.17" reqwest = { version = "0.11.17", features = ["json"] } once_cell = "1.17.1" -alloy-ethers-typecast = { git = "https://github.com/rainlanguage/alloy-ethers-typecast", rev = "f7b5bfd0687f16c77dbfdd4905b2434793fa7885" } +alloy-ethers-typecast = { git = "https://github.com/rainlanguage/alloy-ethers-typecast", rev = "bcc3a04394aefe191fef4ae8e6e94381a419c99a" } eyre = "0.6" rain-error-decoding = { git = "https://github.com/rainlanguage/rain.error", rev = "bf08b5ab305287fc49408a441d6375f35dc280db" } wasm-bindgen-utils = "0.0.10" diff --git a/crates/dispair/src/lib.rs b/crates/dispair/src/lib.rs index b128ab285..af2b49842 100644 --- a/crates/dispair/src/lib.rs +++ b/crates/dispair/src/lib.rs @@ -1,5 +1,5 @@ use alloy::primitives::*; -use alloy_ethers_typecast::transaction::{ +use alloy_ethers_typecast::{ ReadContractParametersBuilder, ReadContractParametersBuilderError, ReadableClient, ReadableClientError, }; diff --git a/crates/parser/src/error.rs b/crates/parser/src/error.rs index 42d1b9037..3ec0eba18 100644 --- a/crates/parser/src/error.rs +++ b/crates/parser/src/error.rs @@ -1,4 +1,4 @@ -use alloy_ethers_typecast::transaction::{ReadContractParametersBuilderError, ReadableClientError}; +use alloy_ethers_typecast::{ReadContractParametersBuilderError, ReadableClientError}; use thiserror::Error; #[derive(Error, Debug)] diff --git a/crates/parser/src/v2.rs b/crates/parser/src/v2.rs index bcc754c9b..8445de9ac 100644 --- a/crates/parser/src/v2.rs +++ b/crates/parser/src/v2.rs @@ -1,6 +1,6 @@ use crate::error::ParserError; use alloy::primitives::*; -use alloy_ethers_typecast::transaction::{ReadContractParametersBuilder, ReadableClient}; +use alloy_ethers_typecast::{ReadContractParametersBuilder, ReadableClient}; use rain_interpreter_bindings::IParserPragmaV1::*; use rain_interpreter_bindings::IParserV2::*; use rain_interpreter_dispair::DISPair;