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

0.2.5 #208

Merged
merged 3 commits into from
Oct 6, 2020
Merged

0.2.5 #208

Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions examples/simpleapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ Otherwise, to run SimpleApp outside the IDE:
* (Windows)
```
cd Sidechains-SDK\examples\simpleapp
java -cp ./target/sidechains-sdk-simpleapp-0.2.4.jar;./target/lib/* com.horizen.examples.SimpleApp <path_to_config_file>
java -cp ./target/sidechains-sdk-simpleapp-0.2.5.jar;./target/lib/* com.horizen.examples.SimpleApp <path_to_config_file>
```
* (Linux)
```
cd ./Sidechains-SDK/examples/simpleapp
java -cp ./target/sidechains-sdk-simpleapp-0.2.4.jar:./target/lib/* com.horizen.examples.SimpleApp <path_to_config_file>
java -cp ./target/sidechains-sdk-simpleapp-0.2.5.jar:./target/lib/* com.horizen.examples.SimpleApp <path_to_config_file>
```
On some Linux OSs during backward transfers certificates proofs generation a extremely big RAM consumption may happen, that will lead to the process force killing by the OS.
While we keep monitoring the memory footprint of the proofs generation process, we have verified that setting the glibc per-thread cache with the following command 'export GLIBC_TUNABLES=glibc.malloc.tcache_count=0' just before starting the sidechain node in order keeps the memory consumption in check.
Expand Down
6 changes: 3 additions & 3 deletions examples/simpleapp/mc_sc_workflow_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Build SDK components by using command (in the root of the SDK folder):

Run Bootstrapping tool using command:

`java -jar tools/sctool/target/sidechains-sdk-scbootstrappingtools-0.2.4.jar`
`java -jar tools/sctool/target/sidechains-sdk-scbootstrappingtools-0.2.5.jar`

All other command are performed as commands for Bootstrapping tool in next format: `"command name" "parameters for command in JSON format"`.
For any help you could use command `help`, for exit just print `exit`
Expand Down Expand Up @@ -280,9 +280,9 @@ Run SimpleApp with the `my_settings.conf`:

* For Windows:
```
java -cp ./examples/simpleapp/target/sidechains-sdk-simpleapp-0.2.4.jar;./examples/simpleapp/target/lib/* com.horizen.examples.SimpleApp ./examples/simpleapp/src/main/resources/my_settings.conf
java -cp ./examples/simpleapp/target/sidechains-sdk-simpleapp-0.2.5.jar;./examples/simpleapp/target/lib/* com.horizen.examples.SimpleApp ./examples/simpleapp/src/main/resources/my_settings.conf
```
* For Linux:
```
java -cp ./examples/simpleapp/target/sidechains-sdk-simpleapp-0.2.4.jar:./examples/simpleapp/target/lib/* com.horizen.examples.SimpleApp ./examples/simpleapp/src/main/resources/my_settings.conf
java -cp ./examples/simpleapp/target/sidechains-sdk-simpleapp-0.2.5.jar:./examples/simpleapp/target/lib/* com.horizen.examples.SimpleApp ./examples/simpleapp/src/main/resources/my_settings.conf
```
4 changes: 2 additions & 2 deletions examples/simpleapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.horizen</groupId>
<artifactId>sidechains-sdk-simpleapp</artifactId>
<version>0.2.4</version>
<version>0.2.5</version>
<inceptionYear>2018</inceptionYear>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -16,7 +16,7 @@
<dependency>
<groupId>io.horizen</groupId>
<artifactId>sidechains-sdk</artifactId>
<version>0.2.4</version>
<version>0.2.5</version>
</dependency>

<dependency>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.horizen</groupId>
<artifactId>Sidechains</artifactId>
<version>0.2.4</version>
<version>0.2.5</version>
<inceptionYear>2018</inceptionYear>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
2 changes: 1 addition & 1 deletion qa/SidechainTestFramework/sc_test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def main(self):
help="Don't stop bitcoinds after the test execution")
parser.add_option("--zendir", dest="zendir", default="ZenCore/src",
help="Source directory containing zend/zen-cli (default: %default)")
parser.add_option("--scjarpath", dest="scjarpath", default="../examples/simpleapp/target/sidechains-sdk-simpleapp-0.2.4.jar;../examples/simpleapp/target/lib/* com.horizen.examples.SimpleApp", #New option. Main class path won't be needed in future
parser.add_option("--scjarpath", dest="scjarpath", default="../examples/simpleapp/target/sidechains-sdk-simpleapp-0.2.5.jar;../examples/simpleapp/target/lib/* com.horizen.examples.SimpleApp", #New option. Main class path won't be needed in future
help="Directory containing .jar file for SC (default: %default)")
parser.add_option("--tmpdir", dest="tmpdir", default="../examples/simpleapp/target/tmp",
help="Root directory for datadirs")
Expand Down
4 changes: 2 additions & 2 deletions qa/SidechainTestFramework/scutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def sync_sc_mempools(api_connections, wait_for=25):
def launch_bootstrap_tool(command_name, json_parameters):
json_param = json.dumps(json_parameters)
java_ps = subprocess.Popen(["java", "-jar",
"../tools/sctool/target/sidechains-sdk-scbootstrappingtools-0.2.4.jar",
"../tools/sctool/target/sidechains-sdk-scbootstrappingtools-0.2.5.jar",
command_name, json_param], stdout=subprocess.PIPE)
sc_bootstrap_output = java_ps.communicate()[0]
jsone_node = json.loads(sc_bootstrap_output)
Expand Down Expand Up @@ -342,7 +342,7 @@ def start_sc_node(i, dirname, extra_args=None, rpchost=None, timewait=None, bina
lib_separator = ";"

if binary is None:
binary = "../examples/simpleapp/target/sidechains-sdk-simpleapp-0.2.4.jar" + lib_separator + "../examples/simpleapp/target/lib/* com.horizen.examples.SimpleApp"
binary = "../examples/simpleapp/target/sidechains-sdk-simpleapp-0.2.5.jar" + lib_separator + "../examples/simpleapp/target/lib/* com.horizen.examples.SimpleApp"
# else if platform.system() == 'Linux':
bashcmd = 'java -cp ' + binary + " " + (datadir + ('/node%s.conf' % i))
sidechainclient_processes[i] = subprocess.Popen(bashcmd.split())
Expand Down
1 change: 1 addition & 0 deletions qa/sc_backward_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ def run_test(self):
assert_equal(1, len(mc_node.getblock(we1_2_mcblock_hash)["tx"]), "MC block expected to contain 1 transaction.")
assert_equal(1, len(mc_node.getblock(we1_2_mcblock_hash)["cert"]), "MC block expected to contain 1 Certificate.")
assert_equal(we0_certHash, mc_node.getblock(we1_2_mcblock_hash)["cert"][0], "MC block expected to contain certificate.")
print("MC block with withdrawal certificate for epoch 0 = {0}\n".format(str(mc_node.getblock(we1_2_mcblock_hash, False))))

# Generate SC block and verify that certificate is synced back
scblock_id4 = generate_next_blocks(sc_node, "first node", 1)[0]
Expand Down
76 changes: 76 additions & 0 deletions qa/test_data_generators/mc_blocks_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/usr/bin/env python2
import json

from SidechainTestFramework.sc_test_framework import SidechainTestFramework
from test_framework.util import assert_equal, assert_true, start_nodes, forward_transfer_to_sidechain
from SidechainTestFramework.scutil import create_sidechain, \
check_mainchain_block_reference_info, check_wallet_balance, generate_next_blocks
from SidechainTestFramework.sc_boostrap_info import SCCreationInfo, Account

"""
Generate MC Blocks data for Unit tests

Configuration: 1 MC node

Test:
- generate MC Block without sidechains
- generate MC Block with 3 sidechains mentioned
"""


class McTxsData(SidechainTestFramework):
def setup_nodes(self):
return start_nodes(1, self.options.tmpdir)

def sc_setup_chain(self):
pass

def sc_setup_nodes(self):
pass

def sc_setup_network(self, split=False):
pass

def run_test(self):
mc_node = self.nodes[0]
mc_node.generate(200)


# Generate MC Block without sidechains.
block_id = mc_node.generate(1)[0]
block_hex = mc_node.getblock(block_id, False)
block_json = mc_node.getblock(block_id)

print("MC Block without SC data: \nHash = {0}\nHex = {1}\nJson = {2}\n"
.format(str(block_id), str(block_hex), str(block_json)))


# Generate MC block with 3 sidechains mentioned.
sc_creation_info = SCCreationInfo(mc_node, 100, 1000)
boot_info = create_sidechain(sc_creation_info)
sidechain_id_1 = str(boot_info.sidechain_id)

boot_info = create_sidechain(sc_creation_info)
sidechain_id_2 = str(boot_info.sidechain_id)

boot_info = create_sidechain(sc_creation_info)
sidechain_id_3 = str(boot_info.sidechain_id)

sc_address = "000000000000000000000000000000000000000000000000000000000000add1"
# Send 3 FTs to different sidechains
mc_node.sc_send(sc_address, 1, sidechain_id_1) # 1 Zen
mc_node.sc_send(sc_address, 2, sidechain_id_2) # 2 Zen
mc_node.sc_send(sc_address, 3, sidechain_id_3) # 3 Zen
# Generate block
block_id = mc_node.generate(1)[0]
block_hex = mc_node.getblock(block_id, False)
block_json = mc_node.getblock(block_id)
# Note: we sort only 2 last characters, so almost equal to the sort of the little-endian bytes
sidechain_ids = [sidechain_id_1, sidechain_id_2, sidechain_id_3]
sorted_sidechain_ids = sorted(sidechain_ids, key = lambda x: x[-2:])
print("MC Block with multiple SCs mentioned: \nHash = {0}\nHex = {1}\nJson = {2}\nSidechains = {3}\n"
.format(str(block_id), str(block_hex), str(block_json), sorted_sidechain_ids))


if __name__ == "__main__":
McTxsData().main()
105 changes: 105 additions & 0 deletions qa/test_data_generators/mc_txs_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env python2
import json

from SidechainTestFramework.sc_test_framework import SidechainTestFramework
from test_framework.util import assert_equal, assert_true, start_nodes, forward_transfer_to_sidechain
from SidechainTestFramework.scutil import create_sidechain, \
check_mainchain_block_reference_info, check_wallet_balance, generate_next_blocks
from SidechainTestFramework.sc_boostrap_info import SCCreationInfo, Account

"""
Generate MC transactions for Unit tests

Configuration: 1 MC node

Test:
- generate MC Tx with version -4 with no SC data
- generate MC Tx with version -4 with single SidechainCreation output
- generate MC Tx with version -4 with single ForwardTransfer output
- generate MC Tx with version -4 with multiple ForwardTransfer outputs
"""


class McTxsData(SidechainTestFramework):
def setup_nodes(self):
return start_nodes(1, self.options.tmpdir)

def sc_setup_chain(self):
pass

def sc_setup_nodes(self):
pass

def sc_setup_network(self, split=False):
pass

def run_test(self):
mc_node = self.nodes[0]
mc_node.generate(200)


# Generate Tx with version -4 with no SC related outputs
mc_address = mc_node.getnewaddress()
tx_id = mc_node.sendtoaddress(mc_address, 10)
tx_hex = mc_node.getrawtransaction(tx_id)

print("MC Transaction with version -4 without SC data: \nHash = {0}\nSize = {1}\nHex = {2}\n"
.format(str(tx_id), len(tx_hex)/2, str(tx_hex)))


# Generate Tx with version -4 with single SidechainCreation output
# Use the same amount and withdrawal epoch length as for unit test
creation_amount = 50
withdrawal_epoch_length = 1000

sc_creation_info = SCCreationInfo(mc_node, creation_amount, withdrawal_epoch_length)
boot_info = create_sidechain(sc_creation_info)

sidechain_id = boot_info.sidechain_id
sc_creation_tx_id = mc_node.getblock(mc_node.getbestblockhash())["tx"][-1]
sc_creation_tx_hex = mc_node.getrawtransaction(sc_creation_tx_id)

print("MC Transaction with version -4 with single SidechainCreation output: \nHash = {0}\nSize = {1}\nHex = {2}"
"\nsidechain_id = {3}\ncreation_amount = {4}, withdrawal_epoch_length = {5}\n"
.format(str(sc_creation_tx_id), len(sc_creation_tx_hex) / 2, str(sc_creation_tx_hex),
sidechain_id, creation_amount, withdrawal_epoch_length))


# Generate Tx with version -4 with single ForwardTransfer output
forward_transfer_amount = 10
ft_tx_id = mc_node.sc_send(boot_info.genesis_account.publicKey, forward_transfer_amount, sidechain_id)
ft_tx_hex = mc_node.getrawtransaction(ft_tx_id)
print("MC Transaction with version -4 with single ForwardTransfer output: \nHash = {0}\nSize = {1}\nHex = {2}"
"\nsidechain_id = {3}\nforward_transfer_amount = {4}, public_key = {5}\n"
.format(str(ft_tx_id), len(ft_tx_hex) / 2, str(ft_tx_hex),
sidechain_id, forward_transfer_amount, boot_info.genesis_account.publicKey))


# Generate Tx with version -4 with multiple ForwardTransfer outputs
send_many_params = [
{
"scid": sidechain_id,
"amount": 10,
"address": "000000000000000000000000000000000000000000000000000000000000add1"
},
{
"scid": sidechain_id,
"amount": 11,
"address": "000000000000000000000000000000000000000000000000000000000000add2"
},
{
"scid": sidechain_id,
"amount": 12,
"address": "000000000000000000000000000000000000000000000000000000000000add3"
}
]
multiple_ft_tx_id = mc_node.sc_sendmany(send_many_params)
multiple_ft_tx_hex = mc_node.getrawtransaction(multiple_ft_tx_id)
print("MC Transaction with version -4 with multiple ForwardTransfer outputs: \nHash = {0}\nSize = {1}\n"
"Hex = {2}\nForward Transfers: = {3}\n"
.format(str(multiple_ft_tx_id), len(multiple_ft_tx_hex) / 2, str(multiple_ft_tx_hex),
json.dumps(send_many_params, indent=4)))


if __name__ == "__main__":
McTxsData().main()
18 changes: 8 additions & 10 deletions sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.horizen</groupId>
<artifactId>sidechains-sdk</artifactId>
<version>0.2.4</version>
<version>0.2.5</version>
<name>${project.groupId}:${project.artifactId}</name>
<description>Zendoo is a unique sidechain and scaling solution developed by Horizen. The Zendoo ${project.artifactId} is a framework that supports the creation of sidechains and their custom business logic, with the Horizen public blockchain as the mainchain.</description>
<url>https://github.com/${project.github.organization}/${project.artifactId}</url>
Expand Down Expand Up @@ -249,8 +249,6 @@
<include>sidechainblock_hex</include>
<include>sidechainblockheader_hex</include>
<include>ommer_hex</include>
<!-- block generated in testnet3 (with sidechain support) -->
<include>mcblock530290_testnet3</include>
<include>mcblock473173_mainnet</include>
<include>mcblock473174_mainnet</include>
<include>mcblock473175_mainnet</include>
Expand Down Expand Up @@ -288,18 +286,18 @@
<include>mctx_v2</include>
<!-- from https://explorer.horizen.global/api/rawtx/dee5a3758cee29648a6a50edf26c56db60c1186e434302299fd0f3e8339bf45a -->
<include>mctx_v-3</include>
<!-- generated on regtest on 15.10.2019 -->
<!-- generated on regtest on 28.09.2020 -->
<include>mctx_v-4_without_sc_data</include>
<!-- generated on regtest on 28.09.2020 -->
<include>mctx_v-4_single_ft</include>
<!-- generated on regtest on 15.10.2019 -->
<!-- generated on regtest on 28.09.2020 -->
<include>mctx_v-4_multiple_ft</include>
<!-- generated on regtest on 15.10.2019 -->
<!-- generated on regtest on 28.09.2020 -->
<include>mctx_v-4_sc_creation</include>
<include>sc_node_holder_fixter_settings.conf</include>
<include>new_mc_blocks/mc_block_empty_sidechains</include>
<include>new_mc_blocks/mc_block_create_3_sidechains</include>
<include>new_mc_blocks/mc_block_forward_transfer_2_sidechains</include>
<include>new_mc_blocks/mc_block_forward_transfer_3_backward_transfer</include>
<include>new_mc_blocks/mc_block_forward_transfer_3_backward_transfer_2</include>
<include>new_mc_blocks/mc_block_with_3_sidechains</include>
<include>new_mc_blocks/mc_block_with_backward_transfer</include>
<include>backward_transfer_certificate_empty</include>
<include>backward_transfer_certificate_non_empty</include>
</includes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ case class MainchainBlockReference(

data.proofOfNoData._1 match {
case Some(leftNeighbourProof) =>
if (new ByteArrayWrapper(leftNeighbourProof.sidechainId) >= sidechainId)
// Compare in little-endian like in MC
if (new ByteArrayWrapper(BytesUtils.reverseBytes(leftNeighbourProof.sidechainId)) >= new ByteArrayWrapper(BytesUtils.reverseBytes(sidechainId.data)))
throw new InconsistentMainchainBlockReferenceDataException(s"MainchainBlockReferenceData ${header.hashHex} left neighbour sidechain id is after current sidechain id")
val merkleRoot = leftNeighbourProof.merklePath.apply(SidechainCommitmentEntry.getSidechainCommitmentEntryHash(leftNeighbourProof))
if (!util.Arrays.equals(header.hashScTxsCommitment, merkleRoot))
Expand All @@ -131,7 +132,8 @@ case class MainchainBlockReference(

data.proofOfNoData._2 match {
case Some(rightNeighbourProof) =>
if (new ByteArrayWrapper(rightNeighbourProof.sidechainId) <= sidechainId)
// Compare in little-endian like in MC
if (new ByteArrayWrapper(BytesUtils.reverseBytes(rightNeighbourProof.sidechainId)) <= new ByteArrayWrapper(BytesUtils.reverseBytes(sidechainId.data)))
throw new InconsistentMainchainBlockReferenceDataException(s"MainchainBlockReferenceData ${header.hashHex} right neighbour sidechain id is before current sidechain id")
val merkleRoot = rightNeighbourProof.merklePath.apply(SidechainCommitmentEntry.getSidechainCommitmentEntryHash(rightNeighbourProof))
if (!util.Arrays.equals(header.hashScTxsCommitment, merkleRoot))
Expand Down
Loading