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

[fix] The node may fork quickly after its very first sync on a given currency

parent 250a1c80
......@@ -278,6 +278,8 @@ export class DuniterBlockchain extends MiscIndexedBlockchain {
conf.msWindow = bconf.msWindow;
conf.xpercent = bconf.xpercent;
conf.msValidity = bconf.msValidity;
conf.msPeriod = bconf.msPeriod; // As defined in the protocol for this new parameter
conf.sigReplay = bconf.msPeriod; // As defined in the protocol for this new parameter
conf.stepMax = bconf.stepMax;
conf.medianTimeBlocks = bconf.medianTimeBlocks;
conf.avgGenTime = bconf.avgGenTime;
......
......@@ -107,6 +107,11 @@ export class QuickSynchronizer {
let blocksToSave: BlockDTO[] = [];
for (const block of blocks) {
if (block.number === 0) {
await this.blockchain.saveParametersForRoot(block, this.conf, this.dal)
}
sync_allBlocks.push(block);
// The new kind of object stored
......@@ -265,10 +270,6 @@ export class QuickSynchronizer {
delete sync_memoryWallets[cond]
}
if (block.number === 0) {
await this.blockchain.saveParametersForRoot(block, this.conf, this.dal)
}
// Last block: cautious mode to trigger all the INDEX expiry mechanisms
const { index, HEAD } = await DuniterBlockchain.checkBlock(dto, constants.WITH_SIGNATURES_AND_POW, this.conf, this.dal)
await this.blockchain.pushTheBlock(dto, index, HEAD, this.conf, this.dal, this.logger)
......
......@@ -1134,7 +1134,7 @@ ud0 | UD(0), i.e. initial Universal Dividend
udTime0 | Time of first UD.
udReevalTime0 | Time of first reevaluation of the UD.
sigPeriod | Minimum delay between 2 certifications of a same issuer, in seconds. Must be positive or zero.
msPeriod | Minimum delay between 2 memberships of a same issuer, in seconds. Must be positive or zero.
msPeriod | Minimum delay between 2 memberships of a same issuer, in seconds. Must be positive or zero. Equals to `msWindow`.
sigReplay | Minimum delay between 2 certifications of a same issuer to a same receiver, in seconds. Equals to `msPeriod`.
sigStock | Maximum quantity of active certifications made by member.
sigWindow | Maximum delay a certification can wait before being expired for non-writing.
......
......@@ -17,7 +17,7 @@ import {reduce} from "../../../app/lib/indexer"
import {CommonConstants} from "../../../app/lib/common-libs/constants"
describe('Certification replay', () => writeBasicTestWithConfAnd2Users({
sigReplay: 3,
msWindow: 3, // Implies sigReplay = 3
sigPeriod: 0,
sigValidity: 5,
}, (test) => {
......
......@@ -22,7 +22,7 @@ describe("Membership chainability", function() {
let s1:any, cat:any
const conf = {
msPeriod: 20,
msWindow: 20, // Determies msPeriod
nbCores: 1,
msValidity: 10000,
udTime0: now,
......@@ -40,7 +40,7 @@ describe("Membership chainability", function() {
await s1.commit({ time: now })
await s1.commit({ time: now })
await s1.commit({ time: now, actives: [
'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd:rppB5NEwmdMUCxw3N/QPMk+V1h2Jpn0yxTzdO2xxcNN3MACv6x8vNTChWwM6DOq+kXiQHTczFzoux+82WkMfDQ==:1-12D7B9BEBE941F6929A4A61CDC06DEEEFCB00FD1DA72E42FFF7B19A338D421E1:0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855:cat'
'HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd:oHIjaiAVcmyac13oBirFulXbYqScAAwZIhvLjocqS5oMfF0eLQcvi8S0AIfkaBqhn2CVqxRZgcFBQaYVwLgwCg==:1-07A550E7DC27710610A290E55AA778CE6FA9F776AB777ABF4DB660D7BF0C4117:0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855:cat'
]})
CommonConstants.BLOCK_NEW_GENERATED_VERSION = nowVersion
})
......@@ -69,7 +69,7 @@ describe("Membership chainability", function() {
let s1:any, cat:any
const conf = {
msPeriod: 20,
msWindow: 20,
nbCores: 1,
msValidity: 10000,
udTime0: now,
......@@ -89,7 +89,7 @@ describe("Membership chainability", function() {
it('should refuse a block with a too early membership in it', async () => {
await s1.commitWaitError({
time: now + 20,
actives: ['HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd:SiCD1MSyDiZKWLp/SP/2Vj5T3JMgjNnIIKMI//yvKRdWMzKjEn6/ZT+TCjyjnl85qRfmEuWv1jLmQSoe8GXSDg==:1-0DEE2A8EA05322FCC4355D5F0E7A2830F4A22ACEBDC4B62399484E091A5CCF27:0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855:cat']
actives: ['HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd:d+2p9+qks9XvYZmLMmmwDkyheUuecXaaRtUk2gFi+RDqRG2MOOFzjwBEC8IZzK7gdrzOwPZAMormHZnijPyiCA==:1-B9A509E0CF1B475012846D180EDD98DDC4D10C3B90EA14B1F28ACBA8FEF1FC88:0-E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855:cat']
}, 'ruleMembershipPeriod')
})
......
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