Skip to content

Commit 3da755b

Browse files
committed
Merge branch 'main' into feature/k12_engine
2 parents d860cbc + 902283e commit 3da755b

24 files changed

+3706
-732
lines changed

.github/workflows/contract-verify.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ jobs:
3939
echo "contract-filepaths=$files" >> "$GITHUB_OUTPUT"
4040
- name: Contract verify action step
4141
id: verify
42-
uses: Franziska-Mueller/qubic-contract-verify@v1.0.4
42+
uses: Franziska-Mueller/qubic-contract-verify@v1.0.5
4343
with:
4444
filepaths: '${{ steps.filepaths.outputs.contract-filepaths }}'

doc/OracleEngine.png

86.6 KB
Loading

doc/OracleEngine.svg

Lines changed: 3 additions & 0 deletions
Loading

doc/contracts.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,12 @@ QX never releases shares passively (following call of `qpi.acquireShares()` by a
478478
The callbacks `PRE_RELEASE_SHARES()` and `PRE_ACQUIRE_SHARES()` may also check that the `qpi.originator()` initiating the transfer is the owner/possessor.
479479

480480

481+
## Querying off-chain data from Oracles
482+
483+
Oracles enable Smart Contracts to actively query off-chain data sources called Oracles.
484+
Read [Querying Oracles from Contracts](contracts_oracles.md) for more details.
485+
486+
481487
## Other QPI features
482488

483489
### Container types

doc/contracts_oracles.md

Lines changed: 484 additions & 0 deletions
Large diffs are not rendered by default.

src/Qubic.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
<ClInclude Include="contracts\Qdraw.h" />
2727
<ClInclude Include="contracts\qRWA.h" />
2828
<ClInclude Include="contracts\Qswap.h" />
29-
<ClInclude Include="contracts\QVAULT_old.h" />
3029
<ClInclude Include="contracts\RandomLottery.h" />
3130
<ClInclude Include="contracts\QDuel.h" />
3231
<ClInclude Include="contracts\SupplyWatcher.h" />

src/Qubic.vcxproj.filters

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,6 @@
365365
<ClInclude Include="oracle_core\snapshot_files.h">
366366
<Filter>oracle_core</Filter>
367367
</ClInclude>
368-
<ClInclude Include="contracts\QVAULT_old.h">
369-
<Filter>contracts</Filter>
370-
</ClInclude>
371368
</ItemGroup>
372369
<ItemGroup>
373370
<Filter Include="platform">
@@ -418,4 +415,4 @@
418415
<Filter>platform</Filter>
419416
</MASM>
420417
</ItemGroup>
421-
</Project>
418+
</Project>

src/assets/assets.h

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "contract_core/contract_def.h"
1515

1616
#include "public_settings.h"
17+
#include "private_settings.h"
1718
#include "logging/logging.h"
1819
#include "kangaroo_twelve.h"
1920
#include "four_q.h"
@@ -771,7 +772,7 @@ static bool saveUniverse(const CHAR16* fileName = UNIVERSE_FILE_NAME, const CHAR
771772
return false;
772773
}
773774

774-
static bool loadUniverse(const CHAR16* fileName = UNIVERSE_FILE_NAME, CHAR16* directory = NULL)
775+
static bool loadUniverse(const CHAR16* fileName = UNIVERSE_FILE_NAME, CHAR16* directory = NULL, bool rebuildIndexLists = true)
775776
{
776777
PROFILE_SCOPE();
777778

@@ -782,9 +783,38 @@ static bool loadUniverse(const CHAR16* fileName = UNIVERSE_FILE_NAME, CHAR16* di
782783

783784
return false;
784785
}
785-
as.indexLists.rebuild();
786+
787+
if (rebuildIndexLists)
788+
as.indexLists.rebuild();
789+
790+
return true;
791+
}
792+
793+
#if TICK_STORAGE_AUTOSAVE_MODE
794+
static bool saveSnapshotUniverseIndex(const CHAR16* fileName, const CHAR16* directory = NULL)
795+
{
796+
long long savedSize = save(fileName, sizeof(as.indexLists), (unsigned char*)&as.indexLists, directory);
797+
logToConsole(L"Saving universe index");
798+
if (savedSize != sizeof(as.indexLists))
799+
{
800+
logToConsole(L"Failed to save universe index");
801+
return false;
802+
}
803+
return true;
804+
}
805+
806+
static bool loadSnapshotUniverseIndex(const CHAR16* fileName, CHAR16* directory = NULL)
807+
{
808+
long long loadedSize = load(fileName, sizeof(as.indexLists), (unsigned char*)&as.indexLists, directory);
809+
logToConsole(L"Loading universe index");
810+
if (loadedSize != sizeof(as.indexLists))
811+
{
812+
logToConsole(L"Failed to load universe index");
813+
return false;
814+
}
786815
return true;
787816
}
817+
#endif
788818

789819
static void assetsEndEpoch()
790820
{

src/assets/net_msg_impl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ static void processRequestAssetsSendRecord(Peer* peer, RequestResponseHeader* re
135135

136136
static void processRequestAssets(Peer* peer, RequestResponseHeader* header)
137137
{
138-
// check size of recieved message (request by universe index may be smaller than sizeof(RequestAssets))
138+
// check size of received message (request by universe index may be smaller than sizeof(RequestAssets))
139139
if (!header->checkPayloadSizeMinMax(sizeof(RequestAssets::byUniverseIdx), sizeof(RequestAssets)))
140140
return;
141141
RequestAssets* request = header->getPayload<RequestAssets>();
142142
if (request->assetReqType != RequestAssets::requestByUniverseIdx && !header->checkPayloadSize(sizeof(RequestAssets)))
143143
return;
144144

145-
// initalize output message (with siblings because the variant without siblings is just a subset)
145+
// initialize output message (with siblings because the variant without siblings is just a subset)
146146
struct
147147
{
148148
RequestResponseHeader header;
@@ -152,7 +152,7 @@ static void processRequestAssets(Peer* peer, RequestResponseHeader* header)
152152
response.header.setType(RespondAssets::type());
153153
response.header.setDejavu(header->dejavu());
154154

155-
// size of output message depends on whether sibilings are requested
155+
// size of output message depends on whether siblings are requested
156156
if (request->byFilter.flags & RequestAssets::getSiblings)
157157
response.header.setSize<sizeof(RequestResponseHeader) + sizeof(RespondAssetsWithSiblings)>();
158158
else

src/contract_core/contract_def.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,7 @@
112112
#define CONTRACT_INDEX QVAULT_CONTRACT_INDEX
113113
#define CONTRACT_STATE_TYPE QVAULT
114114
#define CONTRACT_STATE2_TYPE QVAULT2
115-
#ifdef OLD_QVAULT
116-
#include "contracts/QVAULT_old.h"
117-
#else
118115
#include "contracts/QVAULT.h"
119-
#endif
120116

121117
#undef CONTRACT_INDEX
122118
#undef CONTRACT_STATE_TYPE
@@ -258,6 +254,20 @@
258254
#define CONTRACT_STATE2_TYPE PULSE2
259255
#include "contracts/Pulse.h"
260256

257+
#ifndef NO_VOTTUN
258+
259+
#undef CONTRACT_INDEX
260+
#undef CONTRACT_STATE_TYPE
261+
#undef CONTRACT_STATE2_TYPE
262+
263+
#define VOTTUNBRIDGE_CONTRACT_INDEX 25
264+
#define CONTRACT_INDEX VOTTUNBRIDGE_CONTRACT_INDEX
265+
#define CONTRACT_STATE_TYPE VOTTUNBRIDGE
266+
#define CONTRACT_STATE2_TYPE VOTTUNBRIDGE2
267+
#include "contracts/VottunBridge.h"
268+
269+
#endif
270+
261271
// new contracts should be added above this line
262272

263273
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
@@ -368,6 +378,9 @@ constexpr struct ContractDescription
368378
{"QTF", 199, 10000, sizeof(QTF::StateData)}, // proposal in epoch 197, IPO in 198, construction and first use in 199
369379
{"QDUEL", 199, 10000, sizeof(QDUEL::StateData)}, // proposal in epoch 197, IPO in 198, construction and first use in 199
370380
{"PULSE", 204, 10000, sizeof(PULSE::StateData)}, // proposal in epoch 202, IPO in 203, construction and first use in 204
381+
#ifndef NO_VOTTUN
382+
{"VOTTUN", 206, 10000, sizeof(VOTTUNBRIDGE::StateData)}, // proposal in epoch 204, IPO in 205, construction and first use in 206
383+
#endif
371384
// new contracts should be added above this line
372385
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
373386
{"TESTEXA", 138, 10000, sizeof(TESTEXA::StateData)},
@@ -488,6 +501,9 @@ static void initializeContracts()
488501
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QTF);
489502
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QDUEL);
490503
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(PULSE);
504+
#ifndef NO_VOTTUN
505+
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(VOTTUNBRIDGE);
506+
#endif
491507
// new contracts should be added above this line
492508
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
493509
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(TESTEXA);

0 commit comments

Comments
 (0)