Skip to content
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

New simple SDK #2

Merged
merged 123 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
837ae96
feat: new sdk
alrxy Oct 1, 2024
ae49372
refactor: arch with abstract contracts
alrxy Oct 2, 2024
dbbd79d
refactor: redundant key management
alrxy Oct 2, 2024
3898883
refactor: add hints for slashing, gettters
alrxy Oct 4, 2024
2c3114a
fix: optimize our data structure with times, add vault init check, va…
alrxy Oct 8, 2024
7278b86
refactor: changed timestamps to epoch
alrxy Oct 9, 2024
9ba23ec
feat: new example
1kresh Oct 18, 2024
7d8c5d9
chore: set [email protected]
1kresh Oct 18, 2024
f4d1117
test: add simple middleware tests
alrxy Oct 23, 2024
f221bee
Merge branch 'new-simple-sdk' into new-example
alrxy Oct 24, 2024
4fc50f2
Merge pull request #3 from symbioticfi/new-example
alrxy Oct 24, 2024
e7c382b
chore: Readme and fixes
alrxy Oct 24, 2024
6856448
add LICENSE
algys Oct 24, 2024
a18076d
fix: add opeartors vault check on slash
alrxy Oct 24, 2024
d98f473
chore: add notice epoch starts from 1
alrxy Oct 24, 2024
7f3b5ac
fix: no additional epoch between pause/unpause
alrxy Oct 24, 2024
d63c92a
fix: vault slash check and blskeymanager get key check
alrxy Oct 24, 2024
326c242
fix was active at
alrxy Oct 24, 2024
7aa21a2
fix: wasActiveAt bug and validateUnregister/Unpause
alrxy Oct 24, 2024
b5488cd
fix: unpause/unregister validation
alrxy Oct 24, 2024
4af8fed
chore: start epoch from 0
alrxy Oct 24, 2024
03dbdf2
fix: sdk fixes with tests
alrxy Oct 31, 2024
b048bbe
tests: add tests
alrxy Oct 31, 2024
76ab4db
test: slash stake tests
alrxy Nov 5, 2024
e28288a
refactor: separate modules as default and base
alrxy Nov 5, 2024
2bb43f8
refactor: tests adapt
alrxy Nov 5, 2024
ef71272
refactor: add checks, make virtual some public functions and add was …
alrxy Nov 6, 2024
97e4952
fix: vault inactive slash check
alrxy Nov 6, 2024
6b85333
refactor: readme and arch img
alrxy Nov 6, 2024
57be776
refactor: move examples to examples dir
alrxy Nov 6, 2024
87878df
refactor: make initializble, add all network active vaults getter, su…
alrxy Nov 9, 2024
9e64c77
WIP: removed epochs
algys Nov 9, 2024
25b0899
WIP: fixed almost all compilation issues
algys Nov 10, 2024
2036ec1
WIP: bumped solc version up to 0.8.26 to avoid compilation error
algys Nov 10, 2024
3b86efd
WIP: reworked BaseKeyRegistry
algys Nov 10, 2024
7756d0e
fix: now compile tests
alrxy Nov 10, 2024
99ce066
fixed capture timestamp
gm256 Nov 11, 2024
10fb317
fixed capture timestamp
gm256 Nov 11, 2024
1185593
WIP: new structure with extensions
algys Nov 11, 2024
35873af
refactor: reorganized and add selfresgiterOM
alrxy Nov 11, 2024
e7d8efb
fixed set
gm256 Nov 12, 2024
171e268
Merge branch 'new-simple-sdk' of github.com:symbioticfi/middleware-sd…
gm256 Nov 12, 2024
a656bc0
merge
algys Nov 12, 2024
5ce6284
feat: add sumberworks extension
algys Nov 12, 2024
d3b7810
feat: add oz access managed
algys Nov 12, 2024
4ba578c
fix: selfregisteroperator
alrxy Nov 12, 2024
8799115
temp_commit
gm256 Nov 12, 2024
40f0535
Merge branch 'new-simple-sdk' of github.com:symbioticfi/middleware-sd…
gm256 Nov 12, 2024
358c148
chore: rename key storages
algys Nov 12, 2024
dbf47e9
feat: add ed25519 sig
alrxy Nov 12, 2024
135af7f
added tests
gm256 Nov 12, 2024
81794a3
Merge branch 'new-simple-sdk' of github.com:symbioticfi/middleware-sd…
gm256 Nov 12, 2024
cf13039
fmt
gm256 Nov 12, 2024
6f792d3
feat: key sigs
alrxy Nov 12, 2024
41bc52a
fix: can compile without via-ir
alrxy Nov 14, 2024
aeb2a9d
Merge branch 'new-simple-sdk' into ed25519/ecdsa
alrxy Nov 14, 2024
77e909b
tests: ed25519 tests and refactor
alrxy Nov 16, 2024
1b76443
refactor: add recover function and ecrecover via OZ ECDSA
Nov 18, 2024
5bac83f
refactor: recover is internal
alrxy Nov 18, 2024
c41c8b5
refactor keys and self register operators
alrxy Nov 20, 2024
c404675
refactor: add checkunregister function for bytes32/bytes sets
alrxy Nov 20, 2024
47e8e30
refactor: forge fmt
alrxy Nov 20, 2024
1d17825
refactor: fix docstrings and capture timestamps add
alrxy Nov 21, 2024
4bd51ed
refactor: add check for ed25519sig contract
alrxy Nov 21, 2024
07ba6f1
fix: disallow unpause/unregister in forceoperators
alrxy Nov 21, 2024
67b2ba5
Merge pull request #4 from symbioticfi/ed25519/ecdsa
alrxy Nov 21, 2024
75d9a73
chore: adjust workflows
1kresh Nov 21, 2024
9787a88
feat: make direct storage access
alrxy Nov 21, 2024
22add8a
feat: add enabled constant var getter for extensions
alrxy Nov 21, 2024
31167e4
fix: adjust slot hashes
1kresh Nov 21, 2024
8e322a8
forge install: crypto-lib
alrxy Nov 25, 2024
05ecd75
fix: arbitrary len ed25519 sig
alrxy Nov 25, 2024
c7efb34
fix: ed25519 licence
alrxy Nov 25, 2024
47e83cb
Merge pull request #5 from symbioticfi/fix-ed25519
alrxy Nov 26, 2024
8247e9b
refactor: rename ed25519 to eddsa, key storage to extensions, add bas…
alrxy Nov 26, 2024
dacbed3
fix: lint
alrxy Nov 26, 2024
7818c55
feat: versions instead of enabled
alrxy Nov 26, 2024
40b0450
fix: non-revert noaccessmanager and init owner in sqrttaskmiddleware
alrxy Nov 26, 2024
0b16b20
fix: init not override in sqrttaskmiddleware
alrxy Nov 26, 2024
fe7276a
chore: readme
alrxy Nov 27, 2024
2f5ed47
fix: basemiddleware docstrings
alrxy Nov 27, 2024
e875a73
feat: stake to power extensions
alrxy Nov 27, 2024
70f9ef7
refactor: remove operator stake public function
alrxy Nov 27, 2024
b24cbc0
feat: OzAccessControl
alrxy Nov 27, 2024
c81f6f8
feat: validate operator vault
alrxy Dec 2, 2024
019433a
fix: add operator vault validation
alrxy Dec 2, 2024
52ae4ff
fix: statemind-Double import of IVetoSlasher in VaultManager.sol
alrxy Dec 2, 2024
96b7949
fix: lint tests
alrxy Dec 2, 2024
702a09d
fix: statemind-Extra SLOAD and MLOAD calls
alrxy Dec 2, 2024
e772f1a
fix: statemind-Unused errors in the OperatorManager contract
alrxy Dec 2, 2024
1f5ca0f
fix: statemind-Typos
alrxy Dec 2, 2024
9992230
fix: Vault Check is outside VaultManager._validateVault()
alrxy Dec 2, 2024
3101f0f
fix: statemind-Missing slasher check
alrxy Dec 2, 2024
da22200
fix: optimize vault manager code reusing
alrxy Dec 2, 2024
95e4fd8
chore: make stake functions private
alrxy Dec 4, 2024
c7a044d
chore: rm getOperatorStake function
alrxy Dec 4, 2024
07e7171
WIP: restructure
alrxy Dec 5, 2024
639a351
feat: external read helper
alrxy Dec 5, 2024
81c65f1
chore: clean base middleware
alrxy Dec 5, 2024
990cf3e
fix: read helper
alrxy Dec 6, 2024
3957a61
refactor: restructure managers
alrxy Dec 6, 2024
a99aecb
chore: lint
alrxy Dec 6, 2024
93b9ed1
chore: interfaces and readme
alrxy Dec 6, 2024
52567e0
chore: lint
alrxy Dec 6, 2024
623be0a
chore: wip and under audits mention
alrxy Dec 6, 2024
3a30665
fix: statemind-Unable to unregister operator's key
alrxy Dec 9, 2024
d3aa340
fix: statemind-Extra memory value calls in SimplePosMiddleware._slash…
alrxy Dec 9, 2024
4cfbacd
fix: statemind-SimplePosMiddleware gas optimizations
alrxy Dec 9, 2024
838b0e6
fix: statemind-Redundant module in SqrtTaskMiddleware
alrxy Dec 9, 2024
140db6b
fix:statemind-Inconsistency between Epoch and Timestamp
alrxy Dec 9, 2024
eebbe5d
fix:statemind-Zero check for owner
alrxy Dec 9, 2024
a18cb65
fix:statemind-Incorrect storage slot location
alrxy Dec 9, 2024
e80e1e3
fix: statemind-Use custom errors instead of require
alrxy Dec 9, 2024
49e456f
fix:statemind-Multiple Time.timestamp() calls optimization
alrxy Dec 9, 2024
43d5462
fix:statemind-Typos
alrxy Dec 9, 2024
1fc8c32
fix:statemind-Missing Veto Slasher consideration
alrxy Dec 9, 2024
9deff3f
chore: add epoch duration getter
alrxy Dec 9, 2024
3832990
fix: docstrings and reader
alrxy Dec 11, 2024
1b8cec1
fix: register default subnetwork 0
alrxy Dec 11, 2024
5e24395
fix: lint
alrxy Dec 11, 2024
48828bb
chore: upd readme
alrxy Dec 11, 2024
a931af1
fix: selfed middleware
alrxy Dec 11, 2024
7470662
fix: docstring
alrxy Dec 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
src = "src"
out = "out"
libs = ["lib"]
via_ir = true
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
37 changes: 37 additions & 0 deletions src/BLSKeyManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {Time} from "@openzeppelin/contracts/utils/types/Time.sol";

import {MiddlewareStorage} from "./MiddlewareStorage.sol";
import {ArrayWithTimes} from "./libraries/ArrayWithTimes.sol";

abstract contract BLSKeyManager is MiddlewareStorage {
using ArrayWithTimes for ArrayWithTimes.Address;

error DuplicateBLSKey();

mapping(address => bytes) public blsKeys;
mapping(bytes => ArrayWithTimes.Address) internal blsKeyData;

function operatorByBLSKey(bytes memory key) public view returns (address) {
return blsKeyData[key].getAddress();
}

function operatorBLSKey(address operator) public view returns (bytes memory) {
return blsKeys[operator];
}

function blsKeyWasActiveAt(bytes memory key, uint48 timestamp) public view returns (bool) {
return blsKeyData[key].wasActiveAt(timestamp);
}

function updateBLSKey(address operator, bytes memory key) external onlyOwner {
if (blsKeyData[key].getAddress() != address(0)) {
revert DuplicateBLSKey();
}

alrxy marked this conversation as resolved.
Show resolved Hide resolved
blsKeys[operator] = key;
blsKeyData[key].set(operator);
}
}
37 changes: 37 additions & 0 deletions src/KeyManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {Time} from "@openzeppelin/contracts/utils/types/Time.sol";

import {MiddlewareStorage} from "./MiddlewareStorage.sol";
import {ArrayWithTimes} from "./libraries/ArrayWithTimes.sol";

abstract contract KeyManager is MiddlewareStorage {
using ArrayWithTimes for ArrayWithTimes.Address;

error DuplicateKey();

mapping(address => bytes32) public keys;
mapping(bytes32 => ArrayWithTimes.Address) internal keyData;

function operatorByKey(bytes32 key) public view returns (address) {
return keyData[key].getAddress();
}

function operatorKey(address operator) public view returns (bytes32) {
return keys[operator];
}

function keyWasActiveAt(bytes32 key, uint48 timestamp) public view returns (bool) {
return keyData[key].wasActiveAt(timestamp);
}

function updateKey(address operator, bytes32 key) external onlyOwner {
if (keyData[key].getAddress() != address(0)) {
revert DuplicateKey();
}

alrxy marked this conversation as resolved.
Show resolved Hide resolved
keys[operator] = key;
keyData[key].set(operator);
}
}
79 changes: 0 additions & 79 deletions src/KeyRegistry.sol

This file was deleted.

79 changes: 0 additions & 79 deletions src/KeyRegistry32.sol

This file was deleted.

34 changes: 34 additions & 0 deletions src/MiddlewareStorage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

abstract contract MiddlewareStorage is Ownable {
uint256 public subnetworks;

address public immutable NETWORK;
uint48 public immutable SLASHING_WINDOW;
address public immutable VAULT_REGISTRY;
address public immutable OPERATOR_REGISTRY;
address public immutable OPERATOR_NET_OPTIN;

uint64 public constant INSTANT_SLASHER_TYPE = 0;
uint64 public constant VETO_SLASHER_TYPE = 1;

constructor(
address owner,
address network,
uint48 slashingWindow,
address vaultRegistry,
address operatorRegistry,
address operatorNetOptIn
) Ownable(owner) {
subnetworks = 1;

NETWORK = network;
SLASHING_WINDOW = slashingWindow;
VAULT_REGISTRY = vaultRegistry;
OPERATOR_REGISTRY = operatorRegistry;
OPERATOR_NET_OPTIN = operatorNetOptIn;
}
}
59 changes: 59 additions & 0 deletions src/OperatorManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import {IRegistry} from "@symbiotic/interfaces/common/IRegistry.sol";
import {IOptInService} from "@symbiotic/interfaces/service/IOptInService.sol";

import {Time} from "@openzeppelin/contracts/utils/types/Time.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";

import {MiddlewareStorage} from "./MiddlewareStorage.sol";
import {ArrayWithTimes} from "./libraries/ArrayWithTimes.sol";

abstract contract OperatorManager is MiddlewareStorage {
using ArrayWithTimes for ArrayWithTimes.AddressArray;

error NotOperator();
error OperatorNotOptedIn();
error OperatorNotRegistered();
error OperatorAlreadyRegistred();

ArrayWithTimes.AddressArray internal operators;

function operatorsLength() external view returns (uint256) {
return operators.length();
}

function operatorWithTimesAt(uint256 pos) external view returns (address, uint48, uint48) {
return operators.at(pos);
}

function activeOperators(uint48 timestamp) public view returns (address[] memory) {
return operators.getActive(timestamp);
}

function registerOperator(address operator) external onlyOwner {
if (!IRegistry(OPERATOR_REGISTRY).isEntity(operator)) {
revert NotOperator();
}

if (!IOptInService(OPERATOR_NET_OPTIN).isOptedIn(operator, NETWORK)) {
revert OperatorNotOptedIn();
}

operators.register(operator);
}

function pauseOperator(address operator) external onlyOwner {
operators.pause(operator);
}

function unpauseOperator(address operator) external onlyOwner {
operators.unpause(operator, SLASHING_WINDOW);
}

function unregisterOperator(address operator) external onlyOwner {
operators.unregister(operator, SLASHING_WINDOW);
}
}
Loading