Skip to content

Commit

Permalink
Merge pull request #1765 from theQRL/dev
Browse files Browse the repository at this point in the history
Merged Dev
  • Loading branch information
cyyber authored Nov 18, 2022
2 parents 1bbd78d + cbddb72 commit 759c9bb
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 56 deletions.
27 changes: 9 additions & 18 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2
jobs:
build:
docker:
- image: qrledger/qrl-docker-ci:xenial
- image: qrledger/qrl-docker-ci:bionic
steps:
- checkout
- run: pip install -U setuptools
Expand All @@ -14,7 +14,7 @@ jobs:

test_leaks_CLI:
docker:
- image: qrledger/qrl-docker-ci:xenial
- image: qrledger/qrl-docker-ci:bionic
steps:
- checkout
- run: pip install -U setuptools
Expand All @@ -25,15 +25,15 @@ jobs:

flake8:
docker:
- image: qrledger/qrl-docker-ci:xenial
- image: qrledger/qrl-docker-ci:bionic
steps:
- checkout
- run: pip install -U setuptools
- run: flake8

test_leaks_other:
docker:
- image: qrledger/qrl-docker-ci:xenial
- image: qrledger/qrl-docker-ci:bionic
steps:
- checkout
- run: pip install -U setuptools
Expand All @@ -42,17 +42,6 @@ jobs:
- run: pip install -U pytest-openfiles pytest-leaks pytest-threadleak pytest-repeat
- run: python3 setup.py test --addopts "--ignore=tests/tools/ --ignore=tests/daemon/ --ignore=tests/services/test_WalletAPIService.py --open-files --threadleak -n0"

build_trusty:
docker:
- image: qrledger/qrl-docker-ci:trusty
steps:
- checkout
- run: pip install -U setuptools
- run: pip install -U -r requirements.txt
- run: pip install -U -r test-requirements.txt
- run: python3 --version
- run: python3 setup.py test

build_bionic:
docker:
- image: qrledger/qrl-docker-ci:bionic
Expand All @@ -65,7 +54,7 @@ jobs:

integration_fast:
docker:
- image: qrledger/qrl-docker-ci:xenial
- image: qrledger/qrl-docker-ci:bionic
environment:
PYTHONPATH: /root/project:/root/project/tests_integration
TESTINPLACE: 1
Expand All @@ -79,12 +68,14 @@ jobs:

integration_smoke:
docker:
- image: qrledger/qrl-docker-ci:xenial
- image: qrledger/qrl-docker-ci:bionic
environment:
PYTHONPATH: /root/project:/root/project/tests_integration
TESTINPLACE: 1
steps:
- checkout
- run: apt-get update
- run: apt-get install -y rsync
- run: git submodule update --init --recursive --remote
- run: apt install -y python3-venv
- run: pip install -U -r requirements.txt
Expand Down Expand Up @@ -119,7 +110,7 @@ jobs:

deploy-pypi:
docker:
- image: qrledger/qrl-docker-ci:xenial
- image: qrledger/qrl-docker-ci:bionic
steps:
- checkout
- run: git submodule update --init --recursive
Expand Down
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# Fixing sphinx version due to https://github.com/sphinx-doc/sphinx/issues/3976
# setuptools==50.3.2 # It needs to be installed manually in some cases
plyvel==1.2.0
plyvel>=1.2.0,<=1.4.0
ntplib==0.3.4
Twisted==20.3.0
colorlog==3.1.0
simplejson==3.11.1
PyYAML==5.3.1
grpcio-tools>=1.9.0,<=1.27.2
grpcio>=1.9.0,<=1.27.2
grpcio-tools>=1.9.0,<=1.50.0
grpcio>=1.9.0,<=1.50.0
google-api-python-client==1.8.3
google-auth<2.0dev,>=1.21.1
httplib2>=0.15.0
service_identity==17.0.0
protobuf==3.15.8
protobuf>3.19.0,<=3.20.3
pyopenssl==17.5.0
six==1.13.0
click==7.1.2
click==8.0
pyqrllib>=1.2.3,<1.3.0
pyqryptonight>=0.99.9
pyqrandomx>=0.3.0,<1.0.0
Flask>=1.0.0,<=1.1.2
json-rpc==1.10.8
Flask>=2.0.0,<=2.2.2
json-rpc==1.13.0
idna==2.6
cryptography==2.3
mock==2.0.0
mock>=2.0.0
daemonize==2.4.7
22 changes: 11 additions & 11 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,37 @@ package_dir =
# install_requires = numpy; scipy
install_requires =
# setuptools==50.3.2
plyvel==1.2.0
plyvel>=1.2.0,<=1.4.0
ntplib==0.3.4
Twisted==20.3.0
colorlog==3.1.0
simplejson==3.11.1
PyYAML==5.3.1
grpcio-tools>=1.9.0,<=1.27.2
grpcio>=1.9.0,<=1.27.2
grpcio-tools>=1.9.0,<=1.50.0
grpcio>=1.9.0,<=1.50.0
google-api-python-client==1.8.3
google-auth<2.0dev,>=1.21.1
httplib2>=0.15.0
service_identity==17.0.0
protobuf==3.15.8
protobuf>3.19.0,<=3.20.3
pyopenssl==17.5.0
six==1.13.0
click==7.1.2
click==8.0
pyqrllib>=1.2.3,<1.3.0
pyqryptonight>=0.99.9
pyqrandomx>=0.3.0,<1.0.0
Flask>=1.0.0,<=1.1.2
json-rpc==1.10.8
Flask>=2.0.0,<=2.2.2
json-rpc==1.13.0
idna==2.6
cryptography==2.3
mock==2.0.0
mock>=2.0.0
daemonize==2.4.7

# Add here test requirements (semicolon-separated)
tests_require =
pytest==3.6
pytest-cov==2.5.1
pytest-xdist==1.22.2
pytest>=7.0.0,<=7.1.3
pytest-cov==4.0.0
pytest-xdist==2.5.0
pytest-flake8==1.0.0
flake8==3.5.0
autoflake==1.1
Expand Down
24 changes: 22 additions & 2 deletions src/qrl/core/ChainManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,24 @@ def get_config_by_block_number(self, block_number: int) -> config.DevConfig:
dev_config = config.DevConfig(dev_config_pb_data, True, True)
return dev_config

def get_seed_block(self, blockheader: BlockHeader):
qn = Qryptonight()
seed_height = qn.get_seed_height(blockheader.block_number)

# If parent block belongs to main chain, then seed block will also be in the main chain
prev_mainchain_block = self.get_block_by_number(blockheader.block_number - 1)
if prev_mainchain_block.headerhash == blockheader.prev_headerhash:
return self.get_block_by_number(seed_height)

prev_block = self.get_block(blockheader.prev_headerhash)
while prev_block.block_number > seed_height:
prev_mainchain_block = self.get_block_by_number(prev_block.block_number)
if prev_mainchain_block.headerhash == prev_block.headerhash:
return self.get_block_by_number(seed_height)
prev_block = self.get_block(prev_block.prev_headerhash)

return prev_block

def validate_mining_nonce(self, blockheader: BlockHeader, dev_config: config.DevConfig, enable_logging=True):
with self.lock:
parent_metadata = BlockMetadata.get_block_metadata(self._state, blockheader.prev_headerhash)
Expand All @@ -342,6 +360,8 @@ def validate_mining_nonce(self, blockheader: BlockHeader, dev_config: config.Dev
dev_config=dev_config)

mining_blob = blockheader.mining_blob(dev_config)
qn = Qryptonight()
seed_block = self.get_seed_block(blockheader)

if enable_logging:
logger.debug('-----------------START--------------------')
Expand All @@ -352,10 +372,10 @@ def validate_mining_nonce(self, blockheader: BlockHeader, dev_config: config.Dev
logger.debug('diff %s', UInt256ToString(diff))
logger.debug('target %s', bin2hstr(target))
logger.debug('mining blob %s', bin2hstr(mining_blob))
logger.debug('seed_block #%s', seed_block.block_number)
logger.debug('seed_block hash %s', bin2hstr(seed_block.headerhash))
logger.debug('-------------------END--------------------')

qn = Qryptonight()
seed_block = self.get_block_by_number(qn.get_seed_height(blockheader.block_number))
if not PoWValidator().verify_input(blockheader.block_number,
seed_block.block_number,
seed_block.headerhash,
Expand Down
3 changes: 2 additions & 1 deletion src/qrl/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ def __init__(self, pbdata, ignore_check=False, ignore_singleton=False):
# ======================================
self.hard_fork_heights = [942375, 1938000, 2078800]
self.hard_fork_node_disconnect_delay = [0, 0, 2880]
self.testnet_hard_fork_heights = [1, 3000]
self.testnet_hard_fork_heights = [0, 0, 0]
self.testnet_hard_fork_node_disconnect_delay = [0, 0, 0]

# ======================================
# PROPOSAL CONFIG
Expand Down
2 changes: 1 addition & 1 deletion src/qrl/core/misc/expiring_set.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding=utf-8
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
from collections import Set
from collections.abc import Set

import simplejson as json

Expand Down
5 changes: 4 additions & 1 deletion src/qrl/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def main():
qrl_dir_post_fix = ''
copy_files = []
if args.network_type == 'testnet':
config.dev.hard_fork_heights = list(config.dev.testnet_hard_fork_heights) # Hard Fork Block Height For Testnet
# Hard Fork Block Height For Testnet
config.dev.hard_fork_heights = list(config.dev.testnet_hard_fork_heights)
# Hard Fork Block Height Disconnect Delay For Testnet
config.dev.hard_fork_node_disconnect_delay = list(config.dev.testnet_hard_fork_node_disconnect_delay)
qrl_dir_post_fix = '-testnet'
package_directory = os.path.dirname(os.path.abspath(__file__))
copy_files.append(os.path.join(package_directory, 'network/testnet/genesis.yml'))
Expand Down
13 changes: 11 additions & 2 deletions src/qrl/network/testnet/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
peer_list: [ "18.130.83.207", "209.250.246.234", "136.244.104.146", "95.179.154.132" ]
genesis_prev_headerhash: 'Testnet 2022'
genesis_timestamp: 1641963062
genesis_prev_headerhash: 'Final Testnet'
genesis_timestamp: 1668696491
genesis_difficulty: 5000
p2p_local_port: 29000
p2p_public_port: 29000
admin_api_port: 29008
public_api_port: 29009
mining_api_port: 29007
grpc_proxy_port: 28090
wallet_daemon_port: 28091
public_api_server: "127.0.0.1:29009"
wallet_api_port: 29010
6 changes: 3 additions & 3 deletions src/qrl/network/testnet/genesis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ genesisBalance:
- address: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
balance: '105000000000000000'
header:
hashHeader: LGyQSHq8RYrEHmG7VVtmc9YIqHNxFIH9IMrUTo34lJ0=
hashHeaderPrev: VGVzdG5ldCAyMDIy
hashHeader: 1nZdbgr36LJbrFhyeZmeFruwvTA4RFk04tnzskqJBB4=
hashHeaderPrev: RmluYWwgVGVzdG5ldA==
merkleRoot: wquld1GTaqfKWRhAdWpOeREWVdCmlTYIAUrY9eWGwTQ=
rewardBlock: '65000000000000000'
timestampSeconds: '1641963062'
timestampSeconds: '1668696491'
transactions:
- coinbase:
addrTo: AQYA3oDYKOMv8cfAHpT2zewSkuiz/0gYQy5+atQfOsdD57loCQog
Expand Down
11 changes: 6 additions & 5 deletions src/qrl/tools/generate_genesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ def get_migration_transactions(signing_xmss, filename):


def main():
exclude_migration_tx = False
if len(sys.argv) > 2:
print("Unexpected arguments")
sys.exit(0)
elif len(sys.argv) == 1:
print("Missing Filename")
sys.exit(0)

filename = sys.argv[1]
exclude_migration_tx = True

if sys.version_info.major > 2:
seed = bytes(hstr2bin(input('Enter extended hexseed: ')))
Expand All @@ -73,7 +71,10 @@ def main():

dist_xmss = XMSS.from_extended_seed(seed)

transactions = get_migration_transactions(signing_xmss=dist_xmss, filename=filename)
transactions = []
if not exclude_migration_tx:
filename = sys.argv[1]
transactions = get_migration_transactions(signing_xmss=dist_xmss, filename=filename)

block = Block.create(dev_config=config.dev,
block_number=0,
Expand Down
6 changes: 3 additions & 3 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Add requirements only needed for your unittests and during development here.
# They will be installed automatically when running `python setup.py test`.
# ATTENTION: Don't remove pytest-cov and pytest as they are needed.
pytest==3.6
pytest-cov==2.5.1
pytest-xdist==1.22.2
pytest>=7.0.0,<=7.1.3
pytest-cov==4.0.0
pytest-xdist==2.5.0
flake8==3.5.0
autoflake==1.1
timeout-decorator==0.4.0
Expand Down
2 changes: 1 addition & 1 deletion tests_integration

0 comments on commit 759c9bb

Please sign in to comment.