generated from PaulRBerg/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 15
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
[VEN-2999]: add transient storage to Resilient oracle #239
Open
Debugger022
wants to merge
16
commits into
develop
Choose a base branch
from
feat/transient-storage
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f1de71f
chore: update vm version to cancun and dependencies
Debugger022 1912471
feat: add transient storage in resilient oracle
Debugger022 2ea9a8d
chore: fix dependency version of hardhat and smock
Debugger022 f79e2fe
feat: cache asset price into transient storage in resilient oracle
Debugger022 a799afb
fix: add resolutions to pin hardhat and smock
coreyar d808048
ci: remove ignore checksums
coreyar be72452
fix: relock
coreyar d2c2ff1
refactor: add check for cache price in resilient oracle
Debugger022 dbcd6c3
refactor: _getPrice method in resilient oracle
Debugger022 1dc13c1
fix: remove env variable defination CI/CD
Debugger022 742e12d
fix: pr comment
Debugger022 7e7ccdd
fixup! fix: pr comment
chechu fe00ce8
Merge branch 'develop' into feat/transient-storage
chechu 606522d
fix: patch smock package to check if provider has init
coreyar c881fcf
refactor: add transient library to cache and read value
Debugger022 725d205
refactor: move cache slot for transient library
Debugger022 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity ^0.8.25; | ||
|
||
library Transient { | ||
/// Slot to cache the asset's price, used for transient storage | ||
bytes32 public constant CACHE_SLOT = keccak256(abi.encode("venus-protocol/oracle/ResilientOracle/cache")); | ||
|
||
/** | ||
* @notice Cache the asset price into transient storage | ||
* @param key address of the asset | ||
* @param value asset price | ||
*/ | ||
function cachePrice(address key, uint256 value) internal { | ||
bytes32 slot = keccak256(abi.encode(CACHE_SLOT, key)); | ||
assembly ("memory-safe") { | ||
tstore(slot, value) | ||
} | ||
} | ||
|
||
/** | ||
* @notice Read cached price from transient storage | ||
* @param key address of the asset | ||
* @return value cached asset price | ||
*/ | ||
function readCachedPrice(address key) internal view returns (uint256 value) { | ||
bytes32 slot = keccak256(abi.encode(CACHE_SLOT, key)); | ||
assembly ("memory-safe") { | ||
value := tload(slot) | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not put this in the library. It seems it's specific to the ResilientOracle contract. I would allow every contract using this library to define their own slot. Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
725d205