Skip to content

feat: add annex to env#345

Open
stringhandler wants to merge 2 commits intoBlockstreamResearch:masterfrom
stringhandler:feat/add-annex
Open

feat: add annex to env#345
stringhandler wants to merge 2 commits intoBlockstreamResearch:masterfrom
stringhandler:feat/add-annex

Conversation

@stringhandler
Copy link
Copy Markdown
Contributor

Add the annex to the transaction environment so that it is included in hashes created by jets.

This is almost entirely coded by @delta1 but is required to add functionality to hal-simplicity and can be seen/tested here https://github.com/stringhandler/hal-simplicity/tree/feat/add-annex.

@delta1
Copy link
Copy Markdown
Contributor

delta1 commented Feb 24, 2026

LGTM I copied most of #331 for this. Gonna take a look at fixing CI first

@apoelstra
Copy link
Copy Markdown
Collaborator

CI is passing -- can this be undrafted?

@stringhandler stringhandler marked this pull request as ready for review March 3, 2026 18:00
@stringhandler
Copy link
Copy Markdown
Contributor Author

done

@apoelstra
Copy link
Copy Markdown
Collaborator

In 7ce98ca:

Please separate out the typo fixes and the serde stuff (is this necessary at all?) into separate commits.

Comment thread src/jet/elements/c_env.rs Outdated
annex: inp_data
.annex
.as_ref()
.map(|annex| c_elements::CRawBuffer::new(annex))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In 7ce98ca:

This creates a dangling raw pointer and is unsound.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@stringhandler are you taking a look at this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will do

@stringhandler stringhandler marked this pull request as draft May 7, 2026 14:10
@stringhandler stringhandler marked this pull request as ready for review May 7, 2026 14:17
@apoelstra
Copy link
Copy Markdown
Collaborator

In 0c9abb8:

Can you remove the unrelated serde changes from src/analysis.rs?

Comment thread src/jet/elements/c_env.rs Outdated
for (((n, inp), in_utxo), inp_data) in tx
.input
.iter()
.enumerate()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In 0c9abb8:

I'd prefer you add .zip(raw_annexes.iter_mut()) here rather than enumerate, so then it's clear that we're going through all the iterators simultaneously.

@apoelstra
Copy link
Copy Markdown
Collaborator

utACK other than the above nits.

I spent some time looking for methods on Option or on raw pointers that could simplify this logic but I don't think there are any.

@stringhandler
Copy link
Copy Markdown
Contributor Author

Yeah I also tried some variants but they seemed worse than this

@stringhandler
Copy link
Copy Markdown
Contributor Author

Can you remove the unrelated serde changes from src/analysis.rs?

These seem unrelated but they are necessary for hal-simplicity and other callers to calculate the cost when deciding to add annex padding or not.

@stringhandler
Copy link
Copy Markdown
Contributor Author

re: serde changes: I am happy to push them into another PR but that would also need to be merged before we can complete this section of work

Previously the annex field was always null in the C FFI input struct.
This extracts the annex from the witness stack and passes it through,
with careful lifetime management using a boxed slice to prevent
reallocation before the FFI call completes.
This is useful for downstream users to determine if annex padding is needed
@stringhandler
Copy link
Copy Markdown
Contributor Author

Force pushed into two commits, one for annex and one for serde changes

@apoelstra
Copy link
Copy Markdown
Collaborator

apoelstra commented May 8, 2026

In 050f9bd:

Note to self that a future rust-elements update should provide the get_annex function for you. This has been present in rust-bitcoin for some years but rust-elements is way behind.

@apoelstra
Copy link
Copy Markdown
Collaborator

In c4d6ee6:

Cool, thanks for separating into another patch. I still don't get the motivation but I'm happy to add these serde impls.

Copy link
Copy Markdown
Collaborator

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK c4d6ee6; successfully ran local tests

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.

3 participants