Skip to content

Commit

Permalink
Merge branch 'new-simple-sdk' into ed25519/ecdsa
Browse files Browse the repository at this point in the history
  • Loading branch information
alrxy authored Nov 14, 2024
2 parents 596f894 + 6b61c3b commit 8ac4d11
Show file tree
Hide file tree
Showing 9 changed files with 469 additions and 644 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/core"]
path = lib/core
url = https://github.com/symbioticfi/core
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "lib/core"]
path = lib/core
url = https://github.com/symbioticfi/core
18 changes: 17 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,20 @@
solc-version = "0.8.26"
src = "src"
out = "out"
libs = ["lib"]
fs_permissions = [{ access = "read", path = "./"}]
gas_reports = ["*"]

[fmt]
bracket_spacing = false
int_types = "long"
line_length = 120
multiline_func_header = "params_first"
number_underscore = "thousands"
quote_style = "double"
tab_width = 4

[fuzz]
runs = 4096
max_test_rejects = 262144

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
2 changes: 1 addition & 1 deletion lib/core
Submodule core updated 195 files
20 changes: 10 additions & 10 deletions src/libraries/PauseableEnumerableSet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ library PauseableEnumerableSet {
* @return True if the value was active at the timestamp, false otherwise.
*/
function wasActiveAt(Inner storage self, uint48 timestamp) internal view returns (bool) {
return
self.enabledTimestamp < timestamp && (self.disabledTimestamp == 0 || self.disabledTimestamp >= timestamp);
return self.enabledTimestamp < timestamp && (self.disabledTimestamp == 0 || self.disabledTimestamp >= timestamp);
}

/*
Expand Down Expand Up @@ -711,6 +710,7 @@ library PauseableEnumerableSet {
function set(Inner256 storage self, uint48 timestamp, uint256 value) internal {
self.value = value;
self.enabledTimestamp = timestamp;
self.disabledTimestamp = 0;
}

/*
Expand All @@ -722,6 +722,7 @@ library PauseableEnumerableSet {
function set(Inner256 storage self, uint48 timestamp, bytes32 key) internal {
self.value = uint256(key);
self.enabledTimestamp = timestamp;
self.disabledTimestamp = 0;
}

/*
Expand All @@ -747,7 +748,7 @@ library PauseableEnumerableSet {
if (self.disabledTimestamp != 0) {
revert NotEnabled();
}

self.enabledTimestamp = 0;
self.disabledTimestamp = timestamp;
}

Expand All @@ -758,8 +759,7 @@ library PauseableEnumerableSet {
* @return True if the value was active at the timestamp, false otherwise.
*/
function wasActiveAt(Inner256 storage self, uint48 timestamp) internal view returns (bool) {
return
self.enabledTimestamp < timestamp && (self.disabledTimestamp == 0 || self.disabledTimestamp >= timestamp);
return self.enabledTimestamp < timestamp && (self.disabledTimestamp == 0 || self.disabledTimestamp >= timestamp);
}

/*
Expand Down Expand Up @@ -797,11 +797,11 @@ library PauseableEnumerableSet {
* @param immutablePeriod The immutable period that must pass before unregistering.
* @return True if the value can be unregistered, false otherwise.
*/
function checkUnregister(Inner256 storage self, uint48 timestamp, uint48 immutablePeriod)
internal
view
returns (bool)
{
function checkUnregister(
Inner256 storage self,
uint48 timestamp,
uint48 immutablePeriod
) internal view returns (bool) {
if (self.enabledTimestamp != 0 || self.disabledTimestamp == 0) {
return false;
}
Expand Down
9 changes: 9 additions & 0 deletions src/managers/OperatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ abstract contract OperatorManager is BaseManager {
return _operators.wasActiveAt(timestamp, operator);
}

/*
* @notice Checks if an operator is registered.
* @param operator The address of the operator to check.
* @return A boolean indicating whether the operator is registered.
*/
function isOperatorRegistered(address operator) public view returns (bool) {
return _operators.contains(operator);
}

/*
* @notice Registers a new operator.
* @param operator The address of the operator to register.
Expand Down
31 changes: 17 additions & 14 deletions src/managers/VaultManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,12 @@ abstract contract VaultManager is BaseManager {
* @param timestamp The timestamp to check stake at
* @return The stake amount
*/
function getOperatorStakeAt(address operator, address vault, uint96 subnetwork, uint48 timestamp)
public
view
returns (uint256)
{
function getOperatorStakeAt(
address operator,
address vault,
uint96 subnetwork,
uint48 timestamp
) public view returns (uint256) {
bytes32 subnetworkId = NETWORK.subnetwork(subnetwork);
return IBaseDelegator(IVault(vault).delegator()).stakeAt(subnetworkId, operator, timestamp, "");
}
Expand All @@ -333,11 +334,12 @@ abstract contract VaultManager is BaseManager {
* @param timestamp The timestamp to check power at
* @return The power amount
*/
function getOperatorPowerAt(address operator, address vault, uint96 subnetwork, uint48 timestamp)
public
view
returns (uint256)
{
function getOperatorPowerAt(
address operator,
address vault,
uint96 subnetwork,
uint48 timestamp
) public view returns (uint256) {
uint256 stake = getOperatorStakeAt(operator, vault, subnetwork, timestamp);
return stakeToPower(vault, stake);
}
Expand Down Expand Up @@ -606,10 +608,11 @@ abstract contract VaultManager is BaseManager {
* @param hints Additional data for the veto slasher
* @return slashedAmount The amount that was slashed
*/
function _executeSlash(address vault, uint256 slashIndex, bytes calldata hints)
internal
returns (uint256 slashedAmount)
{
function _executeSlash(
address vault,
uint256 slashIndex,
bytes calldata hints
) internal returns (uint256 slashedAmount) {
address slasher = IVault(vault).slasher();
uint64 slasherType = IEntity(slasher).TYPE();
if (slasherType != VETO_SLASHER_TYPE) {
Expand Down
11 changes: 8 additions & 3 deletions src/middleware/extensions/Operators.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ pragma solidity ^0.8.25;

import {BaseMiddleware} from "../BaseMiddleware.sol";

import {console} from "forge-std/console.sol";

abstract contract Operators is BaseMiddleware {
function registerOperatorVault(address operator, address vault) public checkAccess {
require(isOperatorRegistered(operator), "Operator not registered");
_beforeRegisterOperatorVault(operator, vault);
_registerOperatorVault(operator, vault);
}

function registerOperator(address operator, bytes memory key, address vault) public checkAccess {
_beforeRegisterOperator(operator, key, vault);
_registerOperator(operator);
_updateKey(operator, key);
if (vault != address(0)) {
_registerOperatorVault(operator, vault);
registerOperatorVault(operator, vault);
}
}

Expand All @@ -31,6 +35,7 @@ abstract contract Operators is BaseMiddleware {
}

function _beforeRegisterOperator(address operator, bytes memory key, address vault) internal virtual {}
function _beforeRegisterOperatorVault(address operator, address vault) internal virtual {}
function _beforeUnregisterOperator(address operator) internal virtual {}
function _beforePauseOperator(address operator) internal virtual {}
function _beforeUnpauseOperator(address operator) internal virtual {}
Expand Down
Loading

0 comments on commit 8ac4d11

Please sign in to comment.