From 07a92608638fba9637be8e045e33196b207066be Mon Sep 17 00:00:00 2001 From: re1ro Date: Tue, 23 Jun 2026 13:47:47 -0400 Subject: [PATCH] chore: remove dead _cachedChainId immutable in EIP712 The _cachedChainId immutable was written in the constructor but never read. This fork of OpenZeppelin's EIP712 hardcodes the domain chain id to CROSS_CHAIN_ID = 1 for cross-chain signature compatibility, and _domainSeparatorV4() only guards the cache on address(this). OZ's block.chainid == _cachedChainId half of the cache guard was dropped, orphaning the variable. Remove it and reword the stale comment. Behavior is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/lib/EIP712.sol | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib/EIP712.sol b/src/lib/EIP712.sol index 7216ab7..dbb501f 100644 --- a/src/lib/EIP712.sol +++ b/src/lib/EIP712.sol @@ -22,10 +22,10 @@ abstract contract EIP712 is IERC5267 { /// @dev Value of 1 enables signatures to work across all chains uint256 private constant CROSS_CHAIN_ID = 1; - // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to - // invalidate the cached domain separator if the chain id changes. + // Cache the domain separator as an immutable value, keyed only on `address(this)` so it can be invalidated if the + // contract address changes (e.g. via proxy). The chain id is intentionally NOT part of the cache key: the domain + // deliberately uses a constant chain id (CROSS_CHAIN_ID = 1) for cross-chain signature compatibility. bytes32 private immutable _cachedDomainSeparator; - uint256 private immutable _cachedChainId; address private immutable _cachedThis; bytes32 private immutable _hashedName; @@ -54,7 +54,6 @@ abstract contract EIP712 is IERC5267 { _hashedName = keccak256(bytes(name)); _hashedVersion = keccak256(bytes(version)); - _cachedChainId = CROSS_CHAIN_ID; _cachedDomainSeparator = _buildDomainSeparator(); _cachedThis = address(this); }