Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion slither.db.json

Large diffs are not rendered by default.

63 changes: 63 additions & 0 deletions src/chain/TipCollectionToggler.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2022-2026, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;

import "../precompiles/ArbOwner.sol";
import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";

contract TipCollectionToggler is AccessControlEnumerable {
ArbOwner internal constant ARB_OWNER = ArbOwner(address(0x70));
uint256 internal constant ACTIVATION_DURATION = 2 * 365 days; // 2 years

bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
uint256 public expiryTimestamp;

error NotExpired();
error NotActivated();
error AlreadyActivated();

event Activated(uint256 expiryTimestamp);
event Revoked();
event CollectTipsUpdated(bool collectTips);

modifier onlyActivated() {
if (expiryTimestamp == 0) {
revert NotActivated();
}
_;
}
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed

constructor(address admin, address manager) {
_setupRole(DEFAULT_ADMIN_ROLE, admin);
_setupRole(MANAGER_ROLE, manager);
}

/// @notice Activates the contract for a fixed duration, allowing tip collection to be toggled.
function activate() external onlyRole(DEFAULT_ADMIN_ROLE) {
if (expiryTimestamp != 0) {
revert AlreadyActivated();
}
expiryTimestamp = block.timestamp + ACTIVATION_DURATION;
emit Activated(expiryTimestamp);
}

/// @notice Removes the contract from the list of chain owners after the expiry timestamp
function revoke() external onlyActivated {
if (block.timestamp < expiryTimestamp) {
revert NotExpired();
}
ARB_OWNER.removeChainOwner(address(this));
Comment thread
godzillaba marked this conversation as resolved.
emit Revoked();
}

/// @notice Enables or disables tip collection.
/// @param collectTips If true, transaction tips are collected by the network fee account. If false (default), tips are dropped.
function setCollectTips(
bool collectTips
) external onlyRole(MANAGER_ROLE) onlyActivated {
ARB_OWNER.setCollectTips(collectTips);
emit CollectTipsUpdated(collectTips);
}
}
Loading