Skip to content

Commit

Permalink
Merge pull request #171 from qubic/develop
Browse files Browse the repository at this point in the history
Release/v1.219.0
  • Loading branch information
philippwerner authored Sep 18, 2024
2 parents 804518d + 063977e commit 0bf7788
Show file tree
Hide file tree
Showing 20 changed files with 565 additions and 259 deletions.
6 changes: 4 additions & 2 deletions src/Qubic.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
<ClInclude Include="contract_core\qpi_trivial_impl.h" />
<ClInclude Include="contract_core\stack_buffer.h" />
<ClInclude Include="contract_core\qpi_proposal_voting.h" />
<ClInclude Include="logging.h" />
<ClInclude Include="logging\logging.h" />
<ClInclude Include="logging\net_msg_impl.h" />
<ClInclude Include="mining\mining.h" />
<ClInclude Include="network_core\peers.h" />
<ClInclude Include="network_core\tcp4.h" />
Expand All @@ -59,6 +60,7 @@
<ClInclude Include="network_messages\transactions.h" />
<ClInclude Include="oracles\oracle_machines.h" />
<ClInclude Include="oracles\Price.h" />
<ClInclude Include="platform\assert.h" />
<ClInclude Include="platform\concurrency.h" />
<ClInclude Include="four_q.h" />
<ClInclude Include="kangaroo_twelve.h" />
Expand Down Expand Up @@ -286,4 +288,4 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project>
</Project>
13 changes: 12 additions & 1 deletion src/Qubic.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
</ClInclude>
<ClInclude Include="system.h" />
<ClInclude Include="assets.h" />
<ClInclude Include="logging.h" />
<ClInclude Include="network_messages\assets.h">
<Filter>network_messages</Filter>
</ClInclude>
Expand Down Expand Up @@ -174,6 +173,15 @@
<ClInclude Include="mining\mining.h">
<Filter>mining</Filter>
</ClInclude>
<ClInclude Include="logging\logging.h">
<Filter>logging</Filter>
</ClInclude>
<ClInclude Include="logging\net_msg_impl.h">
<Filter>logging</Filter>
</ClInclude>
<ClInclude Include="platform\assert.h">
<Filter>platform</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="platform">
Expand All @@ -200,6 +208,9 @@
<Filter Include="mining">
<UniqueIdentifier>{df525479-7504-470c-a25a-de4af8be0e5d}</UniqueIdentifier>
</Filter>
<Filter Include="logging">
<UniqueIdentifier>{d334594b-f24d-440e-949a-c791aa13f867}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<MASM Include="platform\custom_stack.asm">
Expand Down
2 changes: 1 addition & 1 deletion src/assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "network_messages/assets.h"

#include "public_settings.h"
#include "logging.h"
#include "logging/logging.h"
#include "kangaroo_twelve.h"
#include "four_q.h"
#include "common_buffers.h"
Expand Down
6 changes: 0 additions & 6 deletions src/contract_core/contract_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,11 @@ struct __FunctionOrProcedureBeginEndGuard
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE

#if IPO_OF_CCF
#define CCF_CONTRACT_INDEX 8
#define CONTRACT_INDEX CCF_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE CCF
#define CONTRACT_STATE2_TYPE CCF2
#include "contracts/ComputorControlledFund.h"
#endif


#define MAX_CONTRACT_ITERATION_DURATION 0 // In milliseconds, must be above 0; for now set to 0 to disable timeout, because a rollback mechanism needs to be implemented to properly handle timeout
Expand Down Expand Up @@ -190,9 +188,7 @@ constexpr struct ContractDescription
{"MLM", 112, 10000, sizeof(IPO)},
{"GQMPROP", 123, 10000, sizeof(GQMPROP)},
{"SWATCH", 123, 10000, sizeof(IPO)},
#if IPO_OF_CCF
{"CCF", 127, 10000, sizeof(CCF)}, // proposal in epoch 125, IPO in 126, construction and first use in 127
#endif
};

constexpr unsigned int contractCount = sizeof(contractDescriptions) / sizeof(contractDescriptions[0]);
Expand Down Expand Up @@ -276,7 +272,5 @@ static void initializeContracts()
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(MLM);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(GQMPROP);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(SWATCH);
#if IPO_OF_CCF
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(CCF);
#endif
}
12 changes: 5 additions & 7 deletions src/contract_core/qpi_proposal_voting.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ namespace QPI
if (!supportScalarVotes)
{
// option voting only (1 byte per voter)
// TODO: ASSERT that proposal type does not require sint64 (internal logic error)
ASSERT(proposal.type != ProposalTypes::VariableScalarMean);
constexpr uint8 noVoteValue = 0xff;
setMemory(votes, noVoteValue);
}
Expand Down Expand Up @@ -206,7 +206,7 @@ namespace QPI
// scalar vote
if (supportScalarVotes)
{
// TODO: add ASSERT checking that storage type is sint64
ASSERT(sizeof(votes[0]) == 8);
if ((voteValue >= this->variableScalar.minValue && voteValue <= this->variableScalar.maxValue))
{
// (cast should not be needed but is to get rid of warning)
Expand Down Expand Up @@ -365,8 +365,7 @@ namespace QPI
// remove oldest proposal
clearProposal(proposalIndex);

// call voters interface again in case it needs to register the proposer
// TODO: add ASSERT, because this should always return the same value if the interface is implemented correctly
// call voters interface again in case it needs to register the proposer (should always return the same value)
proposalIndex = pv.proposersAndVoters.getNewProposalIndex(qpi, proposer);
}

Expand Down Expand Up @@ -463,7 +462,6 @@ namespace QPI
return false;

// scalar voting -> compute mean value of votes
// TODO: ASSERT(optionCount) == 0
sint64 value;
sint64 accumulation = 0;
if (p.variableScalar.maxValue > p.variableScalar.maxSupportedValue / maxVoters
Expand Down Expand Up @@ -554,8 +552,8 @@ namespace QPI
else
{
// option voting -> compute histogram
// TODO: ASSERT(optionCount) > 0
// TODO: assert option count >= array capacity
ASSERT(votingSummary.optionCount > 0);
ASSERT(votingSummary.optionCount <= votingSummary.optionVoteCount.capacity());
auto& hist = votingSummary.optionVoteCount;
hist.setAll(0);
for (uint32 i = 0; i < pv.maxVoters; ++i)
Expand Down
6 changes: 4 additions & 2 deletions src/contracts/qpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// m256i is used for the id data type
#include "../platform/m256.h"

// ASSERT can be used to support debugging and speed-up development
#include "../platform/assert.h"

namespace QPI
{
Expand Down Expand Up @@ -1404,7 +1406,7 @@ namespace QPI
input, output, \
*(contractStateType::function##_locals*)qpi.__qpiAllocLocals(sizeof(contractStateType::function##_locals))); \
qpi.__qpiReleaseStateForReading(contractStateType::__contract_index); \
qpi.__qpiFreeContextOtherContract(contractStateType::__contract_index); \
qpi.__qpiFreeContextOtherContract(); \
qpi.__qpiFreeLocals()

// Transfer invocation reward and invoke of other contract (procedure only)
Expand All @@ -1420,7 +1422,7 @@ namespace QPI
input, output, \
*(contractStateType::procedure##_locals*)qpi.__qpiAllocLocals(sizeof(contractStateType::procedure##_locals))); \
qpi.__qpiReleaseStateForWriting(contractStateType::__contract_index); \
qpi.__qpiFreeContextOtherContract(contractStateType::__contract_index); \
qpi.__qpiFreeContextOtherContract(); \
qpi.__qpiFreeLocals()

#define QUERY_ORACLE(oracle, query) // TODO
Expand Down
Loading

0 comments on commit 0bf7788

Please sign in to comment.