Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: further stack reductions for nanox support #45

Merged
merged 6 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,21 @@ speculos:

# Run firmware under speculos with QEMU debug connection
nanosplus-debug:
cd fw && speculos.py --model nanosp --display qt -k 1.0 --apdu-port 1237 --seed="$(MNEMONIC)" -d target/nanosplus/release/ledger-mob-fw
cd fw && speculos.py --model nanosp --display qt -a 1 --apdu-port 1237 $(SPECULOS_ARGS) -d target/nanosplus/release/ledger-mob-fw

# Launch GDB connecting to speculos QEMU
nanosplus-gdb:
cd fw && rust-gdb --tui fw/target/nanosplus/debug/ledger-mob-fw
cd fw && rust-gdb fw/target/nanosplus/release/ledger-mob-fw

# Objdump to show disassembly of sample_main (see `sp` for stack allocation)
objdump:
arm-none-eabi-objdump fw/target/nanosplus/release/ledger-mob-fw --disassemble=sample_main -S | head -n 20

wts-nanosplus:
wts fw/target/nanosplus/release/ledger-mob-fw -n 15
wts fw/target/nanosplus/release/ledger-mob-fw -n 20

wts-nanox:
wts fw/target/nanox/release/ledger-mob-fw -n 15
wts fw/target/nanox/release/ledger-mob-fw -n 20

# Run linters
lint: fmt clippy
Expand Down
2 changes: 2 additions & 0 deletions apdu/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ impl Digest {
}

/// Reset state digest from random seed
#[inline(never)]
pub fn from_random<R: RngCore + CryptoRng>(rng: &mut R) -> Self {
let mut b = [0u8; 32];
rng.fill_bytes(&mut b);
Expand All @@ -96,6 +97,7 @@ impl Digest {
// TODO: what if we apply an event but lose the response, will the client retry..?
// TODO: swap to tree approach, cache prior event and skip updates to allow retries
// TODO: could use [Digestible], though this adds dependencies for implementers?
#[inline(never)]
pub fn update(&mut self, evt: &[u8; 32]) -> &Self {
// Build and update digest
let mut d = Sha512_256::new();
Expand Down
6 changes: 4 additions & 2 deletions core/src/engine/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl TxDigest {
}

/// Reset transaction digest with from random seed
#[inline(never)]
pub fn from_random<R: RngCore + CryptoRng>(rng: &mut R) -> Self {
let mut b = [0u8; 32];
rng.fill_bytes(&mut b);
Expand All @@ -64,10 +65,11 @@ impl TxDigest {
}

/// Update transaction digest with new event
// TODO: what if we apply an event but lose the response, will the client retry..?
// TODO: what if we apply an event but lose the response, should the client retry..?
// TODO: swap to tree approach, cache prior event and skip updates to allow retries
// TODO: could use [Digestible], though this adds dependencies for implementers?
pub fn update(&mut self, evt: &Event<'_>) -> &Self {
#[inline(never)]
pub fn update(&mut self, evt: &Event) -> &Self {
// Build and update digest
let mut d = Sha512_256::new();

Expand Down
Loading