Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research/parallel-tx/Refactor validblock #1794

Conversation

ilanolkies
Copy link
Contributor

@ilanolkies ilanolkies commented Jun 3, 2022

Refactored tests and a little bit of the implementation. Also corrected one test that hit two cases at the same time, now hits one of the two.

Things we need to further look at:

  • Why would we check if the block has edges. If it is validating edges it means it is already marked as post-RSKIP144, so we should asume edges exist
  • Discussion already opened, why could a block have less than max edges?
  • REMASC tx cannot be parallelized, should edges[edges.length-1] be <= txListSize-1? Thus validating the last edge does not include REMASC that is the last tx

Another additional refactor that we could consider:

  • Constants.getMaxTransactionExecutionThreads() incorporates an external dependency to ValidTxExecutionListsEdgesRule. I would consider having that value set in the constructor to prevent side effects on future changes

@ilanolkies ilanolkies requested a review from julianlen June 3, 2022 20:50

if (edges == null) {
if (edges == null || edges.length == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove the second check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What did I remove? 🤔 If length is zero why would we iterate and all that.

Constants.getMaxTransactionExecutionThreads() must be >1

@ilanolkies ilanolkies changed the title Research/main parallel tx refactor validblock Research/parallel-tx/Refactor validblock Jun 8, 2022
}

if (edges[edges.length-1] > block.getTransactionsList().size()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
if (edges[edges.length-1] > block.getTransactionsList().size()) {
if (edges[edges.length-1] > block.getTransactionsList().size() - 1) {

This would keep the REMASC tx, that is the last tx, outside of the parallel buckets

julianlen and others added 5 commits June 27, 2022 16:55
* store and return a copy of txEdges

* merged two ifs in the BlockHeaderBuilder

* DummyTracker updated so it returns a copy of the maps

* Unused hashmap import deleted from ProgramTraceProcessor

* BlockResult returns and stores a copy of txEdges

* big refactor in BlockExecutor

* Refactor ParallelizeTransactionHandler

* renaming Bucket to Sublist

* renaming txExecutionListsEdges to txExecutionSublistEdges

* simplification of Handler's code

* InterruptedException solved properly in the BlockExecutor
* Avoid tracking write for add balance 0

* Avoid tracking when writing the same value

* Rename assertion

* Remove condition for add balance zero

It is considered in "write the same value"

* Revert breaks
ilanolkies and others added 3 commits July 8, 2022 15:21
…ect index (#1822)

* Fix isRemascTransaction validation and pass correct index

* Remove -1

* Rename local data

* Add tests for isRemascTransaction

* Add tests for remasc transaction

* Fix txindex

Added test for block with rejected tx

* Add missing txindex++
@sonarcloud
Copy link

sonarcloud bot commented Jul 13, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

96.8% 96.8% Coverage
0.0% 0.0% Duplication

@ilanolkies ilanolkies merged commit 156aa3b into research/main_parallel_tx Jul 19, 2022
julianlen added a commit that referenced this pull request Sep 26, 2022
* Refactor repeated code

* Refactor repeated edges mocking

* Modify test for too many edges - it was also hitting out of bounds

* Refactor out of bounds validation

If edges are in order, last edge decides if any was out of bounds

* Rename test

* Add case where first edge is zero

First changed to prev = -1, then added test that failed, then set back prev = 0

* Refactor order verification

* Research/refactoring code (#1817)

* store and return a copy of txEdges

* merged two ifs in the BlockHeaderBuilder

* DummyTracker updated so it returns a copy of the maps

* Unused hashmap import deleted from ProgramTraceProcessor

* BlockResult returns and stores a copy of txEdges

* big refactor in BlockExecutor

* Refactor ParallelizeTransactionHandler

* renaming Bucket to Sublist

* renaming txExecutionListsEdges to txExecutionSublistEdges

* simplification of Handler's code

* InterruptedException solved properly in the BlockExecutor

* Research/parallel-tx/optimize writes (#1811)

* Avoid tracking write for add balance 0

* Avoid tracking when writing the same value

* Rename assertion

* Remove condition for add balance zero

It is considered in "write the same value"

* Revert breaks

* Add test refactor back

* Make remasc transaction not be in a parallelized sublist

* Research/parallel-tx/Fix isRemascTransaction validation and pass correct index (#1822)

* Fix isRemascTransaction validation and pass correct index

* Remove -1

* Rename local data

* Add tests for isRemascTransaction

* Add tests for remasc transaction

* Fix txindex

Added test for block with rejected tx

* Add missing txindex++

* Fix merge error

Co-authored-by: julianlen <[email protected]>
julianlen added a commit that referenced this pull request Nov 16, 2022
* Refactor repeated code

* Refactor repeated edges mocking

* Modify test for too many edges - it was also hitting out of bounds

* Refactor out of bounds validation

If edges are in order, last edge decides if any was out of bounds

* Rename test

* Add case where first edge is zero

First changed to prev = -1, then added test that failed, then set back prev = 0

* Refactor order verification

* Research/refactoring code (#1817)

* store and return a copy of txEdges

* merged two ifs in the BlockHeaderBuilder

* DummyTracker updated so it returns a copy of the maps

* Unused hashmap import deleted from ProgramTraceProcessor

* BlockResult returns and stores a copy of txEdges

* big refactor in BlockExecutor

* Refactor ParallelizeTransactionHandler

* renaming Bucket to Sublist

* renaming txExecutionListsEdges to txExecutionSublistEdges

* simplification of Handler's code

* InterruptedException solved properly in the BlockExecutor

* Research/parallel-tx/optimize writes (#1811)

* Avoid tracking write for add balance 0

* Avoid tracking when writing the same value

* Rename assertion

* Remove condition for add balance zero

It is considered in "write the same value"

* Revert breaks

* Add test refactor back

* Make remasc transaction not be in a parallelized sublist

* Research/parallel-tx/Fix isRemascTransaction validation and pass correct index (#1822)

* Fix isRemascTransaction validation and pass correct index

* Remove -1

* Rename local data

* Add tests for isRemascTransaction

* Add tests for remasc transaction

* Fix txindex

Added test for block with rejected tx

* Add missing txindex++

* Fix merge error

Co-authored-by: julianlen <[email protected]>
julianlen added a commit that referenced this pull request Nov 28, 2022
* Refactor repeated code

* Refactor repeated edges mocking

* Modify test for too many edges - it was also hitting out of bounds

* Refactor out of bounds validation

If edges are in order, last edge decides if any was out of bounds

* Rename test

* Add case where first edge is zero

First changed to prev = -1, then added test that failed, then set back prev = 0

* Refactor order verification

* Research/refactoring code (#1817)

* store and return a copy of txEdges

* merged two ifs in the BlockHeaderBuilder

* DummyTracker updated so it returns a copy of the maps

* Unused hashmap import deleted from ProgramTraceProcessor

* BlockResult returns and stores a copy of txEdges

* big refactor in BlockExecutor

* Refactor ParallelizeTransactionHandler

* renaming Bucket to Sublist

* renaming txExecutionListsEdges to txExecutionSublistEdges

* simplification of Handler's code

* InterruptedException solved properly in the BlockExecutor

* Research/parallel-tx/optimize writes (#1811)

* Avoid tracking write for add balance 0

* Avoid tracking when writing the same value

* Rename assertion

* Remove condition for add balance zero

It is considered in "write the same value"

* Revert breaks

* Add test refactor back

* Make remasc transaction not be in a parallelized sublist

* Research/parallel-tx/Fix isRemascTransaction validation and pass correct index (#1822)

* Fix isRemascTransaction validation and pass correct index

* Remove -1

* Rename local data

* Add tests for isRemascTransaction

* Add tests for remasc transaction

* Fix txindex

Added test for block with rejected tx

* Add missing txindex++

* Fix merge error

Co-authored-by: julianlen <[email protected]>
Vovchyk pushed a commit that referenced this pull request Feb 2, 2023
* Refactor repeated code

* Refactor repeated edges mocking

* Modify test for too many edges - it was also hitting out of bounds

* Refactor out of bounds validation

If edges are in order, last edge decides if any was out of bounds

* Rename test

* Add case where first edge is zero

First changed to prev = -1, then added test that failed, then set back prev = 0

* Refactor order verification

* Research/refactoring code (#1817)

* store and return a copy of txEdges

* merged two ifs in the BlockHeaderBuilder

* DummyTracker updated so it returns a copy of the maps

* Unused hashmap import deleted from ProgramTraceProcessor

* BlockResult returns and stores a copy of txEdges

* big refactor in BlockExecutor

* Refactor ParallelizeTransactionHandler

* renaming Bucket to Sublist

* renaming txExecutionListsEdges to txExecutionSublistEdges

* simplification of Handler's code

* InterruptedException solved properly in the BlockExecutor

* Research/parallel-tx/optimize writes (#1811)

* Avoid tracking write for add balance 0

* Avoid tracking when writing the same value

* Rename assertion

* Remove condition for add balance zero

It is considered in "write the same value"

* Revert breaks

* Add test refactor back

* Make remasc transaction not be in a parallelized sublist

* Research/parallel-tx/Fix isRemascTransaction validation and pass correct index (#1822)

* Fix isRemascTransaction validation and pass correct index

* Remove -1

* Rename local data

* Add tests for isRemascTransaction

* Add tests for remasc transaction

* Fix txindex

Added test for block with rejected tx

* Add missing txindex++

* Fix merge error

Co-authored-by: julianlen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants