Skip to content

Commit

Permalink
Add solutionthreshold to system_info (#85)
Browse files Browse the repository at this point in the history
* Add solutionthreshold to system_info

* Fix struct alignment and potential out-of-bounds access

---------

Co-authored-by: Philipp Werner <[email protected]>
  • Loading branch information
J0ET0M and philippwerner authored Apr 4, 2024
1 parent 082e237 commit 775c1f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/network_messages/system_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#define RESPOND_SYSTEM_INFO 47

#pragma pack(push, 1)
struct RespondSystemInfo
{
short version;
Expand All @@ -27,6 +28,8 @@ struct RespondSystemInfo
unsigned int numberOfTransactions;

m256i randomMiningSeed;
int solutionThreshold;
};
#pragma pack(pop)

static_assert(sizeof(RespondSystemInfo) == 2 + 2 + 4 + 4 + 4 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 4 + 32 + 4, "Something is wrong with the struct size of RespondSystemInfo.");
static_assert(sizeof(RespondSystemInfo) == (2 + 2 + 4 + 4 + 4) + (2 + 1 + 1 + 1 + 1 + 1 + 1) + (4 + 4) + (32 + 4), "Something is wrong with the struct size of RespondSystemInfo.");
1 change: 1 addition & 0 deletions src/qubic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ static void processRequestSystemInfo(Peer* peer, RequestResponseHeader* header)
respondedSystemInfo.numberOfTransactions = numberOfTransactions;

respondedSystemInfo.randomMiningSeed = score->initialRandomSeed;
respondedSystemInfo.solutionThreshold = (system.epoch < MAX_NUMBER_EPOCH) ? solutionThreshold[system.epoch] : SOLUTION_THRESHOLD_DEFAULT;

enqueueResponse(peer, sizeof(respondedSystemInfo), RESPOND_SYSTEM_INFO, header->dejavu(), &respondedSystemInfo);
}
Expand Down

0 comments on commit 775c1f5

Please sign in to comment.