Commit 841d7851 authored by elenadimitrova's avatar elenadimitrova Committed by Kelvin Fichter

Remove suggested dead code by slither

parent 6e44a1fc
...@@ -118,41 +118,6 @@ library Lib_OVMCodec { ...@@ -118,41 +118,6 @@ library Lib_OVMCodec {
return keccak256(encodeTransaction(_transaction)); return keccak256(encodeTransaction(_transaction));
} }
/**
* @notice RLP-encodes an account state struct.
* @param _account Account state struct.
* @return RLP-encoded account state.
*/
function encodeEVMAccount(
EVMAccount memory _account
)
internal
pure
returns (
bytes memory
)
{
bytes[] memory raw = new bytes[](4);
// Unfortunately we can't create this array outright because
// Lib_RLPWriter.writeList will reject fixed-size arrays. Assigning
// index-by-index circumvents this issue.
raw[0] = Lib_RLPWriter.writeBytes(
Lib_Bytes32Utils.removeLeadingZeros(
bytes32(_account.nonce)
)
);
raw[1] = Lib_RLPWriter.writeBytes(
Lib_Bytes32Utils.removeLeadingZeros(
bytes32(_account.balance)
)
);
raw[2] = Lib_RLPWriter.writeBytes(abi.encodePacked(_account.storageRoot));
raw[3] = Lib_RLPWriter.writeBytes(abi.encodePacked(_account.codeHash));
return Lib_RLPWriter.writeList(raw);
}
/** /**
* @notice Decodes an RLP-encoded account state into a useful struct. * @notice Decodes an RLP-encoded account state into a useful struct.
* @param _encoded RLP-encoded account state. * @param _encoded RLP-encoded account state.
......
...@@ -89,23 +89,6 @@ library Lib_RLPWriter { ...@@ -89,23 +89,6 @@ library Lib_RLPWriter {
return writeBytes(abi.encodePacked(_in)); return writeBytes(abi.encodePacked(_in));
} }
/**
* RLP encodes a bytes32 value.
* @param _in The bytes32 to encode.
* @return _out The RLP encoded bytes32 in bytes.
*/
function writeBytes32(
bytes32 _in
)
internal
pure
returns (
bytes memory _out
)
{
return writeBytes(abi.encodePacked(_in));
}
/** /**
* RLP encodes a uint. * RLP encodes a uint.
* @param _in The uint256 to encode. * @param _in The uint256 to encode.
......
...@@ -77,41 +77,4 @@ library Lib_Bytes32Utils { ...@@ -77,41 +77,4 @@ library Lib_Bytes32Utils {
{ {
return bytes32(uint256(_in)); return bytes32(uint256(_in));
} }
/**
* Removes the leading zeros from a bytes32 value and returns a new (smaller) bytes value.
* @param _in Input bytes32 value.
* @return Bytes32 without any leading zeros.
*/
function removeLeadingZeros(
bytes32 _in
)
internal
pure
returns (
bytes memory
)
{
bytes memory out;
assembly {
// Figure out how many leading zero bytes to remove.
let shift := 0
for { let i := 0 } and(lt(i, 32), eq(byte(i, _in), 0)) { i := add(i, 1) } {
shift := add(shift, 1)
}
// Reserve some space for our output and fix the free memory pointer.
out := mload(0x40)
mstore(0x40, add(out, 0x40))
// Shift the value and store it into the output bytes.
mstore(add(out, 0x20), shl(mul(shift, 8), _in))
// Store the new size (with leading zero bytes removed) in the output byte size.
mstore(out, sub(32, shift))
}
return out;
}
} }
...@@ -100,23 +100,6 @@ library Lib_BytesUtils { ...@@ -100,23 +100,6 @@ library Lib_BytesUtils {
return slice(_bytes, _start, _bytes.length - _start); return slice(_bytes, _start, _bytes.length - _start);
} }
function toBytes32PadLeft(
bytes memory _bytes
)
internal
pure
returns (
bytes32
)
{
bytes32 ret;
uint256 len = _bytes.length <= 32 ? _bytes.length : 32;
assembly {
ret := shr(mul(sub(32, len), 8), mload(add(_bytes, 32)))
}
return ret;
}
function toBytes32( function toBytes32(
bytes memory _bytes bytes memory _bytes
) )
...@@ -149,69 +132,6 @@ library Lib_BytesUtils { ...@@ -149,69 +132,6 @@ library Lib_BytesUtils {
return uint256(toBytes32(_bytes)); return uint256(toBytes32(_bytes));
} }
function toUint24(
bytes memory _bytes,
uint256 _start
)
internal
pure
returns (
uint24
)
{
require(_start + 3 >= _start, "toUint24_overflow");
require(_bytes.length >= _start + 3 , "toUint24_outOfBounds");
uint24 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x3), _start))
}
return tempUint;
}
function toUint8(
bytes memory _bytes,
uint256 _start
)
internal
pure
returns (
uint8
)
{
require(_start + 1 >= _start, "toUint8_overflow");
require(_bytes.length >= _start + 1 , "toUint8_outOfBounds");
uint8 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x1), _start))
}
return tempUint;
}
function toAddress(
bytes memory _bytes,
uint256 _start
)
internal
pure
returns (
address
)
{
require(_start + 20 >= _start, "toAddress_overflow");
require(_bytes.length >= _start + 20, "toAddress_outOfBounds");
address tempAddress;
assembly {
tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
}
return tempAddress;
}
function toNibbles( function toNibbles(
bytes memory _bytes bytes memory _bytes
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment