Skip to content

Commit 3cea721

Browse files
committed
Linting (#3)
1 parent 2918cb0 commit 3cea721

34 files changed

+653
-409
lines changed

.github/workflows/rust_lint.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Rust Linting
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'eth2near/**'
8+
pull_request:
9+
branches: [ main ]
10+
paths:
11+
- 'eth2near/**'
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
16+
jobs:
17+
lint:
18+
runs-on: ubuntu-latest
19+
defaults:
20+
run:
21+
working-directory: ./eth2near
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Set up Rust
26+
uses: dtolnay/rust-toolchain@stable
27+
with:
28+
toolchain: 1.86.0
29+
components: clippy, rustfmt
30+
target: wasm32-unknown-unknown
31+
32+
- name: Cache Rust dependencies
33+
uses: Swatinem/rust-cache@v2
34+
with:
35+
workspaces: |
36+
./eth2near
37+
cache-on-failure: true
38+
cache-all-crates: true
39+
40+
- name: Run linters
41+
run: cargo clippy --all-targets --all-features -- -D warnings -D clippy::all
42+
- name: Check formatting
43+
run: cargo fmt --all -- --check

contracts/near/eth-prover/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repository.workspace = true
99
# in https://github.com/near/NEPs/blob/master/neps/nep-0330.md
1010
[package.metadata.near.reproducible_build]
1111
# docker image, descriptor of build environment
12-
image = "sourcescan/cargo-near:0.13.2-rust-1.84.0"
12+
image = "sourcescan/cargo-near:0.16.0-rust-1.86.0"
1313
# tag after colon above serves only descriptive purpose; image is identified by digest
1414
image_digest = "sha256:b41cb89907f92b114da9e2be4e109bff30ab792c22ddcbd2a4cff8e340cb9acb"
1515
# list of environment variables names, whose values, if set, will be used as external build parameters
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "1.84.0"
2+
channel = "1.86.0"

contracts/near/eth-prover/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mod tests {
3030

3131
// TESTS
3232

33-
use near_sdk::{testing_env, VMContext, NearToken};
33+
use near_sdk::{testing_env, NearToken, VMContext};
3434

3535
fn get_context(input: Vec<u8>) -> VMContext {
3636
VMContext {

contracts/near/eth-prover/src/tests_storage_proof.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ mod tests_storage_proof {
8080

8181
// TESTS
8282

83-
use near_sdk::{testing_env, VMContext, NearToken};
83+
use near_sdk::{testing_env, NearToken, VMContext};
8484

8585
fn get_context(input: Vec<u8>) -> VMContext {
8686
VMContext {

contracts/near/eth2-client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repository.workspace = true
99
# in https://github.com/near/NEPs/blob/master/neps/nep-0330.md
1010
[package.metadata.near.reproducible_build]
1111
# docker image, descriptor of build environment
12-
image = "sourcescan/cargo-near:0.13.2-rust-1.84.0"
12+
image = "sourcescan/cargo-near:0.16.0-rust-1.86.0"
1313
# tag after colon above serves only descriptive purpose; image is identified by digest
1414
image_digest = "sha256:b41cb89907f92b114da9e2be4e109bff30ab792c22ddcbd2a4cff8e340cb9acb"
1515
# list of environment variables names, whose values, if set, will be used as external build parameters
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "1.84.0"
2+
channel = "1.86.0"

contracts/near/eth2-client/src/tests/integration_sepolia.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ mod sepolia_integration_tests {
33
use super::*;
44
use crate::tests::utils::get_sepolia_test_data;
55
use crate::tests::utils::InitOptions;
6+
use borsh::{BorshDeserialize, BorshSerialize};
67
use eth2_utility::types::InitInput;
78
use eth_types::eth2::{ExtendedBeaconBlockHeader, SyncCommittee};
89
use eth_types::{Address, Bloom, H256, H64, U256};
9-
use borsh::{BorshDeserialize, BorshSerialize};
1010
use near_sdk::{Gas, NearToken};
11-
use near_workspaces::{Account, Contract};
1211
use near_workspaces::operations::Function;
12+
use near_workspaces::{Account, Contract};
1313
use serde::{Deserialize, Serialize};
1414

1515
const WASM_FILEPATH: &str = "../target/near/eth2_client/eth2_client.wasm";
1616
const WASM_V_0_1_0_FILEPATH: &str = "src/data/eth2_client_v0.1.0_testnet.wasm";
1717

1818
#[derive(Debug, Clone, BorshSerialize, BorshDeserialize, Serialize, Deserialize)]
19-
struct BlockHeaderV1 {
19+
struct BlockHeaderV1 {
2020
pub parent_hash: H256,
2121
pub uncles_hash: H256,
2222
pub author: Address,
@@ -43,14 +43,14 @@ mod sepolia_integration_tests {
4343
pub partial_hash: Option<H256>,
4444
}
4545

46-
impl From<eth_types::BlockHeader> for BlockHeaderV1 {
46+
impl From<eth_types::BlockHeader> for BlockHeaderV1 {
4747
fn from(item: eth_types::BlockHeader) -> Self {
4848
serde_json::from_str(&serde_json::to_string(&item).unwrap()).unwrap()
4949
}
5050
}
5151

5252
#[derive(Clone, BorshDeserialize, BorshSerialize)]
53-
struct InitInputV1 {
53+
struct InitInputV1 {
5454
pub network: String,
5555
pub finalized_execution_header: BlockHeaderV1,
5656
pub finalized_beacon_header: ExtendedBeaconBlockHeader,
@@ -63,7 +63,7 @@ mod sepolia_integration_tests {
6363
pub trusted_signer: Option<near_sdk::AccountId>,
6464
}
6565

66-
impl From<InitInput> for InitInputV1 {
66+
impl From<InitInput> for InitInputV1 {
6767
fn from(message: InitInput) -> Self {
6868
Self {
6969
network: message.network,
@@ -91,9 +91,14 @@ mod sepolia_integration_tests {
9191
let alice = owner
9292
.create_subaccount("alice")
9393
.initial_balance(NearToken::from_near(30))
94-
.transact().await?
94+
.transact()
95+
.await?
9596
.into_result()?;
96-
let _ = contract.call("init").args_borsh(init_input).transact().await?;
97+
let _ = contract
98+
.call("init")
99+
.args_borsh(init_input)
100+
.transact()
101+
.await?;
97102
Ok((alice, contract))
98103
}
99104

@@ -117,10 +122,12 @@ mod sepolia_integration_tests {
117122
update.finality_update.header_update.execution_block_hash = last;
118123

119124
// Submit the light‐client update
120-
let outcome = alice.call(contract.id(), "submit_beacon_chain_light_client_update")
125+
let outcome = alice
126+
.call(contract.id(), "submit_beacon_chain_light_client_update")
121127
.args_borsh(update)
122128
.gas(Gas::from_tgas(300))
123-
.transact().await?;
129+
.transact()
130+
.await?;
124131
assert!(outcome.is_success(), "update failed");
125132

126133
// Submit execution headers in reverse order
@@ -130,7 +137,7 @@ mod sepolia_integration_tests {
130137
tx = tx.call(
131138
Function::new("submit_execution_header")
132139
.args(borsh::to_vec(h)?)
133-
.gas(Gas::from_tgas(6))
140+
.gas(Gas::from_tgas(6)),
134141
);
135142
}
136143
let result = tx.transact().await?;
@@ -139,14 +146,14 @@ mod sepolia_integration_tests {
139146

140147
// Verify that each block’s hash is stored
141148
for h in slice {
142-
let result: Option<H256> = contract.view("block_hash_safe")
143-
.args_borsh(h.number).await?
149+
let result: Option<H256> = contract
150+
.view("block_hash_safe")
151+
.args_borsh(h.number)
152+
.await?
144153
.borsh()?;
145154
assert!(result.is_some(), "block {} missing", h.number);
146155
}
147156

148157
Ok(())
149158
}
150-
151-
152159
}

contracts/near/rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "1.84.0"
2+
channel = "1.86.0"

0 commit comments

Comments
 (0)