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-2378: Add CLI commands to import, export, and benchmark the mempool #19271

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Rigidity
Copy link
Contributor

Adds a new chia dev mempool CLI group with import, export, and create_block commands.

@Rigidity Rigidity requested a review from a team as a code owner February 15, 2025 18:05
@Rigidity Rigidity changed the title Add CLI commands to import, export, and benchmark the mempool CHIA-2378: Add CLI commands to import, export, and benchmark the mempool Feb 15, 2025
@emlowe emlowe added the Added Required label for PR that categorizes merge commit message as "Added" for changelog label Feb 15, 2025
@Rigidity Rigidity added the CLI label Feb 15, 2025
from chia.cmds.cmds_util import get_any_service_client

async with get_any_service_client(FullNodeRpcClient, root_path, rpc_port) as (node_client, _):
start = time.time()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
start = time.time()
start = time.monotonic()

async with get_any_service_client(FullNodeRpcClient, root_path, rpc_port) as (node_client, _):
start = time.time()
bundle = await node_client.create_block_bundle_from_mempool()
end = time.time()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
end = time.time()
end = time.monotonic()

curr_l_tb = self.service.blockchain.block_record(curr_l_tb.prev_hash)

self.service.log.info("Beginning simulated block construction from mempool")
start_time = time.time()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
start_time = time.time()
start_time = time.monotonic()

self.service.log.error(f"Traceback: {traceback.format_exc()}")
self.service.log.error(f"Error making spend bundle {e} peak: {peak}")
mempool_bundle = None
self.service.log.info(f"Simulated block constructed in {time.time() - start_time} seconds")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.service.log.info(f"Simulated block constructed in {time.time() - start_time} seconds")
self.service.log.info(f"Simulated block constructed in {time.monotonic() - start_time} seconds")

Copy link
Contributor

@arvidn arvidn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! One thing that's a bit unexpected is that the import and export RPCs load and save to a file on the nodes machine (not the client's), however, creating the block returns it back to the client

start_time = time.time()

try:
result = await self.service.mempool_manager.create_bundle_from_mempool(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to call create_block_generator(), to also include the time it takes to serialize/compress the block

@@ -835,6 +838,38 @@ async def get_mempool_items_by_coin_name(self, request: dict[str, Any]) -> Endpo

return {"mempool_items": [item.to_json_dict() for item in items]}

async def create_block_bundle_from_mempool(self, _: dict[str, Any]) -> EndpointResult:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the "from mempool" part of this name is implied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Added Required label for PR that categorizes merge commit message as "Added" for changelog CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants