Skip to content

Commit

Permalink
Merge pull request #2439 from OriginTrail/v6/release/testnet
Browse files Browse the repository at this point in the history
Mainnet 6.0.5 Prerelease
  • Loading branch information
NZT48 authored Apr 13, 2023
2 parents 0ee8055 + 2110661 commit 712348e
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 36 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "origintrail_node",
"version": "6.0.4",
"version": "6.0.5",
"description": "OTNode V6",
"main": "index.js",
"type": "module",
Expand Down
14 changes: 8 additions & 6 deletions src/commands/common/commands-cleaner-command.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Command from '../command.js';
// eslint-disable-next-line no-unused-vars
import { COMMAND_STATUS, FINALIZED_COMMAND_CLEANUP_TIME_MILLS } from '../../constants/constants.js';

/**
Expand All @@ -16,12 +17,13 @@ class CommandsCleanerCommand extends Command {
* @param command
*/
async execute() {
await this.repositoryModuleManager.removeFinalizedCommands([
COMMAND_STATUS.COMPLETED,
COMMAND_STATUS.FAILED,
COMMAND_STATUS.EXPIRED,
COMMAND_STATUS.UNKNOWN,
]);
// TODO: Uncomment after discussion
// await this.repositoryModuleManager.removeFinalizedCommands([
// COMMAND_STATUS.COMPLETED,
// COMMAND_STATUS.FAILED,
// COMMAND_STATUS.EXPIRED,
// COMMAND_STATUS.UNKNOWN,
// ]);
return Command.repeat();
}

Expand Down
9 changes: 5 additions & 4 deletions src/commands/local-store/local-store-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class LocalStoreCommand extends Command {
);

const agreementEndTime =
agreementData.startTime + agreementData.epochsNumber * agreementData.epochLength;
Number(agreementData.startTime) +
Number(agreementData.epochsNumber) * Number(agreementData.epochLength);

if (storeType === LOCAL_STORE_TYPES.TRIPLE) {
const storePromises = [];
Expand All @@ -71,7 +72,7 @@ class LocalStoreCommand extends Command {
blockchain,
contract,
tokenId,
agreementData.startTime,
Number(agreementData.startTime),
agreementEndTime,
keyword,
),
Expand All @@ -86,7 +87,7 @@ class LocalStoreCommand extends Command {
blockchain,
contract,
tokenId,
agreementData.startTime,
Number(agreementData.startTime),
agreementEndTime,
keyword,
),
Expand All @@ -101,7 +102,7 @@ class LocalStoreCommand extends Command {
tokenId,
{
...cachedData,
agreementStartTime: agreementData.startTime,
agreementStartTime: Number(agreementData.startTime),
agreementEndTime,
keyword,
},
Expand Down
11 changes: 6 additions & 5 deletions src/commands/protocols/common/epoch-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ class EpochCommand extends Command {
assertionId,
) {
const currentEpoch = await this.calculateCurrentEpoch(
agreementData.startTime,
agreementData.epochLength,
Number(agreementData.startTime),
Number(agreementData.epochLength),
blockchain,
);
const nextEpochStartTime =
agreementData.startTime + agreementData.epochLength * (currentEpoch + 1);
Number(agreementData.startTime) +
Number(agreementData.epochLength) * (currentEpoch + 1);

const commitWindowDurationPerc =
await this.blockchainModuleManager.getCommitWindowDurationPerc(blockchain);
// delay by 10% of commit window length
const offset = ((agreementData.epochLength * commitWindowDurationPerc) / 100) * 0.1;
const offset = ((Number(agreementData.epochLength) * commitWindowDurationPerc) / 100) * 0.1;

const now = await this.blockchainModuleManager.getBlockchainTimestamp(blockchain);

Expand Down Expand Up @@ -72,7 +73,7 @@ class EpochCommand extends Command {

async calculateCurrentEpoch(startTime, epochLength, blockchain) {
const now = await this.blockchainModuleManager.getBlockchainTimestamp(blockchain);
return Math.floor((now - startTime) / epochLength);
return Math.floor((Number(now) - Number(startTime)) / Number(epochLength));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ class HandleProtocolMessageCommand extends Command {

// todo: use shared function with epoch commands
const currentEpoch = Math.floor(
(now - agreementData.startTime) / agreementData.epochLength,
(Number(now) - Number(agreementData.startTime)) / Number(agreementData.epochLength),
);

// todo: consider optimizing to take into account cases where some proofs have already been submitted
const epochsLeft = agreementData.epochsNumber - currentEpoch;
const epochsLeft = Number(agreementData.epochsNumber) - currentEpoch;

const divisor = this.blockchainModuleManager
.toBigNumber(blockchain, r0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class CalculateProofsCommand extends EpochCommand {
);

const epoch = await this.calculateCurrentEpoch(
agreementData.startTime,
agreementData.epochLength,
Number(agreementData.startTime),
Number(agreementData.epochLength),
blockchain,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class EpochCheckCommand extends EpochCommand {
agreementId,
);
const epoch = await this.calculateCurrentEpoch(
agreementData.startTime,
agreementData.epochLength,
Number(agreementData.startTime),
Number(agreementData.epochLength),
blockchain,
);
this.logger.trace(`Epoch number: ${epoch}`);
Expand Down Expand Up @@ -120,7 +120,7 @@ class EpochCheckCommand extends EpochCommand {
}

assetLifetimeExpired(agreementData, epoch) {
return epoch >= agreementData.epochsNumber;
return epoch >= Number(agreementData.epochsNumber);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,20 @@ class SubmitCommitCommand extends EpochCommand {
async (result) => {
if (!result.error) {
const currentEpochStartTime =
agreementData.startTime + agreementData.epochLength * epoch;
Number(agreementData.startTime) + Number(agreementData.epochLength) * epoch;

const proofWindowDurationPerc =
await that.blockchainModuleManager.getProofWindowDurationPerc(blockchain);

const proofWindowDuration =
(agreementData.epochLength * proofWindowDurationPerc) / 100;
(Number(agreementData.epochLength) * proofWindowDurationPerc) / 100;

const proofWindowStartTime =
currentEpochStartTime +
Math.floor(
(agreementData.epochLength * agreementData.proofWindowOffsetPerc) / 100,
(Number(agreementData.epochLength) *
Number(agreementData.proofWindowOffsetPerc)) /
100,
);
// we are not using Date.now() here becouse we have an issue with hardhat blockchain time
const timeNow = await that.blockchainModuleManager.getBlockchainTimestamp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ class HandleStoreRequestCommand extends HandleProtocolMessageCommand {
);

const agreementEndTime =
agreementData.startTime + agreementData.epochsNumber * agreementData.epochLength;
Number(agreementData.startTime) +
Number(agreementData.epochsNumber) * Number(agreementData.epochLength);

await this.tripleStoreService.localStoreAsset(
TRIPLE_STORE_REPOSITORIES.PUBLIC_CURRENT,
Expand All @@ -68,7 +69,7 @@ class HandleStoreRequestCommand extends HandleProtocolMessageCommand {
blockchain,
contract,
tokenId,
agreementData.startTime,
Number(agreementData.startTime),
agreementEndTime,
keyword,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class SubmitUpdateCommitCommand extends EpochCommand {
} = command.data;

const epoch = await this.calculateCurrentEpoch(
agreementData.startTime,
agreementData.epochLength,
Number(agreementData.startTime),
Number(agreementData.epochLength),
blockchain,
);

Expand Down
2 changes: 1 addition & 1 deletion src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export const OPERATION_ID_COMMAND_CLEANUP_TIME_MILLS = 24 * 60 * 60 * 1000;
* @constant {number} FINALIZED_COMMAND_CLEANUP_TIME_MILLS - Command cleanup interval time
* finalized commands command cleanup interval time 24h
*/
export const FINALIZED_COMMAND_CLEANUP_TIME_MILLS = 24 * 60 * 60 * 1000;
export const FINALIZED_COMMAND_CLEANUP_TIME_MILLS = 30 * 24 * 60 * 60 * 1000;
/**
* @constant {number} COMMAND_STATUS -
* Status for commands
Expand Down
7 changes: 4 additions & 3 deletions src/migration/private-assets-metadata-migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,16 @@ class PrivateAssetsMetadataMigration extends BaseMigration {
);

const agreementEndTime =
agreementData.startTime + agreementData.epochsNumber * agreementData.epochLength;
Number(agreementData.startTime) +
Number(agreementData.epochsNumber) * Number(agreementData.epochLength);

await this.tripleStoreService.insertAssetMetadata(
TRIPLE_STORE_REPOSITORIES.PRIVATE_CURRENT,
blockchain,
assetStorageContractAddress,
tokenId,
assertionId,
agreementData.startTime,
Number(agreementData.startTime),
agreementEndTime,
keyword,
);
Expand All @@ -156,7 +157,7 @@ class PrivateAssetsMetadataMigration extends BaseMigration {
assetStorageContractAddress,
tokenId,
privateAssertionId,
agreementData.startTime,
Number(agreementData.startTime),
agreementEndTime,
keyword,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export async function up({ context: { queryInterface, Sequelize } }) {
await queryInterface.changeColumn('commands', 'period', {
type: Sequelize.BIGINT,
});
}

export async function down({ context: { queryInterface, Sequelize } }) {
await queryInterface.changeColumn('commands', 'period', {
type: Sequelize.BIGINT,
});
}

0 comments on commit 712348e

Please sign in to comment.