Skip to content

Commit

Permalink
Rebase with origin (#1)
Browse files Browse the repository at this point in the history
### Description

Rebasing from the parent repo.
  • Loading branch information
shuse2 authored Jun 12, 2024
2 parents 4312165 + 4cba61a commit 52f1a92
Show file tree
Hide file tree
Showing 152 changed files with 5,618 additions and 2,624 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ module.exports = {
"@typescript-eslint/no-unused-vars": ["error", { ignoreRestSiblings: true }],
"chai-expect/missing-assertion": 2,
"no-duplicate-imports": "error",
// "require-await": "error",
"@typescript-eslint/no-floating-promises": ["error"],
"@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
},
settings: {
node: {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ jobs:
- name: "Checkout Repository"
uses: actions/checkout@v3
- name: "Dependency Review"
uses: actions/dependency-review-action@v3.1.2
uses: actions/dependency-review-action@v4.3.2
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:16

WORKDIR /relayer-v2
WORKDIR /relayer

COPY . ./

Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<div align="center">
<br />
<br />
<a href="https://docs.across.to/v2/how-does-across-work/overview"><img alt="Across" src="https://2085701667-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo33kX1T6RRp4inOcEH1d%2Fuploads%2F9CVfE3fSzsUxaZiqausI%2FAcross-green-darkbg.png?alt=media&token=8c84e972-794c-4b52-b9cf-0e5d7ae2270a" width=600></a>
<a href="[https://docs.across.to/](https://docs.across.to/)"><img alt="Across" src="https://2085701667-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo33kX1T6RRp4inOcEH1d%2Fuploads%2F9CVfE3fSzsUxaZiqausI%2FAcross-green-darkbg.png?alt=media&token=8c84e972-794c-4b52-b9cf-0e5d7ae2270a" width=600></a>
<br />
<h3><a href="https://docs.across.to/v2/how-does-across-work/overview">Across</a> is a secure and instant asset-transfer bridge between EVM networks.</h3>
<h3><a href="[https://docs.across.to/](https://docs.across.to/)">Across</a> is a secure and instant asset-transfer bridge between EVM networks.</h3>
<br />
</div>

# Across V2 Relayer
# Across V3 Relayer

This code implements [UMIP-157](https://github.com/UMAprotocol/UMIPs/blob/master/UMIPs/umip-157.md) and interacts with these [smart contracts](https://github.com/across-protocol/contracts-v2). The contracts were audited [by OpenZeppelin](https://blog.openzeppelin.com/uma-across-v2-audit/).
This code implements [UMIP-157](https://github.com/UMAprotocol/UMIPs/blob/master/UMIPs/umip-157.md) and interacts with these [smart contracts](https://github.com/across-protocol/contracts). The contracts were audited [by OpenZeppelin](https://blog.openzeppelin.com/across-v3-incremental-audit).

# How to run a Relayer

Check out [this guide](https://docs.across.to/v2/developers/running-a-relayer) for detailed bot instructions!
Check out [this guide](https://docs.across.to/relayers/running-a-relayer) for detailed bot instructions!

## Prerequisites

After installing dependencies and building the repository, be sure to to [install RedisDB](https://redis.io/docs/getting-started/installation/), an in-memory storage layer that is required to make the bots work. The bots query blockchain RPCs for a lot of smart contract events so its important that the bot
After installing dependencies and building the repository, be sure to [install RedisDB](https://redis.io/docs/getting-started/installation/), an in-memory storage layer that is required to make the bots work. The bots query blockchain RPCs for a lot of smart contract events so its important that the bot
cache some of this data in order to maintain its speed.

The first time that the bot runs, it might be slower than usual as the Redis DB fills up. This slowdown should disappear on subsequent runs.
Expand All @@ -38,7 +38,7 @@ REDIS_URL=redis://localhost:6379

```sh
# install dependencies
cd relayer-v2
cd relayer
yarn install

# build relayer bot
Expand Down Expand Up @@ -69,13 +69,13 @@ Read through [CONTRIBUTING.md](https://github.com/UMAprotocol/protocol/blob/mast

## Bug Bounty

Here's the official Across [bug bounty program](https://docs.across.to/v2/miscellaneous/bug-bounty). The bug bounty only applies to the `master` branch and is agnostic of release versions.
Here's the official Across [bug bounty program](https://docs.across.to/resources/bug-bounty). The bug bounty only applies to the `master` branch and is agnostic of release versions.

## Integration tests

You can conveniently run the dataworker, relayer, and finalizer functions via the hardhat task `integration-tests` which sets safe configurations like `PROPOSER_ENABLED=false` and prevents the user from accidentally sending an on-chain transaction. The test will complete successfully if no functions throw an error, which can be used as an additional source of confidence (in addition to the unit tests) that code has not broken the production bots.

If you want to read more about the three different agents in the Across system, check out the [docs](https://docs.across.to/v2/how-does-across-work/overview/user-roles).
If you want to read more about the three different agents in the Across system, check out the [docs](https://docs.across.to/reference/actors-in-the-system).

```sh
LOG_IN_TEST=true yarn hardhat integration-tests --wallet mnemonic
Expand All @@ -85,9 +85,9 @@ LOG_IN_TEST=true yarn hardhat integration-tests --wallet mnemonic

### Active Branches

| Branch | Status |
| ------------------------------------------------------------------- | ---------------- |
| [master](https://github.com/across-protocol/relayer-v2/tree/master) | Accepts all PRs. |
| Branch | Status |
| ---------------------------------------------------------------- | ---------------- |
| [master](https://github.com/across-protocol/relayer/tree/master) | Accepts all PRs. |

### Overview

Expand Down
6 changes: 6 additions & 0 deletions contracts/AtomicWethDepositor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ interface LineaL1MessageService {
contract AtomicWethDepositor {
Weth public immutable weth = Weth(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
OvmL1Bridge public immutable optimismL1Bridge = OvmL1Bridge(0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1);
OvmL1Bridge public immutable modeL1Bridge = OvmL1Bridge(0x735aDBbE72226BD52e818E7181953f42E3b0FF21);
OvmL1Bridge public immutable bobaL1Bridge = OvmL1Bridge(0xdc1664458d2f0B6090bEa60A8793A4E66c2F1c00);
OvmL1Bridge public immutable baseL1Bridge = OvmL1Bridge(0x3154Cf16ccdb4C6d922629664174b904d80F2C35);
PolygonL1Bridge public immutable polygonL1Bridge = PolygonL1Bridge(0xA0c68C638235ee32657e8f720a23ceC1bFc77C77);
Expand All @@ -55,6 +56,7 @@ contract AtomicWethDepositor {

event ZkSyncEthDepositInitiated(address indexed from, address indexed to, uint256 amount);
event LineaEthDepositInitiated(address indexed from, address indexed to, uint256 amount);
event OvmEthDepositInitiated(uint256 indexed chainId, address indexed from, address indexed to, uint256 amount);

function bridgeWethToOvm(address to, uint256 amount, uint32 l2Gas, uint256 chainId) public {
weth.transferFrom(msg.sender, address(this), amount);
Expand All @@ -64,11 +66,15 @@ contract AtomicWethDepositor {
optimismL1Bridge.depositETHTo{ value: amount }(to, l2Gas, "");
} else if (chainId == 8453) {
baseL1Bridge.depositETHTo{ value: amount }(to, l2Gas, "");
} else if (chainId == 34443) {
modeL1Bridge.depositETHTo{ value: amount }(to, l2Gas, "");
} else if (chainId == 288) {
bobaL1Bridge.depositETHTo{ value: amount }(to, l2Gas, "");
} else {
revert("Invalid OVM chainId");
}

emit OvmEthDepositInitiated(chainId, msg.sender, to, amount);
}

function bridgeWethToPolygon(address to, uint256 amount) public {
Expand Down
60 changes: 60 additions & 0 deletions contracts/MockLineaEvents.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/// This file contains contracts that can be used to unit test the src/clients/bridges/LineaAdapter.ts
/// code which reads events from Linea contracts facilitating cross chain transfers.

pragma solidity ^0.8.0;

contract LineaWethBridge {
event MessageClaimed(bytes32 indexed _messageHash);
event MessageSent(
address indexed _from,
address indexed _to,
uint256 _fee,
uint256 _value,
uint256 _nonce,
bytes _calldata,
bytes32 indexed _messageHash
);

function emitMessageSent(address from, address to, uint256 value) external {
emit MessageSent(from, to, 0, value, 0, new bytes(0), bytes32(0));
}

function emitMessageSentWithMessageHash(address from, address to, uint256 value, bytes32 messageHash) external {
emit MessageSent(from, to, 0, value, 0, new bytes(0), messageHash);
}

function emitMessageClaimed(bytes32 messageHash) external {
emit MessageClaimed(messageHash);
}
}

contract LineaUsdcBridge {
event Deposited(address indexed depositor, uint256 amount, address indexed to);
event ReceivedFromOtherLayer(address indexed recipient, uint256 amount);

function emitDeposited(address depositor, address to) external {
emit Deposited(depositor, 0, to);
}

function emitReceivedFromOtherLayer(address recipient) external {
emit ReceivedFromOtherLayer(recipient, 0);
}
}

contract LineaERC20Bridge {
event BridgingInitiatedV2(address indexed sender, address indexed recipient, address indexed token, uint256 amount);
event BridgingFinalizedV2(
address indexed nativeToken,
address indexed bridgedToken,
uint256 amount,
address indexed recipient
);

function emitBridgingInitiated(address sender, address recipient, address token) external {
emit BridgingInitiatedV2(sender, recipient, token, 0);
}

function emitBridgingFinalized(address l1Token, address recipient) external {
emit BridgingFinalizedV2(l1Token, address(0), 0, recipient);
}
}
24 changes: 24 additions & 0 deletions contracts/MockOpStackEvents.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/// This file contains contracts that can be used to unit test the src/clients/bridges/op-stack
/// code which reads events from OpStack contracts facilitating cross chain transfers.

pragma solidity ^0.8.0;

contract OpStackWethBridge {
event ETHDepositInitiated(address indexed _from, address indexed _to, uint256 _amount, bytes _data);
event DepositFinalized(
address indexed _l1Token,
address indexed _l2Token,
address indexed _from,
address _to,
uint256 _amount,
bytes _data
);

function emitDepositInitiated(address from, address to, uint256 amount) external {
emit ETHDepositInitiated(from, to, amount, new bytes(0));
}

function emitDepositFinalized(address from, address to, uint256 amount) external {
emit DepositFinalized(address(0), address(0), from, to, amount, new bytes(0));
}
}
2 changes: 1 addition & 1 deletion contracts/MockSpokePool.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

import "@across-protocol/contracts-v2/contracts/test/MockSpokePool.sol";
import "@across-protocol/contracts/contracts/test/MockSpokePool.sol";

/**
* @title MockSpokePool
Expand Down
2 changes: 1 addition & 1 deletion deploy/001_deploy_atomic_depositor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
await deploy("AtomicWethDepositor", {
from: deployer,
log: true,
skipIfAlreadyDeployed: true,
skipIfAlreadyDeployed: false,
});
};
module.exports = func;
Expand Down
Loading

0 comments on commit 52f1a92

Please sign in to comment.