mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-21 08:31:52 +03:00
Fix sqlite issue on Github CI machine (#87)
* Add a lock and update cbor2 * Support python3, and tests python3 in ci
This commit is contained in:
parent
88e991c67f
commit
5c49a2858c
3
.github/workflows/pythonpackage.yml
vendored
3
.github/workflows/pythonpackage.yml
vendored
@ -9,6 +9,7 @@ jobs:
|
||||
strategy:
|
||||
max-parallel: 4
|
||||
matrix:
|
||||
python-version: [3.7, 3.8]
|
||||
os: [ubuntu-latest, macOS-latest]
|
||||
|
||||
steps:
|
||||
@ -16,7 +17,7 @@ jobs:
|
||||
- name: Setup Python environment
|
||||
uses: actions/setup-python@v1.1.1
|
||||
with:
|
||||
python-version: 3.7 # optional, default is 3.x
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
env:
|
||||
CHIA_MACHINE_SSH_KEY: ${{ secrets.CHIA_MACHINE_SSH_KEY }}
|
||||
|
@ -11,7 +11,7 @@ class ClassGroup(tuple):
|
||||
assert discriminant < 0
|
||||
assert discriminant % 4 == 1
|
||||
c = (b * b - discriminant) // (4 * a)
|
||||
p = class_(a, b, c).reduced()
|
||||
p = class_((a, b, c)).reduced()
|
||||
assert p.discriminant() == discriminant
|
||||
return p
|
||||
|
||||
@ -20,12 +20,14 @@ class ClassGroup(tuple):
|
||||
int_size = (discriminant.bit_length() + 16) >> 4
|
||||
a = int.from_bytes(bytearray[0:int_size], "big", signed=True)
|
||||
b = int.from_bytes(bytearray[int_size:], "big", signed=True)
|
||||
return ClassGroup(a, b, (b**2 - discriminant)//(4*a))
|
||||
return ClassGroup((a, b, (b**2 - discriminant)//(4*a)))
|
||||
|
||||
def __new__(self, a, b, c):
|
||||
return tuple.__new__(self, (a, b, c))
|
||||
def __new__(cls, t):
|
||||
a, b, c = t
|
||||
return tuple.__new__(cls, (a, b, c))
|
||||
|
||||
def __init__(self, a, b, c):
|
||||
def __init__(self, t):
|
||||
a, b, c = t
|
||||
super(ClassGroup, self).__init__()
|
||||
self._discriminant = None
|
||||
|
||||
@ -50,7 +52,7 @@ class ClassGroup(tuple):
|
||||
while a > c or (a == c and b < 0):
|
||||
s = (c + b) // (c + c)
|
||||
a, b, c = c, -b + 2 * s * c, c * s * s - b * s + a
|
||||
return self.__class__(a, b, c).normalized()
|
||||
return self.__class__((a, b, c)).normalized()
|
||||
|
||||
def normalized(self):
|
||||
a, b, c = self
|
||||
@ -58,7 +60,7 @@ class ClassGroup(tuple):
|
||||
return self
|
||||
r = (a - b) // (2 * a)
|
||||
b, c = b + 2 * r * a, a * r * r + b * r + c
|
||||
return self.__class__(a, b, c)
|
||||
return self.__class__((a, b, c))
|
||||
|
||||
def serialize(self):
|
||||
r = self.reduced()
|
||||
@ -68,7 +70,8 @@ class ClassGroup(tuple):
|
||||
for x in [r[0], r[1]]])
|
||||
|
||||
def __eq__(self, other):
|
||||
return tuple(self.reduced()) == tuple(ClassGroup(*other).reduced())
|
||||
print("other", other)
|
||||
return tuple(self.reduced()) == tuple(ClassGroup((other[0], other[1], other[2])).reduced())
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
@ -85,7 +88,7 @@ class ClassGroup(tuple):
|
||||
|
||||
def inverse(self):
|
||||
a, b, c = self
|
||||
return self.__class__(a, -b, c)
|
||||
return self.__class__((a, -b, c))
|
||||
|
||||
def multiply(self, other):
|
||||
"""
|
||||
@ -130,7 +133,7 @@ class ClassGroup(tuple):
|
||||
a3 = s * t - r * u
|
||||
b3 = (j * u + m * r) - (k * t + l * s)
|
||||
c3 = k * l - j * m
|
||||
return self.__class__(a3, b3, c3).reduced()
|
||||
return self.__class__((a3, b3, c3)).reduced()
|
||||
|
||||
def square(self):
|
||||
"""
|
||||
@ -174,7 +177,7 @@ class ClassGroup(tuple):
|
||||
a3 = s * t - r * u
|
||||
b3 = (j * u + m * r) - (k * t + l * s)
|
||||
c3 = k * l - j * m
|
||||
return self.__class__(a3, b3, c3).reduced()
|
||||
return self.__class__((a3, b3, c3)).reduced()
|
||||
|
||||
|
||||
"""
|
||||
|
@ -8,7 +8,7 @@ attrs==19.3.0
|
||||
autoflake==1.3.1
|
||||
black==19.10b0
|
||||
blspy==0.1.14
|
||||
cbor2==5.0.0
|
||||
cbor2==5.0.1
|
||||
cffi==1.13.2
|
||||
chardet==3.0.4
|
||||
Click==7.0
|
||||
|
@ -626,9 +626,10 @@ class FullNode:
|
||||
Responsd to a peers request for syncing blocks.
|
||||
"""
|
||||
blocks: List[FullBlock] = []
|
||||
tip_block: Optional[FullBlock] = await self.store.get_block(
|
||||
request.tip_header_hash
|
||||
)
|
||||
async with self.store.lock:
|
||||
tip_block: Optional[FullBlock] = await self.store.get_block(
|
||||
request.tip_header_hash
|
||||
)
|
||||
if tip_block is not None:
|
||||
if len(request.heights) > self.config["max_blocks_to_send"]:
|
||||
raise errors.TooManyheadersRequested(
|
||||
@ -642,10 +643,13 @@ class FullNode:
|
||||
] = self.blockchain.get_header_blocks_by_height(
|
||||
request.heights, request.tip_header_hash
|
||||
)
|
||||
for header_block in header_blocks:
|
||||
fetched = await self.store.get_block(header_block.header.get_hash())
|
||||
assert fetched
|
||||
blocks.append(fetched)
|
||||
async with self.store.lock:
|
||||
for header_block in header_blocks:
|
||||
fetched = await self.store.get_block(
|
||||
header_block.header.get_hash()
|
||||
)
|
||||
assert fetched
|
||||
blocks.append(fetched)
|
||||
except KeyError:
|
||||
log.info("Do not have required blocks")
|
||||
return
|
||||
|
@ -18,11 +18,11 @@ def make_sized_bytes(size):
|
||||
"""
|
||||
name = "bytes%d" % size
|
||||
|
||||
def __new__(self, v):
|
||||
def __new__(cls, v):
|
||||
v = bytes(v)
|
||||
if not isinstance(v, bytes) or len(v) != size:
|
||||
raise ValueError("bad %s initializer %s" % (name, v))
|
||||
return bytes.__new__(self, v) # type: ignore
|
||||
return bytes.__new__(cls, v) # type: ignore
|
||||
|
||||
@classmethod # type: ignore
|
||||
def parse(cls, f: BinaryIO) -> Any:
|
||||
|
@ -18,7 +18,6 @@ class StructStream(int):
|
||||
f"Value {value} of size {value.bit_length()} does not fit into "
|
||||
f"{cls.__name__} of size {bits}"
|
||||
)
|
||||
|
||||
return int.__new__(cls, value) # type: ignore
|
||||
|
||||
@classmethod
|
||||
|
@ -89,23 +89,32 @@ class TestRpc:
|
||||
|
||||
_ = await server_2.start_server("127.0.0.1", None)
|
||||
await asyncio.sleep(2) # Allow server to start
|
||||
try:
|
||||
cons = await client.get_connections()
|
||||
assert len(cons) == 0
|
||||
|
||||
cons = await client.get_connections()
|
||||
assert len(cons) == 0
|
||||
# Open a connection through the RPC
|
||||
await client.open_connection(host="127.0.0.1", port=test_node_2_port)
|
||||
cons = await client.get_connections()
|
||||
assert len(cons) == 1
|
||||
|
||||
# Open a connection through the RPC
|
||||
await client.open_connection(host="127.0.0.1", port=test_node_2_port)
|
||||
cons = await client.get_connections()
|
||||
assert len(cons) == 1
|
||||
# Close a connection through the RPC
|
||||
await client.close_connection(cons[0]["node_id"])
|
||||
cons = await client.get_connections()
|
||||
assert len(cons) == 0
|
||||
except AssertionError:
|
||||
# Checks that the RPC manages to stop the node
|
||||
await client.stop_node()
|
||||
client.close()
|
||||
await client.await_closed()
|
||||
server_2.close_all()
|
||||
await server_1.await_closed()
|
||||
await server_2.await_closed()
|
||||
await rpc_cleanup()
|
||||
await store.close()
|
||||
raise
|
||||
|
||||
# Close a connection through the RPC
|
||||
await client.close_connection(cons[0]["node_id"])
|
||||
cons = await client.get_connections()
|
||||
assert len(cons) == 0
|
||||
|
||||
# Checks that the RPC manages to stop the node
|
||||
await client.stop_node()
|
||||
|
||||
client.close()
|
||||
await client.await_closed()
|
||||
server_2.close_all()
|
||||
|
Loading…
Reference in New Issue
Block a user