Skip to content
Snippets Groups Projects
Commit bd2d8799 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Hotfix: wrong certifications were included in blocks again (wrong target block...

Hotfix: wrong certifications were included in blocks again (wrong target block + too old target block)
parent a643ff58
No related branches found
No related tags found
No related merge requests found
...@@ -693,6 +693,11 @@ function NextBlockGenerator(conf, dal) { ...@@ -693,6 +693,11 @@ function NextBlockGenerator(conf, dal) {
// The identity must be known // The identity must be known
if (targetIdty) { if (targetIdty) {
const certSig = cert.sig; const certSig = cert.sig;
// Do not rely on certification block UID, prefer using the known hash of the block by its given number
const targetBlock = yield dal.getBlockOrNull(cert.block_number);
// Check if writable
let duration = current ? current.medianTime - parseInt(targetBlock.medianTime) : 0;
if (duration <= conf.sigWindow) {
cert.sig = ''; cert.sig = '';
cert.currency = conf.currency; cert.currency = conf.currency;
cert.issuer = cert.from; cert.issuer = cert.from;
...@@ -700,7 +705,7 @@ function NextBlockGenerator(conf, dal) { ...@@ -700,7 +705,7 @@ function NextBlockGenerator(conf, dal) {
cert.idty_uid = targetIdty.uid; cert.idty_uid = targetIdty.uid;
cert.idty_buid = targetIdty.buid; cert.idty_buid = targetIdty.buid;
cert.idty_sig = targetIdty.sig; cert.idty_sig = targetIdty.sig;
cert.buid = [cert.block_number, cert.block_hash].join('-'); cert.buid = current ? [cert.block_number, targetBlock.hash].join('-') : constants.BLOCK.SPECIAL_BLOCK;
const rawCert = Certification.statics.fromJSON(cert).getRaw(); const rawCert = Certification.statics.fromJSON(cert).getRaw();
if (crypto.verify(rawCert, certSig, cert.from)) { if (crypto.verify(rawCert, certSig, cert.from)) {
cert.sig = certSig; cert.sig = certSig;
...@@ -732,6 +737,7 @@ function NextBlockGenerator(conf, dal) { ...@@ -732,6 +737,7 @@ function NextBlockGenerator(conf, dal) {
} }
} }
} }
}
return updates; return updates;
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment