Skip to content

Commit

Permalink
OriginTrail Testnet Prerelease v6.5.1 (#3244)
Browse files Browse the repository at this point in the history
* Updated Simulation script for LinearSum, updated dkg-evm-module package (#3215)

* Add support for BASE blockchain (#3216)

* Default config update

* Fix package path for base integration

* Add base-service implementation

* Add Hub contracts for devnet and testnet

* Version bump

* Fix baseTokenTicker in BaseService

* Update dkg.js version. Add typesrcipt dependecy for hardhat support

* Set version to 6.5.0

* OriginTrail Devnet prerelease v6.5.0  (#3218)

* Updated Simulation script for LinearSum, updated dkg-evm-module package (#3215)

* Add support for BASE blockchain (#3216)

* Default config update

* Fix package path for base integration

* Add base-service implementation

* Add Hub contracts for devnet and testnet

* Version bump

* Fix baseTokenTicker in BaseService

* Update dkg.js version. Add typesrcipt dependecy for hardhat support

* Set version to 6.5.0

---------

Co-authored-by: Uladzislau Hubar <71610423+u-hubar@users.noreply.github.com>

* Fix/get gas price in scripts (#3219)

* Update getGasPrice in set-stake

* Update set-ask getGasPrice

* Version update

* OriginTrail Devnet Release v6.5.0 (#3231)

* branch fix 2

* OriginTrail Devnet Release v6.5.1 (#3243)

* OriginTrail Devnet prerelease v6.5.0  (#3217)

* Updated Simulation script for LinearSum, updated dkg-evm-module package (#3215)

* Add support for BASE blockchain (#3216)

* Default config update

* Fix package path for base integration

* Add base-service implementation

* Add Hub contracts for devnet and testnet

* Version bump

* Fix baseTokenTicker in BaseService

* Update dkg.js version. Add typesrcipt dependecy for hardhat support

* Set version to 6.5.0

---------

Co-authored-by: Uladzislau Hubar <71610423+u-hubar@users.noreply.github.com>

* OriginTrail Devnet Preelease v6.5.0 (#3230)

* Update installer.sh (#3224)

- Added base blockchain integration.

Co-authored-by: Mihajlo Pavlovic <mihajlo.pavlovic@origin-trail.com>

* Base mainnet integration (#3229)

* Add hub contract

* Update set scripts

* Remove hotfix

* Update package-lock

---------

Co-authored-by: Samuel Wamala <35219064+swamala@users.noreply.github.com>

* OriginTrail Devnet Preelease v6.5.1 (#3242)

* Update installer.sh (#3224)

- Added base blockchain integration.

Co-authored-by: Mihajlo Pavlovic <mihajlo.pavlovic@origin-trail.com>

* Base mainnet integration (#3229)

* Add hub contract

* Update set scripts

* Remove hotfix

* Update package-lock

* Fixed removal of the AbortSignal event listener (#3227)

* Increasing number of service agreements considered in command and command executor  (#3241)

* Increase number of service agreements for commits fetched from DB

* Increase number of service agreements for commits fetched from DB

* Increse limit and command queue pararelism

* Add dynamic scaling factor when scheduling commits and proofs

* Migration to remove duplicate service agreements (#3240)

* Add findDuplicateServiceAgreement function

* Expand query in findDuplicateServiceAgreement function

* Add RemoveDuplicateServiceAgreementMigration

* Fix migration queries

* Migration tested and working

* version bump

* Add default connection pool to node (#3238)

* Prune corrupted service agreement (#3237)

* Add removeServiceAgreementsByBlockchainAndContract function

* Change removeServiceAgreementsByBlockchainAndContract to remove all service agreements except ones with  given contract

* Add service agreement pruning migration

* Fix epoch check scaling factor

---------

Co-authored-by: Samuel Wamala <35219064+swamala@users.noreply.github.com>
Co-authored-by: Uladzislau Hubar <71610423+u-hubar@users.noreply.github.com>

---------

Co-authored-by: Uladzislau Hubar <71610423+u-hubar@users.noreply.github.com>
Co-authored-by: Nikola Todorovic <nikolaztodorovic26@gmail.com>
Co-authored-by: Samuel Wamala <35219064+swamala@users.noreply.github.com>

---------

Co-authored-by: djordjekovac <djordje.kovacevic@origin-trail.com>
Co-authored-by: Nikola Todorovic <nikolaztodorovic26@gmail.com>
Co-authored-by: Uladzislau Hubar <71610423+u-hubar@users.noreply.github.com>
Co-authored-by: Samuel Wamala <35219064+swamala@users.noreply.github.com>
  • Loading branch information
5 people authored Jul 18, 2024
1 parent 7b185ce commit 05d2aba
Show file tree
Hide file tree
Showing 12 changed files with 264 additions and 22 deletions.
45 changes: 40 additions & 5 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,14 @@
"port": "3306",
"host": "localhost",
"dialect": "mysql",
"logging": false
"logging": false,
"pool": {
"max": 120,
"min": 0,
"acquire": 60000,
"idle": 10000,
"evict": 1000
}
}
}
}
Expand Down Expand Up @@ -260,7 +267,14 @@
"port": "3306",
"host": "localhost",
"dialect": "mysql",
"logging": false
"logging": false,
"pool": {
"max": 120,
"min": 0,
"acquire": 60000,
"idle": 10000,
"evict": 1000
}
}
}
}
Expand Down Expand Up @@ -413,7 +427,14 @@
"port": "3306",
"host": "localhost",
"dialect": "mysql",
"logging": false
"logging": false,
"pool": {
"max": 120,
"min": 0,
"acquire": 60000,
"idle": 10000,
"evict": 1000
}
}
}
}
Expand Down Expand Up @@ -597,7 +618,14 @@
"port": "3306",
"host": "localhost",
"dialect": "mysql",
"logging": false
"logging": false,
"pool": {
"max": 120,
"min": 0,
"acquire": 60000,
"idle": 10000,
"evict": 1000
}
}
}
}
Expand Down Expand Up @@ -781,7 +809,14 @@
"port": "3306",
"host": "localhost",
"dialect": "mysql",
"logging": false
"logging": false,
"pool": {
"max": 120,
"min": 0,
"acquire": 60000,
"idle": 10000,
"evict": 1000
}
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions ot-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,19 @@ class OTNode {
this.logger,
this.config,
);


MigrationExecutor.executeServiceAgreementPruningMigration(
this.container,
this.logger,
this.config,
);

MigrationExecutor.executeRemoveDuplicateServiceAgreementMigration(
this.container,
this.logger,
this.config,
);
}

checkNodeVersion() {
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": "6.5.0",
"version": "6.5.1",
"description": "OTNode V6",
"main": "index.js",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,15 @@ class BlockchainEpochCheckCommand extends Command {
command.period,
);

const numberOfBlockchains = this.blockchainModuleManager.getImplementationNames().length;

// We don't expect to have this many transactions in one epoch check window.
// This is just to make sure we don't schedule too many commands and block the queue
// TODO: find general solution for all commands scheduling blockchain transactions
totalTransactions = Math.min(totalTransactions, COMMAND_QUEUE_PARALLELISM * 0.3);
totalTransactions = Math.min(
totalTransactions,
Math.floor(COMMAND_QUEUE_PARALLELISM / numberOfBlockchains),
);

const transactionQueueLength =
this.blockchainModuleManager.getTotalTransactionQueueLength(blockchain);
Expand Down
2 changes: 1 addition & 1 deletion src/constants/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ export const ARCHIVE_UPDATE_RESPONSES_FOLDER = 'update_responses';
* How many commands will run in parallel
* @type {number}
*/
export const COMMAND_QUEUE_PARALLELISM = 100;
export const COMMAND_QUEUE_PARALLELISM = 150;

export const GET_LATEST_SERVICE_AGREEMENT_BATCH_SIZE = 50;

Expand Down
60 changes: 60 additions & 0 deletions src/migration/migration-executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import MarkStakingEventsAsProcessedMigration from './mark-staking-events-as-proc
import RemoveServiceAgreementsForChiadoMigration from './remove-service-agreements-for-chiado-migration.js';
import MultipleOpWalletsUserConfigurationMigration from './multiple-op-wallets-user-configuration-migration.js';
import GetOldServiceAgreementsMigration from './get-old-service-agreements-migration.js';
import ServiceAgreementPruningMigration from './service-agreement-pruning-migration.js';
import RemoveDuplicateServiceAgreementMigration from './remove-duplicate-service-agreement-migration.js';

class MigrationExecutor {
static async executePullShardingTableMigration(container, logger, config) {
Expand Down Expand Up @@ -442,6 +444,64 @@ class MigrationExecutor {
}
}

static async executeServiceAgreementPruningMigration(container, logger, config) {
if (
process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT ||
process.env.NODE_ENV === NODE_ENVIRONMENTS.TEST
)
return;

const repositoryModuleManager = container.resolve('repositoryModuleManager');
const blockchainModuleManager = container.resolve('blockchainModuleManager');
const serviceAgreementService = container.resolve('serviceAgreementService');

const migration = new ServiceAgreementPruningMigration(
'serviceAgreementPruningMigration',
logger,
config,
repositoryModuleManager,
blockchainModuleManager,
serviceAgreementService,
);
if (!(await migration.migrationAlreadyExecuted())) {
try {
await migration.migrate();
} catch (error) {
logger.error(
`Unable to execute service agreement pruning migration. Error: ${error.message}`,
);
}
}
}

static async executeRemoveDuplicateServiceAgreementMigration(container, logger, config) {
if (
process.env.NODE_ENV === NODE_ENVIRONMENTS.DEVELOPMENT ||
process.env.NODE_ENV === NODE_ENVIRONMENTS.TEST
)
return;

const repositoryModuleManager = container.resolve('repositoryModuleManager');
const blockchainModuleManager = container.resolve('blockchainModuleManager');

const migration = new RemoveDuplicateServiceAgreementMigration(
'removeDuplicateServiceAgreementMigration',
logger,
config,
repositoryModuleManager,
blockchainModuleManager,
);
if (!(await migration.migrationAlreadyExecuted())) {
try {
await migration.migrate();
} catch (error) {
logger.error(
`Unable to execute service agreement pruning migration. Error: ${error.message}`,
);
}
}
}

static exitNode(code = 0) {
process.exit(code);
}
Expand Down
43 changes: 43 additions & 0 deletions src/migration/remove-duplicate-service-agreement-migration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import BaseMigration from './base-migration.js';

class RemoveDuplicateServiceAgreementMigration extends BaseMigration {
constructor(migrationName, logger, config, repositoryModuleManager, blockchainModuleManager) {
super(migrationName, logger, config);
this.repositoryModuleManager = repositoryModuleManager;
this.blockchainModuleManager = blockchainModuleManager;
}

async executeMigration() {
const blockchainIds = this.blockchainModuleManager.getImplementationNames();

for (const blockchainId of blockchainIds) {
const incorrectServiceAgreementId = [];
const duplicateTokenIdsRestult =
// eslint-disable-next-line no-await-in-loop
await this.repositoryModuleManager.findDuplicateServiceAgreements(blockchainId);
const duplicateTokenIds = duplicateTokenIdsRestult.map((t) => t.dataValues.token_id);
const findDuplicateServiceAgreements =
// eslint-disable-next-line no-await-in-loop
await this.repositoryModuleManager.findServiceAgreementsByTokenIds(
duplicateTokenIds,
blockchainId,
);
for (const serviceAgreement of findDuplicateServiceAgreements) {
const blockchainAssertionId =
// eslint-disable-next-line no-await-in-loop
await this.blockchainModuleManager.getAssertionIdByIndex(
blockchainId,
serviceAgreement.assetStorageContractAddress,
serviceAgreement.tokenId,
serviceAgreement.stateIndex,
);
if (serviceAgreement.assertionId !== blockchainAssertionId) {
incorrectServiceAgreementId.push(serviceAgreement.agreementId);
}
}
// eslint-disable-next-line no-await-in-loop
await this.repositoryModuleManager.removeServiceAgreements(incorrectServiceAgreementId);
}
}
}
export default RemoveDuplicateServiceAgreementMigration;
35 changes: 35 additions & 0 deletions src/migration/service-agreement-pruning-migration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import BaseMigration from './base-migration.js';

class ServiceAgreementPruningMigration extends BaseMigration {
constructor(
migrationName,
logger,
config,
repositoryModuleManager,
blockchainModuleManager,
serviceAgreementService,
) {
super(migrationName, logger, config);
this.repositoryModuleManager = repositoryModuleManager;
this.blockchainModuleManager = blockchainModuleManager;
this.serviceAgreementService = serviceAgreementService;
}

async executeMigration() {
const blockchainIds = this.blockchainModuleManager.getImplementationNames();

// eslint-disable-next-line no-await-in-loop
for (const blockchainId of blockchainIds) {
const assetStorageContractAddresses =
// eslint-disable-next-line no-await-in-loop
await this.blockchainModuleManager.getAssetStorageContractAddresses(blockchainId);

// eslint-disable-next-line no-await-in-loop
await this.repositoryModuleManager.removeServiceAgreementsByBlockchainAndContract(
blockchainId,
assetStorageContractAddresses[0],
);
}
}
}
export default ServiceAgreementPruningMigration;
19 changes: 9 additions & 10 deletions src/modules/network/implementation/libp2p-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,18 +397,17 @@ class Libp2pService {
let readResponseStart;
let readResponseEnd;
let response;
const abortSignalEventListener = async () => {
stream.abort();
response = null;
};
const timeoutController = new TimeoutController(timeout);
try {
readResponseStart = Date.now();

timeoutController.signal.addEventListener(
'abort',
async () => {
stream.abort();
response = null;
},
{ once: true },
);
timeoutController.signal.addEventListener('abort', abortSignalEventListener, {
once: true,
});

response = await this._readMessageFromStream(
stream,
Expand All @@ -420,12 +419,12 @@ class Libp2pService {
throw Error('Message timed out!');
}

timeoutController.signal.removeEventListener('abort');
timeoutController.signal.removeEventListener('abort', abortSignalEventListener);
timeoutController.clear();

readResponseEnd = Date.now();
} catch (error) {
timeoutController.signal.removeEventListener('abort');
timeoutController.signal.removeEventListener('abort', abortSignalEventListener);
timeoutController.clear();

readResponseEnd = Date.now();
Expand Down
Loading

0 comments on commit 05d2aba

Please sign in to comment.