Skip to content

Commit

Permalink
Merge pull request #55 from qubic/release/v1.193
Browse files Browse the repository at this point in the history
Release/v1.193 to main
  • Loading branch information
philippwerner authored Feb 14, 2024
2 parents 2ab77fc + 27006a6 commit e05f617
Show file tree
Hide file tree
Showing 16 changed files with 307 additions and 37 deletions.
31 changes: 26 additions & 5 deletions doc/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ For big changes, such as adding a smart contract, we recommended to discuss with
2. Clone your fork on your local machine. Your remote repository on GitHub is called origin.
3. Add the original GitHub repository as a remote called upstream.
4. If you have created your fork a while ago, pull upstream changes into your local repository.
5. Create a new branch from `develop` or the current `release/epXX` branch.
5. Create a new branch from `develop`.
6. Fix the bug, correct the typo, solve the problem, etc. Make sure to follow the coding guidelines below.
7. Commit your changes to your new branch. Make sure to use a concise but meaningful commit message.
8. Push your branch to the remote origin (your fork on Github).
9. From your fork on GitHub, open a pull request (PR) in your new branch targeting the `develop` or the current `release/epXX` branch of the original repo. In the PR, describe the problem and how your changes solve it.
9. From your fork on GitHub, open a pull request (PR) in your new branch targeting the `develop` branch of the original repo. In the PR, describe the problem and how your changes solve it.
10. If the PR reviewer requests further changes, push them to your branch. The PR will be updated automatically.
11. When your PR is approved and merged, you can pull the changes from upstream to your local repo and delete your extra branch.

Expand All @@ -22,10 +22,31 @@ For big changes, such as adding a smart contract, we recommended to discuss with

We use a mixture of [GitFlow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) and a [trunk-based-process](https://www.atlassian.com/continuous-delivery/continuous-integration/trunk-based-development) with the following branches:

1. `main`: The code base which is officially deployed on computors. Releases are created from this branch.
1. `main`: The code base that is officially deployed on computors. Releases are created from this branch.
Changes should NOT be committed here directly, but merged from other branches after testing.
Exception: If the current release (such as v1.191.0) has a critical bug, the fix may be committed to the main branch directly (followed by creating a bugfix release such as v1.191.1 after testing the fix).

2. `develop`: Our current testing branch, which will be automatically deployed to the test-net once active.
3. `release/epXX`: Our release branch for a specific epoch when we have specific tasks to work on (e.g. refactoring). May be deployed to test-net too or automatically by merging to dev.
4. `feature/DeveloperName_FeatureName`: When one of us is working on a specific feature that is unsure to be included into the next release, a feature branch should be created from `develop`. May be deployed to test-net.
Most changes should either be committed here or in feature branches.
Feature branches should be created from `develop` and pull requests (PR) should target `develop`.
Before committing to this branch or creating a PR, please check that everything compiles and the automated tests (gtest) run successfully.

3. `feature/YYYY-MM-DD-FeatureName`: When we are working on a specific feature that is quite complex and/or requires code review, a feature branch should be created from `develop`.
The commits in this branch do not need to be fully functional, but before creating a pull request, you should check that the final commit compiles and the automated tests (gtest) run successfully.
If the code passes the PR review, it can be merged to the develop branch for testing.
(The idea is to test the changes in an accumulated way in the test net, assuming that most changes work and do not require debugging. This should be easier than deploying each feature branch in the test net separately.)
The branch should be deleted after merging with the PR.

4. `release/v1.XYZ`: This is a release branch for a specific version, usually for a new epoch.
It should be created from the develop branch after testing the new features and agreeing what is supposed to be included in the release.
This branch is then merged to the main branch via PR before creating the release on the main branch.
The branch may be deleted after merging.
However, it may be necessary to later recreate the branch if an old release needs to be fixed or updated, such as for creating the rollback version v1.190.1 for epoch 94.

For each release, there will be a tag like `v1.XYZ.N`.
The release description should contain the target epoch number and a short change log.

Mandatory update releases like adding SC or IPO should be published before Sunday (1/2 of the epoch), so that computors can catch up with AUX&MAIN mode and have the new version running the next epoch seamlessly (the following Wednesday).


## Coding guidelines
Expand Down
2 changes: 1 addition & 1 deletion doc/protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ If an outgoing connection to a verified peer is rejected, the peer loses the ver
If an outgoing connection to a non-verified peer is rejected, the peer is removed from the list of peers.
If an outgoing connection to a non-verified peer is accepted and an `ExchangePublicPeers` message is received, the peer gets the verified status.
If a protocol violation is detected at any moment during communication (allowing to assume the remote end runs something else, not Qubic node), then the IP is removed even if it is verified.
An IP is only removed from the list of peers if the list still has at least 10 entries afterwards.
An IP is only removed from the list of peers if the list still has at least 10 entries afterwards and if it is not in the initial `knownPublicPeers`.


## ...
Expand Down
1 change: 1 addition & 0 deletions src/Qubic.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<ClInclude Include="network_messages\header.h" />
<ClInclude Include="network_messages\public_peers.h" />
<ClInclude Include="network_messages\special_command.h" />
<ClInclude Include="network_messages\system_info.h" />
<ClInclude Include="network_messages\tick.h" />
<ClInclude Include="network_messages\transactions.h" />
<ClInclude Include="platform\concurrency.h" />
Expand Down
3 changes: 3 additions & 0 deletions src/Qubic.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@
<ClInclude Include="network_core\tcp4.h">
<Filter>network_core</Filter>
</ClInclude>
<ClInclude Include="network_messages\system_info.h">
<Filter>network_messages</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="smart_contracts">
Expand Down
11 changes: 10 additions & 1 deletion src/assets.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static void deinitAssets()
}
}

static void issueAsset(const m256i& issuerPublicKey, char name[7], char numberOfDecimalPlaces, char unitOfMeasurement[7], long long numberOfShares, unsigned short managingContractIndex,
static long long issueAsset(const m256i& issuerPublicKey, char name[7], char numberOfDecimalPlaces, char unitOfMeasurement[7], long long numberOfShares, unsigned short managingContractIndex,
int* issuanceIndex, int* ownershipIndex, int* possessionIndex)
{
*issuanceIndex = issuerPublicKey.m256i_u32[0] & (ASSETS_CAPACITY - 1);
Expand Down Expand Up @@ -105,6 +105,8 @@ static void issueAsset(const m256i& issuerPublicKey, char name[7], char numberOf
assetIssuance.numberOfDecimalPlaces = numberOfDecimalPlaces; // Order must be preserved!
*((unsigned long long*) assetIssuance.unitOfMeasurement) = *((unsigned long long*) unitOfMeasurement); // Order must be preserved!
logAssetIssuance(assetIssuance);

return numberOfShares;
}
else
{
Expand All @@ -122,6 +124,13 @@ static void issueAsset(const m256i& issuerPublicKey, char name[7], char numberOf
}
else
{
if (assets[*issuanceIndex].varStruct.issuance.type == ISSUANCE
&& ((*((unsigned long long*)assets[*issuanceIndex].varStruct.issuance.name)) & 0xFFFFFFFFFFFFFF) == ((*((unsigned long long*)name)) & 0xFFFFFFFFFFFFFF)
&& assets[*issuanceIndex].varStruct.issuance.publicKey == issuerPublicKey)
{
return 0;
}

*issuanceIndex = (*issuanceIndex + 1) & (ASSETS_CAPACITY - 1);

goto iteration;
Expand Down
17 changes: 17 additions & 0 deletions src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ struct RespondLog
#define CONTRACT_WARNING_MESSAGE 5
#define CONTRACT_INFORMATION_MESSAGE 6
#define CONTRACT_DEBUG_MESSAGE 7
#define BURNING 8
#define CUSTOM_MESSAGE 255
static volatile char logBufferLocks[sizeof(logReaderPasscodes) / sizeof(logReaderPasscodes[0])] = { 0 };
static char* logBuffers[sizeof(logReaderPasscodes) / sizeof(logReaderPasscodes[0])] = { NULL };
Expand Down Expand Up @@ -291,6 +292,22 @@ struct DummyCustomMessage
char _terminator; // Only data before "_terminator" are logged
};

struct Burning
{
m256i sourcePublicKey;
long long amount;

char _terminator; // Only data before "_terminator" are logged
};

template <typename T>
static void logBurning(T message)
{
#if LOG_BURNINGS
logMessage(offsetof(T, _terminator), BURNING, &message);
#endif
}

template <typename T>
static void logCustomMessage(T message)
{
Expand Down
52 changes: 46 additions & 6 deletions src/network_core/peers.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,54 @@ static void enqueueResponse(Peer* peer, unsigned int dataSize, unsigned char typ
RELEASE(responseQueueHeadLock);
}

/**
* checks if a given address is a bogon address
* a bogon address is an ip address which should not be used pubicly (e.g. private networks)
*
* @param address the ip address to be checked
* @return true if address is bogon or false if not
*/
static bool isBogonAddress(const IPv4Address& address)
{
return (!address.u8[0])
|| (address.u8[0] == 127)
|| (address.u8[0] == 10)
|| (address.u8[0] == 172 && address.u8[1] >= 16 && address.u8[1] <= 31)
|| (address.u8[0] == 192 && address.u8[1] == 168)
|| (address.u8[0] == 255);
}

/**
* checks if a given address was manually set in the initial list of known public peers
*
* @param address the ip address to be checked
* @return true if the ip address is in the Known Public Peers or false if not
*/
static bool isAddressInKnownPublicPeers(const IPv4Address& address)
{
// keep this exception to avoid bogon addresses kept for outgoing connections
if (isBogonAddress(address))
return false;

for (unsigned int i = 0; i < sizeof(knownPublicPeers) / sizeof(knownPublicPeers[0]); i++)
{
const IPv4Address& peer_ip = *reinterpret_cast<const IPv4Address*>(knownPublicPeers[i]);
if (peer_ip == address)
return true;
}
return false;
}


// Forget public peer (no matter if verified or not) if we have more than the minium number of peers
static void forgetPublicPeer(const IPv4Address& address)
{
// if address is one of our initial peers we don't forget it
if (isAddressInKnownPublicPeers(address))
{
return;
}

if (listOfPeersIsStatic)
{
return;
Expand Down Expand Up @@ -300,14 +344,10 @@ static void penalizePublicPeerRejectedConnection(const IPv4Address& address)
}
}


static void addPublicPeer(const IPv4Address& address)
{
if ((!address.u8[0])
|| (address.u8[0] == 127)
|| (address.u8[0] == 10)
|| (address.u8[0] == 172 && address.u8[1] >= 16 && address.u8[1] <= 31)
|| (address.u8[0] == 192 && address.u8[1] == 168)
|| (address.u8[0] == 255))
if (isBogonAddress(address))
{
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/network_messages/all.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
#include "special_command.h"
#include "tick.h"
#include "transactions.h"
#include "system_info.h"
23 changes: 22 additions & 1 deletion src/network_messages/special_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,25 @@ struct SpecialCommandToggleMainModeResquestAndResponse
};
#define SPECIAL_COMMAND_REFRESH_PEER_LIST 9ULL // F4
#define SPECIAL_COMMAND_FORCE_NEXT_TICK 10ULL // F5
#define SPECIAL_COMMAND_REISSUE_VOTE 11ULL // F9
#define SPECIAL_COMMAND_REISSUE_VOTE 11ULL // F9


struct UtcTime
{
unsigned short year; // 1900 - 9999
unsigned char month; // 1 - 12
unsigned char day; // 1 - 31
unsigned char hour; // 0 - 23
unsigned char minute; // 0 - 59
unsigned char second; // 0 - 59
unsigned char pad1;
unsigned int nanosecond; // 0 - 999,999,999
};

#define SPECIAL_COMMAND_QUERY_TIME 12ULL // send this to node to query time, responds with time read from clock
#define SPECIAL_COMMAND_SEND_TIME 13ULL // send this to node to set time, responds with time read from clock after setting
struct SpecialCommandSendTime
{
unsigned long long everIncreasingNonceAndCommandType;
UtcTime utcTime;
};
32 changes: 32 additions & 0 deletions src/network_messages/system_info.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include "common_def.h"

#define REQUEST_SYSTEM_INFO 46


#define RESPOND_SYSTEM_INFO 47

struct RespondSystemInfo
{
short version;
unsigned short epoch;
unsigned int tick;
unsigned int initialTick;
unsigned int latestCreatedTick;

unsigned short initialMillisecond;
unsigned char initialSecond;
unsigned char initialMinute;
unsigned char initialHour;
unsigned char initialDay;
unsigned char initialMonth;
unsigned char initialYear;

unsigned int numberOfEntities;
unsigned int numberOfTransactions;

m256i randomMiningSeed;
};

static_assert(sizeof(RespondSystemInfo) == 2 + 2 + 4 + 4 + 4 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 4 + 32 + 4, "Something is wrong with the struct size of RespondSystemInfo.");
1 change: 1 addition & 0 deletions src/private_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static const unsigned char knownPublicPeers[][4] = {
#define LOG_CONTRACT_WARNING_MESSAGES 0
#define LOG_CONTRACT_INFO_MESSAGES 0
#define LOG_CONTRACT_DEBUG_MESSAGES 0
#define LOG_BURNINGS 0
#define LOG_CUSTOM_MESSAGES 0
static unsigned long long logReaderPasscodes[][4] = {
{0, 0, 0, 0}, // REMOVE THIS ENTRY AND REPLACE IT WITH YOUR OWN RANDOM NUMBERS IN [0..18446744073709551615] RANGE IF LOGGING IS ENABLED
Expand Down
6 changes: 3 additions & 3 deletions src/public_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#define NUMBER_OF_SOLUTION_PROCESSORS 2 // do not increase this for this epoch, because there may be issues due too fast ticking

#define VERSION_A 1
#define VERSION_B 192
#define VERSION_B 193
#define VERSION_C 0

#define EPOCH 95
#define TICK 12380000
#define EPOCH 96
#define TICK 12501000

// random seed is now obtained from spectrumDigests

Expand Down
Loading

0 comments on commit e05f617

Please sign in to comment.