Skip to content

Conversation

@vsavchyn-dev
Copy link

Checklist

  • App update process has been followed
  • Target branch is develop
  • Application version has been bumped

Copy link
Contributor

@frol frol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no new screenshots, so I assume that there are not enough tests added

for _i in 0..(chunks as usize) {
stream.read_exact(&mut buf)?;
}
stream.read_exact(&mut buf[0..(remainder as usize)])?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it work well if the remainder is 0 and thus stream.read_exact(buf[0..0])?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. For instance, if we transfer 100 character long contract (making remainder 0), using near-cli-rs, the hash would be the same both on ledger and cli for checking.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, a read function implementation for io::Read trait always tries to check if there is something in buffer, so hash shouldn't be impacted (src/parsing/transaction_stream_reader/mod.rs):

impl<R: io::Read> io::Read for HashingStream<R> {
    fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
        if !buf.is_empty() {
            let n = self.reader.read(buf)?;

            // update hash on each chunk passing through
            if n > 0 {
                let data = &buf[0..n];
                self.sha256
                    .update(data)
                    .map_err(|_err| io::Error::from(io::ErrorKind::OutOfMemory))?;
            }
            return Ok(n);
        }
        Ok(0)
    }
}

Comment on lines 32 to 33
GlobalContractDeployMode::CodeHash => "Code hash (immutable)",
GlobalContractDeployMode::AccountId => "Account Id (mutable)",
Copy link
Contributor

@frol frol Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is not a menu of items that users will be able to select, and they will only see one or the other, I believe it can be confusing:

Deploy mode
Code hash (immutable)

As a user I start to ask myself:

  1. What is "immutable"? It is quite a niche term and yet not well-defined in this context
  2. Does "immutable" mean that I won't ever be able to deploy another contract to the account? (not true - another contract can be deployed to the account)
  3. Are there "mutable" contracts? How to mutate them?
Deploy mode
Account Id (mutable)
  1. Aren't all contracts deployed to some account id?
  2. How "mutable" is the deployment?

I suggest to change it to one of these two options (or suggest something better based on how it looks on the screen):

Option 1:
"Can Be Used"
"by Code Hash"
"by Account ID (auto-upgrade everywhere it is used)"

Option 2:
"Deploy Mode"
"New global contract that can be used by contract hash"
"Auto-update all accounts that use the global contract by the Account ID"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My logic was to use the annotations/strings from near-cli-rs, so people could reference that and double-check themselves. Despite this, I did find it confusing as well when trying to sign it like that :|

Hence, option 1 makes the most sense to me - concise + can see it in 1 screen. Like: Action? Global Contract -> Hash for contract? Here is SHA256 -> How can/will it be used? by code hash or account id

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vsavchyn-dev We will need to update near-cli-rs messaging as well. It is not set in stone

Copy link
Contributor

@frol frol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vsavchyn-dev Thank you for quickly addressing my review comments. I believe this PR is in a good shape to be reviewed by the Ledger team

@frol
Copy link
Contributor

frol commented Aug 6, 2025

@tdejoigny-ledger @fbeutin-ledger This PR is ready for your review

@tdejoigny-ledger
Copy link
Contributor

@frol it seems that there are still some failures in the CI and then a sec audit will be required.
cc: @vforgeoux-ledger

@vsavchyn-dev
Copy link
Author

@tdejoigny-ledger I've updated both ledger-device-sdk to 1.24.5 and ledger-secure-sdk-sys to the latest version as requested. However, I've encountered an issue with Nano devices that will fail tests:

  • ledger-device-sdk versions 1.23.0 and previous versions seem to work fine
  • ledger-device-sdk versions 1.24.0+ cause segfaults on Nano devices (Nano X, Nano S+)
  • The segfault occurs when sending any APDU to the nano device
  • Stax/Flex devices appear unaffected

I've tested this extensively using Speculos emulation, test helper that we have, and reusable workflow script that was failing (check_rust_sdk.sh). I confirmed the segfault consistently occurs at the bagl_hal_draw_bitmap_within_rect syscall, which suggests the issue is related to logo/bitmap display functionality that likely was modified in ledger-device-sdk 1.24.0+.

The problem appears to be isolated to either:

  1. Changes in ledger-device-sdk 1.24.0+ affecting image rendering.
  2. Compatibility issues with the include-gif crate and the new SDK (I saw it was updated when I ran cargo update ledger_device_sdk).

Are there any known fixes to this issue or is there anything else I can do to resolve this issue?

cc: @vforgeoux-ledger

@tdejoigny-ledger
Copy link
Contributor

@yogh333 Do you have any idea what the problem is here?

@yogh333
Copy link
Contributor

yogh333 commented Aug 29, 2025

@yogh333 Do you have any idea what the problem is here?

I will have a look

@yogh333
Copy link
Contributor

yogh333 commented Aug 29, 2025

@vsavchyn-dev @frol Hi I have fixed the issue with this PR: #30
If it is ok for you, I can merge the PR then you will have to rebase yours.

FYI @tdejoigny-ledger @vforgeoux-ledger

@vsavchyn-dev
Copy link
Author

@yogh333 Thanks for looking into this issue! That would be great if you can merge pr #30 so I can proceed with rebasing this one.

@vsavchyn-dev
Copy link
Author

vsavchyn-dev commented Aug 29, 2025

@tdejoigny-ledger checks for nanosp and nanox pass now. You also mentioned something about security audit, right?

cc: @frol @vforgeoux-ledger

@tdejoigny-ledger
Copy link
Contributor

@vsavchyn-dev yes good news ! the CI is 🟢
yes a security audit of the changes are required.

@frol
Copy link
Contributor

frol commented Aug 29, 2025

@tdejoigny-ledger are you referring to a full scale security audit? This sounds like an overkill for the change that just adds two new types of transaction action. Can you just take my review as attestation that this change matches the new protocol feature and implements it fully as in spec?

@tdejoigny-ledger
Copy link
Contributor

@tdejoigny-ledger are you referring to a full scale security audit? This sounds like an overkill for the change that just adds two new types of transaction action. Can you just take my review as attestation that this change matches the new protocol feature and implements it fully as in spec?

hello @frol as I said a security audit needs to be conducted for these changes.

@frol
Copy link
Contributor

frol commented Sep 9, 2025

@tdejoigny-ledger we don't have the capacity to conduct the audit, so we will leave it here as is in case you will ever have the capacity to review it.

@tdejoigny-ledger
Copy link
Contributor

@tdejoigny-ledger we don't have the capacity to conduct the audit, so we will leave it here as is in case you will ever have the capacity to review it.

Hello @frol
Indeed, all the apps provided on Ledger Live must be audited, there are no exceptions. I thought you were aware.

@frol
Copy link
Contributor

frol commented Sep 10, 2025

@tdejoigny-ledger I'd like to see the confirmation that all these changes received the audit:

image

Some of them did not have a single peer review, others do not even pass your CI, and the ones that add new functionality (#12, #17) did not have a single test case added.

I thought you either follow the process always, or make the exceptions for quality contributions - we added extensive testing, did peer reviews, and only involved you after we got extensive testing on our side.

Security audit is just another human reading the code. Be that human for this PR.

@karim-en
Copy link

karim-en commented Dec 17, 2025

@tdejoigny-ledger
Can we expect that this PR will be merged some day?
The Omni bridge team from NearOne rely on these new features, so it is very important to release it asap.

Regarding the audit, the bridge and other teams from Near eco can allocate resources if needed to review these changes. From my perspective these reviews will be more valuable than side audit by auditors who aren't familiar with the ecosystem.

@tdejoigny-ledger
Copy link
Contributor

@tdejoigny-ledger Can we expect that this PR will be merged some day? The Omni bridge team from NearOne rely on these new features, so it is very important to release it asap.

Regarding the audit, the bridge and other teams from Near eco can allocate resources if needed to review these changes. From my perspective these reviews will be more valuable than side audit by auditors who aren't familiar with the ecosystem.

Hello @karim-en , it’s important to distinguish a functional review, which is always welcome and essential; from the security review, which focuses on security vulnerabilities/weaknesses and is mandatory to publish an app on our LW store.

@frol
Copy link
Contributor

frol commented Dec 18, 2025

@tdejoigny-ledger I assume you have an ongoing engagement with some audit company, can you ask them to audit this PR just like you do for other PRs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants