Skip to content

Commit

Permalink
Merge pull request #564 from HorizenOfficial/gp/general_refactoring
Browse files Browse the repository at this point in the history
General refactoring.
  • Loading branch information
Paolo Tagliaferri committed Jun 22, 2023
2 parents 79dfc49 + 884a5df commit 90503e9
Show file tree
Hide file tree
Showing 47 changed files with 185 additions and 181 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define(_CLIENT_VERSION_MINOR, 0)
define(_CLIENT_VERSION_REVISION, 99)
define(_CLIENT_VERSION_BUILD, 0)
define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50)))
define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1)))
define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-alpha$1))
define(_CLIENT_VERSION_IS_RELEASE, false)
define(_COPYRIGHT_YEAR, 2023)
AC_INIT([Zcash],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_SUFFIX(_ZC_BUILD_VAL)],[https://github.com/zcash/zcash/issues],[zcash])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# path to zend project root
repository_root: "./"
# release version to be backported (format "major.minor.patch", suffix must not be included if beta or candidate)
# release version to be backported (format "major.minor.patch", suffix must not be included if beta or candidate or alpha)
version: "4.0.0"
# build number (1-24 for beta (1-24), 25-49 for candidate (1-25), 50 for official)
# build number (0-24 for beta (1-25), 25-49 for candidate (1-25), 50 for official, 51+ for alpha (1+))
build_number: "50"
# script steps flow
script_steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# path to zend project root
repository_root: "./"
# new release version (format "major.minor.patch", suffix must not be included if beta or candidate)
# new release version (format "major.minor.patch", suffix must not be included if beta or candidate or alpha)
version: "4.0.0"
# build number (1-24 for beta (1-24), 25-49 for candidate (1-25), 50 for official)
# build number (0-24 for beta (1-25), 25-49 for candidate (1-25), 50 for official, 51+ for alpha (1+))
build_number: "50"
# mainnet config
mainnet:
Expand All @@ -16,8 +16,8 @@ testnet:
checkpoint_height: "1262900"
# total transaction from genesis block up to checkpoint (can be found in "debug.log" file)
total_transactions: "2145084"
# release date (format "%a, %d %b %Y", e.g. "Apr, 14 Fri 2023")
release_date: "May, 15 Mon 2023"
# release date (format "%a, %d %b %Y", e.g. "Fri, 14 Apr 2023")
release_date: "Mon, 15 May 2023"
# approximated release height (mainnet)
approx_release_height: "1349850"
# weeks until deprecation
Expand All @@ -36,6 +36,12 @@ script_steps:
skip: False
# stop before step (user interaction for proceeding)
stop: False
# initialize_create_branch (sub)step
initialize_create_branch:
# skip step
skip: False
# stop before step (user interaction for proceeding)
stop: False
# set_client_version step
set_client_version:
# skip step
Expand Down
13 changes: 7 additions & 6 deletions contrib/devtools/release_management/release_backport.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ def initialize():
config[rmu.k_version] = input("Enter the backported version (format major.minor.patch, e.g. 3.3.1): ")
print("Enter the backported build number:")
print("Please, use the following values:")
print("[ 1, 24] when releasing a beta version (e.g. 3.3.1-beta1, 3.3.1-beta2, etc.)")
print("[25, 49] when releasing a release candidate (e.g. 3.3.1-rc1, 3.3.1-rc2, etc.)")
print(" [50] when making an official release (e.g. 3.3.1)")
print("[ 0, 24] when backporting a beta version (e.g. 3.3.1-beta1, 3.3.1-beta2, etc.)")
print("[25, 49] when backporting a release candidate (e.g. 3.3.1-rc1, 3.3.1-rc2, etc.)")
print(" [50] when backporting an official release (e.g. 3.3.1)")
print(" [51+] when backporting an alpha version (e.g. 3.3.1-alpha1, 3.3.1-alpha2, etc.)")
config[rmu.k_build_number] = input("")
config[rmu.k_is_official_version] = (config[rmu.k_build_number] == "50")

build_number = int(config[rmu.k_build_number])
if (1 > build_number or build_number > 50):
if (0 > build_number):
print("Wrong build number; modify and retry.")
sys.exit(-1)

Expand Down Expand Up @@ -98,7 +99,7 @@ def reset_client_version():
rep_maj = rmu.replace_string_in_file(os.path.join(config[rmu.k_repository_root], "configure.ac"), r"define\(_CLIENT_VERSION_MAJOR, (\d+)\)", f"define(_CLIENT_VERSION_MAJOR, {version_digits[0]})")
rep_min = rmu.replace_string_in_file(os.path.join(config[rmu.k_repository_root], "configure.ac"), r"define\(_CLIENT_VERSION_MINOR, (\d+)\)", f"define(_CLIENT_VERSION_MINOR, {version_digits[1]})")
rep_rev = rmu.replace_string_in_file(os.path.join(config[rmu.k_repository_root], "configure.ac"), r"define\(_CLIENT_VERSION_REVISION, (\d+)\)", f"define(_CLIENT_VERSION_REVISION, {99})")
rep_bld = rmu.replace_string_in_file(os.path.join(config[rmu.k_repository_root], "configure.ac"), r"define\(_CLIENT_VERSION_BUILD, (\d+)\)", f"define(_CLIENT_VERSION_BUILD, {0})")
rep_bld = rmu.replace_string_in_file(os.path.join(config[rmu.k_repository_root], "configure.ac"), r"define\(_CLIENT_VERSION_BUILD, (\d+)\)", f"define(_CLIENT_VERSION_BUILD, {51})")
if (not rep_maj and not rep_min and not rep_rev and not rep_bld):
print("Version replacement failed (configure.ac)")
sys.exit(-1)
Expand All @@ -108,7 +109,7 @@ def reset_client_version():
rep_maj = rmu.replace_string_in_file(os.path.join(config[rmu.k_repository_root], "src/clientversion.h"), r"(#define\s+CLIENT_VERSION_MAJOR\s+)(\d+)", f"\\g<1>{version_digits[0]}")
rep_min = rmu.replace_string_in_file(os.path.join(config[rmu.k_repository_root], "src/clientversion.h"), r"(#define\s+CLIENT_VERSION_MINOR\s+)(\d+)", f"\\g<1>{version_digits[1]}")
rep_rev = rmu.replace_string_in_file(os.path.join(config[rmu.k_repository_root], "src/clientversion.h"), r"(#define\s+CLIENT_VERSION_REVISION\s+)(\d+)", f"\\g<1>{99}")
rep_bld = rmu.replace_string_in_file(os.path.join(config[rmu.k_repository_root], "src/clientversion.h"), r"(#define\s+CLIENT_VERSION_BUILD\s+)(\d+)", f"\\g<1>{0}")
rep_bld = rmu.replace_string_in_file(os.path.join(config[rmu.k_repository_root], "src/clientversion.h"), r"(#define\s+CLIENT_VERSION_BUILD\s+)(\d+)", f"\\g<1>{51}")
if (not rep_maj and not rep_min and not rep_rev and not rep_bld):
print("Version replacement failed (src/clientversion.h)")
sys.exit(-1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# THIS IS A TEMPLATE FILE, FOR EXAMPLES ON ACTUAL RELEASES CHECK CONTENT OF configs/release_backport_config-X.Y.Z.yaml FILES
# path to zend project root
repository_root: "./"
# release version to be backported (format "major.minor.patch", suffix must not be included if beta or candidate)
# release version to be backported (format "major.minor.patch", suffix must not be included if beta or candidate or alpha)
version: ""
# build number (1-24 for beta (1-24), 25-49 for candidate (1-25), 50 for official)
# build number (0-24 for beta (1-25), 25-49 for candidate (1-25), 50 for official, 51+ for alpha (1+))
build_number: ""
# script steps flow
script_steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,14 @@ def get_version_string_details(version_string: str):
return digits

def get_build_suffix(build_number: int):
if (1 <= build_number and build_number <= 24):
return f"-beta{build_number}"
if (0 <= build_number and build_number <= 24):
return f"-beta{build_number + 1}"
if (25 <= build_number and build_number <= 49):
return f"-rc{build_number - 24}"
if (build_number == 50):
return ""
if (51 <= build_number):
return f"-alpha{build_number - 50}"
return ""

def replace_string_in_file(filepath: str, old_string_regex: str, new_string: str, ):
Expand Down
7 changes: 4 additions & 3 deletions contrib/devtools/release_management/release_preparation.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,14 @@ def initialize():
config[rmu.k_version] = input("Enter the new version (format major.minor.patch, e.g. 3.3.1): ")
print("Enter the build number:")
print("Please, use the following values:")
print("[ 1, 24] when releasing a beta version (e.g. 3.3.1-beta1, 3.3.1-beta2, etc.)")
print("[ 0, 24] when releasing a beta version (e.g. 3.3.1-beta1, 3.3.1-beta2, etc.)")
print("[25, 49] when releasing a release candidate (e.g. 3.3.1-rc1, 3.3.1-rc2, etc.)")
print(" [50] when making an official release (e.g. 3.3.1)")
print(" [50] when releasing an official release (e.g. 3.3.1)")
print(" [51+] when releasing an alpha version (e.g. 3.3.1-alpha1, 3.3.1-alpha2, etc.)")
config[rmu.k_build_number] = input("")

build_number = int(config[rmu.k_build_number])
if (1 > build_number or build_number > 50):
if (0 > build_number):
print("Wrong build number; modify and retry.")
sys.exit(-1)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# THIS IS A TEMPLATE FILE, FOR EXAMPLES ON ACTUAL RELEASES CHECK CONTENT OF configs/release_preparation_config-X.Y.Z.yaml FILES
# path to zend project root
repository_root: "./"
# new release version (format "major.minor.patch", suffix must not be included if beta or candidate)
# new release version (format "major.minor.patch", suffix must not be included if beta or candidate or alpha)
version: ""
# build number (1-24 for beta (1-24), 25-49 for candidate (1-25), 50 for official)
# build number (0-24 for beta (1-25), 25-49 for candidate (1-25), 50 for official, 51+ for alpha (1+))
build_number: ""
# mainnet config
mainnet:
Expand Down
4 changes: 2 additions & 2 deletions qa/rpc-tests/blockdelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def run_test(self):
self.mark_logs("Joining network")
# raw_input("press enter to join the netorks..")
self.join_network()
self.sync_longest_fork(1, 10);
self.sync_longest_fork(1, 10)

print("\nNetwork joined")

Expand Down Expand Up @@ -303,7 +303,7 @@ def run_test(self):
self.nodes[3].generate(64)
print("Malicious blocks generated")

self.sync_longest_fork(1, 10);
self.sync_longest_fork(1, 10)

for i in range(0, 4):
print("Node%d ---" % i)
Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/checkblockatheight.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def run_test(self):

# we will perform on attack aimed at reverting from this block (latest generated) upward
h_attacked = h_current
hash_attacked = blocks[-1];
hash_attacked = blocks[-1]
assert hash_attacked == blocks[h_attacked]
hash_attacked_swapped = swap_bytes(hash_attacked)
hex_tmp = "%04x" % h_attacked
Expand Down
46 changes: 23 additions & 23 deletions qa/rpc-tests/fundrawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def run_test(self):
self.sync_all()
self.nodes[0].generate(101)
self.sync_all()
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.5);
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.0);
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),5.0);
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.5)
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),1.0)
self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(),5.0)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
Expand Down Expand Up @@ -111,7 +111,7 @@ def run_test(self):
for aUtx in listunspent:
if aUtx['amount'] == 5.0:
utx = aUtx
break;
break

assert_equal(utx!=False, True)

Expand Down Expand Up @@ -140,7 +140,7 @@ def run_test(self):
for aUtx in listunspent:
if aUtx['amount'] == 5.0:
utx = aUtx
break;
break

assert_equal(utx!=False, True)

Expand Down Expand Up @@ -170,7 +170,7 @@ def run_test(self):
for aUtx in listunspent:
if aUtx['amount'] == 1.0:
utx = aUtx
break;
break

assert_equal(utx!=False, True)

Expand Down Expand Up @@ -295,7 +295,7 @@ def run_test(self):
except JSONRPCException as e:
errorString = e.error['message']

assert_equal("Insufficient" in errorString, True);
assert_equal("Insufficient" in errorString, True)



Expand All @@ -307,11 +307,11 @@ def run_test(self):
fundedTx = self.nodes[0].fundrawtransaction(rawTx)

#create same transaction over sendtoaddress
txId = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1.1);
txId = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1.1)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']

#compare fee
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################

Expand All @@ -322,11 +322,11 @@ def run_test(self):
rawTx = self.nodes[0].createrawtransaction(inputs, outputs)
fundedTx = self.nodes[0].fundrawtransaction(rawTx)
#create same transaction over sendtoaddress
txId = self.nodes[0].sendmany("", outputs);
txId = self.nodes[0].sendmany("", outputs)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']

#compare fee
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################

Expand All @@ -349,11 +349,11 @@ def run_test(self):
fundedTx = self.nodes[0].fundrawtransaction(rawTx)

#create same transaction over sendtoaddress
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1);
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']

#compare fee
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################

Expand Down Expand Up @@ -382,11 +382,11 @@ def run_test(self):
fundedTx = self.nodes[0].fundrawtransaction(rawTx)

#create same transaction over sendtoaddress
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1);
txId = self.nodes[0].sendtoaddress(mSigObj, 1.1)
signedFee = self.nodes[0].getrawmempool(True)[txId]['fee']

#compare fee
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance)
############################################################

Expand All @@ -405,7 +405,7 @@ def run_test(self):


# send 1.2 BTC to msig addr
txId = self.nodes[0].sendtoaddress(mSigObj, 1.2);
txId = self.nodes[0].sendtoaddress(mSigObj, 1.2)
self.sync_all()
self.nodes[1].generate(1)
self.sync_all()
Expand Down Expand Up @@ -442,7 +442,7 @@ def run_test(self):

error = False
try:
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.2);
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), 1.2)
except:
error = True
assert(error)
Expand Down Expand Up @@ -472,13 +472,13 @@ def run_test(self):
###############################################

#empty node1, send some small coins from node0 to node1
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True);
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()

for i in range(0,20):
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01);
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
Expand All @@ -490,11 +490,11 @@ def run_test(self):
fundedTx = self.nodes[1].fundrawtransaction(rawTx)

#create same transaction over sendtoaddress
txId = self.nodes[1].sendmany("", outputs);
txId = self.nodes[1].sendmany("", outputs)
signedFee = self.nodes[1].getrawmempool(True)[txId]['fee']

#compare fee
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee);
feeDelta = Decimal(fundedTx['fee']) - Decimal(signedFee)
assert(feeDelta >= 0 and feeDelta <= feeTolerance*19) #~19 inputs


Expand All @@ -503,13 +503,13 @@ def run_test(self):
#############################################

#again, empty node1, send some small coins from node0 to node1
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True);
self.nodes[1].sendtoaddress(self.nodes[0].getnewaddress(), self.nodes[1].getbalance(), "", "", True)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()

for i in range(0,20):
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01);
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
self.sync_all()
self.nodes[0].generate(1)
self.sync_all()
Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/getblocktemplate_blockmaxcomplexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def run_test(self):
self.nodes[1].generate(50)
self.sync_all()

node1_taddr = self.nodes[1].getnewaddress();
node1_taddr = self.nodes[1].getnewaddress()

# Create transaction 3 transactions with 10 inputs each
# Each transaction complexity will be equal to 10*10=100
Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/getblocktemplate_proposals.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def run_test(self):
self.doTest(sc_fork_reached)

# reach the height where the next block is the last before the fork point where certificates are supported
delta = ForkHeights['MINIMAL_SC'] - currentHeight - 2;
delta = ForkHeights['MINIMAL_SC'] - currentHeight - 2
self.nodes[0].generate(delta)
self.sync_all()

Expand Down
4 changes: 2 additions & 2 deletions qa/rpc-tests/getchaintips.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def run_test (self):

# Split the network and build two chains of different lengths.
self.split_network ()
self.nodes[0].generate(10);
self.nodes[2].generate(20);
self.nodes[0].generate(10)
self.nodes[2].generate(20)
self.sync_all ()

tips = self.nodes[1].getchaintips ()
Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/mempool_tx_input_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def run_test(self):
node0_zaddr = self.nodes[0].z_getnewaddress()

# Send three inputs from node 0 taddr to zaddr to get out of coinbase
node0_taddr = self.nodes[0].getnewaddress();
node0_taddr = self.nodes[0].getnewaddress()
recipients = []
recipients.append({"address":node0_zaddr, "amount":Decimal('30.0')-Decimal('0.0001')}) # utxo amount less fee
myopid = self.nodes[0].z_sendmany(node0_taddr, recipients)
Expand Down
2 changes: 1 addition & 1 deletion qa/rpc-tests/nulldata.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def doTest():
except JSONRPCException as e:
# this will be refused because data size exceeds max
errorString = e.error['message']
assert_equal("scriptpubkey" in errorString, True);
assert_equal("scriptpubkey" in errorString, True)
print("...Ok, refused data exceeding max size")


Expand Down
Loading

0 comments on commit 90503e9

Please sign in to comment.