Skip to content

Commit

Permalink
Fixup solidity linting and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
hkalodner committed Aug 29, 2020
1 parent 8eb5143 commit e3df57f
Show file tree
Hide file tree
Showing 38 changed files with 269 additions and 905 deletions.
2 changes: 1 addition & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
{
files: '*.sol',
options: {
printWidth: 80,
printWidth: 100,
tabWidth: 4,
useTabs: false,
singleQuote: false,
Expand Down
1 change: 0 additions & 1 deletion packages/arb-bridge-eth/buidler.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ if (!process.env.DOCKER) {
usePlugin('@nomiclabs/buidler-waffle')
usePlugin('buidler-typechain')
usePlugin('solidity-coverage')
usePlugin('@nomiclabs/buidler-solhint')
usePlugin('@nomiclabs/buidler-etherscan')
usePlugin('buidler-spdx-license-identifier')
usePlugin('buidler-gas-reporter')
Expand Down
33 changes: 5 additions & 28 deletions packages/arb-bridge-eth/contracts/arch/Hashing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,11 @@ library Hashing {
return keccak256(abi.encodePacked(val));
}

function hashCodePoint(Value.CodePoint memory cp)
internal
pure
returns (bytes32)
{
function hashCodePoint(Value.CodePoint memory cp) internal pure returns (bytes32) {
assert(cp.immediate.length < 2);
if (cp.immediate.length == 0) {
return
keccak256(
abi.encodePacked(
Value.codePointTypeCode(),
cp.opcode,
cp.nextCodePoint
)
);
keccak256(abi.encodePacked(Value.codePointTypeCode(), cp.opcode, cp.nextCodePoint));
}
return
keccak256(
Expand All @@ -60,14 +50,7 @@ library Hashing {
pure
returns (bytes32)
{
return
keccak256(
abi.encodePacked(
uint8(Value.tupleTypeCode()),
innerHash,
valueSize
)
);
return keccak256(abi.encodePacked(uint8(Value.tupleTypeCode()), innerHash, valueSize));
}

function hash(Value.Data memory val) internal pure returns (bytes32) {
Expand All @@ -87,11 +70,7 @@ library Hashing {
}
}

function getTuplePreImage(Value.Data[] memory vals)
internal
pure
returns (Value.Data memory)
{
function getTuplePreImage(Value.Data[] memory vals) internal pure returns (Value.Data memory) {
require(vals.length <= 8, "Invalid tuple length");
bytes32[] memory hashes = new bytes32[](vals.length);
uint256 hashCount = hashes.length;
Expand All @@ -100,9 +79,7 @@ library Hashing {
hashes[i] = vals[i].hash();
size += vals[i].size;
}
bytes32 firstHash = keccak256(
abi.encodePacked(uint8(hashes.length), hashes)
);
bytes32 firstHash = keccak256(abi.encodePacked(uint8(hashes.length), hashes));
return Value.newTuplePreImage(firstHash, size);
}
}
30 changes: 9 additions & 21 deletions packages/arb-bridge-eth/contracts/arch/Machine.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ library Machine {
uint256 internal constant MACHINE_ERRORSTOP = 1;
uint256 internal constant MACHINE_HALT = 2;

function addStackVal(
Value.Data memory stackValHash,
Value.Data memory valHash
) internal pure returns (Value.Data memory) {
function addStackVal(Value.Data memory stackValHash, Value.Data memory valHash)
internal
pure
returns (Value.Data memory)
{
Value.Data[] memory vals = new Value.Data[](2);
vals[0] = valHash;
vals[1] = stackValHash;
Expand All @@ -52,11 +53,7 @@ library Machine {
uint256 status;
}

function toString(Data memory machine)
internal
pure
returns (string memory)
{
function toString(Data memory machine) internal pure returns (string memory) {
return
string(
abi.encodePacked(
Expand Down Expand Up @@ -93,17 +90,11 @@ library Machine {
machine.status = MACHINE_HALT;
}

function addDataStackValue(Data memory machine, Value.Data memory val)
internal
pure
{
function addDataStackValue(Data memory machine, Value.Data memory val) internal pure {
machine.dataStack = addStackVal(machine.dataStack, val);
}

function addAuxStackValue(Data memory machine, Value.Data memory val)
internal
pure
{
function addAuxStackValue(Data memory machine, Value.Data memory val) internal pure {
machine.auxStack = addStackVal(machine.auxStack, val);
}

Expand Down Expand Up @@ -188,10 +179,7 @@ library Machine {
uint256 errHandler;
(offset, instructionStack) = Marshaling.deserializeInt(data, offset);

(offset, m.dataStack) = Marshaling.deserializeHashPreImage(
data,
offset
);
(offset, m.dataStack) = Marshaling.deserializeHashPreImage(data, offset);
(offset, m.auxStack) = Marshaling.deserializeHashPreImage(data, offset);
(offset, m.registerVal) = Marshaling.deserialize(data, offset);
(offset, m.staticVal) = Marshaling.deserialize(data, offset);
Expand Down
21 changes: 5 additions & 16 deletions packages/arb-bridge-eth/contracts/arch/Marshaling.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ library Marshaling {
pure
returns (uint256 offset, Value.Data memory value)
{
require(
data.length >= startOffset && data.length - startOffset >= 64,
"to short"
);
require(data.length >= startOffset && data.length - startOffset >= 64, "to short");
bytes32 hashData;
uint256 size;
(offset, hashData) = extractBytes32(data, startOffset);
Expand All @@ -51,10 +48,7 @@ library Marshaling {
uint256 // val
)
{
require(
data.length >= startOffset && data.length - startOffset >= 32,
"too short"
);
require(data.length >= startOffset && data.length - startOffset >= 32, "too short");
return (startOffset + 32, data.toUint(startOffset));
}

Expand Down Expand Up @@ -142,9 +136,7 @@ library Marshaling {
return deserializeCodePoint(data, offset);
} else if (valType == Value.tuplePreImageTypeCode()) {
return deserializeHashPreImage(data, offset);
} else if (
valType >= Value.tupleTypeCode() && valType < Value.valueTypeCode()
) {
} else if (valType >= Value.tupleTypeCode() && valType < Value.valueTypeCode()) {
uint8 tupLength = uint8(valType - Value.tupleTypeCode());
Value.Data[] memory tupleVal;
(offset, tupleVal) = deserializeTuple(tupLength, data, offset);
Expand Down Expand Up @@ -220,8 +212,7 @@ library Marshaling {
// If byteCount % 32 != 0, the last chunk will have byteCount % 32 bytes of data in it and the rest should be ignored
uint256 fullChunkCount = byteCount / 32;
uint256 partialChunkSize = byteCount % 32;
uint256 totalChunkCount = fullChunkCount +
(partialChunkSize > 0 ? 1 : 0);
uint256 totalChunkCount = fullChunkCount + (partialChunkSize > 0 ? 1 : 0);

bytes32[] memory fullChunks = new bytes32[](fullChunkCount);
bytes memory partialChunk = new bytes(partialChunkSize);
Expand All @@ -246,9 +237,7 @@ library Marshaling {
} else {
// Put the chunks into fullChunks in reverse order
// We use a separate index fullChunkIndex since we may or may not have included a partial chunk
fullChunks[fullChunkCount - 1 - fullChunkIndex] = bytes32(
nextChunk
);
fullChunks[fullChunkCount - 1 - fullChunkIndex] = bytes32(nextChunk);
fullChunkIndex++;
}
}
Expand Down
Loading

0 comments on commit e3df57f

Please sign in to comment.