-
Notifications
You must be signed in to change notification settings - Fork 0
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
Oyster Secret Storage Implementation #14
Open
rajatlko13
wants to merge
64
commits into
master
Choose a base branch
from
rajat/secret-store
base: master
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 60 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
4ee59da
secret store changes added
rajatlko13 57eb506
comments updated
rajatlko13 a3e63d6
more functions added to SecretStorage contract
rajatlko13 738a5e0
secret store contract splitted
rajatlko13 c139ef0
selectedEnclaves added to SecretStoreCreated event
rajatlko13 53996b4
SecretStoreCreated event updated
rajatlko13 ad101d9
secret store contracts renamed and other post review updates
rajatlko13 047b741
contract updates pushed
rajatlko13 2678318
secret store deployment script pushed
rajatlko13 cd9eb9b
secret store deployment script updated
rajatlko13 7c5a194
secret store contract updates
rajatlko13 4acc2d6
test cases pushed for SecretStore
rajatlko13 84b0cce
Secret Manager test cases added
rajatlko13 e811930
usdc value checks added to SecretManager test cases
rajatlko13 af342f4
indentation fixed in secret store test cases
rajatlko13 6b6b13e
Merge branch 'master' into rajat/secret-store
rajatlko13 ce1166c
addChainGlobal() logic updated for duplicate chains
rajatlko13 665d901
indentation fix
rajatlko13 2fbc7f9
test cases updated
rajatlko13 047593d
added check for all selected enclaves acknowledgement before end time…
rajatlko13 6c01211
updated logic for mark store alive/dead
rajatlko13 2806a05
secret contracts updated
rajatlko13 936136e
underflow condition fixed in secret store payment logic
rajatlko13 698ca2d
added ack fail logic for replaced stores
rajatlko13 77836ab
terminate and remove secret functions updated
rajatlko13 8f331a2
updates in ack fail function
rajatlko13 a2dca16
fixed usdc payment issue for dead store marked in the last epoch
rajatlko13 87f5183
review fixes for usdc payment for secret
rajatlko13 e097254
contracts and test cases updated
rajatlko13 605979e
Alive check signature fix done
rajatlko13 5d9fb9c
bug fix in contract and UTs updated
rajatlko13 bcc1449
fixed function getCurrentConfirmedUsdcDeposit()
rajatlko13 2ef609c
quick fix in _markEnclaveDead()
rajatlko13 78a6a81
missing test cases added for SecretStore
rajatlko13 6ae9c3b
mark dead logic updated in SecretManager
rajatlko13 8fdc10b
nit fix - function name updated
rajatlko13 ed8e74e
storeSecretIds and deadTimestamp mapping moved to SecretStore contract
rajatlko13 4814c84
markAlive() updated
rajatlko13 0807a46
markAlive() logic fix
rajatlko13 b92efce
nit fix
rajatlko13 b741bad
secret store slashing logic updated
rajatlko13 492c7f7
secret store slashing logic bug resolved
rajatlko13 d700780
markAlive bug fix
rajatlko13 ffe578b
secret store test cases updated
rajatlko13 16b32e0
markDead gas estimate script pushed
rajatlko13 556cd82
secret store + job allocation changes pushed
rajatlko13 6a72098
executors code combined in secret store contract
rajatlko13 2d1373e
review bug fixes
rajatlko13 ecd6ca3
function logic updated
rajatlko13 3d986cb
SecretStore contract splitted
rajatlko13 ac6280a
review bug fixes
rajatlko13 aed7337
new structure for secret store and executors contract
rajatlko13 4d5c420
review issues fixed
rajatlko13 558fd1f
reputation logic moved to Executors
rajatlko13 26e5098
updated logic for adding back nodes to the tree post selection
rajatlko13 7a89e1c
slash store exponent issue resolved
rajatlko13 d2e8275
review bug fixes and updated test cases
rajatlko13 27bf83a
bug fixes and jobs UTs updated
rajatlko13 7f548e1
renounceSecrets function added
rajatlko13 139e91c
renounceSecret review fixes
rajatlko13 179a848
renounceSecrets() moved to SecretStore
rajatlko13 d3dcefe
quick fixes
rajatlko13 d8428dd
UT bug fixes
rajatlko13 f30c569
createJob function updated - only select from secret stores
rajatlko13 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,166 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
import "../secret-storage/SecretStore.sol"; | ||
import "../secret-storage/Executors.sol"; | ||
import "@openzeppelin/contracts/utils/Context.sol"; | ||
|
||
contract TeeManagerMock is Context { | ||
|
||
Executors public EXECUTORS; | ||
SecretStore public SECRET_STORE; | ||
uint256 public immutable MIN_STAKE_AMOUNT; | ||
|
||
struct TeeNode { | ||
uint256 stakeAmount; | ||
address owner; | ||
uint8 env; | ||
bool draining; | ||
} | ||
|
||
// enclaveAddress => TEE node details | ||
mapping(address => TeeNode) public teeNodes; | ||
|
||
constructor( | ||
uint256 _minStakeAmount | ||
) { | ||
MIN_STAKE_AMOUNT = _minStakeAmount; | ||
} | ||
|
||
function setExecutors(Executors _executors) external { | ||
EXECUTORS = _executors; | ||
} | ||
|
||
function setSecretStore(SecretStore _secretStore) external { | ||
SECRET_STORE = _secretStore; | ||
} | ||
|
||
// --------------------------------- Executors functions start --------------------------------- | ||
|
||
function registerExecutor( | ||
address _enclaveAddress, | ||
uint256 _jobCapacity, | ||
uint8 _env, | ||
uint256 _stakeAmount | ||
) external { | ||
teeNodes[_enclaveAddress].env = _env; | ||
teeNodes[_enclaveAddress].owner = _msgSender(); | ||
teeNodes[_enclaveAddress].stakeAmount = _stakeAmount; | ||
|
||
EXECUTORS.registerExecutor(_enclaveAddress, _jobCapacity, _env, _stakeAmount); | ||
} | ||
|
||
function deregisterExecutor(address _enclaveAddress) external { | ||
EXECUTORS.deregisterExecutor(_enclaveAddress); | ||
} | ||
|
||
function drainExecutor( | ||
address _enclaveAddress, | ||
uint8 _env | ||
) external { | ||
EXECUTORS.drainExecutor(_enclaveAddress, _env); | ||
} | ||
|
||
function reviveExecutor( | ||
address _enclaveAddress, | ||
uint8 _env, | ||
uint256 _stakeAmount | ||
) external { | ||
EXECUTORS.reviveExecutor(_enclaveAddress, _env, _stakeAmount); | ||
} | ||
|
||
function addExecutorStake( | ||
address _enclaveAddress, | ||
uint8 _env, | ||
uint256 _stake | ||
) external { | ||
EXECUTORS.addExecutorStake(_enclaveAddress, _env, _stake); | ||
} | ||
|
||
function removeExecutorStake( | ||
address _enclaveAddress | ||
) external view { | ||
EXECUTORS.removeExecutorStake(_enclaveAddress); | ||
} | ||
|
||
function slashExecutor( | ||
address _enclaveAddress, | ||
address _recipient | ||
) external returns (uint256) { | ||
return 0; | ||
} | ||
|
||
// ---------------------------------- Executors functions end ------------------------------------- | ||
|
||
// --------------------------------- Secret Store functions start --------------------------------- | ||
|
||
function registerSecretStore( | ||
address _enclaveAddress, | ||
uint256 _storageCapacity, | ||
uint8 _env, | ||
uint256 _stakeAmount | ||
) external { | ||
teeNodes[_enclaveAddress].env = _env; | ||
teeNodes[_enclaveAddress].owner = _msgSender(); | ||
teeNodes[_enclaveAddress].stakeAmount = _stakeAmount; | ||
|
||
SECRET_STORE.registerSecretStore( | ||
_enclaveAddress, | ||
_storageCapacity, | ||
_env, | ||
_stakeAmount | ||
); | ||
} | ||
|
||
function deregisterSecretStore(address _enclaveAddress) external { | ||
SECRET_STORE.deregisterSecretStore(_enclaveAddress); | ||
} | ||
|
||
function drainSecretStore( | ||
address _enclaveAddress, | ||
uint8 _env | ||
) external { | ||
SECRET_STORE.drainSecretStore(_enclaveAddress, _env); | ||
} | ||
|
||
function reviveSecretStore( | ||
address _enclaveAddress, | ||
uint8 _env, | ||
uint256 _stakeAmount | ||
) external { | ||
SECRET_STORE.reviveSecretStore(_enclaveAddress, _env, _stakeAmount); | ||
} | ||
|
||
function addSecretStoreStake( | ||
address _enclaveAddress, | ||
uint8 _env, | ||
uint256 _stake | ||
) external { | ||
SECRET_STORE.addSecretStoreStake(_enclaveAddress, _env, _stake); | ||
} | ||
|
||
function removeSecretStoreStake( | ||
address _enclaveAddress | ||
) external view { | ||
SECRET_STORE.removeSecretStoreStake(_enclaveAddress); | ||
} | ||
|
||
function slashStore( | ||
address _enclaveAddress, | ||
uint256 _missedEpochsCount, | ||
address _recipient | ||
) external {} | ||
|
||
// --------------------------------- Secret Store functions end --------------------------------- | ||
|
||
function getTeeNodesStake( | ||
address[] memory _enclaveAddresses | ||
) external view returns (uint256[] memory) { | ||
uint256 len = _enclaveAddresses.length; | ||
uint256[] memory stakeAmounts = new uint256[](len); | ||
for (uint256 index = 0; index < len; index++) | ||
stakeAmounts[index] = teeNodes[_enclaveAddresses[index]].stakeAmount; | ||
|
||
return stakeAmounts; | ||
} | ||
|
||
} |
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.
can remove this?
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.
it is still being used in the serverless-v2 contracts, so let's keep it for now.