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

Disable Sapling features on mainnet #3458

Merged
merged 3 commits into from Aug 14, 2018

Conversation

@str4d
Copy link
Contributor

str4d commented Aug 13, 2018

Also places them behind an experimental features flag on testnet.

str4d added some commits Aug 13, 2018

Disable Sapling features on mainnet
Also places them behind an experimental features flag on testnet

@str4d str4d added this to the v2.0.0 milestone Aug 13, 2018

@str4d str4d requested review from bitcartel , daira and ebfull Aug 13, 2018

@str4d str4d added this to In Review in Zcashd Team Aug 13, 2018

@str4d

This comment has been minimized.

Copy link
Contributor

str4d commented Aug 13, 2018

@zkbot try

@zkbot

This comment has been minimized.

Copy link
Collaborator

zkbot commented Aug 13, 2018

⌛️ Trying commit 554e00e with merge 511b1a0...

zkbot added a commit that referenced this pull request Aug 13, 2018

Auto merge of #3458 - str4d:temp-sapling-disable, r=<try>
Disable Sapling features on mainnet

Also places them behind an experimental features flag on testnet.
@zkbot

This comment has been minimized.

Copy link
Collaborator

zkbot commented Aug 13, 2018

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

@daira

daira approved these changes Aug 13, 2018

Copy link
Contributor

daira left a comment

utACK. Do we need a test of the -developersapling flag? One way to do that would be to reenable the EncodeAndDecodeSapling test but have it set the flag.

for (size_t i = 0; i < 1000; i++) {
auto sk = SaplingSpendingKey::random();
{
std::string sk_string = EncodeSpendingKey(sk);
BOOST_CHECK(sk_string.compare(0, 24, Params().Bech32HRP(CChainParams::SAPLING_SPENDING_KEY)) == 0);
BOOST_CHECK(sk_string.compare(0, 27, Params().Bech32HRP(CChainParams::SAPLING_SPENDING_KEY)) == 0);

This comment has been minimized.

@bitcartel

bitcartel Aug 13, 2018

Contributor

Why 24 -> 27 ? For regtest?

This comment has been minimized.

@str4d

str4d Aug 13, 2018

Contributor

Yes. This is the length of the HRP, and C++'s std::string::compare takes the data range over which to compare as parameters.

@@ -240,7 +242,7 @@ BOOST_AUTO_TEST_CASE(zs_address_test)
auto addr = sk.default_address();

std::string addr_string = EncodePaymentAddress(addr);
BOOST_CHECK(addr_string.compare(0, 2, Params().Bech32HRP(CChainParams::SAPLING_PAYMENT_ADDRESS)) == 0);
BOOST_CHECK(addr_string.compare(0, 15, Params().Bech32HRP(CChainParams::SAPLING_PAYMENT_ADDRESS)) == 0);

This comment has been minimized.

@bitcartel

bitcartel Aug 13, 2018

Contributor

Why 2 -> 15 ? For regtest? Would be good to define a well-named constant for these magic values.

This comment has been minimized.

@str4d

str4d Aug 13, 2018

Contributor

See above. Not magic per-se, could have just used len() or whatever on the output of Bech32HRP().

{
std::string sk_string = EncodeSpendingKey(sk);
EXPECT_EQ(
sk_string.substr(0, 24),

This comment has been minimized.

@bitcartel

bitcartel Aug 13, 2018

Contributor

Why not 27, based on changes to key_tests?

This comment has been minimized.

@str4d

str4d Aug 13, 2018

Contributor

This is a test explicitly of the mainnet parameters, so it uses the mainnet lengths.


std::string addr_string = EncodePaymentAddress(addr);
EXPECT_EQ(
addr_string.substr(0, 2),

This comment has been minimized.

@bitcartel

bitcartel Aug 13, 2018

Contributor

Ditto, why not 15?

This comment has been minimized.

@str4d

str4d Aug 13, 2018

Contributor

See above.


#include <gtest/gtest.h>

TEST(Keys, DISABLED_EncodeAndDecodeSapling)

This comment has been minimized.

@bitcartel

bitcartel Aug 13, 2018

Contributor

If this test works, why disable it? Should be ok to test against mainnet key encodings, right?

This comment has been minimized.

@str4d

str4d Aug 13, 2018

Contributor

The test works until Sapling support in Decode* is disabled. Marking this as a disabled test causes it to be run by the expected-fail CI builder, so we ensure that it currently fails, and detect that it is no longer failing once the changes to Decode* are reverted, if this test is not also reverted.

BOOST_CHECK_EQUAL(b, true);
BOOST_CHECK_EQUAL(find_value(resultObj, "type").get_str(), "sapling");
b = find_value(resultObj, "ismine").get_bool();
// TODO: Revert when we re-enable Sapling addresses on mainnet

This comment has been minimized.

@bitcartel

bitcartel Aug 13, 2018

Contributor

Not clear what gets reverted and developer will have to check commit. How about keeping old test suitably commented between /** and */ with instructions? Maybe use in conjunction with #if 1 , #if 0 blocks.

This comment has been minimized.

@str4d

str4d Aug 13, 2018

Contributor

The way this PR is designed, all we need to do is a git revert COMMIT_ID for the last commit in this PR (that disabled Sapling support), and everything will be correctly reverted.

@@ -286,7 +286,11 @@ libzcash::PaymentAddress DecodePaymentAddress(const std::string& str)
}
data.clear();
auto bech = bech32::Decode(str);
if (bech.first == Params().Bech32HRP(CChainParams::SAPLING_PAYMENT_ADDRESS) &&
bool allowSapling = Params().NetworkIDString() == "regtest" || (

This comment has been minimized.

@bitcartel

bitcartel Aug 13, 2018

Contributor

Make a global function for this since repeated in several places?

This comment has been minimized.

@str4d

str4d Aug 13, 2018

Contributor

Not worth the overhead, as we'll only be using this for a few weeks, and then will strip it out completely.

@@ -3133,9 +3133,13 @@ UniValue z_getnewaddress(const UniValue& params, bool fHelp)
addrType = params[0].get_str();
}

bool allowSapling = Params().NetworkIDString() == "regtest" || (

This comment has been minimized.

@bitcartel

bitcartel Aug 13, 2018

Contributor

What about z_importkey and z_exportkey? Do they need to be gated or not?

This comment has been minimized.

@str4d

str4d Aug 13, 2018

Contributor

z_importkey is gated because DecodePaymentAddress has been modified to remove Sapling support on mainnet and gate it on testnet. z_exportkey is handled because we have done the same removal/gating to z_getnewaddress sapling, and there is no other way to add a Sapling key to the wallet.

@ebfull

ebfull approved these changes Aug 13, 2018

@bitcartel
Copy link
Contributor

bitcartel left a comment

utACK. One suggestion: modify the help messages of the relevant z_* commands which take Saplng parameters so that users know they only work in regtest mode or testnet with the appropriate flags.

@ebfull

This comment has been minimized.

Copy link
Contributor

ebfull commented Aug 14, 2018

I will be r+'ing this in 12 hours to avoid competition with the activation height PR.

@ebfull

This comment has been minimized.

Copy link
Contributor

ebfull commented Aug 14, 2018

@zkbot r+

@zkbot

This comment has been minimized.

Copy link
Collaborator

zkbot commented Aug 14, 2018

📌 Commit 554e00e has been approved by ebfull

zkbot added a commit that referenced this pull request Aug 14, 2018

Auto merge of #3458 - str4d:temp-sapling-disable, r=ebfull
Disable Sapling features on mainnet

Also places them behind an experimental features flag on testnet.
@zkbot

This comment has been minimized.

Copy link
Collaborator

zkbot commented Aug 14, 2018

⌛️ Testing commit 554e00e with merge b004f25...

@zkbot

This comment has been minimized.

Copy link
Collaborator

zkbot commented Aug 14, 2018

☀️ Test successful - pr-merge
Approved by: ebfull
Pushing b004f25 to master...

@zkbot zkbot merged commit 554e00e into zcash:master Aug 14, 2018

1 check passed

homu Test successful
Details

Zcashd Team automation moved this from In Review to Released (Merged in Master) Aug 14, 2018

@str4d str4d deleted the str4d:temp-sapling-disable branch Aug 15, 2018

zkbot added a commit that referenced this pull request Sep 22, 2018

Auto merge of #3537 - str4d:enable-sapling-features, r=bitcartel
Enable Sapling features on mainnet

Reverts the last commit from #3458.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment