Skip to content

Commit

Permalink
feat(protocol): allow bridge to ban addresses (#15577)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantaik committed Jan 26, 2024
1 parent 30d771c commit 17b074b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/protocol/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,20 @@ contract Bridge is EssentialContract, IBridge {
mapping(bytes32 msgHash => bool recalled) public isMessageRecalled;
mapping(bytes32 msgHash => Status) public messageStatus; // slot 3
Context private _ctx; // // slot 4,5,6pnpm
uint256[44] private __gap;
mapping(address => bool) public addressBanned;
uint256[43] private __gap;

event SignalSent(address indexed sender, bytes32 msgHash);
event MessageSent(bytes32 indexed msgHash, Message message);
event MessageRecalled(bytes32 indexed msgHash);
event DestChainEnabled(uint64 indexed chainId, bool enabled);
event MessageStatusChanged(bytes32 indexed msgHash, Status status);
event AddressBanned(address indexed addr, bool banned);

error B_INVALID_CHAINID();
error B_INVALID_CONTEXT();
error B_INVALID_GAS_LIMIT();
error B_INVALID_STATUS();
error B_INVALID_USER();
error B_INVALID_VALUE();
error B_MESSAGE_NOT_SENT();
Expand All @@ -75,6 +78,12 @@ contract Bridge is EssentialContract, IBridge {
_ctx.msgHash == bytes32(PLACEHOLDER);
}

function banAddress(address addr, bool toBan) external onlyOwner nonReentrant {
if (addressBanned[addr] == toBan) revert B_INVALID_STATUS();
addressBanned[addr] = toBan;
emit AddressBanned(addr, toBan);
}

/// @notice Sends a message to the destination chain and takes custody
/// of Ether required in this contract. All extra Ether will be refunded.
/// @inheritdoc IBridge
Expand Down Expand Up @@ -207,7 +216,7 @@ contract Bridge is EssentialContract, IBridge {
// Process message differently based on the target address
if (
message.to == address(0) || message.to == address(this)
|| message.to == address(signalService)
|| message.to == address(signalService) || addressBanned[message.to]
) {
// Handle special addresses that don't require actual invocation but
// mark message as DONE
Expand Down

0 comments on commit 17b074b

Please sign in to comment.