From 8e3904801b6897459c126442118902eb6b64a09b Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Fri, 9 Feb 2024 00:27:45 +0400 Subject: [PATCH] add magic number to error offset --- src/lib/parse/LibParseError.sol | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/parse/LibParseError.sol b/src/lib/parse/LibParseError.sol index 9a1e7e51..d2db90f5 100644 --- a/src/lib/parse/LibParseError.sol +++ b/src/lib/parse/LibParseError.sol @@ -3,11 +3,14 @@ pragma solidity ^0.8.18; import {ParseState} from "./LibParseState.sol"; +bytes32 constant MAGIC_NUMBER_RAIN_PARSE_ERROR_V1 = keccak256("rain.interpreter.error.parse.0") << 0x10; + library LibParseError { function parseErrorOffset(ParseState memory state, uint256 cursor) internal pure returns (uint256 offset) { bytes memory data = state.data; + bytes32 magicNumber = MAGIC_NUMBER_RAIN_PARSE_ERROR_V1; assembly ("memory-safe") { - offset := sub(cursor, add(data, 0x20)) + offset := or(magicNumber, sub(cursor, add(data, 0x20))) } } }