Repository navigation
Conversation
|
This PR targeted I retargeted it to |
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
5c40fe6 to
87b4f1e
Compare
|
Legatus audit: Approved (commit 87b4f1e) Re-review of PR #438 (DXP-599) at
|
|
/run-e2e all |
|
E2E status was updated. Follow the current E2E and merge checks on this PR. Detailed diagnostics are available internally. |
|
Moved to draft on purpose, not because of a problem found in the code. |
danieljrc888
left a comment
There was a problem hiding this comment.
Reviewed at 87b4f1e. The signing core is careful (address check before every signature, signer recovery after, native modules optional and lazily loaded, keystore path untouched) and nothing here can broadcast a wrong transaction. It still must not ship until it has been exercised on a physical device, and these need fixing first:
1. Signing dependencies float (package.json:85-87)
@ledgerhq/device-management-kit, @ledgerhq/device-signer-kit-ethereum and @ledgerhq/device-transport-kit-node-hid use caret ranges, and @ledgerhq/context-module comes in as an undeclared peer. The lockfile is not published, so every npm i -g genlayer resolves whatever is current at install time, not what was reviewed. For code that signs with user funds, pin exact versions (including the context module) and let Renovate bump them on purpose.
2. Default Ledger context module, undisclosed (src/lib/accounts/ledgerDevice.ts:54)
new SignerEthBuilder({dmk, sessionId}).build() uses the default context module, which contacts Ledger's hosted services during signing (network and contract metadata lookups, and transaction checks when the user accepts them on the device). GenLayer chains are not known to those services, so this adds a network dependency and sends chain id and target address to a third party for no benefit, while the README implies only the device is involved. Build the signer with a context module that has the remote loaders removed, or make it opt-in and document it. Please confirm the exact calls against the DMK version you pin.
3. Misleading error for operator proofs with a Ledger owner (src/commands/staking/StakingAction.ts:229, src/commands/vesting/VestingAction.ts:99, hint in validatorJoin.ts)
With a Ledger owner and no --operator, validator join, the wizard join and vesting validator-create fail with "Invalid keystore format.", and the hint says to omit --operator to use the owner account, which cannot work for Ledger. Detect the Ledger account type and say that a Ledger account cannot sign the operator proof and a local keystore account must be passed with --operator.
4. signMessage is weaker than signTransaction (src/lib/accounts/ledger.ts:88-97)
It does not verify the recovered address, and it passes JS strings straight to the device kit, so a non-ASCII message can sign different bytes than viem's UTF-8 meaning. Always pass bytes and verify with recoverMessageAddress.
5. No-device case (ledgerDevice.ts:51)
With no device attached, discovery errors immediately with a device-kit error object that is not an Error and has no message, so the 15 second wait never happens and the CLI prints a raw object. Poll until the timeout and map the device-kit errors (no device, locked, app not open, blind signing disabled, user rejected) to readable messages.
Not covered by any test: every test mocks the transport or the whole device kit. Real device state machine, HID permissions, v/parity for the GenLayer chain ids, large deploy calldata, and what the device displays (all contract writes need blind signing) are unverified. Also the README Ledger section sits after the License section.
|
Legatus audit: Changes requested (commit 3f7b7d6) Re-review of PR #438 (DXP-599) at
|
|
Re-reviewed at 8d46aac. The five requested changes are resolved: exact pins including the context module, the signer is built with an offline context module (checked against the installed signer kit source and with a network intercept: no outbound calls), the operator proof error, Remaining small items, please fix in this PR:
My blocking review stays until the physical-device checklist in |
|
Legatus audit: Changes requested (commit 8d46aac) Re-review of PR #438 (DXP-599) at
|
|
Checked 76a014e: the README examples, the two extra exact pins and the 6985 message are addressed. Nothing else pending in code; the physical-device validation is the only remaining gate. |
|
Legatus audit: Changes requested (commit 76a014e) Re-review of PR #438 (DXP-599) at
|
|
Legatus audit: Changes requested (commit 76a014e) Re-review of PR #438 (DXP-599) at
|
|
Legatus audit: Changes requested (commit 76a014e) Re-review of PR #438 (DXP-599) at
|
|
Legatus audit: Changes requested (commit 76a014e) Re-review of PR #438 (DXP-599) at
|
What changed
Users can import a Ledger account with
genlayer account import --name ledger --ledger, verify its address on-device, and sign CLI transactions without exporting its private key. Stored accounts contain only type, address and derivation path. Transfers, contract operations, staking and vesting use the hardware signer; read-only operations work without a connected device.Every signing request checks the connected address and verifies the recovered transaction/message signer. Errors never fall back to a cached private key. Hardware accounts cannot export private keys or unlock into the keychain. USB dependencies are optional and loaded lazily.
Ticket: https://linear.app/genlayer-labs/issue/DXP-599/sign-cli-transactions-with-hardware-wallet
Requested changes addressed
docs/ledger-validation.mdaudits the pinned source, exact endpoints, payloads and SDK call sites. Real SDK context/reporting tasks are tested with network calls forbidden, including when device transaction checks are enabled.--operator <address>must refer to a separate local software keystore. Corrected validator-join's misleading owner fallback hint. Tests cover implicit/explicit Ledger operators, the wizard's shared proof path and vesting registration.recoverMessageAddress. Tests cover Unicode, empty/raw messages, wrong keys and wrong message bytes.close()alone leaves USB hotplug listeners active.Physical-device validation remains outstanding. No Ledger was available here. The PR is deliberately draft and must not ship until a maintainer completes the checklist. No transactions were broadcast during implementation. The current PR target is
v0.41-dev; no merge or release was performed.Validation
npm test -- --run --pool=threads --maxWorkers=1: 81 files, 910 tests passed. Existing keytar tests use this Nix host's installed libsecret runtime closure viaLD_LIBRARY_PATH.npm run buildandgit diff --checkpass.docs/ledger-validation.md.npx tsc --noEmitreports the same one pre-existing diagnostic attests/actions/stakingWizard.test.ts:83as an untouched archive of the pre-review branch using the same dependencies. No new diagnostics; not changed here.Assumptions
44'/60'/0'/0/0; custom paths use the Ethereum five-component form withoutm/.Hardware qualification re-review
The remaining blocking review item is unresolved: no physical Ledger is available in this session (local USB inventory reports zero devices with Ledger vendor ID 2c97). No hardware checklist item has been marked complete, no receipts have been invented, and the PR remains draft. Added an explicit results-record template in docs/ledger-validation.md for the maintainer to record device/firmware/app, host/Node, chain IDs, receipt hashes, display observations and network evidence. This documentation commit does not qualify the signing path for release.
The README-placement observation is stale: the Ledger section is already under Account Management at README.md:404, before License at line 773, as of reviewed commit 3f7b7d6. First-accessible-device selection remains documented.
Validation rerun: npm test -- --run --maxWorkers=2 passed all 81 files / 909 tests, using the host libsecret runtime for keytar. The initial unrestricted run ended early with Vitest ERR_IPC_CHANNEL_CLOSED; limiting workers completed successfully. No application code changed in this follow-up.
Remaining small review fixes (76a014e)
genlayer account send 0x... 1gen --account ledger. Verified parsing on the built CLI with--help; no transaction was sent.Build and git diff --check pass. The full suite passed with 81 files / 910 tests using a single worker thread. The default fork-based run with maxWorkers=2 aborted with ERR_IPC_CHANNEL_CLOSED in tinypool ProcessWorker.send; no test assertion failure was reported for that aborted run.
Physical-device qualification is still unresolved; no checklist boxes or results have been fabricated. The PR stays draft until the maintainer records hardware results, clears their review, and confirms the release hold can be lifted.