Skip to content

Commit

Permalink
Merge pull request #2733 from OriginTrail/v6/development-network
Browse files Browse the repository at this point in the history
OriginTrail Testnet Prerelease v6.0.16
  • Loading branch information
djordjekovac authored Sep 29, 2023
2 parents eb90e4c + cc1f019 commit 7fcb391
Show file tree
Hide file tree
Showing 14 changed files with 295 additions and 53 deletions.
8 changes: 3 additions & 5 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
"config": {
"networkId": "otp::testnet",
"hubContractAddress": "0x707233a55bD035C6Bc732196CA4dbffa63CbA169",
"rpcEndpoints": ["wss://lofar.origin-trail.network"],
"rpcEndpoints": ["https://lofar-tm-rpc.origin-trail.network"],
"initialStakeAmount": 50000,
"initialAskAmount": 2
}
Expand Down Expand Up @@ -413,8 +413,7 @@
"hubContractAddress": "0xBbfF7Ea6b2Addc1f38A0798329e12C08f03750A6",
"rpcEndpoints": [
"https://lofar-testnet.origin-trail.network",
"https://lofar-testnet.origintrail.network",
"wss://parachain-testnet-rpc.origin-trail.network"
"https://lofar-testnet.origintrail.network"
]
}
}
Expand Down Expand Up @@ -562,8 +561,7 @@
"hubContractAddress": "0x5fA7916c48Fe6D5F1738d12Ad234b78c90B4cAdA",
"rpcEndpoints": [
"https://astrosat-parachain-rpc.origin-trail.network",
"https://astrosat.origintrail.network/",
"wss://parachain-rpc.origin-trail.network"
"https://astrosat.origintrail.network/"
]
}
}
Expand Down
23 changes: 19 additions & 4 deletions ot-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ class OTNode {

await this.createProfiles();

await this.initializeCommandExecutor();
await this.initializeShardingTableService();
await this.initializeTelemetryInjectionService();
await this.initializeBlockchainEventListenerService();

await this.initializeCommandExecutor();
await this.initializeRouters();
await this.startNetworkModule();
this.resumeCommandExecutor();
this.logger.info('Node is up and running!');
}

Expand Down Expand Up @@ -244,9 +245,11 @@ class OTNode {
async initializeCommandExecutor() {
try {
const commandExecutor = this.container.resolve('commandExecutor');
await commandExecutor.init();
commandExecutor.replay();
await commandExecutor.start();
commandExecutor.pauseQueue();
await commandExecutor.addDefaultCommands();
commandExecutor
.replayOldCommands()
.then(() => this.logger.info('Finished replaying old commands'));
} catch (e) {
this.logger.error(
`Command executor initialization failed. Error message: ${e.message}`,
Expand All @@ -255,6 +258,18 @@ class OTNode {
}
}

resumeCommandExecutor() {
try {
const commandExecutor = this.container.resolve('commandExecutor');
commandExecutor.resumeQueue();
} catch (e) {
this.logger.error(
`Unable to resume command executor queue. Error message: ${e.message}`,
);
this.stop(1);
}
}

async startNetworkModule() {
const networkModuleManager = this.container.resolve('networkModuleManager');
await networkModuleManager.start();
Expand Down
75 changes: 66 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "origintrail_node",
"version": "6.0.15",
"version": "6.0.16",
"description": "OTNode V6",
"main": "index.js",
"type": "module",
Expand Down Expand Up @@ -104,7 +104,7 @@
"pino-pretty": "^9.1.0",
"rc": "^1.2.8",
"rolling-rate-limiter": "^0.2.13",
"semver": "^7.3.7",
"semver": "^7.5.2",
"sequelize": "^6.29.0",
"timeout-abort-controller": "^3.0.0",
"toobusy-js": "^0.5.1",
Expand Down
28 changes: 18 additions & 10 deletions src/commands/command-executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class CommandExecutor {
constructor(ctx) {
this.logger = ctx.logger;
this.commandResolver = ctx.commandResolver;
this.started = false;

this.repositoryModuleManager = ctx.repositoryModuleManager;
this.verboseLoggingEnabled = ctx.config.commandExecutorVerboseLoggingEnabled;
Expand All @@ -39,23 +38,32 @@ class CommandExecutor {
* Initialize executor
* @returns {Promise<void>}
*/
async init() {
await Promise.all(PERMANENT_COMMANDS.map((command) => this._startDefaultCommand(command)));
async addDefaultCommands() {
await Promise.all(PERMANENT_COMMANDS.map((command) => this._addDefaultCommand(command)));

if (this.verboseLoggingEnabled) {
this.logger.trace('Command executor has been initialized...');
}
}

/**
* Starts the command executor
* @return {Promise<void>}
* Resumes the command executor queue
*/
resumeQueue() {
if (this.verboseLoggingEnabled) {
this.logger.trace('Command executor queue has been resumed...');
}
this.queue.resume();
}

/**
* Pause the command executor queue
*/
async start() {
this.started = true;
pauseQueue() {
if (this.verboseLoggingEnabled) {
this.logger.trace('Command executor has been started...');
this.logger.trace('Command executor queue has been paused...');
}
this.queue.pause();
}

/**
Expand Down Expand Up @@ -224,7 +232,7 @@ class CommandExecutor {
* @return {Promise<void>}
* @private
*/
async _startDefaultCommand(name) {
async _addDefaultCommand(name) {
await this._delete(name);
const handler = this.commandResolver.resolve(name);
if (!handler) {
Expand Down Expand Up @@ -398,7 +406,7 @@ class CommandExecutor {
* Replays pending commands from the database
* @returns {Promise<void>}
*/
async replay() {
async replayOldCommands() {
this.logger.info('Replay pending/started commands from the database...');
const pendingCommands = await this.repositoryModuleManager.getCommandsWithStatus(
[COMMAND_STATUS.PENDING, COMMAND_STATUS.STARTED, COMMAND_STATUS.REPEATING],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class SubmitUpdateCommitCommand extends Command {
this.logger.trace(
`Scheduled submit update commit transaction for agreement id: ${agreementId} ` +
`blockchain: ${blockchain} contract: ${contract}, token id: ${tokenId}, ` +
`keyword: ${keyword}, hash function id: ${hashFunctionId}, operationId ${operationId}` +
`transaction queue length: ${transactionQueueLength}.`,
`keyword: ${keyword}, hash function id: ${hashFunctionId}, operationId ${operationId}. ` +
`Transaction queue length: ${transactionQueueLength}.`,
);

return Command.empty();
Expand Down
19 changes: 19 additions & 0 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const STAKE_UINT256_MULTIPLIER_BN = UINT256_MAX_BN.div(500000000);

export const UINT256_UINT32_DIVISOR_BN = UINT256_MAX_BN.div(UINT32_MAX_BN);

export const ZERO_PREFIX = '0x';

export const ZERO_BYTES32 = `0x${'0'.repeat(64)}`;

export const SCHEMA_CONTEXT = 'http://schema.org/';
Expand All @@ -21,6 +23,22 @@ export const COMMITS_DELAY_BETWEEN_NODES_IN_BLOCKS = 2;

export const TRANSACTION_POLLING_TIMEOUT_MILLIS = 50 * 1000;

export const SOLIDITY_ERROR_STRING_PREFIX = '0x08c379a0';

export const SOLIDITY_PANIC_CODE_PREFIX = '0x4e487b71';

export const SOLIDITY_PANIC_REASONS = {
0x1: 'Assertion error',
0x11: 'Arithmetic operation underflowed or overflowed outside of an unchecked block',
0x12: 'Division or modulo division by zero',
0x21: 'Tried to convert a value into an enum, but the value was too big or negative',
0x22: 'Incorrectly encoded storage byte array',
0x31: '.pop() was called on an empty array',
0x32: 'Array accessed at an out-of-bounds or negative index',
0x41: 'Too much memory was allocated, or an array was created that is too large',
0x51: 'Called a zero-initialized variable of internal function type',
};

export const LIBP2P_KEY_DIRECTORY = 'libp2p';

export const LIBP2P_KEY_FILENAME = 'privateKey';
Expand All @@ -38,6 +56,7 @@ export const TRIPLE_STORE_CONNECT_RETRY_FREQUENCY = 10;
export const MAX_FILE_SIZE = 2621440;

export const GET_STATES = { LATEST: 'LATEST', FINALIZED: 'LATEST_FINALIZED' };

export const BYTES_IN_KILOBYTE = 1024;

export const BYTES_IN_MEGABYTE = BYTES_IN_KILOBYTE * BYTES_IN_KILOBYTE;
Expand Down
Loading

0 comments on commit 7fcb391

Please sign in to comment.