Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions chia/_tests/core/mempool/test_mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,10 @@ async def test_double_spend_with_higher_fee(

@pytest.mark.anyio
async def test_invalid_signature(
self, one_node_one_block: tuple[FullNodeSimulator, ChiaServer, BlockTools], wallet_a: WalletTool
self,
one_node_one_block: tuple[FullNodeSimulator, ChiaServer, BlockTools],
wallet_a: WalletTool,
caplog: pytest.LogCaptureFixture,
) -> None:
reward_ph = wallet_a.get_new_puzzlehash()

Expand All @@ -716,11 +719,12 @@ async def test_invalid_signature(
sb: SpendBundle = generate_test_spend_bundle(wallet_a, coin1)
assert sb.aggregated_signature != G2Element.generator()
sb = sb.replace(aggregated_signature=G2Element.generator())
caplog.clear()
res: Optional[Message] = await send_sb(full_node_1, sb)
assert res is not None
ack: TransactionAck = TransactionAck.from_bytes(res.data)
assert ack.status == MempoolInclusionStatus.FAILED.value
assert ack.error == Err.BAD_AGGREGATE_SIGNATURE.name
assert ack.status != MempoolInclusionStatus.SUCCESS.value
assert "chia.util.errors.ValidationError: Error code: BAD_AGGREGATE_SIGNATURE" in caplog.text
invariant_check_mempool(full_node_1.full_node.mempool_manager.mempool)

async def condition_tester(
Expand Down
11 changes: 8 additions & 3 deletions chia/full_node/full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
from chia.util.db_synchronous import db_synchronous_on
from chia.util.db_version import lookup_db_version, set_db_version_async
from chia.util.db_wrapper import DBWrapper2, manage_connection
from chia.util.errors import ConsensusError, Err, TimestampError
from chia.util.errors import ConsensusError, Err, TimestampError, ValidationError
from chia.util.limited_semaphore import LimitedSemaphore
from chia.util.network import is_localhost
from chia.util.path import path_from_root
Expand Down Expand Up @@ -503,11 +503,16 @@ async def _handle_one_transaction(self, entry: TransactionQueueEntry) -> None:
except asyncio.CancelledError:
error_stack = traceback.format_exc()
self.log.debug(f"Cancelling _handle_one_transaction, closing: {error_stack}")
except ValidationError as e:
self.log.exception("Error in _handle_one_transaction, closing")
if peer is not None:
await peer.close(CONSENSUS_ERROR_BAN_SECONDS)
entry.done.set((MempoolInclusionStatus.FAILED, e.code))
except Exception:
error_stack = traceback.format_exc()
self.log.error(f"Error in _handle_one_transaction, closing: {error_stack}")
self.log.exception("Error in _handle_one_transaction, closing")
if peer is not None:
await peer.close(CONSENSUS_ERROR_BAN_SECONDS)
entry.done.set((MempoolInclusionStatus.FAILED, Err.UNKNOWN))
finally:
self.add_transaction_semaphore.release()

Expand Down
1 change: 0 additions & 1 deletion chia/full_node/mempool_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,6 @@ async def pre_validate_spendbundle(
)
# validate_clvm_and_signature raises a ValueError with an error code
except ValueError as e:
log.warning(f"max CLVM cost: {self.max_tx_clvm_cost}")
# Convert that to a ValidationError
if len(e.args) > 1:
error = Err(e.args[1])
Expand Down
6 changes: 0 additions & 6 deletions chia/server/ws_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,6 @@ async def ban_peer_bad_protocol(self, log_err_msg: str) -> None:
self.log.error(f"Banning peer for {ban_seconds} seconds: {self.peer_info.host} {log_err_msg}")
await self.close(ban_seconds, WSCloseCode.PROTOCOL_ERROR, Err.INVALID_PROTOCOL_MESSAGE)

async def ban_peer_consensus_error(self, log_err_msg: str) -> None:
"""Ban peer for consensus rule violation"""
ban_seconds = CONSENSUS_ERROR_BAN_SECONDS
self.log.error(f"Banning peer for {ban_seconds} seconds: {self.peer_info.host} {log_err_msg}")
await self.close(ban_seconds)

def cancel_pending_requests(self) -> None:
for message_id, event in self.pending_requests.items():
try:
Expand Down
1 change: 0 additions & 1 deletion chia/simulator/block_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ def setup_new_gen(
program = simple_solution_generator(transaction_data).program
block_refs = []
cost = compute_block_cost(program, self.constants, uint32(curr.height + 1), prev_tx_height)
print(f"computed cost: {cost} additions: {len(additions)} removals: {len(removals)}")
return NewBlockGenerator(
program,
[],
Expand Down
Loading