Skip to content

Commit

Permalink
Merge pull request #7 from AElfProject/feat/Adding_RunningAelfOnTheCl…
Browse files Browse the repository at this point in the history
…oud_And_RunningASideChain

Adding RunningAelfOnTheCloud And RunningASideChain
  • Loading branch information
AelfHongliang authored Jun 19, 2024
2 parents 01bfd6f + c191523 commit 161a9ed
Show file tree
Hide file tree
Showing 11 changed files with 574 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/tutorials/RunningASideChain/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Table of Contents

- [Request Side-Chain Creation](request-new-side-chain.md)
- [Side Chain Creation API](#side-chain-creation-api)
- [Side Chain Types](#side-chain-types)
- [Pay for Side Chain](#pay-for-side-chain)
- [Indexing Fee](#indexing-fee)
- [Resource Fee](#resource-fee)
- [Simple Demo for Side Chain Creation Request](#simple-demo-for-side-chain-creation-request)
- [Set-up](#set-up)
- [Creation of the Side Chain](#creation-of-the-side-chain)
- [Full Script](#full-script)
- [Running a Side Chain](running-side-chain.md)
- [Side Chain Configuration](#side-chain-configuration)
- [Launch the Side Chain Node](#launch-the-side-chain-node)
420 changes: 420 additions & 0 deletions docs/tutorials/RunningASideChain/requestSideChainCreation.md

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions docs/tutorials/RunningASideChain/runningASideChain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Running a Side Chain (After its Release)

This tutorial explains how to run a side chain node after it has been approved by the producers and released by the creator. After creating the side chain, producers need to run a side chain node.

## Prerequisites

- You already have a main-chain node running.
- The creation of the side chain has been approved and released.

## Important Note

The key-pair (account) used for mining on the side chain must be the same as the one used on the main-chain node. Both production nodes need to be launched with the same key-pair.

For more information about side chain creation, refer to the document in the [request-side-chain section](request-new-side-chain).

## Side Chain Configuration

### Configuration Files

Two configuration files must be placed in the configuration folder of the side chain, from which you will launch the node:

- `appsettings.json`
- `appsettings.SideChain.MainNet.json`

### Chain ID and Settings

After the release of the side chain creation request, the ChainId of the new side chain will be accessible in the SideChainCreatedEvent logged by the transaction that released it.

In this example, we will set up the side chain node with ChainId `tDVV` (1866392 converted to base58), connecting to Redis `db2`, and using web API port `1235`. Don’t forget to change the account, password, and initial miner.

#### appsettings.json

```json
{
"ChainId": "tDVV",
"ChainType": "SideChain",
"NetType": "MainNet",
"ConnectionStrings": {
"BlockchainDb": "redis://localhost:6379?db=2",
"StateDb": "redis://localhost:6379?db=2"
},
"Account": {
"NodeAccount": "YOUR PRODUCER ACCOUNT",
"NodeAccountPassword": "YOUR PRODUCER PASSWORD"
},
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://*:1235/"
}
}
},
"Consensus": {
"MiningInterval": 4000,
"StartTimestamp": 0
}
}
```

#### appsettings.SideChain.MainNet.json

```json
{
"CrossChain": {
"Grpc": {
"ParentChainServerPort": 5010,
"ListeningPort": 5000,
"ParentChainServerIp": "127.0.0.1"
},
"ParentChainId": "AELF"
}
}
```

Change `ParentChainServerIp` and `ParentChainServerPort` depending on the listening address of your mainchain node.

## Launching the Side Chain Node

Open a terminal and navigate to the folder where you created the side chain configuration:

```bash
dotnet ../AElf.Launcher.dll
```

You can try out a few commands from another terminal to check if everything is fine, for example:

```bash
aelf-command get-blk-height -e http://127.0.0.1:1235
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions docs/tutorials/RunningAelfOnTheCloud/googleCloud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Getting Started with Google Cloud

This guide will walk you through the steps required to run an aelf node on Google Cloud Platform (GCP).

## Step 1: Launch aelf Image

1. Go to the [Google Cloud Marketplace](https://console.cloud.google.com/marketplace) and search for "aelf blockchain for enterprise".

![image](gcp-step1.png)

2. Find the aelf image and click on "LAUNCH ON COMPUTE ENGINE".

![image](gcp-step2-b.png)

3. Keep the default settings and click "DEPLOY" at the bottom left of the page.

![image](gcp-deployed.png)

## Step 2: Access and Start the Chain

1. Login to the launched VM instance via SSH. You can do this by clicking the SSH drop-down and selecting "Open in browser window".

![image](gcp-ssh-select.png)

2. In the SSH session, execute `sudo bash` to elevate your privileges.

3. Start the chain with one of the following commands:

- Run it in the foreground:
```bash
cd /opt/aelf-node && docker-compose up
```
- Or run it in the background:
```bash
cd /opt/aelf-node && docker-compose up -d
```

![image](gcp-docker-compose.png)

## Step 3: Verify Chain Status

1. To verify that the node is working, use the following command to send an HTTP request and get the current chain status:

```bash
curl -X GET "http://127.0.0.1:8001/api/blockChain/chainStatus" -H "accept: text/plain; v=1.0"
```

![image](gcp-curl-chain-stat.png)

2. If everything is working normally, you should see the chain status increase with each request.

0 comments on commit 161a9ed

Please sign in to comment.