Skip to content

Commit

Permalink
Merge pull request #3611 from OriginTrail/v8/develop
Browse files Browse the repository at this point in the history
Sigma 18 Devnet Release
  • Loading branch information
Mihajlo-Pavlovic authored Dec 25, 2024
2 parents e6e16d7 + 4a18b32 commit 91aa24e
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 102 deletions.
12 changes: 6 additions & 6 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@
"enabled": false,
"package": "./blockchain/implementation/ot-parachain/ot-parachain-service.js",
"config": {
"hubContractAddress": "0x94cb4Ce3C6ce3654b0dA47255a2325322DaD5552",
"hubContractAddress": "0xd7d073b560412c6A7F33dD670d323D01061E5DEb",
"rpcEndpoints": [
"https://lofar-testnet.origin-trail.network",
"https://lofar-testnet.origintrail.network"
Expand All @@ -500,7 +500,7 @@
"package": "./blockchain/implementation/gnosis/gnosis-service.js",

"config": {
"hubContractAddress": "0xC2d165484ee044aFCD0F693a84Ae57235FD986fA",
"hubContractAddress": "0x2c08AC4B630c009F709521e56Ac385A6af70650f",
"gasPriceOracleLink": "https://blockscout.chiadochain.net/api/v1/gas-price-oracle",
"rpcEndpoints": ["https://rpc.chiadochain.net"],
"operatorFee": 0
Expand All @@ -511,7 +511,7 @@
"package": "./blockchain/implementation/base/base-service.js",

"config": {
"hubContractAddress": "0x4A0aC589D7469868ff4EC889aa2c7eE43d30d823",
"hubContractAddress": "0xf21CE8f8b01548D97DCFb36869f1ccB0814a4e05",
"rpcEndpoints": ["https://sepolia.base.org"],
"operatorFee": 0
}
Expand Down Expand Up @@ -579,9 +579,9 @@
"gnosis:10200": ["https://rpc.chiadochain.net"]
},
"hubContractAddress": {
"base:84532": "0x4A0aC589D7469868ff4EC889aa2c7eE43d30d823",
"otp:20430": "0x94cb4Ce3C6ce3654b0dA47255a2325322DaD5552",
"gnosis:10200": "0xC2d165484ee044aFCD0F693a84Ae57235FD986fA"
"base:84532": "0xf21CE8f8b01548D97DCFb36869f1ccB0814a4e05",
"otp:20430": "0xd7d073b560412c6A7F33dD670d323D01061E5DEb",
"gnosis:10200": "0x2c08AC4B630c009F709521e56Ac385A6af70650f"
}
}
}
Expand Down
18 changes: 9 additions & 9 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.0.0-sigma.17",
"version": "8.0.0-sigma.18",
"description": "OTNode V8",
"main": "index.js",
"type": "module",
Expand Down Expand Up @@ -81,7 +81,7 @@
"axios": "^1.6.0",
"cors": "^2.8.5",
"deep-extend": "^0.6.0",
"dkg-evm-module": "^8.0.0-sigma.3",
"dkg-evm-module": "^8.0.0-sigma.5",
"dotenv": "^16.0.1",
"ethers": "^5.7.2",
"express": "^4.18.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,18 @@ class HandleGetRequestCommand extends HandleProtocolMessageCommand {

let assertionPromise;

if (isOperationV0) {
if (!assertionId) {
assertionId = await this.tripleStoreService.getLatestAssertionId(
TRIPLE_STORE_REPOSITORIES.PUBLIC_CURRENT,
ual,
);

this.logger.info(
`Found assertion id: ${assertionId}, operation id ${operationId}, ual: ${ual}`,
);
}
if (!assertionId) {
assertionId = await this.tripleStoreService.getLatestAssertionId(
TRIPLE_STORE_REPOSITORIES.PUBLIC_CURRENT,
ual,
);

this.logger.info(
`Found assertion id: ${assertionId}, operation id ${operationId}, ual: ${ual}`,
);
}

if (assertionId) {
// DO NOT RUN THIS IF !assertionId
assertionPromise = this.tripleStoreService
.getV6Assertion(TRIPLE_STORE_REPOSITORIES.PUBLIC_CURRENT, assertionId)
Expand All @@ -145,10 +145,7 @@ class HandleGetRequestCommand extends HandleProtocolMessageCommand {
blockchain,
);

return [
...(fallbackResult.public ?? []),
...(fallbackResult.private ?? []),
];
return fallbackResult;
}

this.operationIdService.emitChangeEvent(
Expand All @@ -161,11 +158,21 @@ class HandleGetRequestCommand extends HandleProtocolMessageCommand {
});
} else {
if (!knowledgeAssetId) {
knowledgeAssetId = await this.blockchainModuleManager.getKnowledgeAssetsRange(
blockchain,
contract,
knowledgeCollectionId,
);
try {
knowledgeAssetId = await this.blockchainModuleManager.getKnowledgeAssetsRange(
blockchain,
contract,
knowledgeCollectionId,
);
} catch (error) {
// Asset created on old content asset storage contract
// TODO: actually it could be other error so we should check that, or add try catch to getKARange function
knowledgeAssetId = {
startTokenId: 1,
endTokenId: 1,
burned: [],
};
}
}
assertionPromise = this.tripleStoreService
.getAssertion(
Expand Down Expand Up @@ -208,7 +215,9 @@ class HandleGetRequestCommand extends HandleProtocolMessageCommand {
const [assertion, metadata] = await Promise.all(promises);

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

Expand Down
5 changes: 1 addition & 4 deletions src/commands/protocols/get/sender/get-find-shard-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ class GetFindShardCommand extends FindShardCommand {
getOperationCommandSequence(nodePartOfShard, commandData) {
const sequence = [];
if (nodePartOfShard) {
// If operationV0 and no assertionId found go directly to networkGet
if (!commandData.isOperationV0 || commandData.assertionId) {
sequence.push('localGetCommand');
}
sequence.push('localGetCommand');
}
sequence.push('networkGetCommand');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,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(
Expand Down
25 changes: 19 additions & 6 deletions src/commands/protocols/get/sender/local-get-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class LocalGetCommand extends Command {
knowledgeCollectionId,
contentType,
assertionId,
isOperationV0,
} = command.data;
let { knowledgeAssetId } = command.data;
await this.operationIdService.updateOperationIdStatus(
Expand Down Expand Up @@ -140,11 +141,20 @@ class LocalGetCommand extends Command {
} else {
// TODO: Do this in clean way
if (!knowledgeAssetId) {
knowledgeAssetId = await this.blockchainModuleManager.getKnowledgeAssetsRange(
blockchain,
contract,
knowledgeCollectionId,
);
try {
knowledgeAssetId = await this.blockchainModuleManager.getKnowledgeAssetsRange(
blockchain,
contract,
knowledgeCollectionId,
);
} catch (error) {
// Asset created on old content asset storage contract
knowledgeAssetId = {
startTokenId: 1,
endTokenId: 1,
burned: [],
};
}
}
assertionPromise = this.tripleStoreService
.getAssertion(
Expand Down Expand Up @@ -188,9 +198,12 @@ class LocalGetCommand extends Command {
const [assertion, metadata] = await Promise.all(promises);

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

if (assertion?.public?.length || assertion?.private?.length || assertion?.length) {
await this.operationService.markOperationAsCompleted(
operationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
OPERATION_STATUS,
OPERATION_ID_STATUS,
PRIVATE_HASH_SUBJECT_PREFIX,
OLD_CONTENT_STORAGE_MAP,
} from '../../../../../constants/constants.js';

class GetRequestCommand extends ProtocolRequestCommand {
Expand Down Expand Up @@ -68,7 +69,13 @@ class GetRequestCommand extends ProtocolRequestCommand {
}

async handleAck(command, responseData) {
const { blockchain, contract, knowledgeCollectionId, knowledgeAssetId } = command.data;
const { blockchain, contract, knowledgeCollectionId, knowledgeAssetId, isOperationV0 } =
command.data;

const isOldContract = Object.values(OLD_CONTENT_STORAGE_MAP).some((ca) =>
ca.toLowerCase().includes(contract.toLowerCase()),
);

if (responseData?.assertion?.public) {
// Only whole collection can be validated not particular KA

Expand All @@ -92,31 +99,47 @@ class GetRequestCommand extends ProtocolRequestCommand {
publicKnowledgeAssetsTriplesGrouped.push(
...kcTools.groupNquadsBySubject(privateHashTriples, true),
);
try {
await this.validationService.validateDatasetOnBlockchain(
publicKnowledgeAssetsTriplesGrouped.map((t) => t.sort()).flat(),
blockchain,
contract,
knowledgeCollectionId,
);

// This is added as support when get starts supporting private for curated paranet
// TODO: This needs to be fixed when paranets are introduced
if (responseData.assertion?.private?.length)
await this.validationService.validatePrivateMerkleRoot(
responseData.assertion.public,
responseData.assertion.private,

if (!isOldContract) {
try {
await this.validationService.validateDatasetOnBlockchain(
publicKnowledgeAssetsTriplesGrouped.map((t) => t.sort()).flat(),
blockchain,
contract,
knowledgeCollectionId,
);
} catch (e) {
return this.handleNack(command, {
errorMessage: e.message,
});

// This is added as support when get starts supporting private for curated paranet
// TODO: This needs to be fixed when paranets are introduced
if (responseData.assertion?.private?.length)
await this.validationService.validatePrivateMerkleRoot(
responseData.assertion.public,
responseData.assertion.private,
);
} catch (e) {
return this.handleNack(command, {
errorMessage: e.message,
});
}
}
}

let updatedResponseData = responseData;

if (isOperationV0) {
// TODO: Extract converting assertion into one array from the object into 1 function since its used for v0
const assertion = [
...(responseData.assertion?.public ?? []),
...(responseData.assertion?.private ?? []),
];

updatedResponseData = { ...responseData, assertion };
}

await this.operationService.processResponse(
command,
OPERATION_REQUEST_STATUS.COMPLETED,
responseData,
updatedResponseData,
);

return ProtocolRequestCommand.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BidSuggestionController extends BaseController {

async handleRequest(req, res) {
try {
const { blockchain, epochsNumber, assertionSize } = req.body;
const { blockchain, epochsNumber, assertionSize } = req.query;
const promises = [
this.blockchainModuleManager.getTimeUntilNextEpoch(blockchain),
this.blockchainModuleManager.getEpochLength(blockchain),
Expand Down
Loading

0 comments on commit 91aa24e

Please sign in to comment.