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

Enable ZIP 216 for blocks prior to NU5 activation #6000

Merged
merged 6 commits into from Jul 4, 2022

Conversation

ebfull
Copy link
Contributor

@ebfull ebfull commented Jun 8, 2022

I also take the opportunity in this PR to remove the legacy Sapling verification FFI stuff and replace it with the new cxx approach.

I've tested that ZIP 216 can be applied to blocks prior to activation on both mainnet and testnet.

src/main.cpp Show resolved Hide resolved
@ebfull ebfull added the safe-to-build Used to send PR to prod CI environment label Jun 21, 2022
@@ -135,7 +135,8 @@ class CMainParams : public CChainParams {
uint256S("00000000002038016f976744c369dce7419fca30e7171dfac703af5e5f7ad1d4");
consensus.vUpgrades[Consensus::UPGRADE_NU5].nProtocolVersion = 170100;
consensus.vUpgrades[Consensus::UPGRADE_NU5].nActivationHeight = 1687104;

consensus.vUpgrades[Consensus::UPGRADE_NU5].hashActivationBlock =
uint256S("0000000000d723156d9b65ffcf4984da7a19675ed7e2f06d9e5d5188af087bf8");
Copy link
Contributor

Choose a reason for hiding this comment

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

I checked this hash.

Copy link
Contributor

Choose a reason for hiding this comment

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

I also checked this hash.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't check this hash.

@@ -239,7 +240,7 @@ class CMainParams : public CChainParams {
}

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("00000000000000000000000000000000000000000000000004a90edff47bbdc6");
consensus.nMinimumChainWork = uint256S("000000000000000000000000000000000000000000000000098e5c63248dcb28");
Copy link
Contributor

Choose a reason for hiding this comment

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

I did not check this.

Copy link
Contributor

Choose a reason for hiding this comment

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

I confirmed that this minimum chain work is greater than the chain work at the NU5 activation block, as required.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't check this either.

};

self.0
.final_check(value_balance, sighash_value, binding_sig)
Copy link
Contributor

Choose a reason for hiding this comment

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

These APIs (final_check and SaplingVerificationContext::final_check) also have arguments in an inconsistent order, but here there's no argument that we're preserving the field order in the v4 transaction encoding, because sighash_value is not a field.

daira
daira previously approved these changes Jun 23, 2022
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK with comments.

@str4d str4d added A-consensus Area: Consensus rules C-simplification Category: Changes that simplify the protocol specification or consensus rules. L-rust Involves Rust code. A-rust-ffi Area: The Rust FFI in the librustzcash library. safe-to-build Used to send PR to prod CI environment NU5 Network upgrade: NU5-specific tasks and removed safe-to-build Used to send PR to prod CI environment labels Jun 29, 2022
@ebfull ebfull force-pushed the enablezip216forall branch 2 times, most recently from 2a6c77a to 8b0f27e Compare June 29, 2022 18:01
daira
daira previously approved these changes Jul 1, 2022
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK

@str4d str4d added the safe-to-build Used to send PR to prod CI environment label Jul 1, 2022
@str4d str4d added this to the Release 5.1.0 milestone Jul 1, 2022
@nuttycom nuttycom added safe-to-build Used to send PR to prod CI environment and removed safe-to-build Used to send PR to prod CI environment labels Jul 1, 2022
@nuttycom nuttycom added safe-to-build Used to send PR to prod CI environment and removed safe-to-build Used to send PR to prod CI environment labels Jul 1, 2022
daira
daira previously approved these changes Jul 1, 2022
Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK

@nuttycom nuttycom added safe-to-build Used to send PR to prod CI environment and removed safe-to-build-dev Used to send PR to dev CI environment labels Jul 4, 2022
defuse
defuse previously approved these changes Jul 4, 2022
Copy link
Contributor

@defuse defuse left a comment

Choose a reason for hiding this comment

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

utACK

Copy link
Contributor

@str4d str4d left a comment

Choose a reason for hiding this comment

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

utACK af2b3d3

src/rust/src/sapling.rs Show resolved Hide resolved
@str4d str4d added safe-to-build Used to send PR to prod CI environment and removed safe-to-build Used to send PR to prod CI environment labels Jul 4, 2022
Comment on lines +5 to +8
// This is added because `check_spend` takes several arguments over FFI. This
// annotation gets removed by the cxx procedural macro so it needs to be enabled
// on the entire module.
#![allow(clippy::too_many_arguments)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

This was fixed in dtolnay/cxx#1062, merged in cxx 1.0.70.

self.0.check_output(
cv,
cm,
ephemeral_key,
Copy link
Contributor

Choose a reason for hiding this comment

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

RedDSA.Validate takes an abstract public key and reserializes it for input to $\mathsf{H}^⊛$, so this is correct.
As @str4d says, ephemeral_key should be renamed to epk here.

Suggested change
ephemeral_key,
epk,

std::array<uint8_t, WIDTH> GetRawBytes() const
{
std::array<uint8_t, WIDTH> buf = {};
memcpy(buf.data(), this->begin(), WIDTH);
Copy link
Contributor

@daira daira Jul 4, 2022

Choose a reason for hiding this comment

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

Suggested change
memcpy(buf.data(), this->begin(), WIDTH);
std::memcpy(buf.data(), this->begin(), WIDTH);

It probably works without the std:: (and without using std::memcpy or using namespace std;) by coincidence of the included headers implicitly declaring memcpy in the global namespace. Strictly speaking that's not portable (similarly for the uses of memset in this file).

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@daira daira left a comment

Choose a reason for hiding this comment

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

utACK with suggestions.

Copy link
Contributor

@therealyingtong therealyingtong left a comment

Choose a reason for hiding this comment

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

utACK

@str4d str4d merged commit 466ea88 into zcash:master Jul 4, 2022
str4d added a commit to str4d/zcash that referenced this pull request Feb 2, 2023
This completes the work started in zcash#6000.

Closes zcash#6396.
str4d added a commit to zcash/librustzcash that referenced this pull request Nov 30, 2023
As a side-effect, we remove the ability to verify individual
transactions with pre-ZIP 216 rules (which we already removed from
`zcashd` consensus nodes in zcash/zcash#6000 and zcash/zcash#6399, as
all pre-ZIP 216 transactions on mainnet are also valid under ZIP 216).
str4d added a commit to zcash/librustzcash that referenced this pull request Nov 30, 2023
As a side-effect, we remove the ability to verify individual
transactions with pre-ZIP 216 rules (which we already removed from
`zcashd` consensus nodes in zcash/zcash#6000 and zcash/zcash#6399, as
all pre-ZIP 216 transactions on mainnet are also valid under ZIP 216).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Area: Consensus rules A-rust-ffi Area: The Rust FFI in the librustzcash library. C-simplification Category: Changes that simplify the protocol specification or consensus rules. L-rust Involves Rust code. 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.

None yet

7 participants