Skip to content

DNM: WIP: Make remaining Orchard PCZT fields optional#2552

Closed
czarcas7ic wants to merge 1 commit into
adam/pczt-remaining-after-2548-basefrom
adam/pczt-remaining-after-2548
Closed

DNM: WIP: Make remaining Orchard PCZT fields optional#2552
czarcas7ic wants to merge 1 commit into
adam/pczt-remaining-after-2548-basefrom
adam/pczt-remaining-after-2548

Conversation

@czarcas7ic

Copy link
Copy Markdown
Collaborator

DNM/WIP. This branch isolates the remaining PCZT Orchard optional-field work on a review base that matches the local stack.

It makes the remaining recomputable Orchard-shaped fields optional in the v2 wire encoding, adds MemoKind for elided enc_ciphertext reconstruction, fills derived fields before parsing/signing, and rejects anchor elision before v6.

Validation:

  • cargo fmt --all
  • cargo check -p pczt --all-features
  • cargo test -p pczt --test end_to_end --all-features
  • git diff --check


let bundle = orchard
.into_parsed_with_version(
global.tx_version,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We pass the tx version since leaving out the anchor is only valid in v6 transactions.

Comment thread pczt/src/lib.rs
Ok(Self {
/// omitting empty Transparent, Sapling, and Orchard bundles. Infallible: the v2
/// encoding can represent every in-memory PCZT.
impl From<super::Pczt> for Pczt {

@czarcas7ic czarcas7ic Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is From rather than TryFrom because v2 now represents missing Orchard derived fields as Optional, so encoding no longer needs to reject them.

Comment thread pczt/src/orchard.rs
Comment on lines +488 to +500
impl TryFrom<super::Action> for Action {
type Error = crate::EncodingError;

fn try_from(action: super::Action) -> Result<Self, Self::Error> {
Ok(Self {
// This encoding has no representation for an elided derived field;
// reject any action that has redacted one (see
// [`crate::EncodingError::RequiresV2`]).
cv_net: action.cv_net.ok_or(crate::EncodingError::RequiresV2)?,
spend: Spend::try_from(action.spend)?,
output: Output::try_from(action.output)?,
rcv: action.rcv,
}
})

@czarcas7ic czarcas7ic Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is TryFrom rather than From because v1 cannot represent missing Orchard derived fields (not Optional), so encoding must reject redacted actions.

Comment thread pczt/src/orchard.rs
/// the real anchor.
///
/// On error the bundle may be left partially filled.
pub fn fill_derived_fields(&mut self, tx_version: u32) -> Result<(), FillError> {

@czarcas7ic czarcas7ic Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

One of the primary functions to review here, which keystone call to fill in the respective elided fields.

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.

1 participant