Skip to content

Commit

Permalink
feat: mocha deployment guide, update ram reqs for arb, & add wasm vid…
Browse files Browse the repository at this point in the history
…eo (#1339)

* style: make in code block

* feat: add note about ram

* feat: add youtube video

* feat: add mocha deployment guide

* chore: formatting

* chore: fix formatting

* feat: add cover image

* feat: add another cover

* fix: internal link on deploy page

* fix: remove unecessary changes

* feat: add new container name

from celestiaorg/nitro-testnode#5

* feat: add code diff example

* feat: add container name as "new line" correctly

* fix: use current example path
  • Loading branch information
jcstein authored Dec 22, 2023
1 parent c77e082 commit 998ad51
Show file tree
Hide file tree
Showing 12 changed files with 236 additions and 84 deletions.
4 changes: 4 additions & 0 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ function sidebarHome() {
text: "Deploy an Arbitrum rollup devnet",
link: "/developers/arbitrum-deploy",
},
{
text: "Deploy an Arbitrum rollup to Mocha testnet",
link: "/developers/arbitrum-mocha",
},
{
text: "Deploy a smart contract on Arbitrum rollup",
link: "/developers/arbitrum-smart-contract",
Expand Down
96 changes: 49 additions & 47 deletions developers/arbitrum-dapp-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,77 +18,79 @@ pages.

1. Clone the `gm-portal` from Github and start the frontend:

```bash
cd $HOME
git clone https://github.com/jcstein/gm-portal.git
cd gm-portal && git checkout arbitrum
cd frontend && yarn && yarn dev
```
```bash
cd $HOME
git clone https://github.com/jcstein/gm-portal.git
cd gm-portal && git checkout arbitrum
cd frontend && yarn && yarn dev
```

2. In a new terminal instance, set your private key for the
faucet as a variable and the RPC URL you're using:
faucet as a variable and the RPC URL you're using:

```bash
export PRIVATE_KEY=0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659
export ARB_RPC_URL=http://localhost:8547
```
```bash
export PRIVATE_KEY=0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659
export ARB_RPC_URL=http://localhost:8547
```

3. Change into the `gm-portal/contracts` directory in the same terminal and deploy
the contract using Foundry:
the contract using Foundry:

<!-- markdownlint-disable MD013 -->
```bash
cd $HOME/gm-portal/contracts
forge script script/GmPortal.s.sol:GmPortalScript --rpc-url $ARB_RPC_URL --private-key $PRIVATE_KEY --broadcast
```
<!-- markdownlint-enable MD013 -->
<!-- markdownlint-disable MD013 -->

```bash
cd $HOME/gm-portal/contracts
forge script script/GmPortal.s.sol:GmPortalScript --rpc-url $ARB_RPC_URL --private-key $PRIVATE_KEY --broadcast
```

<!-- markdownlint-enable MD013 -->

4. In the output of the deployment, find the contract address and set it as a variable:

```bash
export CONTRACT_ADDRESS=<your-contract-address-from-the-output-above>
```
```bash
export CONTRACT_ADDRESS=<your-contract-address-from-the-output-above>
```

### Interact with the contract

Next, you're ready to interact with the contract from your terminal!

1. Send a "gm" to the contract:

```bash
cast send $CONTRACT_ADDRESS \
"gm(string)" "gm" \
--private-key $PRIVATE_KEY \
--rpc-url $ARB_RPC_URL
```
```bash
cast send $CONTRACT_ADDRESS \
"gm(string)" "gm" \
--private-key $PRIVATE_KEY \
--rpc-url $ARB_RPC_URL
```

2. Now that you've posted to the contract, you can read all "gms" (GMs) from the
contract with
this command:
contract with
this command:

```bash
cast call $CONTRACT_ADDRESS "getAllGms()" --rpc-url $ARB_RPC_URL
```
```bash
cast call $CONTRACT_ADDRESS "getAllGms()" --rpc-url $ARB_RPC_URL
```

3. Next, query the total number of gms, which will be returned as a hex value:

```bash
cast call $CONTRACT_ADDRESS "getTotalGms()" --rpc-url $ARB_RPC_URL
```
```bash
cast call $CONTRACT_ADDRESS "getTotalGms()" --rpc-url $ARB_RPC_URL
```

4. (Optional) In order to interact with the contract on the frontend, you'll
need to fund an account that you have in your Ethereum wallet. Transfer to an
external account with this command:

```bash
export RECEIVER=<receiver ETH address>
cast send --private-key $PRIVATE_KEY $RECEIVER --value 1ether --rpc-url $ARB_RPC_URL
```

:::tip
If you are in a different terminal than the one you set the
private key in, you may need to set it again.
:::
need to fund an account that you have in your Ethereum wallet. Transfer to an
external account with this command:

```bash
export RECEIVER=<receiver ETH address>
cast send --private-key $PRIVATE_KEY $RECEIVER --value 1ether --rpc-url $ARB_RPC_URL
```

:::tip
If you are in a different terminal than the one you set the
private key in, you may need to set it again.
:::

## Update the frontend

Expand Down
26 changes: 23 additions & 3 deletions developers/arbitrum-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ description: A guide on how to install Arbitrum Nitro and deploy an instance on

# Deploy an Arbitrum rollup devnet

![nitro-vroom](/img/nitro-vroom-devnet.png)

We will go over installation of Arbitrum Nitro and deploying an instance on an
Ubuntu AMD machine. This section covers all necessary dependencies needed to be
installed.
Expand Down Expand Up @@ -97,10 +99,28 @@ your machine.
### Validating with WASM

If you want to run a validator that will validate all blocks in WASM,
add the flag `--validate` to nitro-testnode when starting with
`./test-node.bash --init --dev --validate`.
add the flag `--validate` to nitro-testnode when starting with:

```bash
./test-node.bash --init --dev --validate
```

<!-- markdownlint-disable MD033 -->
<!-- markdownlint-disable MD013 -->
<div class="youtube-wrapper">
<iframe
class="youtube-video"
title="Arbitrum Nitro Rollup with Celestia as DA, validating blocks with WASM"
src="https://youtube.com/embed/xihXA3wkuLI"
allowfullscreen
></iframe>
</div>
:::tip
You may need significantly more RAM and CPU to validate all blocks with WASM.
:::

## Next steps

In the next page we will cover
[deploying a smart contract to your rollup](./arbitrum-smart-contract.md).
[deploying your devnet to Mocha testnet](./arbitrum-mocha.md).
2 changes: 1 addition & 1 deletion developers/arbitrum-integration.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
description: An overview of the integration of Arbitrum Orbit and Nitro with Celestia, detailing the key features and benefits, including the Ethereum fallback mechanism.
description: An overview of the integration of Arbitrum Nitro with Celestia, detailing the key features and benefits, including the Ethereum fallback mechanism.
---

# Introduction to Arbitrum rollups with Celestia as DA
Expand Down
119 changes: 119 additions & 0 deletions developers/arbitrum-mocha.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
description: An overview of the deploying Arbitrum Nitro and Celestia rollup to Mocha testnet.
---

# Deploy an Arbitrum rollup to Mocha testnet

![nitro-vroom](/img/nitro-vroom.png)

<!-- markdownlint-disable MD033 -->
<script setup>
import constants from '/.vitepress/constants/constants.js'
</script>

This guide covers deploying an Arbitrum Nitro rollup to
[Mocha testnet](../nodes/mocha-testnet.md) using Celestia as DA.

## Dependencies

- [Introduction to Arbitrum rollups with Celestia as DA](./arbitrum-integration.md)
- [Deploy an Arbitrum rollup devnet](./arbitrum-deploy.md)
- A fully synced and funded Mocha testnet [light node](../nodes/light-node.md)
- [Mocha testnet faucet](../nodes/mocha-testnet#mocha-testnet-faucet)

## Setting up your light node

<!-- markdownlint-disable MD013 -->

1. Fully sync and fund a light node on Mocha testnet using the binary.
This will use default node store of `$HOME/.celestia-light-{{constants.mochaChainId}}`.
This is what the docker-compose setup for the testnode will pick up
as a node store. If you choose to use another node store, you will need
to make changes yourself to reflect this.

2. Change the following in
[`nitro-testnode/docker-compose.yaml`](https://github.com/celestiaorg/nitro-testnode/blob/e4e5acd36890e650c581188ef746a7b02202583a/docker-compose.yaml#L3-L15):

```bash-vue
da:
container_name: 'celestia-da' // [!code ++]
user: root // [!code ++]
platform: linux/x86_64
image: "ghcr.io/rollkit/local-celestia-devnet:v0.12.1" // [!code --]
image: "ghcr.io/celestiaorg/celestia-node:v0.12.1" // [!code ++]
command: > // [!code ++]
celestia light start // [!code ++]
--core.ip rpc-mocha.pops.one // [!code ++]
--p2p.network mocha // [!code ++]
--log.level debug --gateway // [!code ++]
environment: // [!code ++]
- NODE_TYPE=light // [!code ++]
- P2P_NETWORK=mocha // [!code ++]
ports:
- "26657:26657"
- "26658:26658"
- "26659:26659"
volumes: // [!code ++]
- $HOME/.celestia-light-{{constants.mochaChainId}}/:/home/celestia/.celestia-light-{{constants.mochaChainId}}/ // [!code ++]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:26659/header/1"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
```
:::warning
It is not advised to run with `user: root` permissions in production.
:::
3. In [`nitro-testnode/test-node.bash`](https://github.com/celestiaorg/nitro-testnode/blob/e4e5acd36890e650c581188ef746a7b02202583a/test-node.bash#L7-L287)
make the following changes:
```bash-vue
# Line 7
NODE_PATH="/home/celestia/bridge/" // [!code --]
NODE_PATH="/home/celestia/.celestia-light-{{constants.mochaChainId}}/" // [!code ++]
# Line 287
# NOTE: depending on the version you're using, you may have a different
# container name to start. Change yours accordingly to `celestia-da`.
export CELESTIA_NODE_AUTH_TOKEN="$(docker exec nitro-testnode-da-1 celestia bridge auth admin --node.store ${NODE_PATH})" // [!code --]
export CELESTIA_NODE_AUTH_TOKEN="$(docker exec celestia-da celestia light auth admin --node.store ${NODE_PATH})" // [!code ++]
```
4. Pick a namespace, `<your-10bytenamespace>` that is 10 bytes in hexadecimal.
In [`nitro-testnode/scripts/config.ts`](https://github.com/celestiaorg/nitro-testnode/blob/e4e5acd36890e650c581188ef746a7b02202583a/scripts/config.ts#L223-L224)
make the following changes:
```bash
"tendermint-rpc": "http://da:26657", // [!code --]
"tendermint-rpc": "http://rpc-mocha.pops.one:26657", // [!code ++]
"namespace-id": "000008e5f679bf7116cb", // [!code --]
"namespace-id": "<your-10bytenamespace>", // [!code ++]
```
[See an example diff of the setup](https://github.com/celestiaorg/nitro/pull/4/files),
specifically
[the updates to nitro-testnode](https://github.com/celestiaorg/nitro-testnode/pull/6/files).
## Run your Nitro rollup on Mocha
1. Start your rollup:
```bash
./test-node.bash --init --dev
```
2. Send a transaction:
```bash
./test-node.bash script send-l2 --to address_0x1111222233334444555566667777888899990000
```
3. Find [the batch transaction on mocha](https://mocha.celenium.io/tx/ab5a97ddcf310417cabd57915d0f15f1071b941b902989e974f4025391c71512)
in the namespace you used. In this demonstration, I used
[the `nitrovroom` namespace](https://mocha.celenium.io/namespace/0000000000000000000000000000000000006e6974726f76726f6f6d).
Congratulations! Your Arbitrum Nitro rollup testnet is now posting
to Mocha testnet for data availability. 🏎️
22 changes: 11 additions & 11 deletions developers/arbitrum-smart-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,23 @@ This file performs unit testing on the contract we created in the previous
section. Here's what the test is doing:

- The contract includes a public "Counter" type variable called "counter".
In the `setUp` function, it initializes a new instance of the "Counter"
contract and sets the "number" variable to 0.
In the `setUp` function, it initializes a new instance of the "Counter"
contract and sets the "number" variable to 0.

- There are two test functions in the contract: `testIncrement` and
`testSetNumber`.
`testSetNumber`.

- The `testIncrement` function tests the "increment" function of the
"Counter" contract by calling it and then asserting that the "number" in
the "Counter" contract is 1. It verifies if the increment operation
correctly increases the number by one.
"Counter" contract by calling it and then asserting that the "number" in
the "Counter" contract is 1. It verifies if the increment operation
correctly increases the number by one.

- The `testSetNumber` function is more generic. It takes an unsigned integer
argument 'x' and tests the "setNumber" function of the "Counter" contract.
After calling the "setNumber" function with 'x', it asserts that the
"number" in the "Counter" contract is equal to 'x'. This verifies that the
"setNumber" function correctly updates the "number" in the "Counter"
contract.
argument 'x' and tests the "setNumber" function of the "Counter" contract.
After calling the "setNumber" function with 'x', it asserts that the
"number" in the "Counter" contract is equal to 'x'. This verifies that the
"setNumber" function correctly updates the "number" in the "Counter"
contract.

Now, to test your code, run the following:

Expand Down
22 changes: 11 additions & 11 deletions developers/deploy-on-bubs.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,23 @@ This file performs unit testing on the contract we created in the previous
section. Here's what the test is doing:

- The contract includes a public "Counter" type variable called "counter".
In the `setUp` function, it initializes a new instance of the "Counter"
contract and sets the "number" variable to 0.
In the `setUp` function, it initializes a new instance of the "Counter"
contract and sets the "number" variable to 0.

- There are two test functions in the contract: `testIncrement` and
`testSetNumber`.
`testSetNumber`.

- The `testIncrement` function tests the "increment" function of the
"Counter" contract by calling it and then asserting that the "number" in
the "Counter" contract is 1. It verifies if the increment operation
correctly increases the number by one.
"Counter" contract by calling it and then asserting that the "number" in
the "Counter" contract is 1. It verifies if the increment operation
correctly increases the number by one.

- The `testSetNumber` function is more generic. It takes an unsigned integer
argument 'x' and tests the "setNumber" function of the "Counter" contract.
After calling the "setNumber" function with 'x', it asserts that the
"number" in the "Counter" contract is equal to 'x'. This verifies that the
"setNumber" function correctly updates the "number" in the "Counter"
contract.
argument 'x' and tests the "setNumber" function of the "Counter" contract.
After calling the "setNumber" function with 'x', it asserts that the
"number" in the "Counter" contract is equal to 'x'. This verifies that the
"setNumber" function correctly updates the "number" in the "Counter"
contract.

Now, to test your code, run the following:

Expand Down
8 changes: 4 additions & 4 deletions developers/node-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ commands:

a. Standard build

```bash
make build
```
```bash
make build
```

b. Experimental build

Expand All @@ -249,7 +249,7 @@ commands:
seeking optimal performance with minimal RAM usage, this option is
recommended for you.

```bash
```bash
make build-jemalloc
```

Expand Down
Loading

0 comments on commit 998ad51

Please sign in to comment.