diff --git a/connection.cpp b/connection.cpp index 3096717..5888de7 100644 --- a/connection.cpp +++ b/connection.cpp @@ -13,6 +13,9 @@ #include #include +// core submodule +#include "network_messages/revenue_data.h" + #include "connection.h" #include "logger.h" #include "structs.h" @@ -422,4 +425,4 @@ template GetCurrentPollId_output QubicConnection::receivePacketWithHeaderAs(); // REVENUE -template void QubicConnection::receivePacketWithHeaderAs(RevenueData&); +template void QubicConnection::receivePacketWithHeaderAs(RespondRevenueData&); diff --git a/defines.h b/defines.h index 1864def..6f8a7de 100644 --- a/defines.h +++ b/defines.h @@ -8,7 +8,6 @@ #define DEFAULT_SCHEDULED_TICK_OFFSET 8 #define DEFAULT_NODE_PORT 21841 #define DEFAULT_NODE_IP "127.0.0.1" -#define NUMBER_OF_TRANSACTIONS_PER_TICK 4096 #define SIGNATURE_SIZE 64 #define MAX_INPUT_SIZE 1024ULL #define MAX_TRANSACTION_SIZE (MAX_INPUT_SIZE + sizeof(Transaction) + SIGNATURE_SIZE) @@ -41,8 +40,6 @@ #define RESPOND_POSSESSED_ASSETS 41 #define REQUEST_SYSTEM_INFO 46 #define RESPOND_SYSTEM_INFO 47 -#define REQUEST_REVENUE_DATA 70 -#define RESPOND_REVENUE_DATA 71 #define SPECIAL_COMMAND_SET_SOLUTION_THRESHOLD_REQUEST 5ULL #define SPECIAL_COMMAND_SET_SOLUTION_THRESHOLD_RESPONSE 6ULL diff --git a/node_utils.cpp b/node_utils.cpp index d350c24..c86754b 100644 --- a/node_utils.cpp +++ b/node_utils.cpp @@ -8,6 +8,9 @@ #include #include +// Core network-message header must precede defines.h to avoid macro/enum collisions. +#include "network_messages/revenue_data.h" + #include "defines.h" #include "structs.h" #include "connection.h" @@ -241,14 +244,14 @@ void dumpRevenueDataFromNode(const char* nodeIp, int nodePort, const char* outpu } packet; packet.header.setSize(sizeof(packet)); packet.header.randomizeDejavu(); - packet.header.setType(REQUEST_REVENUE_DATA); + packet.header.setType(RequestRevenueData::type()); qc->sendData((uint8_t *) &packet, packet.header.size()); - // RevenueData is ~16 KB; receive into a heap buffer to avoid a large stack frame. - auto result = std::make_unique(); + // RespondRevenueData is ~16 KB; receive into a heap buffer to avoid a large stack frame. + auto result = std::make_unique(); try { - qc->receivePacketWithHeaderAs(*result); + qc->receivePacketWithHeaderAs(*result); } catch (std::logic_error) { @@ -1973,7 +1976,6 @@ static bool isEmptyEntity(const Entity& e){ } void dumpSpectrumToCSV(const char* input, const char* output){ - const size_t SPECTRUM_CAPACITY = 0x1000000ULL; // may be changed in the future Entity* spectrum = (Entity*)malloc(SPECTRUM_CAPACITY*sizeof(Entity)); FILE* f = fopen(input, "rb"); if (fread(spectrum, 1, SPECTRUM_CAPACITY*sizeof(Entity), f) != SPECTRUM_CAPACITY*sizeof(Entity)) @@ -2010,7 +2012,6 @@ void dumpSpectrumToCSV(const char* input, const char* output){ // only print ownership void dumpUniverseToCSV(const char* input, const char* output){ - const size_t ASSETS_CAPACITY = 0x1000000ULL; // may be changed in the future AssetRecord* asset = (AssetRecord*)malloc(ASSETS_CAPACITY*sizeof(Entity)); FILE* f = fopen(input, "rb"); if (fread(asset, 1, ASSETS_CAPACITY*sizeof(AssetRecord), f) != ASSETS_CAPACITY * sizeof(AssetRecord)) diff --git a/structs.h b/structs.h index 3f9561a..64aef18 100644 --- a/structs.h +++ b/structs.h @@ -3,6 +3,10 @@ #include #include +// Core network-message common_def.h MUST be included before defines.h so that core's +// NetworkMessageType enum is parsed before defines.h's same-named macros are introduced. +#include "network_messages/common_def.h" + #include "defines.h" #include "utils.h" @@ -420,26 +424,6 @@ struct CurrentSystemInfo }; #pragma pack(pop) -// Mirrors core RespondRevenueData (src/network_messages/revenue_data.h). Wire format must match exactly. -// Approximate, current-tick snapshot of the per-computor revenue score components; the consumer -// computes the final revenue from these (rank-cap + k-th root DOGE softening + multiply). -#pragma pack(push, 1) -struct RevenueData -{ - unsigned int tick; // current tick the scores correspond to - unsigned short dogeK; // REVENUE_DOGE_K (DOGE softening exponent) active on the node - long long ipc; // REVENUE_IPC, the per-computor revenue cap - unsigned long long txScore[NUMBER_OF_COMPUTORS]; - unsigned long long oracleScore[NUMBER_OF_COMPUTORS]; - unsigned long long dogeScore[NUMBER_OF_COMPUTORS]; - - static constexpr unsigned char type() - { - return RESPOND_REVENUE_DATA; - } -}; -#pragma pack(pop) - struct TickData { unsigned short computorIndex; diff --git a/submodules/core b/submodules/core index 74b0180..daf3b71 160000 --- a/submodules/core +++ b/submodules/core @@ -1 +1 @@ -Subproject commit 74b0180f0fad9e4bb350e7eca0fa383f88c3d0ba +Subproject commit daf3b71335dfdcea65297826e9aca2df9cc26d72