Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
82f27c29
Unverified
Commit
82f27c29
authored
Sep 15, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(ctb): Inline the _activateDelay logic
This change will enable forwarding zero length data
parent
a4c66440
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
12 deletions
+10
-12
DelayedVetoable.sol
packages/contracts-bedrock/src/L1/DelayedVetoable.sol
+4
-9
DelayedVetoable.t.sol
packages/contracts-bedrock/test/DelayedVetoable.t.sol
+6
-3
No files found.
packages/contracts-bedrock/src/L1/DelayedVetoable.sol
View file @
82f27c29
...
@@ -6,6 +6,7 @@ import { ISemver } from "src/universal/ISemver.sol";
...
@@ -6,6 +6,7 @@ import { ISemver } from "src/universal/ISemver.sol";
/// @title DelayedVetoable
/// @title DelayedVetoable
/// @notice This contract enables a delay before a call is forwarded to a target contract, and during the delay period
/// @notice This contract enables a delay before a call is forwarded to a target contract, and during the delay period
/// the call can be vetoed by the authorized vetoer.
/// the call can be vetoed by the authorized vetoer.
/// This contract does not support value transfers, only data is forwarded.
contract DelayedVetoable is ISemver {
contract DelayedVetoable is ISemver {
/// @notice Error for when the delay has already been set.
/// @notice Error for when the delay has already been set.
error AlreadyDelayed();
error AlreadyDelayed();
...
@@ -128,11 +129,12 @@ contract DelayedVetoable is ISemver {
...
@@ -128,11 +129,12 @@ contract DelayedVetoable is ISemver {
/// the need for additional layers of abi encoding.
/// the need for additional layers of abi encoding.
function _handleCall() internal {
function _handleCall() internal {
// The initiator and vetoer activate the delay by passing in null data.
// The initiator and vetoer activate the delay by passing in null data.
if (msg.data.length == 0) {
if (msg.data.length == 0
&& _delay == 0
) {
if (msg.sender != INITIATOR && msg.sender != VETOER) {
if (msg.sender != INITIATOR && msg.sender != VETOER) {
revert Unauthorized(INITIATOR, msg.sender);
revert Unauthorized(INITIATOR, msg.sender);
}
}
_activateDelay();
_delay = OPERATING_DELAY;
emit DelayActivated(_delay);
return;
return;
}
}
...
@@ -190,11 +192,4 @@ contract DelayedVetoable is ISemver {
...
@@ -190,11 +192,4 @@ contract DelayedVetoable is ISemver {
}
}
}
}
}
}
/// @notice Sets the delay to the operating delay.
function _activateDelay() internal {
if (_delay != 0) revert AlreadyDelayed();
_delay = OPERATING_DELAY;
emit DelayActivated(_delay);
}
}
}
packages/contracts-bedrock/test/DelayedVetoable.t.sol
View file @
82f27c29
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
pragma solidity 0.8.15;
pragma solidity 0.8.15;
import { CommonTest } from "./CommonTest.t.sol";
import { CommonTest } from "./CommonTest.t.sol";
import { DelayedVetoable } from "
../
src/L1/DelayedVetoable.sol";
import { DelayedVetoable } from "src/L1/DelayedVetoable.sol";
contract DelayedVetoable_Init is CommonTest {
contract DelayedVetoable_Init is CommonTest {
error Unauthorized(address expected, address actual);
error Unauthorized(address expected, address actual);
...
@@ -109,6 +109,11 @@ contract DelayedVetoable_HandleCall_Test is DelayedVetoable_Init {
...
@@ -109,6 +109,11 @@ contract DelayedVetoable_HandleCall_Test is DelayedVetoable_Init {
vm.prank(initiator);
vm.prank(initiator);
(bool success,) = address(delayedVetoable).call(data);
(bool success,) = address(delayedVetoable).call(data);
// Check that the call is in the _queuedAt mapping
bytes32 callHash = keccak256(data);
vm.prank(address(0));
assertEq(delayedVetoable.queuedAt(callHash), block.timestamp);
vm.warp(block.timestamp + operatingDelay);
vm.warp(block.timestamp + operatingDelay);
vm.expectEmit(true, false, false, true, address(delayedVetoable));
vm.expectEmit(true, false, false, true, address(delayedVetoable));
emit Forwarded(keccak256(data), data);
emit Forwarded(keccak256(data), data);
...
@@ -124,7 +129,6 @@ contract DelayedVetoable_HandleCall_TestFail is DelayedVetoable_Init {
...
@@ -124,7 +129,6 @@ contract DelayedVetoable_HandleCall_TestFail is DelayedVetoable_Init {
function test_handleCall_unauthorizedInitiation_reverts() external {
function test_handleCall_unauthorizedInitiation_reverts() external {
vm.expectRevert(abi.encodeWithSelector(Unauthorized.selector, initiator, address(this)));
vm.expectRevert(abi.encodeWithSelector(Unauthorized.selector, initiator, address(this)));
(bool success,) = address(delayedVetoable).call(NON_ZERO_DATA);
(bool success,) = address(delayedVetoable).call(NON_ZERO_DATA);
assertTrue(success);
}
}
/// @dev The call cannot be forewarded until the delay has passed.
/// @dev The call cannot be forewarded until the delay has passed.
...
@@ -134,7 +138,6 @@ contract DelayedVetoable_HandleCall_TestFail is DelayedVetoable_Init {
...
@@ -134,7 +138,6 @@ contract DelayedVetoable_HandleCall_TestFail is DelayedVetoable_Init {
vm.expectRevert(abi.encodeWithSelector(ForwardingEarly.selector));
vm.expectRevert(abi.encodeWithSelector(ForwardingEarly.selector));
(success,) = address(delayedVetoable).call(data);
(success,) = address(delayedVetoable).call(data);
assertFalse(success);
}
}
/// @dev The call cannot be forwarded a second time.
/// @dev The call cannot be forwarded a second time.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment