Skip to content

Commit

Permalink
Merge pull request #1541 from eqlabs/sm/run-typos
Browse files Browse the repository at this point in the history
chore: run `typos -w`
  • Loading branch information
sergey-melnychuk authored Nov 20, 2023
2 parents 83d79f3 + 129d87d commit 0b310f8
Show file tree
Hide file tree
Showing 39 changed files with 102 additions and 92 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ jobs:
- run: |
cargo sort --check --workspace
typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: crate-ci/[email protected]
with:
files: .

load_test:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- RPC accepts hex inputs for Felt without '0x' prefix. This led to confusion especially when passing in a decimal string which would get silently interpretted as hex.
- RPC accepts hex inputs for Felt without '0x' prefix. This led to confusion especially when passing in a decimal string which would get silently interpreted as hex.
- using a Nethermind Ethereum endpoint occasionally causes errors such as `<block-number> could not be found` to be logged.
- sync can miss new block events by getting stuck waiting for pending data.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ These __will not work__:

### Build info metrics

- `pathfinder_build_info` reports curent version as a `version` property
- `pathfinder_build_info` reports current version as a `version` property

## Build from source

Expand Down
2 changes: 2 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[files]
extend-exclude = ["crates/gateway-test-fixtures/fixtures/contracts/*.json"]
2 changes: 1 addition & 1 deletion crates/common/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl BlockHeader {
.with_parent_hash(self.hash)
}

/// Creates a [StateUpdate] with the block hash and state commitment fields intialized
/// Creates a [StateUpdate] with the block hash and state commitment fields initialized
/// to match this header.
pub fn init_state_update(&self) -> StateUpdate {
StateUpdate::default()
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl TransactionVersion {
self.without_query_version() == 0
}

/// Returns the transaction versin without QUERY_VERSION_BASE.
/// Returns the transaction version without QUERY_VERSION_BASE.
///
/// QUERY_VERSION_BASE (2**128) is a large constant that gets
/// added to the real version to make sure transactions constructed for
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub(super) mod i64_backed_u64 {

/// Generates felt newtype-wrappers and the `macro_prelude` module.
///
/// Note that this is a sinlge-use macro as it generates a module.
/// Note that this is a single-use macro as it generates a module.
///
/// Usage:
/// `felt_newtypes!([x1, x2, ..]; [y1, y2, ..])`
Expand Down
4 changes: 2 additions & 2 deletions crates/gateway-types/src/class_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn extract_abi_code_hash(
Ok((abi, code, hash))
}
json::ContractDefinition::Cairo(contract_definition) => {
// just in case we'd accidentially modify these in the compute_class_hash0
// just in case we'd accidentally modify these in the compute_class_hash0
let abi = serde_json::to_vec(&contract_definition.abi)
.context("Serialize contract_definition.abi")?;
let code = serde_json::to_vec(&contract_definition.program.data)
Expand Down Expand Up @@ -721,7 +721,7 @@ mod json {

#[test]
fn serde_json_has_raw_value() {
// raw value is needed for others but here for completness; this shouldn't compile if
// raw value is needed for others but here for completeness; this shouldn't compile if
// you the feature wasn't enabled.

#[derive(serde::Deserialize, serde::Serialize)]
Expand Down
2 changes: 1 addition & 1 deletion crates/gateway-types/src/reply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,7 @@ mod tests {

#[test]
fn eth_contract_addresses_ignores_extra_fields() {
// Some gateway mocks include extra addesses, check that we can still parse these.
// Some gateway mocks include extra addresses, check that we can still parse these.
let json = serde_json::json!({
"Starknet": "0x12345abcd",
"GpsStatementVerifier": "0xaabdde",
Expand Down
4 changes: 2 additions & 2 deletions crates/gateway-types/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ pub mod add_transaction {
#[serde_as]
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct InvokeFunction {
// Transacion properties
// Transaction properties
#[serde_as(as = "TransactionVersionAsHexStr")]
pub version: TransactionVersion,

Expand All @@ -277,7 +277,7 @@ pub mod add_transaction {
#[serde_as]
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct Declare {
// Transacion properties
// Transaction properties
#[serde_as(as = "TransactionVersionAsHexStr")]
pub version: TransactionVersion,

Expand Down
2 changes: 1 addition & 1 deletion crates/merkle-tree/src/contract_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl ContractStateUpdateResult {

transaction
.insert_contract_state_hash(block, self.contract_address, self.state_hash)
.context("Inserting constract state hash")
.context("Inserting contract state hash")
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/merkle-tree/src/merkle_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl From<Direction> for bool {
impl BinaryNode {
/// Maps the key's bit at the binary node's height to a [Direction].
///
/// This can be used to check which direction the key descibes in the context
/// This can be used to check which direction the key describes in the context
/// of this binary node i.e. which direction the child along the key's path would
/// take.
pub fn direction(&self, key: &BitSlice<u8, Msb0>) -> Direction {
Expand Down
2 changes: 1 addition & 1 deletion crates/p2p/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Starting up the bootstrap node:
RUST_LOG=info cargo run -p p2p_bootstrap -- --identity-config-file ./identity.json --listen-on /ip4/127.0.0.1/tcp/4000
````

And then starting three peers that initially connect to the boostrap node:
And then starting three peers that initially connect to the bootstrap node:

```shell
RUST_LOG=debug cargo run -p p2p --example peer -- --listen-on /ip4/127.0.0.1/tcp/4001 --bootstrap-addresses /ip4/127.0.0.1/tcp/4000/p2p/12D3KooWFck5QPHjZ9dZkAfEz7dwVfKkcUdf6xA3Rch4wadu7MH7
Expand Down
2 changes: 1 addition & 1 deletion crates/p2p/src/client/peer_agnostic/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ pub(crate) mod state_update {
impl_take_parsed_and_should_stop!(state_updates);
}

/// Merges partitoned classes if necessary
/// Merges partitioned classes if necessary
fn classes_from_dto(classes: Vec<p2p_proto::state::Class>) -> anyhow::Result<Vec<Class>> {
#[derive(Copy, Clone, Debug, Default, PartialEq)]
struct Ctx {
Expand Down
6 changes: 3 additions & 3 deletions crates/pathfinder/resources/fact_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def create(
"""
Creates an initialized instance by reading contract logs from the given web3 provider.
If is_verifier_proxied is true, then gps_statement_verifier_contract is the proxy contract
rather than the statement verifier implemantation.
rather than the statement verifier implementation.
"""
#last_block = web3.eth.block_number
last_block = from_block + 10000
Expand Down Expand Up @@ -221,7 +221,7 @@ def main():
parser = argparse.ArgumentParser()

# Note that Registration of memory pages happens before the state update transaction, hence
# make sure to use from_block which preceeds (~500 blocks) the block of the state transition fact
# make sure to use from_block which precedes (~500 blocks) the block of the state transition fact
parser.add_argument('--from_block', dest='from_block', default=5742000,
help='find memory pages written after this block')
parser.add_argument('--web3_node', dest='web3_node', default=GOERLI_NODE,
Expand Down Expand Up @@ -251,7 +251,7 @@ def main():
)
pages = memory_pages_fetcher.get_memory_pages_from_fact(
bytes.fromhex(args.fact))
# Interpetation of pages
# Interpretation of pages
state_diff = pages[1:] # ignore first page
diffs = [item for page in state_diff for item in page] # flatten
len_deployments = diffs.pop(0)
Expand Down
2 changes: 1 addition & 1 deletion crates/pathfinder/src/bin/pathfinder/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ pub enum Color {

impl Color {
/// Returns true if color should be enabled, either because the setting is [Color::Always],
/// or because it is [Color::Auto] and stdout is targetting a terminal.
/// or because it is [Color::Auto] and stdout is targeting a terminal.
pub fn is_color_enabled(&self) -> bool {
use std::io::IsTerminal;
match self {
Expand Down
2 changes: 1 addition & 1 deletion crates/pathfinder/src/p2p_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub async fn start(context: P2PContext) -> anyhow::Result<P2PNetworkHandle> {
p2p::libp2p::multiaddr::Protocol::P2p(peer_id) => Some(peer_id),
_ => None,
})
.ok_or_else(|| anyhow::anyhow!("Boostrap addresses must inlcude peer ID"))?;
.ok_or_else(|| anyhow::anyhow!("Bootstrap addresses must include peer ID"))?;
p2p_client.dial(peer_id, bootstrap_address.clone()).await?;
p2p_client
.start_listening(
Expand Down
4 changes: 2 additions & 2 deletions crates/pathfinder/src/p2p_network/sync_handlers/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,9 +716,9 @@ mod prop {
limit in rarely_outside(1..num_blocks),
// step is always >= 1
step in rarely_outside(1..num_blocks / 4),
directon in prop_oneof![Just(Direction::Forward), Just(Direction::Backward)],
direction in prop_oneof![Just(Direction::Forward), Just(Direction::Backward)],
) -> (u64, u64, u64, u64, Step, Direction) {
(num_blocks, storage_seed, start, limit, step.into(), directon)
(num_blocks, storage_seed, start, limit, step.into(), direction)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/pathfinder/src/state/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ where
tracing::error!(reason=?e, "Sync consumer task terminated with an error");
}
Err(e) if e.is_cancelled() => {
tracing::debug!("Sync consumer task cancelled succesfully");
tracing::debug!("Sync consumer task cancelled successfully");
},
Err(panic) => {
tracing::error!(%panic, "Sync consumer task panic'd");
Expand All @@ -297,7 +297,7 @@ where
tracing::error!(reason=?e, "L1 sync task terminated with an error");
}
Err(e) if e.is_cancelled() => {
tracing::debug!("L1 sync task cancelled succesfully");
tracing::debug!("L1 sync task cancelled successfully");
},
Err(panic) => {
tracing::error!(%panic, "L1 sync task panic'd");
Expand All @@ -312,7 +312,7 @@ where
tracing::error!(reason=?e, "L2 sync task terminated with an error");
}
Err(e) if e.is_cancelled() => {
tracing::debug!("L2 sync task cancelled succesfully");
tracing::debug!("L2 sync task cancelled successfully");
},
Err(panic) => {
tracing::error!(%panic, "L2 sync task panic'd");
Expand Down Expand Up @@ -834,7 +834,7 @@ async fn l2_reorg(connection: &mut Connection, reorg_tail: BlockNumber) -> anyho

let mut head = transaction
.block_id(pathfinder_storage::BlockId::Latest)
.context("Quering latest block number")?
.context("Querying latest block number")?
.context("Latest block number is none during reorg")?
.0;

Expand Down
4 changes: 2 additions & 2 deletions crates/pathfinder/src/state/sync/l2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ mod tests {
let mut mock = MockGatewayApi::new();
let mut seq = mockall::Sequence::new();

// Downlad the genesis block with respective state update and contracts
// Download the genesis block with respective state update and contracts
expect_block(
&mut mock,
&mut seq,
Expand All @@ -1064,7 +1064,7 @@ mod tests {
BLOCK0_HASH.into(),
Ok(BLOCK0_SIGNATURE.clone()),
);
// Downlad block #1 with respective state update and contracts
// Download block #1 with respective state update and contracts
expect_block(
&mut mock,
&mut seq,
Expand Down
6 changes: 3 additions & 3 deletions crates/rpc/src/jsonrpc/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ pub trait RpcMethod: Send + Sync {
/// async fn context_only(ctx: RpcContext) -> Result<impl Serialize, Into<RpcError>>;
/// ```
///
/// The generics allow us to achieve a form of variadic specilization and can be ignored by callers.
/// The generics allow us to achieve a form of variadic specialization and can be ignored by callers.
/// See [sealed::Sealed] to add more method signatures or more information on how this works.
pub trait IntoRpcMethod<'a, I, O, S>: sealed::Sealed<I, O, S> {
fn into_method(self) -> Box<dyn RpcMethod>;
Expand All @@ -252,12 +252,12 @@ mod sealed {
/// The generics allow for a form of specialization over a methods Input, Output and State
/// by treating each as a tuple. Varying the tuple length allows us to target a specific method
/// signature. This same could be achieved with a single generic but it becomes less clear as
/// each permuation would require a different tuple length.
/// each permutation would require a different tuple length.
///
/// By convention, the lack of a type is equivalent to the unit tuple (). So if we want to target functions
/// with no input params, no input state and an output:
/// ```
/// Sealed<I = (), S = (), O = ((), Ouput)>
/// Sealed<I = (), S = (), O = ((), Output)>
/// ```
pub trait Sealed<I, O, S> {
fn into_method(self) -> Box<dyn RpcMethod>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub async fn get_transaction_status(

let l1_accepted = db_tx
.block_is_l1_accepted(block_hash.into())
.context("Quering block's status")?;
.context("Querying block's status")?;

if l1_accepted {
Ok(Some(TransactionStatus::AcceptedOnL1))
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/src/v02/method/get_transaction_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub async fn get_transaction_receipt(

let l1_accepted = db_tx
.block_is_l1_accepted(block_number.into())
.context("Quering block status")?;
.context("Querying block status")?;

let block_status = if l1_accepted {
BlockStatus::AcceptedOnL1
Expand Down
26 changes: 13 additions & 13 deletions crates/rpc/src/v02/method/syncing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use serde::Serialize;

crate::error::generate_rpc_error_subset!(SyncingError);

pub async fn syncing(context: RpcContext) -> Result<SyncingOuput, SyncingError> {
pub async fn syncing(context: RpcContext) -> Result<SyncingOutput, SyncingError> {
// Scoped so I don't have to think too hard about mutex guard drop semantics.
let value = { context.sync_status.status.read().await.clone() };

use crate::v02::types::syncing::Syncing;
let value = match value {
Syncing::False(_) => SyncingOuput::False,
Syncing::False(_) => SyncingOutput::False,
Syncing::Status(status) => {
let status = SyncingStatus {
starting_block_num: status.starting.number,
Expand All @@ -22,7 +22,7 @@ pub async fn syncing(context: RpcContext) -> Result<SyncingOuput, SyncingError>
current_block_hash: status.current.hash,
highest_block_hash: status.highest.hash,
};
SyncingOuput::Status(status)
SyncingOutput::Status(status)
}
};

Expand All @@ -31,19 +31,19 @@ pub async fn syncing(context: RpcContext) -> Result<SyncingOuput, SyncingError>

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(any(test, feature = "rpc-full-serde"), derive(serde::Deserialize))]
pub enum SyncingOuput {
pub enum SyncingOutput {
False,
Status(SyncingStatus),
}

impl Serialize for SyncingOuput {
impl Serialize for SyncingOutput {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match self {
SyncingOuput::False => serializer.serialize_str("false"),
SyncingOuput::Status(inner) => serializer.serialize_newtype_struct("status", &inner),
SyncingOutput::False => serializer.serialize_str("false"),
SyncingOutput::Status(inner) => serializer.serialize_newtype_struct("status", &inner),
}
}
}
Expand All @@ -68,15 +68,15 @@ pub struct SyncingStatus {

#[cfg(test)]
mod tests {
use super::SyncingOuput;
use super::SyncingOutput;
use crate::context::RpcContext;
use pathfinder_common::macro_prelude::*;
mod serde {
use super::super::{SyncingOuput, SyncingStatus};
use super::super::{SyncingOutput, SyncingStatus};

#[test]
fn not_syncing() {
let json = serde_json::to_string(&SyncingOuput::False).unwrap();
let json = serde_json::to_string(&SyncingOutput::False).unwrap();
assert_eq!(json, r#""false""#);
}

Expand All @@ -93,7 +93,7 @@ mod tests {
current_block_hash: block_hash!("0x12345677"),
highest_block_hash: block_hash!("0x1144ffaacc"),
};
let value = SyncingOuput::Status(status);
let value = SyncingOutput::Status(status);
let json = serde_json::to_value(value).unwrap();

let expected = serde_json::json!( {
Expand Down Expand Up @@ -130,7 +130,7 @@ mod tests {
current_block_hash: block_hash!("0xccddee"),
highest_block_hash: block_hash!("0xeeffaacc"),
};
let expected = SyncingOuput::Status(expected);
let expected = SyncingOutput::Status(expected);

let context = RpcContext::for_tests();
*context.sync_status.status.write().await = status;
Expand All @@ -149,6 +149,6 @@ mod tests {

let result = super::syncing(context).await.unwrap();

assert_eq!(result, SyncingOuput::False);
assert_eq!(result, SyncingOutput::False);
}
}
2 changes: 1 addition & 1 deletion crates/rpc/src/v03/method/get_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ mod types {
#[serde(deny_unknown_fields)]
pub struct GetEventsResult {
pub events: Vec<EmittedEvent>,
/// Offset, measured in events, which points to the chunk that follows currenty requested chunk (`events`)
/// Offset, measured in events, which points to the chunk that follows currently requested chunk (`events`)
pub continuation_token: Option<String>,
}
}
Expand Down
Loading

0 comments on commit 0b310f8

Please sign in to comment.