Skip to content
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

v5 transaction format #5202

Merged
merged 8 commits into from Jun 12, 2021
Merged

v5 transaction format #5202

merged 8 commits into from Jun 12, 2021

Conversation

str4d
Copy link
Contributor

@str4d str4d commented Jun 4, 2021

Includes a new wrapper that enables passing C++ streams across to Rust.

Closes #5022.

@str4d str4d added the NU5 Network upgrade: NU5-specific tasks label Jun 4, 2021
@str4d str4d added this to the Core Sprint 2021-20 milestone Jun 4, 2021
src/primitives/transaction.h Outdated Show resolved Hide resolved
@str4d str4d added the C-upstream-port Category: Changes that are ported from the Bitcoin Core codebase. label Jun 4, 2021
@mdr0id mdr0id added the safe-to-build Used to send PR to prod CI environment label Jun 7, 2021
@str4d
Copy link
Contributor Author

str4d commented Jun 9, 2021

Closing so I can reopen this targeting the correct branch.

@str4d str4d closed this Jun 9, 2021
@str4d
Copy link
Contributor Author

str4d commented Jun 9, 2021

Replaced by #5211.

@str4d
Copy link
Contributor Author

str4d commented Jun 10, 2021

v4.1.1 is released, so we can merge into master again. Hopefully Homu doesn't mind we closed this...

The majority of the parser is in C++, but Orchard bundles are parsed
exclusively by Rust.

The ZIP 244 test vectors are brought in here so we can start by testing
round-trip serialization.
@str4d str4d marked this pull request as ready for review June 10, 2021 21:18
Copy link
Contributor

@nuttycom nuttycom left a comment

Choose a reason for hiding this comment

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

utACK. I don't feel fully qualified to review how the streams are handled in the rust FFI parts of this PR, but it all makes sense to me and I'm happy that there are tests for that code.

src/primitives/transaction.h Outdated Show resolved Hide resolved
src/primitives/transaction.h Outdated Show resolved Hide resolved
src/rust/include/rust/streams.h Show resolved Hide resolved
This also fixes a bug in `CTransaction::SerializationOp` where
`CTransaction::UpdateHash` was not being called for v5 transactions.
@str4d
Copy link
Contributor Author

str4d commented Jun 11, 2021

@zkbot try

@zkbot
Copy link
Contributor

zkbot commented Jun 11, 2021

⌛ Trying commit 36874e7 with merge 6fb94b516af85b2a5483f94e8168d99e40b45974...

if (ser_action.ForRead()) {
SaplingBundle saplingBundle;
READWRITE(saplingBundle);
*const_cast<std::vector<SpendDescription>*>(&vShieldedSpend) =
Copy link
Contributor

@daira daira Jun 11, 2021

Choose a reason for hiding this comment

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

This, and the other casts like it, are undefined behaviour. I know it was undefined behaviour before this PR, but every time we change this code, we have a new chance for it to be miscompiled. It should have been fixed long ago (#967). For anyone who isn't familiar with why it's undefined behaviour and why the const declarations don't help in the first place, see #967 (comment) .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we can fix this in this PR. However, given that for Orchard we are parsing everything in Rust and then using calls to Rust to inspect Orchard data, we require accessors for those, and so we can make a start towards fixing this by doing the same for all new variables going forward.

I will move nConsensusBranchId and orchardBundle to be non-const private member variables.

@zkbot
Copy link
Contributor

zkbot commented Jun 11, 2021

☀️ Test successful - pr-try
State: approved= try=True

Using `const_cast` to serialize into an otherwise-constant field is
undefined behaviour:

  zcash#967 (comment)

Instead, we should make CTransaction's members non-const and private,
and provide accessors. It's not practical to make this change everywhere
yet, but we can start by only introducing new fields in this way. We
will need to provide accessors for orchardBundle's properties in any
case, since we need to call across the Rust FFI.
@str4d str4d added A-rust-ffi Area: The Rust FFI in the librustzcash library. and removed C-upstream-port Category: Changes that are ported from the Bitcoin Core codebase. labels Jun 12, 2021
@str4d
Copy link
Contributor Author

str4d commented Jun 12, 2021

@zkbot r+

@zkbot
Copy link
Contributor

zkbot commented Jun 12, 2021

📌 Commit 1ef8181 has been approved by str4d

@zkbot
Copy link
Contributor

zkbot commented Jun 12, 2021

⌛ Testing commit 1ef8181 with merge bad7f7e...

@zkbot
Copy link
Contributor

zkbot commented Jun 12, 2021

☀️ Test successful - pr-merge
Approved by: str4d
Pushing bad7f7e to master...

@zkbot zkbot merged commit bad7f7e into zcash:master Jun 12, 2021
@str4d str4d deleted the 5022-tx-v5 branch June 12, 2021 19:03
zkbot added a commit that referenced this pull request Jun 29, 2021
Include Orchard bundle in transaction dynamic usage

This was missed in #5202.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rust-ffi Area: The Rust FFI in the librustzcash library. NU5 Network upgrade: NU5-specific tasks safe-to-build Used to send PR to prod CI environment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement ZIP-225 transaction format changes in zcashd.
7 participants