Skip to content

Prepare Witness#3408

Merged
apoelstra merged 3 commits intorust-bitcoin:masterfrom
tcharding:09-24-prep-witness
Oct 1, 2024
Merged

Prepare Witness#3408
apoelstra merged 3 commits intorust-bitcoin:masterfrom
tcharding:09-24-prep-witness

Conversation

@tcharding
Copy link
Copy Markdown
Member

@tcharding tcharding commented Sep 25, 2024

Prepare Witness to be moved to primitives.

This is the first three patches out of #3406. Patch 1 and 2 are internal changes, path 3 is also internal but introduces a slight perf hit by doing multiple writes.

@github-actions github-actions bot added the C-bitcoin PRs modifying the bitcoin crate label Sep 25, 2024
apoelstra
apoelstra previously approved these changes Sep 25, 2024
Copy link
Copy Markdown
Member

@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 3437f6c8b9d6797ca0543acfd77914b30ff8f258 successfully ran local tests

@tcharding
Copy link
Copy Markdown
Member Author

Merge please. This is holding up more primitives work, onwards and upwards!

@apoelstra
Copy link
Copy Markdown
Member

Needs rebase now.

@tcharding tcharding force-pushed the 09-24-prep-witness branch 2 times, most recently from 72c9096 to e61d581 Compare September 30, 2024 21:38
@tcharding
Copy link
Copy Markdown
Member Author

Rebase only, no other changes. (Took me two goes because I left VarInt in there.)

In preparation for moving the `Witness` oven to `primitives` use the
`len` function instead of accessing the `witness_elements` field.

No logic change, `Witness::len()` returns `witness_elements`.
The `Witness::push_slice` function is called by `Witness::push` after
calling `as_ref`, hence is equivalent for all types that implement
`AsRef<[u8]>`. Also, `push_slice` is a private method on `Witness`.

In preparation for moving `Witness` over to `primitives` stop using
`push_slice` in favour of `push`.

Internal change only.
We would like to move the `Witness` to `primitives` however in the
`Encodable` implementation we are currently accessing the private
`content` field.

Instead of accessing `content` we can iterate over the witness elements
and write each individually, this has the same result but does a bunch
of additional calls to `Write::write_all` (via `emit_slice`).

This patch effects performance negatively but makes no changes to the
encoding.
Copy link
Copy Markdown
Contributor

@shinghim shinghim left a comment

Choose a reason for hiding this comment

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

ACK be163ee

Copy link
Copy Markdown
Member

@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 3f3f30d successfully ran local tests

@apoelstra apoelstra merged commit f3fbd0e into rust-bitcoin:master Oct 1, 2024
@tcharding tcharding deleted the 09-24-prep-witness branch October 1, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-bitcoin PRs modifying the bitcoin crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants