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

feat: Added access control contract to make guardian granular #20

Merged
merged 27 commits into from
May 17, 2024
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
f7d4d18
feat: Added access control contract to make guardian granular
sendra Dec 20, 2023
d4b671e
fix: updated with oz (modified) enumerable access control
sendra Dec 20, 2023
98fad05
fix: added natspec
sendra Dec 20, 2023
ac89c0e
fix: Add test
sendra Dec 20, 2023
e114d27
fix: added method to change guardian
sendra Dec 20, 2023
5612b26
fix: added deployment script. Updated address book lib
sendra Dec 20, 2023
4c73aaf
fix: save granular guardian in deployment jsons
sendra Dec 21, 2023
c78f581
fix: add integration tests
sendra Dec 21, 2023
b18fb13
fix: added more integration tests
sendra Dec 22, 2023
8044f4d
fix: fixed retry envelope int test
sendra Dec 22, 2023
c1ff698
fix: solved conflicts
sendra Apr 17, 2024
804717f
fix: fixed fuzzing on tests
sendra Apr 17, 2024
30365f3
fix: ci
sakulstra Apr 17, 2024
c064a3d
fix: removed fork environment for tests
sendra Apr 17, 2024
641a1bc
fix: added extra tests
sendra Apr 17, 2024
5ddbae8
fix: add readme
sendra Apr 18, 2024
1b4455f
Update scripts/access_control/Deploy_Granular_CCC_Guardian.s.sol
sendra Apr 19, 2024
7a8e35f
Update scripts/access_control/Deploy_Granular_CCC_Guardian.s.sol
sendra Apr 19, 2024
8b79676
fix: WIP: integration tests still not working
sendra Apr 19, 2024
66e4ea2
fix: all tests working
sendra Apr 19, 2024
54770fb
fix: removed unused mock
sendra Apr 19, 2024
d104463
fix: moved errors to interface. Fixed test
sendra Apr 24, 2024
6b0370e
fix: added correct check
sendra May 6, 2024
9bb8ce1
add report for Granular-Guardian-Access-Control
nisnislevi May 7, 2024
6197b19
Merge pull request #52 from Certora/certora-for-granular-access-control
sendra May 17, 2024
df417af
Merge branch 'feat/phase-3' of github.com:bgd-labs/aave-delivery-infr…
sendra May 17, 2024
0542da4
fix: added link to audit report
sendra May 17, 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
Prev Previous commit
Next Next commit
fix: added natspec
sendra committed Dec 20, 2023
commit 98fad052e6436f1af4c2c1d0aee7c0f069cc55e6
26 changes: 22 additions & 4 deletions src/contracts/access_control/GranularGuardianAccessControl.sol
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.8;

import {ICrossChainReceiver} from '../interfaces/ICrossChainReceiver.sol';
import {ICrossChainForwarder} from '../interfaces/ICrossChainForwarder.sol';
import {ICrossChainControllerWithEmergencyMode} from '../interfaces/ICrossChainControllerWithEmergencyMode.sol';
import {Envelope} from '../libs/EncodingUtils.sol';
//import {AccessControlEnumerable} from 'openzeppelin-contracts/contracts/access/AccessControlEnumerable.sol';
import {AccessControlEnumerable} from './AccessControlEnumerable.sol';
import {IGranularGuardianAccessControl, Envelope} from './IGranularGuardianAccessControl.sol';

//import {AccessControlEnumerable} from 'openzeppelin-contracts/contracts/access/AccessControlEnumerable.sol';

contract GranularGuardianAccessControl is AccessControlEnumerable {
/**
* @title GranularGuardianAccessControl
* @author BGD Labs
* @notice Contract to manage a granular access to the methods safeguarded by guardian on CrossChainController
*/
contract GranularGuardianAccessControl is AccessControlEnumerable, IGranularGuardianAccessControl {
/// @inheritdoc IGranularGuardianAccessControl
address public immutable CROSS_CHAIN_CONTROLLER;

/// @inheritdoc IGranularGuardianAccessControl
bytes32 public constant SOLVE_EMERGENCY_ROLE = keccak256('SOLVE_EMERGENCY_ROLE');

/// @inheritdoc IGranularGuardianAccessControl
bytes32 public constant RETRY_ROLE = keccak256('RETRY_ROLE');

/**
* @param defaultAdmin address that will have control of the default admin
* @param retryGuardian address to be added to the retry role
* @param solveEmergencyGuardian address to be added to the solve emergency role
* @param crossChainController address of the CrossChainController
*/
constructor(
address defaultAdmin,
address retryGuardian,
@@ -32,13 +47,15 @@ contract GranularGuardianAccessControl is AccessControlEnumerable {
_grantRole(RETRY_ROLE, retryGuardian);
}

/// @inheritdoc IGranularGuardianAccessControl
function retryEnvelope(
Envelope memory envelope,
uint256 gasLimit
) external onlyRole(RETRY_ROLE) returns (bytes32) {
return ICrossChainForwarder(CROSS_CHAIN_CONTROLLER).retryEnvelope(envelope, gasLimit);
}

/// @inheritdoc IGranularGuardianAccessControl
function retryTransaction(
bytes memory encodedTransaction,
uint256 gasLimit,
@@ -51,6 +68,7 @@ contract GranularGuardianAccessControl is AccessControlEnumerable {
);
}

/// @inheritdoc IGranularGuardianAccessControl
function solveEmergency(
ICrossChainReceiver.ConfirmationInput[] memory newConfirmations,
ICrossChainReceiver.ValidityTimestampInput[] memory newValidityTimestamp,
47 changes: 46 additions & 1 deletion src/contracts/access_control/IGranularGuardianAccessControl.sol
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
pragma solidity ^0.8.8;

import {Envelope} from '../libs/EncodingUtils.sol';
import {ICrossChainReceiver} from '../interfaces/ICrossChainReceiver.sol';
import {ICrossChainForwarder} from '../interfaces/ICrossChainForwarder.sol';

/**
* @title IGranularGuardianAccessControl
@@ -11,6 +13,7 @@ import {Envelope} from '../libs/EncodingUtils.sol';
interface IGranularGuardianAccessControl {
/**
* @notice method called to re forward a previously sent envelope.
This method is only callable by the accounts holding the RETRY_ROLE role
* @param envelope the Envelope type data
* @param gasLimit gas cost on receiving side of the message
* @return the transaction id that has the retried envelope
@@ -22,7 +25,8 @@ interface IGranularGuardianAccessControl {
function retryEnvelope(Envelope memory envelope, uint256 gasLimit) external returns (bytes32);

/**
* @notice method to retry forwarding an already forwarded transaction
* @notice method to retry forwarding an already forwarded transaction.
This method is only callable by the accounts holding the RETRY_ROLE role
* @param encodedTransaction the encoded Transaction data
* @param gasLimit limit of gas to spend on forwarding per bridge
* @param bridgeAdaptersToRetry list of bridge adapters to be used for the transaction forwarding retry
@@ -35,4 +39,45 @@ interface IGranularGuardianAccessControl {
uint256 gasLimit,
address[] memory bridgeAdaptersToRetry
) external;

/**
* @notice method to solve an emergency. This method is only callable by the accounts holding the SOLVE_EMERGENCY_ROLE role
* @param newConfirmations number of confirmations necessary for a message to be routed to destination
* @param newValidityTimestamp timestamp in seconds indicating the point to where not confirmed messages will be
* invalidated.
* @param receiverBridgeAdaptersToAllow list of bridge adapter addresses to be allowed to receive messages
* @param receiverBridgeAdaptersToDisallow list of bridge adapter addresses to be disallowed
* @param sendersToApprove list of addresses to be approved as senders
* @param sendersToRemove list of sender addresses to be removed
* @param forwarderBridgeAdaptersToEnable list of bridge adapters to be enabled to send messages
* @param forwarderBridgeAdaptersToDisable list of bridge adapters to be disabled
*/
function solveEmergency(
ICrossChainReceiver.ConfirmationInput[] memory newConfirmations,
ICrossChainReceiver.ValidityTimestampInput[] memory newValidityTimestamp,
ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory receiverBridgeAdaptersToAllow,
ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory receiverBridgeAdaptersToDisallow,
address[] memory sendersToApprove,
address[] memory sendersToRemove,
ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory forwarderBridgeAdaptersToEnable,
ICrossChainForwarder.BridgeAdapterToDisable[] memory forwarderBridgeAdaptersToDisable
) external;

/**
* @notice method to get the address of the CrossChainController where the contract points to
* @return the address of the CrossChainController
*/
function CROSS_CHAIN_CONTROLLER() external view returns (address);

/**
* @notice method to get the solve emergency role
* @return the solve emergency role id
*/
function SOLVE_EMERGENCY_ROLE() external view returns (bytes32);

/**
* @notice method to get the retry role
* @return the retry role id
*/
function RETRY_ROLE() external view returns (bytes32);
}