Skip to content
Merged
Show file tree
Hide file tree
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
21 changes: 0 additions & 21 deletions op-e2e/e2eutils/interop/contracts/bindings/inbox/inbox.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions op-e2e/e2eutils/interop/contracts/src/ICrossL2Inbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ struct Identifier {
/// @notice Interface for the CrossL2Inbox contract.
interface ICrossL2Inbox {

/// @notice Executes a cross chain message on the destination chain.
/// @param _id An Identifier pointing to the initiating message.
/// @param _target Account that is called with _msg.
/// @param _message The message payload, matching the initiating message.
function executeMessage(Identifier calldata _id, address _target, bytes calldata _message) external payable;

/// @notice Validates a cross chain message on the destination chain
/// and emits an ExecutingMessage event. This function is useful
/// for applications that understand the schema of the _message payload and want to
Expand Down
14 changes: 6 additions & 8 deletions op-e2e/interop/interop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,30 +298,28 @@ func TestInteropBlockBuilding(t *testing.T) {

t.Log("Testing invalid message")
{
bobAddr := s2.Address(chainA, "Bob") // direct it to a random account without code
ctx, cancel := context.WithTimeout(context.Background(), time.Second*15)
defer cancel()
// Send an executing message, but with different payload.
// Emitting an executing message, but with different payload.
if s2.(*interopE2ESystem).config.mempoolFiltering {
// We expect the traqnsaction to be filtered out by the mempool if mempool filtering is enabled.
// ExecuteMessage the ErrTxFilteredOut error is checked when sending the tx.
_, err := s2.ExecuteMessage(ctx, chainB, "Alice", identifier, bobAddr, invalidPayload, gethCore.ErrTxFilteredOut)
// ValidateMessage the ErrTxFilteredOut error is checked when sending the tx.
_, err := s2.ValidateMessage(ctx, chainB, "Alice", identifier, invalidPayloadHash, gethCore.ErrTxFilteredOut)
require.ErrorContains(t, err, gethCore.ErrTxFilteredOut.Error())
} else {
// We expect the miner to be unable to include this tx, and confirmation to thus time out, if mempool filtering is disabled.
_, err := s2.ExecuteMessage(ctx, chainB, "Alice", identifier, bobAddr, invalidPayload, nil)
_, err := s2.ValidateMessage(ctx, chainB, "Alice", identifier, invalidPayloadHash, nil)
require.ErrorIs(t, err, ctx.Err())
require.ErrorIs(t, ctx.Err(), context.DeadlineExceeded)
}
}

t.Log("Testing valid message now")
{
bobAddr := s2.Address(chainA, "Bob") // direct it to a random account without code
ctx, cancel := context.WithTimeout(context.Background(), time.Second*15)
defer cancel()
// Send an executing message with the correct identifier / payload
rec, err := s2.ExecuteMessage(ctx, chainB, "Alice", identifier, bobAddr, msgPayload, nil)
// Emit an executing message with the correct identifier / payload
rec, err := s2.ValidateMessage(ctx, chainB, "Alice", identifier, payloadHash, nil)
require.NoError(t, err, "expecting tx to be confirmed")
t.Logf("confirmed executing msg in block %s", rec.BlockNumber)
}
Expand Down
20 changes: 9 additions & 11 deletions op-e2e/interop/supersystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,13 @@ type SuperSystem interface {
EmitData(ctx context.Context, network string, username string, data string) *types.Receipt
// AddDependency adds a dependency (by chain ID) to the given chain
AddDependency(ctx context.Context, network string, dep *big.Int) *types.Receipt
// ExecuteMessage calls the CrossL2Inbox executeMessage function
ExecuteMessage(
// ValidateMessage calls the CrossL2Inbox ValidateMessage function
ValidateMessage(
ctx context.Context,
id string,
sender string,
msgIdentifier supervisortypes.Identifier,
target common.Address,
message []byte,
msgHash [32]byte,
expectedError error,
) (*types.Receipt, error)
// Access a contract on a network by name
Expand Down Expand Up @@ -733,17 +732,16 @@ func (s *interopE2ESystem) SendL2Tx(
newApply)
}

// ExecuteMessage calls the CrossL2Inbox executeMessage function
// ValidateMessage calls the CrossL2Inbox ValidateMessage function
// it uses the L2's chain ID, username key, and geth client.
// expectedError represents the error returned by `ExecuteMessage` if it is expected.
// expectedError represents the error returned by `ValidateMessage` if it is expected.
// the returned err is related to `WaitMined`
func (s *interopE2ESystem) ExecuteMessage(
func (s *interopE2ESystem) ValidateMessage(
ctx context.Context,
id string,
sender string,
msgIdentifier supervisortypes.Identifier,
target common.Address,
message []byte,
msgHash [32]byte,
expectedError error,
) (*types.Receipt, error) {
secret := s.UserKey(id, sender)
Expand All @@ -762,14 +760,14 @@ func (s *interopE2ESystem) ExecuteMessage(
Timestamp: new(big.Int).SetUint64(msgIdentifier.Timestamp),
ChainId: msgIdentifier.ChainID.ToBig(),
}
tx, err := contract.InboxTransactor.ExecuteMessage(auth, identifier, target, message)
tx, err := contract.InboxTransactor.ValidateMessage(auth, identifier, msgHash)
if expectedError != nil {
require.ErrorContains(s.t, err, expectedError.Error())
return nil, err
} else {
require.NoError(s.t, err)
}
s.logger.Info("Executing message", "tx", tx.Hash(), "to", tx.To(), "target", target, "data", hexutil.Bytes(tx.Data()))
s.logger.Info("Validating message", "tx", tx.Hash(), "to", tx.To(), "data", hexutil.Bytes(tx.Data()))
return bind.WaitMined(ctx, s.L2GethClient(id), tx)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ func TestDecodeExecutingMessageLog(t *testing.T) {
// uint256 timestamp;
// uint256 chainId;
// }
// function executeMessage(Identifier calldata _id,
// address _target, bytes calldata _message) external payable;
// event ExecutingMessage(bytes32 indexed msgHash, Identifier id);

originAddr := common.HexToAddress("0x5fbdb2315678afecb367f032d93f642f64180aa3")
payloadHash := common.HexToHash("0xc3f57e1f0dd62a4f77787d834029bfeaab8894022c47edbe13b044fb658c9190")
Expand Down
15 changes: 0 additions & 15 deletions packages/contracts-bedrock/interfaces/L2/ICrossL2Inbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ interface ICrossL2Inbox {
/// @notice Thrown when a non-written transient storage slot is attempted to be read from.
error NotEntered();

/// @notice Thrown when trying to execute a cross chain message with an invalid Identifier timestamp.
error InvalidTimestamp();

/// @notice Thrown when trying to execute a cross chain message with an invalid Identifier chain ID.
error InvalidChainId();

/// @notice Thrown when trying to execute a cross chain message and the target call fails.
error TargetCallFailed();

/// @notice Thrown when trying to execute a cross chain message on a deposit transaction.
error NoExecutingDeposits();

Expand Down Expand Up @@ -60,12 +51,6 @@ interface ICrossL2Inbox {

function setInteropStart() external;

/// @notice Executes a cross chain message on the destination chain.
/// @param _id An Identifier pointing to the initiating message.
/// @param _target Account that is called with _msg.
/// @param _message The message payload, matching the initiating message.
function executeMessage(Identifier calldata _id, address _target, bytes calldata _message) external payable;

/// @notice Validates a cross chain message on the destination chain
/// and emits an ExecutingMessage event. This function is useful
/// for applications that understand the schema of the _message payload and want to
Expand Down
65 changes: 0 additions & 65 deletions packages/contracts-bedrock/snapshots/abi/CrossL2Inbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,56 +25,6 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"components": [
{
"internalType": "address",
"name": "origin",
"type": "address"
},
{
"internalType": "uint256",
"name": "blockNumber",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "logIndex",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "timestamp",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "chainId",
"type": "uint256"
}
],
"internalType": "struct Identifier",
"name": "_id",
"type": "tuple"
},
{
"internalType": "address",
"name": "_target",
"type": "address"
},
{
"internalType": "bytes",
"name": "_message",
"type": "bytes"
}
],
"name": "executeMessage",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"name": "interopStart",
Expand Down Expand Up @@ -243,16 +193,6 @@
"name": "InteropStartAlreadySet",
"type": "error"
},
{
"inputs": [],
"name": "InvalidChainId",
"type": "error"
},
{
"inputs": [],
"name": "InvalidTimestamp",
"type": "error"
},
{
"inputs": [],
"name": "NoExecutingDeposits",
Expand All @@ -272,10 +212,5 @@
"inputs": [],
"name": "ReentrantCall",
"type": "error"
},
{
"inputs": [],
"name": "TargetCallFailed",
"type": "error"
}
]
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/snapshots/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"sourceCodeHash": "0xfa56426153227e798150f6becc30a33fd20a3c6e0d73c797a3922dd631acbb57"
},
"src/L2/CrossL2Inbox.sol": {
"initCodeHash": "0x7a189f6dff6c19ec6f1e94d84a0d9d98a320a68812f957e50bf8b63224bb0dce",
"sourceCodeHash": "0x9bbfabb19b7f572dadae797786c2f87d892693650151bd8de6eadee3e03fc559"
"initCodeHash": "0x2bc4a3765004f9a9e6e5278753bce3c3d53cc95da62efcc0cb10c50d8c806cd4",
"sourceCodeHash": "0x661d7659f09b7f909e8bd5e6c41e8c98f2091036ed2123b7e18a1a74120bd849"
},
"src/L2/ETHLiquidity.sol": {
"initCodeHash": "0xbb16de6a3f678db7301694a000f315154f25f9660c8dcec4b0bef20bc7cfdebd",
Expand Down
60 changes: 2 additions & 58 deletions packages/contracts-bedrock/src/L2/CrossL2Inbox.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ pragma solidity 0.8.25;
// Libraries
import { Predeploys } from "src/libraries/Predeploys.sol";
import { TransientContext, TransientReentrancyAware } from "src/libraries/TransientContext.sol";
import { SafeCall } from "src/libraries/SafeCall.sol";

// Interfaces
import { ISemver } from "interfaces/universal/ISemver.sol";
import { IDependencySet } from "interfaces/L2/IDependencySet.sol";
import { IL1BlockInterop } from "interfaces/L2/IL1BlockInterop.sol";

/// @notice Thrown when the caller is not DEPOSITOR_ACCOUNT when calling `setInteropStart()`
Expand All @@ -20,15 +18,6 @@ error InteropStartAlreadySet();
/// @notice Thrown when a non-written transient storage slot is attempted to be read from.
error NotEntered();

/// @notice Thrown when trying to execute a cross chain message with an invalid Identifier timestamp.
error InvalidTimestamp();

/// @notice Thrown when trying to execute a cross chain message with an invalid Identifier chain ID.
error InvalidChainId();

/// @notice Thrown when trying to execute a cross chain message and the target call fails.
error TargetCallFailed();

/// @notice Thrown when trying to execute a cross chain message on a deposit transaction.
error NoExecutingDeposits();

Expand Down Expand Up @@ -76,8 +65,8 @@ contract CrossL2Inbox is ISemver, TransientReentrancyAware {
address internal constant DEPOSITOR_ACCOUNT = 0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001;

/// @notice Semantic version.
/// @custom:semver 1.0.0-beta.11
string public constant version = "1.0.0-beta.11";
/// @custom:semver 1.0.0-beta.12
string public constant version = "1.0.0-beta.12";

/// @notice Emitted when a cross chain message is being executed.
/// @param msgHash Hash of message payload being executed.
Expand Down Expand Up @@ -137,37 +126,6 @@ contract CrossL2Inbox is ISemver, TransientReentrancyAware {
return TransientContext.get(CHAINID_SLOT);
}

/// @notice Executes a cross chain message on the destination chain.
/// @param _id Identifier of the message.
/// @param _target Target address to call.
/// @param _message Message payload to call target with.
function executeMessage(
Identifier calldata _id,
address _target,
bytes memory _message
)
external
payable
reentrantAware
{
// We need to know if this is being called on a depositTx
if (IL1BlockInterop(Predeploys.L1_BLOCK_ATTRIBUTES).isDeposit()) revert NoExecutingDeposits();

// Check the Identifier.
_checkIdentifier(_id);

// Store the Identifier in transient storage.
_storeIdentifier(_id);

// Call the target account with the message payload.
bool success = SafeCall.call(_target, msg.value, _message);

// Revert if the target call failed.
if (!success) revert TargetCallFailed();

emit ExecutingMessage(keccak256(_message), _id);
}

/// @notice Validates a cross chain message on the destination chain
/// and emits an ExecutingMessage event. This function is useful
/// for applications that understand the schema of the _message payload and want to
Expand All @@ -178,23 +136,9 @@ contract CrossL2Inbox is ISemver, TransientReentrancyAware {
// We need to know if this is being called on a depositTx
if (IL1BlockInterop(Predeploys.L1_BLOCK_ATTRIBUTES).isDeposit()) revert NoExecutingDeposits();

// Check the Identifier.
_checkIdentifier(_id);

emit ExecutingMessage(_msgHash, _id);
}

/// @notice Validates that for a given cross chain message identifier,
/// it's timestamp is not in the future and the source chainId
/// is in the destination chain's dependency set.
/// @param _id Identifier of the message.
function _checkIdentifier(Identifier calldata _id) internal view {
if (_id.timestamp > block.timestamp || _id.timestamp <= interopStart()) revert InvalidTimestamp();
if (!IDependencySet(Predeploys.L1_BLOCK_ATTRIBUTES).isInDependencySet(_id.chainId)) {
revert InvalidChainId();
}
}

/// @notice Stores the Identifier in transient storage.
/// @param _id Identifier to store.
function _storeIdentifier(Identifier calldata _id) internal {
Expand Down
Loading