Skip to content

Commit

Permalink
Merge pull request #771 from Chia-Network/drop_3_8
Browse files Browse the repository at this point in the history
drop 3 8
  • Loading branch information
altendky authored Oct 25, 2024
2 parents 3ffba04 + e3b3fe6 commit fb263ef
Show file tree
Hide file tree
Showing 20 changed files with 405 additions and 423 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"]

env:
stubtest_args: ${{ matrix.python-version == '3.11' && '--allowlist wheel/stubtest.allowlist.3-11-plus' || ''}}
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/build-riscv64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ jobs:
matrix:
os: [ubuntu-latest]
python:
- major-dot-minor: "3.8"
matrix: "3.8"
- major-dot-minor: "3.9"
matrix: "3.9"
- major-dot-minor: "3.10"
Expand Down
16 changes: 2 additions & 14 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,6 @@ jobs:
runs-on:
intel: [windows-latest]
python:
- major-dot-minor: "3.8"
cibw-build: "cp38-*"
by-arch:
arm:
manylinux-version: 2_28
docker-url: ghcr.io/chia-network/build-images/centos-pypa-rust-aarch64
rustup-target: aarch64-unknown-linux-musl
intel:
manylinux-version: 2_28
docker-url: ghcr.io/chia-network/build-images/centos-pypa-rust-x86_64
rustup-target: x86_64-unknown-linux-musl
matrix: "3.8"
- major-dot-minor: "3.9"
cibw-build: "cp39-*"
by-arch:
Expand Down Expand Up @@ -235,8 +223,8 @@ jobs:
arm: [Linux, ARM64]
intel: [ubuntu-latest]
python:
- major-dot-minor: "3.8"
matrix: "3.8"
- major-dot-minor: "3.9"
matrix: "3.9"
arch:
- name: Intel
matrix: intel
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A collection of Rust crates for working with the Chia blockchain. There are also

## Prerequisites

- [Python](https://www.python.org/downloads/) 3.8 or higher installed.
- [Python](https://www.python.org/downloads/) 3.9 or higher installed.
- The [Rust toolchain](https://rustup.rs/) must be installed.

## Unit Tests
Expand Down
6 changes: 3 additions & 3 deletions bump-version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import re
import sys
from pathlib import Path
from typing import Callable, Set
from typing import Callable

v = sys.argv[1]
tag = sys.argv[2]
Expand All @@ -31,7 +31,7 @@
"crates/clvm-utils/fuzz",
]

def crates_with_changes() -> Set[str]:
def crates_with_changes() -> set[str]:
ret = set()
for c in our_crates:
diff = os.popen(f"git diff {tag} -- {c}").read().strip()
Expand All @@ -42,7 +42,7 @@ def crates_with_changes() -> Set[str]:
ret.add("wheel")
return ret

def update_cargo(name: str, crates: Set[str]) -> None:
def update_cargo(name: str, crates: set[str]) -> None:
subst = ""
with open(f"{name}/Cargo.toml") as f:
for line in f:
Expand Down
3 changes: 1 addition & 2 deletions crates/chia-tools/parse-analyze-chain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Dict, List

all_counters: Dict[str, List[int]] = {}
all_counters: dict[str, list[int]] = {}

keys = ["atoms:",
"small_atoms:",
Expand Down
50 changes: 25 additions & 25 deletions tests/merkle_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from abc import ABCMeta, abstractmethod
from hashlib import sha256
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Tuple
from typing import TYPE_CHECKING, Any, Iterable, Optional

from chia_rs.sized_bytes import bytes32

Expand Down Expand Up @@ -47,7 +47,7 @@

BLANK = bytes32([0] * 32)

prehashed: Dict[bytes, _Hash] = {}
prehashed: dict[bytes, _Hash] = {}


def init_prehashed() -> None:
Expand Down Expand Up @@ -105,17 +105,17 @@ def add(self, toadd: bytes, depth: int) -> Node:
pass

@abstractmethod
def is_included(self, tocheck: bytes, depth: int, p: List[bytes]) -> bool:
def is_included(self, tocheck: bytes, depth: int, p: list[bytes]) -> bool:
pass

@abstractmethod
def other_included(
self, tocheck: bytes, depth: int, p: List[bytes], collapse: bool
self, tocheck: bytes, depth: int, p: list[bytes], collapse: bool
) -> None:
pass

@abstractmethod
def _audit(self, hashes: List[bytes], bits: List[int]) -> None:
def _audit(self, hashes: list[bytes], bits: list[int]) -> None:
pass


Expand All @@ -133,13 +133,13 @@ def get_root(self) -> bytes32:
def add_already_hashed(self, toadd: bytes) -> None:
self.root = self.root.add(toadd, 0)

def is_included_already_hashed(self, tocheck: bytes) -> Tuple[bool, bytes]:
proof: List[bytes] = []
def is_included_already_hashed(self, tocheck: bytes) -> tuple[bool, bytes]:
proof: list[bytes] = []
r = self.root.is_included(tocheck, 0, proof)
return r, b"".join(proof)

def _audit(self, hashes: List[bytes]) -> None:
newhashes: List[bytes] = []
def _audit(self, hashes: list[bytes]) -> None:
newhashes: list[bytes] = []
self.root._audit(newhashes, [])
assert newhashes == sorted(newhashes)

Expand Down Expand Up @@ -169,16 +169,16 @@ def is_double(self) -> bool:
def add(self, toadd: bytes, depth: int) -> Node:
return TerminalNode(toadd)

def is_included(self, tocheck: bytes, depth: int, p: List[bytes]) -> bool:
def is_included(self, tocheck: bytes, depth: int, p: list[bytes]) -> bool:
p.append(EMPTY)
return False

def other_included(
self, tocheck: bytes, depth: int, p: List[bytes], collapse: bool
self, tocheck: bytes, depth: int, p: list[bytes], collapse: bool
) -> None:
p.append(EMPTY)

def _audit(self, hashes: List[bytes], bits: List[int]) -> None:
def _audit(self, hashes: list[bytes], bits: list[int]) -> None:
pass


Expand All @@ -189,14 +189,14 @@ def _make_middle(children: Any, depth: int) -> Node:
cbits = [get_bit(child.hash, depth) for child in children]
if cbits[0] != cbits[1]:
return MiddleNode(children)
nextvals: List[Node] = [_empty, _empty]
nextvals: list[Node] = [_empty, _empty]
nextvals[cbits[0] ^ 1] = _empty
nextvals[cbits[0]] = _make_middle(children, depth + 1)
return MiddleNode(nextvals)


class TerminalNode(Node):
def __init__(self, hash: bytes, bits: Optional[List[int]] = None) -> None:
def __init__(self, hash: bytes, bits: Optional[list[int]] = None) -> None:
assert len(hash) == 32
self.hash = hash
if bits is not None:
Expand All @@ -222,23 +222,23 @@ def add(self, toadd: bytes, depth: int) -> Node:
else:
return _make_middle([TerminalNode(toadd), self], depth)

def is_included(self, tocheck: bytes, depth: int, p: List[bytes]) -> bool:
def is_included(self, tocheck: bytes, depth: int, p: list[bytes]) -> bool:
p.append(TERMINAL + self.hash)
return tocheck == self.hash

def other_included(
self, tocheck: bytes, depth: int, p: List[bytes], collapse: bool
self, tocheck: bytes, depth: int, p: list[bytes], collapse: bool
) -> None:
p.append(TERMINAL + self.hash)

def _audit(self, hashes: List[bytes], bits: List[int]) -> None:
def _audit(self, hashes: list[bytes], bits: list[int]) -> None:
hashes.append(self.hash)
for pos, v in enumerate(bits):
assert get_bit(self.hash, pos) == v


class MiddleNode(Node):
def __init__(self, children: List[Node]):
def __init__(self, children: list[Node]):
self.children = children
if children[0].is_empty() and children[1].is_double():
self.hash = children[1].hash
Expand Down Expand Up @@ -285,7 +285,7 @@ def add(self, toadd: bytes, depth: int) -> Node:
newvals[bit] = newchild
return MiddleNode(newvals)

def is_included(self, tocheck: bytes, depth: int, p: List[bytes]) -> bool:
def is_included(self, tocheck: bytes, depth: int, p: list[bytes]) -> bool:
p.append(MIDDLE)
if get_bit(tocheck, depth) == 0:
r = self.children[0].is_included(tocheck, depth + 1, p)
Expand All @@ -300,14 +300,14 @@ def is_included(self, tocheck: bytes, depth: int, p: List[bytes]) -> bool:
return self.children[1].is_included(tocheck, depth + 1, p)

def other_included(
self, tocheck: bytes, depth: int, p: List[bytes], collapse: bool
self, tocheck: bytes, depth: int, p: list[bytes], collapse: bool
) -> None:
if collapse or not self.is_double():
p.append(TRUNCATED + self.hash)
else:
self.is_included(tocheck, depth, p)

def _audit(self, hashes: List[bytes], bits: List[int]) -> None:
def _audit(self, hashes: list[bytes], bits: list[int]) -> None:
self.children[0]._audit(hashes, bits + [0])
self.children[1]._audit(hashes, bits + [1])

Expand All @@ -331,15 +331,15 @@ def is_double(self) -> bool:
def add(self, toadd: bytes, depth: int) -> Node:
return self

def is_included(self, tocheck: bytes, depth: int, p: List[bytes]) -> bool:
def is_included(self, tocheck: bytes, depth: int, p: list[bytes]) -> bool:
raise SetError()

def other_included(
self, tocheck: bytes, depth: int, p: List[bytes], collapse: bool
self, tocheck: bytes, depth: int, p: list[bytes], collapse: bool
) -> None:
p.append(TRUNCATED + self.hash)

def _audit(self, hashes: List[bytes], bits: List[int]) -> None:
def _audit(self, hashes: list[bytes], bits: list[int]) -> None:
pass


Expand Down Expand Up @@ -378,7 +378,7 @@ def deserialize_proof(proof: bytes) -> MerkleSet:
raise SetError()


def _deserialize(proof: bytes, pos: int, bits: List[int]) -> Tuple[Node, int]:
def _deserialize(proof: bytes, pos: int, bits: list[int]) -> tuple[Node, int]:
t = proof[pos : pos + 1] # flake8: noqa
if t == EMPTY:
return _empty, pos + 1
Expand Down
4 changes: 2 additions & 2 deletions tests/run_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from time import time
import sys
from time import perf_counter
from typing import Optional, Tuple
from typing import Optional

DEFAULT_CONSTANTS = ConsensusConstants(
SLOT_BLOCKS_TARGET=uint32(32),
Expand Down Expand Up @@ -87,7 +87,7 @@

def run_gen(
fn: str, flags: int = 0, args: Optional[str] = None, version: int = 1
) -> Tuple[Optional[int], Optional[SpendBundleConditions], float]:
) -> tuple[Optional[int], Optional[SpendBundleConditions], float]:

# constants from the main chia blockchain:
# https://github.com/Chia-Network/chia-blockchain/blob/main/chia/consensus/default_constants.py
Expand Down
8 changes: 4 additions & 4 deletions tests/test_additions_and_removals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Set, Optional, Tuple
from typing import Optional
from chia_rs import (
additions_and_removals,
ALLOW_BACKREFS,
Expand Down Expand Up @@ -39,8 +39,8 @@ def test_additions_and_removals() -> None:
if "FAILED: " in test_file:
continue

expected_additions: Set[Tuple[str, str, str, Optional[str]]] = set()
expected_removals: Set[Tuple[str, str]] = set()
expected_additions: set[tuple[str, str, str, Optional[str]]] = set()
expected_removals: set[tuple[str, str]] = set()
last_coin_id = ""
for l in test_file.splitlines():
if "- coin id: " in l:
Expand All @@ -62,7 +62,7 @@ def test_additions_and_removals() -> None:
assert len(removals) == len(expected_removals)

for add in additions:
addition: Tuple[str, str, str, Optional[str]]
addition: tuple[str, str, str, Optional[str]]
if add[1] is not None:
addition = (
f"{add[0].parent_coin_info}",
Expand Down
6 changes: 3 additions & 3 deletions tests/test_block_record_fidelity.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional, Any, Callable
from typing import Optional, Any, Callable

import sys
import time
Expand Down Expand Up @@ -46,9 +46,9 @@ def get_optional(rng: Random, gen: Callable[[Random], Any]) -> Optional[Any]:
return gen(rng)


def get_list(rng: Random, gen: Callable[[Random], Any]) -> List[Any]:
def get_list(rng: Random, gen: Callable[[Random], Any]) -> list[Any]:
length = rng.sample([0, 1, 5, 32, 500], 1)[0]
ret: List[Any] = []
ret: list[Any] = []
for i in range(length):
ret.append(gen(rng))
return ret
Expand Down
11 changes: 5 additions & 6 deletions tests/test_blscache.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
)
from chia_rs.sized_bytes import bytes32
from chia_rs.sized_ints import uint8, uint16, uint32, uint64, uint128
from typing import List
from chia.util.hash import std_hash
from chia.util.lru_cache import LRUCache
from chia.types.blockchain_format.program import Program as ChiaProgram
Expand Down Expand Up @@ -103,8 +102,8 @@ def test_instantiation() -> None:
pk: G1Element = sk.get_g1()
msg = b"hello"
sig: G2Element = AugSchemeMPL.sign(sk, msg)
pks: List[G1Element] = [pk]
msgs: List[bytes] = [msg]
pks: list[G1Element] = [pk]
msgs: list[bytes] = [msg]
result = bls_cache.aggregate_verify(pks, msgs, sig)
assert result
assert bls_cache.len() == 1
Expand All @@ -131,9 +130,9 @@ def test_cache_limit() -> None:

sk: PrivateKey = AugSchemeMPL.key_gen(seed)
pk: G1Element = sk.get_g1()
pks: List[G1Element] = []
msgs: List[bytes] = []
sigs: List[G2Element] = []
pks: list[G1Element] = []
msgs: list[bytes] = []
sigs: list[G2Element] = []
for i in [0xCAFE, 0xF00D, 0xABCD, 0x1234]:
msgs.append(i.to_bytes(8, byteorder="little"))
pks.append(pk)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_blspy_fidelity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import chia_rs
from random import getrandbits
import sys
from typing import Any, Type
from typing import Any
import pytest
from concurrent.futures import ThreadPoolExecutor

Expand Down
Loading

0 comments on commit fb263ef

Please sign in to comment.