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

OriginTrail Testnet Prerelease v6.0.19 #2775

Merged
merged 20 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
fac3fcd
Fix provider logger
Mihajlo-Pavlovic Nov 7, 2023
6565245
Add log call argument names
Mihajlo-Pavlovic Nov 7, 2023
13805c4
Remove logging result for estimateGas method
Mihajlo-Pavlovic Nov 8, 2023
da8fab6
Add function name and arguments to executeContractFunction and callCo…
Mihajlo-Pavlovic Nov 8, 2023
cf2ee30
Make logs more readable by writing argName=argValue
Mihajlo-Pavlovic Nov 8, 2023
071ca6e
Remove empty proof check
Mihajlo-Pavlovic Nov 8, 2023
0a2c679
Make executeContractFunction and callContractFunction logs more reada…
Mihajlo-Pavlovic Nov 8, 2023
578c4b5
Added try-catch for commits/proofs scheduling
u-hubar Nov 8, 2023
85f3005
Set version
Mihajlo-Pavlovic Nov 8, 2023
84eb3ee
Merge pull request #2771 from OriginTrail/fix/remove-empty-proof-check
u-hubar Nov 8, 2023
d6e5b62
Merge branch 'v6/develop' into v6/fix/fallback-provider-logger
u-hubar Nov 8, 2023
d318931
Merge branch 'v6/develop' into fix/epoch-check-command-unstuck
u-hubar Nov 8, 2023
6cd7a02
Remove noArgs
Mihajlo-Pavlovic Nov 8, 2023
35ba6cf
Merge pull request #2772 from OriginTrail/fix/epoch-check-command-uns…
u-hubar Nov 8, 2023
6f9e3b4
Merge branch 'v6/develop' into v6/fix/fallback-provider-logger
u-hubar Nov 8, 2023
272a89e
Merge pull request #2770 from OriginTrail/v6/fix/fallback-provider-lo…
NZT48 Nov 8, 2023
7fad035
Merge branch 'v6/prerelease/devnet' into v6/develop
NZT48 Nov 8, 2023
a9abd63
Merge pull request #2773 from OriginTrail/v6/develop
NZT48 Nov 8, 2023
eb4891b
Merge pull request #2774 from OriginTrail/v6/prerelease/devnet
NZT48 Nov 8, 2023
37dbc95
Merge branch 'v6/prerelease/testnet' into v6/development-network
NZT48 Nov 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.0.18",
"version": "6.0.19",
"description": "OTNode V6",
"main": "index.js",
"type": "module",
Expand Down
127 changes: 75 additions & 52 deletions src/commands/protocols/common/epoch-check-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
COMMAND_RETRIES,
TRANSACTION_CONFIRMATIONS,
OPERATION_ID_STATUS,
ERROR_TYPE,
} from '../../../constants/constants.js';

class EpochCheckCommand extends Command {
Expand All @@ -16,6 +17,8 @@ class EpochCheckCommand extends Command {
this.shardingTableService = ctx.shardingTableService;
this.blockchainModuleManager = ctx.blockchainModuleManager;
this.serviceAgreementService = ctx.serviceAgreementService;

this.errorType = ERROR_TYPE.COMMIT_PROOF.EPOCH_CHECK_ERROR;
}

async execute(command) {
Expand Down Expand Up @@ -99,43 +102,56 @@ class EpochCheckCommand extends Command {
for (const serviceAgreement of eligibleAgreementForSubmitCommit) {
if (scheduleSubmitCommitCommands.length >= maxTransactions) break;

const rank = await this.calculateRank(
blockchain,
serviceAgreement.keyword,
serviceAgreement.hashFunctionId,
r2,
);

updateServiceAgreementsLastCommitEpoch.push(
this.repositoryModuleManager.updateServiceAgreementLastCommitEpoch(
serviceAgreement.agreementId,
serviceAgreement.currentEpoch,
),
);
try {
const rank = await this.calculateRank(
blockchain,
serviceAgreement.keyword,
serviceAgreement.hashFunctionId,
r2,
);

if (rank == null) {
this.logger.trace(
`Node not in R2: ${r2} for agreement id: ${serviceAgreement.agreementId}. Skipping scheduling submit commit command.`,
updateServiceAgreementsLastCommitEpoch.push(
this.repositoryModuleManager.updateServiceAgreementLastCommitEpoch(
serviceAgreement.agreementId,
serviceAgreement.currentEpoch,
),
);
continue;
}

if (rank >= r0) {
if (rank == null) {
this.logger.trace(
`Node not in R2: ${r2} for the Service Agreement with the ID: ${serviceAgreement.agreementId}. Skipping scheduling submitCommitCommand.`,
);
continue;
}

if (rank >= r0) {
this.logger.trace(
`Calculated rank: ${
rank + 1
}. Node not in R0: ${r0} for the Service Agreement with the ID: ${
serviceAgreement.agreementId
}. Skipping scheduling submitCommitCommand.`,
);
continue;
}

this.logger.trace(
`Calculated rank: ${rank + 1}. Node not in R0: ${r0} for agreement id: ${
`Calculated rank: ${
rank + 1
}. Node in R0: ${r0} for the Service Agreement with the ID: ${
serviceAgreement.agreementId
}. Skipping scheduling submit commit command.`,
}. Scheduling submitCommitCommand.`,
);

scheduleSubmitCommitCommands.push(
this.scheduleSubmitCommitCommand(serviceAgreement),
);
} catch (error) {
this.logger.warn(
`Failed to schedule submitCommitCommand for the Service Agreement with the ID: ${serviceAgreement.agreementId}. Error message: ${error.message}.`,
);
continue;
}

this.logger.trace(
`Calculated rank: ${rank + 1}. Node in R0: ${r0} for agreement id: ${
serviceAgreement.agreementId
}. Scheduling submit commit command.`,
);

scheduleSubmitCommitCommands.push(this.scheduleSubmitCommitCommand(serviceAgreement));
}
await Promise.all([
...scheduleSubmitCommitCommands,
Expand All @@ -161,32 +177,39 @@ class EpochCheckCommand extends Command {
for (const serviceAgreement of eligibleAgreementsForSubmitProofs) {
if (scheduleSubmitProofCommands.length >= maxTransactions) break;

const eligibleForReward = await this.isEligibleForRewards(
blockchain,
serviceAgreement.agreementId,
serviceAgreement.currentEpoch,
serviceAgreement.stateIndex,
r0,
);
if (eligibleForReward) {
this.logger.trace(
`Node is eligible for rewards for agreement id: ${serviceAgreement.agreementId}. Scheduling submit proof command.`,
try {
const eligibleForReward = await this.isEligibleForRewards(
blockchain,
serviceAgreement.agreementId,
serviceAgreement.currentEpoch,
serviceAgreement.stateIndex,
r0,
);

scheduleSubmitProofCommands.push(
this.scheduleSubmitProofsCommand(serviceAgreement),
if (eligibleForReward) {
this.logger.trace(
`Node is eligible for rewards for the Service Agreement with the ID: ${serviceAgreement.agreementId}. Scheduling submitProofsCommand.`,
);

scheduleSubmitProofCommands.push(
this.scheduleSubmitProofsCommand(serviceAgreement),
);
} else {
this.logger.trace(
`Node is not eligible for rewards for the Service Agreement with the ID: ${serviceAgreement.agreementId}. Skipping scheduling submitProofsCommand.`,
);
}
updateServiceAgreementsLastProofEpoch.push(
this.repositoryModuleManager.updateServiceAgreementLastProofEpoch(
serviceAgreement.agreementId,
serviceAgreement.currentEpoch,
),
);
} else {
this.logger.trace(
`Node is not eligible for rewards for agreement id: ${serviceAgreement.agreementId}. Skipping scheduling submit proof command.`,
} catch (error) {
this.logger.warn(
`Failed to schedule submitProofsCommand for the Service Agreement with the ID: ${serviceAgreement.agreementId}. Error message: ${error.message}.`,
);
continue;
}
updateServiceAgreementsLastProofEpoch.push(
this.repositoryModuleManager.updateServiceAgreementLastProofEpoch(
serviceAgreement.agreementId,
serviceAgreement.currentEpoch,
),
);
}
await Promise.all([
...scheduleSubmitProofCommands,
Expand Down Expand Up @@ -326,7 +349,7 @@ class EpochCheckCommand extends Command {
* @param error
*/
async recover(command, error) {
this.logger.warn(`Failed to execute ${command.name}: error: ${error.message}`);
this.logger.warn(`Failed to execute ${command.name}; Error: ${error.message}`);

return Command.repeat();
}
Expand Down
8 changes: 0 additions & 8 deletions src/commands/protocols/common/submit-proofs-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,6 @@ class SubmitProofsCommand extends Command {
return Command.empty();
}

if (proof.length === 0) {
const errorMessage = `Error during Merkle Proof calculation for blockchain: ${blockchain} agreement id: ${agreementId}, epoch: ${epoch}, state index: ${stateIndex}, proof cannot be empty`;
this.logger.trace(errorMessage);

await this.handleError(operationId, errorMessage, this.errorType, true);
return Command.empty();
}

const transactionCompletePromise = new Promise((resolve, reject) => {
this.blockchainModuleManager.sendProof(
blockchain,
Expand Down
46 changes: 34 additions & 12 deletions src/modules/blockchain/implementation/web3-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Web3Service {
await this.initializeWeb3();
this.startBlock = await this.getBlockNumber();
await this.initializeContracts();
// this.initializeProviderDebugging();
this.initializeProviderDebugging();
}

initializeTransactionQueue(concurrency) {
Expand Down Expand Up @@ -189,32 +189,38 @@ class Web3Service {
const { method } = info.request;

if (['call', 'estimateGas'].includes(method)) {
const contractInstance = this.contractAddresses[info.request.params.to];
const inputData = info.request.params.data;
const contractInstance = this.contractAddresses[info.request.params.transaction.to];
const inputData = info.request.params.transaction.data;
const decodedInputData = this._decodeInputData(
inputData,
contractInstance.interface,
);

const functionFragment = contractInstance.interface.getFunction(
inputData.slice(0, 10),
);
const functionName = functionFragment.name;
const inputs = functionFragment.inputs.map(
(input, i) => `${input.name}=${decodedInputData[i]}`,
);
if (info.backend.error) {
const decodedErrorData = this._decodeErrorData(
info.backend.error,
contractInstance.interface,
);
this.logger.debug(
`${decodedInputData} ${method} has failed; Error: ${decodedErrorData}; ` +
`${functionName}(${inputs}) ${method} has failed; Error: ${decodedErrorData}; ` +
`RPC: ${info.backend.provider.connection.url}.`,
);
} else if (info.backend.result !== undefined) {
let message = `${decodedInputData} ${method} has been successfully executed; `;
let message = `${functionName}(${inputs}) ${method} has been successfully executed; `;

if (info.backend.result !== null) {
if (info.backend.result !== null && method !== 'estimateGas') {
const decodedResultData = this._decodeResultData(
inputData.slice(0, 10),
info.backend.result,
contractInstance.interface,
);
message += `Result: ${decodedResultData} `;
message += `Result: ${decodedResultData}; `;
}

message += `RPC: ${info.backend.provider.connection.url}.`;
Expand Down Expand Up @@ -395,10 +401,17 @@ class Web3Service {
result = await contractInstance[functionName](...args);
} catch (error) {
const decodedErrorData = this._decodeErrorData(error, contractInstance.interface);

const functionFragment = contractInstance.interface.getFunction(
error.transaction.data.slice(0, 10),
);
const inputs = functionFragment.inputs.map(
(input, i) => `${input.name}=${args[i]}`,
);

// eslint-disable-next-line no-await-in-loop
await this.handleError(
Error(`Call failed, reason: ${decodedErrorData}`),
functionName,
Error(`Call ${functionName}(${inputs}) failed, reason: ${decodedErrorData}`),
);
}
}
Expand All @@ -419,9 +432,18 @@ class Web3Service {
gasLimit = await contractInstance.estimateGas[functionName](...args);
} catch (error) {
const decodedErrorData = this._decodeErrorData(error, contractInstance.interface);

const functionFragment = contractInstance.interface.getFunction(
error.transaction.data.slice(0, 10),
);
const inputs = functionFragment.inputs.map(
(input, i) => `${input.name}=${args[i]}`,
);

await this.handleError(
Error(`Gas estimation failed, reason: ${decodedErrorData}`),
functionName,
Error(
`Gas estimation ${functionName}(${inputs}) failed, reason: ${decodedErrorData}`,
),
);
}

Expand Down
Loading