diff --git a/main/src/environment.ts b/main/src/environment.ts index 6f7d3651..9d681c5e 100644 --- a/main/src/environment.ts +++ b/main/src/environment.ts @@ -73,7 +73,7 @@ const preEnv = cleanEnv(process.env, { NETWORK_ID: num(), MODE: str({ choices: Object.values(MODE) }), BATCH_INSERT_CHUNK_SIZE: num({ default: 1000 }), - MAX_ATTEMPTS: num({ default: 200 }), + MAX_ATTEMPTS: num({ default: 100 }), PG_SSL_CA_PATH: str({ default: '' }), PG_SSL_KEY_PATH: str({ default: '' }), PG_SSL_CERT_PATH: str({ default: '' }), diff --git a/main/src/modules/Monitoring/service.ts b/main/src/modules/Monitoring/service.ts index 29d8ba5c..2a5d5db5 100644 --- a/main/src/modules/Monitoring/service.ts +++ b/main/src/modules/Monitoring/service.ts @@ -209,11 +209,6 @@ export class MonitoringService { await this.sliMetrics.add({ entity: 'queue', name: 'not_processed_count', value: missedTasks.length }) - console.log('environment.RESTART_BLOCKS_URI', environment.RESTART_BLOCKS_URI) - console.log('environment.RESTART_ROUNDS_URI', environment.RESTART_ROUNDS_URI) - console.log('environment.RESTART_ERAS_URI', environment.RESTART_ERAS_URI) - console.log('environment.RESTART_BALANCES_URI', environment.RESTART_BALANCES_URI) - try { if (environment.RESTART_BLOCKS_URI) await needle('get', environment.RESTART_BLOCKS_URI) if (environment.RESTART_ROUNDS_URI) await needle('get', environment.RESTART_ROUNDS_URI) diff --git a/main/src/modules/MoonbeamStakingProcessor/round-payout.ts b/main/src/modules/MoonbeamStakingProcessor/round-payout.ts index 83f45653..c663cdcb 100644 --- a/main/src/modules/MoonbeamStakingProcessor/round-payout.ts +++ b/main/src/modules/MoonbeamStakingProcessor/round-payout.ts @@ -52,10 +52,11 @@ export class MoonbeamStakingProcessorRoundPayout { const originalRound: any = await apiAtOriginal.query.parachainStaking.round() const originalRoundNumber = originalRound.current const runtime: any = await apiAtOriginal.query.system.lastRuntimeUpgrade() - this.specVersion = runtime.unwrap().specVersion.toNumber() + const specVersion: any = runtime.unwrap().specVersion.toNumber() + this.specVersion = specVersion logger.info({ - event: `Round Stake ${originalRoundNumber.toString(10)} runtime version is ${this.specVersion}.`, + event: `Round Stake ${originalRoundNumber.toString(10)} runtime version is ${specVersion}.`, }) await this.getCollatorsAndDelegators(apiAtOriginal, apiAtOriginal, /*apiAtPriorRewarded, */ originalRoundNumber) @@ -95,7 +96,8 @@ export class MoonbeamStakingProcessorRoundPayout { const rewardDelay = apiAtRewarded.consts.parachainStaking?.rewardPaymentDelay || new BN(2) const priorRewardedBlockHash: BlockHash = await this.api.rpc.chain.getBlockHash(nowRoundFirstBlock.subn(1)) const runtime: any = await apiAtRewarded.query.system.lastRuntimeUpgrade() - this.specVersion = runtime.unwrap().specVersion.toNumber() + const specVersion: any = runtime.unwrap().specVersion.toNumber() + this.specVersion = specVersion // obtain data from original round const rewardRound: any = await apiAtRewarded.query.parachainStaking.round() @@ -112,7 +114,7 @@ export class MoonbeamStakingProcessorRoundPayout { } logger.info({ - event: `Round ${originalRoundNumber.toString(10)} runtime version is ${this.specVersion}.`, + event: `Round ${originalRoundNumber.toString(10)} runtime version is ${specVersion}.`, }) if (originalRoundBlock.toNumber() === 0) { @@ -162,13 +164,13 @@ export class MoonbeamStakingProcessorRoundPayout { // compute max rounds respecting the current block number and the number of awarded collators let maxRoundChecks = 1 - if (this.specVersion > 1002) { + if (specVersion > 1002) { if (awardedCollatorCount > latestBlockNumber - nowBlockNumber + 1) { await sleep(1000 * awardedCollatorCount * 15) } maxRoundChecks = awardedCollatorCount } - if (this.specVersion >= 2000 && maxRoundChecks === 68) { + if (specVersion >= 2000 && maxRoundChecks === 68) { maxRoundChecks = 72 } @@ -202,15 +204,23 @@ export class MoonbeamStakingProcessorRoundPayout { //apiAtPriorRewarded: ApiPromise, roundNumber: number, ): Promise { + const specVersion: any = (await apiAtOriginal.query.system.lastRuntimeUpgrade()).unwrap().specVersion.toNumber() + const atStake: any = await apiAtOriginal.query.parachainStaking.atStake.entries(roundNumber) + console.log('getCollatorsAndDelegators AFTER') for (const [ { args: [_, accountId], }, value, ] of atStake) { - const { bond, total, delegations, nominators } = this.specVersion < 2600 ? value : value.unwrap() + //console.log("VALUE", value) + const { bond, total, delegations, nominators } = specVersion < 2600 ? value : value.unwrap() + console.log('BOND', bond) + console.log('total', total) + console.log('delegations', delegations.length) + //console.log("nominators", nominators.length) const collatorId = accountId.toHex() this.collators.add(collatorId) @@ -318,6 +328,7 @@ export class MoonbeamStakingProcessorRoundPayout { const apiAtBlock = await this.api.at(nowRoundRewardBlockHash) const apiAtPreviousBlock = await this.api.at(await this.api.rpc.chain.getBlockHash(rewardedBlockNumber.toNumber() - 1)) const round: any = await apiAtBlock.query.parachainStaking.round() + const specVersion: any = (await apiAtBlock.query.system.lastRuntimeUpgrade()).unwrap().specVersion.toNumber() logger.info({ event: 'RoundPayoutProcessor.getRewardedFromEventsAtBlock', @@ -358,7 +369,7 @@ export class MoonbeamStakingProcessorRoundPayout { }) } - if (this.specVersion >= 2000) { + if (specVersion >= 2000) { // Now orbiters have their own event. To replicate previous behavior, // we take the collator associated and mark rewards as if they were // to the collator @@ -416,14 +427,14 @@ export class MoonbeamStakingProcessorRoundPayout { return } - if (this.specVersion === 1001 || this.specVersion === 1002) { + if (specVersion === 1001 || specVersion === 1002) { if (reward.collator_id) { //runtime 1001, otherwise it should be defined in previous step. collatorInfo = this.stakedValue[reward.collator_id] } else { return } - } else if (this.specVersion <= 900) { + } else if (specVersion <= 900) { for (const collator of Object.values(this.stakedValue)) { if ( !collator.rewardCollator.isZero() && diff --git a/main/src/modules/MoonbeamStakingProcessor/service.ts b/main/src/modules/MoonbeamStakingProcessor/service.ts index 685b0e6a..03838211 100644 --- a/main/src/modules/MoonbeamStakingProcessor/service.ts +++ b/main/src/modules/MoonbeamStakingProcessor/service.ts @@ -16,7 +16,7 @@ import { ENTITY, ProcessingTaskModel, PROCESSING_STATUS } from '@/models/process /** * Please check this repo * https://github.com/PureStake/moonbeam.git - * + * * and test scripts like: * test/suites/smoke/test-staking-round-cleanup.ts */ @@ -132,8 +132,9 @@ export class MoonbeamStakingProcessorService { } logger.info({ - event: `Round ${round.id.toString(10)} staking processing finished in ${(Date.now() - startProcessingTime) / 1000 - } seconds.`, + event: `Round ${round.id.toString(10)} staking processing finished in ${ + (Date.now() - startProcessingTime) / 1000 + } seconds.`, }) await this.sliMetrics.add({ @@ -279,8 +280,9 @@ export class MoonbeamStakingProcessorService { } logger.info({ - event: `Round ${round.id.toString(10)} staking processing finished in ${(Date.now() - startProcessingTime) / 1000 - } seconds.`, + event: `Round ${round.id.toString(10)} staking processing finished in ${ + (Date.now() - startProcessingTime) / 1000 + } seconds.`, }) await this.sliMetrics.add({