From cdfcdcdc64b472dff6c5d47ce198c98ed6a6d904 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2020 12:47:03 +0000 Subject: [PATCH 1/6] Bump ledgerblue from 0.1.29 to 0.1.31 Bumps [ledgerblue](https://github.com/LedgerHQ/blue-loader-python) from 0.1.29 to 0.1.31. - [Release notes](https://github.com/LedgerHQ/blue-loader-python/releases) - [Commits](https://github.com/LedgerHQ/blue-loader-python/compare/0.1.29...0.1.31) Signed-off-by: dependabot-preview[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1f58361d..f6ae25ce 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ "pytest-cov==2.8.1" ], 'hw-wallet': [ - "ledgerblue==0.1.29" + "ledgerblue==0.1.31" ] } From 9e2aac40cb5e2888d8e3e916b6e0cedcbef40ca0 Mon Sep 17 00:00:00 2001 From: badrogger Date: Mon, 24 Feb 2020 12:59:17 +0200 Subject: [PATCH 2/6] SKALE-2093 Increase provider timeouts --- skale/manager_client.py | 4 ++-- skale/utils/web3_utils.py | 15 ++++++++++++--- tests/main_test.py | 7 ++++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/skale/manager_client.py b/skale/manager_client.py index dfd49beb..59d9ff7c 100644 --- a/skale/manager_client.py +++ b/skale/manager_client.py @@ -41,9 +41,9 @@ def spawn_skale_lib(skale): class Skale: - def __init__(self, endpoint, abi_filepath, wallet=None): + def __init__(self, endpoint, abi_filepath, wallet=None, provider_timeout=30): logger.info(f'Init skale-py, connecting to {endpoint}') - provider = get_provider(endpoint) + provider = get_provider(endpoint, timeout=provider_timeout) self._abi_filepath = abi_filepath self._endpoint = endpoint self.web3 = Web3(provider) diff --git a/skale/utils/web3_utils.py b/skale/utils/web3_utils.py index aa3d9598..3ba12cd6 100644 --- a/skale/utils/web3_utils.py +++ b/skale/utils/web3_utils.py @@ -33,12 +33,21 @@ class TransactionFailedError(Exception): pass -def get_provider(endpoint): +WS_MAX_MESSAGE_DATA_BYTES = 5 * 1024 * 1024 + + +def get_provider(endpoint, timeout=10, request_kwargs={}): scheme = urlparse(endpoint).scheme if scheme == 'ws' or scheme == 'wss': - return WebsocketProvider(endpoint) + kwargs = request_kwargs + if not kwargs: + kwargs = {'max_size': WS_MAX_MESSAGE_DATA_BYTES} + return WebsocketProvider(endpoint, websocket_timeout=timeout, + websocket_kwargs=kwargs) + if scheme == 'http' or scheme == 'https': - return HTTPProvider(endpoint) + return HTTPProvider(endpoint, {'timeout': timeout}) + raise Exception( 'Wrong endpoint option.' 'Supported endpoint schemes: http/https/ws/wss' diff --git a/tests/main_test.py b/tests/main_test.py index 820dfa89..9f564217 100644 --- a/tests/main_test.py +++ b/tests/main_test.py @@ -17,7 +17,7 @@ def test_lib_init(): web3 = init_web3(ENDPOINT) wallet = Web3Wallet(ETH_PRIVATE_KEY, web3) - skale = Skale(ENDPOINT, TEST_ABI_FILEPATH, wallet) + skale = Skale(ENDPOINT, TEST_ABI_FILEPATH, wallet, provider_timeout=20) lib_contracts_info = skale._Skale__contracts_info for contract_info in CONTRACTS_INFO: @@ -32,6 +32,10 @@ def test_lib_init(): assert int(lib_contract.address, 16) != 0 assert web3.eth.getCode(lib_contract.address) assert lib_contract.abi is not None + assert skale.web3.provider.websocket_timeout == 20 + assert skale.web3.provider.conn.websocket_kwargs == { + 'max_size': 5 * 1024 * 1024 + } assert skale.abi is not None @@ -42,6 +46,7 @@ def test_lib_init(): with mock.patch.object(Skale, '_Skale__init_contracts'): skale = Skale(http_endpoint, TEST_ABI_FILEPATH, wallet) provider = skale.web3.provider + assert provider._request_kwargs == {'timeout': 30} assert isinstance(provider, HTTPProvider) file_endpoint = 'file://local_file:1001' From 448954fd0e2eeba7b9d08db2bb644b2d6bee3c39 Mon Sep 17 00:00:00 2001 From: badrogger Date: Mon, 24 Feb 2020 13:04:05 +0200 Subject: [PATCH 3/6] SKALE-2093 Pass request_kwargs to HttpProvider --- skale/utils/web3_utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/skale/utils/web3_utils.py b/skale/utils/web3_utils.py index 17d2d29c..39c78690 100644 --- a/skale/utils/web3_utils.py +++ b/skale/utils/web3_utils.py @@ -39,14 +39,13 @@ class TransactionFailedError(Exception): def get_provider(endpoint, timeout=10, request_kwargs={}): scheme = urlparse(endpoint).scheme if scheme == 'ws' or scheme == 'wss': - kwargs = request_kwargs - if not kwargs: - kwargs = {'max_size': WS_MAX_MESSAGE_DATA_BYTES} + kwargs = request_kwargs or {'max_size': WS_MAX_MESSAGE_DATA_BYTES} return WebsocketProvider(endpoint, websocket_timeout=timeout, websocket_kwargs=kwargs) if scheme == 'http' or scheme == 'https': - return HTTPProvider(endpoint, {'timeout': timeout}) + kwargs = {'timeout': timeout, **request_kwargs} + return HTTPProvider(endpoint, request_kwargs=kwargs) raise Exception( 'Wrong endpoint option.' From 46df319c1e430195ce38642e2385a358c584ebbd Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2020 17:02:15 +0000 Subject: [PATCH 4/6] Bump web3 from 5.2.2 to 5.5.1 Bumps [web3](https://github.com/ethereum/web3.py) from 5.2.2 to 5.5.1. - [Release notes](https://github.com/ethereum/web3.py/releases) - [Changelog](https://github.com/ethereum/web3.py/blob/master/docs/releases.rst) - [Commits](https://github.com/ethereum/web3.py/compare/v5.2.2...v5.5.1) Signed-off-by: dependabot-preview[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 04d028d8..04aa34e0 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,7 @@ url='https://github.com/skalenetwork/skale.py', include_package_data=True, install_requires=[ - "web3==5.2.2", + "web3==5.5.1", "asyncio==3.4.3", "pyyaml==5.1.2", "sgx.py>=0.4dev3", From 2f2e3b1fce2a2fe6584032948a376efea3eb0d55 Mon Sep 17 00:00:00 2001 From: badrogger Date: Mon, 24 Feb 2020 19:19:31 +0200 Subject: [PATCH 5/6] Fix tests --- tests/constants.py | 2 ++ tests/main_test.py | 20 +++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/constants.py b/tests/constants.py index 9ab00eb0..e04af0b0 100644 --- a/tests/constants.py +++ b/tests/constants.py @@ -32,6 +32,8 @@ N_TEST_WALLETS = 2 ENDPOINT = os.environ['ENDPOINT'] + + TEST_ABI_FILEPATH = os.path.join(DIR_PATH, os.pardir, 'test_abi.json') ETH_PRIVATE_KEY = os.environ['ETH_PRIVATE_KEY'] diff --git a/tests/main_test.py b/tests/main_test.py index e14eb98c..4bbd02d1 100644 --- a/tests/main_test.py +++ b/tests/main_test.py @@ -32,22 +32,20 @@ def test_lib_init(): assert int(lib_contract.address, 16) != 0 assert web3.eth.getCode(lib_contract.address) assert lib_contract.abi is not None - assert skale.web3.provider.websocket_timeout == 20 - assert skale.web3.provider.conn.websocket_kwargs == { - 'max_size': 5 * 1024 * 1024 - } + assert skale.web3.provider._request_kwargs == {'timeout': 20} assert skale.abi is not None - provider = skale.web3.provider - assert isinstance(provider, WebsocketProvider) or isinstance(provider, HTTPProvider) + isinstance(skale.web3.provider, HTTPProvider) - http_endpoint = 'http://localhost:8080' + ws_endpoint = 'ws://localhost:8080' with mock.patch.object(Skale, '_Skale__init_contracts'): - skale = Skale(http_endpoint, TEST_ABI_FILEPATH, wallet) - provider = skale.web3.provider - assert provider._request_kwargs == {'timeout': 30} - assert isinstance(provider, HTTPProvider) + skale = Skale(ws_endpoint, TEST_ABI_FILEPATH, wallet) + assert skale.web3.provider.websocket_timeout == 30 + assert skale.web3.provider.conn.websocket_kwargs == { + 'max_size': 5 * 1024 * 1024 + } + assert isinstance(skale.web3.provider, WebsocketProvider) file_endpoint = 'file://local_file:1001' with pytest.raises(Exception): From e88da85a81fa0339ac2262bddf52781b9885fb31 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 24 Feb 2020 17:22:01 +0000 Subject: [PATCH 6/6] Bump twine from 1.12.1 to 3.1.1 Bumps [twine](https://github.com/pypa/twine) from 1.12.1 to 3.1.1. - [Release notes](https://github.com/pypa/twine/releases) - [Changelog](https://github.com/pypa/twine/blob/master/docs/changelog.rst) - [Commits](https://github.com/pypa/twine/compare/1.12.1...3.1.1) Signed-off-by: dependabot-preview[bot] --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 10bf2c2d..7f1dc461 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ "bumpversion==0.5.3", "pytest==5.3.5", "click==7.0", - "twine==1.12.1", + "twine==3.1.1", "mock==4.0.1", "when-changed", "Random-Word==1.0.4",