Skip to content

Commit a578f90

Browse files
jatZamadartdart26
authored andcommitted
feat(host-contracts): cleanup ACL (#1036)
* feat(host-contracts): cleanup ACL * chore(host-contracts): updated tests and selectors * chore(coprocessor): removed deprecated events chore(coprocessor): fix typo * chore(host-contracts): update readme
1 parent f605050 commit a578f90

File tree

8 files changed

+111
-491
lines changed

8 files changed

+111
-491
lines changed

coprocessor/fhevm-engine/host-listener/src/database/tfhe_event_propagate.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -551,12 +551,6 @@ impl Database {
551551
AclContractEvents::Initialized(initialized) => {
552552
warn!(event = ?initialized, "unhandled Acl::Initialized event");
553553
}
554-
AclContractEvents::NewDelegation(new_delegation) => {
555-
warn!(
556-
event = ?new_delegation,
557-
"unhandled Acl::NewDelegation event"
558-
);
559-
}
560554
AclContractEvents::OwnershipTransferStarted(
561555
ownership_transfer_started,
562556
) => {
@@ -571,12 +565,6 @@ impl Database {
571565
"unhandled Acl::OwnershipTransferred event"
572566
);
573567
}
574-
AclContractEvents::RevokedDelegation(revoked_delegation) => {
575-
warn!(
576-
event = ?revoked_delegation,
577-
"unhandled Acl::RevokedDelegation event"
578-
);
579-
}
580568
AclContractEvents::Upgraded(upgraded) => {
581569
warn!(
582570
event = ?upgraded,
@@ -595,12 +583,6 @@ impl Database {
595583
"unhandled Acl::Unpaused event"
596584
);
597585
}
598-
AclContractEvents::UpdatePauser(update_pauser) => {
599-
warn!(
600-
event = ?update_pauser,
601-
"unhandled Acl::UpdatePauser event"
602-
);
603-
}
604586
}
605587
self.tick.update();
606588
Ok(())
@@ -785,13 +767,10 @@ pub fn acl_result_handles(event: &Log<AclContractEvents>) -> Vec<Handle> {
785767
allowed_for_decryption.handlesList.clone()
786768
}
787769
AclContractEvents::Initialized(_)
788-
| AclContractEvents::NewDelegation(_)
789770
| AclContractEvents::OwnershipTransferStarted(_)
790771
| AclContractEvents::OwnershipTransferred(_)
791-
| AclContractEvents::RevokedDelegation(_)
792772
| AclContractEvents::Upgraded(_)
793773
| AclContractEvents::Paused(_)
794-
| AclContractEvents::Unpaused(_)
795-
| AclContractEvents::UpdatePauser(_) => vec![],
774+
| AclContractEvents::Unpaused(_) => vec![],
796775
}
797776
}

host-contracts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
## Introduction
22

3-
This node package contains all the Solidity core contracts needed to deploy an FHEVM instance.
3+
This node package contains the core Solidity host contracts needed to deploy an FHEVM instance on a host EVM blockchain.

host-contracts/contracts/ACL.sol

Lines changed: 0 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,9 @@ import {ACLEvents} from "./ACLEvents.sol";
1717
* secure while still being usable within authorized contexts.
1818
*/
1919
contract ACL is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, PausableUpgradeable, ACLEvents {
20-
/// @notice Returned if the delegatee contract is already delegatee for sender & delegator addresses.
21-
/// @param delegatee delegatee address.
22-
/// @param contractAddress contract address.
23-
error AlreadyDelegated(address delegatee, address contractAddress);
24-
25-
/// @notice Returned if the sender is the delegatee address.
26-
error SenderCannotBeContractAddress(address contractAddress);
27-
28-
/// @notice Returned if the contractAddresses array is empty.
29-
error ContractAddressesIsEmpty();
30-
31-
/// @notice Maximum length of contractAddresses array exceeded.
32-
error ContractAddressesMaxLengthExceeded();
33-
3420
/// @notice Returned if the handlesList array is empty.
3521
error HandlesListIsEmpty();
3622

37-
/// @notice Returned if the the delegatee contract is not already delegatee for sender & delegator addresses.
38-
/// @param delegatee delegatee address.
39-
/// @param contractAddress contract address.
40-
error NotDelegatedYet(address delegatee, address contractAddress);
41-
4223
/// @notice Returned if the sender address is not allowed to pause the contract.
4324
error NotPauser(address sender);
4425

@@ -50,7 +31,6 @@ contract ACL is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, PausableUpgr
5031
struct ACLStorage {
5132
mapping(bytes32 handle => mapping(address account => bool isAllowed)) persistedAllowedPairs;
5233
mapping(bytes32 handle => bool isAllowedForDecryption) allowedForDecryption;
53-
mapping(address account => mapping(address delegatee => mapping(address contractAddress => bool isDelegate))) delegates;
5434
}
5535

5636
/// @notice Name of the contract.
@@ -71,9 +51,6 @@ contract ACL is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, PausableUpgr
7151
/// @notice PauserSet contract.
7252
IPauserSet private constant PAUSER_SET = IPauserSet(pauserSetAdd);
7353

74-
/// @notice maximum length of contractAddresses array during delegation.
75-
uint256 private constant MAX_NUM_CONTRACT_ADDRESSES = 10;
76-
7754
/// Constant used for making sure the version number used in the `reinitializer` modifier is
7855
/// identical between `initializeFromEmptyProxy` and the `reinitializeVX` method
7956
uint64 private constant REINITIALIZER_VERSION = 2;
@@ -162,59 +139,6 @@ contract ACL is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, PausableUpgr
162139
}
163140
}
164141

165-
/**
166-
* @notice Delegates the access of handles in the context of account abstraction for issuing
167-
* reencryption requests from a smart contract account.
168-
* @param delegatee Delegatee address.
169-
* @param contractAddresses Contract addresses.
170-
*/
171-
function delegateAccount(address delegatee, address[] memory contractAddresses) public virtual whenNotPaused {
172-
uint256 lengthContractAddresses = contractAddresses.length;
173-
if (lengthContractAddresses == 0) {
174-
revert ContractAddressesIsEmpty();
175-
}
176-
if (lengthContractAddresses > MAX_NUM_CONTRACT_ADDRESSES) {
177-
revert ContractAddressesMaxLengthExceeded();
178-
}
179-
180-
ACLStorage storage $ = _getACLStorage();
181-
for (uint256 k = 0; k < lengthContractAddresses; k++) {
182-
if (contractAddresses[k] == msg.sender) {
183-
revert SenderCannotBeContractAddress(contractAddresses[k]);
184-
}
185-
if ($.delegates[msg.sender][delegatee][contractAddresses[k]]) {
186-
revert AlreadyDelegated(delegatee, contractAddresses[k]);
187-
}
188-
$.delegates[msg.sender][delegatee][contractAddresses[k]] = true;
189-
}
190-
191-
emit NewDelegation(msg.sender, delegatee, contractAddresses);
192-
}
193-
194-
/**
195-
* @notice Revokes delegated access of handles in the context of account abstraction for issuing
196-
* reencryption requests from a smart contract account.
197-
* @param delegatee Delegatee address.
198-
* @param contractAddresses Contract addresses.
199-
*/
200-
function revokeDelegation(address delegatee, address[] memory contractAddresses) public virtual whenNotPaused {
201-
uint256 lengthContractAddresses = contractAddresses.length;
202-
if (lengthContractAddresses == 0) {
203-
revert ContractAddressesIsEmpty();
204-
}
205-
206-
ACLStorage storage $ = _getACLStorage();
207-
208-
for (uint256 k = 0; k < lengthContractAddresses; k++) {
209-
if (!$.delegates[msg.sender][delegatee][contractAddresses[k]]) {
210-
revert NotDelegatedYet(delegatee, contractAddresses[k]);
211-
}
212-
$.delegates[msg.sender][delegatee][contractAddresses[k]] = false;
213-
}
214-
215-
emit RevokedDelegation(msg.sender, delegatee, contractAddresses);
216-
}
217-
218142
/**
219143
* @dev Triggers stopped state.
220144
* Only a pauser address can pause.
@@ -236,27 +160,6 @@ contract ACL is UUPSUpgradeableEmptyProxy, Ownable2StepUpgradeable, PausableUpgr
236160
_unpause();
237161
}
238162

239-
/**
240-
* @notice Returns whether the delegatee is allowed to access the handle.
241-
* @param delegatee Delegatee address.
242-
* @param handle Handle.
243-
* @param contractAddress Contract address.
244-
* @param account Address of the account.
245-
* @return isAllowed Whether the handle can be accessed.
246-
*/
247-
function allowedOnBehalf(
248-
address delegatee,
249-
bytes32 handle,
250-
address contractAddress,
251-
address account
252-
) public view virtual returns (bool) {
253-
ACLStorage storage $ = _getACLStorage();
254-
return
255-
$.persistedAllowedPairs[handle][account] &&
256-
$.persistedAllowedPairs[handle][contractAddress] &&
257-
$.delegates[account][delegatee][contractAddress];
258-
}
259-
260163
/**
261164
* @notice Checks whether the account is allowed to use the handle in the
262165
* same transaction (transient).

host-contracts/contracts/ACLEvents.sol

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,4 @@ contract ACLEvents {
1212
/// @param caller account calling the allowForDecryption function.
1313
/// @param handlesList List of handles allowed for decryption.
1414
event AllowedForDecryption(address indexed caller, bytes32[] handlesList);
15-
16-
/// @notice Emitted when a new delegatee address is added.
17-
/// @param caller caller address
18-
/// @param delegatee Delegatee address.
19-
/// @param contractAddresses Contract addresses.
20-
event NewDelegation(address indexed caller, address indexed delegatee, address[] contractAddresses);
21-
22-
/// @notice Emitted when a delegatee address is revoked.
23-
/// @param caller caller address
24-
/// @param delegatee Delegatee address.
25-
/// @param contractAddresses Contract addresses.
26-
event RevokedDelegation(address indexed caller, address indexed delegatee, address[] contractAddresses);
27-
28-
/// @notice Emitted when the pauser address is updated.
29-
/// @param newPauser New pauser address.
30-
event UpdatePauser(address indexed newPauser);
3115
}

0 commit comments

Comments
 (0)