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

Sigma Testnet Prerelease Fixes #3549

Merged
merged 11 commits into from
Dec 19, 2024
5 changes: 3 additions & 2 deletions ot-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,16 @@ class OTNode {
continue;
}

const { blockchain, contract, tokenId } = ualService.resolveUAL(paranetUAL);
const { blockchain, contract, knowledgeCollectionId } =
ualService.resolveUAL(paranetUAL);
if (!blockchainModuleManager.getImplementationNames().includes(blockchain)) {
this.logger.warn(
`Unable to initialize Paranet with id ${paranetUAL} because of unsupported blockchain implementation`,
);
continue;
}

const paranetId = paranetService.constructParanetId(contract, tokenId);
const paranetId = paranetService.constructParanetId(contract, knowledgeCollectionId);
// eslint-disable-next-line no-await-in-loop
const paranetExists = await blockchainModuleManager.paranetExists(
blockchain,
Expand Down
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-sigma.2",
"version": "8.0.0-sigma.3",
"description": "OTNode V8",
"main": "index.js",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,189 +1,169 @@
export async function up({ context: { queryInterface } }) {
await queryInterface.addIndex('shard', ['blockchain_id'], {
name: 'blockchain_id_index',
});

await queryInterface.addIndex('shard', ['last_dialed'], {
name: 'last_dialed_index',
});

await queryInterface.addIndex('service_agreement', ['blockchain_id'], {
name: 'blockchain_id_index',
});

await queryInterface.addIndex('service_agreement', ['blockchain_id', 'token_id'], {
name: 'blockchain_id_token_id_index',
});

await queryInterface.addIndex('service_agreement', ['token_id'], {
name: 'token_id_index',
});

await queryInterface.addIndex('paranet_synced_asset', ['ual'], {
name: 'ual_index',
});

await queryInterface.addIndex('paranet_synced_asset', ['paranet_ual', 'data_source'], {
name: 'paranet_ual_data_source_index',
});

await queryInterface.addIndex('paranet', ['blockchain_id', 'paranet_id'], {
name: 'blockchain_id_paranet_id_index',
});

await queryInterface.addIndex('missed_paranet_asset', ['paranet_ual'], {
name: 'paranet_ual_index',
});

await queryInterface.addIndex('missed_paranet_asset', ['ual'], {
name: 'ual_index',
});

await queryInterface.addIndex('event', ['name', 'timestamp'], {
name: 'name_timestamp_index',
});

await queryInterface.addIndex('event', ['operation_id'], {
name: 'operation_id_index',
});

await queryInterface.addIndex('commands', ['name', 'status'], {
name: 'name_status_index',
});

await queryInterface.addIndex('commands', ['status', 'started_at'], {
name: 'status_started_at_index',
});

await queryInterface.addIndex('get', ['operation_id'], {
name: 'operation_id_index',
});

await queryInterface.addIndex('publish', ['operation_id'], {
name: 'operation_id_index',
});

await queryInterface.addIndex('update', ['operation_id'], {
name: 'operation_id_index',
});

await queryInterface.addIndex('publish_paranet', ['operation_id'], {
name: 'operation_id_index',
});

await queryInterface.addIndex('get', ['created_at'], {
name: 'created_at_index',
});

await queryInterface.addIndex('publish', ['created_at'], {
name: 'created_at_index',
});

await queryInterface.addIndex('update', ['created_at'], {
name: 'created_at_index',
});

await queryInterface.addIndex('publish_paranet', ['created_at'], {
name: 'created_at_index',
});

await queryInterface.addIndex('get_response', ['operation_id'], {
name: 'operation_id_index',
});

await queryInterface.addIndex('publish_response', ['operation_id'], {
name: 'operation_id_index',
});

await queryInterface.addIndex('update_response', ['operation_id'], {
name: 'operation_id_index',
});

await queryInterface.addIndex('publish_paranet_response', ['operation_id'], {
name: 'operation_id_index',
});

await queryInterface.addIndex('get_response', ['created_at'], {
name: 'created_at_index',
});

await queryInterface.addIndex('publish_response', ['created_at'], {
name: 'created_at_index',
});

await queryInterface.addIndex('update_response', ['created_at'], {
name: 'created_at_index',
});

await queryInterface.addIndex('publish_paranet_response', ['created_at'], {
name: 'created_at_index',
});

await queryInterface.addIndex('blockchain', ['contract'], {
name: 'contract_index',
});
const indexes = [
{ table: 'shard', column: ['blockchain_id'], name: 'shard_blockchain_id_index' },
{ table: 'shard', column: ['last_dialed'], name: 'last_dialed_index' },
{
table: 'service_agreement',
column: ['blockchain_id'],
name: 'service_agreement_blockchain_id_index',
},
{
table: 'service_agreement',
column: ['blockchain_id', 'token_id'],
name: 'blockchain_id_token_id_index',
},
{ table: 'service_agreement', column: ['token_id'], name: 'token_id_index' },
{ table: 'paranet_synced_asset', column: ['ual'], name: 'paranet_synced_asset_ual_index' },
{
table: 'paranet_synced_asset',
column: ['paranet_ual', 'data_source'],
name: 'paranet_ual_data_source_index',
},
{
table: 'paranet',
column: ['blockchain_id', 'paranet_id'],
name: 'blockchain_id_paranet_id_index',
},
{ table: 'missed_paranet_asset', column: ['paranet_ual'], name: 'paranet_ual_index' },
{ table: 'missed_paranet_asset', column: ['ual'], name: 'missed_paranet_asset_ual_index' },
{ table: 'event', column: ['name', 'timestamp'], name: 'name_timestamp_index' },
{ table: 'event', column: ['operation_id'], name: 'event_operation_id_index' },
{ table: 'commands', column: ['name', 'status'], name: 'name_status_index' },
{ table: 'commands', column: ['status', 'started_at'], name: 'status_started_at_index' },
{ table: 'get', column: ['operation_id'], name: 'get_operation_id_index' },
{ table: 'publish', column: ['operation_id'], name: 'publish_operation_id_index' },
{ table: 'update', column: ['operation_id'], name: 'update_operation_id_index' },
{
table: 'publish_paranet',
column: ['operation_id'],
name: 'publish_paranet_operation_id_index',
},
{ table: 'get', column: ['created_at'], name: 'get_created_at_index' },
{ table: 'publish', column: ['created_at'], name: 'publish_created_at_index' },
{ table: 'update', column: ['created_at'], name: 'update_created_at_index' },
{
table: 'publish_paranet',
column: ['created_at'],
name: 'publish_paranet_created_at_index',
},
{
table: 'get_response',
column: ['operation_id'],
name: 'get_response_operation_id_index',
},
{ table: 'publish_response', column: ['operation_id'], name: 'operation_id_index' },
{
table: 'update_response',
column: ['operation_id'],
name: 'update_response_operation_id_index',
},
{
table: 'publish_paranet_response',
column: ['operation_id'],
name: 'publish_paranet_response_operation_id_index',
},
{ table: 'get_response', column: ['created_at'], name: 'get_response_created_at_index' },
{
table: 'publish_response',
column: ['created_at'],
name: 'publish_response_created_at_index',
},
{
table: 'update_response',
column: ['created_at'],
name: 'update_response_created_at_index',
},
{
table: 'publish_paranet_response',
column: ['created_at'],
name: 'publish_paranet_response_created_at_index',
},
{ table: 'blockchain', column: ['contract'], name: 'contract_index' },
];

for (const index of indexes) {
const { table, column, name } = index;

// eslint-disable-next-line no-await-in-loop
const [results] = await queryInterface.sequelize.query(`
SELECT COUNT(1) AS count
FROM INFORMATION_SCHEMA.STATISTICS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = '${table}' AND INDEX_NAME = '${name}';
`);

if (results[0].count === 0) {
// eslint-disable-next-line no-await-in-loop
await queryInterface.addIndex(table, column, { name });
}
}
}

export async function down({ context: { queryInterface } }) {
await queryInterface.removeIndex('shard', 'blockchain_id_index');
await queryInterface.removeIndex('shard', 'shard_blockchain_id_index');

await queryInterface.removeIndex('shard', 'last_dialed_index');

await queryInterface.removeIndex('service_agreement', 'blockchain_id_index');
await queryInterface.removeIndex('service_agreement', 'service_agreement_blockchain_id_index');

await queryInterface.removeIndex('service_agreement', 'blockchain_id_token_id_index');

await queryInterface.removeIndex('service_agreement', 'token_id_index');

await queryInterface.removeIndex('paranet_synced_asset', 'ual_index');
await queryInterface.removeIndex('paranet_synced_asset', 'paranet_synced_asset_ual_index');

await queryInterface.removeIndex('paranet_synced_asset', 'paranet_ual_data_source_index');

await queryInterface.removeIndex('paranet', 'blockchain_id_paranet_id_index');

await queryInterface.removeIndex('missed_paranet_asset', 'paranet_ual_index');

await queryInterface.removeIndex('missed_paranet_asset', 'ual_index');
await queryInterface.removeIndex('missed_paranet_asset', 'missed_paranet_asset_ual_index');

await queryInterface.removeIndex('event', 'name_timestamp_index');

await queryInterface.removeIndex('event', 'operation_id_index');
await queryInterface.removeIndex('event', 'event_operation_id_index');

await queryInterface.removeIndex('commands', 'name_status_index');

await queryInterface.removeIndex('commands', 'status_started_at_index');

await queryInterface.removeIndex('get', 'operation_id_index');
await queryInterface.removeIndex('get', 'get_operation_id_index');

await queryInterface.removeIndex('publish', 'operation_id_index');
await queryInterface.removeIndex('publish', 'publish_operation_id_index');

await queryInterface.removeIndex('update', 'operation_id_index');
await queryInterface.removeIndex('update', 'update_operation_id_index');

await queryInterface.removeIndex('publish_paranet', 'operation_id_index');
await queryInterface.removeIndex('publish_paranet', 'publish_paranet_operation_id_index');

await queryInterface.removeIndex('get', 'created_at_index');
await queryInterface.removeIndex('get', 'get_created_at_index');

await queryInterface.removeIndex('publish', 'created_at_index');
await queryInterface.removeIndex('publish', 'publish_created_at_index');

await queryInterface.removeIndex('update', 'created_at_index');
await queryInterface.removeIndex('update', 'update_created_at_index');

await queryInterface.removeIndex('publish_paranet', 'created_at_index');
await queryInterface.removeIndex('publish_paranet', 'publish_paranet_created_at_index');

await queryInterface.removeIndex('get_response', 'operation_id_index');
await queryInterface.removeIndex('get_response', 'get_response_operation_id_index');

await queryInterface.removeIndex('publish_response', 'operation_id_index');
await queryInterface.removeIndex('publish_response', 'publish_response_operation_id_index');

await queryInterface.removeIndex('update_response', 'operation_id_index');
await queryInterface.removeIndex('update_response', 'update_response_operation_id_index');

await queryInterface.removeIndex('publish_paranet_response', 'operation_id_index');
await queryInterface.removeIndex(
'publish_paranet_response',
'publish_paranet_response_operation_id_index',
);

await queryInterface.removeIndex('get_response', 'created_at_index');
await queryInterface.removeIndex('get_response', 'get_response_created_at_index');

await queryInterface.removeIndex('publish_response', 'created_at_index');
await queryInterface.removeIndex('publish_response', 'publish_response_created_at_index');

await queryInterface.removeIndex('update_response', 'created_at_index');
await queryInterface.removeIndex('update_response', 'update_response_created_at_index');

await queryInterface.removeIndex('publish_paranet_response', 'created_at_index');
await queryInterface.removeIndex(
'publish_paranet_response',
'publish_paranet_response_created_at_index',
);

await queryInterface.removeIndex('blockchain', 'contract_index');
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function down({ context: { queryInterface, Sequelize } }) {
type: Sequelize.STRING,
allowNull: false,
});
await queryInterface.addColumn('publish_response', 'dataset_root', {
await queryInterface.addColumn('get_response', 'dataset_root', {
type: Sequelize.STRING,
allowNull: false,
});
Expand Down
6 changes: 6 additions & 0 deletions v8-data-migration/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,15 @@ export const BATCH_SIZE = 50;
// export const NODERC_CONFIG_PATH =
// '/Users/zvonimir/projects/ot-node/v8-data-migration/.origintrail_noderc';
// export const ENV_PATH = '/Users/zvonimir/projects/ot-node/data-migration/.env';
// export const DEFAULT_CONFIG_PATH = '/Users/zvonimir/projects/ot-node/config/config.json';
// export const DATA_MIGRATION_DIR =
// '/Users/zvonimir/projects/ot-node/v8-data-migration/data/data-migration';
// export const MIGRATION_PROGRESS_FILE =
// '/Users/zvonimir/projects/ot-node/v8-data-migration/data/migrations/v8DataMigration';
// // LOCAL TESTING END

// REMOTE
export const DEFAULT_CONFIG_PATH = '/root/ot-node/current/config/config.json';
export const NODERC_CONFIG_PATH = '/root/ot-node/.origintrail_noderc';
export const DATA_MIGRATION_DIR = '/root/ot-node/data/data-migration';
export const ENV_PATH = '/root/ot-node/current/.env';
Expand Down
Loading
Loading