Skip to content

Commit

Permalink
Merge pull request #276 from qubic/develop (Release v1.232.0)
Browse files Browse the repository at this point in the history
Release v1.232.0
  • Loading branch information
Franziska-Mueller authored Jan 14, 2025
2 parents 34a07dc + 04a320f commit cb93786
Show file tree
Hide file tree
Showing 25 changed files with 2,853 additions and 238 deletions.
1 change: 1 addition & 0 deletions src/Qubic.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<ClInclude Include="assets\net_msg_impl.h" />
<ClInclude Include="common_buffers.h" />
<ClInclude Include="contracts\ComputorControlledFund.h" />
<ClInclude Include="contracts\Qearn_old.h" />
<ClInclude Include="contracts\SupplyWatcher.h" />
<ClInclude Include="contracts\EmptyTemplate.h" />
<ClInclude Include="contracts\GeneralQuorumProposal.h" />
Expand Down
5 changes: 4 additions & 1 deletion src/Qubic.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
<Filter>contracts</Filter>
</ClInclude>
<ClInclude Include="contracts\QVAULT.h">
<Filter>contracts</Filter>
<Filter>contracts</Filter>
</ClInclude>
<ClInclude Include="contract_core\contract_def.h">
<Filter>contract_core</Filter>
Expand Down Expand Up @@ -211,6 +211,9 @@
<ClInclude Include="platform\global_var.h">
<Filter>platform</Filter>
</ClInclude>
<ClInclude Include="contracts\Qearn_old.h">
<Filter>contracts</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="platform">
Expand Down
24 changes: 12 additions & 12 deletions src/assets/assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

// TODO: move this into AssetStorage class
GLOBAL_VAR_DECL volatile char universeLock GLOBAL_VAR_INIT(0);
GLOBAL_VAR_DECL Asset* assets GLOBAL_VAR_INIT(nullptr);
GLOBAL_VAR_DECL AssetRecord* assets GLOBAL_VAR_INIT(nullptr);
GLOBAL_VAR_DECL m256i* assetDigests GLOBAL_VAR_INIT(nullptr);
static constexpr unsigned long long assetDigestsSizeInBytes = (ASSETS_CAPACITY * 2 - 1) * 32ULL;
GLOBAL_VAR_DECL unsigned long long* assetChangeFlags GLOBAL_VAR_INIT(nullptr);
Expand Down Expand Up @@ -159,7 +159,7 @@ static unsigned int issuanceIndex(const m256i& issuer, unsigned long long assetN

static bool initAssets()
{
if (!allocatePool(ASSETS_CAPACITY * sizeof(Asset), (void**)&assets)
if (!allocatePool(ASSETS_CAPACITY * sizeof(AssetRecord), (void**)&assets)
|| !allocatePool(assetDigestsSizeInBytes, (void**)&assetDigests)
|| !allocatePool(ASSETS_CAPACITY / 8, (void**)&assetChangeFlags))
{
Expand Down Expand Up @@ -276,7 +276,7 @@ static long long issueAsset(const m256i& issuerPublicKey, const char name[7], ch
}

static sint64 numberOfShares(
const AssetIssuanceId& issuanceId,
const Asset& issuanceId,
const AssetOwnershipSelect& ownership = AssetOwnershipSelect::any(),
const AssetPossessionSelect& possession = AssetPossessionSelect::any())
{
Expand Down Expand Up @@ -505,7 +505,7 @@ static void getUniverseDigest(m256i& digest)
{
if (assetChangeFlags[digestIndex >> 6] & (1ULL << (digestIndex & 63)))
{
KangarooTwelve(&assets[digestIndex], sizeof(Asset), &assetDigests[digestIndex], 32);
KangarooTwelve(&assets[digestIndex], sizeof(AssetRecord), &assetDigests[digestIndex], 32);
}
}
unsigned int previousLevelBeginning = 0;
Expand Down Expand Up @@ -538,10 +538,10 @@ static bool saveUniverse(const CHAR16* fileName = UNIVERSE_FILE_NAME, const CHAR
const unsigned long long beginningTick = __rdtsc();

ACQUIRE(universeLock);
long long savedSize = save(fileName, ASSETS_CAPACITY * sizeof(Asset), (unsigned char*)assets, directory);
long long savedSize = save(fileName, ASSETS_CAPACITY * sizeof(AssetRecord), (unsigned char*)assets, directory);
RELEASE(universeLock);

if (savedSize == ASSETS_CAPACITY * sizeof(Asset))
if (savedSize == ASSETS_CAPACITY * sizeof(AssetRecord))
{
setNumber(message, savedSize, TRUE);
appendText(message, L" bytes of the universe data are saved (");
Expand All @@ -555,8 +555,8 @@ static bool saveUniverse(const CHAR16* fileName = UNIVERSE_FILE_NAME, const CHAR

static bool loadUniverse(const CHAR16* fileName = UNIVERSE_FILE_NAME, CHAR16* directory = NULL)
{
long long loadedSize = load(fileName, ASSETS_CAPACITY * sizeof(Asset), (unsigned char*)assets, directory);
if (loadedSize != ASSETS_CAPACITY * sizeof(Asset))
long long loadedSize = load(fileName, ASSETS_CAPACITY * sizeof(AssetRecord), (unsigned char*)assets, directory);
if (loadedSize != ASSETS_CAPACITY * sizeof(AssetRecord))
{
logStatusToConsole(L"EFI_FILE_PROTOCOL.Read() reads invalid number of bytes", loadedSize, __LINE__);

Expand All @@ -571,8 +571,8 @@ static void assetsEndEpoch()
ACQUIRE(universeLock);

// rebuild asset hash map, getting rid of all elements with zero shares
Asset* reorgAssets = (Asset*)reorgBuffer;
setMem(reorgAssets, ASSETS_CAPACITY * sizeof(Asset), 0);
AssetRecord* reorgAssets = (AssetRecord*)reorgBuffer;
setMem(reorgAssets, ASSETS_CAPACITY * sizeof(AssetRecord), 0);
for (unsigned int i = 0; i < ASSETS_CAPACITY; i++)
{
if (assets[i].varStruct.possession.type == POSSESSION
Expand All @@ -591,7 +591,7 @@ static void assetsEndEpoch()
{
if (reorgAssets[issuanceIndex].varStruct.issuance.type == EMPTY)
{
copyMem(&reorgAssets[issuanceIndex], &assets[oldIssuanceIndex], sizeof(Asset));
copyMem(&reorgAssets[issuanceIndex], &assets[oldIssuanceIndex], sizeof(AssetRecord));
}

const m256i& ownerPublicKey = assets[oldOwnershipIndex].varStruct.ownership.publicKey;
Expand Down Expand Up @@ -651,7 +651,7 @@ static void assetsEndEpoch()
}
}
}
copyMem(assets, reorgAssets, ASSETS_CAPACITY * sizeof(Asset));
copyMem(assets, reorgAssets, ASSETS_CAPACITY * sizeof(AssetRecord));

setMem(assetChangeFlags, ASSETS_CAPACITY / 8, 0xFF);

Expand Down
12 changes: 6 additions & 6 deletions src/assets/net_msg_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static void processRequestIssuedAssets(Peer* peer, RequestResponseHeader* header
if (assets[universeIndex].varStruct.issuance.type == ISSUANCE
&& assets[universeIndex].varStruct.issuance.publicKey == request->publicKey)
{
bs->CopyMem(&response.asset, &assets[universeIndex], sizeof(Asset));
bs->CopyMem(&response.asset, &assets[universeIndex], sizeof(AssetRecord));
response.tick = system.tick;
response.universeIndex = universeIndex;
getSiblings<ASSETS_DEPTH>(response.universeIndex, assetDigests, response.siblings);
Expand Down Expand Up @@ -62,8 +62,8 @@ static void processRequestOwnedAssets(Peer* peer, RequestResponseHeader* header)
if (assets[universeIndex].varStruct.issuance.type == OWNERSHIP
&& assets[universeIndex].varStruct.issuance.publicKey == request->publicKey)
{
bs->CopyMem(&response.asset, &assets[universeIndex], sizeof(Asset));
bs->CopyMem(&response.issuanceAsset, &assets[assets[universeIndex].varStruct.ownership.issuanceIndex], sizeof(Asset));
bs->CopyMem(&response.asset, &assets[universeIndex], sizeof(AssetRecord));
bs->CopyMem(&response.issuanceAsset, &assets[assets[universeIndex].varStruct.ownership.issuanceIndex], sizeof(AssetRecord));
response.tick = system.tick;
response.universeIndex = universeIndex;
getSiblings<ASSETS_DEPTH>(response.universeIndex, assetDigests, response.siblings);
Expand Down Expand Up @@ -100,9 +100,9 @@ static void processRequestPossessedAssets(Peer* peer, RequestResponseHeader* hea
if (assets[universeIndex].varStruct.issuance.type == POSSESSION
&& assets[universeIndex].varStruct.issuance.publicKey == request->publicKey)
{
bs->CopyMem(&response.asset, &assets[universeIndex], sizeof(Asset));
bs->CopyMem(&response.ownershipAsset, &assets[assets[universeIndex].varStruct.possession.ownershipIndex], sizeof(Asset));
bs->CopyMem(&response.issuanceAsset, &assets[assets[assets[universeIndex].varStruct.possession.ownershipIndex].varStruct.ownership.issuanceIndex], sizeof(Asset));
bs->CopyMem(&response.asset, &assets[universeIndex], sizeof(AssetRecord));
bs->CopyMem(&response.ownershipAsset, &assets[assets[universeIndex].varStruct.possession.ownershipIndex], sizeof(AssetRecord));
bs->CopyMem(&response.issuanceAsset, &assets[assets[assets[universeIndex].varStruct.possession.ownershipIndex].varStruct.ownership.issuanceIndex], sizeof(AssetRecord));
response.tick = system.tick;
response.universeIndex = universeIndex;
getSiblings<ASSETS_DEPTH>(response.universeIndex, assetDigests, response.siblings);
Expand Down
2 changes: 1 addition & 1 deletion src/common_buffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


constexpr unsigned long long spectrumSizeInBytes = SPECTRUM_CAPACITY * sizeof(::Entity);
constexpr unsigned long long universeSizeInBytes = ASSETS_CAPACITY * sizeof(Asset);
constexpr unsigned long long universeSizeInBytes = ASSETS_CAPACITY * sizeof(AssetRecord);

// Buffer used for reorganizing spectrum and universe hash maps, currently also used as scratchpad buffer for contracts
// Must be large enough to fit any contract, full spectrum, and full universe!
Expand Down
4 changes: 4 additions & 0 deletions src/contract_core/contract_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ struct __FunctionOrProcedureBeginEndGuard
#define CONTRACT_INDEX QEARN_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE QEARN
#define CONTRACT_STATE2_TYPE QEARN2
#ifdef QEARN_UPDATE
#include "contracts/Qearn.h"
#else
#include "contracts/Qearn_old.h"
#endif

#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
Expand Down
6 changes: 3 additions & 3 deletions src/contract_core/qpi_asset_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


// Start iteration with given issuance and given ownership filter (selects first record).
void QPI::AssetOwnershipIterator::begin(const QPI::AssetIssuanceId& issuance, const QPI::AssetOwnershipSelect& ownership)
void QPI::AssetOwnershipIterator::begin(const QPI::Asset& issuance, const QPI::AssetOwnershipSelect& ownership)
{
_issuance = issuance;
_issuanceIdx = ::issuanceIndex(issuance.issuer, issuance.assetName);
Expand Down Expand Up @@ -125,7 +125,7 @@ sint64 QPI::AssetOwnershipIterator::numberOfOwnedShares() const


// Start iteration with given issuance and given ownership + possession filters (selects first record).
void QPI::AssetPossessionIterator::begin(const AssetIssuanceId& issuance, const AssetOwnershipSelect& ownership, const AssetPossessionSelect& possession)
void QPI::AssetPossessionIterator::begin(const Asset& issuance, const AssetOwnershipSelect& ownership, const AssetPossessionSelect& possession)
{
AssetOwnershipIterator::begin(issuance, ownership);

Expand Down Expand Up @@ -433,7 +433,7 @@ long long QPI::QpiContextFunctionCall::numberOfPossessedShares(unsigned long lon
return ::numberOfPossessedShares(assetName, issuer, owner, possessor, ownershipManagingContractIndex, possessionManagingContractIndex);
}

sint64 QPI::QpiContextFunctionCall::numberOfShares(const QPI::AssetIssuanceId& issuanceId, const QPI::AssetOwnershipSelect& ownership, const QPI::AssetPossessionSelect& possession) const
sint64 QPI::QpiContextFunctionCall::numberOfShares(const QPI::Asset& issuanceId, const QPI::AssetOwnershipSelect& ownership, const QPI::AssetPossessionSelect& possession) const
{
return ::numberOfShares(issuanceId, ownership, possession);
}
Expand Down
Loading

0 comments on commit cb93786

Please sign in to comment.