Skip to content

Commit

Permalink
Merge pull request #5 from JukLee0ira/fix-subnet
Browse files Browse the repository at this point in the history
Fix subnet
  • Loading branch information
AnilChinchawale authored Dec 2, 2024
2 parents ec7c82d + 982c82c commit 9515d22
Show file tree
Hide file tree
Showing 37 changed files with 77 additions and 62 deletions.
10 changes: 5 additions & 5 deletions docs/subnet/components/checkpoint_contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The primary function of the parent chain smart contract is to receive block data

- Only three consecutive blocks of `roundNumber` can confirm the previous block, and `mainnetNum` will change from -1 to `block.number` once the block is committed.

![Overview](sc-overview.jpg)
![Overview](../img/sc-overview.jpg)

### Specifics

Expand Down Expand Up @@ -57,7 +57,7 @@ The Checkpoint contract implements a blockchain checkpoint system, which verifie

3. Users can retrieve the information of each block using methods such as `getHeader`.

![Checkpoint](sc-checkpoint.jpg)
![Checkpoint](../img/sc-checkpoint.jpg)

#### Lite Checkpoint

Expand Down Expand Up @@ -122,7 +122,7 @@ The `ProxyGateway` smart contract plays a central role in this module. It inheri
- Ensures the provided logic contract has a `MODE` function that returns "lite".


![Alt text](sc-upgradeable-overview.png)
![alt text](../img/sc-upgradeable-overview.png)

**Logic Flow:**

Expand Down Expand Up @@ -159,9 +159,9 @@ The `ProxyGateway` smart contract plays a central role in this module. It inheri

Through the `ProxyAdmin` functionality, the owner can further manage the proxy, such as changing the admin or even downgrading to a previous version of the logic contract if needed.

![Alt text](sc-upgradeable-upgrade.png)
![Alt text](../img/sc-upgradeable-upgrade.png)

## spec
## Spec

### APIs
- Functions that have access restriction to authorized client
Expand Down
5 changes: 2 additions & 3 deletions docs/subnet/components/relayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ At high level, the relayer is able to:
2. Process and submit subnet block data as smart contract transactions into mainnet
3. When subnet masternodes list changes, report the new list and change height to the mainnet using grand-master account.

![architectural-diagram](relayer-diagram.jpg)

![architectural-diagram](../img/relayer-diagram.jpg)

## Relayer Mode

There are 2 relayer modes 'Full' and 'Lite' where the default mode is 'Full'. In the full mode, all subnet block headers are checkpointed to the parent chain. In the lite mode, only the Epoch and Epoch gap subnet block headers are checkpointed in the parent chain (blocks 451,900,1351,1800, and so on). The Epoch and Epoch gap blocks stores important information regarding subnet validators selection. For further reading please check [Checkpoint Smart Contract](../checkpoint_smart_contract/design.md).
There are 2 relayer modes 'Full' and 'Lite' where the default mode is 'Full'. In the full mode, all subnet block headers are checkpointed to the parent chain. In the lite mode, only the Epoch and Epoch gap subnet block headers are checkpointed in the parent chain (blocks 451,900,1351,1800, and so on). The Epoch and Epoch gap blocks stores important information regarding subnet validators selection. For further reading please check [Checkpoint Smart Contract](../components/checkpoint_contract.md).

### Choosing Full or Lite Relayer

Expand Down
13 changes: 5 additions & 8 deletions docs/subnet/components/subswap.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,17 @@ title: Upgrading the Subnet
# Subswap

## Design
#### Subswap Documentation

**Topic**: **Design of Subswap Cross-Chain Transfer System on XDC Zero**

---

##### **Overview**

Subswap is cross-chain application built on XDC Zero to provide seamless cross-chain transfer capabilities. It is structured in a multi-layered architecture, with each layer handling distinct functions to ensure smooth, secure, and efficient transactions across blockchain networks. This document provides a design overview of each layer, illustrating the components and their roles within the Subswap system.

---

##### **System Architecture**
### **System Architecture**

Subswap is organized into three layers:

Expand All @@ -37,25 +35,24 @@ Subswap is organized into three layers:

---

##### **Design Considerations**
### **Design Considerations**

- **Security**: The use of locking and minting mechanisms prevents double-spending and ensures the security of cross-chain assets.
- **User Experience**: Frontends are designed to be intuitive, making it easy for users to interact with complex cross-chain protocols.
- **Reliability**: Oracles and relayers provide real-time data and reliable transaction relay, reducing the chance of errors in cross-chain transfers.

##### **Conclusion**
### **Conclusion**

Subswap leverages XDC Zero's powerful infrastructure to deliver an efficient cross-chain transfer service. By layering its architecture, Subswap can maintain security, scalability, and ease of use, meeting the needs of users looking for seamless asset transfers across multiple blockchain networks.

### Construction(if you want to make a cross chain transfer)
![Alt text](image2.png)
![Alt text](../img/subswap_image2.png)


![Alt text](image1.png)
![Alt text](../img/subswap_image1.png)

## Spec
### Subswap API Documentation
---
This document provides an API reference for the Subswap contracts, specifically for the `ParentnetTreasury` and `SubnetTreasury` contracts. These contracts facilitate cross-chain asset transfers by minting, burning, locking, and unlocking tokens between chains.

---
Expand Down
9 changes: 4 additions & 5 deletions docs/subnet/components/xdc_zero.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Upgrading the Subnet
---
# XDCZero
default


## Design
Expand Down Expand Up @@ -34,19 +33,19 @@ At its core, the Endpoint functions as the orchestrator for all cross-chain data

Experience a user-centric interface to manage the endpoint contracts spanning different chains. View the chain entities already synchronized with the current endpoint contract and effortlessly onboard new chain entities as per requirements.

![System Architecture](image1.png)
![System Architecture](../img/image1.png)

### Endpoint workflow

![System Architecture](image2.png)
![System Architecture](../img/image2.png)

### Workflow

![System Architecture](image.png)
![System Architecture](../img/image.png)


## API Documentation
// TODO:Spec?
<!-- TODO:Spec? -->

### Restricted Access Functions

Expand Down
Binary file added docs/subnet/img/account_connect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/add_master_node_candidate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/confirm_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/confirm_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/confirm_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/connect_wallet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/docker_mem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/faucet-server1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/faucet-server2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/faucet-server3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/faucet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/homepage_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/homepage_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/image2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/import_account.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/promote_node_delegate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/relayer-diagram.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/remove_master_node.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/sc-checkpoint.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/sc-litecheckpoint.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/sc-overview.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/sc-upgradeable-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/sc-upgradeable-upgrade.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/subnet/img/subswap_image1.png
Binary file added docs/subnet/img/subswap_image2.png
Binary file added docs/subnet/img/switch_subnet.png
Binary file added docs/subnet/img/ui.png
87 changes: 52 additions & 35 deletions docs/subnet/install_guide/f&q.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,32 @@ title: Upgrading the Subnet
# TODO: title
---

# Common Issues and Troubleshooting
# Frequently Asked Questions
## Subnet Launch
### Common Issues
- **Subnet blocks are not being mined**.

## Common Issues
- Subnet blocks are not being mined.
1. First confirm that the Subnet nodes are able to communicate with each other through the network layer. Run the check peer script `generated/scripts/check-peers.sh` the number of peers should be one less than number of subnet nodes. For example, if there are 3 Subnet nodes in total, each node should have 2 peers.

2. If the nodes are peering but still not mining, it could be a low memory issue. In Docker configs you can try to increase memory or swap. Then, in case of fresh Subnet, [delete data and start the nodes again](./1_launch_subnet.md/#deleting-subnet). ![Docker Memory Config](./img/docker_mem.png)
2. If the nodes are peering but still not mining, it could be a low memory issue. In Docker configs you can try to increase memory or swap. Then, in case of fresh Subnet, [delete data and start the nodes again](../install_guide/launch_subnet.md/#deleting-subnet). ![Docker Memory Config](../img/docker_mem.png)!

3. Docker engine in Mac OS can be inconsistent after long-running or high-load. It could help to restart the machine and [hard reset the subnet](./1_launch_subnet.md#deleting-subnet ) to get it running.
3. Docker engine in Mac OS can be inconsistent after long-running or high-load. It could help to restart the machine and [hard reset the subnet](../install_guide/launch_subnet.md/#deleting-subnet) to get it running.

- Subnet node does not boot with error log `Fatal: Error starting protocol stack: listen unix /work/xdcchain/XDC.ipc: bind: invalid argument`

This is due to the volume mount path being too long. The mounth path is your current directory (also can check with `pwd` command). Please move the `generated` folder to a shorter path and try again.
- **Subnet node does not boot with error log `Fatal: Error starting protocol stack: listen unix /work/xdcchain/XDC.ipc: bind: invalid argument`**

- Docker image startup fails with `SIGKILL` or `Error code: 137` found in logs. (Issue found in Frontend image)
This is due to the volume mount path being too long. The mounth path is your current directory (also can check with `pwd` command). Please move the `generated` folder to a shorter path and try again.

This error occurs because Docker ran Out Of Memory (OOM). You can increase the memory limit in [Docker settings](https://docs.docker.com/desktop/settings/mac/#:~:text=lower%20the%20number.-,Memory,-.%20By%20default%2C%20Docker)


- **Docker image startup fails with `SIGKILL` or `Error code: 137` found in logs. (Issue found in Frontend image)**

This error occurs because Docker ran Out Of Memory (OOM). You can increase the memory limit in [Docker settings](https://docs.docker.com/desktop/settings/mac/#:~:text=lower%20the%20number.-,Memory,-.%20By%20default%2C%20Docker)



### Troubleshooting Scripts


## Troubleshooting Scripts
- `generated/scripts/check-mining.sh`

This will check your current block in Subnet
Expand All @@ -34,44 +38,57 @@ title: Upgrading the Subnet
This will check the number of peers of your Subnet node


## Telegram Troubleshooting Support Group
https://t.me/+jvkX6LaLEEthZWM1

## Subnet Node Requirements

- **How many Subnet nodes should I have?**

Even one node is enough to start the Subnet blockchain! However, for better decentralized security, 3+ nodes are recommended. At least 2/3 of all nodes must be online and honest to mine blocks.

## Development and Testing

- **For testing, should I checkpoint the Subnet to devnet or testnet?**

It's recommended to use the testnet, as the devnet will be less stable due to frequent development changes.

## Managing Subnet Tokens

- **Where are all the Subnet tokens, and how do I use the Subnet?**

## Frequently Asked Questions
In XDC-Subnet, all initial tokens are assigned to the Grandmaster wallet (check `keys.json`). You can transfer tokens to any wallet address. For easy transfers, refer to the [Faucet](../using_subnet.md/#faucet) documentation.

- How many Subnet nodes should I have?
- **How can I manage Subnet tokens?**

Even one node is enough to start the Subnet blockchain! However, for better decantralized security, 3+ nodes is recommended. At least 2/3 of all nodes must be online and honest to mine blocks.
1. Use the [Subnet Faucet](../using_subnet.md/#faucet) to easily transfer Subnet tokens to your users.
2. Use any Web3 wallet (such as Metamask or OKX wallet), add the Subnet RPC as a custom network then connect to the Subnet and transfer tokens to other addresses.

- For testing, should I checkpoint the Subnet to devnet or testnet?

Testnet, devnet will be less stable due to frequent development changes.
- **How can I easily give out Subnet tokens to my users?**

- Where are all the Subnet tokens, how do I use the Subnet?
A Faucet server script is provided for you to deploy under `generated/scripts/faucet-server.sh`. Anyone with access to the faucet page can request tokens. Please refer to the [faucet page](../using_subnet.md/#faucet) for more details.

In XDC-Subnet all initial tokens are assigned to the Grandmaster wallet (check keys.json). You can transfer them to any wallet address. Check [Faucet](../usage/2_faucet.md).
## Security and Sensitive Files

- How can I manage Subnet tokens?
- **Which files contain sensitive data and private keys?**

1. Check [here](../usage/2_faucet.md) for how you can use the Subnet Faucet to easily transfer Subnet tokens to your users.
2. You can use any web3 wallet and connect to the Subnet RPC as a custom network, then transfer to other addresses.
The following files contain sensitive information and should be stored securely:

- How can I easily give out Subnet tokens to my users?

We have provided a Faucet server for you to deploy under `generated/scripts/faucet-server.sh`. Anyone with access to the faucet page can request for tokens.
Please check (faucet page)
- `common.env`
- `contract_deploy.env`
- `keys.json`
- `subnet*.env`

- Which files contain sensitive data and private keys?
## Configuration Changes

common.env, contract_deploy.env, keys.json, and subnet*.env. Please make sure these files are kept securely.
- **How do I change the Relayer Wallet/Parentchain Wallet?**

- This function didn't work/I have encoutered an unexpected bug
You can update the `common.env` file to change the Relayer key. Refer to the [service configuration documentation](../upgrading_subnet.md/#updating-services-configs) for more details.

For troubleshooting we can help you at [Telegram Support Group](./3_troubleshooting.md#telegram-troubleshooting-support-group) and we will check as soon as possible.
## Troubleshooting

Other channels for suggestions/requests include [XDC Forum](https://forum.xinfin.org/) and [GitHub Issues](https://github.com/XinFinOrg/XDC-Subnet/issues)
- **What should I do if a function didn’t work or I encountered an unexpected bug?**

- How do I change the Relayer Wallet/Parentchain Wallet?
For troubleshooting support, join our [Telegram Support Group](https://t.me/+jvkX6LaLEEthZWM1).
For suggestions or requests, you can also reach out via:

You can [update services configs](./2_configs_explanation.md#updating-services-configs) in common.env to change the Relayer key
- [XDC Forum](https://forum.xinfin.org/)
- [GitHub Issues](https://github.com/XinFinOrg/XDC-Subnet/issues)
13 changes: 8 additions & 5 deletions docs/subnet/install_guide/launch_subnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ title: Upgrading the Subnet
- https://faucet.blocksscan.io/

## Video Walkthrough
<iframe width="720" height="400" src="https://www.youtube.com/embed/m-sPbMrB8ow" frameborder="0" allow="fullscreen"></iframe>

<iframe width="768" height="432" src="https://www.youtube.com/embed/m-sPbMrB8ow" title="Setting Up Your Own XDC-Subnet Tutorial" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>


## Generate Subnet Configs With UI

Expand All @@ -47,26 +49,27 @@ title: Upgrading the Subnet


4. Config the Subnet options per your requirement.
![UI](./img/ui.png)
![UI](../img/ui.png)

5. follow the generated instructions in `commands.txt`. In general, the steps are:
- start Subnet Nodes
- deploy CSC
- deploy XDC-Zero (optional)
- start Subnet Services (relayer, stats-server, frontend)

6. Once successfully deployed, you can check out [UI usage guide](../usage/ui/1_homepage.md)
6. Once successfully deployed, you can check out [UI usage guide](../using_subnet.md)

## Removing Subnet

### Shutdown Subnet
### Shutdown Subnet
Under `generated` directory
```
docker compose --env-file docker-compose.env --profile services down
docker compose --env-file docker-compose.env --profile machine1 down
```

### Deleting Subnet
### Deleting Subnet

Remove `xdcchain*`, `bootnodes`, and `stats-service` directories
Warning: this cannot be undone
```
Expand Down
2 changes: 1 addition & 1 deletion docs/subnet/upgrading_subnet.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: Upgrading the Subnet
## Updating Configs
### Upgrading Subnet Deployment
#### Create a Subnet backup
1. [Shutdown the subnet](./1_launch_subnet.md#shutdown-subnet )
1. [Shutdown the subnet](install_guide/launch_subnet.md/#shutdown-subnet)

2. Make a copy of `xdcchain` directory

Expand Down

0 comments on commit 9515d22

Please sign in to comment.