Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

ExecutedBlock cleanup #7991

Merged
merged 6 commits into from
Feb 27, 2018
Merged

ExecutedBlock cleanup #7991

merged 6 commits into from
Feb 27, 2018

Conversation

debris
Copy link
Collaborator

@debris debris commented Feb 23, 2018

changes:

  • removed redundant BlockRef and BlockRefMut structure
  • added new structure Tracing which represents underlaying data better than Option<Vec<Vec<FlatTrace>>>
  • removed redundant bestow_block_reward function which, I believe, contained bugs. Use machine instead

I next prs I will get rid of BlocksRef structure and I'll try to reduce number of clones we make during block verification

@debris debris added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Feb 23, 2018
// Bestow block reward
let res = fields.state.add_balance(&receiver, &reward, CleanupMode::NoEmpty)
.map_err(::error::Error::from)
.and_then(|_| fields.state.commit());
Copy link
Collaborator Author

@debris debris Feb 23, 2018

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);
Copy link
Collaborator Author

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

@debris debris requested a review from rphmeier February 23, 2018 15:14
Copy link
Collaborator

@tomusdrw tomusdrw left a 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)

@@ -84,6 +84,38 @@ impl Decodable for Block {
}
}

/// Container for block traces.
#[derive(Clone)]
pub enum Tracing {
Copy link
Collaborator

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();
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

@debris debris Feb 23, 2018

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 ;)

@debris
Copy link
Collaborator Author

debris commented Feb 23, 2018

lgtm, although would first like to merge large pending PRs that probably affect similar parts of the code (instead of causing more conflicts)

If you are talking about #7038, it doesn't modify block.rs and conflicts should not exist / or be insignificant

::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)], &[])?;
Copy link
Contributor

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.

@debris debris added A4-gotissues 💥 Pull request is reviewed and has significant issues which must be addressed. and removed A0-pleasereview 🤓 Pull request needs code review. labels Feb 24, 2018
@5chdn 5chdn added this to the 1.10 milestone Feb 24, 2018
@debris debris added A0-pleasereview 🤓 Pull request needs code review. and removed A4-gotissues 💥 Pull request is reviewed and has significant issues which must be addressed. labels Feb 27, 2018
Copy link
Contributor

@andresilva andresilva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@debris debris merged commit df63341 into master Feb 27, 2018
@debris debris deleted the executed_block_cleanup branch February 27, 2018 17:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants