Skip to content

Commit

Permalink
Merge pull request #2562 from OriginTrail/v6/prerelease/mainnet
Browse files Browse the repository at this point in the history
Mainnet 6.0.9 Release
  • Loading branch information
zeroxbt authored May 23, 2023
2 parents 625dff5 + 4adddd6 commit 15905fa
Show file tree
Hide file tree
Showing 68 changed files with 2,551 additions and 1,969 deletions.
3 changes: 1 addition & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ module.exports = {
},
rules: {
'linebreak-style': ['error', 'unix'],
camelcase: 0,
'class-methods-use-this': 0,
'consistent-return': 0,
'no-restricted-syntax': 0,
'guard-for-in': 0,
'no-console': 'warn',
'no-continue': 1,
'no-continue': 0,
'no-underscore-dangle': 0,
'import/extensions': 0,
},
Expand Down
24 changes: 23 additions & 1 deletion ot-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import ServiceAgreementsMetadataMigration from './src/migration/service-agreemen
import RemoveAgreementStartEndTimeMigration from './src/migration/remove-agreement-start-end-time-migration.js';
import MarkOldBlockchainEventsAsProcessedMigration from './src/migration/mark-old-blockchain-events-as-processed-migration.js';
import TripleStoreMetadataMigration from './src/migration/triple-store-metadata-migration.js';
import RemoveOldEpochCommandsMigration from './src/migration/remove-old-epoch-commands-migration.js';

const require = createRequire(import.meta.url);
const pjson = require('./package.json');
Expand Down Expand Up @@ -55,7 +56,8 @@ class OTNode {
await this.executeRemoveAgreementStartEndTimeMigration();
await this.executeMarkOldBlockchainEventsAsProcessedMigration();
await this.executeTripleStoreMetadataMigration();
this.executeServiceAgreementsMetadataMigration();
await this.executeServiceAgreementsMetadataMigration();
await this.executeRemoveOldEpochCommandsMigration();

await this.createProfiles();

Expand Down Expand Up @@ -399,6 +401,26 @@ class OTNode {
}
}

async executeRemoveOldEpochCommandsMigration() {
if (
process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT ||
process.env.NODE_ENV === NODE_ENVIRONMENTS.TEST
)
return;

const repositoryModuleManager = this.container.resolve('repositoryModuleManager');

const migration = new RemoveOldEpochCommandsMigration(
'removeOldEpochCommandsMigration',
this.logger,
this.config,
repositoryModuleManager,
);
if (!(await migration.migrationAlreadyExecuted())) {
await migration.migrate();
}
}

async initializeShardingTableService() {
try {
const shardingTableService = this.container.resolve('shardingTableService');
Expand Down
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.8",
"version": "6.0.9",
"description": "OTNode V6",
"main": "index.js",
"type": "module",
Expand Down
7 changes: 6 additions & 1 deletion scripts/set-ask.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createRequire } from 'module';
import {
NODE_ENVIRONMENTS,
TRANSACTION_POLLING_TIMEOUT_MILLIS,
TRANSACTION_CONFIRMATIONS,
} from '../src/constants/constants.js';
import validateArguments from './utils.js';

Expand Down Expand Up @@ -39,7 +40,11 @@ async function setAsk(rpcEndpoint, ask, walletPrivateKey, hubContractAddress) {
gasPrice: devEnvironment ? undefined : 8,
gasLimit: 500_000,
});
await provider.waitForTransaction(tx.hash, null, TRANSACTION_POLLING_TIMEOUT_MILLIS);
await provider.waitForTransaction(
tx.hash,
TRANSACTION_CONFIRMATIONS,
TRANSACTION_POLLING_TIMEOUT_MILLIS,
);
}

const expectedArguments = ['rpcEndpoint', 'ask', 'privateKey', 'hubContractAddress'];
Expand Down
7 changes: 6 additions & 1 deletion scripts/set-operator-fee.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createRequire } from 'module';
import {
NODE_ENVIRONMENTS,
TRANSACTION_POLLING_TIMEOUT_MILLIS,
TRANSACTION_CONFIRMATIONS,
} from '../src/constants/constants.js';
import validateArguments from './utils.js';

Expand Down Expand Up @@ -37,7 +38,11 @@ async function setOperatorFee(rpcEndpoint, operatorFee, walletPrivateKey, hubCon
gasPrice: process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT ? undefined : 8,
gasLimit: 500_000,
});
await provider.waitForTransaction(tx.hash, null, TRANSACTION_POLLING_TIMEOUT_MILLIS);
await provider.waitForTransaction(
tx.hash,
TRANSACTION_CONFIRMATIONS,
TRANSACTION_POLLING_TIMEOUT_MILLIS,
);
}

const expectedArguments = ['rpcEndpoint', 'operatorFee', 'privateKey', 'hubContractAddress'];
Expand Down
13 changes: 11 additions & 2 deletions scripts/set-stake.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createRequire } from 'module';
import {
NODE_ENVIRONMENTS,
TRANSACTION_POLLING_TIMEOUT_MILLIS,
TRANSACTION_CONFIRMATIONS,
} from '../src/constants/constants.js';
import validateArguments from './utils.js';

Expand Down Expand Up @@ -55,13 +56,21 @@ async function setStake(
gasPrice: devEnvironment ? undefined : 8,
gasLimit: 500_000,
});
await provider.waitForTransaction(tx.hash, null, TRANSACTION_POLLING_TIMEOUT_MILLIS);
await provider.waitForTransaction(
tx.hash,
TRANSACTION_CONFIRMATIONS,
TRANSACTION_POLLING_TIMEOUT_MILLIS,
);
// TODO: Add ABI instead of hard-coded function definition
tx = await stakingContract['addStake(uint72,uint96)'](identityId, stakeWei, {
gasPrice: devEnvironment ? undefined : 1_000,
gasLimit: 500_000,
});
await provider.waitForTransaction(tx.hash, null, TRANSACTION_POLLING_TIMEOUT_MILLIS);
await provider.waitForTransaction(
tx.hash,
TRANSACTION_CONFIRMATIONS,
TRANSACTION_POLLING_TIMEOUT_MILLIS,
);
}

const expectedArguments = [
Expand Down
41 changes: 17 additions & 24 deletions src/commands/command-executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ import {
DEFAULT_COMMAND_REPEAT_INTERVAL_IN_MILLS,
COMMAND_STATUS,
DEFAULT_COMMAND_DELAY_IN_MILLS,
COMMAND_QUEUE_PARALLELISM,
} from '../constants/constants.js';

/**
* How many commands will run in parallel
* @type {number}
*/
const QUEUE_PARALLELISM = 100;

/**
* Queues and processes commands
*/
Expand All @@ -26,8 +21,6 @@ class CommandExecutor {
this.started = false;

this.repositoryModuleManager = ctx.repositoryModuleManager;

this.parallelism = QUEUE_PARALLELISM;
this.verboseLoggingEnabled = this.config.commandExecutorVerboseLoggingEnabled;

this.queue = async.queue((command, callback = () => {}) => {
Expand All @@ -41,7 +34,7 @@ class CommandExecutor {
);
process.exit(1);
});
}, this.parallelism);
}, COMMAND_QUEUE_PARALLELISM);
}

/**
Expand Down Expand Up @@ -75,7 +68,7 @@ class CommandExecutor {
const command = executeCommand;
const now = Date.now();
await this._update(command, {
started_at: now,
startedAt: now,
});

if (this.verboseLoggingEnabled) {
Expand All @@ -90,7 +83,7 @@ class CommandExecutor {
});
return;
}
if (command.deadline_at && now > command.deadline_at) {
if (command.deadlineAt && now > command.deadlineAt) {
this.logger.warn(`Command ${command.name} and ID ${command.id} is too late...`);
await this._update(command, {
status: COMMAND_STATUS.EXPIRED,
Expand All @@ -108,7 +101,7 @@ class CommandExecutor {
return;
}

const waitMs = command.ready_at + command.delay - now;
const waitMs = command.readyAt + command.delay - now;
if (waitMs > 0) {
if (this.verboseLoggingEnabled) {
this.logger.trace(
Expand Down Expand Up @@ -158,7 +151,7 @@ class CommandExecutor {

const children = result.commands.map((c) => {
const newCommand = c;
newCommand.parent_id = command.id;
newCommand.parentId = command.id;
return newCommand;
});

Expand Down Expand Up @@ -250,10 +243,10 @@ class CommandExecutor {
const now = Date.now();

if (delay != null && delay > MAX_COMMAND_DELAY_IN_MILLS) {
if (command.ready_at == null) {
command.ready_at = now;
if (command.readyAt == null) {
command.readyAt = now;
}
command.ready_at += delay;
command.readyAt += delay;
delay = MAX_COMMAND_DELAY_IN_MILLS;
}

Expand Down Expand Up @@ -339,8 +332,8 @@ class CommandExecutor {
[command.name] = command.sequence;
command.sequence = command.sequence.slice(1);
}
if (!command.ready_at) {
command.ready_at = Date.now(); // take current time
if (!command.readyAt) {
command.readyAt = Date.now(); // take current time
}
if (command.delay == null) {
command.delay = 0;
Expand Down Expand Up @@ -414,10 +407,10 @@ class CommandExecutor {

// TODO consider JOIN instead
const commands = pendingCommands.filter(async (pc) => {
if (!pc.parent_id) {
if (!pc.parentId) {
return true;
}
const parent = await this.repositoryModuleManager.getCommandWithId(pc.parent_id);
const parent = await this.repositoryModuleManager.getCommandWithId(pc.parentId);
return !parent || parent.status === 'COMPLETED';
});

Expand All @@ -427,14 +420,14 @@ class CommandExecutor {
id: commandModel.id,
name: commandModel.name,
data: commandModel.data,
ready_at: commandModel.ready_at,
readyAt: commandModel.readyAt,
delay: commandModel.delay,
started_at: commandModel.started_at,
deadline_at: commandModel.deadline_at,
startedAt: commandModel.startedAt,
deadlineAt: commandModel.deadlineAt,
period: commandModel.period,
status: commandModel.status,
message: commandModel.message,
parent_id: commandModel.parent_id,
parentId: commandModel.parentId,
transactional: commandModel.transactional,
retries: commandModel.retries,
sequence: commandModel.sequence,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/common/dial-peers-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DialPeersCommand extends Command {
if (peersToDial.length) {
this.logger.trace(`Dialing ${peersToDial.length} remote peers`);
await Promise.all(
peersToDial.map(({ peer_id: peerId }) => this.shardingTableService.dial(peerId)),
peersToDial.map(({ peerId }) => this.shardingTableService.dial(peerId)),
);
}

Expand Down
Loading

0 comments on commit 15905fa

Please sign in to comment.