@@ -7,11 +7,8 @@ import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/I
77// solhint-disable-next-line max-line-length
88import { AccessControlledUpgradeable } from "@synaps3/core/primitives/upgradeable/AccessControlledUpgradeable.sol " ;
99import { QuorumUpgradeable } from "@synaps3/core/primitives/upgradeable/QuorumUpgradeable.sol " ;
10- import { IAgreementSettler } from "@synaps3/core/interfaces/financial/IAgreementSettler.sol " ;
11- import { IFeeSchemeValidator } from "@synaps3/core/interfaces/economics/IFeeSchemeValidator.sol " ;
1210import { ICustodianReferendum } from "@synaps3/core/interfaces/custody/ICustodianReferendum.sol " ;
1311import { ICustodianFactory } from "@synaps3/core/interfaces/custody/ICustodianFactory.sol " ;
14- import { FinancialOps } from "@synaps3/core/libraries/FinancialOps.sol " ;
1512import { T } from "@synaps3/core/primitives/Types.sol " ;
1613
1714/// @title CustodianReferendum
@@ -24,27 +21,17 @@ contract CustodianReferendum is
2421 UUPSUpgradeable ,
2522 QuorumUpgradeable ,
2623 AccessControlledUpgradeable ,
27- ICustodianReferendum ,
28- IFeeSchemeValidator
24+ ICustodianReferendum
2925{
30- using FinancialOps for address ;
31-
3226 /// @custom:oz-upgrades-unsafe-allow state-variable-immutable
33- IAgreementSettler public immutable AGREEMENT_SETTLER;
3427 ICustodianFactory public immutable CUSTODIAN_FACTORY;
3528 //slither-disable-end naming-convention
3629
37- /// @dev Defines the expiration period for enrollment, determining how long a custodian remains active.
38- uint256 private _expirationPeriod;
3930 /// @dev Tracks the number of active enrollments within the system.
4031 uint256 private _enrollmentsCount;
41- /// @dev Maps a custodian's address to their respective enrollment deadline timestamp.
42- mapping (address => uint256 ) private _enrollmentDeadline;
43-
4432 /// @notice Event emitted when a custodian is registered
4533 /// @param custodian The address of the registered custodian
46- /// @param paidFees The amount of fees that were paid upon registration
47- event Registered (address indexed custodian , uint256 paidFees );
34+ event Registered (address indexed custodian );
4835
4936 /// @notice Event emitted when a custodian is approved
5037 /// @param custodian The address of the approved custodian
@@ -54,34 +41,25 @@ contract CustodianReferendum is
5441 /// @param custodian The address of the revoked custodian
5542 event Revoked (address indexed custodian );
5643
57- /// @notice Emitted when a new period is set
58- /// @param newPeriod The new period that is set, could be in seconds, blocks, or any other unit
59- event PeriodSet (uint256 newPeriod );
60-
6144 /// @notice Error thrown when the custodian is not recognized by the factory.
6245 /// @param custodian The address of the unregistered custodian contract.
6346 error UnregisteredCustodian (address custodian );
6447
65- /// @notice Error thrown when the custodian does not match the agreement's registered party.
66- /// @param custodian The custodian provided for the operation.s
67- error CustodianAgreementMismatch (address custodian );
68-
6948 /// @notice Modifier to ensure the custodian was deployed through the trusted factory.
7049 /// @param custodian The address of the custodian contract to verify.
7150 modifier onlyValidCustodian (address custodian ) {
7251 // ensure the custodian was deployed through the trusted factory and is known to the protocol
7352 if (! CUSTODIAN_FACTORY.isRegistered (custodian)) {
74- revert UnregisteredCustodian (msg . sender );
53+ revert UnregisteredCustodian (custodian );
7554 }
7655 _;
7756 }
7857
7958 /// @custom:oz-upgrades-unsafe-allow constructor
80- constructor (address agreementSettler , address custodianFactory ) {
59+ constructor (address custodianFactory ) {
8160 /// https://forum.openzeppelin.com/t/what-does-disableinitializers-function-mean/28730/5
8261 /// https://forum.openzeppelin.com/t/uupsupgradeable-vulnerability-post-mortem/15680
8362 _disableInitializers ();
84- AGREEMENT_SETTLER = IAgreementSettler (agreementSettler);
8563 CUSTODIAN_FACTORY = ICustodianFactory (custodianFactory);
8664 }
8765
@@ -90,54 +68,19 @@ contract CustodianReferendum is
9068 __Quorum_init ();
9169 __UUPSUpgradeable_init ();
9270 __AccessControlled_init (accessManager);
93- // 6 months initially..
94- _expirationPeriod = 180 days ;
95- }
96-
97- /// @notice Checks if the given fee scheme is supported in this context.
98- /// @param scheme The fee scheme to validate.
99- /// @return True if the scheme is supported.
100- function isFeeSchemeSupported (T.Scheme scheme ) external pure returns (bool ) {
101- // support only FLAT scheme
102- return scheme == T.Scheme.FLAT;
103- }
104-
105- /// @notice Retrieves the current expiration period for enrollments or registrations.
106- function getExpirationPeriod () external view returns (uint256 ) {
107- return _expirationPeriod;
108- }
109-
110- /// @notice Retrieves the enrollment deadline for a custodian.
111- /// @param custodian The address of the custodian.
112- function getEnrollmentDeadline (address custodian ) external view returns (uint256 ) {
113- return _enrollmentDeadline[custodian];
114- }
115-
116- /// @notice Retrieves the total number of enrollments.
117- function getEnrollmentCount () external view returns (uint256 ) {
118- return _enrollmentsCount;
11971 }
12072
12173 /// @notice Checks if the entity is active.
12274 /// @dev This function verifies the active status of the custodian.
12375 /// @param custodian The custodian's address to check.
12476 function isActive (address custodian ) external view returns (bool ) {
125- // TODO a renovation mechanism is needed to update the enrollment time
126- /// It ensures that custodians remain engaged and do not become inactive for extended periods.
127- /// The enrollment deadline enforces a time-based mechanism where custodians must renew
128- /// their registration to maintain their active status. This prevents dormant custodians
129- /// from continuing to benefit from the protocol without contributing.
130-
13177 // TODO add stateful management to custodians contract, the custodian can
13278 // change his state to "maintenance mode" or "inactive" if its facing issues
13379 // in that way the custodian is omitted during load balancing.
13480 // in this line we can check if the custodian contract is active custodian.isActive()
13581 // this is important feature if the custodians want to avoid harm reputation
13682
137- // This mechanism helps to verify the availability of the custodian,
138- // forcing recurrent registrations and ensuring ongoing participation.
139- bool notExpiredDeadline = _enrollmentDeadline[custodian] > block .timestamp ;
140- return _status (uint160 (custodian)) == T.Status.Active && notExpiredDeadline;
83+ return _status (uint160 (custodian)) == T.Status.Active;
14184 }
14285
14386 /// @notice Checks if the entity is waiting.
@@ -154,61 +97,34 @@ contract CustodianReferendum is
15497 return _status (uint160 (custodian)) == T.Status.Blocked;
15598 }
15699
157- /// @notice Registers a custodian by sending a payment to the contract.
158- /// @param proof The unique identifier of the agreement to be enforced.
100+ /// @notice Registers a custodian to be approved by council.
159101 /// @param custodian The address of the custodian to register.
160- function register (uint256 proof , address custodian ) external onlyValidCustodian (custodian) {
161- /// TODO penalize invalid endpoints, and revoked during referendum
162- // !IMPORTANT:
163- // Fees act as a mechanism to prevent abuse or spam by users
164- // when submitting custodians for approval. This discourages users from
165- // making frivolous or excessive registrations without genuine intent.
166- //
167- // Additionally, the fees establish a foundation of real interest and commitment
168- // from the custodian. This ensures that only those who see value in the protocol
169- // and are willing to contribute to its ecosystem will participate.
170- //
171- // The collected fees are used to support the protocol's operations, aligning
172- // individual actions with the broader sustainability of the network.
173-
174- // IMPORTANT:
175- // The expected fees are locked in the agreement, based on the custodians fees defined by the tollgate.
176- // If the fee amount is insufficient, the transaction will revert during agreement creation.
177- // Only valid agreements can be settled; the validity is guaranteed by the proof.
178- T.Agreement memory agreement = AGREEMENT_SETTLER.settleAgreement (proof, msg .sender );
179- if (agreement.parties[0 ] != custodian) {
180- revert CustodianAgreementMismatch (custodian);
181- }
182-
102+ function register (address custodian ) external onlyValidCustodian (custodian) {
183103 // register custodian as pending approval
184104 _register (uint160 (custodian));
185105 // set the custodian active enrollment period..
186- // after this time the custodian is considered inactive and cannot collect his profits...
187- _enrollmentDeadline[custodian] = block .timestamp + _expirationPeriod;
188- emit Registered (custodian, agreement.fees);
106+ emit Registered (custodian);
189107 }
190108
191109 /// @notice Approves a custodian's registration.
192110 /// @param custodian The address of the custodian to approve.
193111 function approve (address custodian ) external restricted {
194- _enrollmentsCount++ ;
195112 _approve (uint160 (custodian));
113+ _enrollmentsCount++ ;
196114 emit Approved (custodian);
197115 }
198116
199117 /// @notice Revokes the registration of a custodian.
200118 /// @param custodian The address of the custodian to revoke.
201119 function revoke (address custodian ) external restricted {
202- _enrollmentsCount-- ;
203120 _revoke (uint160 (custodian));
121+ _enrollmentsCount-- ;
204122 emit Revoked (custodian);
205123 }
206124
207- /// @notice Sets a new expiration period for an enrollment or registration.
208- /// @param newPeriod The new expiration period, in seconds.
209- function setExpirationPeriod (uint256 newPeriod ) external restricted {
210- _expirationPeriod = newPeriod;
211- emit PeriodSet (newPeriod);
125+ /// @notice Retrieves the total number of enrollments.
126+ function getEnrollmentCount () external view returns (uint256 ) {
127+ return _enrollmentsCount;
212128 }
213129
214130 /// @notice Function that should revert when msg.sender is not authorized to upgrade the contract.
0 commit comments