From f6b8dd0e781c1de37656cada098c156e65a01569 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 24 Aug 2016 18:35:53 +0200 Subject: [PATCH] protection from adding empty traces && assertion in traces db (#1994) * protection from readding empty traces && assertion in traces db * simplified assert --- ethcore/src/trace/db.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ethcore/src/trace/db.rs b/ethcore/src/trace/db.rs index 26fb0b1ff..684c12a70 100644 --- a/ethcore/src/trace/db.rs +++ b/ethcore/src/trace/db.rs @@ -262,6 +262,13 @@ impl TraceDatabase for TraceDB where T: DatabaseExtras { /// Traces of import request's enacted blocks are expected to be already in database /// or to be the currently inserted trace. fn import(&self, batch: &DBTransaction, request: ImportRequest) { + // valid (canon): retracted 0, enacted 1 => false, true, + // valid (branch): retracted 0, enacted 0 => false, false, + // valid (bbcc): retracted 1, enacted 1 => true, true, + // invalid: retracted 1, enacted 0 => true, false, + let ret = request.retracted != 0; + let ena = !request.enacted.is_empty(); + assert!(!(ret && !ena)); // fast return if tracing is disabled if !self.tracing_enabled() { return; @@ -278,7 +285,7 @@ impl TraceDatabase for TraceDB where T: DatabaseExtras { } // now let's rebuild the blooms - { + if !request.enacted.is_empty() { let range_start = request.block_number as Number + 1 - request.enacted.len(); let range_end = range_start + request.retracted; let replaced_range = range_start..range_end;