diff --git a/ci/py-test-stake-pool.sh b/ci/py-test-stake-pool.sh index 3329ebd8abb..4c3ca8cfe72 100755 --- a/ci/py-test-stake-pool.sh +++ b/ci/py-test-stake-pool.sh @@ -8,6 +8,7 @@ cd stake-pool/py python3 -m venv venv source ./venv/bin/activate pip3 install -r requirements.txt +pip3 install -r optional-requirements.txt check_dirs=( "bot" "spl_token" diff --git a/stake-pool/py/README.md b/stake-pool/py/README.md index 49866fb6d23..cda7beea17b 100644 --- a/stake-pool/py/README.md +++ b/stake-pool/py/README.md @@ -22,10 +22,11 @@ $ python3 -m venv venv $ source venv/bin/activate ``` -3. Install requirements +3. Install build and dev requirements ``` $ pip install -r requirements.txt +$ pip install -r optional-requirements.txt ``` 4. Install the Solana tool suite: https://docs.solana.com/cli/install-solana-cli-tools diff --git a/stake-pool/py/optional-requirements.txt b/stake-pool/py/optional-requirements.txt new file mode 100644 index 00000000000..5aa593192f4 --- /dev/null +++ b/stake-pool/py/optional-requirements.txt @@ -0,0 +1,15 @@ +attrs==22.1.0 +flake8==5.0.3 +iniconfig==1.1.1 +mccabe==0.7.0 +mypy==0.971 +mypy-extensions==0.4.3 +packaging==21.3 +pluggy==1.0.0 +py==1.11.0 +pycodestyle==2.9.0 +pyflakes==2.5.0 +pyparsing==3.0.9 +pytest==7.1.2 +pytest-asyncio==0.19.0 +tomli==2.0.1 diff --git a/stake-pool/py/requirements.txt b/stake-pool/py/requirements.txt index 2a39c6063d1..1b72ffc61ad 100644 --- a/stake-pool/py/requirements.txt +++ b/stake-pool/py/requirements.txt @@ -1,35 +1,19 @@ -anyio==3.3.4 -attrs==21.2.0 -base58==2.1.0 +anyio==3.6.1 +base58==2.1.1 cachetools==4.2.4 -certifi==2021.10.8 -cffi==1.15.0 -charset-normalizer==2.0.7 -construct==2.10.67 -flake8==4.0.1 +certifi==2022.6.15 +cffi==1.15.1 +charset-normalizer==2.1.0 +construct==2.10.68 h11==0.12.0 -httpcore==0.13.7 -httpx==0.20.0 +httpcore==0.15.0 +httpx==0.23.0 idna==3.3 -iniconfig==1.1.1 -mccabe==0.6.1 -mypy==0.910 -mypy-extensions==0.4.3 -packaging==21.2 -pluggy==1.0.0 -py==1.10.0 -pycodestyle==2.8.0 -pycparser==2.20 -pyflakes==2.4.0 -PyNaCl==1.4.0 -pyparsing==2.4.7 -pytest==6.2.5 -pytest-asyncio==0.19.0 -requests==2.26.0 +pycparser==2.21 +PyNaCl==1.5.0 +requests==2.28.1 rfc3986==1.5.0 -six==1.16.0 sniffio==1.2.0 solana==0.18.1 -toml==0.10.2 -typing-extensions==3.10.0.2 -urllib3==1.26.7 +typing_extensions==4.3.0 +urllib3==1.26.11 diff --git a/stake-pool/py/stake/instructions.py b/stake-pool/py/stake/instructions.py index 29378e520a9..f4b116bac5b 100644 --- a/stake-pool/py/stake/instructions.py +++ b/stake-pool/py/stake/instructions.py @@ -5,9 +5,8 @@ from construct import Switch # type: ignore from construct import Int32ul, Pass # type: ignore -from construct import Struct +from construct import Bytes, Struct -from solana._layouts.shared import PUBLIC_KEY_LAYOUT from solana.publickey import PublicKey from solana.sysvar import SYSVAR_RENT_PUBKEY from solana.transaction import AccountMeta, TransactionInstruction @@ -15,6 +14,8 @@ from stake.constants import STAKE_PROGRAM_ID from stake.state import AUTHORIZED_LAYOUT, LOCKUP_LAYOUT, Authorized, Lockup, StakeAuthorize +PUBLIC_KEY_LAYOUT = Bytes(32) + class InitializeParams(NamedTuple): """Initialize stake transaction params.""" diff --git a/stake-pool/py/stake/state.py b/stake-pool/py/stake/state.py index 4911de76975..9ff48d34aec 100644 --- a/stake-pool/py/stake/state.py +++ b/stake-pool/py/stake/state.py @@ -2,11 +2,12 @@ from enum import IntEnum from typing import NamedTuple, Dict -from construct import Container, Struct, Float64l, Int32ul, Int64ul # type: ignore +from construct import Bytes, Container, Struct, Float64l, Int32ul, Int64ul # type: ignore from solana.publickey import PublicKey from solana.utils.helpers import decode_byte_string -from solana._layouts.shared import PUBLIC_KEY_LAYOUT + +PUBLIC_KEY_LAYOUT = Bytes(32) class Lockup(NamedTuple): diff --git a/stake-pool/py/stake_pool/state.py b/stake-pool/py/stake_pool/state.py index 93acc103c15..8791c3e25f0 100644 --- a/stake-pool/py/stake_pool/state.py +++ b/stake-pool/py/stake_pool/state.py @@ -2,17 +2,18 @@ from enum import IntEnum from typing import List, NamedTuple, Optional -from construct import Container, Struct, Switch, Int8ul, Int32ul, Int64ul, Pass # type: ignore +from construct import Bytes, Container, Struct, Switch, Int8ul, Int32ul, Int64ul, Pass # type: ignore from solana.publickey import PublicKey from solana.utils.helpers import decode_byte_string -from solana._layouts.shared import PUBLIC_KEY_LAYOUT from stake.state import Lockup, LOCKUP_LAYOUT +PUBLIC_KEY_LAYOUT = Bytes(32) + def decode_optional_publickey(container: Container) -> Optional[PublicKey]: if container: - return PublicKey(container) + return PublicKey(container.popitem()[1]) else: return None diff --git a/stake-pool/py/tests/conftest.py b/stake-pool/py/tests/conftest.py index 660bbe97a48..9e39dda84ae 100644 --- a/stake-pool/py/tests/conftest.py +++ b/stake-pool/py/tests/conftest.py @@ -4,7 +4,6 @@ import os import shutil import tempfile -import time from typing import AsyncIterator, List, Tuple from subprocess import Popen @@ -66,14 +65,14 @@ async def stake_pool_addresses(async_client, payer, validators, waiter) -> Tuple @pytest_asyncio.fixture async def async_client(solana_test_validator) -> AsyncIterator[AsyncClient]: async_client = AsyncClient(commitment=Confirmed) - total_attempts = 10 + total_attempts = 20 current_attempt = 0 while not await async_client.is_connected(): if current_attempt == total_attempts: raise Exception("Could not connect to test validator") else: current_attempt += 1 - time.sleep(1) + await asyncio.sleep(1.0) yield async_client await async_client.close() diff --git a/stake-pool/py/tests/test_stake.py b/stake-pool/py/tests/test_stake.py index 53b23e1b6b5..fdf016bc297 100644 --- a/stake-pool/py/tests/test_stake.py +++ b/stake-pool/py/tests/test_stake.py @@ -10,7 +10,7 @@ @pytest.mark.asyncio async def test_create_stake(async_client, payer): stake = Keypair() - await create_stake(async_client, payer, stake, payer.public_key, MINIMUM_DELEGATION) + await create_stake(async_client, payer, stake, payer.public_key, 1) @pytest.mark.asyncio diff --git a/stake-pool/py/vote/instructions.py b/stake-pool/py/vote/instructions.py index 38106535faf..267aeb4aa46 100644 --- a/stake-pool/py/vote/instructions.py +++ b/stake-pool/py/vote/instructions.py @@ -3,15 +3,16 @@ from enum import IntEnum from typing import NamedTuple -from construct import Struct, Switch, Int8ul, Int32ul, Pass # type: ignore +from construct import Bytes, Struct, Switch, Int8ul, Int32ul, Pass # type: ignore from solana.publickey import PublicKey from solana.sysvar import SYSVAR_CLOCK_PUBKEY, SYSVAR_RENT_PUBKEY from solana.transaction import AccountMeta, TransactionInstruction -from solana._layouts.shared import PUBLIC_KEY_LAYOUT from vote.constants import VOTE_PROGRAM_ID +PUBLIC_KEY_LAYOUT = Bytes(32) + class InitializeParams(NamedTuple): """Initialize vote account params."""