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

BLUE-191 Fixed devPubKeys update and added to use maxCyclesShardDataToKeep config from the network #55

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export interface Config {
usePOQo: boolean
// The percentage of votes required to confirm transaction
requiredVotesPercentage: number
// number of recent cycles of shard data to keep
CYCLE_SHARD_STORAGE_LIMIT: number
// max number of recent cycle shard data to keep
maxCyclesShardDataToKeep: number
// the number of cycles within which we want to keep \changes to a config*/
configChangeMaxCyclesToKeep: number
// the number of config changes to keep*/
Expand Down Expand Up @@ -137,7 +137,7 @@ let config: Config = {
stopGossipTxData: false,
usePOQo: true,
requiredVotesPercentage: 2 / 3,
CYCLE_SHARD_STORAGE_LIMIT: 10,
maxCyclesShardDataToKeep: 10,
configChangeMaxCyclesToKeep: 5,
configChangeMaxChangesToKeep: 1000,
}
Expand Down
14 changes: 10 additions & 4 deletions src/Data/Cycles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ export async function processCycles(cycles: P2PTypes.CycleCreatorTypes.CycleData
setShutdownCycleRecord(cycle)
NodeList.toggleFirstNode()
}
// Clean receipts/originalTxs cache that are older than <CYCLE_SHARD_STORAGE_LIMIT> minutes
const cleanupTimestamp = (cycle.start - config.CYCLE_SHARD_STORAGE_LIMIT * 60) * 1000
// Clean receipts/originalTxs cache that are older than <maxCyclesShardDataToKeep> minutes
const cleanupTimestamp = (cycle.start - config.maxCyclesShardDataToKeep * 60) * 1000
cleanOldOriginalTxsMap(cleanupTimestamp)
cleanOldReceiptsMap(cleanupTimestamp)
cleanShardCycleData(cycle.counter - config.maxCyclesShardDataToKeep)
}
} finally {
if (profilerInstance) profilerInstance.profileSectionEnd('process_cycle', false)
Expand Down Expand Up @@ -519,8 +520,13 @@ function updateShardValues(cycle: P2PTypes.CycleCreatorTypes.CycleData): void {
const list = cycleShardData.nodes.map((n) => n['ip'] + ':' + n['port'])
Logger.mainLogger.debug('cycleShardData', cycleShardData.cycleNumber, list.length, stringifyReduce(list))
shardValuesByCycle.set(cycleShardData.cycleNumber, cycleShardData)
if (shardValuesByCycle.size > config.CYCLE_SHARD_STORAGE_LIMIT) {
shardValuesByCycle.delete(shardValuesByCycle.keys().next().value)
}

const cleanShardCycleData = (cycleNumber: number): void => {
for (const [key] of shardValuesByCycle) {
if (key < cycleNumber) {
shardValuesByCycle.delete(key)
}
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/Data/Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,11 +561,12 @@ async function syncFromNetworkConfig(): Promise<any> {
if (tallyItem?.value?.config?.stateManager) {
// Updating the Archiver Config as per the latest Network Config
const {
devPublicKeys,
useNewPOQ: newPOQReceipt,
configChangeMaxChangesToKeep,
configChangeMaxCyclesToKeep,
maxCyclesShardDataToKeep,
} = tallyItem.value.config.stateManager
const devPublicKeys = tallyItem.value.config.debug.devPublicKeys
const devPublicKey =
devPublicKeys &&
Object.keys(devPublicKeys).length >= 3 &&
Expand Down Expand Up @@ -594,6 +595,12 @@ async function syncFromNetworkConfig(): Promise<any> {
configChangeMaxCyclesToKeep !== config.configChangeMaxCyclesToKeep
)
updateConfig({ configChangeMaxCyclesToKeep })
if (
!Utils.isUndefined(maxCyclesShardDataToKeep) &&
typeof maxCyclesShardDataToKeep === typeof config.maxCyclesShardDataToKeep &&
maxCyclesShardDataToKeep !== config.maxCyclesShardDataToKeep
)
updateConfig({ maxCyclesShardDataToKeep })
return tallyItem
}
return null
Expand Down