Skip to content

Commit 75cefe6

Browse files
committed
Merge branch 'main' into prompt-queueing
2 parents 814e110 + cd6a72a commit 75cefe6

File tree

2 files changed

+118
-22
lines changed

2 files changed

+118
-22
lines changed

.github/workflows/rust.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
workflow_dispatch:
9+
inputs:
10+
name:
11+
description: 'Manually triggered'
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
16+
jobs:
17+
fmt:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
- uses: actions-rs/toolchain@v1
23+
with:
24+
toolchain: nightly
25+
override: true
26+
components: rust-src, rustfmt
27+
- run: rustup component add rustfmt
28+
- name: Cargo fmt
29+
uses: actions-rs/cargo@v1
30+
with:
31+
command: fmt
32+
args: --all -- --check
33+
clippy:
34+
runs-on: ubuntu-latest
35+
strategy:
36+
matrix:
37+
device: [nanos, nanox, nanosplus]
38+
env:
39+
OBJCOPY: arm-none-eabi-objcopy
40+
NM: arm-none-eabi-nm
41+
steps:
42+
- name: arm-none-eabi-gcc
43+
uses: fiam/[email protected]
44+
with:
45+
release: '9-2019-q4'
46+
- name: Checkout
47+
uses: actions/checkout@v3
48+
- name: Checkout SDK (targets)
49+
uses: actions/checkout@v3
50+
with:
51+
repository: 'alamgu/ledger-nanos-sdk'
52+
ref: memory-fixes
53+
path: rsdk
54+
- uses: actions-rs/toolchain@v1
55+
with:
56+
toolchain: nightly
57+
override: true
58+
components: rust-src, clippy
59+
- run: rustup component add clippy
60+
- name: Cargo clippy
61+
uses: actions-rs/cargo@v1
62+
with:
63+
command: clippy
64+
args: -Z build-std=core -Z build-std-features=compiler-builtins-mem --target ./rsdk/${{ matrix.device }}.json
65+
build:
66+
runs-on: ubuntu-latest
67+
strategy:
68+
matrix:
69+
device: [nanos, nanox, nanosplus]
70+
env:
71+
OBJCOPY: arm-none-eabi-objcopy
72+
NM: arm-none-eabi-nm
73+
steps:
74+
- name: arm-none-eabi-gcc
75+
uses: fiam/[email protected]
76+
with:
77+
release: '9-2019-q4'
78+
- name: Checkout
79+
uses: actions/checkout@v3
80+
- name: Checkout SDK (targets)
81+
uses: actions/checkout@v3
82+
with:
83+
repository: 'alamgu/ledger-nanos-sdk'
84+
ref: memory-fixes
85+
path: rsdk
86+
- name: Install clang
87+
run: sudo apt-get update && sudo apt install -y clang
88+
- uses: actions-rs/toolchain@v1
89+
with:
90+
toolchain: nightly
91+
override: true
92+
components: rust-src
93+
- run: echo "$PWD/rsdk/scripts" >> $GITHUB_PATH
94+
- name: Cargo build
95+
uses: actions-rs/cargo@v1
96+
with:
97+
command: build
98+
args: -Z build-std=core -Z build-std-features=compiler-builtins-mem --target ./rsdk/${{ matrix.device }}.json

src/lib.rs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -241,30 +241,28 @@ impl HostIO {
241241
Ok(ref mut s) => {
242242
if s.sent_command.is_some() {
243243
Poll::Pending
244-
} else {
245-
if s.requested_block == Some(sha) {
246-
match s.comm.borrow().get_data().ok().unwrap()[0].try_into() {
247-
Ok(HostToLedgerCmd::GetChunkResponseSuccess) => {
248-
Poll::Ready(Ok(Ref::map(s.comm.borrow(), |comm| {
249-
&comm.get_data().ok().unwrap()[1..]
250-
})))
251-
}
252-
Ok(HostToLedgerCmd::GetChunkResponseFailure) => {
253-
Poll::Ready(Err(ChunkNotFound))
254-
}
255-
_ => {
256-
error!("Reached unreachable");
257-
panic!("Unreachable: should be filtered out by protocol rules before this point.")
258-
}
244+
} else if s.requested_block == Some(sha) {
245+
match s.comm.borrow().get_data().ok().unwrap()[0].try_into() {
246+
Ok(HostToLedgerCmd::GetChunkResponseSuccess) => {
247+
Poll::Ready(Ok(Ref::map(s.comm.borrow(), |comm| {
248+
&comm.get_data().ok().unwrap()[1..]
249+
})))
250+
}
251+
Ok(HostToLedgerCmd::GetChunkResponseFailure) => {
252+
Poll::Ready(Err(ChunkNotFound))
253+
}
254+
_ => {
255+
error!("Reached unreachable");
256+
panic!("Unreachable: should be filtered out by protocol rules before this point.")
259257
}
260-
} else {
261-
s.requested_block = Some(sha);
262-
s.sent_command = Some(LedgerToHostCmd::GetChunk);
263-
let mut io = s.comm.borrow_mut();
264-
io.append(&[LedgerToHostCmd::GetChunk as u8]);
265-
io.append(&sha);
266-
Poll::Pending
267258
}
259+
} else {
260+
s.requested_block = Some(sha);
261+
s.sent_command = Some(LedgerToHostCmd::GetChunk);
262+
let mut io = s.comm.borrow_mut();
263+
io.append(&[LedgerToHostCmd::GetChunk as u8]);
264+
io.append(&sha);
265+
Poll::Pending
268266
}
269267
}
270268
Err(_) => Poll::Pending,

0 commit comments

Comments
 (0)