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

Add typos checker and fix typos #277

Merged
merged 4 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codespell/.codespellrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[codespell]
skip = .git,node_modules,artifacts-zk,yarn.lock,contracts-preprocessed,Cargo.lock
skip = .git,_typos.toml,artifacts,lib,node_modules,artifacts-zk,yarn.lock,contracts-preprocessed,Cargo.lock
count = true
quiet-level = 3
ignore-words = ./.codespell/wordlist.txt
17 changes: 15 additions & 2 deletions .github/workflows/codespell.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# A Github action that using codespell to check spell.
# .codespell/.codespellrc is a config file.
# A Github action that uses codespell and typos to check spell.
# .codespell/.codespellrc is the config file of codespell.
# .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
#
# _typos.toml is a config file of typos.
# More details about typos is https://github.com/crate-ci/typos

name: Codespell

Expand All @@ -28,3 +31,13 @@ jobs:

- name: Spell check
run: codespell --config=./.codespell/.codespellrc

typos:
runs-on: ubuntu-latest

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

- name: Check for typos
uses: crate-ci/typos@master
23 changes: 23 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[files]
# Temporarily commenting a lot so that at least *.sol files are included.
extend-exclude = [
"/l1-contracts/lib/",
"/l1-contracts/out/",
"/l1-contracts/node_modules/",
"/l1-contracts/artifacts",
"/l2-contracts/artifacts-zk",
"/l2-contracts/cache-zk",
"/l2-contracts/typechain",
"/system-contracts/artifacts-zk",
"/system-contracts/cache-zk",
"/system-contracts/contracts-preprocessed",
"/system-contracts/typechain",
"*.json",
"*.lock",
".git/"
]

[default.extend-words]
# Don't correct the surname "Teh"
FOT = "FOT"
ue = "ue"
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ interface IStateTransitionManager {

function protocolVersion() external view returns (uint256);

function initialize(StateTransitionManagerInitializeData calldata _initalizeData) external;
function initialize(StateTransitionManagerInitializeData calldata _initializeData) external;

function setInitialCutHash(Diamond.DiamondCutData calldata _diamondCut) external;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract DepositTest is BridgehubMailboxTest {
// vm.startPrank(nonChainContract);
// bridgehub.deposit(chainId);
// }
// function test_SuccessfullIfCalledByChainContract() public {
// function test_SuccessfulIfCalledByChainContract() public {
// address chainContract = bridgehub.getStateTransition(chainId);
// vm.startPrank(chainContract);
// bridgehub.deposit(chainId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ contract InitializationTest is DiamondCutTest {
diamondCutTestContract.diamondCut(diamondCutData);
}

function test_ReverWhen_DelegateCallToEOA() public {
function test_RevertWhen_DelegateCallToEOA() public {
Diamond.FacetCut[] memory facetCuts = new Diamond.FacetCut[](0);

Diamond.DiamondCutData memory diamondCutData = Diamond.DiamondCutData({
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/test/unit_tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export async function requestExecute(
);
}

// due to gas reasons we call tha chains's contract directly, instead of the bridgehub.
// due to gas reasons we call the chains' contract directly, instead of the bridgehub.
export async function requestExecuteDirect(
mailbox: IMailbox,
to: Address,
Expand Down
20 changes: 10 additions & 10 deletions system-contracts/SystemContractsHashes.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,35 +150,35 @@
"contractName": "bootloader_test",
"bytecodePath": "bootloader/build/artifacts/bootloader_test.yul.zbin",
"sourceCodePath": "bootloader/build/bootloader_test.yul",
"bytecodeHash": "0x01000367d383bb1e456d4b004ac859fed3ad3827f44cc7f6bada054727dcc2cd",
"sourceCodeHash": "0x24d98150d952a5084ef28bf3c50ba11e3a14934f73ad03c3cb3c3675e1824377"
"bytecodeHash": "0x010003677c4902cc91f08d15001e0c5ec16fd9a904c7297a74932c34cab22c1f",
"sourceCodeHash": "0x19893221834773e7896487907ea2ee49a7fe83056b9c3016d05c302ae70705c5"
},
{
"contractName": "fee_estimate",
"bytecodePath": "bootloader/build/artifacts/fee_estimate.yul.zbin",
"sourceCodePath": "bootloader/build/fee_estimate.yul",
"bytecodeHash": "0x01000829fdc3ecb02de0e91a2eb95ddf63f8cddfacc8f6e358b0084a0b7b8fc9",
"sourceCodeHash": "0xb9ff43872d4bb866db01ce7e5713ddbe6a3d6dc5e0df44c57b190343473b8c0c"
"bytecodeHash": "0x01000829d87634f3b1d855c7f4e713df870bb9f271f1dc6c87808c0049c0ae3b",
"sourceCodeHash": "0x80f44c1379ee5eecf1d188c05c835b69cbdf0f33602f2d389b8f0f14aad5167b"
},
{
"contractName": "gas_test",
"bytecodePath": "bootloader/build/artifacts/gas_test.yul.zbin",
"sourceCodePath": "bootloader/build/gas_test.yul",
"bytecodeHash": "0x010007f9cea31213834c000f78895c5641293278dcb2b45c8490b450f5fc4290",
"sourceCodeHash": "0x01cd41ab7fac8bc5f53a380e066e668cb552ebff56ef1539300f8648c202083f"
"bytecodeHash": "0x010007f9b86ee108776e42a1ad50194be894b9941b9b660157ddafcacdfcfe3f",
"sourceCodeHash": "0x814a03d96ae80584b5907997d9d69d6b4f9fa16e3365eb3ac512d98a526d0321"
},
{
"contractName": "playground_batch",
"bytecodePath": "bootloader/build/artifacts/playground_batch.yul.zbin",
"sourceCodePath": "bootloader/build/playground_batch.yul",
"bytecodeHash": "0x0100082fa0c08b2bf4f3267009bc47716d8e46fd666563a1f7a047cc48399aef",
"sourceCodeHash": "0xe72ebdc2642fafc39992ff9329ec83eb94de1d1823b35089a92359ac18143deb"
"bytecodeHash": "0x0100082fb596d4b42bc1b7d5f0fa04a22d7ea5cc2cde757c34d94d00dadc038d",
"sourceCodeHash": "0x4dee4c943408df4375f84351265dee77ed65bba9b4bb565f860c6d435601c4f6"
},
{
"contractName": "proved_batch",
"bytecodePath": "bootloader/build/artifacts/proved_batch.yul.zbin",
"sourceCodePath": "bootloader/build/proved_batch.yul",
"bytecodeHash": "0x0100080996820a8a4056f661f926b3d495758b5f71ce1ddb6c75236b79a3fa82",
"sourceCodeHash": "0x763247aabe6a033c332c1dfeeaca2be2cecca24f50cf4406f58e899ef68fa010"
"bytecodeHash": "0x010008095dfd6a873af3909665f4d7929d3bf86baf725277618f85135e4054d2",
"sourceCodeHash": "0x664f6720c5624c2ff034cb3d1c7b7a969bea1da5910c705d8cd8669a427d8757"
}
]
14 changes: 7 additions & 7 deletions system-contracts/bootloader/bootloader.yul
Original file line number Diff line number Diff line change
Expand Up @@ -2062,9 +2062,9 @@ object "Bootloader" {
mstore(add(txDataWithHashesOffset, 64), 96)

let calldataPtr := prependSelector(txDataWithHashesOffset, selector)
let innerTxDataOffst := add(txDataOffset, 32)
let innerTxDataOffset := add(txDataOffset, 32)

let len := getDataLength(innerTxDataOffst)
let len := getDataLength(innerTxDataOffset)

// Besides the length of the transaction itself,
// we also require 3 words for hashes and the offset
Expand All @@ -2086,9 +2086,9 @@ object "Bootloader" {
/// @dev Calculates and saves the explorer hash and the suggested signed hash for the transaction.
function saveTxHashes(txDataOffset) {
let calldataPtr := prependSelector(txDataOffset, {{GET_TX_HASHES_SELECTOR}})
let innerTxDataOffst := add(txDataOffset, 32)
let innerTxDataOffset := add(txDataOffset, 32)

let len := getDataLength(innerTxDataOffst)
let len := getDataLength(innerTxDataOffset)

// The first word is formal, but still required by the ABI
// We also should take into account the selector.
Expand Down Expand Up @@ -2235,12 +2235,12 @@ object "Bootloader" {
/// this method also enforces that the nonce has been marked as used.
function accountValidateTx(txDataOffset) {
// Skipping the first 0x20 word of the ABI-encoding of the struct
let innerTxDataOffst := add(txDataOffset, 32)
let from := getFrom(innerTxDataOffst)
let innerTxDataOffset := add(txDataOffset, 32)
let from := getFrom(innerTxDataOffset)
ensureAccount(from)

// The nonce should be unique for each transaction.
let nonce := getNonce(innerTxDataOffst)
let nonce := getNonce(innerTxDataOffset)
// Here we check that this nonce was not available before the validation step
ensureNonceUsage(from, nonce, 0)

Expand Down
8 changes: 4 additions & 4 deletions system-contracts/bootloader/test_infra/src/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ pub(crate) enum TestVmHook {

// Number of 32-bytes slots that are reserved for test hooks (passing information between bootloader test code and the VM).
const TEST_HOOKS: u32 = 5;
const TEST_HOOK_ENUM_POSITON: u32 = VM_HOOK_PARAMS_START_POSITION - 1;
const TEST_HOOK_START: u32 = TEST_HOOK_ENUM_POSITON - TEST_HOOKS;
const TEST_HOOK_ENUM_POSITION: u32 = VM_HOOK_PARAMS_START_POSITION - 1;
const TEST_HOOK_START: u32 = TEST_HOOK_ENUM_POSITION - TEST_HOOKS;

pub fn get_vm_hook_params<H: HistoryMode>(memory: &SimpleMemory<H>) -> Vec<U256> {
memory.dump_page_content_as_u256_words(
BOOTLOADER_HEAP_PAGE,
TEST_HOOK_START..TEST_HOOK_ENUM_POSITON,
TEST_HOOK_START..TEST_HOOK_ENUM_POSITION,
)
}

Expand Down Expand Up @@ -88,7 +88,7 @@ impl TestVmHook {
// Only UMA opcodes in the bootloader serve for vm hooks
if !matches!(opcode_variant.opcode, Opcode::UMA(UMAOpcode::HeapWrite))
|| heap_page != BOOTLOADER_HEAP_PAGE
|| fat_ptr.offset != TEST_HOOK_ENUM_POSITON * 32
|| fat_ptr.offset != TEST_HOOK_ENUM_POSITION * 32
{
return Self::NoHook;
}
Expand Down
4 changes: 2 additions & 2 deletions system-contracts/contracts/test-contracts/KeccakTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ contract KeccakTest {
bytes32 constant EMPTY_STRING_KECCAK = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;

// Just some computation-heavy function, it will be used to test out of gas
function infiniteFuction(uint256 n) public pure returns (uint256 sumOfSquares) {
function infiniteFunction(uint256 n) public pure returns (uint256 sumOfSquares) {
for (uint256 i = 0; i < n; i++) {
sumOfSquares += i * i;
}
Expand Down Expand Up @@ -55,7 +55,7 @@ contract KeccakTest {
}

function zeroPointerTest() external {
try this.infiniteFuction{gas: 1000000}(1000000) returns (uint256) {
try this.infiniteFunction{gas: 1000000}(1000000) returns (uint256) {
revert("The transaction should have failed");
} catch {}

Expand Down
16 changes: 8 additions & 8 deletions system-contracts/test/Keccak256.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ describe("Keccak256 tests", function () {
});

it("keccak upgrade test", async () => {
const deployerInterfact = new ethers.utils.Interface((await loadArtifact("ContractDeployer")).abi);
const deployerInterface = new ethers.utils.Interface((await loadArtifact("ContractDeployer")).abi);

const eraseInput = deployerInterfact.encodeFunctionData("forceDeployKeccak256", [alwaysRevertCodeHash]);
const eraseInput = deployerInterface.encodeFunctionData("forceDeployKeccak256", [alwaysRevertCodeHash]);

const upgradeInput = deployerInterfact.encodeFunctionData("forceDeployKeccak256", [correctKeccakCodeHash]);
const upgradeInput = deployerInterface.encodeFunctionData("forceDeployKeccak256", [correctKeccakCodeHash]);

await keccakTest.keccakUpgradeTest(eraseInput, upgradeInput);
});

it("keccak validation test", async () => {
const deployerInterfact = new ethers.utils.Interface((await loadArtifact("ContractDeployer")).abi);
const deployerInterface = new ethers.utils.Interface((await loadArtifact("ContractDeployer")).abi);

const upgradeInput = deployerInterfact.encodeFunctionData("forceDeployKeccak256", [correctKeccakCodeHash]);
const upgradeInput = deployerInterface.encodeFunctionData("forceDeployKeccak256", [correctKeccakCodeHash]);

const resetInput = deployerInterfact.encodeFunctionData("forceDeployKeccak256", [oldKeccakCodeHash]);
const resetInput = deployerInterface.encodeFunctionData("forceDeployKeccak256", [oldKeccakCodeHash]);

const seed = ethers.utils.randomBytes(32);
// Displaying seed for reproducible tests
Expand Down Expand Up @@ -108,9 +108,9 @@ describe("Keccak256 tests", function () {
});

it("keccak upgrade if needed test", async () => {
const deployerInterfact = new ethers.utils.Interface((await loadArtifact("ContractDeployer")).abi);
const deployerInterface = new ethers.utils.Interface((await loadArtifact("ContractDeployer")).abi);

const mockKeccakInput = deployerInterfact.encodeFunctionData("forceDeployKeccak256", [keccakMockCodeHash]);
const mockKeccakInput = deployerInterface.encodeFunctionData("forceDeployKeccak256", [keccakMockCodeHash]);

await keccakTest.keccakPerformUpgrade(mockKeccakInput);

Expand Down
Loading