From 3f1b9ff217e0d47d447b4ddaa3a37e1355ca75b9 Mon Sep 17 00:00:00 2001 From: wjblanke Date: Mon, 3 May 2021 08:47:49 -0700 Subject: [PATCH] merge main into testnet7 (#3534) * 2 harvesting features (#3331) * 3 harvesting features: - Debug level shows the time for every quality lookup - Warning level if takes longer than 5 seconds - Allow configuration of plot loading interval (default 2 minutes) * Comment out super logging * Improve wallet consistency (#3305) * Improve wallet consistency * Improve CLI significantly, and fix self-tx balances * Fix await * Fix deadlock and test * Remove spam.sh * Changelog for 1.1.3 (#3345) * Changelog for 1.1.3 * minor updates * updates part 3 * Those engineers who don't update changelogs... :) * Apologies to @Chida82 who added log rotate count! (#3369) * Rust parse serialized (#3444) * use rust implementation for finding length of a serialized clvm program * bump clvm_rs version * Don't retry respond_peers message (#3508) Co-authored-by: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Co-authored-by: Gene Hoffman <30377676+hoffmang9@users.noreply.github.com> Co-authored-by: Arvid Norberg --- chia/server/ws_connection.py | 19 +++++++++++-------- chia/types/blockchain_format/program.py | 8 ++++---- setup.py | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/chia/server/ws_connection.py b/chia/server/ws_connection.py index d408a593c072..b3975be91cb5 100644 --- a/chia/server/ws_connection.py +++ b/chia/server/ws_connection.py @@ -238,7 +238,7 @@ async def inbound_handler(self): self.log.error(f"Exception Stack: {error_stack}") async def send_message(self, message: Message): - """ Send message sends a message with no tracking / callback. """ + """Send message sends a message with no tracking / callback.""" if self.closed: return await self.outgoing_queue.put(message) @@ -346,13 +346,16 @@ async def _send_message(self, message: Message): f"peer: {self.peer_host}" ) - async def wait_and_retry(msg: Message, queue: asyncio.Queue): - try: - await asyncio.sleep(1) - await queue.put(msg) - except Exception as e: - self.log.debug(f"Exception {e} while waiting to retry sending rate limited message") - return + # TODO: fix this special case. This function has rate limits which are too low. + if ProtocolMessageTypes(message.type) != ProtocolMessageTypes.respond_peers: + + async def wait_and_retry(msg: Message, queue: asyncio.Queue): + try: + await asyncio.sleep(1) + await queue.put(msg) + except Exception as e: + self.log.debug(f"Exception {e} while waiting to retry sending rate limited message") + return asyncio.create_task(wait_and_retry(message, self.outgoing_queue)) return diff --git a/chia/types/blockchain_format/program.py b/chia/types/blockchain_format/program.py index 3a8b6124dcd5..b585c328c27a 100644 --- a/chia/types/blockchain_format/program.py +++ b/chia/types/blockchain_format/program.py @@ -6,8 +6,8 @@ from clvm.casts import int_from_bytes from clvm.EvalError import EvalError from clvm.operators import OP_REWRITE, OPERATOR_LOOKUP -from clvm.serialize import sexp_buffer_from_stream, sexp_from_stream, sexp_to_stream -from clvm_rs import STRICT_MODE, deserialize_and_run_program +from clvm.serialize import sexp_from_stream, sexp_to_stream +from clvm_rs import STRICT_MODE, deserialize_and_run_program, serialized_length from clvm_tools.curry import curry, uncurry from chia.types.blockchain_format.sized_bytes import bytes32 @@ -148,8 +148,8 @@ class SerializedProgram: @classmethod def parse(cls, f) -> "SerializedProgram": - tmp = sexp_buffer_from_stream(f) - return SerializedProgram.from_bytes(tmp) + length = serialized_length(f.getvalue()[f.tell() :]) + return SerializedProgram.from_bytes(f.read(length)) def stream(self, f): f.write(self._buf) diff --git a/setup.py b/setup.py index ab6bc7544709..c5cf95db357e 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ "chiabip158==1.0", # bip158-style wallet filters "chiapos==1.0.1", # proof of space "clvm==0.9.6", - "clvm_rs==0.1.6", + "clvm_rs==0.1.7", "clvm_tools==0.4.3", "aiohttp==3.7.4", # HTTP server for full node rpc "aiosqlite==0.17.0", # asyncio wrapper for sqlite, to store blocks