Skip to content

protocol: Report error to pool when bulk transfer queuing fails - #46

Open
luke-jr wants to merge 3 commits into
CONVOYMining:masterfrom
luke-jr:bulk_queue_overflow_errcode
Open

luke-jr wants to merge 3 commits into
CONVOYMining:masterfrom
luke-jr:bulk_queue_overflow_errcode

Conversation

@luke-jr

@luke-jr luke-jr commented Oct 16, 2026

Copy link
Copy Markdown

Without this, Gateway will just silently drop requests if there's too many bulk transfers going.

@luke-jr luke-jr added this to the v0.5.1 milestone Oct 16, 2026
@luke-jr
luke-jr requested a balanced review from Copilot October 16, 2026 19:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The regression test must verify that the BUSY reply is queued for transmission, not merely prepared.

1 open finding
What changed in this PR

Reports BUSY responses to the pool when bulk-transfer queuing fails, instead of silently dropping requests.

Changes:

  • Adds shared BUSY response constants.
  • Adds fallback replies for validation and unknown-parent requests.
  • Adds a full-queue regression test.
File Description
src/​datum_protocol.h Defines BUSY response constants.
src/​datum_protocol.c Handles queuing failures and limits padding to avoid unnecessary bulk transfers.
src/​datum_protocol_tests.c Tests validation responses with a full bulk queue.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +974 to +976
datum_test(datum_protocol_job_validation_sblock(sizeof(validation_request), validation_request));
datum_test(temp_data[0] == 0x50 && temp_data[1] == 0x92);
datum_test(temp_data[2] == pow.datum_job_id && temp_data[3] == DATUM_VALIDATION_ERROR_BUSY);

@jasonsopko jasonsopko left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tested ACK 15cc269

Builds with -Wall -Werror and passes --test in the gcc, clang, Umbrel, no-API and ASan+UBSan configs.

The code does what it says. The test is the weak spot, as Copilot noted. Five mutations of this PR, run against its own --test:

  • no BUSY after sblock fails to queue: caught
  • datum_protocol_job_validation_send_error builds the reply but never calls datum_protocol_mining_cmd: not caught
  • no BUSY from datum_protocol_job_validation_send_reply (0x90, 0x91): not caught
  • datum_protocol_parent_fetch_reply without the BUSY retry: not caught
  • padding no longer capped, so a direct reply can pass one fragment: not caught

The patch in the gist checks that each of the three handlers puts a BUSY-sized reply in the outbound buffer when the queue is full, and sends 20 direct replies sized 5 bytes short of one fragment. It catches all but the parent fetch case, which the test file can't reach while datum_protocol_parent_fetch_reply is static. It adds a declaration for datum_protocol_job_validation_stxlist to datum_protocol_internal.h.

Its 0x90 part trips UBSan, which every Linux and FreeBSD CI build has: datum_siphash_mod8 reads hash_bin, at offset 178 of T_DATUM_TEMPLATE_TXN, through a uint64_t pointer. #47 fixes that, and on top of it the patch passes all five configs.

What does the pool do with 0xF6 on 0x90, 0x91 and 0x92: wait and ask again, or count the job as failed validation?

Mutation script, patch and logs: https://gist.github.com/jasonsopko/7df5dc75053fc4abb65cb7b927c816a8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants