-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protocol): fix signal service multi-hop proof verification bugs (#…
…15680) Co-authored-by: Keszey Dániel <keszeyd@MacBook-Pro.local> Co-authored-by: Brecht Devos <Brechtp.Devos@gmail.com>
- Loading branch information
1 parent
ea33e65
commit b46269c
Showing
20 changed files
with
371 additions
and
264 deletions.
There are no files selected for viewing
42 changes: 0 additions & 42 deletions
42
packages/protocol/contracts/common/AuthorizableContract.sol
This file was deleted.
Oops, something went wrong.
101 changes: 101 additions & 0 deletions
101
packages/protocol/contracts/signal/HopRelayRegistry.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// SPDX-License-Identifier: MIT | ||
// _____ _ _ _ _ | ||
// |_ _|_ _(_) |_____ | | __ _| |__ ___ | ||
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< | ||
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ | ||
// | ||
// Email: security@taiko.xyz | ||
// Website: https://taiko.xyz | ||
// GitHub: https://github.com/taikoxyz | ||
// Discord: https://discord.gg/taikoxyz | ||
// Twitter: https://twitter.com/taikoxyz | ||
// Blog: https://mirror.xyz/labs.taiko.eth | ||
// Youtube: https://www.youtube.com/@taikoxyz | ||
|
||
pragma solidity 0.8.24; | ||
|
||
import "../common/EssentialContract.sol"; | ||
import "./IHopRelayRegistry.sol"; | ||
|
||
/// @title HopRelayRegistry | ||
contract HopRelayRegistry is EssentialContract, IHopRelayRegistry { | ||
mapping(uint64 => mapping(uint64 => mapping(address => bool))) internal registry; | ||
uint256[49] private __gap; | ||
|
||
event RelayRegistered( | ||
uint64 indexed srcChainId, | ||
uint64 indexed hopChainId, | ||
address indexed hopRelay, | ||
bool registered | ||
); | ||
|
||
error MHG_INVALID_PARAMS(); | ||
error MHG_INVALID_STATE(); | ||
|
||
function init() external initializer { | ||
__Essential_init(); | ||
} | ||
|
||
/// @dev Register a trusted hop relay. | ||
/// @param srcChainId The source chain ID where state roots correspond to. | ||
/// @param hopChainId The hop relay's local chain ID. | ||
/// @param hopRelay The address of the relay. | ||
function registerRelay( | ||
uint64 srcChainId, | ||
uint64 hopChainId, | ||
address hopRelay | ||
) | ||
external | ||
onlyOwner | ||
{ | ||
_registerRelay(srcChainId, hopChainId, hopRelay, true); | ||
} | ||
|
||
/// @dev Deregister a trusted hop relay. | ||
/// @param srcChainId The source chain ID where state roots correspond to. | ||
/// @param hopChainId The hop relay's local chain ID. | ||
/// @param hopRelay The address of the relay. | ||
function deregisterRelay( | ||
uint64 srcChainId, | ||
uint64 hopChainId, | ||
address hopRelay | ||
) | ||
external | ||
onlyOwner | ||
{ | ||
_registerRelay(srcChainId, hopChainId, hopRelay, false); | ||
} | ||
|
||
/// @inheritdoc IHopRelayRegistry | ||
function isRelayRegistered( | ||
uint64 srcChainId, | ||
uint64 hopChainId, | ||
address hopRelay | ||
) | ||
public | ||
view | ||
returns (bool) | ||
{ | ||
return registry[srcChainId][hopChainId][hopRelay]; | ||
} | ||
|
||
function _registerRelay( | ||
uint64 srcChainId, | ||
uint64 hopChainId, | ||
address hopRelay, | ||
bool registered | ||
) | ||
private | ||
{ | ||
if ( | ||
srcChainId == 0 || hopChainId == 0 || srcChainId == hopChainId || hopRelay == address(0) | ||
) { | ||
revert MHG_INVALID_PARAMS(); | ||
} | ||
if (registry[srcChainId][hopChainId][hopRelay] == registered) { | ||
revert MHG_INVALID_STATE(); | ||
} | ||
registry[srcChainId][hopChainId][hopRelay] = registered; | ||
emit RelayRegistered(srcChainId, hopChainId, hopRelay, registered); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// SPDX-License-Identifier: MIT | ||
// _____ _ _ _ _ | ||
// |_ _|_ _(_) |_____ | | __ _| |__ ___ | ||
// | |/ _` | | / / _ \ | |__/ _` | '_ (_-< | ||
// |_|\__,_|_|_\_\___/ |____\__,_|_.__/__/ | ||
// | ||
// Email: security@taiko.xyz | ||
// Website: https://taiko.xyz | ||
// GitHub: https://github.com/taikoxyz | ||
// Discord: https://discord.gg/taikoxyz | ||
// Twitter: https://twitter.com/taikoxyz | ||
// Blog: https://mirror.xyz/labs.taiko.eth | ||
// Youtube: https://www.youtube.com/@taikoxyz | ||
|
||
pragma solidity 0.8.24; | ||
|
||
/// @title IHopRelayRegistry | ||
/// @notice A registry of hop relays for multi-hop bridging. | ||
// A hop relay is a contract that relays a corresponding chain's state roots to its loal signal | ||
// service. | ||
interface IHopRelayRegistry { | ||
/// @dev Returns if a relay is trusted. | ||
/// @param srcChainId The source chain ID where state roots correspond to. | ||
/// @param hopChainId The hop relay's local chain ID. | ||
/// @param hopRelay The address of the relay. | ||
/// @return trusted True if the relay is a trusted one. | ||
function isRelayRegistered( | ||
uint64 srcChainId, | ||
uint64 hopChainId, | ||
address hopRelay | ||
) | ||
external | ||
view | ||
returns (bool trusted); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.