Skip to content

Commit 644528f

Browse files
ci: add a ci to compile and lint the batcher libs (#676)
1 parent e46024f commit 644528f

5 files changed

Lines changed: 52 additions & 11 deletions

File tree

.github/workflows/build-rust.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: build-rust-projects
2+
3+
on:
4+
merge_group:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: ["*"]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Rust
18+
uses: actions-rs/toolchain@v1
19+
with:
20+
toolchain: stable
21+
components: rustfmt, clippy
22+
override: true
23+
- name: Cache Rust dependencies
24+
uses: actions/cache@v3
25+
with:
26+
path: |
27+
~/.cargo/registry
28+
~/.cargo/git
29+
batcher/target
30+
key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }}
31+
restore-keys: |
32+
${{ runner.os }}-rust-
33+
- name: Check formatting of Rust projects
34+
run: |
35+
cd batcher
36+
cargo fmt --all -- --check
37+
- name: Run Clippy
38+
run: |
39+
cd batcher
40+
cargo clippy --all -- -D warnings
41+
- name: Build Rust projects
42+
run: |
43+
cd batcher
44+
cargo build --all

batcher/aligned-batcher/src/lib.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,8 @@ impl Batcher {
217217
if let Ok(addr) = client_msg.verify_signature() {
218218
info!("Message signature verified");
219219
if self.is_nonpaying(&addr) {
220-
return self
221-
.handle_nonpaying_msg(ws_conn_sink.clone(), client_msg)
222-
.await;
220+
self.handle_nonpaying_msg(ws_conn_sink.clone(), client_msg)
221+
.await
223222
} else {
224223
if !self.check_user_balance(&addr).await {
225224
send_message(
@@ -267,7 +266,7 @@ impl Batcher {
267266
info!("Verification data message handled");
268267

269268
send_message(ws_conn_sink, ValidityResponseMessage::Valid).await;
270-
return Ok(());
269+
Ok(())
271270
}
272271
} else {
273272
error!("Signature verification error");
@@ -284,7 +283,7 @@ impl Batcher {
284283
// If user has sufficient balance, increments the user's proof count in the batch
285284
async fn check_user_balance(&self, addr: &Address) -> bool {
286285
let mut user_proof_counts = self.user_proof_count_in_batch.lock().await;
287-
let user_proofs_in_batch = user_proof_counts.get(addr).unwrap_or(&0).clone() + 1;
286+
let user_proofs_in_batch = *user_proof_counts.get(addr).unwrap_or(&0) + 1;
288287

289288
let user_balance = self.get_user_balance(addr).await;
290289

batcher/aligned-sdk/src/communication/messaging.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ pub async fn send_messages(
3030
ws_write: Arc<Mutex<SplitSink<WebSocketStream<MaybeTlsStream<TcpStream>>, Message>>>,
3131
verification_data: &[VerificationData],
3232
wallet: Wallet<SigningKey>,
33-
nonce: U256,
33+
mut nonce: U256,
3434
) -> Result<Vec<NoncedVerificationData>, SubmitError> {
3535
let mut sent_verification_data = Vec::new();
3636

3737
let mut ws_write = ws_write.lock().await;
3838

39-
let mut nonce = nonce.clone();
4039
let mut nonce_bytes = [0u8; 32];
4140

4241
let mut response_stream = response_stream.lock().await;

batcher/aligned/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,9 @@ async fn main() -> Result<(), AlignedError> {
324324
unique_batch_merkle_roots.insert(aligned_verification_data.batch_merkle_root);
325325
}
326326

327-
if unique_batch_merkle_roots.len() > 1 {
328-
info!("Proofs submitted to aligned. See the batches in the explorer:");
329-
} else if unique_batch_merkle_roots.len() == 1 {
330-
info!("Proofs submitted to aligned. See the batch in the explorer:");
327+
match unique_batch_merkle_roots.len() {
328+
1 => info!("Proofs submitted to aligned. See the batch in the explorer:"),
329+
_ => info!("Proofs submitted to aligned. See the batches in the explorer:"),
331330
}
332331

333332
for batch_merkle_root in unique_batch_merkle_roots {

0 commit comments

Comments
 (0)