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

stake-pool-py: Clean up dependencies #3412

Merged
merged 1 commit into from Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/py-test-stake-pool.sh
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion stake-pool/py/README.md
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions 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
42 changes: 13 additions & 29 deletions 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
5 changes: 3 additions & 2 deletions stake-pool/py/stake/instructions.py
Expand Up @@ -5,16 +5,17 @@

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

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."""
Expand Down
5 changes: 3 additions & 2 deletions stake-pool/py/stake/state.py
Expand Up @@ -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):
Expand Down
7 changes: 4 additions & 3 deletions stake-pool/py/stake_pool/state.py
Expand Up @@ -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

Expand Down
5 changes: 2 additions & 3 deletions stake-pool/py/tests/conftest.py
Expand Up @@ -4,7 +4,6 @@
import os
import shutil
import tempfile
import time
from typing import AsyncIterator, List, Tuple
from subprocess import Popen

Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion stake-pool/py/tests/test_stake.py
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions stake-pool/py/vote/instructions.py
Expand Up @@ -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."""
Expand Down