From ac6185e512ec924ff0df35bf6c68d9dc93422d77 Mon Sep 17 00:00:00 2001 From: thedarkjester Date: Tue, 22 Aug 2023 17:06:33 +0100 Subject: [PATCH] more audit cleanup --- contracts/ZkEvmV2.sol | 10 +++++----- contracts/messageService/l2/L2MessageService.sol | 1 - contracts/messageService/lib/Codec.sol | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/contracts/ZkEvmV2.sol b/contracts/ZkEvmV2.sol index fb60679..15fef61 100644 --- a/contracts/ZkEvmV2.sol +++ b/contracts/ZkEvmV2.sol @@ -156,13 +156,13 @@ contract ZkEvmV2 is IZkEvmV2, Initializable, AccessControlUpgradeable, L1Message uint256[] memory timestamps = new uint256[](_blocksData.length); bytes32[] memory blockHashes = new bytes32[](_blocksData.length); - bytes32[] memory hashOfRootHashes; + bytes32[] memory rootHashes; unchecked { - hashOfRootHashes = new bytes32[](_blocksData.length + 1); + rootHashes = new bytes32[](_blocksData.length + 1); } - hashOfRootHashes[0] = _parentStateRootHash; + rootHashes[0] = _parentStateRootHash; bytes32 hashOfTxHashes; bytes32 hashOfMessageHashes; @@ -193,7 +193,7 @@ contract ZkEvmV2 is IZkEvmV2, Initializable, AccessControlUpgradeable, L1Message timestamps[i] = blockInfo.l2BlockTimestamp; unchecked { - hashOfRootHashes[i + 1] = blockInfo.blockRootHash; + rootHashes[i + 1] = blockInfo.blockRootHash; } emit BlockFinalized(currentBlockNumberTemp, blockInfo.blockRootHash); @@ -217,7 +217,7 @@ contract ZkEvmV2 is IZkEvmV2, Initializable, AccessControlUpgradeable, L1Message keccak256(abi.encodePacked(blockHashes)), firstBlockNumber, keccak256(abi.encodePacked(timestamps)), - keccak256(abi.encodePacked(hashOfRootHashes)) + keccak256(abi.encodePacked(rootHashes)) ) ) ); diff --git a/contracts/messageService/l2/L2MessageService.sol b/contracts/messageService/l2/L2MessageService.sol index 4ac5357..f6be119 100644 --- a/contracts/messageService/l2/L2MessageService.sol +++ b/contracts/messageService/l2/L2MessageService.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.19; import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import { ReentrancyGuardUpgradeable } from "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; -import { CodecV2 } from "../lib/Codec.sol"; import { IMessageService } from "../../interfaces/IMessageService.sol"; import { IGenericErrors } from "../../interfaces/IGenericErrors.sol"; import { RateLimiter } from "../lib/RateLimiter.sol"; diff --git a/contracts/messageService/lib/Codec.sol b/contracts/messageService/lib/Codec.sol index 6e0d8fb..454910d 100644 --- a/contracts/messageService/lib/Codec.sol +++ b/contracts/messageService/lib/Codec.sol @@ -11,6 +11,7 @@ library CodecV2 { * @notice Decodes a collection of bytes32 (hashes) from the calldata of a transaction. * @dev Extracts and decodes skipping the function selector (selector is expected in the input). * @dev A check beforehand must be performed to confirm this is the correct type of transaction. + * @dev A memory manipulation strips out the function signature, do not reuse. * @param _calldataWithSelector The calldata for the transaction. * @return bytes32[] - array of message hashes. */