Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 8f75f59

Browse files
authored
stake-pool-py: Clean up dependencies (#3412)
1 parent 8f74ba5 commit 8f75f59

File tree

10 files changed

+47
-43
lines changed

10 files changed

+47
-43
lines changed

ci/py-test-stake-pool.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ cd stake-pool/py
88
python3 -m venv venv
99
source ./venv/bin/activate
1010
pip3 install -r requirements.txt
11+
pip3 install -r optional-requirements.txt
1112
check_dirs=(
1213
"bot"
1314
"spl_token"

stake-pool/py/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ $ python3 -m venv venv
2222
$ source venv/bin/activate
2323
```
2424

25-
3. Install requirements
25+
3. Install build and dev requirements
2626

2727
```
2828
$ pip install -r requirements.txt
29+
$ pip install -r optional-requirements.txt
2930
```
3031

3132
4. Install the Solana tool suite: https://docs.solana.com/cli/install-solana-cli-tools
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
attrs==22.1.0
2+
flake8==5.0.3
3+
iniconfig==1.1.1
4+
mccabe==0.7.0
5+
mypy==0.971
6+
mypy-extensions==0.4.3
7+
packaging==21.3
8+
pluggy==1.0.0
9+
py==1.11.0
10+
pycodestyle==2.9.0
11+
pyflakes==2.5.0
12+
pyparsing==3.0.9
13+
pytest==7.1.2
14+
pytest-asyncio==0.19.0
15+
tomli==2.0.1

stake-pool/py/requirements.txt

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,19 @@
1-
anyio==3.3.4
2-
attrs==21.2.0
3-
base58==2.1.0
1+
anyio==3.6.1
2+
base58==2.1.1
43
cachetools==4.2.4
5-
certifi==2021.10.8
6-
cffi==1.15.0
7-
charset-normalizer==2.0.7
8-
construct==2.10.67
9-
flake8==4.0.1
4+
certifi==2022.6.15
5+
cffi==1.15.1
6+
charset-normalizer==2.1.0
7+
construct==2.10.68
108
h11==0.12.0
11-
httpcore==0.13.7
12-
httpx==0.20.0
9+
httpcore==0.15.0
10+
httpx==0.23.0
1311
idna==3.3
14-
iniconfig==1.1.1
15-
mccabe==0.6.1
16-
mypy==0.910
17-
mypy-extensions==0.4.3
18-
packaging==21.2
19-
pluggy==1.0.0
20-
py==1.10.0
21-
pycodestyle==2.8.0
22-
pycparser==2.20
23-
pyflakes==2.4.0
24-
PyNaCl==1.4.0
25-
pyparsing==2.4.7
26-
pytest==6.2.5
27-
pytest-asyncio==0.19.0
28-
requests==2.26.0
12+
pycparser==2.21
13+
PyNaCl==1.5.0
14+
requests==2.28.1
2915
rfc3986==1.5.0
30-
six==1.16.0
3116
sniffio==1.2.0
3217
solana==0.18.1
33-
toml==0.10.2
34-
typing-extensions==3.10.0.2
35-
urllib3==1.26.7
18+
typing_extensions==4.3.0
19+
urllib3==1.26.11

stake-pool/py/stake/instructions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55

66
from construct import Switch # type: ignore
77
from construct import Int32ul, Pass # type: ignore
8-
from construct import Struct
8+
from construct import Bytes, Struct
99

10-
from solana._layouts.shared import PUBLIC_KEY_LAYOUT
1110
from solana.publickey import PublicKey
1211
from solana.sysvar import SYSVAR_RENT_PUBKEY
1312
from solana.transaction import AccountMeta, TransactionInstruction
1413

1514
from stake.constants import STAKE_PROGRAM_ID
1615
from stake.state import AUTHORIZED_LAYOUT, LOCKUP_LAYOUT, Authorized, Lockup, StakeAuthorize
1716

17+
PUBLIC_KEY_LAYOUT = Bytes(32)
18+
1819

1920
class InitializeParams(NamedTuple):
2021
"""Initialize stake transaction params."""

stake-pool/py/stake/state.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
from enum import IntEnum
44
from typing import NamedTuple, Dict
5-
from construct import Container, Struct, Float64l, Int32ul, Int64ul # type: ignore
5+
from construct import Bytes, Container, Struct, Float64l, Int32ul, Int64ul # type: ignore
66

77
from solana.publickey import PublicKey
88
from solana.utils.helpers import decode_byte_string
9-
from solana._layouts.shared import PUBLIC_KEY_LAYOUT
9+
10+
PUBLIC_KEY_LAYOUT = Bytes(32)
1011

1112

1213
class Lockup(NamedTuple):

stake-pool/py/stake_pool/state.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
from enum import IntEnum
44
from typing import List, NamedTuple, Optional
5-
from construct import Container, Struct, Switch, Int8ul, Int32ul, Int64ul, Pass # type: ignore
5+
from construct import Bytes, Container, Struct, Switch, Int8ul, Int32ul, Int64ul, Pass # type: ignore
66

77
from solana.publickey import PublicKey
88
from solana.utils.helpers import decode_byte_string
9-
from solana._layouts.shared import PUBLIC_KEY_LAYOUT
109
from stake.state import Lockup, LOCKUP_LAYOUT
1110

11+
PUBLIC_KEY_LAYOUT = Bytes(32)
12+
1213

1314
def decode_optional_publickey(container: Container) -> Optional[PublicKey]:
1415
if container:
15-
return PublicKey(container)
16+
return PublicKey(container.popitem()[1])
1617
else:
1718
return None
1819

stake-pool/py/tests/conftest.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import os
55
import shutil
66
import tempfile
7-
import time
87
from typing import AsyncIterator, List, Tuple
98
from subprocess import Popen
109

@@ -66,14 +65,14 @@ async def stake_pool_addresses(async_client, payer, validators, waiter) -> Tuple
6665
@pytest_asyncio.fixture
6766
async def async_client(solana_test_validator) -> AsyncIterator[AsyncClient]:
6867
async_client = AsyncClient(commitment=Confirmed)
69-
total_attempts = 10
68+
total_attempts = 20
7069
current_attempt = 0
7170
while not await async_client.is_connected():
7271
if current_attempt == total_attempts:
7372
raise Exception("Could not connect to test validator")
7473
else:
7574
current_attempt += 1
76-
time.sleep(1)
75+
await asyncio.sleep(1.0)
7776
yield async_client
7877
await async_client.close()
7978

stake-pool/py/tests/test_stake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
@pytest.mark.asyncio
1111
async def test_create_stake(async_client, payer):
1212
stake = Keypair()
13-
await create_stake(async_client, payer, stake, payer.public_key, MINIMUM_DELEGATION)
13+
await create_stake(async_client, payer, stake, payer.public_key, 1)
1414

1515

1616
@pytest.mark.asyncio

stake-pool/py/vote/instructions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
from enum import IntEnum
44
from typing import NamedTuple
55

6-
from construct import Struct, Switch, Int8ul, Int32ul, Pass # type: ignore
6+
from construct import Bytes, Struct, Switch, Int8ul, Int32ul, Pass # type: ignore
77

88
from solana.publickey import PublicKey
99
from solana.sysvar import SYSVAR_CLOCK_PUBKEY, SYSVAR_RENT_PUBKEY
1010
from solana.transaction import AccountMeta, TransactionInstruction
11-
from solana._layouts.shared import PUBLIC_KEY_LAYOUT
1211

1312
from vote.constants import VOTE_PROGRAM_ID
1413

14+
PUBLIC_KEY_LAYOUT = Bytes(32)
15+
1516

1617
class InitializeParams(NamedTuple):
1718
"""Initialize vote account params."""

0 commit comments

Comments
 (0)