diff --git a/README.md b/README.md index 780c99dfb..01b9a2a5b 100644 --- a/README.md +++ b/README.md @@ -89,77 +89,11 @@ pip3 install -U qrl --log ~/pip3-Qrl.log * * * -## Wallet - -Create a new wallet using the `qrl` command. After you create a wallet you can create a new `slaves.json` file and use it to mine with. - -### Create New Wallet - -```bash -# Create a new wallet -qrl wallet_gen -``` -### Get Mnemonic/hexseed - -```bash -# Get mnemonic phrase and hexseed -qrl wallet_secret -``` -### Recover QRL Wallet - -```bash -# Options: -# --seed-type [hexseed|mnemonic] -# --help Show this message and exit. - -qrl wallet_recover --seed-type mnemonic -``` - -### Generate a slaves.json file - -Using the wallet you just created generate the slaves.json file against a know working node. You can switch the ip-address with a trusted open node. - -``` -# QRL Nodes - -104.237.3.185 -104.237.3.184 -104.251.219.145 -104.251.219.40 -``` - -```bash -# Generate slaves.json file -qrl -r --host 104.237.3.185 slave_tx_generate -``` -This will prompt with some questions: - -```bash -Src []: # The wallet you generated by #ID -Addr from []: # (Leave blank in case same as source) -Number of slaves [0]: # Enter 4 -Access type [0]: # Mining only or transfer coins [0],[1] - # 0 Gives all permissions from the master wallet to slave wallet - # 1 Only mining permissions to slave wallet - # This setting allows incoming only transfers (SAFE) -Fee [0.0]: 0 # How much fee -``` - -This will generate a `slaves.json` in the directory you are in. - -If you have saved the **Mnemonic** or **hexseed** somewhere safe you can delete the open `wallet.qrl` file and use the `slaves.json` file to mine with. - -Move this fie into your `~/.qrl` directory. If needed, create the directory. - -* * * - ## Start QRL Node -Now that we have a `slaves.json` file in our ~/.qrl folder we can start qrl. - ```bash # start qrl -start_qrl +start_qrl --miningCreditWallet=YOUR_QRL_ADDRESS ``` Check out all the options with a simple `start_qrl --help` @@ -168,7 +102,7 @@ Using `screen` you can run in the background and reconnect later. You may need t ```bash # run in background -screen -d -m start_qrl +screen -d -m start_qrl --miningCreditWallet=YOUR_QRL_ADDRESS ``` You can see the progress in the `~/.qrl/qrl.log` file. diff --git a/qrl/core/config.py b/qrl/core/config.py index 2fcb66379..b33cb9800 100644 --- a/qrl/core/config.py +++ b/qrl/core/config.py @@ -106,7 +106,7 @@ def __init__(self): self.version = version self.required_version = '0.0.' - self.genesis_prev_headerhash = b'The Burning Ice' + self.genesis_prev_headerhash = b'Excession' ################################################################ # Warning: Don't change following configuration. # @@ -142,7 +142,7 @@ def __init__(self): self.ots_bitfield_size = ceil(self.max_ots_tracking_index / 8) self.default_nonce = 0 - self.default_account_balance = 100 * (10 ** 9) + self.default_account_balance = 0 * (10 ** 9) self.hash_buffer_size = 4 self.minimum_minting_delay = 45 # Minimum delay in second before a block is being created self.mining_setpoint_blocktime = 60 @@ -158,7 +158,7 @@ def __init__(self): self.slave_dat_filename = 'slave.qrl' self.banned_peers_filename = 'banned_peers.qrl' - self.genesis_timestamp = 1519601074 + self.genesis_timestamp = 1521888567 self.supplied_coins = 65000000 * (10 ** 9) diff --git a/qrl/core/genesis.json b/qrl/core/genesis.json index d4888379d..a26756aa7 100644 --- a/qrl/core/genesis.json +++ b/qrl/core/genesis.json @@ -1,7 +1,7 @@ { "header": { - "hashHeader": "HCAERhKw6N0g2VahApsS21eJFXCztfjSev0QYVqPLYw=", - "hashHeaderPrev": "VGhlIEJ1cm5pbmcgSWNl", + "hashHeader": "PW0i0dvkzO+WGAuMZWYBdXYv9i/4SeEOj75peRnF3eA=", + "hashHeaderPrev": "RXhjZXNzaW9u", "rewardBlock": "65000000000000000", "merkleRoot": "D9OP1iojqiWK3nIasICIdc8OJOVT+LVBiMGfMQyfeQA=" }, diff --git a/tests/core/test_ChainManager.py b/tests/core/test_ChainManager.py index c556f9e07..f9305fd72 100644 --- a/tests/core/test_ChainManager.py +++ b/tests/core/test_ChainManager.py @@ -15,7 +15,7 @@ from qrl.core.GenesisBlock import GenesisBlock from qrl.core.State import State from qrl.core.Transaction import SlaveTransaction, TransferTransaction -from tests.misc.helper import get_alice_xmss, get_bob_xmss, set_data_dir +from tests.misc.helper import get_alice_xmss, get_bob_xmss, set_data_dir, set_default_balance_size class TestChainManager(TestCase): @@ -57,7 +57,7 @@ def test_simple_add_block(self): prevblock_headerhash=genesis_block.headerhash, transactions=[], miner_address=alice_xmss.address) - block_1.set_mining_nonce(162) + block_1.set_mining_nonce(219) # Uncomment only to determine the correct mining_nonce of above blocks # from qrl.core.PoWValidator import PoWValidator @@ -70,6 +70,7 @@ def test_simple_add_block(self): self.assertTrue(result) self.assertEqual(chain_manager.last_block, block_1) + @set_default_balance_size() def test_multi_output_transaction_add_block(self): with set_data_dir('no_data'): with State() as state: @@ -108,7 +109,7 @@ def test_multi_output_transaction_add_block(self): prevblock_headerhash=genesis_block.headerhash, transactions=[transfer_transaction], miner_address=alice_xmss.address) - block_1.set_mining_nonce(339) + block_1.set_mining_nonce(237) # Uncomment only to determine the correct mining_nonce of above blocks # from qrl.core.PoWValidator import PoWValidator @@ -170,7 +171,12 @@ def test_add_block(self, mock_difficulty_tracker_get): prevblock_headerhash=genesis_block.headerhash, transactions=[slave_tx], miner_address=alice_xmss.address) - block_1.set_mining_nonce(1) + block_1.set_mining_nonce(0) + # Uncomment only to determine the correct mining_nonce of above blocks + # from qrl.core.PoWValidator import PoWValidator + # while not PoWValidator().validate_mining_nonce(state, block_1.blockheader, False): + # block_1.set_mining_nonce(block_1.mining_nonce + 1) + # print(block_1.mining_nonce) result = chain_manager.add_block(block_1) self.assertTrue(result) @@ -188,7 +194,12 @@ def test_add_block(self, mock_difficulty_tracker_get): transactions=[], miner_address=bob_xmss.address) - block.set_mining_nonce(4) + block.set_mining_nonce(0) + # Uncomment only to determine the correct mining_nonce of above blocks + # from qrl.core.PoWValidator import PoWValidator + # while not PoWValidator().validate_mining_nonce(state, block.blockheader, False): + # block.set_mining_nonce(block.mining_nonce + 1) + # print(block.mining_nonce) result = chain_manager.add_block(block) self.assertTrue(result) @@ -204,7 +215,12 @@ def test_add_block(self, mock_difficulty_tracker_get): transactions=[], miner_address=bob_xmss.address) - block_2.set_mining_nonce(0) + block_2.set_mining_nonce(1) + # Uncomment only to determine the correct mining_nonce of above blocks + # from qrl.core.PoWValidator import PoWValidator + # while not PoWValidator().validate_mining_nonce(state, block_2.blockheader, False): + # block_2.set_mining_nonce(block_2.mining_nonce + 1) + # print(block_2.mining_nonce) result = chain_manager.add_block(block_2) self.assertTrue(result) @@ -239,12 +255,12 @@ def test_orphan_block(self): alice_xmss = get_alice_xmss() with mock.patch('qrl.core.misc.ntp.getTime') as time_mock: - time_mock.return_value = 1519601174 # Very high to get an easy difficulty + time_mock.return_value = 1521889325 # Very high to get an easy difficulty block_1 = Block.create(block_number=1, prevblock_headerhash=genesis_block.headerhash, transactions=[], miner_address=alice_xmss.address) - block_1.set_mining_nonce(71) + block_1.set_mining_nonce(78) # Uncomment only to determine the correct mining_nonce of above blocks # from qrl.core.PoWValidator import PoWValidator # while not PoWValidator().validate_mining_nonce(state, block_1.blockheader, False): @@ -258,12 +274,12 @@ def test_orphan_block(self): bob_xmss = get_bob_xmss() with mock.patch('qrl.core.misc.ntp.getTime') as time_mock: - time_mock.return_value = 1519601174 + devconfig.minimum_minting_delay * 2 + time_mock.return_value = 1521889326 + devconfig.minimum_minting_delay * 2 block = Block.create(block_number=1, prevblock_headerhash=genesis_block.headerhash, transactions=[], miner_address=bob_xmss.address) - block.set_mining_nonce(91) + block.set_mining_nonce(221) # Uncomment only to determine the correct mining_nonce of above blocks # from qrl.core.PoWValidator import PoWValidator @@ -272,12 +288,12 @@ def test_orphan_block(self): # print(block.mining_nonce) with mock.patch('qrl.core.misc.ntp.getTime') as time_mock: - time_mock.return_value = 1519601174 + devconfig.minimum_minting_delay * 3 + time_mock.return_value = 1521889327 + devconfig.minimum_minting_delay * 3 block_2 = Block.create(block_number=2, prevblock_headerhash=block.headerhash, transactions=[], miner_address=bob_xmss.address) - block_2.set_mining_nonce(5) + block_2.set_mining_nonce(1) # Uncomment only to determine the correct mining_nonce of above blocks # from qrl.core.PoWValidator import PoWValidator diff --git a/tests/core/test_State.py b/tests/core/test_State.py index 85ed0d025..fb638cc44 100644 --- a/tests/core/test_State.py +++ b/tests/core/test_State.py @@ -15,7 +15,8 @@ from qrl.core.Block import Block from qrl.core.BlockMetadata import BlockMetadata from qrl.generated import qrl_pb2 -from tests.misc.helper import set_data_dir, get_alice_xmss, get_bob_xmss, get_token_transaction +from tests.misc.helper import set_data_dir, get_alice_xmss, get_bob_xmss, get_token_transaction, \ + set_default_balance_size logger.initialize_default() @@ -198,6 +199,7 @@ def test_address_state(self): with self.assertRaises(Exception): state.set_addresses_state({"state": 'test'}, 0) + @set_default_balance_size() def test_basic_state_funcs(self): with set_data_dir('no_data'): with State() as state: diff --git a/tests/misc/helper.py b/tests/misc/helper.py index 072a214fa..59aced0cb 100644 --- a/tests/misc/helper.py +++ b/tests/misc/helper.py @@ -35,6 +35,16 @@ from tests.misc.random_number_generator import RNG +@contextlib.contextmanager +def set_default_balance_size(new_value=100 * int(config.dev.shor_per_quanta)): + old_value = config.dev.block_timeseries_size + try: + config.dev.default_account_balance = new_value + yield + finally: + config.dev.default_account_balance = old_value + + @contextlib.contextmanager def set_wallet_dir(wallet_name): dst_dir = tempfile.mkdtemp() diff --git a/tests/services/test_PublicAPIService_transfer.py b/tests/services/test_PublicAPIService_transfer.py index 450934ca2..4bb123463 100644 --- a/tests/services/test_PublicAPIService_transfer.py +++ b/tests/services/test_PublicAPIService_transfer.py @@ -16,7 +16,7 @@ from qrl.crypto.misc import sha256 from qrl.generated import qrl_pb2 from qrl.services.PublicAPIService import PublicAPIService -from tests.misc.helper import get_alice_xmss, set_data_dir, set_wallet_dir, get_bob_xmss +from tests.misc.helper import get_alice_xmss, set_data_dir, set_wallet_dir, get_bob_xmss, set_default_balance_size logger.initialize_default() @@ -25,6 +25,7 @@ class TestPublicAPI(TestCase): def __init__(self, *args, **kwargs): super(TestPublicAPI, self).__init__(*args, **kwargs) + @set_default_balance_size() def test_transferCoins_get_unsigned(self): with set_data_dir('no_data'): with State() as db_state: @@ -59,7 +60,8 @@ def test_transferCoins_get_unsigned(self): self.assertIsNotNone(response) self.assertIsNotNone(response.extended_transaction_unsigned) - self.assertEqual('transfer', response.extended_transaction_unsigned.tx.WhichOneof('transactionType')) + self.assertEqual('transfer', + response.extended_transaction_unsigned.tx.WhichOneof('transactionType')) self.assertEqual(12, response.extended_transaction_unsigned.tx.fee) self.assertEqual(alice.pk, response.extended_transaction_unsigned.tx.public_key) @@ -71,6 +73,7 @@ def test_transferCoins_get_unsigned(self): self.assertEqual(bob.address, response.extended_transaction_unsigned.tx.transfer.addrs_to[0]) self.assertEqual(101, response.extended_transaction_unsigned.tx.transfer.amounts[0]) + @set_default_balance_size() def test_transferCoins_push_unsigned(self): with set_data_dir('no_data'): with State() as db_state: @@ -125,6 +128,7 @@ def test_transferCoins_push_unsigned(self): self.assertEqual(qrl_pb2.PushTransactionResp.VALIDATION_FAILED, resp_push.error_code) + @set_default_balance_size() def test_transferCoins_sign(self): with set_data_dir('no_data'): with State() as db_state: