Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
51c0dde
Merge pull request #472 from qubic/develop (Release v1.250.0)
Franziska-Mueller Jul 8, 2025
1854d5e
Merge pull request #478 from qubic/develop (Release v1.251.0)
Franziska-Mueller Jul 16, 2025
cb553eb
log message when initializing SC state at construction
Franziska-Mueller Jul 22, 2025
6d2af78
fix output in loadComputer for files where load() failed
Franziska-Mueller Jul 22, 2025
572786c
Merge pull request #481 from qubic/develop (Release v1.252.0)
Franziska-Mueller Jul 23, 2025
3f076ee
NOST: Return the amount for user who invest in non-investment period …
small-debug Jul 24, 2025
a0c174e
NOST: Checking valid time to create the fundraising (#484)
small-debug Jul 24, 2025
7c75362
update params for epoch 172 / v1.253.0
Franziska-Mueller Jul 28, 2025
6fcdd63
Revert "add NO_NOST toggle"
Franziska-Mueller Jul 29, 2025
101e43b
fix bug due to change nost contract index 13 ~ 14 (#486)
small-debug Jul 29, 2025
052683b
qutil: add an delay func
krypdkat Jul 19, 2025
486c5fa
increase target tick duration to 3s
Franziska-Mueller Jul 30, 2025
2a7fc34
Remove never called piece of code.
cyber-pc Jul 29, 2025
6f4c959
Merge checkAndSwitchMiningPhase with customMiningPhase.
cyber-pc Jul 29, 2025
5edd494
Handle begin/end of epoch in checkAndSwitchMining function.
cyber-pc Jul 29, 2025
7845e57
group all QUtil state vars together, fix linker error in test project
Franziska-Mueller Jul 30, 2025
881b31e
Merge pull request #488 from qubic/develop (Release v1.253.0)
Franziska-Mueller Jul 30, 2025
778c1e7
Adjust TARGET_TICK_DURATION (#490)
fnordspace Jul 31, 2025
f1ec559
Add VottunBridge smart contract for cross-chain bridge functionality
sergimima Aug 1, 2025
7f25278
Support multiple events for custom mining.
cyber-pc Aug 2, 2025
368207f
Compilation fixes
sergimima Aug 3, 2025
23b84b7
Merge branch 'develop' of https://github.com/qubic/core into feature/…
sergimima Aug 3, 2025
faf3f0c
Fixed compilation errors
sergimima Aug 3, 2025
a550856
Update VottunBridge.h
sergimima Aug 4, 2025
ec72605
Compilation working
sergimima Aug 4, 2025
fdfb3a9
Add save/load for custom mining v2.
cyber-pc Aug 4, 2025
a2867eb
Add more comments and remove redundant log.
cyber-pc Aug 5, 2025
a3b83d1
score df: fix a bug
krypdkat Aug 5, 2025
3f18f35
Merge pull request #494 from qubic/feature/2025-08-02-multiple-event-…
Franziska-Mueller Aug 5, 2025
aec6a3c
update params for epoch 173 / v1.254.0
Franziska-Mueller Aug 5, 2025
1598a3d
Merge pull request #498 from qubic/develop (Release v1.254.0)
Franziska-Mueller Aug 6, 2025
89a033b
feat: Add VottunBridge smart contract with comprehensive test suite
sergimima Aug 6, 2025
33da56d
Merge branch 'develop' of https://github.com/qubic/core into feature/…
sergimima Aug 6, 2025
9fe06c5
Merge remote-tracking branch 'origin/feature/2025-08-01-VottunBridge'…
sergimima Aug 6, 2025
e14cbbc
Don't pay dividend of 0 if entity has 0 shares (#487)
philippwerner Aug 7, 2025
3d8163e
Prevent calling BEGIN_EPOCH again after network restart during epoch …
philippwerner Aug 11, 2025
b8f455f
update params for epoch 174 / v1.255.0
Franziska-Mueller Aug 11, 2025
ec52ea0
Address reviewer feedback: clean up comments, optimize functions, fix…
sergimima Aug 11, 2025
9950477
Address additional reviewer feedback: optimize getAdminID function an…
sergimima Aug 12, 2025
7ebe482
extMining: update compId struct
krypdkat Aug 12, 2025
00c4922
dfFunc: increase duration
krypdkat Aug 12, 2025
5e43d99
extMining: keep legacy version
krypdkat Aug 12, 2025
4ba3797
revert df change
krypdkat Aug 13, 2025
f918aa3
Fix isManager function: use WITH_LOCALS for loop variable
sergimima Aug 13, 2025
f3a8873
adapt initial tick so it falls inside external mining window
Franziska-Mueller Aug 13, 2025
33dc1fa
Merge pull request #505 from qubic/develop (Release v1.255.0)
Franziska-Mueller Aug 13, 2025
011ff41
Fix VottunBridge refund security vulnerability KS-VB-F-01
sergimima Aug 13, 2025
fb26f19
Fix code style formatting for security tests
sergimima Aug 14, 2025
50be31a
Fix VottunBridge code style and PR review issues
sergimima Aug 14, 2025
cb1cf45
score test: remove duplicate definition NUMBER_OF_TRANSACTIONS_PER_TI…
Franziska-Mueller Aug 14, 2025
38ff41c
fix(QSwap): Spelling error, liqudity -> liquidity (#502)
ozsefw Aug 14, 2025
e134ccc
Removed coment
sergimima Aug 14, 2025
5e8253f
Recovering the qearn data in epoch172 (#509)
TakaYuPP Aug 19, 2025
c1821aa
update params for epoch 175 / v1.256.0
Franziska-Mueller Aug 19, 2025
b40cf4c
Merge pull request #511 from qubic/develop (Release v1.256.0)
Franziska-Mueller Aug 20, 2025
ee39270
Verify SC files automatically (#506)
Franziska-Mueller Aug 20, 2025
1b2df12
contributing doc: add paragraph about curly braces style
Franziska-Mueller Aug 20, 2025
ea479e0
update contract guidelines (#512)
Franziska-Mueller Aug 22, 2025
618daf6
update contract guidelines (#512)
Franziska-Mueller Aug 22, 2025
563b014
remove unused defines that clash with QPI definitions
Franziska-Mueller Aug 22, 2025
6dade49
fix: fixed gtest bug in qearn (#516)
TakaYuPP Aug 23, 2025
0f703fb
update contract verify tool to v0.3.3-beta
Franziska-Mueller Aug 26, 2025
82d37bf
Fix incorrect vc optimization of FourQ for release mode. (#517)
cyber-pc Aug 26, 2025
e13ac4c
networking: support private IPs (#513)
krypdkat Aug 26, 2025
e220819
Fix bug relate to invalid mining seed of qpi mining. (#518)
cyber-pc Aug 26, 2025
5b34b01
update params for epoch 176 / v1.257.0
fnordspace Aug 26, 2025
e9aaf1d
Remove mining seed set function in qpi.
cyber-pc Aug 26, 2025
0499e91
Increase target tick duration
fnordspace Aug 27, 2025
e04a75b
Merge pull request #520 from qubic/develop
fnordspace Aug 27, 2025
73e3ba2
Fix bug in PRIVATE_PEER_IP logic
fnordspace Aug 27, 2025
d79b6c3
Merge pull request #519 from qubic/feature/2025-08-26-improve-init-mi…
cyber-pc Aug 27, 2025
7089a6f
last fix
sergimima Aug 27, 2025
619cbd5
Merge branch 'develop' of https://github.com/qubic/core into feature/…
sergimima Aug 27, 2025
f4cba86
Fixed order in createOrder_input
sergimima Aug 27, 2025
3773a95
Merge upstream changes
sergimima Aug 27, 2025
ff501e8
Merge pull request #521 from qubic/feature/2025-08-26-fix-private-pee…
cyber-pc Aug 27, 2025
1fd3a79
Merge remote-tracking branch 'origin/main' into develop
cyber-pc Aug 27, 2025
2a94576
update params for epoch 176 / v1.257.1
cyber-pc Aug 27, 2025
2d673b2
Merge pull request #522 from qubic/develop
fnordspace Aug 27, 2025
8f10cb1
Add VottunBridge Smart Contract (#497)
sergimima Sep 2, 2025
5db4dd2
add NO_VBRIDGE toggle
Franziska-Mueller Sep 2, 2025
84550e6
update params for epoch 177 / v1.258.0
Franziska-Mueller Sep 2, 2025
bc20113
VBRIDGE: fix vcxproj.filters, adapt construction epoch
Franziska-Mueller Sep 2, 2025
ab525b5
Merge pull request #526 from qubic/develop (Release v1.258.0)
Franziska-Mueller Sep 3, 2025
3debd3e
Revert "VBRIDGE: fix vcxproj.filters, adapt construction epoch"
Franziska-Mueller Sep 3, 2025
be6fc10
Revert "add NO_VBRIDGE toggle"
Franziska-Mueller Sep 3, 2025
2ac59ba
Revert "Add VottunBridge Smart Contract (#497)"
Franziska-Mueller Sep 3, 2025
43aac32
use bigger data type for numberOfTickTransactions in processRequestTi…
Franziska-Mueller Sep 3, 2025
e9c8906
use wider data type in processRequestTickTransactions
Franziska-Mueller Sep 5, 2025
d8a06aa
Decrease TARGET_TICK_DURATION
fnordspace Sep 7, 2025
d61a7f5
Merge pull request #527 from fnordspace/hotfix/2025-09-05-DecreaseTar…
fnordspace Sep 7, 2025
22f831c
Merge pull request #528 from qubic/main
Franziska-Mueller Sep 9, 2025
f624a52
QDRAW (#514)
ouya99 Sep 9, 2025
3a59058
add QDRAW in VS project and contract_def.h
Franziska-Mueller Sep 9, 2025
4ad2e13
add NO_QDRAW toggle
Franziska-Mueller Sep 9, 2025
5ececb7
update params for epoch 178 / v1.259.0
Franziska-Mueller Sep 9, 2025
fda45fb
remove last 4 chars (checksum) from QDRAW owner ID
Franziska-Mueller Sep 9, 2025
390f3c4
Merge pull request #530 from qubic/develop (Release v1.259.0)
Franziska-Mueller Sep 10, 2025
506b9a0
transfer management rights logging fixed (#529)
baoLuck Sep 10, 2025
238650a
Revert "add NO_QDRAW toggle"
Franziska-Mueller Sep 10, 2025
fa7c014
change qpi ID macro to function (#531)
Franziska-Mueller Sep 10, 2025
f242bc4
add safe mul, fix overflow bug in qx
krypdkat Sep 11, 2025
a48272d
add logging for df function
krypdkat Sep 11, 2025
8f18654
add unitest
krypdkat Sep 11, 2025
3d9bc7e
add safe mul, fix overflow bug in qx
krypdkat Sep 11, 2025
98e0f12
add logging for df function
krypdkat Sep 11, 2025
9de0b71
add unitest
krypdkat Sep 11, 2025
6b562b7
Merge pull request #532 from qubic/hotfix/25-09-11-HotFixSCandLogging
fnordspace Sep 11, 2025
0c33ffe
Bump version
fnordspace Sep 11, 2025
0fa8e5c
Merge pull request #533 from qubic/hotfix/25-09-11-bumpVersion
fnordspace Sep 11, 2025
b0f7547
Ignore wrong votes for specific ticks
fnordspace Sep 11, 2025
de3860d
Merge pull request #535 from qubic/hotfix/25-09-11-ignoreWrongVotes
fnordspace Sep 11, 2025
ecc4f9a
Bump version
fnordspace Sep 11, 2025
bae660e
Merge remote-tracking branch 'origin/main' into develop
philippwerner Sep 12, 2025
948d46e
Revert "Ignore wrong votes for specific ticks"
philippwerner Sep 12, 2025
012eac4
ScoreAVX2: remove warning in loading 256 bits function.
Sep 12, 2025
463f63c
FullExternalMining: remove warning by using 32bits data type.
Sep 12, 2025
0009559
Merge pull request #540 from qubic/feature/2025-09-12-remove-warnings
philippwerner Sep 12, 2025
4a660d7
run IPO only at epoch construction - 1 (#536)
Franziska-Mueller Sep 15, 2025
e4cb919
Implement DistributeQuToShareholders() in QUTIL (#539)
philippwerner Sep 15, 2025
d638e9b
Deactivate delay function (#538)
fnordspace Sep 15, 2025
8a410de
Decouples TARGET_TICK_DURATION and tick_storage allocation (#541)
fnordspace Sep 15, 2025
f1f4af2
update params for epoch 179 / v1.260.0
Franziska-Mueller Sep 15, 2025
98cbd37
fix overflow vulnerabilities in QUtil, add safe add in QPI (#548)
Franziska-Mueller Sep 16, 2025
3803cd2
Merge pull request #550 from qubic/develop (Release v1.260.0)
Franziska-Mueller Sep 17, 2025
db76542
fix: fixed double payment for transferShareManagementRight fee (#549)
TakaYuPP Sep 17, 2025
4eb874b
feat: added the transferShareManagementRights and LOG_INFO into Qswap…
TakaYuPP Sep 22, 2025
9454c1d
Update test project to use Windows SDK version available on GitHub Bu…
cyber-pc Sep 22, 2025
fb72ae2
Update test project to use Windows SDK version available on GitHub Bu…
cyber-pc Sep 22, 2025
c15d46f
Speed up score for 1000 ticks. (#553)
cyber-pc Sep 23, 2025
d01fd10
update guidelines (#555)
Franziska-Mueller Sep 23, 2025
eadb4df
update params for epoch 180 / v1.261.0
Franziska-Mueller Sep 23, 2025
1c3f7fc
Update contract-verify to new release (#556)
Franziska-Mueller Sep 23, 2025
c54800c
Increase TICK_DUATION_FOR_ALLOCATION_MS
fnordspace Sep 23, 2025
48c869d
fix a bug in logging
krypdkat Sep 23, 2025
9f8410a
Merge pull request #557 from qubic/develop (Release v1.261.0)
Franziska-Mueller Sep 24, 2025
7a13c95
add timeout to contract-verify action
Franziska-Mueller Sep 24, 2025
f40606f
Merge pull request #558 from qubic/main
Franziska-Mueller Sep 24, 2025
5314cf1
Msvault v2.0 (#485)
icyblob Sep 29, 2025
29a5586
add MSVAULT_V1 toggle
Franziska-Mueller Sep 29, 2025
efd29c7
Random Lottery (#552)
N-010 Sep 29, 2025
f3cd543
add NO_RANDOM_LOTTERY toggle
Franziska-Mueller Sep 29, 2025
ab457cd
update params for epoch 181 / v1.262.0
Franziska-Mueller Sep 29, 2025
ec062a3
QBond smart contract (#559)
baoLuck Sep 29, 2025
cf1467f
remove unused function in QBond test
Franziska-Mueller Sep 29, 2025
10da921
fix arithmetic types warnings in RandomLottery
Franziska-Mueller Sep 29, 2025
9e0d226
add NO_QBOND toggle
Franziska-Mueller Sep 29, 2025
4b78e06
fix linker warning in RandomLottery
Franziska-Mueller Sep 29, 2025
8b9b995
Merge pull request #561 from qubic/develop (Release v1.262.0)
Franziska-Mueller Oct 1, 2025
1912339
Fix broken gtest (scratchpad) (#562)
philippwerner Oct 1, 2025
4783375
Revert "add NO_QBOND toggle"
Franziska-Mueller Oct 1, 2025
55e5325
Revert "add NO_RANDOM_LOTTERY toggle"
Franziska-Mueller Oct 1, 2025
c0b9c9f
Revert "add MSVAULT_V1 toggle"
Franziska-Mueller Oct 1, 2025
173ebe7
add final index for contract QBond
Franziska-Mueller Oct 1, 2025
2ec269d
CustomMining: remove 32bits nonce and support 64bit nonce verifier.
cyber-pc Jul 31, 2025
c097eaa
CustomMining: Rename custom mining's members.
cyber-pc Oct 1, 2025
474edb2
add two output parameters to qbond table
baoLuck Oct 5, 2025
e0104b9
Merge pull request #564 from qubic/feature/2025-09-25-64bits-nonce-cl…
philippwerner Oct 6, 2025
54268ec
Merge pull request #565 from baoLuck/feature/2025-10-06-QBond-add-out…
philippwerner Oct 6, 2025
d2cb70c
update params for epoch 182 / v1.263.0
philippwerner Oct 6, 2025
0757a1e
QUTIL General Voting: minor changes (#560)
icyblob Oct 7, 2025
2a23a1f
Merge pull request #568 from qubic/develop (Release v1.263.0)
philippwerner Oct 8, 2025
02c8713
MSVAULT - Fix releaseAssetTo (#567)
icyblob Oct 9, 2025
f727bed
RandomLottery bug fix: refund on BuyTicket failures (#569)
N-010 Oct 10, 2025
217ed47
add managingContractIndex to logging event
krypdkat Oct 12, 2025
7d28d46
reduce logging event to 1 flag
krypdkat Oct 12, 2025
3014e39
add hint message to distribute dividends
krypdkat Oct 12, 2025
9a3477e
update params for epoch 183 / v1.264.0
Franziska-Mueller Oct 13, 2025
17acc08
Merge branch 'develop' of https://github.com/qubic/core into feature/…
sergimima Oct 14, 2025
3467ad4
Merge pull request #573 from qubic/develop (Release v1.264.0)
Franziska-Mueller Oct 15, 2025
c2366be
contract-verify action: exclude math_lib, qpi and TestExample
Franziska-Mueller Oct 15, 2025
7f2047a
transaction mempool with tx prioritization (#563)
Franziska-Mueller Oct 16, 2025
8ba877c
Merge pull request #576 from qubic/main
Franziska-Mueller Oct 16, 2025
551a867
add comment for system.latestLedTick
Franziska-Mueller Oct 16, 2025
99c25d8
Fixes winnersInfoNextEmptyIndex (#575)
N-010 Oct 16, 2025
e887494
update
sergimima Oct 17, 2025
6e68794
Merge branch 'develop' of https://github.com/qubic/core into feature/…
sergimima Oct 17, 2025
fc1298f
fix for testnet
sergimima Oct 20, 2025
abf2dc5
admin addresess update
sergimima Oct 21, 2025
1152ae2
update on addresses
sergimima Oct 21, 2025
0d93ac9
update in admins
sergimima Oct 22, 2025
11e868f
update in proposals arry
sergimima Oct 22, 2025
445c237
update
sergimima Oct 22, 2025
c6b4945
epoch update
sergimima Oct 22, 2025
060d814
sc update
sergimima Oct 24, 2025
30fa31a
update in order status return
sergimima Nov 12, 2025
e3896cb
Refactor fee accumulation and order handling in VottunBridge. Fees ar…
sergimima Jan 16, 2026
73e3039
update for compiler
sergimima Jan 17, 2026
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
44 changes: 44 additions & 0 deletions .github/workflows/contract-verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: ContractVerify

on:
push:
branches: [ "main", "develop" ]
paths:
- 'src/contracts/*.h'
- '!src/contracts/math_lib.h'
- '!src/contracts/qpi.h'
- '!src/contracts/TestExample*.h'
- '.github/workflows/contract-verify.yml'
pull_request:
branches: [ "main", "develop" ]
paths:
- 'src/contracts/*.h'
- '!src/contracts/math_lib.h'
- '!src/contracts/qpi.h'
- '!src/contracts/TestExample*.h'
- '.github/workflows/contract-verify.yml'

jobs:
contract_verify_job:
runs-on: ubuntu-latest
timeout-minutes: 15 # Sometimes the parser can get stuck
name: Verify smart contract files
steps:
# Checkout repo to use files of the repo as input for container action
- name: Checkout
uses: actions/checkout@v4
- name: Find all contract files to verify
id: filepaths
run: |
files=$(find src/contracts/ -maxdepth 1 -type f -name "*.h" ! -name "*TestExample*" ! -name "*math_lib*" ! -name "*qpi*" -printf "%p\n" | paste -sd, -)
echo "contract-filepaths=$files" >> "$GITHUB_OUTPUT"
- name: Contract verify action step
id: verify
uses: Franziska-Mueller/qubic-contract-verify@v1.0.0
with:
filepaths: '${{ steps.filepaths.outputs.contract-filepaths }}'
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,22 @@ x64/
.DS_Store
.clang-format
tmp

# Build directories and temporary files
out/build/
**/Testing/Temporary/
**/_deps/googletest-src
test/CMakeLists.txt
test/CMakeLists.txt
comp.md
proposal.md
src/Qubic.vcxproj
.claude/settings.local.json
src/Qubic.vcxproj
test/CMakeLists.txt
ANALISIS_STATUS_3.md
.gitignore
node.md
report.md
claude.md
RESUMEN_REVISION.md
29 changes: 19 additions & 10 deletions doc/contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ In order to develop a contract, follow these steps:
- Design and implement the interfaces of your contract (the user procedures and user functions along with its inputs and outputs).
The QPI available for implementing the contract is defined in `src/contracts/qpi.h`.
- Implement the system procedures needed and remove all the system procedures that are not needed by your contract.
- Add the short form contract name as a prefix to all global constants (if any).
- Follow the general [qubic style guidelines](https://github.com/qubic/core/blob/main/doc/contributing.md#style-guidelines) when writing your code.
- Add the short form contract name as a prefix to all global constants, structs and classes (if any).
- Make sure your code is efficient. Execution time will cost fees in the future.
Think about the data structures you use, for example if you can use a hash map instead of an array with linear search.
Check if you can optimize code in loops and especially in nested loops.
Expand All @@ -92,8 +93,9 @@ In order to develop a contract, follow these steps:
## Review and tests

Each contract must be validated with the following steps:
1. The contract is verified with a special software tool, ensuring that it complies with the formal requirements mentioned above, such as no use of forbidden C++ features.
(Currently, this tool has not been implemented yet. Thus, this check needs to be done during the review in point 3.)
1. The contract is verified with the [Qubic Contract Verification Tool](https://github.com/Franziska-Mueller/qubic-contract-verify), ensuring that it complies with the formal requirements mentioned above, such as no use of [forbidden C++ features](#restrictions-of-c-language-features).
In the `qubic/core` repository, the tool is run automatically as GitHub workflow for PRs to the `develop` and `main` branches (as well as for commits in these branches).
However, since workflow runs on PRs require maintainer approval, we highly recommend to either build the tool from source or use the GitHub action provided in the tool's repository to analyze your contract header file before opening your PR.
2. The features of the contract have to be extensively tested with automated tests implemented within the Qubic Core's GoogleTest framework.
3. The contract and testing code must be reviewed by at least one of the Qubic Core devs, ensuring it meets high quality standards.
4. Before integrating the contract in the official Qubic Core release, the features of the contract must be tested in a test network with multiple nodes, showing that the contract works well in practice and that the nodes run stable with the contract.
Expand All @@ -105,7 +107,7 @@ After going through this validation process, a contract can be integrated in off

Steps for deploying a contract:

1. Finish development, review, and tests as written above.
1. Finish development, review, and tests as written above. This includes waiting for approval of your PR by the core dev team. If you need to make any significant changes to the code after the computors accepted your proposal, you will need to make a second proposal.
2. A proposal for including your contract into the Qubic Core needs to be prepared.
We recommend to add your proposal description to https://github.com/qubic/proposal/tree/main/SmartContracts via a pull request (this directory also contains files from other contracts added before, which can be used as a template).
The proposal description should include a detailed description of your contract (see point 1 of the [Development section](#development)) and the final source code of the contract.
Expand Down Expand Up @@ -547,8 +549,8 @@ In consequence, the procedure is executed but with `qpi.invocationReward() == 0`

## Restrictions of C++ Language Features

It is prohibited to locally instantiating objects or variables on the function call stack.
Instead, use the function and procedure definition macros with the postfix `_WITH_LOCALS` (see above).
It is prohibited to locally instantiate objects or variables on the function call stack. This includes loop index variables `for (int i = 0; ...)`.
Instead, use the function and procedure definition macros with the postfix `_WITH_LOCALS` (see above).
In procedures you alternatively may store temporary variables permanently as members of the state.

Defining, casting, and dereferencing pointers is forbidden.
Expand All @@ -566,22 +568,25 @@ The division operator `/` and the modulo operator `%` are prohibited to prevent
Use `div()` and `mod()` instead, which return zero in case of division by zero.

Strings `"` and chars `'` are forbidden, because they can be used to jump to random memory fragments.
If you want to use `static_assert` you can do so via the `STATIC_ASSERT` macro defined in `qpi.h` which does not require a string literal.

Variadic arguments are prohibited (character combination `...`).
Variadic arguments, template parameter packs, and function parameter packs are prohibited (character combination `...`).

Double underscores `__` must not be used in a contract, because these are reserved for internal functions and compiler macros that are prohibited to be used directly.
For similar reasons, `QpiContext` and `const_cast` are prohibited too.

The scope resolution operator `::` is also prohibited, except for structs, enums, and namespaces defined in contracts and `qpi.h`.

The keywords `typedef` and `union` are prohibited to make the code easier to read and prevent tricking code audits.
The keyword `union` is prohibited to make the code easier to read and prevent tricking code audits.
Similarly, the keywords `typedef` and `using` are only allowed in local scope, e.g. inside structs or functions.
The only exception is `using namespace QPI` which can be used at global scope.

Global variables are not permitted.
Global constants must begin with the name of the contract state struct.
Global constants, structs and classes must begin with the name of the contract state struct.

There is a limit for recursion and depth of nested contract function / procedure calls (the limit is 10 at the moment).

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`.
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.
Complex types that may have an inconsistent internal state, such as `Collection`, are forbidden in the public interface of a contract.


Expand Down Expand Up @@ -627,3 +632,7 @@ The file `proposal.cpp` has a lot of examples showing how to use both functions.
For example, `getProposalIndices()` shows how to call a contract function requiring input and providing output with `runContractFunction()`.
An example use case of `makeContractTransaction()` can be found in `gqmpropSetProposal()`.
The function `castVote()` is a more complex example combining both, calling a contract function and invoking a contract procedure.




30 changes: 30 additions & 0 deletions doc/contributing.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# How to Contribute

## Table of contents

1. [Contributing as an external developer](#contributing-as-an-external-developer)
2. [Development workflow / branches](#development-workflow--branches)
3. [Coding guidelines](#coding-guidelines)
1. [Most important principles](#most-important-principles)
2. [General guidelines](#general-guidelines)
3. [Style guidelines](#style-guidelines)
4. [Version naming scheme](#version-naming-scheme)
5. [Profiling](#profiling)

## Contributing as an external developer

If you find bugs, typos, or other problems that can be fixed with a few changes, you are more than welcome to contribute these fixes with a pull request as follows.
Expand Down Expand Up @@ -191,6 +202,8 @@ The code formatting rules are enforced using `clang-format`, ideally setup as a
They are based on the "Microsoft" style with some custom modifications.
Currently, the style guidelines are designed to improve consistency while minimizing the number of changes needed in the existing codebase.

#### Naming

The following naming rules are not strictly enforced, but should be followed at least in new code:

- **Preprocessor symbols** must be defined `ALL_CAPS`.
Expand Down Expand Up @@ -221,6 +234,21 @@ The following naming rules are not strictly enforced, but should be followed at

- **Functions** are named following the same pattern as variables. They usually start with a verb. Examples: `getComputerDigest()`, `processExchangePublicPeers()`, `initContractExec()`.

#### Curly Braces Style

Every opening curly brace should be on a new line. This applies to conditional blocks, loops, functions, classes, structs, etc. For example:

```
if (cond)
{
// do something
}
else
{
// do something else
}
```



## Version naming scheme
Expand Down Expand Up @@ -373,3 +401,5 @@ Even when bound by serializing instructions, the system environment at the time
[AMD64 Architecture Programmer's Manual, Volumes 1-5, 13.2.4 Time-Stamp Counter](https://www.amd.com/content/dam/amd/en/documents/processor-tech-docs/programmer-references/40332.pdf)

Another rich source: [Intel® 64 and IA-32 Architectures Software Developer's Manual Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D, and 4](https://cdrdv2.intel.com/v1/dl/getContent/671200)


6 changes: 6 additions & 0 deletions src/Qubic.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
<ClInclude Include="assets\net_msg_impl.h" />
<ClInclude Include="common_buffers.h" />
<ClInclude Include="contracts\ComputorControlledFund.h" />
<ClInclude Include="contracts\Qdraw.h" />
<ClInclude Include="contracts\Qswap.h" />
<ClInclude Include="contracts\RandomLottery.h" />
<ClInclude Include="contracts\SupplyWatcher.h" />
<ClInclude Include="contracts\EmptyTemplate.h" />
<ClInclude Include="contracts\GeneralQuorumProposal.h" />
Expand All @@ -39,6 +41,8 @@
<ClInclude Include="contracts\QVAULT.h" />
<ClInclude Include="contracts\QBAY.h" />
<ClInclude Include="contracts\Nostromo.h" />
<ClInclude Include="contracts\QBond.h" />
<ClInclude Include="contracts\VottunBridge.h" />
<ClInclude Include="contracts\TestExampleA.h" />
<ClInclude Include="contracts\TestExampleB.h" />
<ClInclude Include="contracts\TestExampleC.h" />
Expand All @@ -50,6 +54,7 @@
<ClInclude Include="contract_core\qpi_asset_impl.h" />
<ClInclude Include="contract_core\qpi_collection_impl.h" />
<ClInclude Include="contract_core\qpi_ipo_impl.h" />
<ClInclude Include="contract_core\qpi_mining_impl.h" />
<ClInclude Include="contract_core\qpi_spectrum_impl.h" />
<ClInclude Include="contract_core\qpi_system_impl.h" />
<ClInclude Include="contract_core\qpi_hash_map_impl.h" />
Expand Down Expand Up @@ -115,6 +120,7 @@
<ClInclude Include="platform\time.h" />
<ClInclude Include="ticking\ticking.h" />
<ClInclude Include="ticking\tick_storage.h" />
<ClInclude Include="ticking\pending_txs_pool.h" />
<ClInclude Include="vote_counter.h" />
</ItemGroup>
<ItemGroup>
Expand Down
20 changes: 19 additions & 1 deletion src/Qubic.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@
<ClInclude Include="contracts\Nostromo.h">
<Filter>contracts</Filter>
</ClInclude>
<ClInclude Include="contracts\QBond.h">
<Filter>contracts</Filter>
</ClInclude>
<ClInclude Include="contracts\VottunBridge.h">
<Filter>contracts</Filter>
</ClInclude>
<ClInclude Include="contract_core\contract_def.h">
<Filter>contract_core</Filter>
</ClInclude>
Expand Down Expand Up @@ -270,6 +276,18 @@
<Filter>platform</Filter>
</ClInclude>
<ClInclude Include="revenue.h" />
<ClInclude Include="contract_core\qpi_mining_impl.h">
<Filter>contract_core</Filter>
</ClInclude>
<ClInclude Include="ticking\pending_txs_pool.h">
<Filter>ticking</Filter>
</ClInclude>
<ClInclude Include="contracts\Qdraw.h">
<Filter>contracts</Filter>
</ClInclude>
<ClInclude Include="contracts\RandomLottery.h">
<Filter>contracts</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="platform">
Expand Down Expand Up @@ -317,4 +335,4 @@
<Filter>platform</Filter>
</MASM>
</ItemGroup>
</Project>
</Project>
5 changes: 3 additions & 2 deletions src/assets/assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ static long long issueAsset(const m256i& issuerPublicKey, const char name[7], ch
AssetIssuance assetIssuance;
assetIssuance.issuerPublicKey = issuerPublicKey;
assetIssuance.numberOfShares = numberOfShares;
assetIssuance.managingContractIndex = managingContractIndex; // any SC can call issueAsset now (eg: QBOND) not just QX
*((unsigned long long*) assetIssuance.name) = *((unsigned long long*) name); // Order must be preserved!
assetIssuance.numberOfDecimalPlaces = numberOfDecimalPlaces; // Order must be preserved!
*((unsigned long long*) assetIssuance.unitOfMeasurement) = *((unsigned long long*) unitOfMeasurement); // Order must be preserved!
Expand Down Expand Up @@ -417,8 +418,8 @@ static bool transferShareManagementRights(int sourceOwnershipIndex, int sourcePo
logPM.possessionPublicKey = possessionPublicKey;
logPM.ownershipPublicKey = ownershipPublicKey;
logPM.issuerPublicKey = assets[issuanceIndex].varStruct.issuance.publicKey;
logOM.sourceContractIndex = assets[sourcePossessionIndex].varStruct.ownership.managingContractIndex;
logOM.destinationContractIndex = destinationPossessionManagingContractIndex;
logPM.sourceContractIndex = assets[sourcePossessionIndex].varStruct.ownership.managingContractIndex;
logPM.destinationContractIndex = destinationPossessionManagingContractIndex;
logPM.numberOfShares = numberOfShares;
*((unsigned long long*) & logPM.assetName) = *((unsigned long long*) & assets[assets[sourceOwnershipIndex].varStruct.ownership.issuanceIndex].varStruct.issuance.name); // possible with 7 byte array, because it is followed by memory reserved for terminator byte
logger.logAssetPossessionManagingContractChange(logPM);
Expand Down
56 changes: 48 additions & 8 deletions src/contract_core/contract_def.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once

#include "network_messages/common_def.h"
#include "platform/m256.h"

////////// Smart contracts \\\\\\\\\\
Expand Down Expand Up @@ -194,8 +194,6 @@ struct __FunctionOrProcedureBeginEndGuard
#define CONTRACT_STATE2_TYPE QSWAP2
#include "contracts/Qswap.h"

#ifndef NO_NOST

#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE
Expand All @@ -206,7 +204,45 @@ struct __FunctionOrProcedureBeginEndGuard
#define CONTRACT_STATE2_TYPE NOST2
#include "contracts/Nostromo.h"

#endif
#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE

#define QDRAW_CONTRACT_INDEX 15
#define CONTRACT_INDEX QDRAW_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE QDRAW
#define CONTRACT_STATE2_TYPE QDRAW2
#include "contracts/Qdraw.h"

#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE

#define RL_CONTRACT_INDEX 16
#define CONTRACT_INDEX RL_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE RL
#define CONTRACT_STATE2_TYPE RL2
#include "contracts/RandomLottery.h"

#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE

#define QBOND_CONTRACT_INDEX 17
#define CONTRACT_INDEX QBOND_CONTRACT_INDEX
#define CONTRACT_STATE_TYPE QBOND
#define CONTRACT_STATE2_TYPE QBOND2
#include "contracts/QBond.h"

#undef CONTRACT_INDEX
#undef CONTRACT_STATE_TYPE
#undef CONTRACT_STATE2_TYPE

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

// new contracts should be added above this line

Expand Down Expand Up @@ -304,9 +340,11 @@ constexpr struct ContractDescription
{"MSVAULT", 149, 10000, sizeof(MSVAULT)}, // proposal in epoch 147, IPO in 148, construction and first use in 149
{"QBAY", 154, 10000, sizeof(QBAY)}, // proposal in epoch 152, IPO in 153, construction and first use in 154
{"QSWAP", 171, 10000, sizeof(QSWAP)}, // proposal in epoch 169, IPO in 170, construction and first use in 171
#ifndef NO_NOST
{"NOST", 172, 10000, sizeof(NOST)}, // proposal in epoch 170, IPO in 171, construction and first use in 172
#endif
{"QDRAW", 179, 10000, sizeof(QDRAW)}, // proposal in epoch 177, IPO in 178, construction and first use in 179
{"RL", 182, 10000, sizeof(RL)}, // proposal in epoch 180, IPO in 181, construction and first use in 182
{"QBOND", 182, 10000, sizeof(QBOND)}, // proposal in epoch 180, IPO in 181, construction and first use in 182
{"VBRIDGE", 184, 10000, sizeof(VOTTUNBRIDGE)}, // Vottun Bridge - Qubic <-> EVM bridge with multisig admin
// new contracts should be added above this line
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
{"TESTEXA", 138, 10000, sizeof(IPO)},
Expand Down Expand Up @@ -409,9 +447,11 @@ static void initializeContracts()
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(MSVAULT);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QBAY);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QSWAP);
#ifndef NO_NOST
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(NOST);
#endif
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QDRAW);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(RL);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(QBOND);
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(VOTTUNBRIDGE);
// new contracts should be added above this line
#ifdef INCLUDE_CONTRACT_TEST_EXAMPLES
REGISTER_CONTRACT_FUNCTIONS_AND_PROCEDURES(TESTEXA);
Expand Down
Loading