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

Advance AuRa step as far as we can and prevent invalid blocks. #7451

Merged
merged 10 commits into from
Jan 8, 2018

Conversation

tomusdrw
Copy link
Collaborator

@tomusdrw tomusdrw commented Jan 4, 2018

Currently the step might be lagging behind since we are relying on perfect timing of timeout invocation. In case event loop is busy doing some other stuff this might not happen and the step will off by one.

Since we are accepting a future-step blocks (window of 1), sometimes this may trigger sealing a new block with step < parent_step especially if timeout did not run.

The change introduces a check for that in generate_seal and also attempts to progress the step as far as possible by looping inside timeout callback.

Also the timeout is now triggered more often, but I'm not super convinced it improves anything - let me know.

Resolves #7441 #5689

@tomusdrw tomusdrw added A0-pleasereview 🤓 Pull request needs code review. B0-patch M4-core ⛓ Core client code / Rust. labels Jan 4, 2018
@tomusdrw tomusdrw changed the title Advance AuRa step as far as we can. Advance AuRa step as far as we can and prevent invalid blocks. Jan 4, 2018
engine.step();
}

let next_run_at = engine.step.duration_remaining().as_millis() >> 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is too much.

@tomusdrw
Copy link
Collaborator Author

tomusdrw commented Jan 5, 2018

@ddorgan did some tests with this PR and it seems the warnings are still produces, so there are still some circumstances under which invalid block is produced, but prevented by the check in this PR.

@5chdn 5chdn added this to the 1.9 milestone Jan 5, 2018
@5chdn 5chdn mentioned this pull request Jan 5, 2018
@rphmeier
Copy link
Contributor

rphmeier commented Jan 5, 2018

Wouldn't it be better to just delay blocks offset by one step as well?

@tomusdrw
Copy link
Collaborator Author

tomusdrw commented Jan 8, 2018

@rphmeier Fixed. I removed the acceptance threshold for future blocks.

@rphmeier rphmeier merged commit 33b8f28 into master Jan 8, 2018
@5chdn 5chdn deleted the td-aura-step branch January 8, 2018 13:49
debris pushed a commit that referenced this pull request Jan 8, 2018
* Advance AuRa step as far as we can.

* Wait for future blocks.
@5chdn 5chdn added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 8, 2018
tomusdrw added a commit that referenced this pull request Jan 8, 2018
* Advance AuRa step as far as we can.

* Wait for future blocks.
tomusdrw added a commit that referenced this pull request Jan 8, 2018
* Advance AuRa step as far as we can.

* Wait for future blocks.
5chdn pushed a commit that referenced this pull request Jan 8, 2018
* Merge pull request #7368 from paritytech/td-future-blocks

Wait for future blocks in AuRa

* Advance AuRa step as far as we can and prevent invalid blocks. (#7451)

* Advance AuRa step as far as we can.

* Wait for future blocks.

* 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).

* Fix tests.

* detect different node, same-key signing in aura (#7245)

* detect different node, same-key signing in aura

* reduce scope of warning
5chdn pushed a commit that referenced this pull request Jan 9, 2018
* Merge pull request #7368 from paritytech/td-future-blocks

Wait for future blocks in AuRa

* Fix tracing failed calls.

* Problem: sending any Whisper message fails

The error is "PoW too low to compete with other messages"

This has been previously reported in #7144

Solution: prevent the move semantics

The source of the error is in PoolHandle.relay
implementation for NetPoolHandle.

Because of the move semantics, `res` variable is in fact
copied (as it implements Copy) into the closure and for
that reason, the returned result is always `false.

* Merge pull request #7433 from paritytech/td-strict-config

Strict config parsing

* 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).

* Merge pull request #7437 from paritytech/a5-chains-expanse

Remove expanse chain

* Expanse Byzantium update w/ correct metropolis difficulty increment divisor (#7463)

* Byzantium Update for Expanse

Here the changes go. Hope I didnt miss anything.

* expip2 changes - update duration limit

* Fix missing EXPIP-2 fields

* Format numbers as hex

* Fix compilation errors

* Group expanse chain spec fields together

* Set metropolisDifficultyIncrementDivisor for Expanse

* Revert #7437

* Add Expanse block 900_000 hash checkpoint

* Advance AuRa step as far as we can and prevent invalid blocks. (#7451)

* Advance AuRa step as far as we can.

* Wait for future blocks.

* fixed panic when io is not available for export block, closes #7486 (#7495)

* Update Parity Mainnet Bootnodes (#7476)

* Update Parity Mainnet Bootnodes

* Replace the Azure HDD bootnodes with the new ones :)

* Use https connection (#7503)

Use https when connecting to etherscan.io API for price-info

* Expose default gas price percentile configuration in CLI (#7497)

* Expose gas price percentile.

* Fix light eth_call.

* fix gas_price in light client
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants