From 17e4a855d46d4c666867a815a97e5ed48fe296c2 Mon Sep 17 00:00:00 2001 From: adria0 Date: Thu, 8 Aug 2024 08:02:00 +0200 Subject: [PATCH] feat: check for typos in CI --- .github/workflows/ci.yml | 16 ++++++++++++++++ Typos.toml | 13 +++++++++++++ crates/interpreter/src/instructions/data.rs | 4 ++-- crates/interpreter/src/interpreter/analysis.rs | 6 +++--- crates/interpreter/src/interpreter_action.rs | 2 +- .../src/interpreter_action/eof_create_inputs.rs | 2 +- crates/primitives/src/env/handler_cfg.rs | 2 +- crates/primitives/src/result.rs | 2 +- crates/revm/src/handler.rs | 4 ++-- crates/revm/src/optimism/fast_lz.rs | 2 +- documentation/src/crates/interpreter/memory.md | 2 +- documentation/src/crates/primitives.md | 2 +- documentation/src/crates/primitives/kzg.md | 2 +- 13 files changed, 44 insertions(+), 15 deletions(-) create mode 100644 Typos.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b51370b02..0fcaa8fa48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,3 +93,19 @@ jobs: with: components: rustfmt - run: cargo fmt --all --check + + typos-check: + needs: [skip_check] + if: | + github.event.pull_request.draft == false && + (github.event.action == 'ready_for_review' || needs.skip_check.outputs.should_skip != 'true') + name: TyposCheck + timeout-minutes: 5 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: crate-ci/typos@v1.22.7 + with: + config: ./typos.toml + isolated: true + diff --git a/Typos.toml b/Typos.toml new file mode 100644 index 0000000000..0449825c11 --- /dev/null +++ b/Typos.toml @@ -0,0 +1,13 @@ +[default] +extend-ignore-identifiers-re = [ + "[sS]imular", + "ba", + "modul" +] + +[files] +extend-exclude = [ + "CHANGELOG.md", + "tests" +] + diff --git a/crates/interpreter/src/instructions/data.rs b/crates/interpreter/src/instructions/data.rs index dada108c1d..44024ec090 100644 --- a/crates/interpreter/src/instructions/data.rs +++ b/crates/interpreter/src/instructions/data.rs @@ -60,7 +60,7 @@ pub fn data_copy(interpreter: &mut Interpreter, _host: &mut H) gas!(interpreter, VERYLOW); pop!(interpreter, mem_offset, offset, size); - // sizes more than u64::MAX will spend all the gas in memmory resize. + // sizes more than u64::MAX will spend all the gas in memory resize. let size = as_usize_or_fail!(interpreter, size); // size of zero should not change the memory if size == 0 { @@ -75,7 +75,7 @@ pub fn data_copy(interpreter: &mut Interpreter, _host: &mut H) let offset = as_usize_saturated!(offset); let data = interpreter.contract.bytecode.eof().expect("eof").data(); - // set data from the eof to the shared memory. Padd it with zeros. + // set data from the eof to the shared memory. Padded it with zeros. interpreter .shared_memory .set_data(mem_offset, offset, size, data); diff --git a/crates/interpreter/src/interpreter/analysis.rs b/crates/interpreter/src/interpreter/analysis.rs index d3a6c75535..6d235c394c 100644 --- a/crates/interpreter/src/interpreter/analysis.rs +++ b/crates/interpreter/src/interpreter/analysis.rs @@ -89,7 +89,7 @@ pub fn validate_raw_eof_inner( /// Only place where validation happen is in Creating Transaction. /// Because of that we are assuming CodeType is ReturnContract. /// -/// Note: If neeed we can make a flag that would assume ReturnContract CodeType. +/// Note: If needed we can make a flag that would assume ReturnContract CodeType. pub fn validate_eof(eof: &Eof) -> Result<(), EofError> { validate_eof_inner(eof, Some(CodeType::ReturnContract)) } @@ -224,7 +224,7 @@ impl std::error::Error for EofError {} #[derive(Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Clone, Copy)] pub enum EofValidationError { - FalsePossitive, + FalsePositive, /// Opcode is not known. It is not defined in the opcode table. UnknownOpcode, /// Opcode is disabled in EOF. For example JUMP, JUMPI, etc. @@ -398,7 +398,7 @@ impl fmt::Display for EofValidationError { f, "{}", match self { - Self::FalsePossitive => "False positive", + Self::FalsePositive => "False positive", Self::UnknownOpcode => "Opcode is not known", Self::OpcodeDisabled => "Opcode is disabled", Self::InstructionNotForwardAccessed => "Should have forward jump", diff --git a/crates/interpreter/src/interpreter_action.rs b/crates/interpreter/src/interpreter_action.rs index 1d2c27d622..9beded2310 100644 --- a/crates/interpreter/src/interpreter_action.rs +++ b/crates/interpreter/src/interpreter_action.rs @@ -17,7 +17,7 @@ use std::boxed::Box; #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum InterpreterAction { /// CALL, CALLCODE, DELEGATECALL, STATICCALL - /// or EOF EXT instuction called. + /// or EOF EXT instruction called. Call { inputs: Box }, /// CREATE or CREATE2 instruction called. Create { inputs: Box }, diff --git a/crates/interpreter/src/interpreter_action/eof_create_inputs.rs b/crates/interpreter/src/interpreter_action/eof_create_inputs.rs index 30bc525a4e..c5cafb3c87 100644 --- a/crates/interpreter/src/interpreter_action/eof_create_inputs.rs +++ b/crates/interpreter/src/interpreter_action/eof_create_inputs.rs @@ -50,7 +50,7 @@ impl Default for EOFCreateKind { pub struct EOFCreateInputs { /// Caller of Eof Craate pub caller: Address, - /// Values of ether transfered + /// Values of ether transferred pub value: U256, /// Gas limit for the create call. pub gas_limit: u64, diff --git a/crates/primitives/src/env/handler_cfg.rs b/crates/primitives/src/env/handler_cfg.rs index f57a3e8c99..56560ae675 100644 --- a/crates/primitives/src/env/handler_cfg.rs +++ b/crates/primitives/src/env/handler_cfg.rs @@ -108,7 +108,7 @@ impl Deref for CfgEnvWithHandlerCfg { /// Evm environment with the chain spec id. #[derive(Clone, Debug, Default, Eq, PartialEq)] pub struct EnvWithHandlerCfg { - /// Evm enironment. + /// Evm environment. pub env: Box, /// Handler configuration fields. pub handler_cfg: HandlerCfg, diff --git a/crates/primitives/src/result.rs b/crates/primitives/src/result.rs index 858078ec02..517cdb8a59 100644 --- a/crates/primitives/src/result.rs +++ b/crates/primitives/src/result.rs @@ -461,7 +461,7 @@ pub enum HaltReason { OutOfFunds, CallTooDeep, - /// Aux data overflow, new aux data is larger tha u16 max size. + /// Aux data overflow, new aux data is larger than u16 max size. EofAuxDataOverflow, /// Aud data is smaller then already present data size. EofAuxDataTooSmall, diff --git a/crates/revm/src/handler.rs b/crates/revm/src/handler.rs index 50942fa729..ed31917bbe 100644 --- a/crates/revm/src/handler.rs +++ b/crates/revm/src/handler.rs @@ -177,7 +177,7 @@ impl<'a, EXT, DB: Database> EvmHandler<'a, EXT, DB> { if out.is_some() { let registers = core::mem::take(&mut self.registers); let mut base_handler = Handler::mainnet_with_spec(self.cfg.spec_id); - // apply all registers to default handeler and raw mainnet instruction table. + // apply all registers to default handler and raw mainnet instruction table. for register in registers { base_handler.append_handler_register(register) } @@ -190,7 +190,7 @@ impl<'a, EXT, DB: Database> EvmHandler<'a, EXT, DB> { pub fn create_handle_generic(&mut self) -> EvmHandler<'a, EXT, DB> { let registers = core::mem::take(&mut self.registers); let mut base_handler = Handler::mainnet::(); - // apply all registers to default handeler and raw mainnet instruction table. + // apply all registers to default handler and raw mainnet instruction table. for register in registers { base_handler.append_handler_register(register) } diff --git a/crates/revm/src/optimism/fast_lz.rs b/crates/revm/src/optimism/fast_lz.rs index 3906bcb362..cf715bf3cb 100644 --- a/crates/revm/src/optimism/fast_lz.rs +++ b/crates/revm/src/optimism/fast_lz.rs @@ -120,7 +120,7 @@ mod tests { #[rstest] #[case::empty(&[], 0)] #[case::thousand_zeros(&[0; 1000], 21)] - #[case::thousand_fourty_twos(&[42; 1000], 21)] + #[case::thousand_forty_twos(&[42; 1000], 21)] #[case::short_hex(&bytes!("FACADE"), 4)] #[case::sample_contract_call(&bytes!("02f901550a758302df1483be21b88304743f94f80e51afb613d764fa61751affd3313c190a86bb870151bd62fd12adb8e41ef24f3f000000000000000000000000000000000000000000000000000000000000006e000000000000000000000000af88d065e77c8cc2239327c5edb3a432268e5831000000000000000000000000000000000000000000000000000000000003c1e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000148c89ed219d02f1a5be012c689b4f5b731827bebe000000000000000000000000c001a033fd89cb37c31b2cba46b6466e040c61fc9b2a3675a7f5f493ebd5ad77c497f8a07cdf65680e238392693019b4092f610222e71b7cec06449cb922b93b6a12744e"), 202)] #[case::base_0x5dadeb52979f29fc7a7494c43fdabc5be1d8ff404f3aafe93d729fa8e5d00769(&bytes!("b9047c02f904788221050883036ee48409c6c87383037f6f941195cf65f83b3a5768f3c496d3a05ad6412c64b78644364c5bb000b90404d123b4d80000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000038000000000000000000000000000000000f6476f90447748c19248ccaa31e6b8bfda4eb9d830f5f47df7f0998f7c2123d9e6137761b75d3184efb0f788e3b14516000000000000000000000000000000000000000000000000000044364c5bb000000000000000000000000000f38e53bd45c8225a7c94b513beadaa7afe5d222d0000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002a000000000000000000000000000000000000000000000000000000000000002c000000000000000000000000000000000000000000000000000000000000002e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084d6574614d61736b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d656852577a743347745961776343347564745657557233454c587261436746434259416b66507331696f48610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000cd0d83d9e840f8e27d5c2e365fd365ff1c05b2480000000000000000000000000000000000000000000000000000000000000ce40000000000000000000000000000000000000000000000000000000000000041e4480d358dbae20880960a0a464d63b06565a0c9f9b1b37aa94b522247b23ce149c81359bf4239d1a879eeb41047ec710c15f5c0f67453da59a383e6abd742971c00000000000000000000000000000000000000000000000000000000000000c001a0b57f0ff8516ea29cb26a44ac5055a5420847d1e16a8e7b03b70f0c02291ff2d5a00ad3771e5f39ccacfff0faa8c5d25ef7a1c179f79e66e828ffddcb994c8b512e"), 471)] diff --git a/documentation/src/crates/interpreter/memory.md b/documentation/src/crates/interpreter/memory.md index 24d4c39edc..2f28764f7a 100644 --- a/documentation/src/crates/interpreter/memory.md +++ b/documentation/src/crates/interpreter/memory.md @@ -2,7 +2,7 @@ Is a memory localized to the current Interpreter context. Interpreter context is a call or create frame. It is used by opcodes to store or format data that are more then 32 bytes long, for example calls to format input, return output or for logs data. Revm has a shared memory between all the Interpreters but Interpreter loop only see the part it is allocated to it. -Extending memory is paid by the gas. It consumes 3 gas per word plus square of the number of words added divided by `512` (`3*N+ N^2/512`). There is no limit on the size of the memory, but it is limited by logaritmic growth of the gas cost. For 30M there is a calculated max memory of 32MB (Blog post by ramco: [Upper bound for transaction memory](https://xn--2-umb.com/22/eth-max-mem/)). +Extending memory is paid by the gas. It consumes 3 gas per word plus square of the number of words added divided by `512` (`3*N+ N^2/512`). There is no limit on the size of the memory, but it is limited by logarithmic growth of the gas cost. For 30M there is a calculated max memory of 32MB (Blog post by ramco: [Upper bound for transaction memory](https://xn--2-umb.com/22/eth-max-mem/)). ## Opcodes diff --git a/documentation/src/crates/primitives.md b/documentation/src/crates/primitives.md index 45d57594ef..49d35c9766 100644 --- a/documentation/src/crates/primitives.md +++ b/documentation/src/crates/primitives.md @@ -15,7 +15,7 @@ It is set up to be compatible with environments that do not include Rust's stand - [specification](./primitives/specifications.md): This module defines types related to Ethereum specifications (also known as hard forks). - [state](./primitives/state.md): This module provides types and functions for managing Ethereum state, including accounts and storage. - [utilities](./primitives/utils.md): This module provides utility functions used in multiple places across the EVM implementation. -- [kzg](./primitives/kzg.md): This module provides types and functions related to KZG commitment, it is empolyed visibly in the Point Evalution Precompile. +- [kzg](./primitives/kzg.md): This module provides types and functions related to KZG commitment, it is empolyed visibly in the Point Evaluation Precompile. ### External Crates: diff --git a/documentation/src/crates/primitives/kzg.md b/documentation/src/crates/primitives/kzg.md index 7e7e6316d3..7c72a08eb8 100644 --- a/documentation/src/crates/primitives/kzg.md +++ b/documentation/src/crates/primitives/kzg.md @@ -1,6 +1,6 @@ # KZG -With the introduction of [EIP4844](https://eips.ethereum.org/EIPS/eip-4844), this use of blobs for a more efficent short term storage is employed, the validity of this blob stored in the consensus layer is verified using the `Point Evaluation` pre-compile, a fancy way of verifing that and evaluation at a given point of a commited polynomial is vaild, in a much more bigger scale, implies that `Data is Available`. +With the introduction of [EIP4844](https://eips.ethereum.org/EIPS/eip-4844), this use of blobs for a more efficient short term storage is employed, the validity of this blob stored in the consensus layer is verified using the `Point Evaluation` pre-compile, a fancy way of verifying that and evaluation at a given point of a committed polynomial is valid, in a much more bigger scale, implies that `Data is Available`. This module houses;