Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHIA-194: CHIP-0026 Mempool Updates #17980

Merged
merged 24 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
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
6 changes: 3 additions & 3 deletions benchmarks/mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ async def add_spend_bundles(spend_bundles: List[SpendBundle]) -> None:
spend_bundle_id = tx.name()
npc = await mempool.pre_validate_spendbundle(tx, None, spend_bundle_id)
assert npc is not None
_, status, error = await mempool.add_spend_bundle(tx, npc, spend_bundle_id, height)
assert status == MempoolInclusionStatus.SUCCESS
assert error is None
info = await mempool.add_spend_bundle(tx, npc, spend_bundle_id, height)
assert info.status == MempoolInclusionStatus.SUCCESS
assert info.error is None

suffix = "st" if single_threaded else "mt"

Expand Down
21 changes: 16 additions & 5 deletions chia/_tests/connection_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncio
import logging
from pathlib import Path
from typing import Set, Tuple
from typing import List, Set, Tuple

import aiohttp
from cryptography import x509
Expand Down Expand Up @@ -39,15 +39,26 @@ async def disconnect_all_and_reconnect(server: ChiaServer, reconnect_to: ChiaSer


async def add_dummy_connection(
server: ChiaServer, self_hostname: str, dummy_port: int, type: NodeType = NodeType.FULL_NODE
server: ChiaServer,
self_hostname: str,
dummy_port: int,
type: NodeType = NodeType.FULL_NODE,
*,
additional_capabilities: List[Tuple[uint16, str]] = [],
) -> Tuple[asyncio.Queue, bytes32]:
wsc, peer_id = await add_dummy_connection_wsc(server, self_hostname, dummy_port, type)
wsc, peer_id = await add_dummy_connection_wsc(
server, self_hostname, dummy_port, type, additional_capabilities=additional_capabilities
)

return wsc.incoming_queue, peer_id


async def add_dummy_connection_wsc(
server: ChiaServer, self_hostname: str, dummy_port: int, type: NodeType = NodeType.FULL_NODE
server: ChiaServer,
self_hostname: str,
dummy_port: int,
type: NodeType = NodeType.FULL_NODE,
additional_capabilities: List[Tuple[uint16, str]] = [],
) -> Tuple[WSChiaConnection, bytes32]:
timeout = aiohttp.ClientTimeout(total=10)
session = aiohttp.ClientSession(timeout=timeout)
Expand Down Expand Up @@ -86,7 +97,7 @@ async def add_dummy_connection_wsc(
peer_id,
100,
30,
local_capabilities_for_handshake=default_capabilities[type],
local_capabilities_for_handshake=default_capabilities[type] + additional_capabilities,
)
await wsc.perform_handshake(server._network_id, dummy_port, type)
if wsc.incoming_message_task is not None:
Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/mempool/test_mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2863,7 +2863,7 @@ def test_limit_expiring_transactions(height: bool, items: List[int], expected: L
invariant_check_mempool(mempool)
if increase_fee:
fee_rate += 0.1
assert ret is None
assert ret.error is None
else:
fee_rate -= 0.1

Expand Down
2 changes: 1 addition & 1 deletion chia/_tests/core/mempool/test_mempool_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ async def add_spendbundle(
npc_result = await mempool_manager.pre_validate_spendbundle(sb, None, sb_name)
ret = await mempool_manager.add_spend_bundle(sb, npc_result, sb_name, TEST_HEIGHT)
invariant_check_mempool(mempool_manager.mempool)
return ret
return ret.cost, ret.status, ret.error


async def generate_and_add_spendbundle(
Expand Down
2 changes: 2 additions & 0 deletions chia/_tests/util/build_network_protocol_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def visit_wallet_protocol(visitor: Callable[[Any, str], None]) -> None:
visitor(request_coin_state, "request_coin_state")
visitor(respond_coin_state, "respond_coin_state")
visitor(reject_coin_state, "reject_coin_state")
visitor(request_cost_info, "request_cost_info")
visitor(respond_cost_info, "respond_cost_info")


def visit_harvester_protocol(visitor: Callable[[Any, str], None]) -> None:
Expand Down
21 changes: 21 additions & 0 deletions chia/_tests/util/network_protocol_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,27 @@
uint8(wallet_protocol.RejectStateReason.EXCEEDED_SUBSCRIPTION_LIMIT)
)

removed_mempool_item = wallet_protocol.RemovedMempoolItem(
bytes32(bytes.fromhex("59710628755b6d7f7d0b5d84d5c980e7a1c52e55f5a43b531312402bd9045da7")), uint8(1)
)

mempool_items_added = wallet_protocol.MempoolItemsAdded(
[bytes32(bytes.fromhex("59710628755b6d7f7d0b5d84d5c980e7a1c52e55f5a43b531312402bd9045da7"))]
)

mempool_items_removed = wallet_protocol.MempoolItemsRemoved([removed_mempool_item])

request_cost_info = wallet_protocol.RequestCostInfo()

respond_cost_info = wallet_protocol.RespondCostInfo(
max_transaction_cost=uint64(100000),
max_block_cost=uint64(1000000),
max_mempool_cost=uint64(10000000),
mempool_cost=uint64(50000),
mempool_fee=uint64(500000),
bump_fee_per_cost=uint8(10),
)


### HARVESTER PROTOCOL
pool_difficulty = harvester_protocol.PoolDifficulty(
Expand Down
Binary file modified chia/_tests/util/protocol_messages_bytes-v1.0
Binary file not shown.
11 changes: 11 additions & 0 deletions chia/_tests/util/protocol_messages_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -2119,6 +2119,17 @@

reject_coin_state_json: Dict[str, Any] = {"reason": 1}

request_cost_info_json: Dict[str, Any] = {}

respond_cost_info_json: Dict[str, Any] = {
"max_transaction_cost": 100000,
"max_block_cost": 1000000,
"max_mempool_cost": 10000000,
"mempool_cost": 50000,
"mempool_fee": 500000,
"bump_fee_per_cost": 10,
}

pool_difficulty_json: Dict[str, Any] = {
"difficulty": 14819251421858580996,
"sub_slot_iters": 12852879676624401630,
Expand Down
Loading
Loading