Skip to content

Commit

Permalink
chore: typo fixes and CI (#422)
Browse files Browse the repository at this point in the history
* chore: typos -w
* chore: manual typo fixes
  • Loading branch information
roberts-pumpurs authored Sep 4, 2024
1 parent ea9a028 commit c1df988
Show file tree
Hide file tree
Showing 37 changed files with 150 additions and 106 deletions.
17 changes: 17 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
- package-ecosystem: cargo
directory: /
schedule:
interval: daily
ignore:
- dependency-name: "*"
# patch and minor updates don't matter for libraries
# remove this ignore rule if your package has binaries
update-types:
- "version-update:semver-patch"
- "version-update:semver-minor"
20 changes: 20 additions & 0 deletions .github/workflows/typos.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Typos check

on:
push:
branches: [main]
pull_request:
branches: [main]

defaults:
run:
shell: bash

jobs:
typos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/[email protected]
with:
files: .
3 changes: 3 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://github.com/crate-ci/typos/blob/master/docs/reference.md
[files]
extend-exclude = ["axelar-amplifier", "evm-contracts/lib/*", "offchain", "solana/xtask/devnet-amplifier.json"]
5 changes: 5 additions & 0 deletions solana/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ skip_core_tasks = true
workspace = false
dependencies = ["check", "test", "unused-deps"]

[tasks.typos]
workspace = false
install_crate = "typos-cli"
command = "typos"

[tasks.fmt]
workspace = false
command = "cargo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ pub fn random_execute_data_and_verifier_set_for_payload_with_invalid_signatures(
{
Some(Signature::EcdsaRecoverable(bytes)) => bytes.as_mut_slice(),
Some(Signature::Ed25519(bytes)) => bytes.as_mut_slice(),
_ => unimplemented!("signature not attaced"),
_ => unimplemented!("signature not attached"),
};
signature_bytes[0] ^= 1;

Expand Down
2 changes: 1 addition & 1 deletion solana/crates/axelar-rkyv-encoding/src/types/u128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ mod tests {
use crate::test_fixtures::random_bytes;

#[test]
fn test_endiannes() {
fn test_endianness() {
let bytes = random_bytes::<16>();
let u128 = U128::from_le(bytes);
assert_eq!(*u128.to_le(), bytes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<'payload> DataPayload<'payload> {
fn encoding_scheme_prefixed_array(&self) -> Vec<u8> {
let mut writer_vec = Vec::<u8>::with_capacity(
// This might not be the exact size, but it's a good approximation
// Ideally we calcualte the size of data before writing it.
// Ideally we calculate the size of data before writing it.
// Could be achieved with a build.rs script that generates the size of the data for
// each encoding type.
size_of::<u8>() // encoding scheme
Expand Down
4 changes: 2 additions & 2 deletions solana/helpers/evm-contracts-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use std::path::PathBuf;

use ethers::contract::Abigen;

/// Using a buid.rs script to generate the bindings for the EVM contracts
/// Using a build.rs script to generate the bindings for the EVM contracts
/// and write them to the OUT_DIR.
///
/// The generated bindings are then included in the lib.rs file.
/// This is preffered to using the `abigen!` macro because it does not act on
/// This is preferred to using the `abigen!` macro because it does not act on
/// `*.json` file changes and cannot be used in a `build.rs` script.
fn main() {
build_contract();
Expand Down
2 changes: 1 addition & 1 deletion solana/helpers/interchain-token-transfer-gmp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ sol! {
/// This message has the following data encoded and should only be sent
/// after the proper tokens have been procured by the service. It should
/// result in the proper funds being transferred to the user at the
/// destionation chain.
/// destination chain.
#[derive(Debug, PartialEq)]
#[repr(C)]
struct InterchainTransfer {
Expand Down
14 changes: 7 additions & 7 deletions solana/helpers/test-fixtures/src/test_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use axelar_rkyv_encoding::types::{ExecuteData, Message, Payload, VerifierSet};
use borsh::BorshDeserialize;
use gateway::commands::OwnedCommand;
use gateway::hasher_impl;
use gateway::instructions::{InitializeConfig, VerifierSetWraper};
use gateway::instructions::{InitializeConfig, VerifierSetWrapper};
use gateway::processor::ToBytes;
use gateway::state::execute_data::{
ApproveMessagesVariant, ArchivedGatewayExecuteData, ExecuteDataVariant, RotateSignersVariant,
Expand Down Expand Up @@ -328,17 +328,17 @@ impl TestFixture {
root_pda_address
}

pub fn create_verifier_sets(&self, signers: &[&SigningVerifierSet]) -> Vec<VerifierSetWraper> {
pub fn create_verifier_sets(&self, signers: &[&SigningVerifierSet]) -> Vec<VerifierSetWrapper> {
signers
.iter()
.map(|set| VerifierSetWraper::new_from_verifier_set(set.verifier_set()).unwrap())
.map(|set| VerifierSetWrapper::new_from_verifier_set(set.verifier_set()).unwrap())
.collect_vec()
}

pub fn base_initialize_config(
&self,
domain_separator: [u8; 32],
) -> InitializeConfig<VerifierSetWraper> {
) -> InitializeConfig<VerifierSetWrapper> {
InitializeConfig {
domain_separator,
initial_signer_sets: vec![],
Expand All @@ -350,7 +350,7 @@ impl TestFixture {

pub async fn initialize_gateway_config_account(
&mut self,
init_config: InitializeConfig<VerifierSetWraper>,
init_config: InitializeConfig<VerifierSetWrapper>,
) -> Pubkey {
let (gateway_config_pda, _) = gateway::get_gateway_root_config_pda();
let ix = gateway::instructions::initialize_config(
Expand Down Expand Up @@ -918,10 +918,10 @@ mod tests {
use super::*;

/// Try to deploy the same program elf file using the
/// `bbf_loader_upgradeable` programm directly, and regiestering the PDAs
/// `bbf_loader_upgradeable` program directly, and regiestering the PDAs
/// manually.
/// The core asserts is to ensure that the account data storage
/// is the same, thus ensuring that both operatiosn are somewhat equivelant.
/// is the same, thus ensuring that both operatiosn are somewhat equivalent.
#[tokio::test]
async fn test_manually_added_bpf_upgradeable_accounts_contain_expected_state() {
// setup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async fn test_send_from_solana_to_evm() {
let message = messages[0].clone();
// - The relayer relays the contract call to the EVM gateway
// evm_gateway.message_hash_to_sign(, )
let _tx_reciept = evm_gateway
let _tx_receipt = evm_gateway
.approve_messages(messages, proof)
.send()
.await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use solana_sdk::transaction::Transaction;
use crate::program_test;

#[tokio::test]
async fn test_succesfully_send_to_gateway() {
async fn test_successfully_send_to_gateway() {
// Setup
let mut solana_chain = program_test().await;
let memo = "🐪🐪🐪🐪";
Expand Down
2 changes: 1 addition & 1 deletion solana/programs/gas-service/src/instruction.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Instruction module; consist of fasade instructions, test ix constructors and
//! Instruction module; consist of facade instructions, test ix constructors and
//! internal helpers.

use axelar_message_primitives::U256;
Expand Down
32 changes: 16 additions & 16 deletions solana/programs/gas-service/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ impl Processor {
}

// Check: Root PDA Account.
let (addr, bumb) = get_gas_service_root_pda();
let (addr, bump) = get_gas_service_root_pda();
if gas_service_root_pda_account.key != &addr {
return Err(GasServiceError::InvalidGasServiceRootPDAAccount.into());
}
Expand All @@ -230,7 +230,7 @@ impl Processor {
fees,
),
&[sender_account.clone(), gas_service_root_pda_account.clone()],
&[&[&[bumb]]],
&[&[&[bump]]],
)?;

events::emit_native_gas_paid_for_contract_call_event(
Expand Down Expand Up @@ -285,7 +285,7 @@ impl Processor {
}

// Check: Root PDA Account.
let (addr, bumb) = get_gas_service_root_pda();
let (addr, bump) = get_gas_service_root_pda();
if gas_service_root_pda_account.key != &addr {
return Err(GasServiceError::InvalidGasServiceRootPDAAccount.into());
}
Expand All @@ -307,7 +307,7 @@ impl Processor {
fees,
),
&[sender_account.clone(), gas_service_root_pda_account.clone()],
&[&[&[bumb]]],
&[&[&[bump]]],
)?;

events::emit_native_gas_paid_for_contract_call_with_token_event(
Expand Down Expand Up @@ -359,7 +359,7 @@ impl Processor {
}

// Check: Root PDA Account.
let (addr, bumb) = get_gas_service_root_pda();
let (addr, bump) = get_gas_service_root_pda();
if gas_service_root_pda_account.key != &addr {
return Err(GasServiceError::InvalidGasServiceRootPDAAccount.into());
}
Expand All @@ -381,7 +381,7 @@ impl Processor {
fees,
),
&[sender_account.clone(), gas_service_root_pda_account.clone()],
&[&[&[bumb]]],
&[&[&[bump]]],
)?;

events::emit_native_gas_paid_for_express_call_event(
Expand Down Expand Up @@ -438,7 +438,7 @@ impl Processor {
}

// Check: Root PDA Account.
let (addr, bumb) = get_gas_service_root_pda();
let (addr, bump) = get_gas_service_root_pda();
if gas_service_root_pda_account.key != &addr {
return Err(GasServiceError::InvalidGasServiceRootPDAAccount.into());
}
Expand All @@ -460,7 +460,7 @@ impl Processor {
fees,
),
&[sender_account.clone(), gas_service_root_pda_account.clone()],
&[&[&[bumb]]],
&[&[&[bump]]],
)?;

events::emit_native_gas_paid_for_express_call_with_token_event(
Expand Down Expand Up @@ -508,7 +508,7 @@ impl Processor {
}

// Check: Root PDA Account.
let (addr, bumb) = get_gas_service_root_pda();
let (addr, bump) = get_gas_service_root_pda();
if gas_service_root_pda_account.key != &addr {
return Err(GasServiceError::InvalidGasServiceRootPDAAccount.into());
}
Expand All @@ -530,7 +530,7 @@ impl Processor {
fees,
),
&[sender_account.clone(), gas_service_root_pda_account.clone()],
&[&[&[bumb]]],
&[&[&[bump]]],
)?;

events::emit_native_gas_added_event(tx_hash, log_index, fees, refund_address)?;
Expand Down Expand Up @@ -570,7 +570,7 @@ impl Processor {
}

// Check: Root PDA Account.
let (addr, bumb) = get_gas_service_root_pda();
let (addr, bump) = get_gas_service_root_pda();
if gas_service_root_pda_account.key != &addr {
return Err(GasServiceError::InvalidGasServiceRootPDAAccount.into());
}
Expand All @@ -592,7 +592,7 @@ impl Processor {
fees,
),
&[sender_account.clone(), gas_service_root_pda_account.clone()],
&[&[&[bumb]]],
&[&[&[bump]]],
)?;

events::emit_native_express_gas_added_event(tx_hash, log_index, fees, refund_address)?;
Expand Down Expand Up @@ -621,7 +621,7 @@ impl Processor {
}

// Check: Root PDA Account.
let (addr, _bumb) = get_gas_service_root_pda();
let (addr, _bump) = get_gas_service_root_pda();
if gas_service_root_pda_account.key != &addr {
return Err(GasServiceError::InvalidGasServiceRootPDAAccount.into());
}
Expand Down Expand Up @@ -649,7 +649,7 @@ impl Processor {
return Err(GasServiceError::SenderAccountIsNotExpectedAuthority.into());
}

// Check: The requested amount bigger than tresure account saldo minus required
// Check: The requested amount bigger than treasure account saldo minus required
// rent exempt value.
let space = gas_service_root_pda_account.data.borrow().len();
let rent_sysvar = Rent::get()?;
Expand Down Expand Up @@ -686,7 +686,7 @@ impl Processor {
}

// Check: Root PDA Account.
let (addr, _bumb) = get_gas_service_root_pda();
let (addr, _bump) = get_gas_service_root_pda();
if gas_service_root_pda_account.key != &addr {
return Err(GasServiceError::InvalidGasServiceRootPDAAccount.into());
}
Expand Down Expand Up @@ -714,7 +714,7 @@ impl Processor {
return Err(GasServiceError::SenderAccountIsNotExpectedAuthority.into());
}

// Check: The requested amount bigger than tresure account saldo minus required
// Check: The requested amount bigger than treasure account saldo minus required
// rent exempt value.
let space = gas_service_root_pda_account.data.borrow().len();
let rent_sysvar = Rent::get()?;
Expand Down
4 changes: 2 additions & 2 deletions solana/programs/gas-service/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ async fn collect_fees_happy_scenario() -> Result<()> {
(rent_exempt + fees) - amount_to_collect
);

// Check: Reciever got funds.
// Check: Receiver got funds.
assert_eq!(
banks_client
.get_account(receiver_address.pubkey())
Expand Down Expand Up @@ -955,7 +955,7 @@ async fn refund_happy_scenario() -> Result<()> {
(rent_exempt + fees) - amount_to_collect
);

// Check: Reciever got funds.
// Check: Receiver got funds.
assert_eq!(
banks_client
.get_account(receiver_address.pubkey())
Expand Down
2 changes: 1 addition & 1 deletion solana/programs/gateway/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ impl BorshDeserialize for OwnedCommand {
}

/// FIXME: This is a workaround to wrap the serialized Message from the
/// `axelar-rkyv-encoding` crate. It shoud not be needed once we fully migrate
/// `axelar-rkyv-encoding` crate. It should not be needed once we fully migrate
/// types from that crate.
#[derive(BorshDeserialize, BorshSerialize, PartialEq, Eq, Debug, Clone)]
pub struct MessageWrapper {
Expand Down
6 changes: 3 additions & 3 deletions solana/programs/gateway/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub enum GatewayError {
InvalidApprovedMessageAccount,

/// Failed to decode `execute_data`
#[error("Falied to decode execute_data")]
#[error("Failed to decode execute_data")]
FailedToDecodeExecuteData,

/// Arithmetic overflow
Expand All @@ -104,7 +104,7 @@ pub enum GatewayError {

/// Signer Set set epoch is different than the current epoch
#[error("Signer Set set epoch is different than the current epoch.")]
EpochMissmatch,
EpochMismatch,

/// Failed to decode a valid signature
#[error("Failed to deserialize signature")]
Expand Down Expand Up @@ -132,7 +132,7 @@ pub enum GatewayError {
UnorderedOrDuplicateSignerSet,

// 30
/// Thresold was presented as zero, which is an invalid value.
/// Threshold was presented as zero, which is an invalid value.
#[error("Threshold cannot be equal to zero")]
ZeroThreshold,

Expand Down
4 changes: 2 additions & 2 deletions solana/programs/gateway/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ impl GatewayEvent {
Ok(())
}

/// Encode the [`GatewayEvent`] into a [`Vec<u8>`] which satifies rkyv
/// Encode the [`GatewayEvent`] into a [`Vec<u8>`] which satisfies rkyv
/// alignment requirements
pub fn encode(&self) -> rkyv::AlignedVec {
rkyv::to_bytes::<_, 0>(self).unwrap()
Expand All @@ -184,7 +184,7 @@ pub struct EventContainer {
}

impl EventContainer {
/// Create a new [`EventContainer`] from an rkyv enocded [`GatewayEvent`]
/// Create a new [`EventContainer`] from an rkyv encoded [`GatewayEvent`]
///
/// The method will return `None` if the buffer cannod be deserialised into
/// a valid [`ArchivedGatewayEvent`]
Expand Down
Loading

0 comments on commit c1df988

Please sign in to comment.