Skip to content

Commit a2c8bee

Browse files
Merge branch 'qubic:main' into feature/qutil
2 parents bf4b800 + 130a393 commit a2c8bee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+9229
-536
lines changed

.github/workflows/contract-verify.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ jobs:
3232
# Checkout repo to use files of the repo as input for container action
3333
- name: Checkout
3434
uses: actions/checkout@v4
35+
with:
36+
submodules: 'true'
3537
- name: Find all contract files to verify
3638
id: filepaths
3739
run: |
38-
files=$(find src/contracts/ -maxdepth 1 -type f -name "*.h" ! -name "*QUtil*" ! -name "*TestExample*" ! -name "*math_lib*" ! -name "*qpi*" -printf "%p\n" | paste -sd, -)
40+
files=$(find src/contracts/ -maxdepth 1 -type f -name "*.h" ! -name "*TestExample*" ! -name "*math_lib*" ! -name "*qpi*" -printf "%p\n" | paste -sd, -)
3941
echo "contract-filepaths=$files" >> "$GITHUB_OUTPUT"
4042
- name: Contract verify action step
4143
id: verify
42-
uses: Franziska-Mueller/qubic-contract-verify@v1.0.5
44+
uses: Franziska-Mueller/qubic-contract-verify@main
4345
with:
4446
filepaths: '${{ steps.filepaths.outputs.contract-filepaths }}'

doc/contracts.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,9 @@ The following container types are available in the QPI:
498498
Lookup by key, insert, and remove run in approximately constant time if population is less than 80% of `L`.
499499
- `HashSet<KeyT, L>`: Hash set of keys of type `KeyT` and total capacity `L`.
500500
Lookup by key, insert, and remove run in approximately constant time if population is less than 80% of `L`.
501+
- `LinkedList<T, L>`: Doubly-linked list of elements of type `T` with fixed capacity `L` (`L` must be 2^N).
502+
Provides O(1) insertion at head/tail, O(1) insertion before/after a given index, O(1) removal by index, and bidirectional traversal.
503+
Removed nodes are immediately recycled via a free list (no deferred cleanup needed).
501504

502505
Please note that removing items from `Collection`, `HashMap`, and `HashSet` does not immediately free the hash map slots used for the removed items.
503506
This may negatively impact the lookup speed, which depends on the maximum population seen since the last cleanup.
@@ -613,7 +616,7 @@ Global constants, structs and classes must begin with the name of the contract s
613616
There is a limit for recursion and depth of nested contract function / procedure calls (the limit is 10 at the moment).
614617

615618
The input and output structs of contract user procedures and functions may only use integer and boolean types (such as `uint64`, `sint8`, `bit`) as well as `id`, `Array`, and `BitArray`, and struct types containing only allowed types.
616-
Complex types that may have an inconsistent internal state, such as `Collection`, are forbidden in the public interface of a contract.
619+
Complex types that may have an inconsistent internal state, such as `Collection` and `LinkedList`, are forbidden in the public interface of a contract.
617620

618621

619622
## General Change Management

doc/protocol.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ The following transaction types (`tx->inputType`) are defined:
2626
- `FileTrailerTransaction`, type 5, defined in `src/files/files.h`.
2727
- `OracleReplyCommitTransactionPrefix`, type 6, defined in `src/oracle_core/oracle_transactions.h`.
2828
- `OracleReplyRevealTransactionPrefix`, type 7, defined in `src/oracle_core/oracle_transactions.h`.
29-
- `CustomMiningSolutionTransaction`, type 8, defined in `src/mining/mining.h`.
29+
- `CustomMiningSolutionTransaction`, type 8, defined in `src/mining/mining.h`. (will be reclaimed if XMR is removed)
3030
- `ExecutionFeeReportTransactionPrefix`, type 9, defined in `src/network_messages/execution_fees.h`.
3131
- `OracleUserQueryTransactionPrefix`, type 10, defined in `src/oracle_core/oracle_transactions.h`.
32+
- `DogeMiningShareTransaction`, type 11, defined in `src/mining/mining.h`.
3233

3334

3435
## Peer Sharing

src/Qubic.vcxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@
4646
<ClInclude Include="contracts\QRaffle.h" />
4747
<ClInclude Include="contracts\QBond.h" />
4848
<ClInclude Include="contracts\QIP.h" />
49+
<ClInclude Include="contracts\Qusino.h" />
4950
<ClInclude Include="contracts\QReservePool.h" />
5051
<ClInclude Include="contracts\QThirtyFour.h" />
5152
<ClInclude Include="contracts\Pulse.h" />
53+
<ClInclude Include="contracts\Escrow.h" />
5254
<ClInclude Include="contracts\TestExampleA.h" />
5355
<ClInclude Include="contracts\TestExampleB.h" />
5456
<ClInclude Include="contracts\TestExampleC.h" />
@@ -67,13 +69,15 @@
6769
<ClInclude Include="contract_core\qpi_spectrum_impl.h" />
6870
<ClInclude Include="contract_core\qpi_system_impl.h" />
6971
<ClInclude Include="contract_core\qpi_hash_map_impl.h" />
72+
<ClInclude Include="contract_core\qpi_linked_list_impl.h" />
7073
<ClInclude Include="contract_core\qpi_ticking_impl.h" />
7174
<ClInclude Include="contract_core\qpi_trivial_impl.h" />
7275
<ClInclude Include="contract_core\stack_buffer.h" />
7376
<ClInclude Include="contract_core\qpi_proposal_voting.h" />
7477
<ClInclude Include="files\files.h" />
7578
<ClInclude Include="logging\logging.h" />
7679
<ClInclude Include="logging\net_msg_impl.h" />
80+
<ClInclude Include="mining\custom_qubic_mining_storage.h" />
7781
<ClInclude Include="mining\mining.h" />
7882
<ClInclude Include="mining\score_addition.h" />
7983
<ClInclude Include="mining\score_common.h" />
@@ -106,6 +110,7 @@
106110
<ClInclude Include="oracle_core\oracle_interfaces_def.h" />
107111
<ClInclude Include="oracle_core\oracle_transactions.h" />
108112
<ClInclude Include="oracle_core\snapshot_files.h" />
113+
<ClInclude Include="oracle_interfaces\DogeShareValidation.h" />
109114
<ClInclude Include="oracle_interfaces\Mock.h" />
110115
<ClInclude Include="oracle_interfaces\Price.h" />
111116
<ClInclude Include="platform\assert.h" />

src/Qubic.vcxproj.filters

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,12 @@
132132
<ClInclude Include="contracts\QIP.h">
133133
<Filter>contracts</Filter>
134134
</ClInclude>
135+
<ClInclude Include="contracts\Qusino.h">
136+
<Filter>contracts</Filter>
137+
</ClInclude>
138+
<ClInclude Include="contracts\Escrow.h">
139+
<Filter>contracts</Filter>
140+
</ClInclude>
135141
<ClInclude Include="contract_core\contract_def.h">
136142
<Filter>contract_core</Filter>
137143
</ClInclude>
@@ -206,6 +212,9 @@
206212
<ClInclude Include="contract_core\qpi_hash_map_impl.h">
207213
<Filter>contract_core</Filter>
208214
</ClInclude>
215+
<ClInclude Include="contract_core\qpi_linked_list_impl.h">
216+
<Filter>contract_core</Filter>
217+
</ClInclude>
209218
<ClInclude Include="contract_core\qpi_asset_impl.h">
210219
<Filter>contract_core</Filter>
211220
</ClInclude>
@@ -365,6 +374,12 @@
365374
<ClInclude Include="oracle_core\snapshot_files.h">
366375
<Filter>oracle_core</Filter>
367376
</ClInclude>
377+
<ClInclude Include="oracle_interfaces\DogeShareValidation.h">
378+
<Filter>oracle_interfaces</Filter>
379+
</ClInclude>
380+
<ClInclude Include="mining\custom_qubic_mining_storage.h">
381+
<Filter>mining</Filter>
382+
</ClInclude>
368383
</ItemGroup>
369384
<ItemGroup>
370385
<Filter Include="platform">
@@ -415,4 +430,4 @@
415430
<Filter>platform</Filter>
416431
</MASM>
417432
</ItemGroup>
418-
</Project>
433+
</Project>

src/common_buffers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CommonBuffers
4343
// memory layout of buffer: sub buffer pointers | sub buffer locks | sub buffer 1 | sub buffer 2 | ...
4444
unsigned char* buffer = nullptr;
4545
const unsigned long long ptrSize = count * sizeof(unsigned char*);
46-
const unsigned long long lockSize = (count + 7) / 8;
46+
const unsigned long long lockSize = count * sizeof(subBufferLock[0]);
4747
const unsigned long long bufSize = count * size;
4848

4949
if (!allocPoolWithErrorLog(L"commonBuffers", ptrSize + lockSize + bufSize, (void**)&buffer, __LINE__))

src/contract_core/contract_def.h

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,6 @@
254254
#define CONTRACT_STATE2_TYPE PULSE2
255255
#include "contracts/Pulse.h"
256256

257-
#ifndef NO_VOTTUN
258-
259257
#undef CONTRACT_INDEX
260258
#undef CONTRACT_STATE_TYPE
261259
#undef CONTRACT_STATE2_TYPE
@@ -266,6 +264,27 @@
266264
#define CONTRACT_STATE2_TYPE VOTTUNBRIDGE2
267265
#include "contracts/VottunBridge.h"
268266

267+
#undef CONTRACT_INDEX
268+
#undef CONTRACT_STATE_TYPE
269+
#undef CONTRACT_STATE2_TYPE
270+
271+
#define QUSINO_CONTRACT_INDEX 26
272+
#define CONTRACT_INDEX QUSINO_CONTRACT_INDEX
273+
#define CONTRACT_STATE_TYPE QUSINO
274+
#define CONTRACT_STATE2_TYPE QUSINO2
275+
#include "contracts/Qusino.h"
276+
277+
#ifndef NO_ESCROW
278+
#undef CONTRACT_INDEX
279+
#undef CONTRACT_STATE_TYPE
280+
#undef CONTRACT_STATE2_TYPE
281+
282+
#define ESCROW_CONTRACT_INDEX 27
283+
#define CONTRACT_INDEX ESCROW_CONTRACT_INDEX
284+
#define CONTRACT_STATE_TYPE ESCROW
285+
#define CONTRACT_STATE2_TYPE ESCROW2
286+
#include "contracts/Escrow.h"
287+
269288
#endif
270289

271290
// new contracts should be added above this line
@@ -327,6 +346,7 @@ constexpr unsigned short TESTEXD_CONTRACT_INDEX = (CONTRACT_INDEX + 1);
327346
#include "qpi_collection_impl.h"
328347
#include "qpi_trivial_impl.h"
329348
#include "qpi_hash_map_impl.h"
349+
#include "qpi_linked_list_impl.h"
330350

331351
#include "platform/global_var.h"
332352

@@ -356,7 +376,7 @@ constexpr struct ContractDescription
356376
{"", 0, 0, sizeof(Contract0State)},
357377
{"QX", 66, 10000, sizeof(QX::StateData)},
358378
{"QTRY", 72, 10000, sizeof(QUOTTERY::StateData)},
359-
{"RANDOM", 88, 10000, sizeof(IPO)},
379+
{"RANDOM", 88, 10000, sizeof(RANDOM::StateData)},
360380
{"QUTIL", 99, 10000, sizeof(QUTIL::StateData)},
361381
{"MLM", 112, 10000, sizeof(IPO)},
362382
{"GQMPROP", 123, 10000, sizeof(GQMPROP::StateData)},
@@ -378,8 +398,10 @@ constexpr struct ContractDescription
378398
{"QTF", 199, 10000, sizeof(QTF::StateData)}, // proposal in epoch 197, IPO in 198, construction and first use in 199
379399
{"QDUEL", 199, 10000, sizeof(QDUEL::StateData)}, // proposal in epoch 197, IPO in 198, construction and first use in 199
380400
{"PULSE", 204, 10000, sizeof(PULSE::StateData)}, // proposal in epoch 202, IPO in 203, construction and first use in 204
381-
#ifndef NO_VOTTUN
382401
{"VOTTUN", 206, 10000, sizeof(VOTTUNBRIDGE::StateData)}, // proposal in epoch 204, IPO in 205, construction and first use in 206
402+
{"QUSINO", 208, 10000, sizeof(QUSINO::StateData)}, // proposal in epoch 206, IPO in 207, construction and first use in 208
403+
#ifndef NO_ESCROW
404+
{"ESCROW", 210, 10000, sizeof(ESCROW::StateData)}, // proposal in epoch 208, IPO in 209, construction and first use in 210
383405
#endif
384406
// new contracts should be added above this line
385407
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
@@ -501,8 +523,10 @@ static void initializeContracts()
501523
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QTF);
502524
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QDUEL);
503525
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(PULSE);
504-
#ifndef NO_VOTTUN
505526
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(VOTTUNBRIDGE);
527+
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QUSINO);
528+
#ifndef NO_ESCROW
529+
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(ESCROW);
506530
#endif
507531
// new contracts should be added above this line
508532
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
@@ -513,6 +537,15 @@ static void initializeContracts()
513537
#endif
514538
}
515539

540+
// Automatic Contract Padding
541+
// Contracts whose state struct grew this epoch. Update this list each epoch as needed.
542+
// When enabling, replace both lines below, e.g.:
543+
// constexpr unsigned int paddableContracts[] = { RANDOM_CONTRACT_INDEX };
544+
// constexpr unsigned int paddableCount = sizeof(paddableContracts) / sizeof(paddableContracts[0]);
545+
constexpr const unsigned int* paddableContracts = nullptr;
546+
constexpr unsigned int paddableCount = 0;
547+
548+
516549
// Class for registering and looking up user procedures independently of input type, for example for notifications
517550
class UserProcedureRegistry
518551
{

src/contract_core/qpi_collection_impl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,10 @@ namespace QPI
621621
return;
622622
}
623623

624-
// Init buffers
625-
__ScopedScratchpad scratchpad(sizeof(_povs) + sizeof(_povOccupationFlags), /*initZero=*/true);
624+
// Init buffers. Besides the rebuilt pov tables we also need traversal stack
625+
// space for walking a pov's BST while updating element.povIndex.
626+
const uint64 stackBytes = _population * sizeof(sint64);
627+
__ScopedScratchpad scratchpad(sizeof(_povs) + sizeof(_povOccupationFlags) + stackBytes, /*initZero=*/true);
626628
ASSERT(scratchpad.ptr);
627629
auto* _povsBuffer = reinterpret_cast<PoV*>(scratchpad.ptr);
628630
auto* _povOccupationFlagsBuffer = reinterpret_cast<uint64*>(_povsBuffer + L);

src/contract_core/qpi_hash_map_impl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
#pragma once
77

8+
#include "pre_qpi_def.h"
9+
#include "../common_buffers.h"
810
#include "../contracts/qpi.h"
911
#include "../platform/memory.h"
1012
#include "../kangaroo_twelve.h"

0 commit comments

Comments
 (0)