Skip to content

Ticking without ARB packet / Improvement on computorlist #356

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

Open
wants to merge 35 commits into
base: develop
Choose a base branch
from

Conversation

fnordspace
Copy link
Contributor

Overview

This PR implements a mechanism for nodes to compute and validate their own computorlist during epoch transitions.

Key Features

  • Implements computor index assignment logic:
    • Requalifying computors retain their previous indices
    • New computors are assigned to available indices sequentially
  • Computation occurs between EndEpoch() and StartEpoch(), using system.futureComputors
  • Added useSelfGeneratedComputor flag to track computorlist status and ARB signature verification
  • New validation system for ARB-signed computor lists:
    • If lists match: Continue operation and mark as verified
    • If lists differ: Trigger Critical Situation 2 and pause ticking
    • On Critical Situation 2 manual intervention is needed
  • Extends critical situation system with code 2 which stops tickProcessor.
  • selfGeneratedComputors and useSelfGeneratedComputors are added to the system struct

Testing

  • Epoch transitions with both requalifying and new computors
  • Handling of ARB-signed list arrival
  • Recovery from Critical Situation 2
  • Index assignment consistency across nodes
  • Restart of nodes from save states
  • Restart from system file

- Add self-generated computor list and related flags
- Implement saving of future computors at end of epoch for next epoch use
- Update beginEpoch to use self-generated computor list when available
- Modify processBroadcastComputors to compare ARB list with self-generated list
- Modify tickProcessor to handle self-generated computor list scenarios
- Add warnings and debug messages for unverified self-generated lists
- Update main loop to display warning for unverified self-generated lists

This commit allows the network to continue ticking with a self-generated
computor list in the case of seamless transition when the ARB list is not
 available, improving network resilience while maintaining the ability to
 verify against the official ARB list when received.
- Add logic to maintain indices for computors keeping their status
- Introduce temporary arrays to manage computor list reorganization
- Implement two-phase approach for computor list generation:
  1. Preserve indices for continuing computors
  2. Fill remaining spots with new computors
- Add error handling for unexpected scenarios
- Update selfGeneratedComputors with the newly organized list

This commit ensures that computors maintaining their status across
epochs keep their original indices, while new computors are assigned
to the remaining available slots. This change enhances the continuity
and predictability of the network's computor assignment process.
Instead of allocating seperate memory for the temporary computor list
we use the reorgBuffer. This also solves a problem where the compiler
tries to optimize the function with the use of memset, which is not
available.
In the case that the computorlist is self generated and not signed by
the arbitrator we do not send computorlist to other nodes.
In case that the self-generated computorlist and the list of ARB is
different.
If a new list of ARB is broadcasted which matches continue ticking
again.
Fix issues during review.
Make use of clang-format with style 'Microsoft' for formating.
Switch bs->SetMem and bs->CopyMem to setMem and copyMem functions.
- Fix pointer error in `copyMem()` function
- Use `useSelfGeneratedComputors` to decide if computor list is broadcasted
- Add a comment about the sorting of `minderPublicKeys`
- Initialise `selfGeneratedComputors` array with 0s
- Fix index assignment for new computors
- Disable begin of epoch assert all minderPublicKeys == 0 for self-generated computor list
- Reduce log spamming when using self-generated computor list
- Change `NULL` to `nullptr` in `platform/memory.h`
During epoche change futureComputors will be filled with computed
computors. This handles the edge case when another epoche change
happens before any solution is submitted.
If the computor list is self generated request broadcastedComputors to
receive list of ARB if it exists.
Reallows the transmission of computorlist even if list is
selfGenerated. It will not be accepted if the list is not signed by ARB
@fnordspace fnordspace added the enhancement New feature or request label Apr 2, 2025
@fnordspace fnordspace self-assigned this Apr 2, 2025
@fnordspace fnordspace added this to qubic Apr 2, 2025
@fnordspace fnordspace requested review from krypdkat and philippwerner and removed request for krypdkat April 2, 2025 17:09
@philippwerner philippwerner linked an issue Apr 3, 2025 that may be closed by this pull request
Copy link
Contributor

@philippwerner philippwerner 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 to me. I just have two minor comments.

src/qubic.cpp Outdated
}
else
{
// Handle error; something went wrong
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add/keep a #ifndef NDEBUG with addDebugMessage() here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.
Also added a todo to discuss if on this failure the use of the self-generated computorlist should be turned off.

Copy link
Contributor

@philippwerner philippwerner Apr 3, 2025

Choose a reason for hiding this comment

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

Good idea. IMO you can uncomment it (for not using self-generated computorlist).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Ticking without ARB packet / Improvement on computor list
2 participants