-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Conversation
// Bestow block reward | ||
let res = fields.state.add_balance(&receiver, &reward, CleanupMode::NoEmpty) | ||
.map_err(::error::Error::from) | ||
.and_then(|_| fields.state.commit()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue 1 -> bestow_block_reward
is called from on_close_block
and it does state.commit()
. It shouldn't. What's more this function is called in a loop, so it's possible that there were multiple commits made in a single on_close_block
.
}); | ||
|
||
if let Err(ref e) = res { | ||
warn!("Encountered error on bestowing reward: {}", e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue 2 -> error is silently ignored
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, although would first like to merge large pending PRs that probably affect similar parts of the code (instead of causing more conflicts)
ethcore/src/block.rs
Outdated
@@ -84,6 +84,38 @@ impl Decodable for Block { | |||
} | |||
} | |||
|
|||
/// Container for block traces. | |||
#[derive(Clone)] | |||
pub enum Tracing { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't feel like it's a right place to store this structure.
let traces: Vec<FlatTransactionTraces> = traces.into_iter() | ||
.map(Into::into) | ||
.collect(); | ||
let traces = block.traces().clone().drain(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like unnecessary clone, since block
is discarded anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally agree!
But for now, we can't omit clone()
, cause block
is generic over IsBlock
trait, and IsBlock
has only fn traces(&self)
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's why I wrote, that in next pr
I'll try to reduce number of clones we make during block verification ;)
If you are talking about #7038, it doesn't modify |
::engines::common::bestow_block_reward(block, self.block_reward, empty_step.author()?)?; | ||
let author = empty_step.author()?; | ||
self.machine.add_balance(block, &author, &self.block_reward)?; | ||
self.machine.note_rewards(block, &[(author, self.block_reward)], &[])?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be more efficient if we had only one call to note_rewards
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
changes:
BlockRef
andBlockRefMut
structureTracing
which represents underlaying data better thanOption<Vec<Vec<FlatTrace>>>
bestow_block_reward
function which, I believe, contained bugs. Use machine insteadI next prs
I will get rid ofI'll try to reduce number of clones we make during block verificationBlocksRef
structure and