Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/v8/develop' into v8/event-listen…
Browse files Browse the repository at this point in the history
…er-module
  • Loading branch information
zsculac committed Nov 21, 2024
2 parents fc733b8 + fca929a commit 6529c35
Show file tree
Hide file tree
Showing 17 changed files with 157 additions and 86 deletions.
10 changes: 5 additions & 5 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
}
}
},
"maximumAssertionSizeInKb": 10000,
"maximumAssertionSizeInKb": 500000,
"commandExecutorVerboseLoggingEnabled": false,
"appDataPath": "data",
"logLevel": "info",
Expand Down Expand Up @@ -350,7 +350,7 @@
}
}
},
"maximumAssertionSizeInKb": 10000,
"maximumAssertionSizeInKb": 500000,
"commandExecutorVerboseLoggingEnabled": false,
"appDataPath": "data",
"logLevel": "trace",
Expand Down Expand Up @@ -528,7 +528,7 @@
}
}
},
"maximumAssertionSizeInKb": 10000,
"maximumAssertionSizeInKb": 500000,
"commandExecutorVerboseLoggingEnabled": false,
"appDataPath": "data",
"logLevel": "trace",
Expand Down Expand Up @@ -705,7 +705,7 @@
}
}
},
"maximumAssertionSizeInKb": 10000,
"maximumAssertionSizeInKb": 500000,
"commandExecutorVerboseLoggingEnabled": false,
"appDataPath": "data",
"logLevel": "trace",
Expand Down Expand Up @@ -905,7 +905,7 @@
}
}
},
"maximumAssertionSizeInKb": 10000,
"maximumAssertionSizeInKb": 500000,
"commandExecutorVerboseLoggingEnabled": false,
"appDataPath": "data",
"logLevel": "trace",
Expand Down
15 changes: 9 additions & 6 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": "8.1.2+beta.0",
"version": "8.1.3+beta.5",
"description": "OTNode V8",
"main": "index.js",
"type": "module",
Expand Down Expand Up @@ -73,7 +73,7 @@
"@polkadot/util": "^10.1.7",
"@polkadot/util-crypto": "^10.1.7",
"app-root-path": "^3.1.0",
"assertion-tools": "^2.0.2",
"assertion-tools": "^2.2.1",
"async": "^3.2.4",
"async-mutex": "^0.3.2",
"awilix": "^7.0.3",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/common/validate-asset-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ValidateAssetCommand extends Command {
);

try {
this.validationService.validateAssertionId(
await this.validationService.validateAssertionId(
cachedData.private.assertion,
cachedData.private.assertionId,
);
Expand Down
13 changes: 8 additions & 5 deletions src/commands/paranet/paranet-sync-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ class ParanetSyncCommand extends Command {
state: assertionId,
hashFunctionId: CONTENT_ASSET_HASH_FUNCTION_ID,
assertionId,
paranetId,
paranetUAL,
},
transactional: false,
});
Expand All @@ -234,6 +236,8 @@ class ParanetSyncCommand extends Command {
state: assertionId,
hashFunctionId: CONTENT_ASSET_HASH_FUNCTION_ID,
assertionId,
paranetId,
paranetUAL,
},
transactional: false,
});
Expand Down Expand Up @@ -274,9 +278,8 @@ class ParanetSyncCommand extends Command {
}

const data = await this.operationIdService.getCachedOperationIdData(getOperationId);

this.logger.debug(
`Paranet sync: ${data.nquads.length} nquads found for asset with ual: ${ual}, state index: ${stateIndex}, assertionId: ${assertionId}`,
`Paranet sync: ${data.assertion.length} nquads found for asset with ual: ${ual}, state index: ${stateIndex}, assertionId: ${assertionId}`,
);

let repository;
Expand All @@ -293,19 +296,19 @@ class ParanetSyncCommand extends Command {
await this.tripleStoreService.localStoreAsset(
repository,
assertionId,
data.nquads,
data.assertion,
blockchain,
contract,
tokenId,
keyword,
LOCAL_INSERT_FOR_CURATED_PARANET_MAX_ATTEMPTS,
LOCAL_INSERT_FOR_CURATED_PARANET_RETRY_DELAY,
);
if (paranetNodesAccessPolicy === 'CURATED' && data.privateNquads) {
if (paranetNodesAccessPolicy === 'CURATED' && data.privateAssertion) {
await this.tripleStoreService.localStoreAsset(
repository,
data.syncedAssetRecord.privateAssertionId,
data.privateNquads,
data.privateAssertion,
blockchain,
contract,
tokenId,
Expand Down
2 changes: 1 addition & 1 deletion src/commands/protocols/common/submit-proofs-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class SubmitProofsCommand extends SendTransactionCommand {
return Command.empty();
}

const { leaf, proof } = this.validationModuleManager.getMerkleProof(
const { leaf, proof } = await this.validationModuleManager.getMerkleProof(
assertion,
Number(challenge),
);
Expand Down
6 changes: 3 additions & 3 deletions src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const TRANSACTION_QUEUE_CONCURRENCY = 1;

export const TRIPLE_STORE_CONNECT_RETRY_FREQUENCY = 10;

export const MAX_FILE_SIZE = 10000000;
export const MAX_FILE_SIZE = 524288000;

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

Expand Down Expand Up @@ -232,7 +232,7 @@ export const SIMPLE_ASSET_SYNC_PARAMETERS = {

export const PARANET_SYNC_PARAMETERS = {
GET_RESULT_POLLING_INTERVAL_MILLIS: 1 * 1000,
GET_RESULT_POLLING_MAX_ATTEMPTS: 30,
GET_RESULT_POLLING_MAX_ATTEMPTS: 300,
};

export const COMMAND_TX_GAS_INCREASE_FACTORS = {
Expand Down Expand Up @@ -308,7 +308,7 @@ export const NETWORK_MESSAGE_TIMEOUT_MILLS = {
},
GET: {
INIT: 60 * 1000,
REQUEST: 60 * 1000,
REQUEST: 5 * 60 * 1000,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class LocalStoreController extends BaseController {
this.commandExecutor = ctx.commandExecutor;
this.operationIdService = ctx.operationIdService;
this.dataService = ctx.dataService;
this.fileService = ctx.fileService;
}

async handleRequest(req, res) {
Expand All @@ -23,8 +24,13 @@ class LocalStoreController extends BaseController {
null,
OPERATION_ID_STATUS.LOCAL_STORE.LOCAL_STORE_INIT_END,
);

const assertions = req.body;
let assertions;
const { filePath } = req.body;
if (filePath) {
assertions = JSON.parse(await this.fileService.readFile(filePath));
} else {
assertions = req.body;
}

const cachedAssertions = {
public: {},
Expand Down
109 changes: 71 additions & 38 deletions src/controllers/http-api/v0/request-schema/local-store-schema-v0.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,82 @@
import { LOCAL_STORE_TYPES } from '../../../../constants/constants.js';

export default (argumentsObject) => ({
type: 'array',
type: ['object', 'array'],
items: {
type: 'object',
required: ['assertionId', 'assertion'],
properties: {
assertionId: {
type: 'string',
minLength: 66,
maxLength: 66,
},
assertion: {
type: 'array',
items: {
type: 'string',
oneOf: [
{
type: 'object',
required: ['assertionId', 'assertion'],
properties: {
assertionId: {
type: 'string',
minLength: 66,
maxLength: 66,
},
assertion: {
type: 'array',
items: {
type: 'string',
},
minItems: 1,
},
blockchain: {
enum: argumentsObject.blockchainImplementationNames,
},
contract: {
type: 'string',
minLength: 42,
maxLength: 42,
},
tokenId: {
type: 'number',
minimum: 0,
},
storeType: {
enum: [
LOCAL_STORE_TYPES.TRIPLE,
LOCAL_STORE_TYPES.TRIPLE_PARANET,
LOCAL_STORE_TYPES.PENDING,
],
},
paranetUAL: {
type: 'string',
},
},
minItems: 1,
maxItems: 2,
},
blockchain: {
enum: argumentsObject.blockchainImplementationNames,
},
contract: {
type: 'string',
minLength: 42,
maxLength: 42,
},
tokenId: {
type: 'number',
minimum: 0,
},
storeType: {
type: {
enum: [
LOCAL_STORE_TYPES.TRIPLE,
LOCAL_STORE_TYPES.TRIPLE_PARANET,
LOCAL_STORE_TYPES.PENDING,
],
{
type: 'object',
required: ['filePath'],
properties: {
filePath: {
type: 'string',
},
paranetUAL: {
type: 'string',
},
blockchain: {
enum: argumentsObject.blockchainImplementationNames,
},
contract: {
type: 'string',
minLength: 42,
maxLength: 42,
},
tokenId: {
type: 'number',
minimum: 0,
},
storeType: {
enum: [
LOCAL_STORE_TYPES.TRIPLE,
LOCAL_STORE_TYPES.TRIPLE_PARANET,
LOCAL_STORE_TYPES.PENDING,
],
},
},
},
paranetUAL: {
type: 'string',
},
},
],
},
minItems: 1,
maxItems: 2,
});
2 changes: 1 addition & 1 deletion src/migration/pending-storage-migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class PendingStorageMigration extends BaseMigration {
const cachedData = await this.fileService.readFile(newDirectoryPath, true);
await this.fileService.removeFile(newDirectoryPath);
if (cachedData?.public?.assertion) {
const newDocumentName = calculateRoot(cachedData.public.assertion);
const newDocumentName = await calculateRoot(cachedData.public.assertion);
await this.fileService.writeContentsToFile(
newDirectoryPath,
newDocumentName,
Expand Down
4 changes: 2 additions & 2 deletions src/modules/validation/implementation/merkle-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class MerkleValidation {
};
}

calculateRoot(assertion) {
async calculateRoot(assertion) {
return calculateRoot(assertion);
}

getMerkleProof(nquadsArray, challenge) {
async getMerkleProof(nquadsArray, challenge) {
return getMerkleProof(nquadsArray, challenge);
}

Expand Down
4 changes: 2 additions & 2 deletions src/modules/validation/validation-module-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ValidationModuleManager extends BaseModuleManager {
return 'validation';
}

calculateRoot(assertion) {
async calculateRoot(assertion) {
if (this.initialized) {
if (!assertion) {
throw new Error('Calculation failed: Assertion cannot be null or undefined.');
Expand All @@ -15,7 +15,7 @@ class ValidationModuleManager extends BaseModuleManager {
throw new Error('Validation module is not initialized.');
}

getMerkleProof(assertion, index) {
async getMerkleProof(assertion, index) {
if (this.initialized) {
if (!assertion) {
throw new Error('Get merkle proof failed: Assertion cannot be null or undefined.');
Expand Down
Loading

0 comments on commit 6529c35

Please sign in to comment.