Verified contractPartialUNLICENSED
BridgeRowsV4
Address0xac375ea0d628e9834c3d0f3c2fe774531ec3cbd1
- Balance
0 ETH
- Transactions
0
- Compiler
solc 0.8.30
- Same code
Only this contract
Details
- Compiler
- solc 0.8.30+commit.73712a01
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- cancun
- Via IR
- yes
- License
- UNLICENSED
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,399,326
- Creation transaction
- 0xe7dd9aa162…b25a177148
2 files
- src/v4/bridge/BridgeRowsV4.solmain3.32 KB
- src/v4/bridge/ITransportV4.sol1.26 KB
src/v4/bridge/BridgeRowsV4.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
import {IBridgeForAdaptersV4} from "./ITransportV4.sol";
/// @notice T17-SIZE (EIP-170): the rowsHash view of ONE bridge, created by that bridge in its constructor (like
/// BridgeBuyerV4). Stateless; reads the creating bridge's rows through `routeOf`. PangeaBridgeV4.rowsHash
/// forwards here (same selector at the bridge, same reverts: the errors below have the bridge's selectors).
contract BridgeRowsV4 {
/// @notice The bridge whose rows are hashed (the creator).
IBridgeForAdaptersV4 public immutable bridge;
error TransportNotListed(uint8 tid);
error RouteMissing(uint32 pcid, uint8 tid);
constructor() {
bridge = IBridgeForAdaptersV4(msg.sender);
}
/// @notice rowsHash of the bridge's rows (§11.2.2) for a coin listing `chains` with `mask` and per-chain tids
/// `chainTids` (bits [16i, 16i+16) = the tids chains[i] uses; 0 = the mask on every chain). ELY-TRANSPORT (row
/// 17): a route uses the tids its two ends share, so LayerZero can run A <-> B while every Elysium route is
/// Hyperlane only. Hashed: the rows of the COMMON tids (in every chain's set), u32 pcid | u8 tid | u32 domain |
/// peer, then u128 chainTids iff it is not the mask on every chain (a full coin hashes exactly as before).
/// T17-FIX (AUD-T17): the sets are the creator's, fixed in the coinId through this hash, never read from the
/// live rows: a row added later changes no coin (M-1) and extends no open coin (L-1, `_checkPair`).
/// Refused with TransportNotListed(0): a tid outside the mask, a chain index past the list, or a mask tid that
/// no route uses, i.e. in fewer than two chains' sets (M-2); RouteMissing(0, 0): no common tid; RouteMissing(
/// pcid, tid): a common row missing here. T17-SIZE: same logic as the former BridgeRoleV4._rowsHash; the row
/// is read by `bridge.routeOf` (= the bridge's `_routes[pcid][tid]`).
function rowsHash(uint32[] calldata chains, uint16 mask, uint128 chainTids) external view returns (bytes32) {
uint256 n = chains.length;
uint256 full;
for (uint256 i = 0; i < n; i++) {
full |= uint256(mask) << (16 * i);
}
uint256 ct = chainTids == 0 ? full : chainTids;
uint256 common = mask;
uint256 seen;
uint256 twice;
for (uint256 i = 0; i < n; i++) {
uint256 x = uint16(ct >> (16 * i));
common &= x;
twice |= seen & x;
seen |= x;
}
if (ct & ~full != 0 || (n > 1 ? twice : seen) != mask) revert TransportNotListed(0);
if (common == 0) revert RouteMissing(0, 0);
bytes memory b;
for (uint256 i = 0; i < n; i++) {
for (uint8 t = 1; t < 16; t++) {
if ((common >> t) & 1 == 0) continue;
IBridgeForAdaptersV4.Route memory r = bridge.routeOf(chains[i], t);
if (r.peer == bytes32(0)) revert RouteMissing(chains[i], t);
b = abi.encodePacked(b, chains[i], t, r.remoteDomain, r.peer);
}
}
if (ct != full) b = abi.encodePacked(b, uint128(ct));
return keccak256(b);
}
}
src/v4/bridge/ITransportV4.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.30;
/// @title ITransportAdapterV4 -- a transport adapter of the shared bridge (V4-INTERFACES §11.2.14)
interface ITransportAdapterV4 {
function transportId() external view returns (uint8);
function bridge() external view returns (address);
function quote(uint32 dstPcid, bytes calldata message, bytes calldata extraOptions) external view returns (uint256);
/// @notice Bridge only. Returns the transport's own message id (LZ guid / Hyperlane message id).
function send(uint32 dstPcid, bytes calldata message, bytes calldata extraOptions, address refundTo)
external
payable
returns (bytes32 transportMsgId);
}
/// @notice What the adapters read from / call on the bridge.
interface IBridgeForAdaptersV4 {
struct Route {
uint32 remoteDomain;
bytes32 peer;
}
function owner() external view returns (address);
function routeOf(uint32 pcid, uint8 tid) external view returns (Route memory);
function pcidOf(uint8 tid, uint32 remoteDomain) external view returns (uint32);
function receiveFromTransport(uint32 srcPcid, bytes32 srcPeer, bytes calldata message, bytes32 transportMsgId, address executor)
external;
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"forge-std/=lib/forge-std/src/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"@openzeppelin/=lib/openzeppelin-contracts/",
"@layerzerolabs/oft-evm/=lib/layerzero/oft-evm/",
"@layerzerolabs/oapp-evm/=lib/layerzero/oapp-evm/",
"@layerzerolabs/lz-evm-protocol-v2/=lib/layerzero/protocol-v2/",
"@uniswap/v4-core/=lib/uniswap-v4-core/",
"solmate/=lib/solmate/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
"halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
"layerzero/=lib/layerzero/",
"uniswap-v4-core/=lib/uniswap-v4-core/src/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.