diff --git a/packages/protocol/contracts/thirdparty/LibBytesUtils.sol b/packages/protocol/contracts/thirdparty/LibBytesUtils.sol index cad328022ca..ce13f3ef897 100644 --- a/packages/protocol/contracts/thirdparty/LibBytesUtils.sol +++ b/packages/protocol/contracts/thirdparty/LibBytesUtils.sol @@ -111,19 +111,6 @@ library LibBytesUtils { return slice(_bytes, _start, _bytes.length - _start); } - function toBytes32(bytes memory _bytes) internal pure returns (bytes32) { - if (_bytes.length < 32) { - bytes32 ret; - assembly { - ret := mload(add(_bytes, 32)) - } - return ret; - } - - return abi.decode(_bytes, (bytes32)); // will truncate if input length > - // 32 bytes - } - function toNibbles(bytes memory _bytes) internal pure returns (bytes memory) { bytes memory nibbles = new bytes(_bytes.length * 2); diff --git a/packages/protocol/contracts/thirdparty/LibMerkleTrie.sol b/packages/protocol/contracts/thirdparty/LibMerkleTrie.sol index 89f11f4de47..d124b56c6be 100644 --- a/packages/protocol/contracts/thirdparty/LibMerkleTrie.sol +++ b/packages/protocol/contracts/thirdparty/LibMerkleTrie.sol @@ -171,10 +171,7 @@ library LibMerkleTrie { ); } else { // Nodes smaller than 31 bytes aren't hashed. - require( - LibBytesUtils.toBytes32(currentNode.encoded) == currentNodeID, - "Invalid internal node hash" - ); + require(bytes32(currentNode.encoded) == currentNodeID, "Invalid internal node hash"); } if (currentNode.decoded.length == BRANCH_NODE_LENGTH) { @@ -275,7 +272,7 @@ library LibMerkleTrie { nodeID = LibRLPReader.readBytes(_node); } - return LibBytesUtils.toBytes32(nodeID); + return bytes32(nodeID); } /**