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

Commit

Permalink
Merge pull request #3809 from ethcore/mining-min-gas-limit
Browse files Browse the repository at this point in the history
block: enforce gas limit falls within engine bounds
  • Loading branch information
gavofyork committed Dec 11, 2016
2 parents d3077c5 + 9252ebf commit b28537a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ethcore/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ impl<'x> OpenBlock<'x> {
r.block.base.header.set_extra_data(extra_data);
r.block.base.header.note_dirty();

engine.populate_from_parent(&mut r.block.base.header, parent, gas_range_target.0, gas_range_target.1);
let gas_floor_target = ::std::cmp::max(gas_range_target.0, engine.params().min_gas_limit);
engine.populate_from_parent(&mut r.block.base.header, parent, gas_floor_target, gas_range_target.1);
engine.on_new_block(&mut r.block);
Ok(r)
}
Expand Down
5 changes: 3 additions & 2 deletions ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ pub trait Engine : Sync + Send {
self.verify_block_basic(header, None).and_then(|_| self.verify_block_unordered(header, None))
}

/// Don't forget to call Super::populate_from_parent when subclassing & overriding.
// TODO: consider including State in the params.
/// Populate a header's fields based on its parent's header.
/// Takes gas floor and ceiling targets.
/// The gas floor target must not be lower than the engine's minimum gas limit.
fn populate_from_parent(&self, header: &mut Header, parent: &Header, _gas_floor_target: U256, _gas_ceil_target: U256) {
header.set_difficulty(parent.difficulty().clone());
header.set_gas_limit(parent.gas_limit().clone());
Expand Down

0 comments on commit b28537a

Please sign in to comment.