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

fix(drive): inconsistent platform state and version during ABCI calls #1733

Merged
merged 112 commits into from
Mar 8, 2024

Conversation

shumkov
Copy link
Member

@shumkov shumkov commented Mar 5, 2024

Issue being fixed or feature implemented

During the same call of query or check tx, for example, we are reading version and state from shared locks multiple times. That can lead to situation that in the middle of the call the state will be updated with a new block. It means a part of the call will use information of previous block and another part will use a new block.

Another problem that currently we open read lock for entire query or check tx call so if we have many parallel calls then consensus app (block production) will be paused until those requests will be finished to acquire write lock. And while write lock is open check tx and queries won't be processed since they won't be able to acquire a read lock.

What was done?

  • Used ArcSwap (non blocking reads and writes) for PlatformState
  • Used ArcSwap for System Data Contracts Cache
  • Moved block execution context from Platform to consensus app since it's required only for sharing state between app's handlers
  • Removed unnecessary locks in ABCI handlers and further used functions.
  • Make sure we load platform state only once per ABCI handler call so the state will be consistent
  • Make sure we use correct platform version (from the current block) in finalize block handler
  • Make sure we load platform state only once per query call so the state will be consistent
  • Fixed dashmate local network readiness check that led CI to fail

How Has This Been Tested?

With existing tests

Breaking Changes

None

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@shumkov shumkov changed the title perf(drive): remove unnecessary shared locks fix(drive): inconsistent platform state and version during ABCI calls Mar 6, 2024
@shumkov shumkov added this to the v1.0.0 milestone Mar 6, 2024
@shumkov shumkov marked this pull request as ready for review March 6, 2024 17:27
@shumkov shumkov requested a review from QuantumExplorer as a code owner March 6, 2024 17:27
@shumkov shumkov requested a review from QuantumExplorer March 7, 2024 15:28
# Conflicts:
#	packages/rs-drive-abci/src/execution/check_tx/v0/mod.rs
#	packages/rs-drive-abci/src/execution/engine/run_block_proposal/mod.rs
#	packages/rs-drive-abci/src/query/data_contract_based_queries/data_contract/v0/mod.rs
#	packages/rs-drive-abci/src/query/identity_based_queries/identity/v0/mod.rs
#	packages/rs-drive-abci/src/query/identity_based_queries/identity_nonce/v0/mod.rs
QuantumExplorer
QuantumExplorer previously approved these changes Mar 8, 2024
@shumkov shumkov merged commit 22137c7 into v1.0-dev Mar 8, 2024
39 checks passed
@shumkov shumkov deleted the feat/drive/fast-read-locks branch March 8, 2024 12:42
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