Skip to content

Commit

Permalink
added additional safety checks for ProtocolControl
Browse files Browse the repository at this point in the history
  • Loading branch information
thogard785 committed Aug 2, 2023
1 parent 85a0cd6 commit 5944e58
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/contracts/protocol/ProtocolControl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ abstract contract ProtocolControl is Test, GovernanceControl, ExecutionBase {

// Safety and support functions and modifiers that make the relationship between protocol
// and FastLane's backend trustless.
modifier validControl() {
require(control == _control(), "ERR-PC050 InvalidControl");
_;
}
modifier mustBeDelegated() {
require(address(this) != control, "ERR-EB001 MustBeDelegated");
require(address(this) != control, "ERR-PC051 MustBeDelegated");
_;
}

Expand All @@ -85,6 +89,11 @@ abstract contract ProtocolControl is Test, GovernanceControl, ExecutionBase {
_;
}

modifier mustBeCalled() {
require(address(this) == control, "ERR-PC052 MustBeCalled");
_;
}

modifier onlyApprovedStandardCaller() {
require(msg.sender == ISafetyLocks(escrow).approvedCaller(), "ERR-PC061 InvalidCaller");
_;
Expand All @@ -93,16 +102,20 @@ abstract contract ProtocolControl is Test, GovernanceControl, ExecutionBase {
modifier onlyApprovedCaller(bool isDelegated) {
if (isDelegated) {
require(msg.sender == escrow, "ERR-PC060 InvalidCaller");
require(address(this) != control, "ERR-PC051 MustBeDelegated");
} else {
require(msg.sender == ISafetyLocks(escrow).approvedCaller(), "ERR-PC061 InvalidCaller");
require(address(this) == control, "ERR-PC052 MustBeCalled");
}
require(control == _control(), "ERR-PC053 InvalidControl");
_;
}

function stagingCall(address to, address from, bytes4 userSelector, bytes calldata userData)
external
mustBeDelegated
onlyApprovedDelegateCaller
validControl
returns (bytes memory)
{
return _stagingCall(to, from, userSelector, userData);
Expand All @@ -112,6 +125,7 @@ abstract contract ProtocolControl is Test, GovernanceControl, ExecutionBase {
external
mustBeDelegated
onlyApprovedDelegateCaller
validControl
returns (bytes memory)
{
return delegateUser ? _userLocalDelegateCall(data) : _userLocalStandardCall(data);
Expand All @@ -121,6 +135,7 @@ abstract contract ProtocolControl is Test, GovernanceControl, ExecutionBase {
external
mustBeDelegated
onlyApprovedDelegateCaller
validControl
{
return _allocatingCall(data);
}
Expand All @@ -129,6 +144,7 @@ abstract contract ProtocolControl is Test, GovernanceControl, ExecutionBase {
external
mustBeDelegated
onlyApprovedDelegateCaller
validControl
returns (bool)
{
return _verificationCall(data);
Expand Down

0 comments on commit 5944e58

Please sign in to comment.