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: enforce using _legacy suffix for protx commands; no more guessi…
…ng based if v19 is activated

Soft fork V19 is activated long time ago, so, basically no changes for mainnet/testnet
  • Loading branch information
knst committed Dec 27, 2024
commit 5ea9ff9e7150f3594823f6091767f6578002dfaa
5 changes: 2 additions & 3 deletions src/rpc/evo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ static UniValue protx_register_common_wrapper(const JSONRPCRequest& request,
tx.nVersion = 3;
tx.nType = TRANSACTION_PROVIDER_REGISTER;

const bool use_legacy = isV19active ? specific_legacy_bls_scheme : true;
const bool use_legacy = specific_legacy_bls_scheme;

CProRegTx ptx;
ptx.nType = mnType;
Expand Down Expand Up @@ -1107,8 +1107,7 @@ static RPCHelpMan protx_update_registrar_wrapper(bool specific_legacy_bls_scheme
ptx.keyIDVoting = dmn->pdmnState->keyIDVoting;
ptx.scriptPayout = dmn->pdmnState->scriptPayout;

const bool isV19Active{DeploymentActiveAfter(WITH_LOCK(cs_main, return chainman.ActiveChain().Tip();), Params().GetConsensus(), Consensus::DEPLOYMENT_V19)};
const bool use_legacy = isV19Active ? specific_legacy_bls_scheme : true;
const bool use_legacy = specific_legacy_bls_scheme;

if (request.params[1].get_str() != "") {
// new pubkey
Expand Down
8 changes: 4 additions & 4 deletions test/functional/feature_dip3_deterministicmns.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def run_test(self):
assert old_voting_address != new_voting_address
# also check if funds from payout address are used when no fee source address is specified
node.sendtoaddress(mn.rewards_address, 0.001)
node.protx('update_registrar', mn.protx_hash, "", new_voting_address, "")
node.protx('update_registrar' if softfork_active(node, 'v19') else 'update_registrar_legacy', mn.protx_hash, "", new_voting_address, "")
self.generate(node, 1)
new_dmnState = mn.node.masternode("status")["dmnState"]
new_voting_address_from_rpc = new_dmnState["votingAddress"]
Expand Down Expand Up @@ -254,7 +254,7 @@ def register_fund_mn(self, node, mn):
mn.collateral_address = node.getnewaddress()
mn.rewards_address = node.getnewaddress()

mn.protx_hash = node.protx('register_fund', mn.collateral_address, '127.0.0.1:%d' % mn.p2p_port, mn.ownerAddr, mn.operatorAddr, mn.votingAddr, mn.operator_reward, mn.rewards_address, mn.fundsAddr)
mn.protx_hash = node.protx('register_fund' if softfork_active(node, 'v19') else 'register_fund_legacy', mn.collateral_address, '127.0.0.1:%d' % mn.p2p_port, mn.ownerAddr, mn.operatorAddr, mn.votingAddr, mn.operator_reward, mn.rewards_address, mn.fundsAddr)
mn.collateral_txid = mn.protx_hash
mn.collateral_vout = None

Expand All @@ -270,7 +270,7 @@ def register_mn(self, node, mn):
node.sendtoaddress(mn.fundsAddr, 0.001)
mn.rewards_address = node.getnewaddress()

mn.protx_hash = node.protx('register', mn.collateral_txid, mn.collateral_vout, '127.0.0.1:%d' % mn.p2p_port, mn.ownerAddr, mn.operatorAddr, mn.votingAddr, mn.operator_reward, mn.rewards_address, mn.fundsAddr)
mn.protx_hash = node.protx('register' if softfork_active(node, 'v19') else 'register_legacy', mn.collateral_txid, mn.collateral_vout, '127.0.0.1:%d' % mn.p2p_port, mn.ownerAddr, mn.operatorAddr, mn.votingAddr, mn.operator_reward, mn.rewards_address, mn.fundsAddr)
self.generate(node, 1, sync_fun=self.no_op)

def start_mn(self, mn):
Expand All @@ -288,7 +288,7 @@ def spend_mn_collateral(self, mn, with_dummy_input_output=False):

def update_mn_payee(self, mn, payee):
self.nodes[0].sendtoaddress(mn.fundsAddr, 0.001)
self.nodes[0].protx('update_registrar', mn.protx_hash, '', '', payee, mn.fundsAddr)
self.nodes[0].protx('update_registrar' if softfork_active(self.nodes[0], 'v19') else 'update_registrar_legacy', mn.protx_hash, '', '', payee, mn.fundsAddr)
self.generate(self.nodes[0], 1)
info = self.nodes[0].protx('info', mn.protx_hash)
assert info['state']['payoutAddress'] == payee
Expand Down
13 changes: 8 additions & 5 deletions test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -1303,7 +1303,8 @@ 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') if softfork_active(self.nodes[0], 'v19') else self.nodes[0].bls('generate', True)
v19_active = softfork_active(self.nodes[0], 'v19')
bls = self.nodes[0].bls('generate') if v19_active 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 @@ -1336,7 +1337,7 @@ def dynamically_prepare_masternode(self, idx, node_p2p_port, evo=False, rnd=None
if evo:
protx_result = self.nodes[0].protx("register_evo", collateral_txid, collateral_vout, ipAndPort, owner_address, bls['public'], voting_address, operatorReward, reward_address, platform_node_id, platform_p2p_port, platform_http_port, funds_address, True)
else:
protx_result = self.nodes[0].protx("register", collateral_txid, collateral_vout, ipAndPort, owner_address, bls['public'], voting_address, operatorReward, reward_address, funds_address, True)
protx_result = self.nodes[0].protx("register" if v19_active else "register_legacy", collateral_txid, collateral_vout, ipAndPort, owner_address, bls['public'], voting_address, operatorReward, reward_address, funds_address, True)

self.bump_mocktime(10 * 60 + 1) # to make tx safe to include in block
tip = self.generate(self.nodes[0], 1)[0]
Expand Down Expand Up @@ -1387,7 +1388,9 @@ def prepare_masternode(self, idx):

register_fund = (idx % 2) == 0

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

bls = self.nodes[0].bls('generate') if v19_active else self.nodes[0].bls('generate', True)
knst marked this conversation as resolved.
Show resolved Hide resolved
address = self.nodes[0].getnewaddress()

collateral_amount = MASTERNODE_COLLATERAL
Expand Down Expand Up @@ -1416,10 +1419,10 @@ def prepare_masternode(self, idx):
submit = (idx % 4) < 2

if register_fund:
protx_result = self.nodes[0].protx('register_fund', address, ipAndPort, ownerAddr, bls['public'], votingAddr, operatorReward, rewardsAddr, address, submit)
protx_result = self.nodes[0].protx('register_fund' if v19_active else 'register_fund_legacy', address, ipAndPort, ownerAddr, bls['public'], votingAddr, operatorReward, rewardsAddr, address, submit)
else:
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
protx_result = self.nodes[0].protx('register', txid, collateral_vout, ipAndPort, ownerAddr, bls['public'], votingAddr, operatorReward, rewardsAddr, address, submit)
protx_result = self.nodes[0].protx('register' if v19_active else 'register_legacy', txid, collateral_vout, ipAndPort, ownerAddr, bls['public'], votingAddr, operatorReward, rewardsAddr, address, submit)

if submit:
proTxHash = protx_result
Expand Down