Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OriginTrail v8.0.0-beta Release #3442

Open
wants to merge 54 commits into
base: v8/develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
a04e2b9
Added priority queues for Command Executor and transactions
u-hubar Nov 26, 2024
8baffe7
Added priority column to 'commands' table
u-hubar Nov 26, 2024
6fbd845
Remove redundant caching
brkagithub Nov 27, 2024
243f8d4
Minor fixes
brkagithub Nov 27, 2024
739d5c2
Added binaries for bls-tools, implemented BLSService
u-hubar Nov 27, 2024
4ba015f
Remove local store from http controller
Mihajlo-Pavlovic Nov 28, 2024
5a5ca9c
Move findShardCommand to controller
Mihajlo-Pavlovic Nov 28, 2024
810b59e
Add missing linter annotation
brkagithub Nov 28, 2024
327b0d3
Merge branch 'improvement/v8-alpha-remove-redundant-caching' of https…
brkagithub Nov 28, 2024
1060dec
Rework command flow for publish
Mihajlo-Pavlovic Nov 28, 2024
fe76cba
Working
Mihajlo-Pavlovic Nov 28, 2024
46caf57
Add memory cache to pending storage and clean it periodically
brkagithub Nov 28, 2024
b180439
Updated logic for pending storage, return signatures for publish oper…
u-hubar Nov 28, 2024
57777a4
remove get-init
Mihajlo-Pavlovic Nov 28, 2024
cc35e05
Merge branch 'feature/move-find-shard-and-make-node-self-aware' into …
Mihajlo-Pavlovic Nov 28, 2024
f13602d
Small Command Executor refactor
u-hubar Nov 28, 2024
e21a4a8
Fix pending storage cleanup command
brkagithub Nov 28, 2024
d463273
Adapt cleaner function to delete signatures too
brkagithub Nov 28, 2024
7e5b4a2
skip path if doesn't exist
brkagithub Nov 28, 2024
5186a8c
Add pending storage cleaner command to permanent
brkagithub Nov 28, 2024
d05f6b5
Separated publish finalization into commands
u-hubar Nov 28, 2024
5161262
Merge pull request #3439 from OriginTrail/feature/bls-signatures
u-hubar Nov 28, 2024
929fa68
Merge branch 'release/v8.0.0-beta' into improvement/publish-finalizat…
u-hubar Nov 28, 2024
fb02896
Merge pull request #3441 from OriginTrail/improvement/publish-finaliz…
u-hubar Nov 28, 2024
3804787
Merge pull request #3428 from OriginTrail/feature/priority-queues
u-hubar Nov 28, 2024
c452e89
linter fixes
brkagithub Nov 28, 2024
7a9a148
Merge branch 'improvement/v8-alpha-remove-redundant-caching' of https…
brkagithub Nov 28, 2024
9575998
Fixed variables naming
u-hubar Nov 28, 2024
1734957
Fixed Command Executor _insert
u-hubar Nov 28, 2024
28c546f
wip
Mihajlo-Pavlovic Nov 28, 2024
a04b6b7
Updated dkg-evm-module and pending storage caching logic
u-hubar Nov 28, 2024
023d6cb
Merge branch 'release/v8.0.0-beta' into improvement/v8-alpha-remove-r…
brkagithub Nov 28, 2024
b2b8443
Remove memory storage from pending storage, use operation id as key, …
brkagithub Nov 28, 2024
565db64
remove extra caching, integrate with pr
brkagithub Nov 29, 2024
77233e8
split operation id caching into memory and file, replace storage w op…
brkagithub Nov 29, 2024
8607f10
before testing
Mihajlo-Pavlovic Nov 29, 2024
166327b
Fix controler versions
Mihajlo-Pavlovic Nov 29, 2024
6348678
Placeholder for get controler
Mihajlo-Pavlovic Nov 29, 2024
3d91a3f
Merge branch 'release/v8.0.0-beta' into feature/remove-get-init
Mihajlo-Pavlovic Nov 29, 2024
2982943
Merge pull request #3445 from OriginTrail/feature/remove-get-init
Mihajlo-Pavlovic Nov 29, 2024
24a4446
local store fix
Mihajlo-Pavlovic Nov 29, 2024
b760400
get fixes
Mihajlo-Pavlovic Dec 2, 2024
026e3d3
PR improvements
brkagithub Dec 2, 2024
6b3831e
Merge remote-tracking branch 'origin/release/v8.0.0-beta' into improv…
brkagithub Dec 2, 2024
5af2974
Remove unused variables
brkagithub Dec 2, 2024
e5da9e9
Merge pull request #3444 from OriginTrail/improvement/v8-alpha-remove…
u-hubar Dec 2, 2024
74feb85
Add parsing
Mihajlo-Pavlovic Dec 2, 2024
0f16b54
Add includeMetada flag support
Mihajlo-Pavlovic Dec 2, 2024
0f121c7
Logs wording fix
Mihajlo-Pavlovic Dec 2, 2024
9230c3e
Update src/commands/protocols/get/sender/local-get-command.js
Mihajlo-Pavlovic Dec 2, 2024
4584758
Update src/commands/protocols/get/sender/local-get-command.js
Mihajlo-Pavlovic Dec 2, 2024
0b9a170
Update src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-r…
Mihajlo-Pavlovic Dec 2, 2024
7155a34
Update src/commands/protocols/get/receiver/v1.0.0/v1-0-0-handle-get-r…
Mihajlo-Pavlovic Dec 2, 2024
a92be04
Merge pull request #3450 from OriginTrail/feature/get-metadata-flag
Mihajlo-Pavlovic Dec 2, 2024
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
Binary file added bin/darwin/arm64/bls-tools
Binary file not shown.
Binary file added bin/darwin/x64/bls-tools
Binary file not shown.
Binary file added bin/linux/arm64/bls-tools
Binary file not shown.
Binary file added bin/linux/x64/bls-tools
Binary file not shown.
Binary file added bin/win32/x64/bls-tools.exe
Binary file not shown.
13 changes: 13 additions & 0 deletions ot-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class OTNode {

await this.initializeRouters();
await this.startNetworkModule();
await this.initializeBLSService();
this.startTelemetryModule();
this.resumeCommandExecutor();
this.logger.info('Node is up and running!');
Expand Down Expand Up @@ -403,6 +404,18 @@ class OTNode {
tripleStoreService.initializeRepositories();
}

async initializeBLSService() {
try {
const blsService = this.container.resolve('blsService');
await blsService.initialize();
} catch (error) {
this.logger.error(
`Unable to initialize BLS Service. Error message: ${error.message} OT-node shutting down...`,
);
this.stop(1);
}
}

stop(code = 0) {
this.logger.info('Stopping node...');
process.exit(code);
Expand Down
14 changes: 7 additions & 7 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
Expand Up @@ -80,7 +80,7 @@
"axios": "^1.6.0",
"cors": "^2.8.5",
"deep-extend": "^0.6.0",
"dkg-evm-module": "^8.0.1-alpha.1",
"dkg-evm-module": "^8.0.2-alpha.0",
"dotenv": "^16.0.1",
"ethers": "^5.7.2",
"express": "^4.18.1",
Expand Down
63 changes: 63 additions & 0 deletions src/commands/cleaners/pending-storage-cleaner-command.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import Command from '../command.js';
import {
PUBLISH_STORAGE_MEMORY_CLEANUP_COMMAND_CLEANUP_TIME_MILLS,
PUBLISH_STORAGE_FILE_CLEANUP_COMMAND_CLEANUP_TIME_MILLS,
PENDING_STORAGE_FILES_FOR_REMOVAL_MAX_NUMBER,
} from '../../constants/constants.js';

/**
* Cleans memory cache in the pending storage service
*/
class PendingStorageCleanerCommand extends Command {
constructor(ctx) {
super(ctx);
this.logger = ctx.logger;
this.pendingStorageService = ctx.pendingStorageService;
}

/**
* Executes command and produces one or more events
* @param command
*/
async execute() {
this.logger.debug('Starting command for removal of expired pending storage entries');

const removed = await this.pendingStorageService.removeExpiredFileCache(
PUBLISH_STORAGE_FILE_CLEANUP_COMMAND_CLEANUP_TIME_MILLS,
PENDING_STORAGE_FILES_FOR_REMOVAL_MAX_NUMBER,
);
if (removed) {
this.logger.debug(`Successfully removed ${removed} expired cached operation files`);
}

return Command.repeat();
}

/**
* Recover system from failure
* @param command
* @param error
*/
async recover(command) {
this.logger.warn(`Failed to clean pending storage: error: ${command.message}`);
return Command.repeat();
}

/**
* Builds default command
* @param map
* @returns {{add, data: *, delay: *, deadline: *}}
*/
default(map) {
const command = {
name: 'pendingStorageCleanerCommand',
period: PUBLISH_STORAGE_MEMORY_CLEANUP_COMMAND_CLEANUP_TIME_MILLS,
data: {},
transactional: false,
};
Object.assign(command, map);
return command;
}
}

export default PendingStorageCleanerCommand;
47 changes: 25 additions & 22 deletions src/commands/command-executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
COMMAND_STATUS,
DEFAULT_COMMAND_DELAY_IN_MILLS,
COMMAND_QUEUE_PARALLELISM,
DEFAULT_COMMAND_PRIORITY,
} from '../constants/constants.js';

/**
Expand All @@ -20,7 +21,7 @@ class CommandExecutor {
this.repositoryModuleManager = ctx.repositoryModuleManager;
this.verboseLoggingEnabled = ctx.config.commandExecutorVerboseLoggingEnabled;

this.queue = async.queue((command, callback = () => {}) => {
this.queue = async.priorityQueue((command, callback = () => {}) => {
this._execute(command)
.then((result) => {
callback(result);
Expand Down Expand Up @@ -81,7 +82,7 @@ class CommandExecutor {
commandId: command.id,
commandName: command.name,
};
if (command.data && command.data.operationId) {
if (command.data?.operationId !== undefined) {
commandContext.operationId = command.data.operationId;
}
const loggerWithContext = this.logger.child(commandContext);
Expand All @@ -106,7 +107,7 @@ class CommandExecutor {
});
return;
}
if (command.deadlineAt && now > command.deadlineAt) {
if (command.deadlineAt !== undefined && now > command.deadlineAt) {
loggerWithContext.warn('Command is too late...');
await this._update(command, {
status: COMMAND_STATUS.EXPIRED,
Expand Down Expand Up @@ -280,7 +281,7 @@ class CommandExecutor {
let delay = addDelay ?? 0;

if (delay > MAX_COMMAND_DELAY_IN_MILLS) {
if (command.readyAt == null) {
if (command.readyAt === undefined) {
command.readyAt = Date.now();
}
command.readyAt += delay;
Expand All @@ -290,16 +291,19 @@ class CommandExecutor {
if (insert) {
command = await this._insert(command);
}

const commandPriority = command.priority ?? DEFAULT_COMMAND_PRIORITY;

if (delay) {
setTimeout(
(timeoutCommand) => {
this.queue.push(timeoutCommand);
this.queue.push(timeoutCommand, commandPriority);
},
delay,
command,
);
} else {
this.queue.push(command);
this.queue.push(command, commandPriority);
}
}

Expand All @@ -311,7 +315,7 @@ class CommandExecutor {
*/
async _handleRetry(retryCommand, handler) {
const command = retryCommand;
if (command.retries > 1) {
if (command.retries !== undefined && command.retries > 1) {
command.data = handler.pack(command.data);
await this._update(command, {
status: COMMAND_STATUS.PENDING,
Expand All @@ -337,7 +341,7 @@ class CommandExecutor {
* @private
*/
async _handleError(command, handler, error) {
if (command.retries > 0) {
if (command.retries !== undefined && command.retries > 0) {
await this._update(command, {
retries: command.retries - 1,
});
Expand Down Expand Up @@ -373,28 +377,26 @@ class CommandExecutor {
[command.name] = command.sequence;
command.sequence = command.sequence.slice(1);
}
if (!command.readyAt) {
command.readyAt = Date.now(); // take current time
}
if (command.delay == null) {
command.delay = 0;
}
if (!command.transactional) {
command.transactional = 0;
}

command.readyAt = command.readyAt || Date.now();
command.delay = command.delay ?? 0;
command.transactional = command.transactional ?? 0;
command.priority = command.priority ?? DEFAULT_COMMAND_PRIORITY;
command.status = COMMAND_STATUS.PENDING;

if (!command.data) {
const commandInstance = this.commandResolver.resolve(command.name);
if (commandInstance) {
command.data = commandInstance.pack(command.data);
}
}
command.status = COMMAND_STATUS.PENDING;
const opts = {};
if (transaction != null) {
opts.transaction = transaction;
}

const opts = transaction ? { transaction } : {};

const model = await this.repositoryModuleManager.createCommand(command, opts);

command.id = model.id;

return command;
}

Expand Down Expand Up @@ -462,6 +464,7 @@ class CommandExecutor {
id: commandModel.id,
name: commandModel.name,
data: commandModel.data,
priority: commandModel.priority ?? DEFAULT_COMMAND_PRIORITY,
readyAt: commandModel.readyAt,
delay: commandModel.delay,
startedAt: commandModel.startedAt,
Expand Down
48 changes: 31 additions & 17 deletions src/commands/local-store/local-store-command.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { OPERATION_ID_STATUS, ERROR_TYPE, LOCAL_STORE_TYPES } from '../../constants/constants.js';
import {
OPERATION_ID_STATUS,
ERROR_TYPE,
LOCAL_STORE_TYPES,
OPERATION_REQUEST_STATUS,
NETWORK_MESSAGE_TYPES,
} from '../../constants/constants.js';
import Command from '../command.js';

class LocalStoreCommand extends Command {
Expand All @@ -8,6 +14,7 @@ class LocalStoreCommand extends Command {
this.paranetService = ctx.paranetService;
this.pendingStorageService = ctx.pendingStorageService;
this.operationIdService = ctx.operationIdService;
this.operationService = ctx.publishService;
this.dataService = ctx.dataService;
this.ualService = ctx.ualService;
this.serviceAgreementService = ctx.serviceAgreementService;
Expand Down Expand Up @@ -37,27 +44,34 @@ class LocalStoreCommand extends Command {

if (storeType === LOCAL_STORE_TYPES.TRIPLE) {
const storePromises = [];
if (cachedData.public.dataset && cachedData.public.datasetRoot) {
storePromises.push(
this.pendingStorageService.cacheDataset(
blockchain,
cachedData.public.datasetRoot,
cachedData.public.dataset,
operationId,
),
);
}
// if (cachedData.private?.assertion && cachedData.private?.assertionId) {

// if (cachedData.dataset && cachedData.datasetRoot) {
// storePromises.push(
// this.pendingStorageService.cacheDataset(
// blockchain,
// datasetRoot,
// dataset,
// operationId,
// cachedData.datasetRoot,
// cachedData.dataset,
// ),
// );
// }
// if (cachedData.private?.assertion && cachedData.private?.assertionId) {
// storePromises.push(
// this.pendingStorageService.cacheDataset(operationId, datasetRoot, dataset),
// );
// }
await Promise.all(storePromises);
await this.operationService.processResponse(
command,
OPERATION_REQUEST_STATUS.COMPLETED,
{
messageType: NETWORK_MESSAGE_TYPES.RESPONSES.ACK,
messageData: {
signature: `signature-${Math.floor(Math.random() * 1000000) + 1}`,
},
},
null,
true,
);
} else if (storeType === LOCAL_STORE_TYPES.TRIPLE_PARANET) {
const paranetMetadata = await this.blockchainModuleManager.getParanetMetadata(
blockchain,
Expand All @@ -73,7 +87,7 @@ class LocalStoreCommand extends Command {
await this.tripleStoreModuleManager.initializeParanetRepository(paranetRepository);
await this.paranetService.initializeParanetRecord(blockchain, paranetId);

if (cachedData.public.dataset && cachedData.public.datasetRoot) {
if (cachedData && cachedData.datasetRoot) {
// await this.tripleStoreService.localStoreAsset(
// paranetRepository,
// cachedData.public.assertionId,
Expand All @@ -86,7 +100,7 @@ class LocalStoreCommand extends Command {
// LOCAL_INSERT_FOR_CURATED_PARANET_RETRY_DELAY,
// );
}
if (cachedData.private?.assertion && cachedData.private?.assertionId) {
if (cachedData && cachedData.datasetRoot) {
// await this.tripleStoreService.localStoreAsset(
// paranetRepository,
// cachedData.private.assertionId,
Expand Down
Loading
Loading