Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/contract-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ jobs:
echo "contract-filepaths=$files" >> "$GITHUB_OUTPUT"
- name: Contract verify action step
id: verify
uses: Franziska-Mueller/qubic-contract-verify@v1.0.4
uses: Franziska-Mueller/qubic-contract-verify@v1.0.5
with:
filepaths: '${{ steps.filepaths.outputs.contract-filepaths }}'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,6 @@ We cannot support you in any case. You are welcome to provide updates, bug fixes
- [Qubic protocol](doc/protocol.md)
- [Custom mining](doc/custom_mining.md)
- [Seamless epoch transition](SEAMLESS.md)
- [Querying oracles](doc/contracts_oracles.md)
- [Proposals and voting](doc/contracts_proposals.md)

Binary file added doc/OracleEngine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions doc/OracleEngine.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions doc/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,12 @@ QX never releases shares passively (following call of `qpi.acquireShares()` by a
The callbacks `PRE_RELEASE_SHARES()` and `PRE_ACQUIRE_SHARES()` may also check that the `qpi.originator()` initiating the transfer is the owner/possessor.


## Querying off-chain data from Oracles

Oracles enable Smart Contracts to actively query off-chain data sources called Oracles.
Read [Querying Oracles from Contracts](contracts_oracles.md) for more details.


## Other QPI features

### Container types
Expand Down
484 changes: 484 additions & 0 deletions doc/contracts_oracles.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/Qubic.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<ClInclude Include="contracts\Qdraw.h" />
<ClInclude Include="contracts\qRWA.h" />
<ClInclude Include="contracts\Qswap.h" />
<ClInclude Include="contracts\QVAULT_old.h" />
<ClInclude Include="contracts\RandomLottery.h" />
<ClInclude Include="contracts\QDuel.h" />
<ClInclude Include="contracts\SupplyWatcher.h" />
Expand Down
5 changes: 1 addition & 4 deletions src/Qubic.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,6 @@
<ClInclude Include="oracle_core\snapshot_files.h">
<Filter>oracle_core</Filter>
</ClInclude>
<ClInclude Include="contracts\QVAULT_old.h">
<Filter>contracts</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="platform">
Expand Down Expand Up @@ -418,4 +415,4 @@
<Filter>platform</Filter>
</MASM>
</ItemGroup>
</Project>
</Project>
34 changes: 32 additions & 2 deletions src/assets/assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "contract_core/contract_def.h"

#include "public_settings.h"
#include "private_settings.h"
#include "logging/logging.h"
#include "kangaroo_twelve.h"
#include "four_q.h"
Expand Down Expand Up @@ -771,7 +772,7 @@ static bool saveUniverse(const CHAR16* fileName = UNIVERSE_FILE_NAME, const CHAR
return false;
}

static bool loadUniverse(const CHAR16* fileName = UNIVERSE_FILE_NAME, CHAR16* directory = NULL)
static bool loadUniverse(const CHAR16* fileName = UNIVERSE_FILE_NAME, CHAR16* directory = NULL, bool rebuildIndexLists = true)
{
PROFILE_SCOPE();

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

return false;
}
as.indexLists.rebuild();

if (rebuildIndexLists)
as.indexLists.rebuild();

return true;
}

#if TICK_STORAGE_AUTOSAVE_MODE
static bool saveSnapshotUniverseIndex(const CHAR16* fileName, const CHAR16* directory = NULL)
{
long long savedSize = save(fileName, sizeof(as.indexLists), (unsigned char*)&as.indexLists, directory);
logToConsole(L"Saving universe index");
if (savedSize != sizeof(as.indexLists))
{
logToConsole(L"Failed to save universe index");
return false;
}
return true;
}

static bool loadSnapshotUniverseIndex(const CHAR16* fileName, CHAR16* directory = NULL)
{
long long loadedSize = load(fileName, sizeof(as.indexLists), (unsigned char*)&as.indexLists, directory);
logToConsole(L"Loading universe index");
if (loadedSize != sizeof(as.indexLists))
{
logToConsole(L"Failed to load universe index");
return false;
}
return true;
}
#endif

static void assetsEndEpoch()
{
Expand Down
6 changes: 3 additions & 3 deletions src/assets/net_msg_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ static void processRequestAssetsSendRecord(Peer* peer, RequestResponseHeader* re

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

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

// size of output message depends on whether sibilings are requested
// size of output message depends on whether siblings are requested
if (request->byFilter.flags & RequestAssets::getSiblings)
response.header.setSize<sizeof(RequestResponseHeader) + sizeof(RespondAssetsWithSiblings)>();
else
Expand Down
24 changes: 20 additions & 4 deletions src/contract_core/contract_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,7 @@
#define CONTRACT_INDEX QVAULT_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE QVAULT
#define CONTRACT_STATE2_TYPE QVAULT2
#ifdef OLD_QVAULT
#include "contracts/QVAULT_old.h"
#else
#include "contracts/QVAULT.h"
#endif

#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
Expand Down Expand Up @@ -258,6 +254,20 @@
#define CONTRACT_STATE2_TYPE PULSE2
#include "contracts/Pulse.h"

#ifndef NO_VOTTUN

#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE

#define VOTTUNBRIDGE_CONTRACT_INDEX 25
#define CONTRACT_INDEX VOTTUNBRIDGE_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE VOTTUNBRIDGE
#define CONTRACT_STATE2_TYPE VOTTUNBRIDGE2
#include "contracts/VottunBridge.h"

#endif

// new contracts should be added above this line

#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
Expand Down Expand Up @@ -368,6 +378,9 @@ constexpr struct ContractDescription
{"QTF", 199, 10000, sizeof(QTF::StateData)}, // proposal in epoch 197, IPO in 198, construction and first use in 199
{"QDUEL", 199, 10000, sizeof(QDUEL::StateData)}, // proposal in epoch 197, IPO in 198, construction and first use in 199
{"PULSE", 204, 10000, sizeof(PULSE::StateData)}, // proposal in epoch 202, IPO in 203, construction and first use in 204
#ifndef NO_VOTTUN
{"VOTTUN", 206, 10000, sizeof(VOTTUNBRIDGE::StateData)}, // proposal in epoch 204, IPO in 205, construction and first use in 206
#endif
// new contracts should be added above this line
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
{"TESTEXA", 138, 10000, sizeof(TESTEXA::StateData)},
Expand Down Expand Up @@ -488,6 +501,9 @@ static void initializeContracts()
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QTF);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QDUEL);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(PULSE);
#ifndef NO_VOTTUN
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(VOTTUNBRIDGE);
#endif
// new contracts should be added above this line
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(TESTEXA);
Expand Down
Loading
Loading