Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint: synchronise linting rules of repositories #65

Closed
6 changes: 6 additions & 0 deletions ethereum/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint"],
"root": true
}
2 changes: 2 additions & 0 deletions ethereum/.markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
lib
node_modules
9 changes: 9 additions & 0 deletions ethereum/.markdownlintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"default": true,
"header-increment": false,
"no-duplicate-header": false,
"no-inline-html": false,
"line-length": false,
"fenced-code-language": false,
"no-multiple-blanks": false
}
6 changes: 6 additions & 0 deletions ethereum/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
artifacts
artifacts-forge
cache
cache-forge
lib
node_modules
49 changes: 48 additions & 1 deletion ethereum/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,63 @@
{
"plugins": ["prettier-plugin-solidity"],
"overrides": [
{
"files": "*.js",
"options": {
"tabWidth": 4,
"printWidth": 120,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true
}
},
{
"files": "*.json",
"options": {
"tabWidth": 2,
"printWidth": 120,
"bracketSpacing": true
}
},
{
"files": "*.md",
"options": {
"tabWidth": 2,
"printWidth": 120,
"parser": "markdown",
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true,
"proseWrap": "always"
}
},
{
"files": "*.sol",
"options": {
"parser": "solidity-parse",
"printWidth": 120,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false
}
},
{
"files": "*.ts",
"options": {
"tabWidth": 4,
"printWidth": 120,
"parser": "typescript",
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true
}
},
{
"files": "*.yaml",
"options": {
"tabWidth": 2,
"printWidth": 120
}
}
]
}
21 changes: 12 additions & 9 deletions ethereum/.solhint.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"rules": {
"prettier/prettier": ["error"],
"func-visibility": ["error", { "ignoreConstructors": true }],
"compiler-version": ["error", ">=0.8.0"],
"max-line-length": ["error", 120],
"state-visibility": "off",
"func-visibility": ["warn", { "ignoreConstructors": true }],
"var-name-mixedcase": "off",
"func-name-mixedcase": "off",
"avoid-call-value": "off",
"no-empty-blocks": "off",
"not-rely-on-time": "off",
"avoid-low-level-calls": "off",
"no-inline-assembly": "off",
"custom-errors": "off",
"no-global-import": "off",
"const-name-snakecase": "off",
"no-complex-fallback": "off",
"immutable-vars-naming": ["warn", { "immutablesAsConstants": false }]
"reason-string": "off",
"func-name-mixedcase": "off",
"no-unused-vars": "off",
"max-states-count": "off",
"compiler-version": ["warn", "^0.8.0"]
}
}
3 changes: 3 additions & 0 deletions ethereum/.solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cache
lib
node_modules
7 changes: 0 additions & 7 deletions ethereum/.vscode/extensions.json

This file was deleted.

6 changes: 0 additions & 6 deletions ethereum/.vscode/settings.json

This file was deleted.

6 changes: 1 addition & 5 deletions ethereum/contracts/bridge/interfaces/IL2Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ interface IL2Bridge {
bytes calldata _data
) external payable;

function withdraw(
address _l1Receiver,
address _l2Token,
uint256 _amount
) external;
function withdraw(address _l1Receiver, address _l2Token, uint256 _amount) external;

function l1TokenAddress(address _l2Token) external view returns (address);

Expand Down
6 changes: 1 addition & 5 deletions ethereum/contracts/bridge/interfaces/IL2ERC20Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@ pragma solidity ^0.8.13;

/// @author Matter Labs
interface IL2ERC20Bridge {
function initialize(
address _l1Bridge,
bytes32 _l2TokenProxyBytecodeHash,
address _governor
) external;
function initialize(address _l1Bridge, bytes32 _l2TokenProxyBytecodeHash, address _governor) external;
}
6 changes: 1 addition & 5 deletions ethereum/contracts/bridge/interfaces/IL2WethBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@
pragma solidity ^0.8.13;

interface IL2WethBridge {
function initialize(
address _l1Bridge,
address _l1WethAddress,
address _l2WethAddress
) external;
function initialize(address _l1Bridge, address _l1WethAddress, address _l2WethAddress) external;
}
27 changes: 5 additions & 22 deletions ethereum/contracts/common/interfaces/IAllowList.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,9 @@ interface IAllowList {

function getAccessMode(address _target) external view returns (AccessMode);

function hasSpecialAccessToCall(
address _caller,
address _target,
bytes4 _functionSig
) external view returns (bool);

function canCall(
address _caller,
address _target,
bytes4 _functionSig
) external view returns (bool);
function hasSpecialAccessToCall(address _caller, address _target, bytes4 _functionSig) external view returns (bool);

function canCall(address _caller, address _target, bytes4 _functionSig) external view returns (bool);

function getTokenDepositLimitData(address _l1Token) external view returns (Deposit memory);

Expand All @@ -66,20 +58,11 @@ interface IAllowList {
bool[] calldata _enables
) external;

function setPermissionToCall(
address _caller,
address _target,
bytes4 _functionSig,
bool _enable
) external;
function setPermissionToCall(address _caller, address _target, bytes4 _functionSig, bool _enable) external;

/*//////////////////////////////////////////////////////////////
DEPOSIT LIMIT LOGIC
//////////////////////////////////////////////////////////////*/

function setDepositLimit(
address _l1Token,
bool _depositLimitation,
uint256 _depositCap
) external;
function setDepositLimit(address _l1Token, bool _depositLimitation, uint256 _depositCap) external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,5 @@ interface IL2ContractDeployer {
/// @param _salt The create2 salt.
/// @param _bytecodeHash The correctly formatted hash of the bytecode.
/// @param _input The constructor calldata.
function create2(
bytes32 _salt,
bytes32 _bytecodeHash,
bytes calldata _input
) external;
function create2(bytes32 _salt, bytes32 _bytecodeHash, bytes calldata _input) external;
}
2 changes: 1 addition & 1 deletion ethereum/contracts/common/libraries/L2ContractHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ library L2ContractHelper {
require(_bytecode.length % 32 == 0, "pq");

uint256 bytecodeLenInWords = _bytecode.length / 32;
require(bytecodeLenInWords < 2**16, "pp"); // bytecode length must be less than 2^16 words
require(bytecodeLenInWords < 2 ** 16, "pp"); // bytecode length must be less than 2^16 words
require(bytecodeLenInWords % 2 == 1, "ps"); // bytecode length in words must be odd
hashedBytecode = sha256(_bytecode) & 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
// Setting the version of the hash
Expand Down
39 changes: 20 additions & 19 deletions ethereum/contracts/dev-contracts/test/ExecutorProvingTest.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
pragma solidity ^0.8.13;

import {ExecutorFacet} from '../../zksync/facets/Executor.sol';
import {ExecutorFacet} from "../../zksync/facets/Executor.sol";
import {VerifierParams} from "../../zksync/Storage.sol";


contract ExecutorProvingTest is ExecutorFacet {
function getBatchProofPublicInput(
bytes32 _prevBatchCommitment,
Expand All @@ -13,25 +12,28 @@ contract ExecutorProvingTest is ExecutorFacet {
return _getBatchProofPublicInput(_prevBatchCommitment, _currentBatchCommitment, _verifierParams);
}

function createBatchCommitment(CommitBatchInfo calldata _newBatchData, bytes32 _stateDiffHash)
external
view
returns (bytes32) {
function createBatchCommitment(
CommitBatchInfo calldata _newBatchData,
bytes32 _stateDiffHash
) external view returns (bytes32) {
return _createBatchCommitment(_newBatchData, _stateDiffHash);

}

function processL2Logs(CommitBatchInfo calldata _newBatch, bytes32 _expectedSystemContractUpgradeTxHash)
external
pure
returns (
uint256 numberOfLayer1Txs,
bytes32 chainedPriorityTxsHash,
bytes32 previousBatchHash,
bytes32 stateDiffHash,
bytes32 l2LogsTreeRoot,
uint256 packedBatchAndL2BlockTimestamp
) {
function processL2Logs(
CommitBatchInfo calldata _newBatch,
bytes32 _expectedSystemContractUpgradeTxHash
)
external
pure
returns (
uint256 numberOfLayer1Txs,
bytes32 chainedPriorityTxsHash,
bytes32 previousBatchHash,
bytes32 stateDiffHash,
bytes32 l2LogsTreeRoot,
uint256 packedBatchAndL2BlockTimestamp
)
{
return _processL2Logs(_newBatch, _expectedSystemContractUpgradeTxHash);
}

Expand All @@ -42,4 +44,3 @@ contract ExecutorProvingTest is ExecutorFacet {
s.zkPorterIsAvailable = false;
}
}

20 changes: 14 additions & 6 deletions ethereum/contracts/dev-contracts/test/ReenterGovernance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {IGovernance} from "../../governance/IGovernance.sol";
contract ReenterGovernance {
IGovernance governance;

// Store call, predecessor and salt separately,
// Store call, predecessor and salt separately,
// because Operation struct can't be stored on storage.
IGovernance.Call call;
bytes32 predecessor;
Expand All @@ -25,7 +25,11 @@ contract ReenterGovernance {

FunctionToCall functionToCall;

function initialize(IGovernance _governance, IGovernance.Operation memory _op, FunctionToCall _functionToCall) external {
function initialize(
IGovernance _governance,
IGovernance.Operation memory _op,
FunctionToCall _functionToCall
) external {
governance = _governance;
require(_op.calls.length == 1, "Only 1 calls supported");
call = _op.calls[0];
Expand All @@ -40,18 +44,22 @@ contract ReenterGovernance {
alreadyReentered = true;
IGovernance.Call[] memory calls = new IGovernance.Call[](1);
calls[0] = call;
IGovernance.Operation memory op = IGovernance.Operation({calls: calls, predecessor: predecessor, salt: salt});
IGovernance.Operation memory op = IGovernance.Operation({
calls: calls,
predecessor: predecessor,
salt: salt
});

if (functionToCall == ReenterGovernance.FunctionToCall.Execute) {
governance.execute(op);
} else if(functionToCall == ReenterGovernance.FunctionToCall.ExecuteInstant) {
} else if (functionToCall == ReenterGovernance.FunctionToCall.ExecuteInstant) {
governance.executeInstant(op);
} else if(functionToCall == ReenterGovernance.FunctionToCall.Cancel) {
} else if (functionToCall == ReenterGovernance.FunctionToCall.Cancel) {
bytes32 opId = governance.hashOperation(op);
governance.cancel(opId);
} else {
revert("Unset function to call");
}
}
}
}
}
Loading
Loading