-
Notifications
You must be signed in to change notification settings - Fork 672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Nakamoto] Potential incorrect NakamotoCoinbase encoding #4115
Comments
Seems odd that we're using |
The other tx types have their binary format specified in SIPs, which is helpful for several other projects that encode/decode these. Maybe we should get the new Nakamoto related txs documented as well? |
This was merged as part of #4121 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Describe the bug
The code serializing the NakamotoCoinbase might be using unintended code paths.
The current
next
behavior for the NakamotoCoinbase encodes the vrf_proof as a length-prefixed byte vector. I believe it's intended to use au8, 80
(always 80 length).The code should be using
consensus_serialize
directly. Instead it's usingwrite_next
on a vector, which obfuscates what's happening. (This can be fine in many cases, but in this case it hides that LP serialize is used, when the VRFProof actually has aconsensus_serialize
.Steps To Reproduce
Hard for me to show in the Rust codebase, but the bytes used for the proof are more than needed. (due to LP)
Code
stacks-core/stackslib/src/chainstate/stacks/transaction.rs
Lines 279 to 297 in 53c168d
stacks-core/stacks-common/src/types/chainstate.rs
Lines 304 to 313 in 53c168d
stacks-core/stacks-common/src/codec/mod.rs
Lines 186 to 202 in 53c168d
My recommendation here would be to try to use a top-level
consensus_serialize
as much as possible, reducingwrite_next
calls / data transformations in the serialize cases.Anyway, I could be wrong and this could be intended. If so, it might be worth adding a comment. But likely this could use a change, before it's consensus critical. 🍀
The text was updated successfully, but these errors were encountered: