Skip to content

Commit

Permalink
Merge pull request #260 from matter-labs/denis/fix_misprints
Browse files Browse the repository at this point in the history
Fix typos and add codespell workflow
  • Loading branch information
dnkolegov authored Mar 12, 2024
2 parents 00fb39f + f64c2b6 commit d5c5d7a
Show file tree
Hide file tree
Showing 69 changed files with 478 additions and 436 deletions.
5 changes: 5 additions & 0 deletions .codespell/.codespellrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[codespell]
skip = .git,node_modules,artifacts-zk,yarn.lock,contracts-preprocessed,Cargo.lock
count =
quiet-level = 3
ignore-words = ./.codespell/wordlist.txt
1 change: 1 addition & 0 deletions .codespell/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
codespell==2.2.5
6 changes: 6 additions & 0 deletions .codespell/wordlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
correcty
fot
ue
tha
bu
crate
30 changes: 30 additions & 0 deletions .github/workflows/codespell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# A Github action that using codespell to check spell.
# .codespell/.codespellrc is a config file.
# .codespell/wordlist.txt is a list of words that will ignore word checks.
# More details please check the following link:
# https://github.com/codespell-project/codespell

name: Codespell

on: pull_request

jobs:
codespell:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: pip cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-

- name: Install prerequisites
run: sudo pip install -r ./.codespell/requirements.txt

- name: Spell check
run: codespell --config=./.codespell/.codespellrc
12 changes: 6 additions & 6 deletions docs/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ enum SystemLogKey {
When a batch is committed, we process L2 -> L1 system logs. Here are the invariants that are expected there:

- In a given batch there will be either 7 or 8 system logs. The 8th log is only required for a protocol upgrade.
- There will be a single log for each key that is containted within `SystemLogKey`
- There will be a single log for each key that is contained within `SystemLogKey`
- Three logs from the `L2_TO_L1_MESSENGER` with keys:
- `L2_TO_L1_LOGS_TREE_ROOT_KEY`
- `TOTAL_L2_TO_L1_PUBDATA_KEY`
Expand Down Expand Up @@ -255,12 +255,12 @@ the Alpha stage.
This contract consists of four main functions `commitBatches`, `proveBatches`, `executeBatches`, and `revertBatches`,
that can be called only by the validator.

When the validator calls `commitBatches`, the same calldata will be propogated to the zkSync contract (`DiamondProxy`
When the validator calls `commitBatches`, the same calldata will be propagated to the zkSync contract (`DiamondProxy`
through `call` where it invokes the `ExecutorFacet` through `delegatecall`), and also a timestamp is assigned to these
batches to track the time these batches are commited by the validator to enforce a delay between committing and
execution of batches. Then, the validator can prove the already commited batches regardless of the mentioned timestamp,
and again the same calldata (related to the `proveBatches` function) will be propogated to the zkSync contract. After,
the `delay` is elapsed, the validator is allowed to call `executeBatches` to propogate the same calldata to zkSync
batches to track the time these batches are committed by the validator to enforce a delay between committing and
execution of batches. Then, the validator can prove the already committed batches regardless of the mentioned timestamp,
and again the same calldata (related to the `proveBatches` function) will be propagated to the zkSync contract. After,
the `delay` is elapsed, the validator is allowed to call `executeBatches` to propagate the same calldata to zkSync
contract.

### L2 specifics
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/contracts/bridge/L1ERC20Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ contract L1ERC20Bridge is IL1ERC20Bridge, ReentrancyGuard {
function initialize() external reentrancyGuardInitializer {}

/// @dev transfer token to shared bridge as part of upgrade
function tranferTokenToSharedBridge(address _token, uint256 _amount) external {
function transferTokenToSharedBridge(address _token, uint256 _amount) external {
require(msg.sender == address(sharedBridge), "Not shared bridge");

Check warning on line 64 in l1-contracts/contracts/bridge/L1ERC20Bridge.sol

View workflow job for this annotation

GitHub Actions / lint

Use Custom Errors instead of require statements

Check warning on line 64 in l1-contracts/contracts/bridge/L1ERC20Bridge.sol

View workflow job for this annotation

GitHub Actions / lint

Use Custom Errors instead of require statements

Check warning on line 64 in l1-contracts/contracts/bridge/L1ERC20Bridge.sol

View workflow job for this annotation

GitHub Actions / lint

Use Custom Errors instead of require statements
uint256 amount = IERC20(_token).balanceOf(address(this));
require(amount == _amount, "Incorrect amount");

Check warning on line 66 in l1-contracts/contracts/bridge/L1ERC20Bridge.sol

View workflow job for this annotation

GitHub Actions / lint

Use Custom Errors instead of require statements

Check warning on line 66 in l1-contracts/contracts/bridge/L1ERC20Bridge.sol

View workflow job for this annotation

GitHub Actions / lint

Use Custom Errors instead of require statements

Check warning on line 66 in l1-contracts/contracts/bridge/L1ERC20Bridge.sol

View workflow job for this annotation

GitHub Actions / lint

Use Custom Errors instead of require statements
Expand Down
10 changes: 5 additions & 5 deletions l1-contracts/contracts/bridge/L1SharedBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Initializable, Owna
l2BridgeAddress[ERA_CHAIN_ID] = ERA_ERC20_BRIDGE_ADDRESS;
}

/// @dev tranfer tokens from legacy erc20 bridge or mailbox and set chainBalance as part of migration process
/// @dev transfer tokens from legacy erc20 bridge or mailbox and set chainBalance as part of migration process
function transferFundsFromLegacy(address _token, address _target, uint256 _targetChainId) external onlyOwner {
if (_token == ETH_TOKEN_ADDRESS) {
uint256 balanceBefore = address(this).balance;
Expand All @@ -127,7 +127,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Initializable, Owna
uint256 balanceBefore = IERC20(_token).balanceOf(address(this));
uint256 amount = IERC20(_token).balanceOf(address(legacyBridge));
require(amount > 0, "ShB: 0 amount to transfer");
IL1ERC20Bridge(_target).tranferTokenToSharedBridge(_token, amount);
IL1ERC20Bridge(_target).transferTokenToSharedBridge(_token, amount);
uint256 balanceAfter = IERC20(_token).balanceOf(address(this));
require(balanceAfter - balanceBefore == amount, "ShB: wrong amount transferred");
chainBalance[_targetChainId][_token] = chainBalance[_targetChainId][_token] + amount;
Expand Down Expand Up @@ -436,7 +436,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Initializable, Owna

if (!hyperbridgingEnabled[_chainId]) {
// Check that the chain has sufficient balance
require(chainBalance[_chainId][l1Token] >= amount, "ShB not enough funds 2"); // not enought funds
require(chainBalance[_chainId][l1Token] >= amount, "ShB not enough funds 2"); // not enough funds
chainBalance[_chainId][l1Token] -= amount;
}

Expand Down Expand Up @@ -498,7 +498,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Initializable, Owna
// = 4 + 20 + 32 + 32 + _additionalData.length >= 68 (bytes).

// So the data is expected to be at least 56 bytes long.
require(_l2ToL1message.length >= 56, "ShB wrong msg len"); // wrong messsage length
require(_l2ToL1message.length >= 56, "ShB wrong msg len"); // wrong message length

(uint32 functionSignature, uint256 offset) = UnsafeBytes.readUint32(_l2ToL1message, 0);
if (bytes4(functionSignature) == IMailbox.finalizeEthWithdrawal.selector) {
Expand Down Expand Up @@ -611,7 +611,7 @@ contract L1SharedBridge is IL1SharedBridge, ReentrancyGuard, Initializable, Owna
///
/// @return l1Receiver The address on L1 that will receive the withdrawn funds
/// @return l1Token The address of the L1 token being withdrawn
/// @return amount The amount of the token being withdrawns
/// @return amount The amount of the token being withdrawn
function finalizeWithdrawalLegacyErc20Bridge(
uint256 _l2BatchNumber,
uint256 _l2MessageIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,5 @@ interface IL1ERC20Bridge {
bytes32 _depositL2TxHash
) external returns (uint256 amount);

function tranferTokenToSharedBridge(address _token, uint256 _amount) external;
function transferTokenToSharedBridge(address _token, uint256 _amount) external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ library L2ContractHelper {

/// @notice Validates the format of the given bytecode hash.
/// @dev Due to the specification of the L2 bytecode hash, not every 32 bytes could be a legit bytecode hash.
/// @dev The function reverts on invalid bytecode hash formam.
/// @dev The function reverts on invalid bytecode hash format.
/// @param _bytecodeHash The hash of the bytecode to validate.
function validateBytecodeHash(bytes32 _bytecodeHash) internal pure {
uint8 version = uint8(_bytecodeHash[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract RevertReceiveAccount {
}

receive() external payable {
// Assert is used here to also simulate the out-of-gas error, since failed asserion
// Assert is used here to also simulate the out-of-gas error, since failed assertion
// consumes up all the remaining gas
assert(!revertReceive);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract RevertTransferERC20 is TestnetERC20Token {
}

function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
// Assert is used here to also simulate the out-of-gas error, since failed asserion
// Assert is used here to also simulate the out-of-gas error, since failed assertion
// consumes up all the remaining gas
assert(!revertTransfer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract CustomUpgradeTest is BaseZkSyncUpgrade {
/// Typically this function will never be used.
/// @param _customCallDataForUpgrade Custom data for upgrade, which may be interpreted differently for each upgrade.
function _upgradeL1Contract(bytes calldata _customCallDataForUpgrade) internal override {
keccak256(_customCallDataForUpgrade); // called to supress compilation warning
keccak256(_customCallDataForUpgrade); // called to suppress compilation warning
emit Test();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ contract L1SharedBridgeTest is L1SharedBridge {
_;
}

/// @notice used by bridgehub to aquire mintValue. If l2Tx fails refunds are sent to refundrecipient on L2
/// @notice used by bridgehub to acquire mintValue. If l2Tx fails refunds are sent to refund recipient on L2
/// we also use it to keep to track each chain's assets
function bridgehubDepositBaseToken(
uint256 _chainId,
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/contracts/state-transition/Verifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ contract Verifier is IVerifier {
// No memory was accessed yet, so keys can be loaded into the right place and not corrupt any other memory.
_loadVerificationKey();

// Begining of the big inline assembly block that makes all the verification work.
// Beginning of the big inline assembly block that makes all the verification work.
// Note: We use the custom memory layout, so the return value should be returned from the assembly, not
// Solidity code.
assembly {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ contract ExecutorFacet is ZkSyncStateTransitionBase, IExecutor {
// 1. A chain has to keep their protocol version up to date, as processing a block requires the latest or previous protocol version
// to solve this we will need to add the feature to create batches with only the protocol upgrade tx, without any other txs.
// 2. A chain might become out of sync if it launches while we are in the middle of a protocol upgrade. This would mean they cannot process their genesis upgrade
// as thier protocolversion would be outdated, and they also cannot process the protocol upgrade tx as they have a pending upgrade.
// as their protocolversion would be outdated, and they also cannot process the protocol upgrade tx as they have a pending upgrade.
// 3. The protocol upgrade is increased in the BaseZkSyncUpgrade, in the executor only the systemContractsUpgradeTxHash is checked
require(
IStateTransitionManager(s.stateTransitionManager).protocolVersion() == s.protocolVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ interface IMailbox is IZkSyncStateTransitionBase {
uint256 _l2GasPerPubdataByteLimit
) external view returns (uint256);

/// @notice tranfer Eth to shared bridge as part of migration process
/// @notice transfer Eth to shared bridge as part of migration process
function transferEthToSharedBridge() external;

/// @notice New priority request event. Emitted when a request is placed into the priority queue
Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/contracts/upgrades/BaseZkSyncUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ abstract contract BaseZkSyncUpgrade is ZkSyncStateTransitionBase {
function _setVerifier(IVerifier _newVerifier) private {
// An upgrade to the verifier must be done carefully to ensure there aren't batches in the committed state
// during the transition. If verifier is upgraded, it will immediately be used to prove all committed batches.
// Batches committed expecting the old verifier will fail. Ensure all commited batches are finalized before the
// Batches committed expecting the old verifier will fail. Ensure all committed batches are finalized before the
// verifier is upgraded.
if (_newVerifier == IVerifier(address(0))) {
return;
Expand All @@ -142,7 +142,7 @@ abstract contract BaseZkSyncUpgrade is ZkSyncStateTransitionBase {
function _setVerifierParams(VerifierParams calldata _newVerifierParams) private {
// An upgrade to the verifier params must be done carefully to ensure there aren't batches in the committed state
// during the transition. If verifier is upgraded, it will immediately be used to prove all committed batches.
// Batches committed expecting the old verifier params will fail. Ensure all commited batches are finalized before the
// Batches committed expecting the old verifier params will fail. Ensure all committed batches are finalized before the
// verifier is upgraded.
if (
_newVerifierParams.recursionNodeLevelVkHash == bytes32(0) &&
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/scripts/migrate-governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ async function main() {
);
displayTx("L2 ERC20 beacon upgrade: ", l2TxForErc20BeaconUpgrade);

// Small delimeter for better readability.
// Small delimiter for better readability.
console.log("\n\n\n", "-".repeat(20), "\n\n\n");

console.log("Secondly, the new governor needs to accept all the roles where they need to be accepted.");
Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/src.ts/deploy-test-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function defaultDeployerForTests(deployWallet: Wallet, ownerAddress
return new Deployer({
deployWallet,
ownerAddress,
verbose: false, // change here to view deployement
verbose: false, // change here to view deployment
addresses: addressConfig,
bootloaderBytecodeHash: L2_BOOTLOADER_BYTECODE_HASH,
defaultAccountBytecodeHash: L2_DEFAULT_ACCOUNT_BYTECODE_HASH,
Expand All @@ -43,7 +43,7 @@ export async function defaultEraDeployerForTests(deployWallet: Wallet, ownerAddr
return new EraDeployer({
deployWallet,
ownerAddress,
verbose: false, // change here to view deployement
verbose: false, // change here to view deployment
addresses: addressConfig,
bootloaderBytecodeHash: L2_BOOTLOADER_BYTECODE_HASH,
defaultAccountBytecodeHash: L2_DEFAULT_ACCOUNT_BYTECODE_HASH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ contract ExperimentalBridgeTest is Test {
vm.store(address(mockChainContract), baseTokenGasPriceNominatorLocation, bytes32(uint256(1)));
bytes32 baseTokenGasPriceDenominatorLocation = bytes32(uint256(41));
vm.store(address(mockChainContract), baseTokenGasPriceDenominatorLocation, bytes32(uint256(1)));
// The ownership can only be transfered by the current owner to a new owner via the two-step approach
// The ownership can only be transferred by the current owner to a new owner via the two-step approach

// Default owner calls transferOwnership
bridgeHub.transferOwnership(bridgeOwner);
Expand Down Expand Up @@ -102,7 +102,7 @@ contract ExperimentalBridgeTest is Test {
isSTMRegistered = bridgeHub.stateTransitionManagerIsRegistered(randomAddressWithoutTheCorrectInterface);
assertTrue(isSTMRegistered);

// An address that has already been registered, cannot be registered again (atleast not before calling `removeStateTransitionManager`).
// An address that has already been registered, cannot be registered again (at least not before calling `removeStateTransitionManager`).
vm.prank(bridgeOwner);
vm.expectRevert(bytes("Bridgehub: state transition already registered"));
bridgeHub.addStateTransitionManager(randomAddressWithoutTheCorrectInterface);
Expand Down Expand Up @@ -131,7 +131,7 @@ contract ExperimentalBridgeTest is Test {
isSTMRegistered = bridgeHub.stateTransitionManagerIsRegistered(randomAddressWithoutTheCorrectInterface);
assertTrue(isSTMRegistered);

// An address that has already been registered, cannot be registered again (atleast not before calling `removeStateTransitionManager`).
// An address that has already been registered, cannot be registered again (at least not before calling `removeStateTransitionManager`).
vm.prank(bridgeOwner);
vm.expectRevert(bytes("Bridgehub: state transition already registered"));
bridgeHub.addStateTransitionManager(randomAddressWithoutTheCorrectInterface);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ contract L1SharedBridgeTest is Test {
uint16 l2TxNumberInBatch;
bytes32[] merkleProof;

// storing depoistHappend[chainId][l2TxHash] = txDataHash. DepositHappened is 3rd so 3 -1 + dependency storage slots
// storing depositHappend[chainId][l2TxHash] = txDataHash. DepositHappened is 3rd so 3 -1 + dependency storage slots
uint256 depositLocationInStorage = uint256(3 - 1 + 1 + 1);
uint256 chainBalanceLocationInStorage = uint256(6 - 1 + 1 + 1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {IGetters} from "solpp/state-transition/chain-interfaces/IGetters.sol";

// import "forge-std/console.sol";

/// We are testing all the specifici revert and require cases.
/// We are testing all the specified revert and require cases.
contract L1SharedBridgeFailTest is Test {
event BridgehubDepositBaseTokenInitiated(
uint256 indexed chainId,
Expand Down Expand Up @@ -92,7 +92,7 @@ contract L1SharedBridgeFailTest is Test {
uint16 l2TxNumberInBatch;
bytes32[] merkleProof;

// storing depoistHappend[chainId][l2TxHash] = txDataHash. DepositHappened is 3rd so 3 -1 + dependency storage slots
// storing depositHappened[chainId][l2TxHash] = txDataHash. DepositHappened is 3rd so 3 -1 + dependency storage slots
uint256 depositLocationInStorage = uint256(3 - 1 + 1 + 1);
uint256 chainBalanceLocationInStorage = uint256(6 - 1 + 1 + 1);
uint256 isWithdrawalFinalizedStorageLocation = uint256(4 - 1 + 1 + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {ERA_CHAIN_ID} from "solpp/common/Config.sol";

// import "forge-std/console.sol";

// note, this should be the same as where hyper is disalbed
// note, this should be the same as where hyper is disabled
contract L1SharedBridgeHyperEnabledTest is Test {
event BridgehubDepositBaseTokenInitiated(
uint256 indexed chainId,
Expand Down Expand Up @@ -197,7 +197,7 @@ contract L1SharedBridgeHyperEnabledTest is Test {
function test_claimFailedDeposit_Erc() public {
token.mint(address(sharedBridge), amount);

// storing depoistHappend[chainId][l2TxHash] = txDataHash. DepositHappened is 3rd so 3 -1 + dependency storage slots
// storing depositHappened[chainId][l2TxHash] = txDataHash. DepositHappened is 3rd so 3 -1 + dependency storage slots
uint256 depositLocationInStorage = uint256(3 - 1 + 1 + 1);
bytes32 txDataHash = keccak256(abi.encode(alice, address(token), amount));
vm.store(
Expand Down Expand Up @@ -257,7 +257,7 @@ contract L1SharedBridgeHyperEnabledTest is Test {
function test_claimFailedDeposit_Eth() public {
vm.deal(address(sharedBridge), amount);

// storing depoistHappend[chainId][l2TxHash] = txDataHash. DepositHappened is 3rd so 3 -1 + dependency storage slots
// storing depositHappened[chainId][l2TxHash] = txDataHash. DepositHappened is 3rd so 3 -1 + dependency storage slots
uint256 depositLocationInStorage = uint256(3 - 1 + 1 + 1);
bytes32 txDataHash = keccak256(abi.encode(alice, ETH_TOKEN_ADDRESS, amount));
vm.store(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ contract L1SharedBridgeLegacyTest is Test {
function test_claimFailedDepositLegacyErc20Bridge_Erc() public {
token.mint(address(sharedBridge), amount);

// storing depoistHappend[chainId][l2TxHash] = txDataHash. DepositHappened is 3rd so 3 -1 + dependency storage slots
// storing depositHappened[chainId][l2TxHash] = txDataHash. DepositHappened is 3rd so 3 -1 + dependency storage slots
uint256 depositLocationInStorage = uint256(3 - 1 + 1 + 1);
bytes32 txDataHash = keccak256(abi.encode(alice, address(token), amount));
vm.store(
Expand Down
Loading

0 comments on commit d5c5d7a

Please sign in to comment.