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

PoA: Wait for transition finality before applying #5774

Merged
merged 35 commits into from
Jun 28, 2017
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6ce6434
final engine changes
rphmeier May 29, 2017
b24093b
migration to v13
rphmeier May 29, 2017
e4949f9
Merge branch 'master' into wait-for-transition-finality
rphmeier May 29, 2017
a93fa05
adding and removing pending transitions
rphmeier May 29, 2017
dcd10dd
epoch_transition_for
rphmeier May 29, 2017
1a95a68
port snapshot to new engine methods
rphmeier Jun 1, 2017
d74874b
final validator set interface
rphmeier Jun 6, 2017
416926c
Merge branch 'master' into wait-for-transition-finality
rphmeier Jun 6, 2017
9475b34
fix compiler errors
rphmeier Jun 7, 2017
7306d27
revert v13/epoch_depth transition
rphmeier Jun 7, 2017
07de21a
make call on new epoch
rphmeier Jun 7, 2017
1dc8e5f
rolling finality checker
rphmeier Jun 8, 2017
5ff6cb1
tests for finality checker
rphmeier Jun 8, 2017
848e99f
constructing finality proof upon pending transition
rphmeier Jun 9, 2017
5f37b7c
fix warnings and finality proof checking
rphmeier Jun 9, 2017
308d7ed
fix compiler warnings in tests
rphmeier Jun 9, 2017
9f5e0f4
test fixes
rphmeier Jun 9, 2017
b0f68b3
don't include genesis in finality checking
rphmeier Jun 12, 2017
ca43e5d
change snapshot test chain building logic
rphmeier Jun 12, 2017
0f4edb6
minor refactorings
rphmeier Jun 14, 2017
e414b26
fetch epoch transition based on parent, fix divide-by-zero in SimpleList
rphmeier Jun 14, 2017
0ce1c98
fix formatting
rphmeier Jun 14, 2017
e4346d7
fix ABIs and finality checking in snapshot restoration
rphmeier Jun 15, 2017
5ca71eb
encode signal number in proof
rphmeier Jun 15, 2017
abc88e6
create more blocks at the end of tests
rphmeier Jun 16, 2017
08ce15a
update gist to accurate contract code
rphmeier Jun 16, 2017
b0e5b50
test for epoch_transition_for
rphmeier Jun 16, 2017
365e08f
fix tests with immediateTransitions parameter
rphmeier Jun 16, 2017
a0c93bc
Merge branch 'master' into wait-for-transition-finality
rphmeier Jun 16, 2017
a814791
disable force flag after forcing
rphmeier Jun 19, 2017
201ee03
rename ValidatorsChanged to InitiateChange and finalizeSignal to fina…
rphmeier Jun 19, 2017
b30dccf
a few more validator set tests
rphmeier Jun 19, 2017
3a329ad
Merge branch 'master' into wait-for-transition-finality
rphmeier Jun 19, 2017
6818b75
Merge branch 'master' into wait-for-transition-finality
rphmeier Jun 22, 2017
e30be1c
Merge branch 'master' into wait-for-transition-finality
rphmeier Jun 28, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ethcore/native_contracts/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const SECRETSTORE_ACL_STORAGE_ABI: &'static str = include_str!("res/secretstore_
const VALIDATOR_SET_ABI: &'static str = include_str!("res/validator_set.json");
const VALIDATOR_REPORT_ABI: &'static str = include_str!("res/validator_report.json");

const TEST_VALIDATOR_SET_ABI: &'static str = r#"[{"constant":true,"inputs":[],"name":"transitionNonce","outputs":[{"name":"n","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"newValidators","type":"address[]"}],"name":"setValidators","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getValidators","outputs":[{"name":"vals","type":"address[]"}],"payable":false,"type":"function"},{"inputs":[],"payable":false,"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_parent_hash","type":"bytes32"},{"indexed":true,"name":"_nonce","type":"uint256"},{"indexed":false,"name":"_new_set","type":"address[]"}],"name":"ValidatorsChanged","type":"event"}]"#;
const TEST_VALIDATOR_SET_ABI: &'static str = include_str!("res/test_validator_set.json");

fn build_file(name: &str, abi: &str, filename: &str) {
let code = ::native_contract_generator::generate_module(name, abi).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion ethcore/native_contracts/generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fn generate_functions(contract: &Contract) -> Result<String, Error> {
/// Outputs: {abi_outputs:?}
pub fn {snake_name}<F, U>(&self, call: F, {params}) -> BoxFuture<{output_type}, String>
where
F: Fn(util::Address, Vec<u8>) -> U,
F: FnOnce(util::Address, Vec<u8>) -> U,
U: IntoFuture<Item=Vec<u8>, Error=String>,
U::Future: Send + 'static
{{
Expand Down
8 changes: 8 additions & 0 deletions ethcore/native_contracts/res/test_validator_set.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{"constant":false,"inputs":[{"name":"_validators","type":"address[]"}],"name":"setValidators","outputs":[],"payable":false,"type":"function"},
{"constant":false,"inputs":[{"name":"","type":"address"},{"name":"","type":"bytes"}],"name":"reportMalicious","outputs":[],"payable":false,"type":"function"},
{"constant":false,"inputs":[],"name":"finalizeChange","outputs":[],"payable":false,"type":"function"},
{"constant":true,"inputs":[],"name":"getValidators","outputs":[{"name":"_validators","type":"address[]"}],"payable":false,"type":"function"},
{"constant":false,"inputs":[{"name":"","type":"address"}],"name":"reportBenign","outputs":[],"payable":false,"type":"function"},
{"anonymous":false,"inputs":[{"indexed":true,"name":"_parent_hash","type":"bytes32"},{"indexed":false,"name":"_new_set","type":"address[]"}],"name":"InitiateChange","type":"event"}
]
4 changes: 2 additions & 2 deletions ethcore/native_contracts/res/validator_set.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
{"constant":true,"inputs":[],"name":"transitionNonce","outputs":[{"name":"nonce","type":"uint256"}],"payable":false,"type":"function"},
{"constant":false,"inputs":[],"name":"finalizeChange","outputs":[],"payable":false,"type":"function"},
{"constant":true,"inputs":[],"name":"getValidators","outputs":[{"name":"validators","type":"address[]"}],"payable":false,"type":"function"},
{"anonymous":false,"inputs":[{"indexed":true,"name":"_parent_hash","type":"bytes32"},{"indexed":true,"name":"_nonce","type":"uint256"},{"indexed":false,"name":"_new_set","type":"address[]"}],"name":"ValidatorsChanged","type":"event"}
{"anonymous":false,"inputs":[{"indexed":true,"name":"_parent_hash","type":"bytes32"},{"indexed":false,"name":"_new_set","type":"address[]"}],"name":"InitiateChange","type":"event"}
]
3 changes: 2 additions & 1 deletion ethcore/res/authority_round.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"0x7d577a597b2742b498cb5cf0c26cdcd726d39e6e",
"0x82a978b3f5962a5b0957d9ee9eef472ee55b42f1"
]
}
},
"immediateTransitions": true
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion ethcore/res/validator_contract.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"startStep": 2,
"validators": {
"contract": "0x0000000000000000000000000000000000000005"
}
},
"immediateTransitions": true
}
}
},
Expand Down
44 changes: 36 additions & 8 deletions ethcore/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ impl<'x> OpenBlock<'x> {
author: Address,
gas_range_target: (U256, U256),
extra_data: Bytes,
is_epoch_begin: bool,
) -> Result<Self, Error> {
let state = State::from_existing(db, parent.state_root().clone(), engine.account_start_nonce(), factories)?;
let mut r = OpenBlock {
Expand All @@ -278,7 +279,8 @@ impl<'x> OpenBlock<'x> {
let gas_floor_target = cmp::max(gas_range_target.0, engine.params().min_gas_limit);
let gas_ceil_target = cmp::max(gas_range_target.1, gas_floor_target);
engine.populate_from_parent(&mut r.block.header, parent, gas_floor_target, gas_ceil_target);
engine.on_new_block(&mut r.block, last_hashes)?;
engine.on_new_block(&mut r.block, last_hashes, is_epoch_begin)?;

Ok(r)
}

Expand Down Expand Up @@ -429,7 +431,7 @@ impl<'x> OpenBlock<'x> {

#[cfg(test)]
/// Return mutable block reference. To be used in tests only.
pub fn block_mut (&mut self) -> &mut ExecutedBlock { &mut self.block }
pub fn block_mut(&mut self) -> &mut ExecutedBlock { &mut self.block }
}

impl<'x> IsBlock for OpenBlock<'x> {
Expand Down Expand Up @@ -553,6 +555,7 @@ pub fn enact(
parent: &Header,
last_hashes: Arc<LastHashes>,
factories: Factories,
is_epoch_begin: bool,
) -> Result<LockedBlock, Error> {
{
if ::log::max_log_level() >= ::log::LogLevel::Trace {
Expand All @@ -562,7 +565,19 @@ pub fn enact(
}
}

let mut b = OpenBlock::new(engine, factories, tracing, db, parent, last_hashes, Address::new(), (3141562.into(), 31415620.into()), vec![])?;
let mut b = OpenBlock::new(
engine,
factories,
tracing,
db,
parent,
last_hashes,
Address::new(),
(3141562.into(), 31415620.into()),
vec![],
is_epoch_begin,
)?;

b.set_difficulty(*header.difficulty());
b.set_gas_limit(*header.gas_limit());
b.set_timestamp(header.timestamp());
Expand Down Expand Up @@ -617,9 +632,22 @@ pub fn enact_verified(
parent: &Header,
last_hashes: Arc<LastHashes>,
factories: Factories,
is_epoch_begin: bool,
) -> Result<LockedBlock, Error> {
let view = BlockView::new(&block.bytes);
enact(&block.header, &block.transactions, &view.uncles(), engine, tracing, db, parent, last_hashes, factories)

enact(
&block.header,
&block.transactions,
&view.uncles(),
engine,
tracing,
db,
parent,
last_hashes,
factories,
is_epoch_begin,
)
}

#[cfg(test)]
Expand Down Expand Up @@ -652,7 +680,7 @@ mod tests {
let header = block.header();
let transactions: Result<Vec<_>, Error> = block.transactions().into_iter().map(SignedTransaction::new).collect();
let transactions = transactions?;
enact(&header, &transactions, &block.uncles(), engine, tracing, db, parent, last_hashes, factories)
enact(&header, &transactions, &block.uncles(), engine, tracing, db, parent, last_hashes, factories, false)
}

/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header. Seal the block aferwards
Expand All @@ -677,7 +705,7 @@ mod tests {
let genesis_header = spec.genesis_header();
let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let b = OpenBlock::new(&*spec.engine, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap();
let b = OpenBlock::new(&*spec.engine, Default::default(), false, db, &genesis_header, last_hashes, Address::zero(), (3141562.into(), 31415620.into()), vec![], false).unwrap();
let b = b.close_and_lock();
let _ = b.seal(&*spec.engine, vec![]);
}
Expand All @@ -691,7 +719,7 @@ mod tests {

let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap()
let b = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![], false).unwrap()
.close_and_lock().seal(engine, vec![]).unwrap();
let orig_bytes = b.rlp_bytes();
let orig_db = b.drain();
Expand All @@ -715,7 +743,7 @@ mod tests {

let db = spec.ensure_db_good(get_temp_state_db(), &Default::default()).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let mut open_block = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![]).unwrap();
let mut open_block = OpenBlock::new(engine, Default::default(), false, db, &genesis_header, last_hashes.clone(), Address::zero(), (3141562.into(), 31415620.into()), vec![], false).unwrap();
let mut uncle1_header = Header::new();
uncle1_header.set_extra_data(b"uncle1".to_vec());
let mut uncle2_header = Header::new();
Expand Down
Loading