Skip to content

Bug/is 1247#2309

Open
olehnikolaiev wants to merge 36 commits into
developfrom
bug/IS-1247
Open

Bug/is 1247#2309
olehnikolaiev wants to merge 36 commits into
developfrom
bug/IS-1247

Conversation

@olehnikolaiev
Copy link
Copy Markdown
Collaborator

@olehnikolaiev olehnikolaiev commented Oct 28, 2025

fixes https://github.com/skalenetwork/internal-support/issues/1247

during catchup skaled produces 5-10 blocks per second. this produces a lot of writes to level-0 files in LevelDB, triggering compaction. because we use sync=false and background compaction, it is possible that during the read operation LevelDB returns stale key value from lower level, while higher levels are being compacted.
the bug is most likely to reproduce during catchup of a big batch of blocks on a chain with high average txns count.

in the proposed solution a new write-cache is added to State class. when a new key-value storage pair is committed into the database, it's added into the cache as well (or the cache is updated with a new value for a given key). when a contract's storage is read, the cache is checked first before making a request to the db.
only State instance with write rights has access to this cache - readonly copies always read the data from the database's snapshot.

Copilot AI review requested due to automatic review settings October 28, 2025 11:29
@github-actions
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a global LRU cache for storage key-value pairs to reduce database read operations and adds improved error handling for database operations. The changes address internal-support issue #1247.

Key changes:

  • Adds a global LRU cache (100K entries) for storage operations to avoid redundant database reads
  • Enhances error handling with a catch-all exception handler for database commits
  • Protects database deletion operations with proper locking

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
libdevcore/LruCache.h Enhanced LRU cache implementation with custom hash support, insertOrUpdate method, and std::any-based get method
libskale/State.h Added StorageKey type, custom hash function, and global LRU cache static member declaration with required includes
libskale/State.cpp Initialized global cache, integrated cache population on commit, and added cache lookup in storage retrieval path
libskale/OverlayDB.cpp Added catch-all exception handler for database commit failures
libdevcore/LevelDB.cpp Added locking protection around Delete() operations to prevent concurrent access issues
libethereum/ClientBase.cpp Changed to use read-only block copy for gas estimation
libethereum/Block.cpp Removed debugging state copy operation
libevm/LegacyVM.h Added trace logger member for VM operations
libevm/LegacyVM.cpp Fixed braces formatting in updateSSGasPreEIP1283 method
libethereum/Executive.cpp Fixed braces formatting in go method
deps/build.sh Pinned double-conversion to specific commit hash

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libdevcore/LruCache.h
Comment thread libskale/State.cpp Outdated
Comment thread libskale/OverlayDB.cpp
Comment thread libdevcore/LruCache.h Outdated
Comment thread deps/build.sh
@olehnikolaiev olehnikolaiev requested a review from Copilot October 28, 2025 15:35
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libskale/State.cpp
Comment thread libskale/State.h Outdated
Comment thread libdevcore/LruCache.h
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