Peer protocol to full node protocol, and too many open plots no crash
This commit is contained in:
parent
257e314077
commit
7777661f5e
|
@ -13,7 +13,7 @@ from src.consensus.constants import constants
|
|||
from src.consensus.pot_iterations import calculate_iterations
|
||||
from src.consensus.weight_verifier import verify_weight
|
||||
from src.store import FullNodeStore
|
||||
from src.protocols import farmer_protocol, peer_protocol, timelord_protocol
|
||||
from src.protocols import farmer_protocol, full_node_protocol, timelord_protocol
|
||||
from src.util.bundle_tools import best_solution_program
|
||||
from src.mempool_manager import MempoolManager
|
||||
from src.server.outbound_message import Delivery, Message, NodeType, OutboundMessage
|
||||
|
@ -160,7 +160,7 @@ class FullNode:
|
|||
assert block
|
||||
blocks.append(block)
|
||||
for block in blocks:
|
||||
request = peer_protocol.Block(block)
|
||||
request = full_node_protocol.Block(block)
|
||||
yield OutboundMessage(
|
||||
NodeType.FULL_NODE, Message("block", request), Delivery.RESPOND
|
||||
)
|
||||
|
@ -188,7 +188,7 @@ class FullNode:
|
|||
|
||||
async def introducer_client():
|
||||
async def on_connect() -> OutboundMessageGenerator:
|
||||
msg = Message("request_peers", peer_protocol.RequestPeers())
|
||||
msg = Message("request_peers", full_node_protocol.RequestPeers())
|
||||
yield OutboundMessage(NodeType.INTRODUCER, msg, Delivery.RESPOND)
|
||||
|
||||
while not self._shut_down:
|
||||
|
@ -267,7 +267,7 @@ class FullNode:
|
|||
if self._shut_down:
|
||||
return
|
||||
# Download all the header hashes and find the fork point
|
||||
request = peer_protocol.RequestAllHeaderHashes(tip_block.header_hash)
|
||||
request = full_node_protocol.RequestAllHeaderHashes(tip_block.header_hash)
|
||||
yield OutboundMessage(
|
||||
NodeType.FULL_NODE,
|
||||
Message("request_all_header_hashes", request),
|
||||
|
@ -344,7 +344,7 @@ class FullNode:
|
|||
highest_height_requested = batch_end - 1
|
||||
|
||||
request_made = True
|
||||
request_hb = peer_protocol.RequestHeaderBlocks(
|
||||
request_hb = full_node_protocol.RequestHeaderBlocks(
|
||||
tip_block.header.get_hash(),
|
||||
[uint32(h) for h in range(batch_start, batch_end)],
|
||||
)
|
||||
|
@ -452,7 +452,7 @@ class FullNode:
|
|||
if batch_end - 1 > highest_height_requested:
|
||||
highest_height_requested = batch_end - 1
|
||||
request_made = True
|
||||
request_sync = peer_protocol.RequestSyncBlocks(
|
||||
request_sync = full_node_protocol.RequestSyncBlocks(
|
||||
tip_block.header_hash,
|
||||
[
|
||||
uint32(height)
|
||||
|
@ -554,7 +554,7 @@ class FullNode:
|
|||
for block in potential_fut_blocks:
|
||||
if self._shut_down:
|
||||
return
|
||||
async for msg in self.block(peer_protocol.Block(block)):
|
||||
async for msg in self.block(full_node_protocol.Block(block)):
|
||||
yield msg
|
||||
|
||||
# Update farmers and timelord with most recent information
|
||||
|
@ -565,12 +565,12 @@ class FullNode:
|
|||
|
||||
@api_request
|
||||
async def request_all_header_hashes(
|
||||
self, request: peer_protocol.RequestAllHeaderHashes
|
||||
self, request: full_node_protocol.RequestAllHeaderHashes
|
||||
) -> OutboundMessageGenerator:
|
||||
try:
|
||||
header_hashes = self.blockchain.get_header_hashes(request.tip_header_hash)
|
||||
message = Message(
|
||||
"all_header_hashes", peer_protocol.AllHeaderHashes(header_hashes)
|
||||
"all_header_hashes", full_node_protocol.AllHeaderHashes(header_hashes)
|
||||
)
|
||||
yield OutboundMessage(NodeType.FULL_NODE, message, Delivery.RESPOND)
|
||||
except ValueError:
|
||||
|
@ -578,7 +578,7 @@ class FullNode:
|
|||
|
||||
@api_request
|
||||
async def all_header_hashes(
|
||||
self, all_header_hashes: peer_protocol.AllHeaderHashes
|
||||
self, all_header_hashes: full_node_protocol.AllHeaderHashes
|
||||
) -> OutboundMessageGenerator:
|
||||
assert len(all_header_hashes.header_hashes) > 0
|
||||
self.store.set_potential_hashes(all_header_hashes.header_hashes)
|
||||
|
@ -590,7 +590,7 @@ class FullNode:
|
|||
|
||||
@api_request
|
||||
async def request_header_blocks(
|
||||
self, request: peer_protocol.RequestHeaderBlocks
|
||||
self, request: full_node_protocol.RequestHeaderBlocks
|
||||
) -> OutboundMessageGenerator:
|
||||
"""
|
||||
A peer requests a list of header blocks, by height. Used for syncing or light clients.
|
||||
|
@ -626,14 +626,14 @@ class FullNode:
|
|||
self.log.info(f"{e}")
|
||||
return
|
||||
|
||||
response = peer_protocol.HeaderBlocks(request.tip_header_hash, header_blocks)
|
||||
response = full_node_protocol.HeaderBlocks(request.tip_header_hash, header_blocks)
|
||||
yield OutboundMessage(
|
||||
NodeType.FULL_NODE, Message("header_blocks", response), Delivery.RESPOND
|
||||
)
|
||||
|
||||
@api_request
|
||||
async def header_blocks(
|
||||
self, request: peer_protocol.HeaderBlocks
|
||||
self, request: full_node_protocol.HeaderBlocks
|
||||
) -> OutboundMessageGenerator:
|
||||
"""
|
||||
Receive header blocks from a peer.
|
||||
|
@ -650,7 +650,7 @@ class FullNode:
|
|||
|
||||
@api_request
|
||||
async def request_sync_blocks(
|
||||
self, request: peer_protocol.RequestSyncBlocks
|
||||
self, request: full_node_protocol.RequestSyncBlocks
|
||||
) -> OutboundMessageGenerator:
|
||||
"""
|
||||
Responsd to a peers request for syncing blocks.
|
||||
|
@ -690,13 +690,13 @@ class FullNode:
|
|||
)
|
||||
return
|
||||
response = Message(
|
||||
"sync_blocks", peer_protocol.SyncBlocks(request.tip_header_hash, blocks)
|
||||
"sync_blocks", full_node_protocol.SyncBlocks(request.tip_header_hash, blocks)
|
||||
)
|
||||
yield OutboundMessage(NodeType.FULL_NODE, response, Delivery.RESPOND)
|
||||
|
||||
@api_request
|
||||
async def sync_blocks(
|
||||
self, request: peer_protocol.SyncBlocks
|
||||
self, request: full_node_protocol.SyncBlocks
|
||||
) -> OutboundMessageGenerator:
|
||||
"""
|
||||
We have received the blocks that we needed for syncing. Add them to processing queue.
|
||||
|
@ -872,7 +872,7 @@ class FullNode:
|
|||
unfinished_block_obj: FullBlock = FullBlock(pos, None, block_header, block_body)
|
||||
|
||||
# Propagate to ourselves (which validates and does further propagations)
|
||||
request = peer_protocol.UnfinishedBlock(unfinished_block_obj)
|
||||
request = full_node_protocol.UnfinishedBlock(unfinished_block_obj)
|
||||
async for m in self.unfinished_block(request):
|
||||
# Yield all new messages (propagation to peers)
|
||||
yield m
|
||||
|
@ -910,13 +910,13 @@ class FullNode:
|
|||
if self.store.get_sync_mode():
|
||||
self.store.add_potential_future_block(new_full_block)
|
||||
else:
|
||||
async for msg in self.block(peer_protocol.Block(new_full_block)):
|
||||
async for msg in self.block(full_node_protocol.Block(new_full_block)):
|
||||
yield msg
|
||||
|
||||
# PEER PROTOCOL
|
||||
@api_request
|
||||
async def new_proof_of_time(
|
||||
self, new_proof_of_time: peer_protocol.NewProofOfTime
|
||||
self, new_proof_of_time: full_node_protocol.NewProofOfTime
|
||||
) -> OutboundMessageGenerator:
|
||||
"""
|
||||
A proof of time, received by a peer full node. If we have the rest of the block,
|
||||
|
@ -948,7 +948,7 @@ class FullNode:
|
|||
|
||||
@api_request
|
||||
async def unfinished_block(
|
||||
self, unfinished_block: peer_protocol.UnfinishedBlock
|
||||
self, unfinished_block: full_node_protocol.UnfinishedBlock
|
||||
) -> OutboundMessageGenerator:
|
||||
"""
|
||||
We have received an unfinished block, either created by us, or from another peer.
|
||||
|
@ -1043,7 +1043,7 @@ class FullNode:
|
|||
|
||||
@api_request
|
||||
async def transaction(
|
||||
self, tx: peer_protocol.NewTransaction
|
||||
self, tx: full_node_protocol.NewTransaction
|
||||
) -> OutboundMessageGenerator:
|
||||
"""
|
||||
Receives a full transaction from peer.
|
||||
|
@ -1051,7 +1051,7 @@ class FullNode:
|
|||
"""
|
||||
added, error = await self.mempool_manager.add_spendbundle(tx.transaction)
|
||||
if added:
|
||||
maybeTX = peer_protocol.TransactionId(tx.transaction.name())
|
||||
maybeTX = full_node_protocol.TransactionId(tx.transaction.name())
|
||||
yield OutboundMessage(
|
||||
NodeType.FULL_NODE,
|
||||
Message("maybe_transaction", maybeTX),
|
||||
|
@ -1065,7 +1065,7 @@ class FullNode:
|
|||
|
||||
@api_request
|
||||
async def maybe_transaction(
|
||||
self, tx_id: peer_protocol.TransactionId
|
||||
self, tx_id: full_node_protocol.TransactionId
|
||||
) -> OutboundMessageGenerator:
|
||||
"""
|
||||
Receives a transaction_id, ignore if we've seen it already.
|
||||
|
@ -1075,7 +1075,7 @@ class FullNode:
|
|||
self.log.info(f"tx_id({tx_id.transaction_id}) already seen")
|
||||
return
|
||||
else:
|
||||
requestTX = peer_protocol.RequestTransaction(tx_id.transaction_id)
|
||||
requestTX = full_node_protocol.RequestTransaction(tx_id.transaction_id)
|
||||
yield OutboundMessage(
|
||||
NodeType.FULL_NODE,
|
||||
Message("request_transaction", requestTX),
|
||||
|
@ -1084,14 +1084,14 @@ class FullNode:
|
|||
|
||||
@api_request
|
||||
async def request_transaction(
|
||||
self, tx_id: peer_protocol.RequestTransaction
|
||||
self, tx_id: full_node_protocol.RequestTransaction
|
||||
) -> OutboundMessageGenerator:
|
||||
""" Peer has request a full transaction from us. """
|
||||
spend_bundle = await self.mempool_manager.get_spendbundle(tx_id.transaction_id)
|
||||
if spend_bundle is None:
|
||||
return
|
||||
|
||||
transaction = peer_protocol.NewTransaction(spend_bundle)
|
||||
transaction = full_node_protocol.NewTransaction(spend_bundle)
|
||||
yield OutboundMessage(
|
||||
NodeType.FULL_NODE, Message("transaction", transaction), Delivery.RESPOND,
|
||||
)
|
||||
|
@ -1099,7 +1099,7 @@ class FullNode:
|
|||
self.log.info(f"sending transaction (tx_id: {spend_bundle.name()}) to peer")
|
||||
|
||||
@api_request
|
||||
async def block(self, block: peer_protocol.Block) -> OutboundMessageGenerator:
|
||||
async def block(self, block: full_node_protocol.Block) -> OutboundMessageGenerator:
|
||||
"""
|
||||
Receive a full block from a peer full node (or ourselves).
|
||||
"""
|
||||
|
@ -1168,7 +1168,7 @@ class FullNode:
|
|||
)
|
||||
msg = Message(
|
||||
"request_block",
|
||||
peer_protocol.RequestBlock(block.block.prev_header_hash),
|
||||
full_node_protocol.RequestBlock(block.block.prev_header_hash),
|
||||
)
|
||||
self.store.add_disconnected_block(block.block)
|
||||
yield OutboundMessage(NodeType.FULL_NODE, msg, Delivery.RESPOND)
|
||||
|
@ -1238,7 +1238,7 @@ class FullNode:
|
|||
|
||||
# Recursively process the next block if we have it
|
||||
if next_block is not None:
|
||||
async for ret_msg in self.block(peer_protocol.Block(next_block)):
|
||||
async for ret_msg in self.block(full_node_protocol.Block(next_block)):
|
||||
yield ret_msg
|
||||
|
||||
# Removes all temporary data for old blocks
|
||||
|
@ -1250,7 +1250,7 @@ class FullNode:
|
|||
|
||||
@api_request
|
||||
async def request_block(
|
||||
self, request_block: peer_protocol.RequestBlock
|
||||
self, request_block: full_node_protocol.RequestBlock
|
||||
) -> OutboundMessageGenerator:
|
||||
block: Optional[FullBlock] = await self.store.get_block(
|
||||
request_block.header_hash
|
||||
|
@ -1258,12 +1258,12 @@ class FullNode:
|
|||
if block is not None:
|
||||
yield OutboundMessage(
|
||||
NodeType.FULL_NODE,
|
||||
Message("block", peer_protocol.Block(block)),
|
||||
Message("block", full_node_protocol.Block(block)),
|
||||
Delivery.RESPOND,
|
||||
)
|
||||
|
||||
@api_request
|
||||
async def peers(self, request: peer_protocol.Peers) -> OutboundMessageGenerator:
|
||||
async def peers(self, request: full_node_protocol.Peers) -> OutboundMessageGenerator:
|
||||
if self.server is None:
|
||||
return
|
||||
conns = self.server.global_connections
|
||||
|
|
|
@ -74,15 +74,21 @@ class Harvester:
|
|||
continue
|
||||
|
||||
found = False
|
||||
failed_to_open = False
|
||||
for filename in potential_filenames:
|
||||
if filename.exists():
|
||||
self.provers[partial_filename_str] = DiskProver(str(filename))
|
||||
try:
|
||||
self.provers[partial_filename_str] = DiskProver(str(filename))
|
||||
except ValueError:
|
||||
log.error(f"Failed to open file {filename}.")
|
||||
failed_to_open = True
|
||||
break
|
||||
log.info(
|
||||
f"Farming plot {filename} of size {self.provers[partial_filename_str].get_size()}"
|
||||
)
|
||||
found = True
|
||||
break
|
||||
if not found:
|
||||
if not found and not failed_to_open:
|
||||
log.warning(f"Plot at {potential_filenames} does not exist.")
|
||||
|
||||
@api_request
|
||||
|
|
|
@ -2,7 +2,7 @@ import asyncio
|
|||
import logging
|
||||
from typing import AsyncGenerator, Dict
|
||||
|
||||
from src.protocols.peer_protocol import Peers, RequestPeers
|
||||
from src.protocols.full_node_protocol import Peers, RequestPeers
|
||||
from src.server.outbound_message import Delivery, Message, NodeType, OutboundMessage
|
||||
from src.server.server import ChiaServer
|
||||
from src.types.sized_bytes import bytes32
|
||||
|
|
|
@ -329,6 +329,7 @@ class Timelord:
|
|||
async def _manage_discriminant_queue(self):
|
||||
while not self._is_shutdown:
|
||||
async with self.lock:
|
||||
log.info("Looping")
|
||||
if len(self.discriminant_queue) > 0:
|
||||
max_weight = max([h for _, h in self.discriminant_queue])
|
||||
if max_weight <= self.best_weight_three_proofs:
|
||||
|
|
|
@ -4,7 +4,7 @@ import pytest
|
|||
|
||||
from src.util.bundle_tools import best_solution_program
|
||||
from src.server.outbound_message import OutboundMessage
|
||||
from src.protocols import peer_protocol
|
||||
from src.protocols import full_node_protocol
|
||||
from src.types.full_block import FullBlock
|
||||
from src.types.hashable.SpendBundle import SpendBundle
|
||||
from src.util.ConsensusError import Err
|
||||
|
@ -43,7 +43,7 @@ class TestBlockchainTransactions:
|
|||
full_node_1, full_node_2, server_1, server_2 = two_nodes
|
||||
|
||||
for block in blocks:
|
||||
async for _ in full_node_1.block(peer_protocol.Block(block)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(block)):
|
||||
pass
|
||||
|
||||
spent_block = blocks[1]
|
||||
|
@ -53,7 +53,7 @@ class TestBlockchainTransactions:
|
|||
)
|
||||
|
||||
assert spend_bundle is not None
|
||||
tx: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle)
|
||||
tx: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle)
|
||||
async for _ in full_node_1.transaction(tx):
|
||||
outbound: OutboundMessage = _
|
||||
# Maybe transaction means that it's accepted in mempool
|
||||
|
@ -77,7 +77,7 @@ class TestBlockchainTransactions:
|
|||
)
|
||||
|
||||
next_block = new_blocks[11]
|
||||
async for _ in full_node_1.block(peer_protocol.Block(next_block)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(next_block)):
|
||||
pass
|
||||
|
||||
tips = full_node_1.blockchain.get_current_tips()
|
||||
|
@ -122,7 +122,7 @@ class TestBlockchainTransactions:
|
|||
full_node_1, full_node_2, server_1, server_2 = two_nodes
|
||||
|
||||
for block in blocks:
|
||||
async for _ in full_node_1.block(peer_protocol.Block(block)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(block)):
|
||||
pass
|
||||
|
||||
spent_block = blocks[1]
|
||||
|
@ -165,7 +165,7 @@ class TestBlockchainTransactions:
|
|||
full_node_1, full_node_2, server_1, server_2 = two_nodes
|
||||
|
||||
for block in blocks:
|
||||
async for _ in full_node_1.block(peer_protocol.Block(block)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(block)):
|
||||
pass
|
||||
|
||||
spent_block = blocks[1]
|
||||
|
|
|
@ -4,7 +4,7 @@ import time
|
|||
import pytest
|
||||
|
||||
from src.types.peer_info import PeerInfo
|
||||
from src.protocols import peer_protocol
|
||||
from src.protocols import full_node_protocol
|
||||
from src.util.ints import uint16
|
||||
from tests.setup_nodes import setup_two_nodes, test_constants, bt
|
||||
|
||||
|
@ -28,7 +28,7 @@ class TestFullSync:
|
|||
full_node_1, full_node_2, server_1, server_2 = two_nodes
|
||||
|
||||
for i in range(1, num_blocks):
|
||||
async for _ in full_node_1.block(peer_protocol.Block(blocks[i])):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(blocks[i])):
|
||||
pass
|
||||
|
||||
await server_2.start_client(
|
||||
|
@ -64,15 +64,15 @@ class TestFullSync:
|
|||
|
||||
# 10 blocks to node_1
|
||||
for i in range(1, num_blocks):
|
||||
async for _ in full_node_1.block(peer_protocol.Block(blocks[i])):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(blocks[i])):
|
||||
pass
|
||||
# 4 different blocks to node_2
|
||||
for i in range(1, num_blocks_2):
|
||||
async for _ in full_node_2.block(peer_protocol.Block(blocks_2[i])):
|
||||
async for _ in full_node_2.block(full_node_protocol.Block(blocks_2[i])):
|
||||
pass
|
||||
|
||||
# 6th block from node_1 to node_2
|
||||
async for _ in full_node_2.block(peer_protocol.Block(blocks[5])):
|
||||
async for _ in full_node_2.block(full_node_protocol.Block(blocks[5])):
|
||||
pass
|
||||
|
||||
await server_2.start_client(
|
||||
|
|
|
@ -4,7 +4,7 @@ from time import time
|
|||
import pytest
|
||||
|
||||
from src.server.outbound_message import OutboundMessage
|
||||
from src.protocols import peer_protocol
|
||||
from src.protocols import full_node_protocol
|
||||
from src.types.ConditionVarPair import ConditionVarPair
|
||||
from src.types.condition_opcodes import ConditionOpcode
|
||||
from src.util.ints import uint64
|
||||
|
@ -44,14 +44,14 @@ class TestMempool:
|
|||
|
||||
block = blocks[1]
|
||||
print(f"block coinbase: {block.body.coinbase.name()}")
|
||||
async for _ in full_node_1.block(peer_protocol.Block(block)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(block)):
|
||||
pass
|
||||
|
||||
spend_bundle = wallet_a.generate_signed_transaction(
|
||||
1000, receiver_puzzlehash, block.body.coinbase
|
||||
)
|
||||
assert spend_bundle is not None
|
||||
tx: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle)
|
||||
tx: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle)
|
||||
async for _ in full_node_1.transaction(tx):
|
||||
outbound: OutboundMessage = _
|
||||
# Maybe transaction means that it's accepted in mempool
|
||||
|
@ -74,14 +74,14 @@ class TestMempool:
|
|||
full_node_1, full_node_2, server_1, server_2 = two_nodes_standard_freeze
|
||||
|
||||
block = blocks[1]
|
||||
async for _ in full_node_1.block(peer_protocol.Block(block)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(block)):
|
||||
pass
|
||||
|
||||
spend_bundle = wallet_a.generate_signed_transaction(
|
||||
1000, receiver_puzzlehash, block.body.coinbase
|
||||
)
|
||||
assert spend_bundle is not None
|
||||
tx: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle)
|
||||
tx: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle)
|
||||
|
||||
async for _ in full_node_1.transaction(tx):
|
||||
outbound: OutboundMessage = _
|
||||
|
@ -96,7 +96,7 @@ class TestMempool:
|
|||
)
|
||||
|
||||
for i in range(1, 201):
|
||||
async for _ in full_node_1.block(peer_protocol.Block(blocks[i])):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(blocks[i])):
|
||||
pass
|
||||
|
||||
async for _ in full_node_1.transaction(tx):
|
||||
|
@ -121,7 +121,7 @@ class TestMempool:
|
|||
full_node_1, full_node_2, server_1, server_2 = two_nodes
|
||||
|
||||
block = blocks[1]
|
||||
async for _ in full_node_1.block(peer_protocol.Block(block)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(block)):
|
||||
pass
|
||||
|
||||
spend_bundle1 = wallet_a.generate_signed_transaction(
|
||||
|
@ -129,7 +129,7 @@ class TestMempool:
|
|||
)
|
||||
|
||||
assert spend_bundle1 is not None
|
||||
tx1: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle1)
|
||||
tx1: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle1)
|
||||
async for _ in full_node_1.transaction(tx1):
|
||||
outbound: OutboundMessage = _
|
||||
# Maybe transaction means that it's accepted in mempool
|
||||
|
@ -140,7 +140,7 @@ class TestMempool:
|
|||
1000, other_receiver.get_new_puzzlehash(), block.body.coinbase
|
||||
)
|
||||
assert spend_bundle2 is not None
|
||||
tx2: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle2)
|
||||
tx2: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle2)
|
||||
async for _ in full_node_1.transaction(tx2):
|
||||
pass
|
||||
|
||||
|
@ -164,14 +164,14 @@ class TestMempool:
|
|||
full_node_1, full_node_2, server_1, server_2 = two_nodes
|
||||
|
||||
block = blocks[1]
|
||||
async for _ in full_node_1.block(peer_protocol.Block(block)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(block)):
|
||||
pass
|
||||
|
||||
spend_bundle1 = wallet_a.generate_signed_transaction(
|
||||
1000, receiver_puzzlehash, block.body.coinbase
|
||||
)
|
||||
assert spend_bundle1 is not None
|
||||
tx1: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle1)
|
||||
tx1: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle1)
|
||||
async for _ in full_node_1.transaction(tx1):
|
||||
outbound: OutboundMessage = _
|
||||
# Maybe transaction means that it's accepted in mempool
|
||||
|
@ -182,7 +182,7 @@ class TestMempool:
|
|||
)
|
||||
|
||||
assert spend_bundle2 is not None
|
||||
tx2: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle2)
|
||||
tx2: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle2)
|
||||
async for _ in full_node_1.transaction(tx2):
|
||||
pass
|
||||
|
||||
|
@ -206,7 +206,7 @@ class TestMempool:
|
|||
full_node_1, full_node_2, server_1, server_2 = two_nodes
|
||||
|
||||
block = blocks[1]
|
||||
async for _ in full_node_1.block(peer_protocol.Block(block)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(block)):
|
||||
pass
|
||||
|
||||
cvp = ConditionVarPair(
|
||||
|
@ -221,7 +221,7 @@ class TestMempool:
|
|||
)
|
||||
|
||||
assert spend_bundle1 is not None
|
||||
tx1: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle1)
|
||||
tx1: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle1)
|
||||
async for _ in full_node_1.transaction(tx1):
|
||||
outbound: OutboundMessage = _
|
||||
# Maybe transaction means that it's accepted in mempool
|
||||
|
@ -245,7 +245,7 @@ class TestMempool:
|
|||
full_node_1, full_node_2, server_1, server_2 = two_nodes
|
||||
|
||||
block = blocks[1]
|
||||
async for _ in full_node_1.block(peer_protocol.Block(block)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(block)):
|
||||
pass
|
||||
|
||||
cvp = ConditionVarPair(
|
||||
|
@ -260,7 +260,7 @@ class TestMempool:
|
|||
)
|
||||
|
||||
assert spend_bundle1 is not None
|
||||
tx1: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle1)
|
||||
tx1: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle1)
|
||||
async for _ in full_node_1.transaction(tx1):
|
||||
outbound: OutboundMessage = _
|
||||
# Maybe transaction means that it's accepted in mempool
|
||||
|
@ -284,7 +284,7 @@ class TestMempool:
|
|||
full_node_1, full_node_2, server_1, server_2 = two_nodes
|
||||
|
||||
block = blocks[1]
|
||||
async for _ in full_node_1.block(peer_protocol.Block(block)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(block)):
|
||||
pass
|
||||
|
||||
cvp = ConditionVarPair(
|
||||
|
@ -297,7 +297,7 @@ class TestMempool:
|
|||
)
|
||||
|
||||
assert spend_bundle1 is not None
|
||||
tx1: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle1)
|
||||
tx1: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle1)
|
||||
async for _ in full_node_1.transaction(tx1):
|
||||
outbound: OutboundMessage = _
|
||||
# Maybe transaction means that it's accepted in mempool
|
||||
|
@ -323,7 +323,7 @@ class TestMempool:
|
|||
block = blocks[1]
|
||||
|
||||
for b in blocks:
|
||||
async for _ in full_node_1.block(peer_protocol.Block(b)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(b)):
|
||||
pass
|
||||
|
||||
cvp = ConditionVarPair(
|
||||
|
@ -336,7 +336,7 @@ class TestMempool:
|
|||
)
|
||||
|
||||
assert spend_bundle1 is not None
|
||||
tx1: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle1)
|
||||
tx1: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle1)
|
||||
async for _ in full_node_1.transaction(tx1):
|
||||
outbound: OutboundMessage = _
|
||||
# Maybe transaction means that it's accepted in mempool
|
||||
|
@ -362,7 +362,7 @@ class TestMempool:
|
|||
block = blocks[1]
|
||||
|
||||
for b in blocks:
|
||||
async for _ in full_node_1.block(peer_protocol.Block(b)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(b)):
|
||||
pass
|
||||
|
||||
cvp = ConditionVarPair(
|
||||
|
@ -375,7 +375,7 @@ class TestMempool:
|
|||
)
|
||||
|
||||
assert spend_bundle1 is not None
|
||||
tx1: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle1)
|
||||
tx1: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle1)
|
||||
async for _ in full_node_1.transaction(tx1):
|
||||
outbound: OutboundMessage = _
|
||||
# Maybe transaction means that it's accepted in mempool
|
||||
|
@ -401,7 +401,7 @@ class TestMempool:
|
|||
block = blocks[1]
|
||||
|
||||
for b in blocks:
|
||||
async for _ in full_node_1.block(peer_protocol.Block(b)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(b)):
|
||||
pass
|
||||
|
||||
cvp = ConditionVarPair(
|
||||
|
@ -414,7 +414,7 @@ class TestMempool:
|
|||
)
|
||||
|
||||
assert spend_bundle1 is not None
|
||||
tx1: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle1)
|
||||
tx1: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle1)
|
||||
async for _ in full_node_1.transaction(tx1):
|
||||
outbound: OutboundMessage = _
|
||||
# Maybe transaction means that it's accepted in mempool
|
||||
|
@ -440,7 +440,7 @@ class TestMempool:
|
|||
block = blocks[1]
|
||||
|
||||
for b in blocks:
|
||||
async for _ in full_node_1.block(peer_protocol.Block(b)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(b)):
|
||||
pass
|
||||
|
||||
time_now = uint64(int(time() * 1000))
|
||||
|
@ -455,7 +455,7 @@ class TestMempool:
|
|||
)
|
||||
|
||||
assert spend_bundle1 is not None
|
||||
tx1: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle1)
|
||||
tx1: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle1)
|
||||
async for _ in full_node_1.transaction(tx1):
|
||||
outbound: OutboundMessage = _
|
||||
# Maybe transaction means that it's accepted in mempool
|
||||
|
@ -481,7 +481,7 @@ class TestMempool:
|
|||
block = blocks[1]
|
||||
|
||||
for b in blocks:
|
||||
async for _ in full_node_1.block(peer_protocol.Block(b)):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(b)):
|
||||
pass
|
||||
|
||||
time_now = uint64(int(time() * 1000))
|
||||
|
@ -499,7 +499,7 @@ class TestMempool:
|
|||
)
|
||||
|
||||
assert spend_bundle1 is not None
|
||||
tx1: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle1)
|
||||
tx1: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle1)
|
||||
async for _ in full_node_1.transaction(tx1):
|
||||
outbound: OutboundMessage = _
|
||||
assert outbound.message.function != "maybe_transaction"
|
||||
|
@ -510,7 +510,7 @@ class TestMempool:
|
|||
# Sleep so that 3 sec passes
|
||||
await asyncio.sleep(3)
|
||||
|
||||
tx2: peer_protocol.NewTransaction = peer_protocol.NewTransaction(spend_bundle1)
|
||||
tx2: full_node_protocol.NewTransaction = full_node_protocol.NewTransaction(spend_bundle1)
|
||||
async for _ in full_node_1.transaction(tx2):
|
||||
outbound_2: OutboundMessage = _
|
||||
# Maybe transaction means that it's accepted in mempool
|
||||
|
|
|
@ -3,7 +3,7 @@ import time
|
|||
|
||||
import pytest
|
||||
|
||||
from src.protocols import peer_protocol
|
||||
from src.protocols import full_node_protocol
|
||||
from src.server.connection import NodeType
|
||||
from src.server.outbound_message import Delivery, Message, OutboundMessage
|
||||
from src.types.peer_info import PeerInfo
|
||||
|
@ -30,7 +30,7 @@ class TestNodeLoad:
|
|||
blocks = bt.get_consecutive_blocks(test_constants, num_blocks, [], 10)
|
||||
|
||||
for i in range(1, num_blocks - 1):
|
||||
async for _ in full_node_1.block(peer_protocol.Block(blocks[i])):
|
||||
async for _ in full_node_1.block(full_node_protocol.Block(blocks[i])):
|
||||
pass
|
||||
|
||||
await server_2.start_client(
|
||||
|
@ -42,13 +42,13 @@ class TestNodeLoad:
|
|||
num_unfinished_blocks = 1000
|
||||
start_unf = time.time()
|
||||
for i in range(num_unfinished_blocks):
|
||||
msg = Message("unfinished_block", peer_protocol.UnfinishedBlock(blocks[9]))
|
||||
msg = Message("unfinished_block", full_node_protocol.UnfinishedBlock(blocks[9]))
|
||||
server_1.push_message(
|
||||
OutboundMessage(NodeType.FULL_NODE, msg, Delivery.BROADCAST)
|
||||
)
|
||||
|
||||
# Send the whole block ast the end so we can detect when the node is done
|
||||
block_msg = Message("block", peer_protocol.Block(blocks[9]))
|
||||
block_msg = Message("block", full_node_protocol.Block(blocks[9]))
|
||||
server_1.push_message(
|
||||
OutboundMessage(NodeType.FULL_NODE, block_msg, Delivery.BROADCAST)
|
||||
)
|
||||
|
@ -80,7 +80,7 @@ class TestNodeLoad:
|
|||
|
||||
start_unf = time.time()
|
||||
for i in range(1, num_blocks):
|
||||
msg = Message("block", peer_protocol.Block(blocks[i]))
|
||||
msg = Message("block", full_node_protocol.Block(blocks[i]))
|
||||
server_1.push_message(
|
||||
OutboundMessage(NodeType.FULL_NODE, msg, Delivery.BROADCAST)
|
||||
)
|
||||
|
|
|
@ -20,8 +20,8 @@ class TestSimulation:
|
|||
async def test_simulation_1(self, simulation):
|
||||
node1, node2 = simulation
|
||||
start = time.time()
|
||||
while time.time() - start < 200:
|
||||
if max([h.height for h in node1.blockchain.get_current_tips()]) > 10:
|
||||
while time.time() - start < 1000:
|
||||
if max([h.height for h in node1.blockchain.get_current_tips()]) > 10000:
|
||||
return
|
||||
await asyncio.sleep(1)
|
||||
assert False
|
||||
|
|
Loading…
Reference in New Issue