Commit f9282124 authored by Cédric Moreau's avatar Cédric Moreau

Merge branch 'fix/fork-wot-distance' into dev

parents bf86827f bd13d60e
......@@ -74,6 +74,7 @@ export const ExecuteCommand = () => {
.option('--isolate', 'Avoid the node to send peering or status informations to the network')
.option('--forksize <size>', 'Maximum size of fork window', parseInt)
.option('--notrim', 'Disable the INDEX trimming.')
.option('--notrimc', 'Disable the C_INDEX trimming specifically.')
.option('--memory', 'Memory mode')
;
......
......@@ -17,6 +17,7 @@ export interface ProgramOptions {
mdb?: string
home?: string
notrim?: boolean
notrimc?: boolean // Specificaly disable for c_index
nosbx?: boolean
nopeers?: boolean
nop2p?: boolean
......
......@@ -1089,7 +1089,9 @@ export class FileDAL {
await this.bindexDAL.trimBlocks(maxNumber)
await this.iindexDAL.trimRecords(maxNumber)
await this.mindexDAL.trimRecords(maxNumber)
await this.cindexDAL.trimExpiredCerts(maxNumber)
if (!cliprogram.notrimc) {
await this.cindexDAL.trimExpiredCerts(maxNumber)
}
}
await this.sindexDAL.trimConsumedSource(maxNumber)
await this.dividendDAL.trimConsumedUDs(maxNumber)
......
......@@ -275,8 +275,8 @@ export class GlobalIndexStream extends Duplex {
})
}
if (data.cindex.length) {
await this.updateWotbLinks(data.cindex)
if (sync_cindex.length) {
await this.updateWotbLinks(sync_cindex)
}
gData.gindex.iindex = sync_iindex
gData.gindex.mindex = sync_mindex
......
......@@ -22,6 +22,7 @@ import {dumpWotWizard} from "./dump/wotwizard/wotwizard.dump"
import {OtherConstants} from "../lib/other_constants"
import {Querable, querablep} from "../lib/common-libs/querable"
import {dumpBlocks, dumpForks} from "./dump/blocks/dump.blocks"
import {newResolveTimeoutPromise} from "../lib/common-libs/timeout-promise"
const Table = require('cli-table')
......@@ -88,6 +89,10 @@ module.exports = {
await dumpTable(server, name, cond)
break
case 'wot':
await dumpWot(server)
break
case 'history':
await dumpHistory(server, name)
break
......@@ -181,7 +186,7 @@ async function dumpTable(server: Server, name: string, condition?: string) {
break
case 'c_index':
rows = await server.dal.cindexDAL.findRawWithOrder(criterion, [['writtenOn', false], ['issuer', false], ['receiver', false]])
dump(rows, ['op','issuer','receiver','created_on','written_on','sig','expires_on','expired_on','chainable_on','from_wid','to_wid'])
dump(rows, ['op','issuer','receiver','created_on','written_on','sig','expires_on','expired_on','chainable_on','from_wid','to_wid','replayable_on'])
break
case 's_index':
const rowsTX = await server.dal.sindexDAL.findRawWithOrder(criterion, [['writtenOn', false], ['identifier', false], ['pos', false]])
......@@ -256,6 +261,12 @@ async function dumpHistory(server: Server, pub: string) {
}
}
async function dumpWot(server: Server) {
const data = server.dal.wotb.dumpWoT()
console.log(data)
await newResolveTimeoutPromise(1000, null)
}
async function getDateFor(server: Server, blockstamp: string) {
const b = (await server.dal.getAbsoluteBlockByBlockstamp(blockstamp)) as DBBlock
const s = " " + b.number
......
......@@ -72,6 +72,59 @@ describe('Certification replay', () => writeBasicTestWithConfAnd2Users({
assertEqual(reduce(reducableFromCat).expires_on, now + 4 + 10) // The expiration date should have changed! (this is the interest of a replay)
})
test('should correctly update wotb: current state', async (s1) => {
assertEqual(s1._server.dal.wotb.dumpWoT(), `[M] [E] [R] [I] -> Links[maxCert = 40]
[0] [1] [1] [1] -> 1 |
[1] [1] [1] [1] -> 0 |
`)
})
test('should correctly update wotb: toc joins (t + 6)', async (s1, cat, tac, toc) => {
await s1.commit({ time: now + 6 })
await s1.commit({ time: now + 6 })
await toc.createIdentity()
await cat.cert(toc)
await tac.cert(toc)
await toc.join()
await s1.commit({ time: now + 6 })
assertEqual(s1._server.dal.wotb.dumpWoT(), `[M] [E] [R] [I] -> Links[maxCert = 40]
[0] [1] [1] [2] -> 1 |
[1] [1] [1] [2] -> 0 |
[2] [1] [2] [0] -> 0 | 1 |
`)
})
test('should correctly update wotb: toc => cat', async (s1, cat, tac, toc) => {
await s1.commit({ time: now + 6 })
await toc.cert(cat)
await s1.commit({ time: now + 12 })
assertEqual(s1._server.dal.wotb.dumpWoT(), `[M] [E] [R] [I] -> Links[maxCert = 40]
[0] [1] [2] [2] -> 1 | 2 |
[1] [1] [1] [2] -> 0 |
[2] [1] [2] [1] -> 0 | 1 |
`)
})
test('should correctly update wotb: cat loses 1 cert', async (s1) => {
await s1.commit({ time: now + 12 })
assertEqual(s1._server.dal.wotb.dumpWoT(), `[M] [E] [R] [I] -> Links[maxCert = 40]
[0] [1] [1] [2] -> 2 |
[1] [1] [1] [1] -> 0 |
[2] [1] [2] [1] -> 0 | 1 |
`)
})
test('should correctly update wotb: tac loses 1 cert and gets kicked', async (s1) => {
await s1.commit({ time: now + 14 }) // Change `Time`
await s1.commit({ time: now + 14 }) // Change `MedianTime`
await s1.commit({ time: now + 14 }) // Kick
assertEqual(s1._server.dal.wotb.dumpWoT(), `[M] [E] [R] [I] -> Links[maxCert = 40]
[0] [1] [1] [1] -> 2 |
[1] [0] [0] [1] ->
[2] [1] [2] [1] -> 0 | 1 |
`)
})
after(() => {
CommonConstants.BLOCK_NEW_GENERATED_VERSION = 10
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment