Skip to content

Commit 881b31e

Browse files
Merge pull request #488 from qubic/develop (Release v1.253.0)
Release v1.253.0
2 parents 572786c + 7845e57 commit 881b31e

File tree

13 files changed

+149
-26
lines changed

13 files changed

+149
-26
lines changed

src/Qubic.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<ClInclude Include="contract_core\qpi_asset_impl.h" />
5151
<ClInclude Include="contract_core\qpi_collection_impl.h" />
5252
<ClInclude Include="contract_core\qpi_ipo_impl.h" />
53+
<ClInclude Include="contract_core\qpi_mining_impl.h" />
5354
<ClInclude Include="contract_core\qpi_spectrum_impl.h" />
5455
<ClInclude Include="contract_core\qpi_system_impl.h" />
5556
<ClInclude Include="contract_core\qpi_hash_map_impl.h" />

src/Qubic.vcxproj.filters

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@
270270
<Filter>platform</Filter>
271271
</ClInclude>
272272
<ClInclude Include="revenue.h" />
273+
<ClInclude Include="contract_core\qpi_mining_impl.h">
274+
<Filter>contract_core</Filter>
275+
</ClInclude>
273276
</ItemGroup>
274277
<ItemGroup>
275278
<Filter Include="platform">
@@ -317,4 +320,4 @@
317320
<Filter>platform</Filter>
318321
</MASM>
319322
</ItemGroup>
320-
</Project>
323+
</Project>

src/contract_core/contract_def.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@ struct __FunctionOrProcedureBeginEndGuard
194194
#define CONTRACT_STATE2_TYPE QSWAP2
195195
#include "contracts/Qswap.h"
196196

197-
#ifndef NO_NOST
198-
199197
#undef CONTRACT_INDEX
200198
#undef CONTRACT_STATE_TYPE
201199
#undef CONTRACT_STATE2_TYPE
@@ -206,8 +204,6 @@ struct __FunctionOrProcedureBeginEndGuard
206204
#define CONTRACT_STATE2_TYPE NOST2
207205
#include "contracts/Nostromo.h"
208206

209-
#endif
210-
211207
// new contracts should be added above this line
212208

213209
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
@@ -304,9 +300,7 @@ constexpr struct ContractDescription
304300
{"MSVAULT", 149, 10000, sizeof(MSVAULT)}, // proposal in epoch 147, IPO in 148, construction and first use in 149
305301
{"QBAY", 154, 10000, sizeof(QBAY)}, // proposal in epoch 152, IPO in 153, construction and first use in 154
306302
{"QSWAP", 171, 10000, sizeof(QSWAP)}, // proposal in epoch 169, IPO in 170, construction and first use in 171
307-
#ifndef NO_NOST
308303
{"NOST", 172, 10000, sizeof(NOST)}, // proposal in epoch 170, IPO in 171, construction and first use in 172
309-
#endif
310304
// new contracts should be added above this line
311305
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
312306
{"TESTEXA", 138, 10000, sizeof(IPO)},
@@ -409,9 +403,7 @@ static void initializeContracts()
409403
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(MSVAULT);
410404
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QBAY);
411405
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QSWAP);
412-
#ifndef NO_NOST
413406
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(NOST);
414-
#endif
415407
// new contracts should be added above this line
416408
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
417409
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(TESTEXA);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma once
2+
3+
#include "contracts/qpi.h"
4+
#include "score.h"
5+
6+
static ScoreFunction<
7+
NUMBER_OF_INPUT_NEURONS,
8+
NUMBER_OF_OUTPUT_NEURONS,
9+
NUMBER_OF_TICKS*2,
10+
NUMBER_OF_NEIGHBORS,
11+
POPULATION_THRESHOLD,
12+
NUMBER_OF_MUTATIONS,
13+
SOLUTION_THRESHOLD_DEFAULT,
14+
1
15+
>* score_qpi = nullptr; // NOTE: SC is single-threaded
16+
17+
m256i QPI::QpiContextFunctionCall::computeMiningFunction(const m256i miningSeed, const m256i publicKey, const m256i nonce) const
18+
{
19+
(*score_qpi)(0, publicKey, miningSeed, nonce);
20+
return score_qpi->getLastOutput(0);
21+
}

src/contract_core/qpi_ticking_impl.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,19 @@ QPI::DateAndTime QPI::QpiContextFunctionCall::now() const
5555
result.second = etalonTick.second;
5656
result.millisecond = etalonTick.millisecond;
5757
return result;
58+
}
59+
60+
m256i QPI::QpiContextFunctionCall::getPrevSpectrumDigest() const
61+
{
62+
return etalonTick.prevSpectrumDigest;
63+
}
64+
65+
m256i QPI::QpiContextFunctionCall::getPrevUniverseDigest() const
66+
{
67+
return etalonTick.prevUniverseDigest;
68+
}
69+
70+
m256i QPI::QpiContextFunctionCall::getPrevComputerDigest() const
71+
{
72+
return etalonTick.prevComputerDigest;
5873
}

src/contracts/Nostromo.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,14 @@ struct NOST : public ContractBase
572572
}
573573
return ;
574574
}
575+
if (QUOTTERY::checkValidQtryDateTime(locals.firstPhaseStartDate) == 0 || QUOTTERY::checkValidQtryDateTime(locals.firstPhaseEndDate) == 0 || QUOTTERY::checkValidQtryDateTime(locals.secondPhaseStartDate) == 0 || QUOTTERY::checkValidQtryDateTime(locals.secondPhaseEndDate) == 0 || QUOTTERY::checkValidQtryDateTime(locals.thirdPhaseStartDate) == 0 || QUOTTERY::checkValidQtryDateTime(locals.thirdPhaseEndDate) == 0 || QUOTTERY::checkValidQtryDateTime(locals.listingStartDate) == 0 || QUOTTERY::checkValidQtryDateTime(locals.cliffEndDate) == 0 || QUOTTERY::checkValidQtryDateTime(locals.vestingEndDate) == 0)
576+
{
577+
if (qpi.invocationReward() > 0)
578+
{
579+
qpi.transfer(qpi.invocator(), qpi.invocationReward());
580+
}
581+
return ;
582+
}
575583

576584
if (input.stepOfVesting == 0 || input.stepOfVesting > 12 || input.TGE > 50 || input.threshold > 50 || input.indexOfProject >= state.numberOfCreatedProject)
577585
{
@@ -923,6 +931,14 @@ struct NOST : public ContractBase
923931
}
924932
locals.tmpFundraising.raisedFunds += qpi.invocationReward();
925933
}
934+
else
935+
{
936+
if (qpi.invocationReward() > 0)
937+
{
938+
qpi.transfer(qpi.invocator(), qpi.invocationReward());
939+
}
940+
return ;
941+
}
926942
if (locals.minCap <= locals.tmpFundraising.raisedFunds && locals.tmpFundraising.isCreatedToken == 0)
927943
{
928944
locals.input.assetName = state.projects.get(locals.tmpFundraising.indexOfProject).tokenName;

src/contracts/QUtil.h

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ struct QUTIL : public ContractBase
106106
uint64 current_poll_id;
107107
uint64 new_polls_this_epoch;
108108

109+
// DF function variables
110+
m256i dfMiningSeed;
111+
m256i dfCurrentState;
112+
109113
// Get Qubic Balance
110114
struct get_qubic_balance_input {
111115
id address;
@@ -368,15 +372,6 @@ struct QUTIL : public ContractBase
368372
QUtilPoll current_poll;
369373
};
370374

371-
struct BEGIN_EPOCH_locals
372-
{
373-
uint64 i;
374-
uint64 j;
375-
QUtilPoll default_poll;
376-
QUtilVoter default_voter;
377-
Array<uint8, QUTIL_POLL_GITHUB_URL_MAX_SIZE> zero_link;
378-
};
379-
380375
/**************************************/
381376
/***********HELPER FUNCTIONS***********/
382377
/**************************************/
@@ -1171,6 +1166,25 @@ struct QUTIL : public ContractBase
11711166
state.new_polls_this_epoch = 0;
11721167
}
11731168

1169+
BEGIN_EPOCH()
1170+
{
1171+
state.dfMiningSeed = qpi.getPrevSpectrumDigest();
1172+
}
1173+
1174+
struct BEGIN_TICK_locals
1175+
{
1176+
m256i dfPubkey, dfNonce;
1177+
};
1178+
/*
1179+
* A deterministic delay function
1180+
*/
1181+
BEGIN_TICK_WITH_LOCALS()
1182+
{
1183+
locals.dfPubkey = qpi.getPrevSpectrumDigest();
1184+
locals.dfNonce = qpi.getPrevComputerDigest();
1185+
state.dfCurrentState = qpi.computeMiningFunction(state.dfMiningSeed, locals.dfPubkey, locals.dfNonce);
1186+
}
1187+
11741188
/*
11751189
* @return Return total number of shares that currently exist of the asset given as input
11761190
*/

src/contracts/qpi.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,18 @@ namespace QPI
17681768
// return current datetime (year, month, day, hour, minute, second, millisec)
17691769
inline DateAndTime now() const;
17701770

1771+
// return last spectrum digest on etalonTick
1772+
inline m256i getPrevSpectrumDigest() const;
1773+
1774+
// return last universe digest on etalonTick
1775+
inline m256i getPrevUniverseDigest() const;
1776+
1777+
// return last computer digest on etalonTick
1778+
inline m256i getPrevComputerDigest() const;
1779+
1780+
// run the score function (in qubic mining) and return first 256 bit of output
1781+
inline m256i computeMiningFunction(const m256i miningSeed, const m256i publicKey, const m256i nonce) const;
1782+
17711783
inline bit signatureValidity(
17721784
const id& entity,
17731785
const id& digest,

src/public_settings.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
// Number of ticks from prior epoch that are kept after seamless epoch transition. These can be requested after transition.
2424
#define TICKS_TO_KEEP_FROM_PRIOR_EPOCH 100
2525

26-
#define TARGET_TICK_DURATION 1500
26+
#define TARGET_TICK_DURATION 3000
2727
#define TRANSACTION_SPARSENESS 1
2828

2929
// Below are 2 variables that are used for auto-F5 feature:
@@ -56,12 +56,12 @@ static_assert(AUTO_FORCE_NEXT_TICK_THRESHOLD* TARGET_TICK_DURATION >= PEER_REFRE
5656
// Config options that should NOT be changed by operators
5757

5858
#define VERSION_A 1
59-
#define VERSION_B 252
59+
#define VERSION_B 253
6060
#define VERSION_C 0
6161

6262
// Epoch and initial tick for node startup
63-
#define EPOCH 171
64-
#define TICK 30220000
63+
#define EPOCH 172
64+
#define TICK 30655000
6565

6666
#define ARBITRATOR "AFZPUAIYVPNUYGJRQVLUKOPPVLHAZQTGLYAAUUNBXFTVTAMSBKQBLEIEPCVJ"
6767
#define DISPATCHER "XPXYKFLGSWRHRGAUKWFWVXCDVEYAPCPCNUTMUDWFGDYQCWZNJMWFZEEGCFFO"

src/qubic.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#define SINGLE_COMPILE_UNIT
22

3-
// #define NO_NOST
4-
53
// contract_def.h needs to be included first to make sure that contracts have minimal access
64
#include "contract_core/contract_def.h"
75
#include "contract_core/contract_exec.h"
@@ -70,6 +68,7 @@
7068
#include "mining/mining.h"
7169
#include "oracles/oracle_machines.h"
7270

71+
#include "contract_core/qpi_mining_impl.h"
7372
#include "revenue.h"
7473

7574
////////// Qubic \\\\\\\\\\
@@ -5531,6 +5530,12 @@ static bool initialize()
55315530
}
55325531
setMem(score, sizeof(*score), 0);
55335532

5533+
if (!allocPoolWithErrorLog(L"score", sizeof(*score_qpi), (void**)&score_qpi, __LINE__))
5534+
{
5535+
return false;
5536+
}
5537+
setMem(score_qpi, sizeof(*score_qpi), 0);
5538+
55345539
setMem(solutionThreshold, sizeof(int) * MAX_NUMBER_EPOCH, 0);
55355540
if (!allocPoolWithErrorLog(L"minserSolutionFlag", NUMBER_OF_MINER_SOLUTION_FLAGS / 8, (void**)&minerSolutionFlags, __LINE__))
55365541
{

0 commit comments

Comments
 (0)