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: entrypoints #13456

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cd22d5b
feat: include overloaded sendMessage(uint256,address,bytes,address)
0xiamflux Nov 20, 2024
a8dd2b6
feat: update relayMessage to support entrypoints, update tests
0xiamflux Nov 20, 2024
ac1ddbd
test: remove redundant test cases
0xiamflux Nov 20, 2024
fd83aed
chore: update comments on L2ToL2CrossDomainMessenger
0xiamflux Nov 21, 2024
e90d994
Merge pull request #133 from defi-wonderland/chore/sync-update
hexshire Nov 21, 2024
8ec3476
refactor: change to inline-conditional for consistency
0xiamflux Nov 21, 2024
0dd64b6
test: update test name for clarity
0xiamflux Nov 21, 2024
bf2a020
test: update test
0xiamflux Nov 21, 2024
ce1b54c
docs: update semgrep version, update natspec comments
0xiamflux Nov 21, 2024
3a6b9fe
chore: address review comments
hexshire Nov 22, 2024
f578bdf
chore: fix natspec
hexshire Nov 22, 2024
8186ef1
chore: pre pr
hexshire Nov 22, 2024
740de23
chore: update version
hexshire Nov 28, 2024
f3626a8
chore: address review comments
hexshire Nov 29, 2024
8095b27
test: fuzz message sender
hexshire Nov 29, 2024
6d2945b
Merge pull request #131 from defi-wonderland/feat/entrypoints
hexshire Dec 10, 2024
0e8c22e
Merge branch 'develop' into chore/entrypoints-sync
hexshire Dec 10, 2024
7646d93
Merge pull request #148 from defi-wonderland/chore/entrypoints-sync
hexshire Dec 10, 2024
5b48b9f
refactor: change params order
0xiamflux Dec 17, 2024
2427264
Merge branch 'develop' into chore/entrypoints-sync-2
hexshire Dec 17, 2024
901de51
Merge pull request #158 from defi-wonderland/chore/entrypoints-sync-2
hexshire Dec 17, 2024
8823728
feat: relay context update
0xiamflux Dec 18, 2024
e38a44c
Merge branch 'develop' into chore/sync-develop-entrypoints
0xDiscotech Dec 18, 2024
80f2338
Merge pull request #161 from defi-wonderland/chore/sync-develop-entry…
0xDiscotech Dec 18, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,28 @@ interface IL2ToL2CrossDomainMessenger {
/// @notice Thrown when attempting to use a chain ID that is not in the dependency set.
error InvalidChainId();

/// @notice Thrown when relaying a message from an address different than the specified entrypoint.
error InvalidEntrypoint();

/// @notice Emitted whenever a message is sent to a destination
/// @param destination Chain ID of the destination chain.
/// @param target Target contract or wallet address.
/// @param messageNonce Nonce associated with the messsage sent
/// @param messageNonce Nonce associated with the message sent
/// @param sender Address initiating this message call
/// @param entrypoint Address of the entrypoint on the destination chain.
/// @param message Message payload to call target with.
event SentMessage(
uint256 indexed destination, address indexed target, uint256 indexed messageNonce, address sender, bytes message
uint256 indexed destination,
address indexed target,
uint256 indexed messageNonce,
address sender,
address entrypoint,
bytes message
);

/// @notice Emitted whenever a message is successfully relayed on this chain.
/// @param source Chain ID of the source chain.
/// @param messageNonce Nonce associated with the messsage sent
/// @param messageNonce Nonce associated with the message sent
/// @param messageHash Hash of the message that was relayed.
event RelayedMessage(uint256 indexed source, uint256 indexed messageNonce, bytes32 indexed messageHash);

Expand All @@ -83,20 +92,51 @@ interface IL2ToL2CrossDomainMessenger {
/// @return source_ Chain ID of the source of the current cross domain message.
function crossDomainMessageSource() external view returns (uint256 source_);

/// @notice Retrieves the entrypoint of the current cross domain message.
/// @return entrypoint_ Address of the entrypoint of the current cross domain message.
function crossDomainMessageEntrypoint() external view returns (address entrypoint_);

/// @notice Retrieves the nonce of the current cross domain message.
/// @return nonce_ Nonce of the current cross domain message.
function crossDomainMessageNonce() external view returns (uint256 nonce_);

/// @notice Retrieves the context of the current cross domain message. If not entered, reverts.
/// @return sender_ Address of the sender of the current cross domain message.
/// @return source_ Chain ID of the source of the current cross domain message.
function crossDomainMessageContext() external view returns (address sender_, uint256 source_);
/// @return entrypoint_ Address of the entrypoint of the current cross domain message.
/// @return nonce_ Nonce of the current cross domain message.
function crossDomainMessageContext()
external
view
returns (address sender_, uint256 source_, address entrypoint_, uint256 nonce_);

/// @notice Sends a message to some target address on a destination chain with an entrypoint address as an
/// authorized relayer. Note that if the call always reverts, then the message will be unrelayable and any
/// ETH sent will be permanently locked. The same will occur if the target on the other chain is considered
/// unsafe (see the _isUnsafeTarget() function). The entrypoint must have the capability to call
/// `relayMessage` for successful relaying.
/// @param _destination Chain ID of the destination chain.
/// @param _target Target contract or wallet address.
/// @param _entrypoint Address of the entrypoint on the destination chain. If it is address(0) then the
/// message can be relayed by any address on the destination chain.
/// @param _message Message payload to call target with.
/// @return The hash of the message being sent, used to track whether the message has successfully been relayed.
function sendMessage(
uint256 _destination,
address _target,
address _entrypoint,
bytes calldata _message
)
external
returns (bytes32);

/// @notice Sends a message to some target address on a destination chain. Note that if the call
/// always reverts, then the message will be unrelayable, and any ETH sent will be
/// permanently locked. The same will occur if the target on the other chain is
/// considered unsafe (see the _isUnsafeTarget() function).
/// @notice Sends a message to some target address on a destination chain. Note that if the call always reverts,
/// then the message will be unrelayable and any ETH sent will be permanently locked. The same will occur
/// if the target on the other chain is considered unsafe (see the _isUnsafeTarget() function).
/// @param _destination Chain ID of the destination chain.
/// @param _target Target contract or wallet address.
/// @param _message Message to trigger the target address with.
/// @return msgHash_ The hash of the message being sent, which can be used for tracking whether
/// the message has successfully been relayed.
/// @param _message Message payload to call target with.
/// @return The hash of the message being sent, used to track whether the message has successfully been relayed.
function sendMessage(uint256 _destination, address _target, bytes calldata _message) external returns (bytes32);

/// @notice Relays a message that was sent by the other CrossDomainMessenger contract. Can only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,13 @@ func abiItemLess(a, b map[string]interface{}) bool {

aName := getString(a, "name")
bName := getString(b, "name")
return aName < bName
if aName != bName {
return aName < bName
}

aInputs := a["inputs"].([]interface{})
bInputs := b["inputs"].([]interface{})
return len(aInputs) < len(bInputs)
}

func getString(m map[string]interface{}, key string) string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,42 @@
"internalType": "uint256",
"name": "source_",
"type": "uint256"
},
{
"internalType": "address",
"name": "entrypoint_",
"type": "address"
},
{
"internalType": "uint256",
"name": "nonce_",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "crossDomainMessageEntrypoint",
"outputs": [
{
"internalType": "address",
"name": "entrypoint_",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "crossDomainMessageNonce",
"outputs": [
{
"internalType": "uint256",
"name": "nonce_",
"type": "uint256"
}
],
"stateMutability": "view",
Expand Down Expand Up @@ -149,6 +185,40 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_destination",
"type": "uint256"
},
{
"internalType": "address",
"name": "_target",
"type": "address"
},
{
"internalType": "address",
"name": "_entrypoint",
"type": "address"
},
{
"internalType": "bytes",
"name": "_message",
"type": "bytes"
}
],
"name": "sendMessage",
"outputs": [
{
"internalType": "bytes32",
"name": "",
"type": "bytes32"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down Expand Up @@ -233,6 +303,12 @@
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "entrypoint",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes",
Expand All @@ -258,6 +334,11 @@
"name": "InvalidChainId",
"type": "error"
},
{
"inputs": [],
"name": "InvalidEntrypoint",
"type": "error"
},
{
"inputs": [],
"name": "MessageAlreadyRelayed",
Expand Down
12 changes: 6 additions & 6 deletions packages/contracts-bedrock/snapshots/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
"sourceCodeHash": "0xaef8ea36c5b78cd12e0e62811d51db627ccf0dfd2cc5479fb707a10ef0d42048"
},
"src/L2/L2ToL2CrossDomainMessenger.sol": {
"initCodeHash": "0xc56db8cb569efa0467fd53ab3fa218af3051e54f5517d7fafb7b5831b4350618",
"sourceCodeHash": "0x72062343a044e9c56f4143dcfc71706286eb205902006c2afcf6a4cd90c3e9f8"
"initCodeHash": "0x486127eb0deebf15dcedbbdae026f1a3f43f68601b4b8e30b6aef2aed3923e74",
"sourceCodeHash": "0xa61bd92bce98a66d3261d6be4220fe113a50ac495d8aa8594b151c7dc91e94ee"
},
"src/L2/OptimismSuperchainERC20.sol": {
"initCodeHash": "0xdac32a1057a6bc8a8d2ffdce1db8f34950cd0ffd1454d2133865736d21869192",
Expand All @@ -124,12 +124,12 @@
"sourceCodeHash": "0x981dca5b09da9038a9dff071b40a880e1b52b20268c6780ef54be3bc98a4f629"
},
"src/L2/SuperchainTokenBridge.sol": {
"initCodeHash": "0x6b568ed564aede82a3a4cbcdb51282cad0e588a3fe6d91cf76616d3113df3901",
"sourceCodeHash": "0xcd2b49cb7cf6d18616ee8bec9183fe5b5b460941875bc0b4158c4d5390ec3b0c"
"initCodeHash": "0x4c3d5990c37eef0ce09c7b32ecb668fab45151f2bcbf7a0b923cb2e8d3e3538b",
"sourceCodeHash": "0x421394215e658a2018cd4d6043089e07319f05c261d17abdaa43b01cdb329575"
},
"src/L2/SuperchainWETH.sol": {
"initCodeHash": "0x6ded8aeea6edf7e0ead7b0d2a12ef236f1fb7d21980a1dd564cbe86affca7927",
"sourceCodeHash": "0x11d711704a5afcae6076d017ee001b25bc705728973b1ad2e6a32274a8475f50"
"initCodeHash": "0x7813e841bea7fac3fda1d47ceb07edfa4e839c1c491a9e921b90bf2fcc823c7c",
"sourceCodeHash": "0x1884441724b07b2625675bf2dd30b94ff74691d2c9456d01e6e25a913479eb7c"
},
"src/L2/WETH.sol": {
"initCodeHash": "0x480d4f8dbec1b0d3211bccbbdfb69796f3e90c784f724b1bbfd4703b0aafdeba",
Expand Down
Loading