Skip to content

Commit

Permalink
OriginTrail Devnet Release v6.4.0 Hotfix 5 (#3189)
Browse files Browse the repository at this point in the history
* OriginTrail Devnet Prerelease v6.4.0 Hotfix 4 (#3185)

* OriginTrail Mainnet Prerelease v6.1.1 (#2853)

* Upp sharding table migration enabled

* Update event insert in chunks

* version bump

* Add migration for makring staking events as processed

* Updated migration executor added mark staking events as processed migration

* Updated migration added await on get latest block

* Updated migration for all contracts

* Migration updated

---------

Co-authored-by: NZT48 <nikolaztodorovic26@gmail.com>

* Revert "OriginTrail Devnet Prerelease v6.2.0 Hotfix 10"

* Revert "Merge pull request #2965 from OriginTrail/revert-2964-v6/develop"

This reverts commit d7cd260, reversing
changes made to 491baf8.

* Fix

* Fix/handle state finalized events (#3184)

* Fix getKnowledgeAssetLocatorFromParanetId call in handleStateFinalizedEvents

* Version bump

* Correct version

* Add more fixes

* Fix contract call getKnowledgeAssetLocatorFromParanetId

* Fix getKnowledgeAssetLocatorFromParanetId

* Add check on state finalized to confirm that paranet repo exists

* Fix getKALocator from Paranet ID in handling state finalized

* Fix package lock

---------

Co-authored-by: NZT48 <nikolaztodorovic26@gmail.com>

---------

Co-authored-by: djordjekovac <djordje.kovacevic@origin-trail.com>
Co-authored-by: NZT48 <nikolaztodorovic26@gmail.com>
Co-authored-by: Branimir Rakic <33914812+branarakic@users.noreply.github.com>

* OriginTrail Devnet Prerelease v6.4.0 Hotfix 5 (#3188)

* OriginTrail Mainnet Prerelease v6.1.1 (#2853)

* Upp sharding table migration enabled

* Update event insert in chunks

* version bump

* Add migration for makring staking events as processed

* Updated migration executor added mark staking events as processed migration

* Updated migration added await on get latest block

* Updated migration for all contracts

* Migration updated

---------

Co-authored-by: NZT48 <nikolaztodorovic26@gmail.com>

* Revert "OriginTrail Devnet Prerelease v6.2.0 Hotfix 10"

* Revert "Merge pull request #2965 from OriginTrail/revert-2964-v6/develop"

This reverts commit d7cd260, reversing
changes made to 491baf8.

* Fix

* Fix/handle state finalized events (#3184)

* Fix getKnowledgeAssetLocatorFromParanetId call in handleStateFinalizedEvents

* Version bump

* Correct version

* Add more fixes

* Fix contract call getKnowledgeAssetLocatorFromParanetId

* Fix getKnowledgeAssetLocatorFromParanetId

* Add check on state finalized to confirm that paranet repo exists

* Fix getKALocator from Paranet ID in handling state finalized

* Fix package lock

---------

Co-authored-by: NZT48 <nikolaztodorovic26@gmail.com>

* Fix/add syncing paranets at blockchain check (#3187)

* Add getParanetsBlockchains to repository module manager

* Add check paranets synced at blockchain in event listener

* Version bump

---------

Co-authored-by: djordjekovac <djordje.kovacevic@origin-trail.com>
Co-authored-by: NZT48 <nikolaztodorovic26@gmail.com>
Co-authored-by: Branimir Rakic <33914812+branarakic@users.noreply.github.com>

---------

Co-authored-by: djordjekovac <djordje.kovacevic@origin-trail.com>
Co-authored-by: NZT48 <nikolaztodorovic26@gmail.com>
Co-authored-by: Branimir Rakic <33914812+branarakic@users.noreply.github.com>
  • Loading branch information
4 people authored Jun 7, 2024
1 parent fc3bce7 commit 4fe30a8
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 39 deletions.
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": "6.4.0",
"version": "6.4.0+hotfix.5",
"description": "OTNode V6",
"main": "index.js",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions src/modules/blockchain/implementation/web3-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -1659,8 +1659,8 @@ class Web3Service {

async getKnowledgeAssetLocatorFromParanetId(paranetId) {
const [paranetKAStorageContract, paranetKATokenId] = await this.callContractFunction(
this.ParanetRegistryContract,
'getKnowledgeAssetLocator',
this.ParanetsRegistryContract,
'getParanetKnowledgeAssetLocator',
[paranetId],
);
const tokenId = paranetKATokenId.toNumber();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Sequelize } from 'sequelize';

class ParanetRepository {
constructor(models) {
this.sequelize = models.sequelize;
Expand Down Expand Up @@ -59,6 +61,14 @@ class ParanetRepository {
},
});
}

async getParanetsBlockchains() {
return this.model.findAll({
attributes: [
[Sequelize.fn('DISTINCT', Sequelize.col('blockchain_id')), 'blockchain_id'],
],
});
}
}

export default ParanetRepository;
4 changes: 4 additions & 0 deletions src/modules/repository/repository-module-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,10 @@ class RepositoryModuleManager extends BaseModuleManager {
async getCountOfMissedAssetsOfParanet(ual) {
return this.getRepository('missed_paranet_asset').getCountOfMissedAssetsOfParanet(ual);
}

async getParanetsBlockchains() {
return this.getRepository('paranet').getParanetsBlockchains();
}
}

export default RepositoryModuleManager;
86 changes: 52 additions & 34 deletions src/service/blockchain-event-listener-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
DELAY_BETWEEN_FAILED_FETCH_EVENTS_MILLIS,
CONTRACT_EVENT_TO_GROUP_MAPPING,
GROUPED_CONTRACT_EVENTS,
ZERO_BYTES32,
} from '../constants/constants.js';

const fetchEventsFailedCount = {};
Expand Down Expand Up @@ -578,49 +579,66 @@ class BlockchainEventListenerService {
]);

// eslint-disable-next-line no-await-in-loop
const knowledgeAssetId = await this.paranetService.constructKnowledgeAssetId(
blockchain,
contract,
tokenId,
);
const paranetsBlockchains = await this.repositoryModuleManager.getParanetsBlockchains();

// eslint-disable-next-line no-await-in-loop
const paranetId = await this.blockchainModuleManager.getParanetId(knowledgeAssetId);
if (paranetId) {
const {
knowledgeAssetStorageContract: paranetKasContract,
tokenId: paranetTokenId,
// eslint-disable-next-line no-await-in-loop
} = await this.blockchainModuleManager.getKnowledgeAssetLocatorFromParanetId(
paranetId,
);
const paranetUAL = this.ualService.deriveUAL(
if (paranetsBlockchains.includes(blockchain)) {
// eslint-disable-next-line no-await-in-loop
const knowledgeAssetId = await this.paranetService.constructKnowledgeAssetId(
blockchain,
paranetKasContract,
paranetTokenId,
contract,
tokenId,
);

// eslint-disable-next-line no-await-in-loop
const paranetAssetExists = await this.tripleStoreService.paranetAssetExists(
const paranetId = await this.blockchainModuleManager.getParanetId(
blockchain,
contract,
tokenId,
paranetKasContract,
paranetTokenId,
knowledgeAssetId,
);
if (paranetId && paranetId !== ZERO_BYTES32) {
// eslint-disable-next-line no-await-in-loop
const paranetExists = await this.repositoryModuleManager.paranetExists(
paranetId,
blockchain,
);
if (paranetExists) {
const {
paranetKAStorageContract: paranetKasContract,
tokenId: paranetTokenId,
} =
// eslint-disable-next-line no-await-in-loop
await this.blockchainModuleManager.getKnowledgeAssetLocatorFromParanetId(
blockchain,
paranetId,
);
const paranetUAL = this.ualService.deriveUAL(
blockchain,
paranetKasContract,
paranetTokenId,
);

if (paranetAssetExists) {
const kaUAL = this.ualService.deriveUAL(blockchain, contract, tokenId);
// eslint-disable-next-line no-await-in-loop
const paranetAssetExists = await this.tripleStoreService.paranetAssetExists(
blockchain,
contract,
tokenId,
paranetKasContract,
paranetTokenId,
);

// Create a record for missing Paranet KA
// Paranet sync command will get it from network
// eslint-disable-next-line no-await-in-loop
await this.repositoryModuleManager.createMissedParanetAssetRecord({
blockchainId: blockchain,
ual: kaUAL,
paranetUal: paranetUAL,
knowledgeAssetId,
});
if (paranetAssetExists) {
const kaUAL = this.ualService.deriveUAL(blockchain, contract, tokenId);

// Create a record for missing Paranet KA
// Paranet sync command will get it from network
// eslint-disable-next-line no-await-in-loop
await this.repositoryModuleManager.createMissedParanetAssetRecord({
blockchainId: blockchain,
ual: kaUAL,
paranetUal: paranetUAL,
knowledgeAssetId,
});
}
}
}
}
}
Expand Down

0 comments on commit 4fe30a8

Please sign in to comment.