Skip to content

Commit

Permalink
Merge branch 'master' into md-mdx-conversion-batch-36
Browse files Browse the repository at this point in the history
  • Loading branch information
anegg0 committed Aug 2, 2024
2 parents c628f4e + 215b69a commit efb6d6a
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 110 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
.vscode
arbitrum-docs/sdk-docs
arbitrum-docs/sdk
9 changes: 0 additions & 9 deletions CODEOWNERS

This file was deleted.

28 changes: 15 additions & 13 deletions arbitrum-docs/audit-reports.mdx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Security Audit Reports

| Auditor | Audit date | Audited code | View report |
|-------------------------|------------|------------------------------------------------|-----------------------------------------------------------------------------------------|
| **ConsenSys Diligence** | 11/05/2021 | Core Contracts, Token Bridge | [view](hosted-audit-reports/ConsenSys_Diligence_Arbitrum_Contracts_11_2021.pdf) |
| **ConsenSys Diligence** | 06/24/2022 | Nitro Node & Core Contracts | [view](hosted-audit-reports/ConsenSys_Diligence_Nitro_Contracts_5_2022.pdf) |
| **Trail of Bits** | 10/10/2022 | Nitro Node & Core Contracts | [view](hosted-audit-reports/Trail_Of_Bits_Nitro_10_2022.pdf) |
| **Trail of Bits** | 01/06/2023 | Governance& Token Bridge | [view](hosted-audit-reports/trail_of_bits_governance_report_1_6_2023.pdf) |
| **chainsecurity** | 03/20/2024 | Nova Fee Router Updates (ArbOS 31) | [view](https://www.chainsecurity.com/security-audit/offchain-labs-fund-distribution) |
| **Trail of Bits** | 05/02/2024 | Arbitrum BoLD & Delay Buffer | [view](hosted-audit-reports/2024-04-offchainbold-securityreview.pdf) |
| **Code4rena** | 06/17/2024 | Arbitrum BoLD: Public Audit Competition Report | [view](https://code4rena.com/reports/2024-05-arbitrum-foundation) |
| **Trail of Bits** | 06/10/2024 | Arbitrum Stylus | [view](hosted-audit-reports/2024-05-offchain-arbitrumstylus-securityreview.pdf) |
| **Trail of Bits** | 07/26/2024 | Arbos30 Nitro upgrade | [view](hosted-audit-reports/2024-04-offchain-arbos-30-nitro-upgrade-securityreview.pdf) |
| **Trail of Bits** | 07/26/2024 | Arbos 31 | [view](hosted-audit-reports/2024-04-offchain-arbos-31-securityreview.pdf) |
| **Trail of Bits** | 07/24/2024 | l1-l3-teleporter | [view](hosted-audit-reports/2024-04-offchain-l1-l3-teleporter-securityreview.pdf) |
| Auditor | Audit date | Audited code | View report |
| ----------------------- | ---------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------- |
| **ConsenSys Diligence** | 11/05/2021 | Core Contracts, Token Bridge | [view](hosted-audit-reports/ConsenSys_Diligence_Arbitrum_Contracts_11_2021.pdf) |
| **ConsenSys Diligence** | 06/24/2022 | Nitro Node & Core Contracts | [view](hosted-audit-reports/ConsenSys_Diligence_Nitro_Contracts_5_2022.pdf) |
| **Trail of Bits** | 10/10/2022 | Nitro Node & Core Contracts | [view](hosted-audit-reports/Trail_Of_Bits_Nitro_10_2022.pdf) |
| **Trail of Bits** | 01/06/2023 | Governance& Token Bridge | [view](hosted-audit-reports/trail_of_bits_governance_report_1_6_2023.pdf) |
| **chainsecurity** | 03/20/2024 | Nova Fee Router Updates (ArbOS 31) | [view](https://www.chainsecurity.com/security-audit/offchain-labs-fund-distribution) |
| **Trail of Bits** | 05/02/2024 | Arbitrum BoLD & Delay Buffer | [view](hosted-audit-reports/2024-04-offchainbold-securityreview.pdf) |
| **Code4rena** | 06/17/2024 | Arbitrum BoLD: Public Audit Competition Report | [view](https://code4rena.com/reports/2024-05-arbitrum-foundation) |
| **Trail of Bits** | 06/10/2024 | Arbitrum Stylus | [view](hosted-audit-reports/2024-05-offchain-arbitrumstylus-securityreview.pdf) |
| **Trail of Bits** | 07/26/2024 | Arbos30 Nitro upgrade | [view](hosted-audit-reports/2024-04-offchain-arbos-30-nitro-upgrade-securityreview.pdf) |
| **Trail of Bits** | 07/26/2024 | Arbos 31 | [view](hosted-audit-reports/2024-04-offchain-arbos-31-securityreview.pdf) |
| **Trail of Bits** | 07/24/2024 | l1-l3-teleporter | [view](hosted-audit-reports/2024-04-offchain-l1-l3-teleporter-securityreview.pdf) |
| **Trail of Bits** | 08/01/2024 | Custom fee token | [view](hosted-audit-reports/2024_08_01_trail_of_bits_security_audit_custom_fee_token.pdf) |

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Arbitrary L1 to L2 contract calls can be created via the `Inbox`'s `createRetrya

For details and protocol specification, see [L1 to L2 Messages](/how-arbitrum-works/arbos/l1-l2-messaging.md).

For an example of retryable tickets in action, see the [Greeter](https://github.com/OffchainLabs/arbitrum-tutorials/tree/master/packages/greeter) tutorial, which uses the [Arbitrum SDK](./sdk).
For an example of retryable tickets in action, see the [Greeter](https://github.com/OffchainLabs/arbitrum-tutorials/tree/master/packages/greeter) tutorial, which uses the [Arbitrum SDK](../sdk/1-introduction.mdx).

## Arbitrum-to-Ethereum messaging

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ As explained in the conceptual page, there are 2 contracts that we need to be aw

For simplicity, in this how-to we’ll focus on the first case: bridging from Ethereum (L1) to Arbitrum (L2).

We’ll explain below what specific contracts and methods need to be called to bridge your token, but you can abstract this whole process of finding the right addresses by using Arbitrum’s SDK. You can use the [deposit](/sdk/assetBridger_erc20Bridger#deposit) function of the [ERC20Bridger](/sdk/assetBridger_erc20Bridger) class to bridge your tokens, which will use the appropriate router contract based on the network you’re connected to, and will relay the request to the appropriate gateway contract. You can also use the function [getL1GatewayAddress](/sdk/assetBridger_erc20Bridger#getl1gatewayaddress) to get the address of the gateway contract that’s going to be used. But don’t worry about any of this yet, we’ll use those functions in the next steps.
We’ll explain below what specific contracts and methods need to be called to bridge your token, but you can abstract this whole process of finding the right addresses by using Arbitrum’s SDK. You can use the [deposit](../../../sdk/reference/assetBridger/erc20Bridger.md#deposit) function of the [Erc20Bridger](../../../sdk/reference/assetBridger/erc20Bridger.md) class to bridge your tokens, which will use the appropriate router contract based on the network you’re connected to, and will relay the request to the appropriate gateway contract. You can also use the function [getParentGatewayAddress](../../../sdk/reference/assetBridger/erc20Bridger.md#getParentGatewayAddress) to get the address of the gateway contract that’s going to be used. But don’t worry about any of this yet, we’ll use those functions in the next steps.

Now, here’s an explanation of the contracts and methods that need to be called to manually bridge your token:

Expand All @@ -100,28 +100,28 @@ You can find the addresses of the contracts involved in the process in [this pag

The gateway contract will be the one that will transfer the tokens to be bridged over. So the next step is to allow the gateway contract to do so.

We typically do that by using the `approve` method of the token, but you can use Arbitrum’s SDK to abstract this process, by calling the method [approveToken](/sdk/assetBridger_erc20Bridger#approvetoken) of the [ERC20Bridger](/sdk/assetBridger_erc20Bridger) class, which will call the approve method of the token passed by parameter, and set the allowance to the appropriate gateway contract.
We typically do that by using the `approve` method of the token, but you can use Arbitrum’s SDK to abstract this process, by calling the method [approveToken](../../../sdk/reference/assetBridger/erc20Bridger.md#approvetoken) of the [Erc20Bridger](../../../sdk/reference/assetBridger/erc20Bridger.md) class, which will call the approve method of the token passed by parameter, and set the allowance to the appropriate gateway contract.

```tsx
/**
* Use l2Network to create an Arbitrum SDK Erc20Bridger instance
* We'll use Erc20Bridger for its convenience methods around transferring token to L2
*/
const l2Network = await getL2Network(l2Provider);
const l2Network = await getArbitrumNetwork(l2Provider);
const erc20Bridge = new Erc20Bridger(l2Network);

/**
* The Standard Gateway contract will ultimately be making the token transfer call; thus, that's the contract we need to approve.
* erc20Bridger.approveToken handles this approval
* Arguments required are:
* (1) l1Signer: The L1 address transferring token to L2
* (2) erc20L1Address: L1 address of the ERC20 token to be depositted to L2
* (2) erc20L1Address: L1 address of the ERC20 token to be deposited to L2
*/
console.log('Approving:');
const l1Erc20Address = l1DappToken.address;
const approveTx = await erc20Bridger.approveToken({
l1Signer: l1Wallet,
erc20L1Address: l1Erc20Address,
parentSigner: l1Wallet,
erc20ParentAddress: l1Erc20Address,
});

const approveRec = await approveTx.wait();
Expand All @@ -136,7 +136,7 @@ As mentioned before, you can also call the `approve` method of the token and sen

After allowing the gateway contract to transfer the tokens, we can now start the bridging process.

You can use Arbitrum’s SDK to abstract this process, by calling the method [deposit](/sdk/assetBridger_erc20Bridger#deposit) of the [ERC20Bridger](/sdk/assetBridger_erc20Bridger) class, which will estimate the gas parameters (\_maxGas, \_gasPriceBid and maxSubmissionCost, explained below) and call the `outboundTransferCustomRefund` method of the router contract. You will only need to specify the following parameters:
You can use Arbitrum’s SDK to abstract this process, by calling the method [deposit](../../../sdk/reference/assetBridger/erc20Bridger.md#deposit) of the [Erc20Bridger](../../../sdk/reference/assetBridger/erc20Bridger.md) class, which will estimate the gas parameters (\_maxGas, \_gasPriceBid and maxSubmissionCost, explained below) and call the `outboundTransferCustomRefund` method of the router contract. You will only need to specify the following parameters:

- `amount`: Amount of tokens to bridge
- `erc20L1Address`: L1 address of the ERC20 token being bridged
Expand All @@ -156,9 +156,9 @@ You can use Arbitrum’s SDK to abstract this process, by calling the method [de
*/
const depositTx = await erc20Bridger.deposit({
amount: tokenDepositAmount,
erc20L1Address: l1Erc20Address,
l1Signer: l1Wallet,
l2Provider: l2Provider,
erc20ParentAddress: l1Erc20Address,
parentSigner: l1Wallet,
childProvider: l2Provider,
});
```

Expand All @@ -185,7 +185,7 @@ You can programmatically wait for the execution of the transaction on L2 using A
* Now we wait for L1 and L2 side of transactions to be confirmed
*/
const depositRec = await depositTx.wait();
const l2Result = await depositRec.waitForL2(l2Provider);
const l2Result = await depositRec.waitForChildTransactionReceipt(l2Provider);

/**
* The `complete` boolean tells us if the l1 to l2 message was successful
Expand All @@ -201,15 +201,15 @@ If you’re going the manual way, you can verify if the message has been execute

Finally, let’s find the token contract that has been created on L2.

Using Arbitrum’s SDK, you can call method [getL2ERC20Address](/sdk/assetBridger_erc20Bridger#getl2erc20address) of the [ERC20Bridger](/sdk/assetBridger_erc20Bridger) class, which will return the address of the token contract in L2 that corresponds to the L1 token contract sent as parameter.
Using Arbitrum’s SDK, you can call method [getChildErc20Address](../../../sdk/reference/assetBridger/erc20Bridger.md#getChildErc20Address) of the [Erc20Bridger](../../../sdk/reference/assetBridger/erc20Bridger.md) class, which will return the address of the token contract in L2 that corresponds to the L1 token contract sent as parameter.

```tsx
/**
* Check if our l2Wallet DappToken balance has been updated correctly
* To do so, we use erc20Bridge to get the l2Token address and contract
*/
const l2TokenAddress = await erc20Bridger.getL2ERC20Address(l1Erc20Address, l1Provider);
const l2Token = erc20Bridger.getL2TokenContract(l2Provider, l2TokenAddress);
const l2TokenAddress = await erc20Bridger.getChildErc20Address(l1Erc20Address, l1Provider);
const l2Token = erc20Bridger.getChildTokenContract(l2Provider, l2TokenAddress);
```

To do this operation manually, you can call method `calculateL2TokenAddress` of the router contract.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ We now deploy that token to L1.
```tsx
const { ethers } = require('hardhat');
const { providers, Wallet } = require('ethers');
const { getL2Network } = require('@arbitrum/sdk');
const { getArbitrumNetwork } = require('@arbitrum/sdk');
require('dotenv').config();

const walletPrivateKey = process.env.DEVNET_PRIVKEY;
Expand All @@ -178,7 +178,7 @@ const main = async () => {
/**
* Use l2Network to get the token bridge addresses needed to deploy the token
*/
const l2Network = await getL2Network(l2Provider);
const l2Network = await getArbitrumNetwork(l2Provider);

const l1Gateway = l2Network.tokenBridge.l1CustomGateway;
const l1Router = l2Network.tokenBridge.l1GatewayRouter;
Expand Down Expand Up @@ -259,7 +259,7 @@ We now deploy that token to L2.
```tsx
const { ethers } = require('hardhat');
const { providers, Wallet } = require('ethers');
const { getL2Network } = require('@arbitrum/sdk');
const { getArbitrumNetwork } = require('@arbitrum/sdk');
require('dotenv').config();

const walletPrivateKey = process.env.DEVNET_PRIVKEY;
Expand All @@ -275,12 +275,12 @@ const main = async () => {
/**
* Use l2Network to get the token bridge addresses needed to deploy the token
*/
const l2Network = await getL2Network(l2Provider);
const l2Gateway = l2Network.tokenBridge.l2CustomGateway;
const l2Network = await getArbitrumNetwork(l2Provider);
const l2Gateway = l2Network.tokenBridge.childCustomGateway;

/**
* Deploy our custom token smart contract to L2
* We give the custom token contract the address of l2CustomGateway as well as the address of the counterpart L1 token
* We give the custom token contract the address of childCustomGateway as well as the address of the counterpart L1 token
*/
console.log('Deploying the test L2Token to L2:');
const L2Token = await (await ethers.getContractFactory('L2Token')).connect(l2Wallet);
Expand Down Expand Up @@ -309,7 +309,7 @@ When using this function two actions will be performed:
1. Call function `registerTokenToL2` of `L1CustomGateway`. This will change the `l1ToL2Token` internal mapping it holds and will send a retryable ticket to the counterpart `L2CustomGateway` contract in L2, to also set its mapping to the new values.
2. Call function `setGateway` of `L1GatewayRouter`. This will change the `l1TokenToGateway` internal mapping it holds and will send a retryable ticket to the counterpart `L2GatewayRouter` contract in L2, to also set its mapping to the new values.

To simplify the process, we’ll use Arbitrum’s SDK. We’ll call the method [registerCustomToken](/sdk/assetBridger_erc20Bridger#registercustomtoken) of the [AdminErc20Bridger](/sdk/assetBridger_erc20Bridger#adminerc20bridger) class, which will call the registerTokenOnL2 method of the token passed by parameter.
To simplify the process, we’ll use Arbitrum’s SDK. We’ll call the method [registerCustomToken](../../../sdk/reference/assetBridger/erc20Bridger#registercustomtoken) of the [AdminErc20Bridger](../../../sdk/reference/assetBridger/erc20Bridger#adminerc20bridger) class, which will call the registerTokenOnL2 method of the token passed by parameter.

```tsx
/**
Expand All @@ -333,7 +333,7 @@ console.log(
* To compute this txn hash, we need our message's "sequence numbers", unique identifiers of each L1 to L2 message.
* We'll fetch them from the event logs with a helper method.
*/
const l1ToL2Msgs = await registerTokenRec.getL1ToL2Messages(l2Provider);
const l1ToL2Msgs = await registerTokenRec.getParentToChildMessages(l2Provider);

/**
* In principle, a single L1 txn can trigger any number of L1-to-L2 messages (each with its own sequencer number).
Expand All @@ -345,10 +345,10 @@ const l1ToL2Msgs = await registerTokenRec.getL1ToL2Messages(l2Provider);
expect(l1ToL2Msgs.length, 'Should be 2 messages.').to.eq(2);

const setTokenTx = await l1ToL2Msgs[0].waitForStatus();
expect(setTokenTx.status, 'Set token not redeemed.').to.eq(L1ToL2MessageStatus.REDEEMED);
expect(setTokenTx.status, 'Set token not redeemed.').to.eq(ParentToChildMessageStatus.REDEEMED);

const setGateways = await l1ToL2Msgs[1].waitForStatus();
expect(setGateways.status, 'Set gateways not redeemed.').to.eq(L1ToL2MessageStatus.REDEEMED);
expect(setGateways.status, 'Set gateways not redeemed.').to.eq(ParentToChildMessageStatus.REDEEMED);

console.log(
'Your custom token is now registered on our custom gateway 🥳 Go ahead and make the deposit!',
Expand Down
Loading

0 comments on commit efb6d6a

Please sign in to comment.