Skip to content

Add integration tests on block processing#7378

Merged
ahamlat merged 22 commits intobesu-eth:mainfrom
ahamlat:add-integration-tests-on-block-processing
Aug 1, 2024
Merged

Add integration tests on block processing#7378
ahamlat merged 22 commits intobesu-eth:mainfrom
ahamlat:add-integration-tests-on-block-processing

Conversation

@ahamlat
Copy link
Copy Markdown
Contributor

@ahamlat ahamlat commented Jul 25, 2024

PR description

This PR aims to enhance block processing testing, inspired by this comment from @garyschulte regarding test coverage. The goal is to develop unit tests that focus on executing block transactions without concerning header and body validations. For each scenario specified by @matkt, we test both sequential and parallel processing to ensure state changes remain consistent.

The tested cases are:

  • Test 1

    • Trx1: Transfer from a to b
    • Trx2: Transfer from a to c
  • Test 2

    • Trx1: Transfer from a to b
    • Trx2: Transfer from b to c
  • Test 3

    • Trx1: Transfer from a to b
    • Trx2: Transfer from c to d
  • Test 4

    • Trx1: Transfer from a to b
    • Trx2: Transfer from c to coinbase
  • Test 5

    • Trx1: Contract with read from account A
    • Trx2: Contract with update to account A
  • Test 6

    • Trx1: Contract with update to account A
    • Trx2: Contract with read from account A
  • Test 7

    • Trx1: Contract with update to account A
    • Trx2: Contract with read from account B
  • Test 8 (Slots)

    • Trx1: Contract with read from slot S1
    • Trx2: Contract with update to slot S1
  • Test 9 (Slots)

    • Trx1: Contract with update to slot S1
    • Trx2: Contract with read from slot S1
  • Test 10 (Slots)

    • Trx1: Contract with update to slot S1
    • Trx2: Contract with read from slot S2

The Solidity contract file has been added for reference. It represents the smart contract that the bytecode is included in the genesis file. Including this file in the PR helps in understanding the tests.

Fixed Issue(s)

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

ahamlat added 8 commits July 22, 2024 14:28
… parallel execution have the same behaviour

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
…for information.

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Copy link
Copy Markdown
Contributor

@siladu siladu left a comment

Choose a reason for hiding this comment

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

Since it's a large test class, I think readability would be improved if it was a parameterized test with sequentialBlockProcessor and parallelBlockProcessor as the two parameters - what you do think?

ahamlat added 4 commits July 29, 2024 14:12
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
@ahamlat
Copy link
Copy Markdown
Contributor Author

ahamlat commented Jul 29, 2024

Since it's a large test class, I think readability would be improved if it was a parameterized test with sequentialBlockProcessor and parallelBlockProcessor as the two parameters - what you do think?

To be honest, I believe that using parameterized tests may reduce readability. This is because the same test will be executed twice with identical names for both sequential and parallel block processing. At present, each test has a distinct name that clearly indicates its purpose.

Copy link
Copy Markdown
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

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

think renaming the keyPair variables to match the corresponding accounts would help readability

@siladu
Copy link
Copy Markdown
Contributor

siladu commented Jul 30, 2024

This is because the same test will be executed twice with identical names for both sequential and parallel block processing. At present, each test has a distinct name that clearly indicates its purpose.

That's true and it's personal preference whether you like parameterized tests or not. IMO, reducing 20 methods -> 10 methods in a big file is worth it. Also the framework allows you to make the distinction clear, e.g. you can label each processor...

 private static Stream<Arguments> blockProcessors() {
  ...
    return Stream.of(
        Arguments.of("Sequential", sequentialBlockProcessor),
        Arguments.of("Parallel", parallelBlockProcessor)
    );
  @ParameterizedTest
  @MethodSource("blockProcessors")
  void testBlockProcessingWithTransfers(final MainnetBlockProcessor blockProcessor) {
    processSimpleTransfers(blockProcessor);
  }

and it appears in the test results as such...

testBlockProcessingWithTransfers
 - [1] Sequential
 - [2] Parallel

Might we end up with more variants of BlockProcessors as we develop new strategies for parallel processing/conflict detection?

Copy link
Copy Markdown
Contributor

@siladu siladu left a comment

Choose a reason for hiding this comment

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

LGTM, all comments are non-blocking regarding naming and style.

@ahamlat
Copy link
Copy Markdown
Contributor Author

ahamlat commented Jul 30, 2024

and it appears in the test results as such...

testBlockProcessingWithTransfers

  • [1] Sequential
  • [2] Parallel

Ah nice, I haven't tried before, in this case, it makes sens.

ahamlat and others added 9 commits July 30, 2024 10:28
Co-authored-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: ahamlat <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
@ahamlat ahamlat merged commit 9cb8b06 into besu-eth:main Aug 1, 2024
gconnect pushed a commit to gconnect/besu that referenced this pull request Aug 26, 2024
Add a block processing integration test to verify that sequential and parallel execution have the same behaviour

Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
Co-authored-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: gconnect <agatevureglory@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants