Skip to content

Commit

Permalink
rosen updates
Browse files Browse the repository at this point in the history
  • Loading branch information
glasgowm148 committed Dec 11, 2023
1 parent 10850f5 commit 713c2a9
Show file tree
Hide file tree
Showing 12 changed files with 408 additions and 7 deletions.
16 changes: 10 additions & 6 deletions docs/eco/rosen.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ tags:
{type: tip, open: true}
Rosen Bridge is expected to launch imminently, join the [Rosen Telegram chat](https://t.me/rosenbridge_erg) to keep up to date.
///
## Key Features:

- **Multi-Layer Security**: Rosen Bridge is safeguarded by two distinct layers of security, ensuring robust protection against potential exploits.
- **Smart Contract Reduction**: It minimizes the need for smart contracts on bridged chains, thanks to Ergo's secure hub.
- **Architecture**: The bridge's architecture includes Watchers and Guards. Watchers monitor blockchain activities and report to Guards, who then process these events and execute actions, ensuring a high level of security and functionality.
- **RSN Token**: The Rosen Token (RSN) is integral to the bridge's operation, serving as a sybil resistance mechanism, a fee distribution system, and a means to access bridge services.
- **Scalability and User Safety**: The design accommodates new chains through independent modules and prioritizes user transaction success by waiting for sufficient confirmations.
## Key Features

Rosen Bridge is an [open-source](https://github.com/rosen-bridge) protocol, primarily focused on Ergo, that allows users to seamlessly transfer coins and tokens between Ergo and any other compatible blockchain. The compatibility of the other blockchain, referred to as chainX, is determined by its support for multi-signature transactions or threshold signatures.

One of the unique aspects of this bridge is that it eliminates the need for deploying and using smart contracts on the other chains. This is because consensus on any action is achieved on the Ergo platform by a group of entities known as Guards. These Guards generate a signed transaction (either for Ergo or chainX) which can then be broadcasted to the other chain by any party, including the Guards themselves.

- **Architecture**: The architecture of the bridge comprises of Watchers and Guards. [Watchers](rosen-watcher.md) are responsible for monitoring blockchain activities and reporting them to [Guards](rosen-guard.md). The Guards process these events and execute actions, thereby ensuring a high level of security and functionality.
- **Smart Contract Reduction**: The Ergo-centric logic of Rosen Bridge significantly reduces the need for smart contracts on the chains it bridges.
- **RSN Token**: The Rosen Token (RSN) plays a crucial role in the operation of the bridge. It serves as a mechanism for sybil resistance, a system for fee distribution, and a means to access the services of the bridge.
- **Scalability and User Safety**: The design of Rosen Bridge allows for the addition of new chains through independent modules. It also prioritizes the success of user transactions by waiting for a sufficient number of confirmations.

93 changes: 93 additions & 0 deletions docs/eco/rosen/rosen-faq.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

# FAQs: Rosen Bridge Operations and Features

### What is the bridge fee structure?

Initially, it's the greater of $10 or 0.5% of the transaction value, plus network fees, adjustable by the guard set. The fee is collected in the transferred token on Ergo. Network fees vary: static for Ergo and Cardano, dynamic for EVM-based networks.

### Is there a maximum amount for a single transaction on Rosen Bridge?

No fixed maximum, but large transfers may take longer, from hours to 1-2 days, due to manual guard intervention for fund transfers from cold to hot wallets.

### How is ADA managed within the system for transactions to Cardano?

Network fees in the transaction token on Ergo are sent to a dedicated address for covering network fees on different chains. Currently, the Rosen team manually manages this, with plans for future automation.

### How can a project add new token options to the bridge?

Projects pay a listing fee to the Rosen Fund, with potential discounts for open-source projects. This involves minting wrapped tokens and updating the token map. Fees are distributed to watchers and guards.

### What are the next chains to be added following ADA?

The roadmap includes BTC, BSC (EVM-chains), and Dogecoin in the midterm. Code refactoring aims to facilitate adding new chains, with initial chains being the most challenging.

### What is the size and composition of your team?

The team includes 8 developers, with some frontend and UI tasks outsourced. Additionally, 2-3 developers have worked part-time over the past year, supported by several advisors.

## Watcher FAQs

### Role and Rewards
Watchers are essential for accurate reporting and receive 70% of transaction fees as rewards for successful and accurate reporting. (while 30% goes to the guard set).

### Collateral Requirements:
Each instance requires 800 ERG and 30,000 RSN as collateral. This collateral is fully redeemable and the amount is adjustable.

### Permit Acquisition:
To report, watchers must acquire permits, costing an additional 3,000 RSN. Multiple permits are necessary for reporting concurrent events, and permits can be seized if reports are found fraudulent.

### Reporting Process:
- Watchers report deposit events as part of a collective effort.
- A consensus among watchers on an event triggers a final report and guard intervention.
- Guards take necessary actions based on these reports.
- Watchers involved in successful cross-chain settlements are rewarded.

### Is there a limit on the number of watchers?
Effectively, yes. A a minimum of 70%+1 of watchers required to trigger an event, and a maximum of 20 commitments, adjustable by the guard set.

### Can I run multiple watchers?
Yes, but it incurs financial considerations to prevent abuse. Each instance needs a unique folder and WATCHER_PORT.

### What if my report is successful?
You'll receive rewards and your staked amount will be returned.

### What if my report is incorrect and uncorroborated?
You'll get a refund of your stake without any additional penalties.

### What are the consequences of collusion and fraud in reporting?
Colluding watchers will lose the amount they staked.

### Are permits spent or staked for reporting?
Permits are staked, not spent, and can be managed through your dashboard.

### Can I adjust my permits?
Yes, you can increase or decrease your permits at any time and redeem them when leaving.

### How many permits are needed for concurrent reporting?
The number depends on bridge activity, with about 160 needed to report one transaction per minute.

### How do I redeem my collateral?
You can redeem it after redeeming your last permit token, but if you have unsettled reports, you must wait until those permits are returned.

### Do I still need RSN on Ergo to be a watcher on another chain?
Yes, all permit operations are conducted on the Ergo platform, and Rosen's logic is Ergo-based.

### Common Issues

#### Permit Health Broken

By default, the permit health warning parameter is set quite high. This is adjustable locally by adding the following into local.yaml


```yaml
healthCheck:
permit:
warnCommitmentCount: 1
criticalCommitmentCount: 0
```
Adjust the numbers as you wish.
`warnCommitmentCount`` will change the warning to yellow when the available Permits reduce to the number.

`criticalCommitmentCount`` will change to red when the available Permits reduce to this number.
Empty file added docs/eco/rosen/rosen-guard.md
Empty file.
47 changes: 47 additions & 0 deletions docs/eco/rosen/rosen-prerequisites.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Rosen Watcher Prerequisites

## Recommended Hardware Requirements

- **CPU**: 2 cores
- **RAM**: 2 GB
- **Storage**: 20 GB

## Ergo Node

If you aren't running an explorer, you will need to run a node with `ExtraIndex` enabled. This setting, if set to true, allows the node to store all transactions, boxes, and addresses in an index. `extraCacheSize` sets the number of recently used extra indexes kept in memory.

```conf
extraIndex = false
extraCacheSize = 500
```

With your complete config looking something like this

```conf
ergo {
node {
mining = false
extraIndex = true
extraCacheSize = 500
}
}
scorex {
restApi {
# Note: you must set a unique password for your API!
apiKeyHash = "324dcf027dd4a30a932c441f365a25e86b173defa4b8e58948253471b81b72cf"
}
}
```

## Docker Compose

Docker Compose is a tool used for defining and running multi-container Docker applications. It uses YAML files to configure the application's services and performs the creation and start-up process of all the containers with a single command. Docker Compose is particularly useful for development, testing, and staging environments, as well as CI workflows.

The recommended method for installing Docker Compose is to install Docker Desktop, which includes Docker Compose, Docker Engine, and Docker CLI. These are all necessary components for running multi-container Docker applications.

You can download Docker Desktop for your specific Operating System from the following link: [Docker Desktop](https://docs.docker.com/desktop/)

## Postgres

17 changes: 17 additions & 0 deletions docs/eco/rosen/rosen-team.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Rosen Team

The Rosen team is composed of a diverse group of individuals, including 8 full-time developers and 2-3 part-time developers. Some frontend and UI tasks are outsourced. The team is further bolstered by the support of several advisors.

## Founders

- **Mohammad Hasan Samadani (mhs_sam)**, an honourary Ergo Foundation board member and a founder of Rosen Bridge, has a PhD in computer science and over 12 years of experience in security and software development. He has made significant contributions to the Ergo mining infrastructure, Stratum server, and ergopool. His expertise in product ownership, research, and team leadership has been instrumental in the development of Rosen Bridge.
- **Joseph Armeanio**, a board member and director of the Ergo Foundation and a founder of Rosen Bridge, has been involved in the crypto industry since 2013. He was a partner CIO at Big Bear Investments and has been on the board of the Universal Education Foundation, a 501(c)3 organisation, since 2008. Joseph's passion for counter-economic frameworks and tools for social good drives his work in creating partnerships in the crypto industry, educational partnerships, and research opportunities, all while promoting the adoption of Ergo tooling in the public and non-profit sectors.

## Developers

- [Mohammad Kermani](https://github.com/mkermani144) is a software engineer with over 7 years of experience, including five years in the industry. He enjoys the challenge of building user-centric applications and is always eager to learn new technologies.
- [Fateme Rahmani](https://github.com/fatemeh-ra) is a dedicated developer on the Rosen Bridge team.
- [Moein zargarzadeh](https://github.com/zargarzadehm) contributes his development skills to the Rosen Bridge project.
- [SepehrGanji](https://github.com/SepehrGanji) is a key developer in the Rosen Bridge team.
- [RaaCT0R](https://github.com/RaaCT0R) brings his development expertise to the Rosen Bridge project.
- [Amir Arsalan](https://github.com/arsalanyavari) is an M.Sc. Student at Sharif University of Tehran with a passion for teaching and learning. He has a diverse range of skills including programming, Object-Oriented Programming, Data Structures, Algorithm Design, and more. He contributes his skills and knowledge to the development of Rosen Bridge.
Empty file.
13 changes: 13 additions & 0 deletions docs/eco/rosen/rosen-watcher.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Rosen Watcher Setup

Watchers are integral to Rosen Bridge, serving as cross-chain oracles. They observe and report deposit events on their network to Ergo, contributing to the network's security and expansion.

## Watcher Setup Guides

There is a [General Watchers app Tutorials Playlist](https://youtube.com/playlist?list=PLyQeADPK2PWgztdc9lCvAyqjknPaN9woQ&si=SNYxoZMv2iID610o), and more tailored guides for each platform available:

- [Windows](watcher-win.md)
- [Linux](watcher-linux.md)
- [Mac](watcher-mac.md)


168 changes: 168 additions & 0 deletions docs/eco/rosen/rosen_mac_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#!/bin/bash


## Rosen Bridge Watcher with Ergo configuration

## Steps to use
### Download this file as rosen_install.sh
### chmod +x rosen_install.sh
### ./rosen_install.sh

# Exit immediately if a command exits with a non-zero status.
set -e
# Function to install Docker and Docker Compose
install_docker() {
echo "Installing Docker..."
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io

echo "Installing Docker Compose..."
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Assumes Homebrew is installed on macOS
brew cask install docker

# Docker for Mac includes Compose, no separate installation required
fi
echo "Docker and Docker Compose installed successfully."
}

# Function to install PostgreSQL
install_postgres() {
echo "Installing PostgreSQL..."
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
sudo apt-get update
sudo apt-get install -y postgresql postgresql-contrib
elif [[ "$OSTYPE" == "darwin"* ]]; then
# Assumes Homebrew is installed on macOS
brew install postgresql
fi
echo "PostgreSQL installed successfully."
}

# Check if Docker is installed
if ! command -v docker &> /dev/null; then
install_docker
else
echo "Docker is already installed."
fi

# Check if PostgreSQL is installed
if ! command -v psql &> /dev/null; then
install_postgres
else
echo "PostgreSQL is already installed."
fi

# Prompt for environment variables
read -p "Enter your POSTGRES_PASSWORD: " POSTGRES_PASSWORD
read -p "Enter your POSTGRES_USER: " POSTGRES_USER
read -p "Enter your POSTGRES_DB: " POSTGRES_DB
POSTGRES_PORT=5432 # Default port, change if needed
read -p "Enter your MNEMONIC: " MNEMONIC
read -p "Enter your API_PASS: " API_PASS

# Create a new directory for the node and navigate into it
mkdir -p node && cd node

# Set up the `ergo.conf`
echo "
ergo {
node {
mining = false
extraIndex = true
extraCacheSize = 500
}
}
scorex {
restApi {
apiKeyHash = \"324dcf027dd4a30a932c441f365a25e86b173defa4b8e58948253471b81b72cf\"
}
}" > ergo.conf

# Populate docker-compose.yml
echo "version: \"3.8\"
services:
# Ergo blockchain node
node:
image: ergoplatform/ergo
container_name: mn-ergo-node
command: --mainnet -c /etc/ergo.conf
volumes:
- ./.ergo:/home/ergo/.ergo
- ./ergo.conf:/etc/ergo.conf:ro
ports:
- 9053:9053
- 9030:9030
restart: unless-stopped
environment:
- MAX_HEAP=4G
logging:
options:
max-size: \"10m\"
max-file: \"3\"" > docker-compose.yml

# Run the node
docker-compose up -d

# Navigate back to the parent directory
cd ..

# Clone the operation repository
git clone https://github.com/rosen-bridge/operation.git
cd operation/watcher/

# Copy the environment template file
cp env.template .env

# Set the required environment variables
echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD
POSTGRES_USER=$POSTGRES_USER
POSTGRES_DB=$POSTGRES_DB
POSTGRES_PORT=$POSTGRES_PORT" >> .env

# Set permissions for logs directory
sudo chown -R 3000:3000 logs
if [[ "$OSTYPE" == "darwin"* ]]; then
sudo chmod -R 707 logs
fi
# Pull Docker images
docker compose pull

# Create local.yaml
touch config/local.yaml

# Fetch PEER_HEIGHT
## Note: Please update this when your sync is done
PEER_HEIGHT=$(curl --silent --max-time 10 -X GET "http://localhost:9053/info" -H "accept: application/json" | python -c "import sys, json; print(json.load(sys.stdin)['maxPeerHeight']);")

# Populate config/local.yaml
echo "network: ergo
ergo:
type: node
initialHeight: \$PEER_HEIGHT
mnemonic: \$MNEMONIC
node:
url: http://127.0.0.1:9053/
transaction:
commitmentTimeoutConfirmation: 720
observation:
confirmation: 10
validThreshold: 720" > config/local.yaml

# Update config/local.yaml with actual values
sed -i '' "s/\$PEER_HEIGHT/$PEER_HEIGHT/; s/\$MNEMONIC/$MNEMONIC/" config/local.yaml

# Set BLAKE_HASH and update ergo.conf
cd ../../node
BLAKE_HASH=$(curl --silent -X POST "http://localhost:9053/utils/hash/blake2b" -H "accept: application/json" -H "Content-Type: application/json" -d "\"$API_PASS\"")
sed -i '' "s/apiKeyHash = .*/apiKeyHash = $BLAKE_HASH/" ergo.conf
docker restart mn-ergo-node

echo "Rosen Watcher setup completed."
5 changes: 5 additions & 0 deletions docs/eco/rosen/watcher-linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Setting up a Watcher on Linux

mgpai walks through a Watcher instance in [Linux and Cloud](https://www.youtube.com/watch?time_continue=1&v=1dpfLWdWMLs&embeds_referring_euri=https%3A%2F%2Fwww.therefour.org%2F&embeds_referring_origin=https%3A%2F%2Fwww.therefour.org&source_ve_path=MjM4NTE&feature=emb_title)

See also the [General Watchers app Tutorials Playlist](https://youtube.com/playlist?list=PLyQeADPK2PWgztdc9lCvAyqjknPaN9woQ&si=SNYxoZMv2iID610o)
Loading

0 comments on commit 713c2a9

Please sign in to comment.