Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly update computer digest when state of contract 0 is changed #84

Merged
merged 2 commits into from
Apr 4, 2024
Merged
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
13 changes: 9 additions & 4 deletions src/qubic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,13 @@ static void requestProcessor(void* ProcedureArgument)
}
}

// Return reference to fee reserve of contract for changing its value (data stored in state of contract 0)
static long long & contractFeeReserve(unsigned int contractIndex)
{
contractStateChangeFlags[0] |= 1ULL;
return ((Contract0State*)contractStates[0])->contractFeeReserves[contractIndex];
}

static void __beginFunctionOrProcedure(const unsigned int functionOrProcedureId)
{
// TODO
Expand Down Expand Up @@ -1473,8 +1480,7 @@ static long long __burn(long long amount)

if (decreaseEnergy(index, amount))
{
Contract0State* contract0State = (Contract0State*)contractStates[0];
contract0State->contractFeeReserves[executedContractIndex] += amount;
contractFeeReserve(executedContractIndex) += amount;

const Burning burning = { currentContract , amount };
logBurning(burning);
Expand Down Expand Up @@ -2743,7 +2749,6 @@ static void endEpoch()
getUniverseDigest(etalonTick.prevUniverseDigest);
getComputerDigest(etalonTick.prevComputerDigest);

Contract0State* contract0State = (Contract0State*)contractStates[0];
for (unsigned int contractIndex = 1; contractIndex < sizeof(contractDescriptions) / sizeof(contractDescriptions[0]); contractIndex++)
{
if (system.epoch < contractDescriptions[contractIndex].constructionEpoch)
Expand Down Expand Up @@ -2794,7 +2799,7 @@ static void endEpoch()
logQuTransfer(quTransfer);
}

contract0State->contractFeeReserves[contractIndex] = finalPrice * NUMBER_OF_COMPUTORS;
contractFeeReserve(contractIndex) = finalPrice * NUMBER_OF_COMPUTORS;
}
}

Expand Down
Loading