8000
Skip to content

Conversation

@SWvheerden
Copy link
Collaborator
@SWvheerden SWvheerden commented Nov 5, 2025

Description

upgrades pgp to a newer version

Summary by CodeRabbit

  • Dependencies

    • Updated PGP library to version 0.18.
  • Bug Fixes/Improvements

    • Updated cryptographic signature handling for enhanced compatibility.
    • Changed default transport mechanism to Tor.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor
coderabbitai bot commented Nov 5, 2025

Walkthrough

The pgp dependency is upgraded from 0.14.2 to 0.18, and the codebase is updated to use the new pgp::composed module types for SignedPublicKey and DetachedSignature. Additionally, the default TransportType variant is changed from Tcp to Tor.

Changes

Cohort / File(s) Summary
Dependency Upgrade
base_layer/p2p/Cargo.toml
pgp dependency bumped from 0.14.2 to 0.18 (optional feature unchanged)
PGP API Migration
base_layer/p2p/src/auto_update/mod.rs, base_layer/p2p/src/auto_update/signature.rs
Type paths updated to use pgp::composed module variants: StandaloneSignature → DetachedSignature, direct types → pgp::composed::SignedPublicKey; parsing logic adjusted for new API; maintainer key and signature handling refactored
Default Transport Type
base_layer/p2p/src/transport.rs
TransportType enum default variant switched from Tcp to Tor via #[default] attribute relocation

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify pgp 0.18 API compatibility for composed types (DetachedSignature, SignedPublicKey) in auto_update/mod.rs and signature.rs
  • Confirm type migrations maintain correct deserialization and verification logic for PGP signatures
  • Validate that the default TransportType change to Tor is intentional and does not affect existing behavior negatively

Poem

🐰 The pgp grew stronger, ve 8000 rsion by version,
Composed types now guide us with steady conversion,
And Tor takes the lead where TCP once stood—
Hops through the rabbit hole, faster and good! 🌙

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title claims upgrading pgp to 0.17, but the actual changes show upgrading pgp from 0.14.2 to 0.18. Update the PR title to accurately reflect the change: 'chore: upgrade pgp to 0.18' instead of 0.17.
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8fe8028 and 1e9684e.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • base_layer/p2p/Cargo.toml (1 hunks)
  • base_layer/p2p/src/auto_update/mod.rs (3 hunks)
  • base_layer/p2p/src/auto_update/signature.rs (4 hunks)
  • base_layer/p2p/src/transport.rs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • base_layer/p2p/src/auto_update/mod.rs
  • base_layer/p2p/Cargo.toml
  • base_layer/p2p/src/auto_update/signature.rs
  • base_layer/p2p/src/transport.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Cucumber tests / FFI
  • GitHub Check: Cucumber tests / Base Layer
  • GitHub Check: cargo check with msrv
  • GitHub Check: cargo check with stable
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: ci
  • GitHub Check: ledger build tests
  • GitHub Check: wasm build tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
base_layer/p2p/src/auto_update/signature.rs (1)

143-159: Update test code to use pgp 0.17 API.

The test code still references the old pgp API which will cause compilation errors. Update the types to use the pgp::composed namespace.

Apply this diff to fix the tests:

     #[test]
     fn it_verifies_signed_message() {
-        let (sig, _) = pgp::StandaloneSignature::from_string(VALID_SIGNATURE.trim()).unwrap();
-        let (key, _) = pgp::SignedPublicKey::from_string(PUBLIC_KEY).unwrap();
+        let (sig, _) = pgp::composed::DetachedSignature::from_string(VALID_SIGNATURE.trim()).unwrap();
+        let (key, _) = pgp::composed::SignedPublicKey::from_string(PUBLIC_KEY).unwrap();
         let verifier = SignedMessageVerifier::new(vec![key]);
         let signer = verifier.verify_signature(&sig, MESSAGE).unwrap();
 
-        let (maintainer, _) = pgp::SignedPublicKey::from_string(PUBLIC_KEY).unwrap();
+        let (maintainer, _) = pgp::composed::SignedPublicKey::from_string(PUBLIC_KEY).unwrap();
         assert_eq!(*signer, maintainer);
     }
 
     #[test]
     fn it_does_not_validate_with_tampered_message() {
-        let (sig, _) = pgp::StandaloneSignature::from_string(VALID_SIGNATURE.trim()).unwrap();
+        let (sig, _) = pgp::composed::DetachedSignature::from_string(VALID_SIGNATURE.trim()).unwrap();
         let verifier = SignedMessageVerifier::new(maintainers().collect());
         assert!(verifier.verify_signature(&sig, "Zilip R. Phimmermann").is_none());
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18b38f8 and 04106e6.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • base_layer/p2p/Cargo.toml (1 hunks)
  • base_layer/p2p/src/auto_update/mod.rs (3 hunks)
  • base_layer/p2p/src/auto_update/signature.rs (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
base_layer/p2p/src/auto_update/signature.rs (1)
base_layer/p2p/src/auto_update/mod.rs (1)
  • maintainers (205-210)
base_layer/p2p/src/auto_update/mod.rs (1)
base_layer/p2p/src/auto_update/signature.rs (1)
  • new (31-33)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: wasm build tests
  • GitHub Check: ledger build tests
  • GitHub Check: ci
  • GitHub Check: cargo check with stable
  • GitHub Check: cargo check with msrv
  • GitHub Check: Cucumber tests / Base Layer
  • GitHub Check: Cucumber tests / FFI
🔇 Additional comments (6)
base_layer/p2p/src/auto_update/mod.rs (3)

26-26: LGTM!

The import correctly uses the new pgp::composed::Deserializable path for pgp 0.17.


190-196: LGTM!

The function signature and deserialization logic have been correctly updated to use pgp::composed::DetachedSignature from pgp 0.17.


205-210: LGTM!

The iterator return type and key deserialization have been correctly migrated to use pgp::composed::SignedPublicKey from pgp 0.17.

base_layer/p2p/src/auto_update/signature.rs (3)

27-33: LGTM!

The struct field and constructor have been correctly updated to use pgp::composed::SignedPublicKey from pgp 0.17.


35-52: LGTM!

The method signature correctly uses pgp::composed::DetachedSignature from pgp 0.17.


54-62: LGTM!

The helper method signature has been correctly updated to use pgp::composed::DetachedSignature and pgp::composed::SignedPublicKey from pgp 0.17.

@SWvheerden SWvheerden requested a review from a team as a code owner November 6, 2025 06:42
Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
base_layer/transaction_components/src/transaction_components/output_type.rs (1)

48-52: Add a quick test asserting the default variant

To lock this change in, assert that OutputType::default() == Standard.

Apply within the existing tests:

@@
     #[test]
     fn it_converts_from_byte_to_output_type() {
+        assert_eq!(OutputType::default(), OutputType::Standard);
         assert_eq!(OutputType::from_byte(0), Some(OutputType::Standard));
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 04106e6 and 8fe8028.

📒 Files selected for processing (12)
  • applications/minotari_console_wallet/src/automation/commands.rs (1 hunks)
  • applications/minotari_console_wallet/src/ui/state/app_state.rs (1 hunks)
  • applications/minotari_node/src/commands/parser.rs (1 hunks)
  • base_layer/common_types/src/payment_reference.rs (1 hunks)
  • base_layer/core/tests/tests/block_validation.rs (1 hunks)
  • base_layer/p2p/src/auto_update/signature.rs (4 hunks)
  • base_layer/p2p/src/transport.rs (2 hunks)
  • base_layer/transaction_components/src/transaction_components/output_type.rs (1 hunks)
  • base_layer/transaction_components/src/transaction_components/range_proof_type.rs (1 hunks)
  • base_layer/transaction_components/src/transaction_components/test.rs (2 hunks)
  • base_layer/wallet/src/transaction_service/config.rs (1 hunks)
  • comms/dht/examples/memorynet.rs (1 hunks)
🧰 Additional context used
🧠 Learnings (9)
📚 Learning: 2025-06-14T04:56:43.247Z
Learnt from: hansieodendaal
Repo: tari-project/tari PR: 7216
File: base_layer/core/src/base_node/comms_interface/comms_request.rs:146-148
Timestamp: 2025-06-14T04:56:43.247Z
Learning: In the Tari codebase, `HashOutput` is a type alias for `FixedHash`, and `FixedHash` already implements `Display` trait with hex formatting by calling `self.0.to_hex()` internally. This means when formatting `HashOutput` values, there's no need to explicitly call `.to_hex()` as the Display implementation handles hex conversion automatically.

Applied to files:

  • base_layer/transaction_components/src/transaction_components/output_type.rs
  • applications/minotari_node/src/commands/parser.rs
📚 Learning: 2025-10-03T10:21:49.027Z
Learnt from: hansieodendaal
Repo: tari-project/tari PR: 7514
File: base_layer/transaction_components/src/transaction_builder/builder.rs:704-752
Timestamp: 2025-10-03T10:21:49.027Z
Learning: In base_layer/transaction_components/src/transaction_builder/builder.rs, the change_encrypted_data_if_fee_changed helper should only update fees in MemoField instances that already contain a fee (when get_fee() returns Some). It should not set fees in memos where get_fee() returns None, as not all outputs require fees in their memos.

Applied to files:

  • base_layer/transaction_components/src/transaction_components/test.rs
  • applications/minotari_console_wallet/src/ui/state/app_state.rs
📚 Learning: 2025-05-23T07:49:57.349Z
Learnt from: hansieodendaal
Repo: tari-project/tari PR: 6963
File: common_sqlite/src/error.rs:88-92
Timestamp: 2025-05-23T07:49:57.349Z
Learning: In the StorageError enum in common_sqlite/src/error.rs, the HexError variant should keep the manual From<HexError> implementation rather than using #[from] attribute, as it stores a String representation of the error rather than the HexError type itself.

Applied to files:

  • applications/minotari_node/src/commands/parser.rs
📚 Learning: 2025-07-09T08:33:29.320Z
Learnt from: hansieodendaal
Repo: tari-project/tari PR: 7294
File: comms/dht/src/network_discovery/seed_strap.rs:352-456
Timestamp: 2025-07-09T08:33:29.320Z
Learning: In comms/dht/src/network_discovery/seed_strap.rs, the NUM_RETRIES logic in get_peers is specifically designed to handle peer connections that are closed while trying to RPC stream peer info, not general connection failures. The retry logic only applies when peers.is_empty() && !conn.is_connected() && attempt < NUM_RETRIES, which indicates a mid-stream disconnection.

Applied to files:

  • comms/dht/examples/memorynet.rs
📚 Learning: 2025-07-09T08:33:29.320Z
Learnt from: hansieodendaal
Repo: tari-project/tari PR: 7294
File: comms/dht/src/network_discovery/seed_strap.rs:352-456
Timestamp: 2025-07-09T08:33:29.320Z
Learning: In comms/dht/src/network_discovery/seed_strap.rs, the fetch_peers_from_connection and collect_peer_stream functions rely on RPC streaming, and when the main connection is closed by another process, collect_peer_stream times out after STREAM_ITEM_TIMEOUT because it cannot detect that the peer can no longer respond, returning an empty vector of peers. This is why the connection state check is important for the retry logic.

Applied to files:

  • comms/dht/examples/memorynet.rs
📚 Learning: 2025-06-16T14:49:31.831Z
Learnt from: martinserts
Repo: tari-project/tari PR: 7122
File: base_layer/wallet/src/transaction_service/offline_signing/one_sided_signer.rs:0-0
Timestamp: 2025-06-16T14:49:31.831Z
Learning: In Tari's one-sided transaction offline signing implementation, the script_keys vector in the script offset calculation should only include input.output.script_key_id, not output script keys, change output script keys, or recipient script keys. This is by design for the one-sided transaction protocol.

Applied to files:

  • applications/minotari_console_wallet/src/automation/commands.rs
  • base_layer/core/tests/tests/block_validation.rs
📚 Learning: 2025-07-15T12:23:14.650Z
Learnt from: hansieodendaal
Repo: tari-project/tari PR: 7284
File: applications/minotari_console_wallet/src/automation/commands.rs:0-0
Timestamp: 2025-07-15T12:23:14.650Z
Learning: In applications/minotari_console_wallet/src/automation/commands.rs, the consistent error handling pattern for command execution is to use match statements that: 1) On success: log with debug!, print user feedback, and push tx_id to tx_ids vector for monitoring, 2) On error: print error message with eprintln! using the format "{CommandName} error! {}", rather than using .unwrap() which would panic.

Applied to files:

  • applications/minotari_console_wallet/src/automation/commands.rs
  • applications/minotari_console_wallet/src/ui/state/app_state.rs
📚 Learning: 2025-08-11T15:37:17.354Z
Learnt from: hansieodendaal
Repo: tari-project/tari PR: 7387
File: base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs:2896-2927
Timestamp: 2025-08-11T15:37:17.354Z
Learning: The `update_accumulated_difficulty` method in `base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs` is migration-specific code that only runs during a once-off migration when existing ChainHeader data is present in LMDB. The consistency guarantees are upheld by the calling function `process_accumulated_data_for_height`, so additional validation within this method is redundant.

Applied to files:

  • applications/minotari_console_wallet/src/automation/commands.rs
📚 Learning: 2025-09-08T08:43:50.910Z
Learnt from: MCozhusheck
Repo: tari-project/tari PR: 7478
File: base_layer/p2p/src/signature_verification/gpg_keys/seed_peers_http.asc:1-15
Timestamp: 2025-09-08T08:43:50.910Z
Learning: In the Tari codebase, temporary test PGP keys for signature verification are acceptable during development phases when they will be replaced with production keys before final release. The maintainers prefer to keep the implementation simple during drafts rather than over-engineering with test-only conditionals for temporary keys.

Applied to files:

  • base_layer/p2p/src/auto_update/signature.rs
🧬 Code graph analysis (3)
base_layer/transaction_components/src/transaction_components/test.rs (1)
base_layer/transaction_components/src/transaction_components/transaction_output.rs (2)
  • outputs (545-549)
  • outputs (572-576)
comms/dht/examples/memorynet.rs (1)
comms/dht/examples/memory_net/utilities.rs (1)
  • make_node (639-659)
base_layer/p2p/src/auto_update/signature.rs (1)
base_layer/p2p/src/auto_update/mod.rs (1)
  • maintainers (205-210)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: cargo check with msrv
  • GitHub Check: test (mainnet, stagenet)
  • GitHub Check: test (testnet, esmeralda)
  • GitHub Check: test (nextnet, nextnet)
  • GitHub Check: cargo check with stable
  • GitHub Check: wasm build tests
  • GitHub Check: ledger build tests
  • GitHub Check: ci
  • GitHub Check: Cucumber tests / FFI
  • GitHub Check: Cucumber tests / Base Layer
🔇 Additional comments (16)
applications/minotari_console_wallet/src/ui/state/app_state.rs (1)

753-754: LGTM: Efficient migration from Vec to slice reference.

The change from vec![txn.into()] to &[txn.into()] is a good optimization that avoids unnecessary heap allocation for a single-item collection. The temporary array lives long enough for the function call and await, and this aligns with the function signature expecting &[CompletedTransaction].

comms/dht/examples/memorynet.rs (1)

86-95: LGTM! Appropriate use of array literal for fixed-size collection.

The change from a Vec to an array for the single seed node is correct and slightly more efficient (stack-allocated vs heap-allocated). Since seed_node is never mutated and always contains exactly one element, an array is the appropriate choice.

Note: This refactor appears unrelated to the pgp upgrade mentioned in the PR title, but it's a reasonable cleanup.

base_layer/transaction_components/src/transaction_components/test.rs (2)

252-260: LGTM! Array literal is a valid optimization.

The change from vec![...] to an array literal [...] is functionally equivalent and slightly more efficient since it avoids an initial heap allocation before collecting references.


263-266: LGTM! Consistent with the earlier change.

The tampering test correctly uses the same array literal pattern, maintaining consistency with the earlier modification while preserving the test's validation logic.

base_layer/p2p/src/transport.rs (1)

89-103: Default TransportType is now Tor — confirm intended behavior

Deriving Default with #[default] on Tor makes TransportConfig::default() choose Tor by default. If this differs from the prior impl, it alters out-of-the-box transport. Please confirm this default is intentional and update docs/config examples if needed.

base_layer/transaction_components/src/transaction_components/range_proof_type.rs (1)

43-47: LGTM: derive(Default) with BulletProofPlus as default

Matches existing tests and reduces boilerplate.

applications/minotari_node/src/commands/parser.rs (1)

39-45: LGTM: derive(Default) for Format with Text default

Removes boilerplate; behavior remains Text by default.

base_layer/wallet/src/transaction_service/config.rs (1)

94-100: LGTM; confirm default routing remains unchanged

Default is now provided via derive(Default) with DirectAndStoreAndForward. Please confirm this matches the prior manual Default and update any docs if they mention defaults explicitly.

base_layer/common_types/src/payment_reference.rs (1)

178-187: LGTM: default PayRef display is Shortened

Good ergonomic default; implementation remains straightforward.

base_layer/core/tests/tests/block_validation.rs (1)

294-296: LGTM: migrated to slice-based get_script_offset

Callsite matches new signature and retains intent.

base_layer/p2p/src/auto_update/signature.rs (6)

26-33: Type migration looks correct and consistent.

The struct and constructor have been properly updated to use pgp::composed::SignedPublicKey. The related maintainers() function in auto_update/mod.rs also returns this type, ensuring API compatibility.


35-52: Type migration to DetachedSignature is semantically appropriate.

The change from StandaloneSignature to DetachedSignature aligns with the signature verification pattern where the signature is separate from the signed data (the hashes string).


67-67: Import update is consistent with the pgp 0.17 module structure.


144-152: Test updated correctly for new pgp types.

The test properly uses pgp::composed::DetachedSignature and pgp::composed::SignedPublicKey with the from_string constructor. The test logic remains unchanged.


154-159: Negative test case correctly updated.

The test properly validates that signature verification fails with a tampered message using the new pgp types.


54-62: API compatibility verified for pgp 0.17.

The verify() method in pgp 0.17 accepts (&self, pub_key: &SignedPublicKey, data: &[u8]) and returns Result<()>. The code at line 61 correctly calls signature.verify(pk, message.as_bytes()).is_ok(), which matches this signature. Tests at lines 143–159 validate this functionality.

Copy link
Contributor
@hansieodendaal hansieodendaal left a comment

Choose a reason for hiding this comment

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

Looks good, except for the one issue that looks like a copy-paste problem.

Comment on lines 1492 to 1493
std::slice::from_ref(&party_info.pre_mine_script_key_id),
std::slice::from_ref(&party_info.pre_mine_script_key_id),
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems wrong - copy-paste problem?

@leet4tari leet4tari changed the title chore: upgrade pgp to 0.17 chore: upgrade pgp to 0.18 Dec 18, 2025
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.

2 participants

0