feat: Implement WasmCache for Contract Bytecode (#405) - #418
Open
GiftedGiftB wants to merge 1 commit into
Open
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closed #405
Description
This PR implements the
WasmCacheto specialize in storing and retrieving compiled WebAssembly (Wasm) modules. By eliminating redundant parsing and compilation steps across repeated executions, this implementation heavily optimizes the contract execution pipeline.How It Was Done
crates/core/src/cache/wasm.rscontaining a specializedWasmCachestruct that leverages the existingCacheProvidertrait.hash_bytecodeutility usingsha2::Sha256to create unique, cryptographic cache keys derived from the raw contract bytecode.get,put, andclearcaching methods to seamlessly retrieve and store instantiated Wasm module buffers (Vec<u8>).wasmmodule incrates/core/src/cache/mod.rs.InMemoryCacheDoubleto ensure safe operation logic independently from file system constraints.Issues Encountered (If Any)
No significant roadblocks. We were able to leverage the existing
sha2dependency present in thegrat-corecargo manifest and smoothly map the caching data over the sharedCacheProvidertrait layout.How It Was Tested
tokio::testcases insidecrates/core/src/cache/wasm.rs.cargo test --package grat-core --lib cache::wasmto verify successful test suite completion.Screenshots / Video (If Applicable)
N/A - This is a backend caching infrastructural optimization.