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

V8 Hotfix 4 Testnet Release #3661

Merged
merged 41 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
727f5e2
Fix get on migrated assets
Dec 27, 2024
7c2db0e
Fix fetching v6 assertion first
Dec 27, 2024
095fa7c
Fix create paranet synced asset record table migration
Mihajlo-Pavlovic Dec 30, 2024
423723e
Add main dir variable
Dec 30, 2024
8ad3521
Add redownloads if db download fails or its integrity is compromised
Dec 30, 2024
5967efc
fix integrity check typo
Dec 30, 2024
5e80bb6
Fix add indexes to tables migration
Mihajlo-Pavlovic Dec 30, 2024
6951974
Fix renam keywork column to datasetroot in repsonse tables
Mihajlo-Pavlovic Dec 30, 2024
7f2789f
Fix add commands priority migration
Mihajlo-Pavlovic Dec 30, 2024
19c558a
Fix add commands is blocking migration
Mihajlo-Pavlovic Dec 30, 2024
86f8e0e
Fix remove dataset root response table migration
Mihajlo-Pavlovic Dec 30, 2024
0ca8deb
Fix update blockchain events migration
Mihajlo-Pavlovic Dec 30, 2024
17ad6fa
add db close if integrity check fails
Dec 30, 2024
bb21b8e
Fix rename ask migration
Mihajlo-Pavlovic Dec 30, 2024
2f70f82
Exit loop when db is valid
Dec 30, 2024
ae890e8
Dont store gateway publisher signature
Mihajlo-Pavlovic Dec 30, 2024
38671ef
Fix local-store command
Mihajlo-Pavlovic Dec 30, 2024
ebc47a2
Save finality ACK only if node iteslf is part of the sard
Mihajlo-Pavlovic Dec 30, 2024
9957b87
Enable local get if node is not part of the shard
Mihajlo-Pavlovic Dec 30, 2024
e2a1661
Remove commented out code
Mihajlo-Pavlovic Dec 30, 2024
c30e1ac
Move schedule sending network finality message after collection asser…
Mihajlo-Pavlovic Dec 30, 2024
abeeee4
Remove unsed dependencies in ReadCachedPublishDataCommand
Mihajlo-Pavlovic Dec 30, 2024
a8d8a6b
Set MAX_RETRIES_READ_CACHED_PUBLISH_DATA to 10
Mihajlo-Pavlovic Dec 30, 2024
5957baa
Increase default number of retries for insertKnowledgeCollection in t…
Mihajlo-Pavlovic Dec 30, 2024
df6fd26
Rename isOldContract into isV6Contract
Dec 31, 2024
4156b86
Add SPARQL timeout
Mihajlo-Pavlovic Dec 31, 2024
5b5cdae
Merge pull request #3656 from OriginTrail/chore/increase-number-of-re…
Mihajlo-Pavlovic Dec 31, 2024
65f6755
Merge pull request #3638 from OriginTrail/fix/get-on-migrated-assets
Mihajlo-Pavlovic Dec 31, 2024
f28c289
Merge pull request #3651 from OriginTrail/fix/sql-migrations
Mihajlo-Pavlovic Dec 31, 2024
fc18896
Merge pull request #3652 from OriginTrail/v8/data-migration-fix
Mihajlo-Pavlovic Dec 31, 2024
ab95d2d
Merge pull request #3653 from OriginTrail/fix/gateway-node-can-publish
Mihajlo-Pavlovic Dec 31, 2024
badeb28
Merge branch 'v8/develop' into rework/send-finalization-ack-after-insert
Mihajlo-Pavlovic Dec 31, 2024
a395339
Merge pull request #3654 from OriginTrail/rework/send-finalization-ac…
Mihajlo-Pavlovic Dec 31, 2024
ccba429
Merge pull request #3655 from OriginTrail/chore/change-number-of-retr…
Mihajlo-Pavlovic Dec 31, 2024
6f04418
Merge pull request #3658 from OriginTrail/rework/send-finalization-ac…
Mihajlo-Pavlovic Dec 31, 2024
cb6638c
Merge pull request #3657 from OriginTrail/improvment/add-sparql-timeout
Mihajlo-Pavlovic Dec 31, 2024
50f73b4
Merge pull request #3659 from OriginTrail/v8/develop
Mihajlo-Pavlovic Dec 31, 2024
28086a2
Merge branch 'v6/prerelease/testnet' into v8/release/devnet
Mihajlo-Pavlovic Dec 31, 2024
8d6a0df
Merge pull request #3660 from OriginTrail/v8/release/devnet
Mihajlo-Pavlovic Dec 31, 2024
7f912a2
version bump
Mihajlo-Pavlovic Dec 31, 2024
01116b1
Merge branch 'v6/release/testnet' into v6/prerelease/testnet
Mihajlo-Pavlovic Dec 31, 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
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.0.0+hotfix.3",
"version": "8.0.0+hotfix.4",
"description": "OTNode V8",
"main": "index.js",
"type": "module",
Expand Down
62 changes: 38 additions & 24 deletions src/commands/local-store/local-store-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class LocalStoreCommand extends Command {
tokenId,
minimumNumberOfNodeReplications,
batchSize,
nodePartOfShard,
} = command.data;

try {
Expand Down Expand Up @@ -191,21 +192,26 @@ class LocalStoreCommand extends Command {

return Command.empty();
}

let v;
let r;
let s;
let vs;
const identityId = await this.blockchainModuleManager.getIdentityId(blockchain);
const { v, r, s, vs } = await this.signatureService.signMessage(
blockchain,
datasetRoot,
);
await this.signatureService.addSignatureToStorage(
NETWORK_SIGNATURES_FOLDER,
operationId,
identityId,
v,
r,
s,
vs,
);
if (nodePartOfShard) {
({ v, r, s, vs } = await this.signatureService.signMessage(
blockchain,
datasetRoot,
));
await this.signatureService.addSignatureToStorage(
NETWORK_SIGNATURES_FOLDER,
operationId,
identityId,
v,
r,
s,
vs,
);
}

const {
v: publisherNodeV,
Expand Down Expand Up @@ -239,16 +245,24 @@ class LocalStoreCommand extends Command {
batchSize: batchSizePar,
minAckResponses,
};

await this.operationService.processResponse(
{ ...command, data: updatedData },
OPERATION_REQUEST_STATUS.COMPLETED,
{
messageType: NETWORK_MESSAGE_TYPES.RESPONSES.ACK,
messageData: { identityId, v, r, s, vs },
},
null,
);
if (nodePartOfShard) {
await this.operationService.processResponse(
{ ...command, data: updatedData },
OPERATION_REQUEST_STATUS.COMPLETED,
{
messageType: NETWORK_MESSAGE_TYPES.RESPONSES.ACK,
messageData: { identityId, v, r, s, vs },
},
null,
);
} else {
await this.operationService.processResponse(
{ ...command, data: updatedData },
OPERATION_REQUEST_STATUS.FAILED,
{},
'Node is not part of the shard.',
);
}
} catch (e) {
await this.handleError(operationId, blockchain, e.message, this.errorType, true);
return Command.empty();
Expand Down
1 change: 1 addition & 0 deletions src/commands/protocols/common/find-shard-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class FindShardCommand extends Command {
return this.continueSequence(
{
...command.data,
nodePartOfShard,
leftoverNodes: shardNodes,
numberOfFoundNodes: shardNodes.length + (nodePartOfShard ? 1 : 0),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class HandleGetRequestCommand extends HandleProtocolMessageCommand {
ual,
includeMetadata,
isOperationV0,
isV6Contract,
} = commandData;

let { assertionId, knowledgeAssetId } = commandData;
Expand Down Expand Up @@ -109,6 +110,7 @@ class HandleGetRequestCommand extends HandleProtocolMessageCommand {
);

let assertionPromise;
let notMigrated = false;

if (!assertionId) {
assertionId = await this.tripleStoreService.getLatestAssertionId(
Expand All @@ -123,39 +125,50 @@ class HandleGetRequestCommand extends HandleProtocolMessageCommand {

if (assertionId) {
// DO NOT RUN THIS IF !assertionId
assertionPromise = this.tripleStoreService
.getV6Assertion(TRIPLE_STORE_REPOSITORIES.PUBLIC_CURRENT, assertionId)
.then(async (result) => {
if (!result?.length) {
this.logger.info(
`No V6 assertion found for assertionId: ${assertionId}, falling back to V8 getAssertion`,
);
assertionPromise = (async () => {
let result = null;

if (!isOperationV0) {
result = await this.tripleStoreService.getAssertion(
blockchain,
contract,
knowledgeCollectionId,
knowledgeAssetId,
TRIPLES_VISIBILITY.PUBLIC,
);
}

if (!result?.length) {
// eslint-disable-next-line no-await-in-loop
result = await this.tripleStoreService.getV6Assertion(
TRIPLE_STORE_REPOSITORIES.PUBLIC_CURRENT,
assertionId,
);
if (result?.length && !isOperationV0) {
notMigrated = true;
}

const fallbackResult = await this.tripleStoreService.getAssertion(
if (!result?.length && isOperationV0) {
result = await this.tripleStoreService.getAssertion(
blockchain,
contract,
knowledgeCollectionId,
knowledgeAssetId,
TRIPLES_VISIBILITY.PUBLIC,
);

this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.GET.GET_REMOTE_GET_ASSERTION_END,
operationId,
blockchain,
);

return fallbackResult;
}
}

this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.GET.GET_REMOTE_GET_ASSERTION_END,
operationId,
blockchain,
);
this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.GET.GET_REMOTE_GET_ASSERTION_END,
operationId,
blockchain,
);

return result.split('\n').filter((res) => res.length > 0);
});
return typeof result === 'string'
? result.split('\n').filter((res) => res.length > 0)
: result;
})();
} else {
if (!knowledgeAssetId) {
try {
Expand Down Expand Up @@ -223,9 +236,10 @@ class HandleGetRequestCommand extends HandleProtocolMessageCommand {
const [assertion, metadata] = await Promise.all(promises);

const responseData = {
assertion: isOperationV0
? [...(assertion.public ?? []), ...(assertion.private ?? [])]
: assertion,
assertion:
(isOperationV0 || notMigrated) && isV6Contract
? [...(assertion.public ?? []), ...(assertion.private ?? [])]
: assertion,
...(includeMetadata && metadata && { metadata }),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ class GetFindShardCommand extends FindShardCommand {
// eslint-disable-next-line no-unused-vars
getOperationCommandSequence(nodePartOfShard, commandData) {
const sequence = [];
if (nodePartOfShard) {
sequence.push('localGetCommand');
}
sequence.push('networkGetCommand');
sequence.push('localGetCommand', 'networkGetCommand');

return sequence;
}
Expand Down
25 changes: 11 additions & 14 deletions src/commands/protocols/get/sender/get-validate-asset-command.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import ValidateAssetCommand from '../../../common/validate-asset-command.js';
import Command from '../../../command.js';
import {
OPERATION_ID_STATUS,
ERROR_TYPE,
OLD_CONTENT_STORAGE_MAP,
} from '../../../../constants/constants.js';
import { OPERATION_ID_STATUS, ERROR_TYPE } from '../../../../constants/constants.js';

class GetValidateAssetCommand extends ValidateAssetCommand {
constructor(ctx) {
Expand All @@ -27,8 +23,15 @@ class GetValidateAssetCommand extends ValidateAssetCommand {
* @param command
*/
async execute(command) {
const { operationId, blockchain, contract, knowledgeCollectionId, ual, isOperationV0 } =
command.data;
const {
operationId,
blockchain,
contract,
knowledgeCollectionId,
ual,
isOperationV0,
isV6Contract,
} = command.data;
await this.operationIdService.updateOperationIdStatus(
operationId,
blockchain,
Expand All @@ -53,13 +56,7 @@ class GetValidateAssetCommand extends ValidateAssetCommand {
blockchain,
);
// TODO: Update to validate knowledge asset index
// TODO: Use isOldContract as variable and pass it through with command.data since it's used
if (
!isOperationV0 &&
Object.values(OLD_CONTENT_STORAGE_MAP).every(
(ca) => !ca.toLowerCase().includes(contract.toLowerCase()),
)
) {
if (!isOperationV0 && !isV6Contract) {
const isValidUal = await this.validationService.validateUal(
blockchain,
contract,
Expand Down
51 changes: 36 additions & 15 deletions src/commands/protocols/get/sender/local-get-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class LocalGetCommand extends Command {
contentType,
assertionId,
isOperationV0,
isV6Contract,
} = command.data;
let { knowledgeAssetId } = command.data;
await this.operationIdService.updateOperationIdStatus(
Expand Down Expand Up @@ -103,23 +104,13 @@ class LocalGetCommand extends Command {
);

let assertionPromise;
let notMigrated = false;

if (assertionId) {
assertionPromise = (async () => {
let result = null;

for (const repository of [
TRIPLE_STORE_REPOSITORIES.PRIVATE_CURRENT,
TRIPLE_STORE_REPOSITORIES.PUBLIC_CURRENT,
]) {
// eslint-disable-next-line no-await-in-loop
result = await this.tripleStoreService.getV6Assertion(repository, assertionId);
if (result?.length) {
break;
}
}

if (!result?.length) {
if (!isOperationV0) {
result = await this.tripleStoreService.getAssertion(
blockchain,
contract,
Expand All @@ -128,6 +119,35 @@ class LocalGetCommand extends Command {
contentType,
);
}

if (!result?.length) {
for (const repository of [
TRIPLE_STORE_REPOSITORIES.PRIVATE_CURRENT,
TRIPLE_STORE_REPOSITORIES.PUBLIC_CURRENT,
]) {
// eslint-disable-next-line no-await-in-loop
result = await this.tripleStoreService.getV6Assertion(
repository,
assertionId,
);
if (result?.length) {
if (!isOperationV0) {
notMigrated = true;
}
break;
}
}
if (!result?.length && isOperationV0) {
result = await this.tripleStoreService.getAssertion(
blockchain,
contract,
knowledgeCollectionId,
knowledgeAssetId,
contentType,
);
}
}

this.operationIdService.emitChangeEvent(
OPERATION_ID_STATUS.GET.GET_LOCAL_GET_ASSERTION_END,
operationId,
Expand Down Expand Up @@ -206,9 +226,10 @@ class LocalGetCommand extends Command {
const [assertion, metadata] = await Promise.all(promises);

const responseData = {
assertion: isOperationV0
? [...(assertion?.public ?? []), ...(assertion?.private ?? [])]
: assertion,
assertion:
(isOperationV0 || notMigrated) && isV6Contract
? [...(assertion?.public ?? []), ...(assertion?.private ?? [])]
: assertion,
...(includeMetadata && metadata && { metadata }),
};

Expand Down
Loading
Loading