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

Merge block-stm to develop #840

Merged
merged 45 commits into from
May 12, 2023
Merged

Merge block-stm to develop #840

merged 45 commits into from
May 12, 2023

Conversation

cffls
Copy link
Contributor

@cffls cffls commented Apr 27, 2023

Description

Enables parallel execution of EVM.

Changes

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)
  • Changes only for a subset of nodes

Breaking changes

Please complete this section if any breaking changes have been made, otherwise delete it

Nodes audience

In case this PR includes changes that must be applied only to a subset of nodes, please specify how you handled it (e.g. by adding a flag with a default value...)

Checklist

  • I have added at least 2 reviewer or the whole pos-v1 team
  • I have added sufficient documentation in code
  • I will be resolving comments - if any - by pushing each fix in a separate commit and linking the commit hash in the comment reply

Cross repository changes

  • This PR requires changes to heimdall
    • In case link the PR here:
  • This PR requires changes to matic-cli
    • In case link the PR here:

Testing

  • I have added unit tests
  • I have added tests to CI
  • I have tested this code manually on local environment
  • I have tested this code manually on remote devnet using express-cli
  • I have tested this code manually on mumbai
  • I have created new e2e tests into express-cli

Manual tests

Please complete this section with the steps you performed if you ran manual tests for this functionality, otherwise delete it

Additional comments

Please post additional comments in this section if you have them, otherwise delete it

cffls and others added 30 commits September 28, 2022 16:12
* basic txn prioritizer implemented using mutex map

* Re-execute parallel tasks when there is a read in coinbase or burn address

* Re-execute parallel tasks when there is a read in coinbase or burn address

* using *sync.RWMutex{} in mutexMap

Co-authored-by: Jerry <jerrycgh@gmail.com>
Added tests for executor and some improvements:

1. Add a dependency map during execution. This will prevent aborted tasks from being sent for execution immedaitely after failure.
2. Change the key of MVHashMap from string to a byte array. This will reduce time to convert byte slices to strings.
3. Use sync.Map to reduce the time spent in global mutex.
4. Skip applying intermediate states.
5. Estimate dependency when an execution fails without dependency information.
6. Divide execution task queue into two separate queues. One for relatively certain transactions, and the other for speculative future transactions.
7. Setting dependencies of Txs coming from the same sender before starting parallel execution.
8. Process results in their semantic order (transaction index) instead of the order when they arrive. Replace result channel with a priority queue.
* Create MVHashMap and use it StateDB

* Parallel state processor

* Move fee burning and tipping out of state transition to reduce read/write dependencies between transactions

* Re-execute parallel tasks when there is a read in coinbase or burn address

* Block-stm optimization

Added tests for executor and two major improvements:

1. Add a dependency map during execution. This will prevent aborted tasks from being sent for execution immedaitely after failure.
2. Change the key of MVHashMap from string to a byte array. This will reduce time to convert byte slices to strings.

* Remove cache from executor test

* added mvhashmap unit tests (with  as key)

* Shard mvhashmap to reduce the time spent in global mutex

* Skip applying intermediate states

* Dependency improvement

* added test for status

* Create MVHashMap and use it StateDB

* Parallel state processor

* Move fee burning and tipping out of state transition to reduce read/write dependencies between transactions

* Re-execute parallel tasks when there is a read in coinbase or burn address

* Txn prioritizer implemented using mutex map (#487)

* basic txn prioritizer implemented using mutex map

* Re-execute parallel tasks when there is a read in coinbase or burn address

* Re-execute parallel tasks when there is a read in coinbase or burn address

* using *sync.RWMutex{} in mutexMap

Co-authored-by: Jerry <jerrycgh@gmail.com>

* added getReadMap and getWriteMap (#473)

* Block-stm optimization

Added tests for executor and some improvements:

1. Add a dependency map during execution. This will prevent aborted tasks from being sent for execution immedaitely after failure.
2. Change the key of MVHashMap from string to a byte array. This will reduce time to convert byte slices to strings.
3. Use sync.Map to reduce the time spent in global mutex.
4. Skip applying intermediate states.
5. Estimate dependency when an execution fails without dependency information.
6. Divide execution task queue into two separate queues. One for relatively certain transactions, and the other for speculative future transactions.
7. Setting dependencies of Txs coming from the same sender before starting parallel execution.
8. Process results in their semantic order (transaction index) instead of the order when they arrive. Replace result channel with a priority queue.

* Do not write entire objects directly when applying write set in blockstm

* fixed a small bug in the Report function (#530)

* linters

Co-authored-by: Jerry <jerrycgh@gmail.com>
There seems to be an issue when hasher is used concurrently in parallel
execution. This change will ensure no hasher is used by multiple
executors at the same time.
* added support for dependencies (executor_tests)

* added a function to get dependency map

* getting all dependencies in the GetDep function

* updated GetDep function

* changed the type of AllDeps

* added a function to get dependency map

* updated GetDep function

* generate and get dependencies from block producer

* optimized getDep function

* bug fix regarding txn index and dep structure

* fixed gas bug

* optimized getDep function

* tests updated/added

* few updates regarding dependencies

* added channel to calculate the dependencies in a separate go routine

* minor changes in the executor which uses latest changes of dependecies + removed metadata flag/argument

* Use channel when metadata is available

* small bug fix

* getting reads and writes only when the transaction succeeds

* fixed bug in adding dependencies

* updated logic for delay/not delay

* bug fix (shouldDelayFeeCal) in parallel state processor

* lint fix

* using EnableMVHashMap flag

* fixed worker and stateProcessor and removed SetMVHashMapNil fumction from stateDB

* addredded few comments and fixed bug in executor tests

* commented executor tests with metadata (panic: test timed out after 5m0s)

* added a check to check len(mvReadMapList) > 0 in miner

* addressed comments, minor refactoring in dag.go

* moved blockContext out of Execute and adding it in execution task

* removed Author() from Settle() and added  in execution task

* not calling block.Header() again and again, using  instead

* removed EnableMVHashMap flag, and updated applyTransaction function

* addressed comments

* added unit test to check dependencies in the block header

Co-authored-by: Jerry <jerrycgh@gmail.com>
* removed the first 2 element in TxDependency[i]

* addressed comments
Merge remote-tracking branch 'upstream/develop' into block-stm
Parallel execution can fail due to bad dependencies. In the case of bad
dependencies, the result of serial execution should be used.
Run serial and parallel processor at the same time
@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Patch coverage: 68.50% and project coverage change: +0.22 🎉

Comparison is base (acff69a) 56.60% compared to head (0a7594b) 56.83%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #840      +/-   ##
===========================================
+ Coverage    56.60%   56.83%   +0.22%     
===========================================
  Files          611      617       +6     
  Lines        72430    73600    +1170     
===========================================
+ Hits         40999    41828     +829     
- Misses       27917    28236     +319     
- Partials      3514     3536      +22     
Impacted Files Coverage Δ
core/types/gen_header_json.go 0.00% <0.00%> (ø)
core/vm/interpreter.go 22.86% <0.00%> (-0.42%) ⬇️
eth/backend.go 0.00% <0.00%> (ø)
eth/state_accessor.go 0.00% <0.00%> (ø)
params/config.go 29.80% <0.00%> (-0.44%) ⬇️
core/types/block.go 25.56% <20.00%> (-0.22%) ⬇️
core/evm.go 67.27% <33.33%> (-1.96%) ⬇️
core/parallel_state_processor.go 37.63% <37.63%> (ø)
core/blockstm/dag.go 48.00% <48.00%> (ø)
core/state/statedb.go 59.79% <68.93%> (+3.83%) ⬆️
... and 14 more

... and 27 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@cffls cffls mentioned this pull request Apr 28, 2023
@cffls cffls marked this pull request as ready for review May 2, 2023 17:33
@cffls cffls requested a review from a team May 2, 2023 17:33
cmd/utils/flags.go Outdated Show resolved Hide resolved
@cffls cffls requested a review from a team May 9, 2023 17:23
pratikspatil024 and others added 3 commits May 10, 2023 10:33
* added check for circular and out-of-range dependency problem

* addressed comment

* addressed comments
If a transaction is reverted, its write records should be excluded from
dependency calculation.
docs/config.md Outdated Show resolved Hide resolved
@cffls cffls merged commit eeb0805 into develop May 12, 2023
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.

3 participants