Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol): allow bridge to ban addresses #15577

Merged
merged 2 commits into from
Jan 26, 2024
Merged
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
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]
dantaik marked this conversation as resolved.
Show resolved Hide resolved
) {
// Handle special addresses that don't require actual invocation but
// mark message as DONE
Expand Down
Loading