proof.length can be used instead ofheight in EcrecoverRatifier.isRatified
Summary
EcrecoverRatifier.isRatified decodes height from the ratifier data and folds it into the EIP-712 typehash. For every tree the protocol accepts under OfferTree(Offer[2]...[2] offerTree), so height is always equal to proof.length.
Detail
HashLib.offerTreeTypeHash only returns typehashes for Offer[2]^height balanced binary trees, so the height is the length of the proof.
Impact
Optimization
Code Snippet
(Signature memory sig, uint256 height, bytes32 root, bytes32[] memory proof) =
abi.decode(ratifierData, (Signature, uint256, bytes32, bytes32[]));
require(HashLib.isLeaf(root, HashLib.hashOffer(offer), proof), InvalidProof());
require(!isRootCanceled[offer.maker][root], RootCanceled());
bytes32 structHash = keccak256(abi.encode(HashLib.offerTreeTypeHash(height), root));Tool Used
Manual Review
Recommendation
Use proof.length instead of height.