Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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": "8.1.1-rc.12",
"version": "8.2.1",
"description": "OTNode V8",
"main": "index.js",
"type": "module",
Expand Down
63 changes: 12 additions & 51 deletions src/commands/protocols/publish/publish-finalization-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,7 @@ class PublishFinalizationCommand extends Command {
const ual = this.ualService.deriveUAL(blockchain, contractAddress, id);

try {
await this.validatePublishData(
operationId,
blockchain,
merkleRoot,
cachedMerkleRoot,
byteSize,
assertion,
ual,
);
await this.validatePublishData(merkleRoot, cachedMerkleRoot, byteSize, assertion, ual);
} catch (e) {
this.logger.error(`Failed to validate publish data: ${e.message}`);
this.operationIdService.emitChangeEvent(
Expand Down Expand Up @@ -173,52 +165,21 @@ class PublishFinalizationCommand extends Command {
return Command.empty();
}

async validatePublishData(
operationId,
blockchain,
merkleRoot,
cachedMerkleRoot,
byteSize,
assertion,
ual,
) {
try {
if (merkleRoot !== cachedMerkleRoot) {
const errorMessage = `Invalid Merkle Root for Knowledge Collection: ${ual}. Received value from blockchain: ${merkleRoot}, Cached value from publish operation: ${cachedMerkleRoot}`;

this.logger.error(`Command error (${this.errorType}): ${errorMessage}`);

this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.FAILED,
operationId,
blockchain,
);
}

const calculatedAssertionSize = this.dataService.calculateAssertionSize(
assertion.public ?? assertion,
);
async validatePublishData(merkleRoot, cachedMerkleRoot, byteSize, assertion, ual) {
if (merkleRoot !== cachedMerkleRoot) {
const errorMessage = `Invalid Merkle Root for Knowledge Collection: ${ual}. Received value from blockchain: ${merkleRoot}, Cached value from publish operation: ${cachedMerkleRoot}`;

if (byteSize.toString() !== calculatedAssertionSize.toString()) {
const errorMessage = `Invalid Assertion Size for Knowledge Collection: ${ual}. Received value from blockchain: ${byteSize}, Calculated value: ${calculatedAssertionSize}`;
throw new Error(errorMessage);
}

this.logger.error(`Command error (${this.errorType}): ${errorMessage}`);
const calculatedAssertionSize = this.dataService.calculateAssertionSize(
assertion.public ?? assertion,
);

this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.FAILED,
operationId,
blockchain,
);
}
} catch (e) {
this.logger.error(`Command error (${this.errorType}): ${e.message}`);
if (byteSize.toString() !== calculatedAssertionSize.toString()) {
const errorMessage = `Invalid Assertion Size for Knowledge Collection: ${ual}. Received value from blockchain: ${byteSize}, Calculated value: ${calculatedAssertionSize}`;

this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.FAILED,
operationId,
blockchain,
);
throw e;
throw new Error(errorMessage);
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/modules/auto-updater/implementation/ot-auto-updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import semver from 'semver';
import axios from 'axios';
import unzipper from 'unzipper';

const REPOSITORY_URL = 'https://github.com/OriginTrail/ot-node';
const ARCHIVE_REPOSITORY_URL = 'github.com/OriginTrail/ot-node/archive/';
const REPOSITORY_URL = 'https://github.com/OriginTrail/dkg-engine';
const ARCHIVE_REPOSITORY_URL = 'github.com/OriginTrail/dkg-engine/archive/';

class OTAutoUpdater {
async initialize(config, logger) {
Expand Down Expand Up @@ -50,7 +50,7 @@ class OTAutoUpdater {

async update() {
try {
this.logger.debug(`AutoUpdater - Updating ot-node from ${REPOSITORY_URL}`);
this.logger.debug(`AutoUpdater - Updating dkg-engine from ${REPOSITORY_URL}`);
const currentDirectory = appRootPath.path;
const rootPath = path.join(currentDirectory, '..');

Expand Down Expand Up @@ -173,7 +173,7 @@ class OTAutoUpdater {
downloadUpdate(destination) {
return new Promise((resolve, reject) => {
const url = `https://${path.join(ARCHIVE_REPOSITORY_URL, this.config.branch)}.zip`;
this.logger.debug(`AutoUpdater - Downloading ot-node .zip file from url: ${url}`);
this.logger.debug(`AutoUpdater - Downloading dkg-engine .zip file from url: ${url}`);
axios({ method: 'get', url, responseType: 'stream' })
.then((response) => {
const fileStream = fs.createWriteStream(destination);
Expand All @@ -191,15 +191,15 @@ class OTAutoUpdater {
.catch((error) => {
reject(
Error(
`AutoUpdater - Unable to download new version of ot-node. Error: ${error.message}`,
`AutoUpdater - Unable to download new version of dkg-engine. Error: ${error.message}`,
),
);
});
});
}

unzipFile(destination, source) {
this.logger.debug(`AutoUpdater - Unzipping ot-node new version archive`);
this.logger.debug(`AutoUpdater - Unzipping dkg-engine new version archive`);
return new Promise((resolve, reject) => {
const fileReadStream = fs
.createReadStream(source)
Expand All @@ -220,7 +220,7 @@ class OTAutoUpdater {
const destinationDirFiles = await fs.readdir(extractedDataPath);
if (destinationDirFiles.length !== 1) {
await fs.remove(extractedDataPath);
throw Error('Extracted archive for new ot-node version is not valid');
throw Error('Extracted archive for new dkg-engine version is not valid');
}
const sourcePath = path.join(extractedDataPath, destinationDirFiles[0]);
await fs.remove(destinationPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class OtBlazegraph extends OtTripleStore {
} catch (error) {
if (error.response && error.response.status === 404) {
// Expected error: GraphDB is up but has not created node0 repository
// Ot-node will create repo in initialization
// dkg-engine will create repo in initialization
return false;
}
this.logger.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
} catch (e) {
if (e.response && e.response.status === 404) {
// Expected error: GraphDB is up but has not created node0 repository
// Ot-node will create repo in initialization
// dkg-engine will create repo in initialization
return true;
}
return false;
Expand Down Expand Up @@ -142,7 +142,7 @@

return true;
} catch (error) {
console.error(`SPARQL update failed: ${error.message}`);

Check warning on line 145 in src/modules/triple-store/implementation/ot-graphdb/ot-graphdb.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 145 in src/modules/triple-store/implementation/ot-graphdb/ot-graphdb.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
throw error;
}
}
Expand All @@ -160,7 +160,7 @@

return response.data.boolean; // true or false
} catch (error) {
console.error(`ASK query failed: ${error.message}`);

Check warning on line 163 in src/modules/triple-store/implementation/ot-graphdb/ot-graphdb.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 163 in src/modules/triple-store/implementation/ot-graphdb/ot-graphdb.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
throw error;
}
}
Expand All @@ -176,7 +176,7 @@
});
return response.data;
} catch (error) {
console.error(`SPARQL query failed: ${error.message}`);

Check warning on line 179 in src/modules/triple-store/implementation/ot-graphdb/ot-graphdb.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 179 in src/modules/triple-store/implementation/ot-graphdb/ot-graphdb.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
throw error;
}
}
Expand Down Expand Up @@ -208,7 +208,7 @@
}
return result;
} catch (error) {
console.error(`SPARQL query failed: ${error.message}`);

Check warning on line 211 in src/modules/triple-store/implementation/ot-graphdb/ot-graphdb.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

Check warning on line 211 in src/modules/triple-store/implementation/ot-graphdb/ot-graphdb.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
throw error;
}
}
Expand Down
10 changes: 5 additions & 5 deletions tools/local-network-setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ This tool will help you set up a local DKG V8 network running with the Hardhat b

# Setup instructions

In order to run the local network you fist need to clone the "ot-node" repository.
In order to run the local network you fist need to clone the "dkg-engine" repository.
<br/>

## 1. CLONE OT-NODE REPOSITORY & INSTALL DEPENDENCIES
## 1. CLONE DKG-ENGINE REPOSITORY & INSTALL DEPENDENCIES

After cloning the **ot-node** repository, please checkout to "v8/develop" branch and install dependencies by running:
After cloning the **dkg-engine** repository, please checkout to "v8/develop" branch and install dependencies by running:

```bash
git clone https://github.com/OriginTrail/ot-node.git && cd ot-node/ && npm install && cd ..
git clone https://github.com/OriginTrail/dkg-engine.git && cd dkg-engine/ && npm install && cd ..
```

<br/>

### 2.2 Create the .env file inside the "ot-node" directory:
### 2.2 Create the .env file inside the "dkg-engine" directory:

```bash
nano .env
Expand Down
2 changes: 1 addition & 1 deletion v8-data-migration/triple-store-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export async function healthCheck(tripleStoreRepositories, repository, tripleSto
} catch (e) {
if (e.response && e.response.status === 404) {
// Expected error: GraphDB is up but has not created node0 repository
// Ot-node will create repo in initialization
// dkg-engine will create repo in initialization
return true;
}
logger.error(`Health check failed for repository ${repository}:`, e);
Expand Down
Loading