From ceb34fc5a291f15a9f35928fa6cc1ad166753b05 Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Thu, 14 May 2026 22:30:59 +0400 Subject: [PATCH] docs: decouple EVM-opcode reference comments from float internals The block-number / block-timestamp / chain-id opcodes' reference functions exercise `fromFixedDecimalLosslessPacked(x, 0)`. The previous comments described that call as a test of the float library's internal identity, mixing architectural concerns. Reword so the comments simply record the equivalence and point at the float library as the owner of the invariant. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/lib/op/evm/LibOpBlockNumber.sol | 9 ++++++--- src/lib/op/evm/LibOpBlockTimestamp.sol | 9 ++++++--- src/lib/op/evm/LibOpChainId.sol | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/lib/op/evm/LibOpBlockNumber.sol b/src/lib/op/evm/LibOpBlockNumber.sol index 2c348ae39..37ef1f477 100644 --- a/src/lib/op/evm/LibOpBlockNumber.sol +++ b/src/lib/op/evm/LibOpBlockNumber.sol @@ -32,9 +32,12 @@ library LibOpBlockNumber { } /// @notice Reference implementation of `block-number` for testing. - /// Uses the float conversion with exponent 0 to verify that - /// `fromFixedDecimalLosslessPacked(value, 0)` is identity, unlike `run()` - /// which stores the raw value directly as a gas optimization. + /// `run()` writes the raw EVM integer directly because + /// `fromFixedDecimalLosslessPacked(x, 0)` is bitwise-identical to + /// `bytes32(x)` for any `x` that fits in `int224` — an invariant + /// owned and tested by `LibDecimalFloat`. The reference path goes + /// through the float conversion so that fact is explicit at the + /// opcode boundary. /// @return The output values to push onto the stack. function referenceFn(InterpreterState memory, OperandV2, StackItem[] memory) internal diff --git a/src/lib/op/evm/LibOpBlockTimestamp.sol b/src/lib/op/evm/LibOpBlockTimestamp.sol index 6a0fdaf95..7d408c2bd 100644 --- a/src/lib/op/evm/LibOpBlockTimestamp.sol +++ b/src/lib/op/evm/LibOpBlockTimestamp.sol @@ -32,9 +32,12 @@ library LibOpBlockTimestamp { } /// @notice Reference implementation of `block-timestamp` for testing. - /// Uses the float conversion with exponent 0 to verify that - /// `fromFixedDecimalLosslessPacked(value, 0)` is identity, unlike `run()` - /// which stores the raw value directly as a gas optimization. + /// `run()` writes the raw EVM integer directly because + /// `fromFixedDecimalLosslessPacked(x, 0)` is bitwise-identical to + /// `bytes32(x)` for any `x` that fits in `int224` — an invariant + /// owned and tested by `LibDecimalFloat`. The reference path goes + /// through the float conversion so that fact is explicit at the + /// opcode boundary. /// @return The output values to push onto the stack. function referenceFn(InterpreterState memory, OperandV2, StackItem[] memory) internal diff --git a/src/lib/op/evm/LibOpChainId.sol b/src/lib/op/evm/LibOpChainId.sol index 3ca258c63..82d96ba76 100644 --- a/src/lib/op/evm/LibOpChainId.sol +++ b/src/lib/op/evm/LibOpChainId.sol @@ -32,9 +32,12 @@ library LibOpChainId { } /// @notice Reference implementation of `chain-id` for testing. - /// Uses the float conversion with exponent 0 to verify that - /// `fromFixedDecimalLosslessPacked(value, 0)` is identity, unlike `run()` - /// which stores the raw value directly as a gas optimization. + /// `run()` writes the raw EVM integer directly because + /// `fromFixedDecimalLosslessPacked(x, 0)` is bitwise-identical to + /// `bytes32(x)` for any `x` that fits in `int224` — an invariant + /// owned and tested by `LibDecimalFloat`. The reference path goes + /// through the float conversion so that fact is explicit at the + /// opcode boundary. /// @return The output values to push onto the stack. function referenceFn(InterpreterState memory, OperandV2, StackItem[] memory) internal