Skip to content

Conversation

@lmorett1
Copy link
Contributor

Replaces the heap-allocated Vec in nodes_from_tap_tree with a fixed-size stack array, addressing an existing FIXME.

Since Taproot tree depth is strictly consensus-limited to 128, using a small stack array (~2KB) eliminates unnecessary heap allocations during tree traversal without any risk of overflow.

@tcharding
Copy link
Member

You can run just fmt to get past CI mate.

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK 94eea85

Code review only, I do not know about the 128 depth limit thing.

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

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

ACK 90b1be3

@tcharding
Copy link
Member

Is there any reason you didn't use ArrayVec like the code comment mentioned?

@apoelstra
Copy link
Member

We don't have an arrayvec dependency here. (There is one which is inherited from hex-conservative 0.2 but it's not exposed and won't obviously be retained when we move to 1.0.)

This code looks fine to me but I'd prefer that it used TAPROOT_CONTROL_MAX_NODE_COUNT rather than 128, as in taptree.rs, so that the two bounds checks are comparable.

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