This repository was archived by the owner on Nov 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ExecutedBlock cleanup #7991
Merged
Merged
ExecutedBlock cleanup #7991
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c95f0dd
ExecutedBlock cleanup
debris 07aeb96
Merge branch 'master' into executed_block_cleanup
debris caf0f59
authority round makes only one call to note_rewards
debris bb9816f
Merge branch 'master' into executed_block_cleanup
debris 726311b
move Tracing from block to trace module
debris 915e1a4
removed BlockRef
debris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -393,35 +393,3 @@ pub trait EthEngine: Engine<::machine::EthereumMachine> { | |
|
|
||
| // convenience wrappers for existing functions. | ||
| impl<T> EthEngine for T where T: Engine<::machine::EthereumMachine> { } | ||
|
|
||
| /// Common engine utilities | ||
| pub mod common { | ||
| use block::ExecutedBlock; | ||
| use error::Error; | ||
| use trace::{Tracer, ExecutiveTracer, RewardType}; | ||
| use state::CleanupMode; | ||
|
|
||
| use ethereum_types::{Address, U256}; | ||
|
|
||
| /// Give reward and trace. | ||
| pub fn bestow_block_reward(block: &mut ExecutedBlock, reward: U256, receiver: Address) -> Result<(), Error> { | ||
| let fields = block.fields_mut(); | ||
|
|
||
| // Bestow block reward | ||
| let res = fields.state.add_balance(&receiver, &reward, CleanupMode::NoEmpty) | ||
| .map_err(::error::Error::from) | ||
| .and_then(|_| fields.state.commit()); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue 1 -> |
||
|
|
||
| fields.traces.as_mut().map(move |traces| { | ||
| let mut tracer = ExecutiveTracer::default(); | ||
| tracer.trace_reward(receiver, reward, RewardType::Block); | ||
| traces.push(tracer.drain()) | ||
| }); | ||
|
|
||
| if let Err(ref e) = res { | ||
| warn!("Encountered error on bestowing reward: {}", e); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue 2 -> error is silently ignored |
||
| } | ||
|
|
||
| res | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
blockis 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(), causeblockis generic overIsBlocktrait, andIsBlockhas onlyfn traces(&self)method.Uh oh!
There was an error while loading. Please reload this page.
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