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

refactor: deglobalization of bls_legacy_scheme 3/N #6508

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: use basic scheme for RPC bls generate by default
Soft fork V19 is activated long time ago, so, basically no changes for mainnet/testnet
  • Loading branch information
knst committed Dec 27, 2024
commit 394d6496166aa55a65f49d67038a66fce8068e26
14 changes: 4 additions & 10 deletions src/rpc/evo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1705,7 +1705,7 @@ static RPCHelpMan bls_generate()
return RPCHelpMan{"bls generate",
"\nReturns a BLS secret/public key pair.\n",
{
{"legacy", RPCArg::Type::BOOL, RPCArg::DefaultHint{"true until the v19 fork is activated, otherwise false"}, "Use legacy BLS scheme"},
{"legacy", RPCArg::Type::BOOL, RPCArg::Default{false}, "Set it true if need in legacy BLS scheme"},
},
RPCResult{
RPCResult::Type::OBJ, "", "",
Expand All @@ -1719,12 +1719,9 @@ static RPCHelpMan bls_generate()
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
const NodeContext& node = EnsureAnyNodeContext(request.context);
const ChainstateManager& chainman = EnsureChainman(node);

CBLSSecretKey sk;
sk.MakeNewKey();
bool bls_legacy_scheme{!DeploymentActiveAfter(WITH_LOCK(cs_main, return chainman.ActiveChain().Tip();), Params().GetConsensus(), Consensus::DEPLOYMENT_V19)};
bool bls_legacy_scheme{false};
if (!request.params[0].isNull()) {
bls_legacy_scheme = ParseBoolV(request.params[0], "bls_legacy_scheme");
}
Expand All @@ -1744,7 +1741,7 @@ static RPCHelpMan bls_fromsecret()
"\nParses a BLS secret key and returns the secret/public key pair.\n",
{
{"secret", RPCArg::Type::STR, RPCArg::Optional::NO, "The BLS secret key"},
{"legacy", RPCArg::Type::BOOL, RPCArg::DefaultHint{"true until the v19 fork is activated, otherwise false"}, "Use legacy BLS scheme"},
{"legacy", RPCArg::Type::BOOL, RPCArg::Default{false}, "Pass true if you need in legacy scheme"},
},
RPCResult{
RPCResult::Type::OBJ, "", "",
Expand All @@ -1758,10 +1755,7 @@ static RPCHelpMan bls_fromsecret()
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
const NodeContext& node = EnsureAnyNodeContext(request.context);
const ChainstateManager& chainman = EnsureChainman(node);

bool bls_legacy_scheme{!DeploymentActiveAfter(WITH_LOCK(cs_main, return chainman.ActiveChain().Tip();), Params().GetConsensus(), Consensus::DEPLOYMENT_V19)};
bool bls_legacy_scheme{false};
if (!request.params[1].isNull()) {
bls_legacy_scheme = ParseBoolV(request.params[1], "bls_legacy_scheme");
}
Expand Down
14 changes: 7 additions & 7 deletions src/test/rpc_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ BOOST_AUTO_TEST_CASE(rpc_bls)
UniValue r;

BOOST_CHECK_NO_THROW(r = CallRPC(std::string("bls generate")));
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "scheme").get_str(), "legacy");
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "scheme").get_str(), "basic");

BOOST_CHECK_NO_THROW(r = CallRPC(std::string("bls generate 1")));
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "scheme").get_str(), "legacy");
Expand All @@ -555,15 +555,15 @@ BOOST_AUTO_TEST_CASE(rpc_bls)
std::string secret_basic = find_value(r.get_obj(), "secret").get_str();
std::string public_basic = find_value(r.get_obj(), "public").get_str();

BOOST_CHECK_NO_THROW(r = CallRPC(std::string("bls fromsecret ") + secret_legacy));
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "scheme").get_str(), "legacy");
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "public").get_str(), public_legacy);
BOOST_CHECK_NO_THROW(r = CallRPC(std::string("bls fromsecret ") + secret_basic));
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "scheme").get_str(), "basic");
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "public").get_str(), public_basic);

BOOST_CHECK_NO_THROW(r = CallRPC(std::string("bls fromsecret ") + secret_legacy + std::string(" 1")));
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "scheme").get_str(), "legacy");
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "public").get_str(), public_legacy);

BOOST_CHECK_NO_THROW(r = CallRPC(std::string("bls fromsecret ") + secret_legacy + std::string(" 0")));
BOOST_CHECK_NO_THROW(r = CallRPC(std::string("bls fromsecret ") + secret_basic + std::string(" 0")));
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "scheme").get_str(), "basic");
BOOST_CHECK(find_value(r.get_obj(), "public").get_str() != public_legacy);

Expand All @@ -576,10 +576,10 @@ BOOST_AUTO_TEST_CASE(rpc_bls)
BOOST_CHECK(find_value(r.get_obj(), "public").get_str() != public_basic);

std::string secret = "0b072b1b8b28335b0460aa695ee8ce1f60dc01e6eb12655ece2a877379dfdb51";
BOOST_CHECK_NO_THROW(r = CallRPC(std::string("bls fromsecret ") + secret));
BOOST_CHECK_NO_THROW(r = CallRPC(std::string("bls fromsecret ") + secret + " 1"));
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "scheme").get_str(), "legacy");
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "public").get_str(), "9379c28e0f50546906fe733f1222c8f7e39574d513790034f1fec1476286eb652a350c8c0e630cd2cc60d10c26d6f6ee");
BOOST_CHECK_NO_THROW(r = CallRPC(std::string("bls fromsecret ") + secret + " 0"));
BOOST_CHECK_NO_THROW(r = CallRPC(std::string("bls fromsecret ") + secret));
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "scheme").get_str(), "basic");
BOOST_CHECK_EQUAL(find_value(r.get_obj(), "public").get_str(), "b379c28e0f50546906fe733f1222c8f7e39574d513790034f1fec1476286eb652a350c8c0e630cd2cc60d10c26d6f6ee");
}
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_dip3_deterministicmns.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from test_framework.blocktools import create_block_with_mnpayments
from test_framework.messages import tx_from_hex
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal, force_finish_mnsync, p2p_port
from test_framework.util import assert_equal, force_finish_mnsync, p2p_port, softfork_active

class Masternode(object):
pass
Expand Down Expand Up @@ -226,7 +226,7 @@ def prepare_mn(self, node, idx, alias):
mn.p2p_port = p2p_port(mn.idx)
mn.operator_reward = (mn.idx % self.num_initial_mn)

blsKey = node.bls('generate')
blsKey = node.bls('generate') if softfork_active(node, 'v19') else node.bls('generate', True)
mn.fundsAddr = node.getnewaddress()
mn.ownerAddr = node.getnewaddress()
mn.operatorAddr = blsKey['public']
Expand Down
4 changes: 2 additions & 2 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,7 @@ def dynamically_add_masternode(self, evo=False, rnd=None, should_be_rejected=Fal
return created_mn_info

def dynamically_prepare_masternode(self, idx, node_p2p_port, evo=False, rnd=None):
bls = self.nodes[0].bls('generate')
bls = self.nodes[0].bls('generate') if softfork_active(self.nodes[0], 'v19') else self.nodes[0].bls('generate', True)
collateral_address = self.nodes[0].getnewaddress()
funds_address = self.nodes[0].getnewaddress()
owner_address = self.nodes[0].getnewaddress()
Expand Down Expand Up @@ -1387,7 +1387,7 @@ def prepare_masternode(self, idx):

register_fund = (idx % 2) == 0

bls = self.nodes[0].bls('generate')
bls = self.nodes[0].bls('generate') if softfork_active(self.nodes[0], 'v19') else self.nodes[0].bls('generate', True)
address = self.nodes[0].getnewaddress()

collateral_amount = MASTERNODE_COLLATERAL
Expand Down