diff --git a/src/crons/cache.warmer/cache.warmer.service.ts b/src/crons/cache.warmer/cache.warmer.service.ts index 8d8126755..8b4063a67 100644 --- a/src/crons/cache.warmer/cache.warmer.service.ts +++ b/src/crons/cache.warmer/cache.warmer.service.ts @@ -135,6 +135,11 @@ export class CacheWarmerService { @Lock({ name: 'Node auction invalidations', verbose: true }) async handleNodeAuctionInvalidations() { + const currentEpoch = await this.blockService.getCurrentEpoch(); + if (currentEpoch < this.apiConfigService.getStakingV4ActivationEpoch()) { + return; + } + // wait randomly between 1 and 2 seconds to avoid all nodes refreshing at the same time await new Promise(resolve => setTimeout(resolve, 1000 + 1000 * Math.random())); diff --git a/src/endpoints/network/network.service.ts b/src/endpoints/network/network.service.ts index 376187770..ae0aeab7e 100644 --- a/src/endpoints/network/network.service.ts +++ b/src/endpoints/network/network.service.ts @@ -113,8 +113,10 @@ export class NetworkService { const egldPrice = await this.dataApiService.getEgldPrice(); const tokenMarketCap = await this.tokenService.getTokenMarketCapRaw(); + const currentEpoch = await this.blockService.getCurrentEpoch(); + let totalWaitingStake: BigInt = BigInt(0); - if (!this.apiConfigService.isStakingV4Enabled()) { + if (!this.apiConfigService.isStakingV4Enabled() || currentEpoch < this.apiConfigService.getStakingV4ActivationEpoch()) { totalWaitingStake = await this.getTotalWaitingStake(); } diff --git a/src/endpoints/nodes/node.service.ts b/src/endpoints/nodes/node.service.ts index 8bd63e281..55acc303a 100644 --- a/src/endpoints/nodes/node.service.ts +++ b/src/endpoints/nodes/node.service.ts @@ -388,7 +388,8 @@ export class NodeService { await this.applyNodeStakeInfo(nodes); - if (this.apiConfigService.isStakingV4Enabled()) { + const currentEpoch = await this.blockService.getCurrentEpoch(); + if (this.apiConfigService.isStakingV4Enabled() && currentEpoch >= this.apiConfigService.getStakingV4ActivationEpoch()) { const auctions = await this.gatewayService.getValidatorAuctions(); await this.processAuctions(nodes, auctions); } diff --git a/src/test/unit/services/nodes.spec.ts b/src/test/unit/services/nodes.spec.ts index 5c9f129f0..48c5d4b26 100644 --- a/src/test/unit/services/nodes.spec.ts +++ b/src/test/unit/services/nodes.spec.ts @@ -493,7 +493,7 @@ describe('NodeService', () => { const result = await nodeService.deleteOwnersForAddressInCache(address); expect(result).toEqual([]); - expect(currentEpochSpy).toHaveBeenCalledTimes(1); + expect(currentEpochSpy).toHaveBeenCalledTimes(2); expect(allNodesSpy).toHaveBeenCalledTimes(1); }); }); @@ -539,7 +539,7 @@ describe('NodeService', () => { undefined, ] ); - expect(currentEpochSpy).toHaveBeenCalledTimes(1); + expect(currentEpochSpy).toHaveBeenCalledTimes(2); }); });