Lighthouse: Block processing testing

Created on 24 Mar 2019  ·  17Comments  ·  Source: sigp/lighthouse

Description

During the latest spec update and code restructure we lost a lot of our block processing testing.

The objective of this issue is:

implement regression testing that ensures block processing fails when supplied an invalid parameter.

Detail

Block processing lives in the state_processing crate, specifically in the per_block_processing.rs file and per_block_processing/ dir.

Tests should be implemented in a new file: ... state_processing/src/per_block_processing/tests.rs.

The task will primarily consist of:

  • Devise some valid block and accompanying state and ensure it passes block validation.
  • For each test, modify the valid block (or state?) to trigger some invalidity condition and assert that that condition was triggered by inspecting the error chain (i.e., ensure the returned Result is erroneous and the Error is correct).

We have a suite of "builders" in types/src/test_utils/ that are perfect for this task. For example, TestingBeaconBlockBuilder and TestingBeaconStateBuilder will produce valid blocks and states "from thin air", without needing to build a whole chain.

The best resource for learning how to use these builders is in the "old" (circa last week, before a spec update) benching code, which is presently not compiling (sorry). Particularly the BlockBenchingBuilder. I would probably start by copying the BlockBenchingBuilder and modifying it into the BlockProcessingTestBuilder (or w/e, name not well thought out).

I'm imagining this sort of flow:

let spec = ChainSpec::foundation();
let builder = BlockProcessingTestBuilder::new(...);
let (mut block, mut state) = builder.build();

state.slot = 133713
block.slot = 424242;

let result = per_block_processing(&mut state, &block, &spec);

assert_eq!(result, Err(BlockProcessingError(Invalid(BlockInvalid::StateSlotMismatch))));

_Note: this is pseudo-code. Won't compile, may have errors._

test improvement

All 17 comments

@darrenlangley I believe you're interested in this issue :)

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__This issue now has a funding of 350.0 DAI (350.0 USD @ $1.0/DAI) attached to it.__

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__Work has been started__.

These users each claimed they can complete the work by 2 weeks ago.
Please review their action plans below:

1) darrenlangley has been approved to start work.

I will review the block processing code for invalidity conditions (I think there are 10 on last check) and setup the scenarios for each.

Learn more on the Gitcoin Issue Details page.

@darrenlangley Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • [x] reminder (3 days)
  • [ ] escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

Hi @gitcoinbot - just groking and will submit a WIP PR shortly :)

@darrenlangley Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • [x] reminder (3 days)
  • [ ] escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

Hi @gitcoinbot - yes I am working on this task.

Closing in favor of @darrenlangley's issue.

@darrenlangley Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • [x] reminder (3 days)
  • [ ] escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

Hi @gitcoinbot I am still working on this.

@darrenlangley Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

  • [x] reminder (3 days)
  • [ ] escalation to mods (6 days)

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

Hi @gitcoinbot I am still working on this.

Thanks @darrenlangley for keeping us posted here. We've snoozed Gitcoin Bot for 10 days here as I know you've broken this up elsewhere.

This issue is complete! @gitcoinbot you can do your magic :)

⚡️ A tip worth 350.00000 DAI (350.0 USD @ $1.0/DAI) has been granted to @darrenlangley for this issue from @ceresstation. ⚡️

Nice work @darrenlangley! Your tip has automatically been deposited in the ETH address we have on file.

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


__This Bounty has been completed.__

Additional Tips for this Bounty:

  • ceresstation tipped 350.0000 DAI worth 350.0 USD to darrenlangley.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

paulhauner picture paulhauner  ·  4Comments

q9f picture q9f  ·  4Comments

nickoneill picture nickoneill  ·  3Comments

paulhauner picture paulhauner  ·  3Comments

paulhauner picture paulhauner  ·  4Comments