diff --git a/services/blockchain-connector/shared/sdk/endpoints.js b/services/blockchain-connector/shared/sdk/endpoints.js index b771458ec1..dd7e81dc51 100644 --- a/services/blockchain-connector/shared/sdk/endpoints.js +++ b/services/blockchain-connector/shared/sdk/endpoints.js @@ -303,6 +303,18 @@ const getGenerators = async () => { } }; +const getBFTParameters = async height => { + try { + const bftParameters = await invokeEndpoint('consensus_getBFTParameters', { height }); + return bftParameters; + } catch (err) { + if (err.message.includes(timeoutMessage)) { + throw new TimeoutException("Request timed out when calling 'getBFTParameters'."); + } + throw err; + } +}; + module.exports = { invokeEndpoint, getSchemas, @@ -328,4 +340,5 @@ module.exports = { postTransaction, dryRunTransaction, getGenerators, + getBFTParameters, }; diff --git a/services/blockchain-connector/shared/sdk/events.js b/services/blockchain-connector/shared/sdk/events.js index e6b0293bb8..a99305fbde 100644 --- a/services/blockchain-connector/shared/sdk/events.js +++ b/services/blockchain-connector/shared/sdk/events.js @@ -26,7 +26,7 @@ const { getEventsByHeight, getNodeInfo, getBlockByHeight, - getGenerators, + getBFTParameters, } = require('./endpoints'); const { updateTokenInfo } = require('./token'); const { getPosConstants } = require('./pos'); @@ -73,8 +73,12 @@ const emitNodeEvents = async () => { (latestNodeInfo.height - latestNodeInfo.genesisHeight) % posConstants.roundLength === 1 ) { - const { list: validators } = await getGenerators(); - Signals.get(EVENT_CHAIN_VALIDATORS_CHANGE).dispatch({ nextValidators: validators }); + const bftParameters = await getBFTParameters(latestNodeInfo.height); + Signals.get(EVENT_CHAIN_VALIDATORS_CHANGE).dispatch({ + nextValidators: bftParameters.validators, + certificateThreshold: bftParameters.certificateThreshold, + precommitThreshold: bftParameters.precommitThreshold, + }); } } } diff --git a/services/blockchain-coordinator/shared/eventsScheduler.js b/services/blockchain-coordinator/shared/eventsScheduler.js index d4d78a3e36..281a207b8d 100644 --- a/services/blockchain-coordinator/shared/eventsScheduler.js +++ b/services/blockchain-coordinator/shared/eventsScheduler.js @@ -39,9 +39,8 @@ const scheduleDeleteBlock = async payload => { }; const scheduleUpdatesOnNewRound = async payload => { - const { validators } = payload; logger.debug('Scheduling updates on new round.'); - await eventMessageQueue.add({ validators, isNewRound: true }); + await eventMessageQueue.add({ ...payload, isNewRound: true }); logger.debug('Finished scheduling updates on new round}.'); };