Skip to content

Commit cbc6a97

Browse files
authored
Merge pull request #4076 from OriginTrail/v8/develop
8.2.3 prerelease testnet
2 parents ca656ef + 43d08f2 commit cbc6a97

File tree

5 files changed

+67
-42
lines changed

5 files changed

+67
-42
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "origintrail_node",
3-
"version": "8.2.2",
3+
"version": "8.2.3",
44
"description": "OTNode V8",
55
"main": "index.js",
66
"type": "module",

src/commands/protocols/publish/publish-finalization-command.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ class PublishFinalizationCommand extends Command {
3333
const { id, publishOperationId, merkleRoot, byteSize } = eventData;
3434
const { blockchain, contractAddress } = event;
3535
const operationId = this.operationIdService.generateId();
36+
const ual = this.ualService.deriveUAL(blockchain, contractAddress, id);
37+
3638
this.operationIdService.emitChangeEvent(
3739
OPERATION_ID_STATUS.PUBLISH_FINALIZATION.PUBLISH_FINALIZATION_START,
3840
operationId,
@@ -70,8 +72,10 @@ class PublishFinalizationCommand extends Command {
7072
cachedMerkleRoot = result.merkleRoot;
7173
assertion = result.assertion;
7274
publisherPeerId = result.remotePeerId;
73-
} catch (error) {
74-
this.logger.error(`Failed to read cached publish data: ${error.message}`); // TODO: Make this log more descriptive
75+
} catch (_error) {
76+
this.logger.warn(
77+
`[Cache] Failed to read cached publish data for UAL ${ual} (publishOperationId: ${publishOperationId}, txHash: ${txHash}, operationId: ${operationId})`,
78+
);
7579
this.operationIdService.emitChangeEvent(
7680
OPERATION_ID_STATUS.FAILED,
7781
operationId,
@@ -81,8 +85,6 @@ class PublishFinalizationCommand extends Command {
8185
return Command.empty();
8286
}
8387

84-
const ual = this.ualService.deriveUAL(blockchain, contractAddress, id);
85-
8688
try {
8789
await this.validatePublishData(merkleRoot, cachedMerkleRoot, byteSize, assertion, ual);
8890
} catch (e) {
@@ -185,23 +187,24 @@ class PublishFinalizationCommand extends Command {
185187

186188
async readWithRetries(publishOperationId) {
187189
let attempt = 0;
190+
const datasetPath = this.fileService.getPendingStorageDocumentPath(publishOperationId);
188191

189192
while (attempt < MAX_RETRIES_READ_CACHED_PUBLISH_DATA) {
190193
try {
191-
const datasetPath =
192-
this.fileService.getPendingStorageDocumentPath(publishOperationId);
193194
// eslint-disable-next-line no-await-in-loop
194195
const cachedData = await this.fileService.readFile(datasetPath, true);
195196
return cachedData;
196197
} catch (error) {
197198
attempt += 1;
198-
199199
// eslint-disable-next-line no-await-in-loop
200200
await new Promise((resolve) => {
201201
setTimeout(resolve, RETRY_DELAY_READ_CACHED_PUBLISH_DATA);
202202
});
203203
}
204204
}
205+
this.logger.warn(
206+
`[Cache] Exhausted retries reading cached publish data (publishOperationId: ${publishOperationId}, path: ${datasetPath}).`,
207+
);
205208
// TODO: Mark this operation as failed
206209
throw new Error('Failed to read cached publish data');
207210
}

src/modules/triple-store/implementation/ot-blazegraph/ot-blazegraph.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,24 @@ class OtBlazegraph extends OtTripleStore {
177177
}
178178

179179
async queryVoid(repository, query, timeout) {
180-
return axios.post(this.repositories[repository].sparqlEndpoint, query, {
181-
headers: {
182-
'Content-Type': 'application/sparql-update; charset=UTF-8',
183-
'X-BIGDATA-MAX-QUERY-MILLIS': timeout,
184-
},
185-
});
180+
try {
181+
return await axios.post(this.repositories[repository].sparqlEndpoint, query, {
182+
headers: {
183+
'Content-Type': 'application/sparql-update; charset=UTF-8',
184+
'X-BIGDATA-MAX-QUERY-MILLIS': timeout,
185+
},
186+
});
187+
} catch (error) {
188+
const status = error?.response?.status;
189+
const dataSnippet =
190+
typeof error?.response?.data === 'string' ? error.response.data.slice(0, 200) : '';
191+
this.logger.error(
192+
`[OtBlazegraph.queryVoid] Update failed for ${repository} (status: ${status}): ${
193+
error.message
194+
}${dataSnippet ? ` | data: ${dataSnippet}` : ''}`,
195+
);
196+
throw error;
197+
}
186198
}
187199

188200
async deleteRepository(repository) {

src/service/publish-service.js

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -69,32 +69,42 @@ class PublishService extends OperationService {
6969
// }
7070

7171
// 2. Check if all responses have been received
72-
if (totalResponses === numberOfFoundNodes) {
73-
// 2.1 If minimum replication is reached, mark the operation as completed
74-
if (completedNumber >= minAckResponses) {
75-
await this.markOperationAsCompleted(
76-
operationId,
77-
blockchain,
78-
null,
79-
this.completedStatuses,
80-
);
81-
await this.repositoryModuleManager.updateMinAcksReached(operationId, true);
82-
this.logResponsesSummary(completedNumber, failedNumber);
83-
}
84-
// 2.2 Otherwise, mark as failed
85-
else {
86-
await this.markOperationAsFailed(
87-
operationId,
88-
blockchain,
89-
'Not replicated to enough nodes!',
90-
this.errorType,
91-
);
92-
this.operationIdService.emitChangeEvent(
93-
OPERATION_ID_STATUS.PUBLISH.PUBLISH_FAILED,
94-
operationId,
95-
);
96-
this.logResponsesSummary(completedNumber, failedNumber);
97-
}
72+
// 2.1 If minimum replication is reached, mark the operation as completed
73+
74+
const record = await this.operationIdService.getOperationIdRecord(operationId);
75+
if (record?.minAcksReached) return;
76+
77+
if (completedNumber >= minAckResponses) {
78+
this.logger.info(
79+
`[PUBLISH] Minimum replication reached for operationId: ${operationId}, ` +
80+
`datasetRoot: ${datasetRoot}, completed: ${completedNumber}/${minAckResponses}`,
81+
);
82+
await this.markOperationAsCompleted(
83+
operationId,
84+
blockchain,
85+
null,
86+
this.completedStatuses,
87+
);
88+
await this.repositoryModuleManager.updateMinAcksReached(operationId, true);
89+
this.logResponsesSummary(completedNumber, failedNumber);
90+
}
91+
// 2.2 Otherwise, mark as failed
92+
else if (totalResponses === numberOfFoundNodes) {
93+
this.logger.warn(
94+
`[PUBLISH] Failed for operationId: ${operationId}, ` +
95+
`only ${completedNumber}/${minAckResponses} nodes responded successfully`,
96+
);
97+
await this.markOperationAsFailed(
98+
operationId,
99+
blockchain,
100+
'Not replicated to enough nodes!',
101+
this.errorType,
102+
);
103+
this.operationIdService.emitChangeEvent(
104+
OPERATION_ID_STATUS.PUBLISH.PUBLISH_FAILED,
105+
operationId,
106+
);
107+
this.logResponsesSummary(completedNumber, failedNumber);
98108
}
99109
// else {
100110
// // 3. Not all responses have arrived yet.

0 commit comments

Comments
 (0)