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

Fixes for misbehavior reporting in AuthorityRound #8998

Merged
merged 12 commits into from
Jul 6, 2018

Conversation

andresilva
Copy link
Contributor

@andresilva andresilva commented Jun 27, 2018

  • Use the epoch set when validating
  • Always report on the contract (self.validators)
  • Use correct epoch number when reporting
  • Report skipped primaries when generating seal (otherwise the current sealer won't report misbehavior since it won't verify his own block)

@andresilva andresilva added A0-pleasereview 🤓 Pull request needs code review. M4-core ⛓ Core client code / Rust. labels Jun 27, 2018
@5chdn 5chdn added this to the 1.12 milestone Jun 27, 2018
@andresilva
Copy link
Contributor Author

andresilva commented Jun 27, 2018

Maybe fixes #8994 and #8065. I haven't been able to replicate so far.

let set_number = if self.immediate_transitions {
header.number()
} else {
self.epoch_set(header)?.1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it guaranteed that parent block is already imported when we are doing block_basic verification? If not then zooming to the epoch set will most likely fail. Would be good to have a test case for this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didn't think of this, so it's possible that verify_block_basic is done in parallel and therefore the parent might not be imported yet? This verification must be done in phase 1 since we want TemporarilyInvalid errors to be emitted at this phase (otherwise it won't recover the sync process).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I believe we do that when the block is imported to the queue:
https://github.com/paritytech/parity/blob/7d7d4822a5087b24b49f2a1ddb111f2daa51a017/ethcore/src/verification/verification.rs#L62

And it seems that both Phase 1 and Phase 2 operate on individual blocks, where there is no guarantee that parent block is already imported. We can only check that in Phase 3 (hence original todo comment was saying that bening reporting should be moved further in the verification.

let active_set;
let validators = if self.immediate_transitions {
&*self.validators
let (validators, set_number) = if self.immediate_transitions {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This pattern seems to repeat couple of times, might be worth to extract it to a function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've refactored part of it into the epoch_set function. Unfortunately it's not easy to get the whole pattern into a function since both branches are returning different types (&ValidatorSet vs SimpleList). It could work by returning Box<ValidatorSet> from the function but I can't clone self.validators.

@5chdn
Copy link
Contributor

5chdn commented Jun 29, 2018

Test engines::authority_round::tests::reports_skipped failed.

This was referenced Jun 30, 2018
@andresilva andresilva added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jul 2, 2018
@5chdn
Copy link
Contributor

5chdn commented Jul 5, 2018

Could you give me an ETA?

@5chdn 5chdn added B9-blocker 🚧 This pull request blocks the next release from happening. Use only in extreme cases. P2-asap 🌊 No need to stop dead in your tracks, however issue should be addressed as soon as possible. labels Jul 5, 2018
@andresilva andresilva added A0-pleasereview 🤓 Pull request needs code review. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Jul 5, 2018
@andresilva
Copy link
Contributor Author

I think this is good to review:

  • Created a CowLike type to return borrowed or owned data and refactor the epoch_set duplication
  • Let reporting fail on verify_block_basic:
    • Only authorities can report and it's expected that they'll be up-to-date and importing
    • Even if you are an authority that is syncing the chain the contract will ignore old reports
    • This specific check is only relevant if you're importing (since it checks against wall clock)

Copy link
Collaborator

@tomusdrw tomusdrw left a comment

Choose a reason for hiding this comment

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

LGTM, a comment on why a failure of reporting is allowed would be good for the future.

@@ -1114,8 +1114,10 @@ impl Engine<EthereumMachine> for AuthorityRound {

match verify_timestamp(&self.step.inner, header_step(header, self.empty_steps_transition)?) {
Err(BlockError::InvalidSeal) => {
let set_number = self.epoch_set(header)?.1;
self.validators.report_benign(header.author(), set_number, header.number());
if let Ok((_, set_number)) = self.epoch_set(header) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a comment why it may fail and why it's ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@tomusdrw tomusdrw added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jul 5, 2018
@5chdn
Copy link
Contributor

5chdn commented Jul 5, 2018

Needs a second review, anyone?

@ascjones ascjones merged commit e9bd41b into master Jul 6, 2018
@ascjones ascjones deleted the andre/fix-aura-reporting branch July 6, 2018 09:44
andresilva added a commit that referenced this pull request Jul 6, 2018
* aura: only report after checking for repeated skipped primaries

* aura: refactor duplicate code for getting epoch validator set

* aura: verify_external: report on validator set contract instance

* aura: use correct validator set epoch number when reporting

* aura: use epoch set when verifying blocks

* aura: report skipped primaries when generating seal

* aura: handle immediate transitions

* aura: don't report skipped steps from genesis to first block

* aura: fix reporting test

* aura: refactor duplicate code to handle immediate_transitions

* aura: let reporting fail on verify_block_basic

* aura: add comment about possible failure of reporting
ordian pushed a commit that referenced this pull request Jul 7, 2018
* aura: only report after checking for repeated skipped primaries

* aura: refactor duplicate code for getting epoch validator set

* aura: verify_external: report on validator set contract instance

* aura: use correct validator set epoch number when reporting

* aura: use epoch set when verifying blocks

* aura: report skipped primaries when generating seal

* aura: handle immediate transitions

* aura: don't report skipped steps from genesis to first block

* aura: fix reporting test

* aura: refactor duplicate code to handle immediate_transitions

* aura: let reporting fail on verify_block_basic

* aura: add comment about possible failure of reporting
5chdn added a commit that referenced this pull request Jul 7, 2018
* parity-version: bump stable to 1.10.9

* scripts: remove md5 checksums (#8884)

* Add support for --chain tobalaba (#8870)

* Add support for --chain tobalaba

* Only return error log for rustls (#9025)

* Fixes for misbehavior reporting in AuthorityRound (#8998)

* aura: only report after checking for repeated skipped primaries

* aura: refactor duplicate code for getting epoch validator set

* aura: verify_external: report on validator set contract instance

* aura: use correct validator set epoch number when reporting

* aura: use epoch set when verifying blocks

* aura: report skipped primaries when generating seal

* aura: handle immediate transitions

* aura: don't report skipped steps from genesis to first block

* aura: fix reporting test

* aura: refactor duplicate code to handle immediate_transitions

* aura: let reporting fail on verify_block_basic

* aura: add comment about possible failure of reporting
5chdn added a commit that referenced this pull request Jul 9, 2018
* parity-version: bump beta to 1.11.6

* scripts: remove md5 checksums (#8884)

* Add support for --chain tobalaba

* Convert indents to tabs :)

* Fixes for misbehavior reporting in AuthorityRound (#8998)

* aura: only report after checking for repeated skipped primaries

* aura: refactor duplicate code for getting epoch validator set

* aura: verify_external: report on validator set contract instance

* aura: use correct validator set epoch number when reporting

* aura: use epoch set when verifying blocks

* aura: report skipped primaries when generating seal

* aura: handle immediate transitions

* aura: don't report skipped steps from genesis to first block

* aura: fix reporting test

* aura: refactor duplicate code to handle immediate_transitions

* aura: let reporting fail on verify_block_basic

* aura: add comment about possible failure of reporting

* Only return error log for rustls (#9025)

* Transaction Pool improvements (#8470)

* Don't use ethereum_types in transaction pool.

* Hide internal insertion_id.

* Fix tests.

* Review grumbles.

* Improve should_replace on NonceAndGasPrice (#8980)

* Additional tests for NonceAndGasPrice::should_replace.

* Fix should_replace in the distinct sender case.

* Use natural priority ordering to simplify should_replace.

* Minimal effective gas price in the queue (#8934)

* Minimal effective gas price.

* Fix naming, add test

* Fix minimal entry score and add test.

* Fix worst_transaction.

* Remove effective gas price threshold.

* Don't leak gas_price decisions out of Scoring.

* Never drop local transactions from different senders. (#9002)

* Recently rejected cache for transaction queue (#9005)

* Store recently rejected transactions.

* Don't cache AlreadyImported rejections.

* Make the size of transaction verification queue dependent on pool size.

* Add a test for recently rejected.

* Fix logging for recently rejected.

* Make rejection cache smaller.

* obsolete test removed

* obsolete test removed

* Construct cache with_capacity.

* Optimize pending transactions filter (#9026)

* rpc: return unordered transactions in pending transactions filter

* ethcore: use LruCache for nonce cache

Only clear the nonce cache when a block is retracted

* Revert "ethcore: use LruCache for nonce cache"

This reverts commit b382c19.

* Use only cached nonces when computing pending hashes.

* Give filters their own locks, so that they don't block one another.

* Fix pending transaction count if not sealing.

* Clear cache only when block is enacted.

* Fix RPC tests.

* Address review comments.

* A last bunch of txqueue performance optimizations (#9024)

* Clear cache only when block is enacted.

* Add tracing for cull.

* Cull split.

* Cull after creating pending block.

* Add constant, remove sync::read tracing.

* Reset debug.

* Remove excessive tracing.

* Use struct for NonceCache.

* Fix build

* Remove warnings.

* Fix build again.

* miner: add missing macro use for trace_time

* ci: remove md5 merge leftovers
ordian added a commit to ordian/parity that referenced this pull request Jul 9, 2018
…rp_sync_on_light_client

* 'master' of https://github.com/paritytech/parity:
  Fixes for misbehavior reporting in AuthorityRound (openethereum#8998)
  A last bunch of txqueue performance optimizations (openethereum#9024)
  reduce number of constraints for triedb types (openethereum#9043)
  bump fs-swap to 0.2.3 so it is compatible with osx 10.11 again (openethereum#9050)
  Recursive test (openethereum#9042)
  Introduce more optional features in ethcore (openethereum#9020)
  Update ETSC bootnodes (openethereum#9038)
  Optimize pending transactions filter (openethereum#9026)
  eip160/eip161 spec: u64 -> BlockNumber (openethereum#9044)
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. B9-blocker 🚧 This pull request blocks the next release from happening. Use only in extreme cases. M4-core ⛓ Core client code / Rust. P2-asap 🌊 No need to stop dead in your tracks, however issue should be addressed as soon as possible.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants