-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rewards on closing blocks #6194
Conversation
needs a rebase to master |
ethcore/src/spec/spec.rs
Outdated
@@ -166,9 +168,17 @@ impl From<ethjson::spec::Params> for CommonParams { | |||
nonce_cap_increment: p.nonce_cap_increment.map_or(64, Into::into), | |||
remove_dust_contracts: p.remove_dust_contracts.unwrap_or(false), | |||
wasm: p.wasm.unwrap_or(false), | |||
<<<<<<< HEAD |
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.
Leftovers
ethcore/src/block.rs
Outdated
@@ -196,6 +204,9 @@ pub trait IsBlock { | |||
|
|||
/// Get all uncles in this block. | |||
fn uncles(&self) -> &[Header] { &self.block().uncles } | |||
|
|||
/// Get tracing enabled flag for this block. | |||
fn tracing_enabled(&self) -> &bool { &self.block().tracing_enabled } |
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.
could just return bool
, it's actually smaller than the ref type
ethcore/src/engines/null_engine.rs
Outdated
use engines::Engine; | ||
use block::*; | ||
use util::*; | ||
use engines::{Engine, CloseOutcome}; |
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.
Better not to use glob imports where avoidable
ethcore/src/ethereum/ethash.rs
Outdated
fields.state.add_balance( | ||
u.author(), | ||
&(reward * U256::from(8 + u.number() - current_number) / U256::from(8)), | ||
&(result_uncle_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.
parentheses no longer necessary
Add relnotes label in order to reflect, that transaction id and hash for trace can be null after this change |
ethcore/src/block.rs
Outdated
@@ -419,7 +423,7 @@ impl<'x> OpenBlock<'x> { | |||
let mut s = self; | |||
|
|||
if let Err(e) = s.engine.on_close_block(&mut s.block) { | |||
warn!("Encountered error on closing the block: {}", e); | |||
warn!("Encountered error on closing the block: {}", 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.
dodgy space added (beginning of line)
@@ -429,7 +433,7 @@ impl<'x> OpenBlock<'x> { | |||
s.block.header.set_transactions_root(ordered_trie_root(s.block.transactions.iter().map(|e| e.rlp_bytes().into_vec()))); | |||
} | |||
let uncle_bytes = s.block.uncles.iter().fold(RlpStream::new_list(s.block.uncles.len()), |mut s, u| {s.append_raw(&u.rlp(Seal::With), 1); s} ).out(); | |||
if s.block.header.uncles_hash().is_zero() { | |||
if s.block.header.uncles_hash().is_zero() || s.block.header.uncles_hash() == &SHA3_EMPTY_LIST_RLP { |
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.
any particular reason for this change?
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.
Yes. From my point of view it's a logical flaw. If block is initialized using default construction, uncle_hash won't be zero and won't be set in this method. I assume, that original intent was to set it in this case. You can see the same pattern (checking default values and zero) in this function for other fields. As a result simple integration test with close_and_seal for block failed.
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.
ok that's fair enough.
ethcore/src/engines/mod.rs
Outdated
@@ -229,7 +229,7 @@ pub trait Engine : Sync + Send { | |||
|
|||
/// Block transformation functions, after the transactions. | |||
fn on_close_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error> { | |||
Ok(()) | |||
Ok(()) |
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.
dodgy space added
ethcore/src/ethereum/ethash.rs
Outdated
@@ -24,6 +24,7 @@ use block::*; | |||
use builtin::Builtin; | |||
use vm::EnvInfo; | |||
use error::{BlockError, Error, TransactionError}; | |||
use trace::{Tracer, ExecutiveTracer,RewardType}; |
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.
inconsistent spaces.
ethcore/src/ethereum/ethash.rs
Outdated
CleanupMode::NoEmpty | ||
) | ||
) |
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.
trailing whitespace
ethcore/src/spec/spec.rs
Outdated
@@ -170,7 +170,7 @@ impl From<ethjson::spec::Params> for CommonParams { | |||
wasm: p.wasm.unwrap_or(false), | |||
gas_limit_bound_divisor: p.gas_limit_bound_divisor.into(), | |||
block_reward: p.block_reward.map_or_else(U256::zero, Into::into), | |||
registrar: p.registrar.map_or_else(Address::new, Into::into), | |||
registrar: p.registrar.map_or_else(Address::new, Into::into) |
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 kill the trailing ,
ethcore/src/tests/trace.rs
Outdated
|
||
// Add root block first | ||
let mut root_block = OpenBlock::new( | ||
engine, |
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.
only one indentation needed
ethcore/src/tests/trace.rs
Outdated
|
||
// Add parent block | ||
let mut parent_block = OpenBlock::new( | ||
engine, |
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.
only one indentation needed
(3141562.into(), 31415620.into()), | ||
vec![], | ||
false | ||
).unwrap(); |
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.
should be one indent fewer
ethcore/src/tests/trace.rs
Outdated
|
||
// Test0. Check overall filter | ||
let filter = TraceFilter { | ||
range: (BlockId::Number(1)..BlockId::Number(3)), |
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.
should be one indentation fewer
ethcore/src/trace/types/filter.rs
Outdated
@@ -128,6 +128,10 @@ impl Filter { | |||
let from_matches = self.from_address.matches(&suicide.address); | |||
let to_matches = self.to_address.matches(&suicide.refund_address); | |||
from_matches && to_matches | |||
}, | |||
Action::Reward(ref reward) => { | |||
let to_matches = self.to_address.matches(&reward.author); |
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.
what's the point of let X = ...; X
? why not just ...
?
ethcore/src/trace/types/flat.rs
Outdated
use evm::CallType; | ||
use trace::RewardType; |
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.
tabs! not spaces.
more just did a style review. quite a lot of issues. some were probably just misconfigured editor, others misunderstanding about our house style. one or two, however, were carelessness, which is a bad omen given this is utterly consensus-critical code that you're hacking on. the logic here should be positively and deeply reviewed by at least three experienced core devs before merge. |
@gavofyork I provided the reasoning in the question about logic's change. All other style comments will be fixed with the next commit. |
I will fix build failures and merge to master |
Thanks @debris ! |
Done. I'll merge once CI is green 👍 |
Added tracing of rewards on closing blocks. The following major changes made:
The work was done in terms of #4858