openethereum/ethcore
Yurii Rashkovskii d5b81ead71 Problem: AuRa's unsafeties around step duration (#7282)
Firstly, `Step.duration_remaining` casts it to u32, unnecesarily
limiting it to 2^32. While theoretically this is "good enough" (at 3
seconds steps it provides room for a little over 400 years), it is
still a lossy way to calculate the remaining time until the next step.

Secondly, step duration might be zero, triggering division by zero
in `Step.calibrate`

Solution: rework the code around the fact that duration is
typically in single digits and never grows, hence, it can be represented
by a much narrower range (u16) and this highlights the fact that
multiplying u64 by u16 will only result in an overflow in even further
future, at which point we should panic informatively (if anybody's
still around)

Similarly, panic when it is detected that incrementing the step
counter wrapped around on the overflow of usize.

As for the division by zero, prevent it by making zero an invalid
value for step duration. This will make AuRa log the constraint
mismatch and panic (after all, what purpose would zero step duration
serve? it makes no sense within the definition of the protocol,
as finality can only be achieved as per the specification
if messages are received within the step duration, which would violate
the speed of light and other physical laws in this case).
2017-12-21 14:59:09 +01:00
..
benches Fixes bench and removes rustc_serialize dependency (#5988) 2017-10-11 17:39:12 +07:00
evm rename hash crate to keccak-hash 2017-11-10 20:08:28 +01:00
light Merge branch 'master' into upload-crates 2017-11-17 16:42:41 +01:00
native_contracts updated ethabi to version 4.0 (#6742) 2017-10-16 10:21:35 +02:00
node_filter renamed kvdb_memorydb::in_memory -> kvdb_memorydb::create 2017-10-15 16:17:15 +02:00
res Merge pull request #7222 from ellaismer/ellaism 2017-12-19 09:34:21 -04:00
src Problem: AuRa's unsafeties around step duration (#7282) 2017-12-21 14:59:09 +01:00
types rename hash crate to keccak-hash 2017-11-10 20:08:28 +01:00
vm Merge branch 'master' into upload-crates 2017-11-17 16:42:41 +01:00
wasm pwasm-run-test utility upgrade 2017-12-01 16:41:09 +03:00
Cargo.toml Removed ethcore-util dependency from ethcore-network (#7180) 2017-12-02 10:08:04 +01:00