Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include <string>
#include <stdexcept>

// core submodule
#include "network_messages/revenue_data.h"

#include "connection.h"
#include "logger.h"
#include "structs.h"
Expand Down Expand Up @@ -422,4 +425,4 @@ template GetCurrentPollId_output QubicConnection::receivePacketWithHeaderAs<GetC
template GetPollInfo_output QubicConnection::receivePacketWithHeaderAs<GetPollInfo_output>();

// REVENUE
template void QubicConnection::receivePacketWithHeaderAs<RevenueData>(RevenueData&);
template void QubicConnection::receivePacketWithHeaderAs<RespondRevenueData>(RespondRevenueData&);
3 changes: 0 additions & 3 deletions defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
13 changes: 7 additions & 6 deletions node_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include <stdexcept>
#include <cinttypes>

// 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"
Expand Down Expand Up @@ -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<RevenueData>();
// RespondRevenueData is ~16 KB; receive into a heap buffer to avoid a large stack frame.
auto result = std::make_unique<RespondRevenueData>();
try
{
qc->receivePacketWithHeaderAs<RevenueData>(*result);
qc->receivePacketWithHeaderAs<RespondRevenueData>(*result);
}
catch (std::logic_error)
{
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
24 changes: 4 additions & 20 deletions structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
#include <cstddef>
#include <cstring>

// 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"

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion submodules/core
Submodule core updated 56 files
+48 −0 .github/workflows/build-tests.yml
+1 −1 .github/workflows/efi-build-develop.yml
+20 −4 doc/contracts.md
+3 −2 src/Qubic.vcxproj
+9 −6 src/Qubic.vcxproj.filters
+2 −0 src/addons/tx_status_request.h
+7 −1 src/assets/net_msg_impl.h
+52 −14 src/contract_core/contract_def.h
+71 −1 src/contract_core/contract_exec.h
+2 −1 src/contract_core/pre_qpi_def.h
+1,250 −0 src/contracts/GGWP.h
+110 −120 src/contracts/QBond.h
+450 −166 src/contracts/QIP.h
+3 −22 src/contracts/QRaffle.h
+0 −1,499 src/contracts/QRaffle_old.h
+0 −3,692 src/contracts/QVAULT_old.h
+139 −29 src/contracts/Qbay.h
+2,774 −0 src/contracts/Qbay_old.h
+34 −11 src/contracts/Qearn.h
+272 −216 src/contracts/Qswap.h
+2,436 −0 src/contracts/Qswap_old.h
+307 −158 src/contracts/Random.h
+14 −2 src/contracts/SupplyWatcher.h
+150 −0 src/contracts/math_lib.h
+28 −19 src/contracts/qpi.h
+61 −2 src/four_q.h
+10 −0 src/logging/net_msg_impl.h
+1,923 −676 src/mining/score_addition.h
+1 −0 src/network_messages/all.h
+1 −1 src/network_messages/common_def.h
+2 −0 src/network_messages/network_message_type.h
+40 −0 src/network_messages/revenue_data.h
+6 −0 src/oracle_core/oracle_engine.h
+21 −0 src/platform/file_io.h
+20 −12 src/platform/virtual_memory.h
+15 −13 src/public_settings.h
+234 −86 src/qubic.cpp
+253 −93 src/revenue.h
+5 −5 src/ticking/tick_storage.h
+1,089 −0 test/contract_ggwp.cpp
+306 −19 test/contract_qbay.cpp
+18 −19 test/contract_qbond.cpp
+545 −95 test/contract_qip.cpp
+20 −17 test/contract_qswap.cpp
+1,086 −0 test/contract_random.cpp
+ test/data/custom_revenue.eoe
+1,025 −0 test/data/scores_addition_detour.csv
+431 −0 test/fourq.cpp
+134 −0 test/math_lib.cpp
+335 −112 test/revenue.cpp
+1 −1 test/score.cpp
+82 −87 test/score_addition_reference.h
+6 −4 test/score_params.h
+1 −0 test/test.vcxproj
+1 −0 test/test.vcxproj.filters
+1 −0 test/test.vcxproj.user
Loading