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
af490bbf
Unverified
Commit
af490bbf
authored
Sep 14, 2023
by
Maurelian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(ctb): Allow vetoing after the delay
test(ctb): Some DV test clean up
parent
70df6757
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
DelayedVetoable.sol
packages/contracts-bedrock/src/L1/DelayedVetoable.sol
+3
-1
DelayedVetoable.t.sol
packages/contracts-bedrock/test/DelayedVetoable.t.sol
+17
-8
No files found.
packages/contracts-bedrock/src/L1/DelayedVetoable.sol
View file @
af490bbf
...
...
@@ -147,7 +147,9 @@ contract DelayedVetoable is ISemver {
}
// Case 2: The vetoer is calling the contract to veto a call.
if (msg.sender == _vetoer && _queuedAt[callHash] != 0 && block.timestamp <= _queuedAt[callHash] + _delay) {
// Note: The vetoer retains the ability to veto even after the delay has passed. This makes censoring the vetoer
// more costly, as there is no time limit after which their transaction can be included.
if (msg.sender == _vetoer && _queuedAt[callHash] != 0) {
delete _queuedAt[callHash];
emit Vetoed(callHash, msg.data);
return;
...
...
packages/contracts-bedrock/test/DelayedVetoable.t.sol
View file @
af490bbf
...
...
@@ -35,9 +35,16 @@ contract DelayedVetoable_Init is CommonTest {
reverter = new Reverter();
}
/// @dev This function is used to prevent initiating the delay unintentionally..
/// @param data The data to be used in the call.
function assumeNonzeroData(bytes memory data) internal pure {
vm.assume(data.length > 0);
}
}
contract DelayedVetoable_Getters_Test is DelayedVetoable_Init {
/// @dev The getters return the expected values when called by the zero address.
function test_getters() external {
vm.startPrank(address(0));
assertEq(delayedVetoable.initiator(), initiator);
...
...
@@ -49,8 +56,9 @@ contract DelayedVetoable_Getters_Test is DelayedVetoable_Init {
contract DelayedVetoable_Getters_TestFail is DelayedVetoable_Init {
function test_getters_notVetoer() external {
// getter calls from addresses other than the
vetoer or
zero address will revert in the
// getter calls from addresses other than the zero address will revert in the
// initiation branch of the proxy.
vm.assume(msg.sender != address(0) && msg.sender != initiator && msg.sender != vetoer);
vm.expectRevert(abi.encodeWithSelector(Unauthorized.selector, initiator, address(this)));
delayedVetoable.initiator();
vm.expectRevert(abi.encodeWithSelector(Unauthorized.selector, initiator, address(this)));
...
...
@@ -65,9 +73,7 @@ contract DelayedVetoable_Getters_TestFail is DelayedVetoable_Init {
contract DelayedVetoable_HandleCall_Test is DelayedVetoable_Init {
/// @dev A call can be initiated by the initiator.
function testFuzz_handleCall_initiation_succeeds(bytes memory data) external {
// Calls with no data are used to activate the delay and are not valid otherwise,
// so we assume a non-zero data value.
vm.assume(data.length > 0);
assumeNonzeroData(data);
vm.expectEmit(true, false, false, true, address(delayedVetoable));
emit Initiated(keccak256(data), data);
...
...
@@ -79,9 +85,7 @@ contract DelayedVetoable_HandleCall_Test is DelayedVetoable_Init {
/// @dev The delay is inititially set to zero and the call is immediately forwarded.
function testFuzz_handleCall_initialForwardingImmediately_succeeds(bytes memory data) external {
// Calls with no data are used to activate the delay and are not valid otherwise,
// so we assume a non-zero data value.
vm.assume(data.length > 0);
assumeNonzeroData(data);
// Reset the delay to zero
vm.store(address(delayedVetoable), bytes32(uint256(0)), bytes32(uint256(0)));
...
...
@@ -97,7 +101,8 @@ contract DelayedVetoable_HandleCall_Test is DelayedVetoable_Init {
/// @dev The delay can be activated by the vetoer or initiator, and are not forwarded until the delay has passed
/// once activated.
function testFuzz_handleCall_forwardingWithDelay_succeeds(bytes memory data) external {
vm.assume(data.length > 0);
assumeNonzeroData(data);
vm.prank(initiator);
// it's immediately forwarding for some reason.
(bool success,) = address(delayedVetoable).call(data);
...
...
@@ -132,6 +137,8 @@ contract DelayedVetoable_HandleCall_TestFail is DelayedVetoable_Init {
/// @dev The call cannot be forwarded a second time.
function test_handleCall_forwardingTwice_reverts(bytes memory data) external {
assumeNonzeroData(data);
// Initiate the call
vm.prank(initiator);
(bool success,) = address(delayedVetoable).call(data);
...
...
@@ -153,6 +160,8 @@ contract DelayedVetoable_HandleCall_TestFail is DelayedVetoable_Init {
/// @dev If the target reverts, it is bubbled up.
function test_handleCall_forwardingTargetReverts_reverts(bytes memory data) external {
assumeNonzeroData(data);
vm.etch(target, address(reverter).code);
vm.prank(initiator);
...
...
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