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

Add EIP-5164: Cross-Chain Execution #5164

Merged
merged 24 commits into from
Sep 22, 2022
Merged
Changes from 9 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3bec89b
Added Cross-Chain Execution EIP
asselstine Jun 15, 2022
46079ca
Merge branch 'ethereum:master' into master
asselstine Jun 15, 2022
aceeecb
Merge branch 'ethereum:master' into master
asselstine Jun 17, 2022
1e6e221
Integrated pull request review changes for EIP 5164
asselstine Jun 17, 2022
daf60ab
Added discussion-to link
asselstine Jun 17, 2022
a641fed
Updated EIP-5164 according to discussion
asselstine Jun 24, 2022
d7b0fdb
Latest Pull Request changes
asselstine Jul 28, 2022
c777eb6
Changed ERC->EIP
asselstine Jul 28, 2022
7ffa5e5
EIP-5164: Fixed up for EIPW bot
asselstine Jul 28, 2022
da5558d
EIP-5164: add ReceiverAware specification
PierrickGT Sep 6, 2022
4cb72fa
Merge pull request #1 from pooltogether/feat/bridge-aware
PierrickGT Sep 20, 2022
7c7aed9
EIP-5164: fix EIP-N linting
PierrickGT Sep 20, 2022
772f1c7
EIP-5164: improve CrossChainExecutor description
PierrickGT Sep 20, 2022
a93d3a0
EIP-5164: improve ExecutorAware description
PierrickGT Sep 22, 2022
a478089
EIP-5164: remove executor from relayCalls
PierrickGT Sep 22, 2022
7c5fae8
EIP-5164: reword RelayCalls requirements
PierrickGT Sep 22, 2022
63d10ad
EIP-5164: reword RelayedCalls requirements
PierrickGT Sep 22, 2022
cfce086
EIP-5164: reword GasLimitTooHigh requirements
PierrickGT Sep 22, 2022
60bb7c3
EIP-5164: reword Authentication requirements
PierrickGT Sep 22, 2022
53efa86
EIP-5164: reword Authentication requirements
PierrickGT Sep 22, 2022
20cce9e
EIP-5164: reword CallFailure requirements
PierrickGT Sep 22, 2022
b4a6000
EIP-5164: reword ExecutedCalls requirements
PierrickGT Sep 22, 2022
02c673e
EIP-5164: reword Security Considerations
PierrickGT Sep 22, 2022
fcd8e63
EIP-5164: update rationale
PierrickGT Sep 22, 2022
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
211 changes: 211 additions & 0 deletions EIPS/eip-5164.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
---
eip: 5164
title: Cross-Chain Execution
description: This specification defines an interface that supports execution across EVM networks.
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved
author: Brendan Asselstine (@asselstine), Anna Carroll (@anna-carroll), Hadrien Croubois (@Amxx), Nam Chu Hoai (@nambrot), Georgios (@geogons), Theo Gonella (@mintcloud), Rafael Solari (@rsolari), Auryn Macmillan (@auryn-macmillan), Nathan Ginnever (@nginnever)
SamWilsn marked this conversation as resolved.
Show resolved Hide resolved
discussions-to: https://ethereum-magicians.org/t/eip-5164-cross-chain-execution/9658
status: Draft
type: Standards Track
category: ERC
created: 2022-06-14
---

## Abstract

This specification defines a cross-chain execution interface for EVM-based blockchains. Developers will be able to have contracts call contracts on other chains. There are two parts to this spec: the "sending" interface and the "receiving" interface. The "sending" interface specifies the interface to send a call to another chain; this interface must be implemented by bridges. The "receiving" interface must be implemented by the developer; it is an interface for receiving cross-chain calls. This specification is agnostic of the bridge implementation; it simply standardizes the call interfaces.
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice if the abstract gave a tad more of a technical overview, and a hint of how the cross-chain communication works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting ready to turn my attention back to this. I will add more background!

## Motivation

Many Ethereum protocols need to coordinate state changes across multiple EVM-based blockchains. These chains often have native or third-party bridges that allow Ethereum contracts to execute code. However, bridges have different APIs so bridge integrations are bespoke.
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved

Bridge technology is improving rapidly, and there are multiple bridges to choose from. Each one affords different properties; with varying degrees of security, speed, and control.
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved

By standardizing a cross-chain execution interface, we can cleanly separate the transport layer from the application layer. Cross-chain execution becomes another composable piece with which the Ethereum ecosystem can build shared infrastructure.
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved

## Specification

This specification allows contracts on one chain to send messages to contracts on another chain. There are two key contracts:
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved

- CrossChainRelayer
- CrossChainReceiver

The `CrossChainRelayer` lives on the origin chain. Users can share a single `CrossChainRelayer` or deploy their own.

The `CrossChainReceiver` lives on the destination chain and receives relayed calls.
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved

### CrossChainRelayer
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved

The `CrossChainRelayer` lives on the chain from which messages are sent. The Relayer's job is to broadcast the messages through a transport layer.

#### Methods

**relayCalls**

MUST emit the `Relayed` event when successfully called.
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved

MUST increment a `nonce` so that each batch of calls can be uniquely identified.

MAY require payment. Some bridges may require payment in the native currency, so the function is payable.

Implementations MUST relay the Calls by calling the `receiveCalls` function on the `CrossChainReceiver` on the receiving chain with the call data.

```solidity
struct Call {
address target;
bytes data;
uint value;
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved
}

interface CrossChainRelayer {
function relayCalls(CrossChainReceiver receiver, Call[] calldata calls, uint256 gas) external payable;
}
```

```yaml
- name: relayCalls
type: function
stateMutability: payable
inputs:
- name: receiver
type: CrossChainReceiver
- name: calls
type: Call[]
- name: gas
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved
type: uint256
```

#### Events

**RelayedCalls**

MUST be emitted by the `CrossChainRelayer` when `relayCalls` is called.
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved
PierrickGT marked this conversation as resolved.
Show resolved Hide resolved

```solidity
interface CrossChainRelayer {
event RelayedCalls(
uint256 indexed nonce,
address indexed sender,
CrossChainReceiver indexed receiver,
Call[] calls,
uint256 gas
Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved
);
}
```

```yaml
- name: RelayedCalls
type: event
inputs:
- name: nonce
indexed: true
type: uint256
- name: sender
indexed: true
type: address
- name: receiver
indexed: true
type: address
- name: calls
type: Call[]
- name: gas
type: uint256
```

### CrossChainReceiver

The `CrossChainReceiver` contract executes call batches. Developers must implement a `CrossChainReceiver` in order to receive messages.

#### Methods

**receiveCalls**

Receives a batch of calls.

SHOULD authenticate the caller as being the bridge transport layer.

MUST emit the ReceivedCalls event when calls are received.

```solidity
interface CrossChainReceiver {
function receiveCalls(
CrossChainRelayer relayer,
uint256 nonce,
address caller,
Call[] calldata calls
) external;
}
```

```yaml
- name: receiveCalls
type: function
stateMutability: nonpayable
inputs:
- name: relayer
type: CrossChainRelayer
- name: nonce
type: uint
- name: caller
type: address
- name: calls
type: Call[]
```

#### Events

**ReceivedCalls**

MUST be emitted when calls are received.

```solidity
interface CrossChainReceiver {
event ReceivedCalls(
CrossChainRelayer indexed relayer,
uint256 indexed nonce,
address indexed caller,
Call[] calls
);
}
```

```yaml
- name: ReceivedCalls
type: event
inputs:
- name: relayer
indexed: true
type: CrossChainRelayer
- name: nonce
indexed: true
type: uint256
- name: caller
indexed: true
type: address
- name: calls
type: Call[]
```

## Rationale

There are some notable design decisions worth talking about:

- Relayer and nonce are passed to the Receiver
- Calls are relayed in batches

The Relayer address is passed to the receiver so that the execution can easily be traced by a client using the relayer address and nonce. A third party just needs to be aware of a list of Relayers and a list of Receivers and can trace execution across all of them.

Calls are relayed in batches because it is such a common action. Rather than have implementors take different approaches to encoding multiple calls into the `data` portion, this spec includes call batching to take away any guess work.

## Backwards Compatibility

This specification is compatible with existing governance systems as it offers simple cross-chain execution.

Pandapip1 marked this conversation as resolved.
Show resolved Hide resolved
## Security Considerations

Different bridges have wildly different trust profiles, so it's important that the user understands that bridge security will depend on the implementation being used.
PierrickGT marked this conversation as resolved.
Show resolved Hide resolved

## Copyright

Copyright and related rights waived via [CC0](../LICENSE.md).