-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from venture23-aleo/develop
ci: mainnet deployment
- Loading branch information
Showing
323 changed files
with
70,652 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# .github/release.yml | ||
|
||
changelog: | ||
exclude: | ||
labels: | ||
- cicd | ||
- scripts | ||
- test | ||
categories: | ||
- title: Breaking Changes 🛠 | ||
labels: | ||
- Major | ||
- breaking-change | ||
- title: New Features 🎉 | ||
labels: | ||
- Minor | ||
- enhancement | ||
- Feature | ||
- title: Bug Fixes 🐛 | ||
labels: | ||
- Patch | ||
- bug | ||
- title: Other Changes 📝 | ||
labels: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Pre-release | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
permissions: | ||
contents: write | ||
packages: write | ||
repository-projects: write | ||
|
||
jobs: | ||
release: | ||
name: Release and Publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Initialize variables | ||
id: vars | ||
run: | | ||
echo «::set-output name=date::$(date +'%Y-%m-%d')» | ||
echo «::set-output name=sha8::$(echo ${GITHUB_SHA} | cut -c1-8)» | ||
- name: Changelog | ||
uses: scottbrenner/generate-changelog-action@master | ||
id: Changelog | ||
env: | ||
REPO: ${{ github.repository }} | ||
- name: Create Release | ||
id: create_release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
body: | | ||
${{ steps.Changelog.outputs.changelog }} | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,26 @@ | ||
# Ignore files for attestor | ||
go.work* | ||
attestor/rust/aleo_hash/target | ||
**/rust/target | ||
**/*.log | ||
*.txt | ||
!requirements.txt | ||
**/*UTC* | ||
**/*.db | ||
*.lock | ||
.DS_Store | ||
# solidity-coverage files | ||
coverage | ||
coverage.json | ||
*.cer | ||
*.key | ||
*.crt | ||
keys.yaml | ||
*venv | ||
*.pem | ||
.temp.* | ||
.temp | ||
|
||
# ignore go build outputs | ||
/attestor/chainService/chainService | ||
/attestor/signingService/signingService | ||
/attestor/proxy/proxy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Define variables | ||
IMAGE_NAME := myapp | ||
DOCKER_COMPOSE_FILE := ./attestor/compose.yaml # Updated Docker Compose file location | ||
AWS_PROFILE := attestor # Changed AWS profile name | ||
AWS_REGION := us-west-2 | ||
TAR_FILE := attestor.tar.gz | ||
|
||
# Default target, will be executed when you run just 'make' without any arguments | ||
all: help | ||
|
||
# Build the Docker images | ||
build: | ||
docker-compose -f $(DOCKER_COMPOSE_FILE) build | ||
|
||
# Deploy the application locally | ||
deploy-local: | ||
docker-compose -f $(DOCKER_COMPOSE_FILE) up -d attestor | ||
|
||
# Deploy the application with AWS Secrets Manager | ||
deploy-secretmanager: | ||
AWS_PROFILE=$(AWS_PROFILE) AWS_REGION=$(AWS_REGION) docker-compose -f $(DOCKER_COMPOSE_FILE) up -d attestor | ||
|
||
# Configure AWS access (set AWS credentials) | ||
configure-aws: | ||
aws configure --profile $(AWS_PROFILE) | ||
|
||
# Install Python dependencies using pip | ||
install-dependencies: | ||
pip3 install -r scripts/aws/requirements.txt >/dev/null | ||
|
||
# Create a tar.gz archive of the 'attestor' folder | ||
tar-attestor: | ||
tar -czf $(TAR_FILE) ./attestor | ||
|
||
|
||
# Run the deploy_attestor.py script | ||
deploy-to-aws: | ||
python3 ./scripts/aws/deploy_attestor.py | ||
|
||
# Create a virtual environment using venv | ||
python-venv: | ||
python3 -m venv venv | ||
. venv/bin/activate && pip3 install -r scripts/aws/requirements.txt | ||
|
||
# Help target to display available targets | ||
help: | ||
@echo "Available targets:" | ||
@echo " make build - Build the Docker images" | ||
@echo " make deploy-local - Deploy the application locally" | ||
@echo " make deploy-secretmanager - Deploy the application with AWS Secrets Manager" | ||
@echo " make configure-aws - Configure AWS access (set AWS credentials)" | ||
@echo " make deploy-auto - Deploy automatically and run Python script" | ||
@echo " make tar-attestor - Create a tar.gz file of the 'attestor' folder" | ||
@echo " make create-venv - Create a virtual environment using venv" | ||
@echo " make help - Display this help message" | ||
|
||
# Ensure that 'make' without arguments runs the 'help' target | ||
.PHONY: all build deploy-local deploy-secretmanager configure-aws deploy-auto run-script help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# aleo-bridge | ||
# Verulink Bridge | ||
Aleo and Ethereum Bridge. | ||
## Attestor Service | ||
### [Attestor Deployment Guide](./scripts/aws/DEPLOYMENT.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ALEO_DEVNET_PRIVATE_KEY1="APrivateKey1zkp8CZNn3yeCseEtxuVPbDCwSyhGW6yZKUYKfgXmcpoGPWH" | ||
ALEO_DEVNET_PRIVATE_KEY2="APrivateKey1zkp2RWGDcde3efb89rjhME1VYA8QMxcxep5DShNBR6n8Yjh" | ||
ALEO_DEVNET_PRIVATE_KEY3="APrivateKey1zkp2GUmKbVsuc1NSj28pa1WTQuZaK5f1DQJAT6vPcHyWokG" | ||
ALEO_DEVNET_PRIVATE_KEY4="APrivateKey1zkpBjpEgLo4arVUkQmcLdKQMiAKGaHAQVVwmF8HQby8vdYs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
artifacts/ | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
# Architecture Overview | ||
|
||
This document provides overview of the implementation of Aleo programs for Aleo-Eth Multisig bridge. The overall architecture is discussed [here](../docs/architecture_overview.md). | ||
|
||
There are four main programs on Aleo that make up the bridge on Aleo. | ||
|
||
1. Token Bridge | ||
2. Token Service | ||
3. MTSP (Multi Token Support Program) | ||
4. Token Holding | ||
|
||
## Program Dependencies | ||
|
||
The dependencies between these program has been been described in the following graph: | ||
|
||
```mermaid | ||
flowchart LR | ||
TokenService -- imports --> TokenHolding | ||
TokenService -- imports --> MTSP | ||
TokenService -- imports --> TokenBridge | ||
TokenHolding -- imports --> MTSP | ||
``` | ||
|
||
## Common Data Structures | ||
|
||
### Address | ||
|
||
For address of Aleo, we represent with the primitive [`address`](https://developer.aleo.org/leo/language#addresses) type. | ||
To represent addresses of some other chain, we represent it as bytes32 (zero-left-padded). | ||
For EVM addresses (of 20 bytes), the first 12 bytes are 0s. | ||
|
||
> Representing as bytes32 allows to add support for other chains in the future with the same programs. | ||
Example: | ||
USDC Contract Address: 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 is represented as following\ | ||
`[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 160, 184, 105, 145, 198, 33, 139, 54, 193, 209, 157, 74, 46, 158, 176, 206, 54, 6, 235, 72 ]` | ||
|
||
### String | ||
|
||
Since the string type is not supported on Aleo (yet), we represent string as ASCII-byte in hex, then concatenate all and convert to decimal again which will be stored as u128.\ | ||
Example: `USD Coin` is represented as following:\ | ||
String to ASCII-byte hex conversion: `55 53 44 20 43 6F 69 6E`\ | ||
Concatenate together: `55534420436F696E`\ | ||
Convert to Decimal: `6148332821651876206`\ | ||
`6148332821651876206` will be stored as `u128` for the `name` field. | ||
|
||
## Token Bridge | ||
|
||
[`Packet`](../docs/architecture_overview.md#packet) is published, received and consumed in the token bridge. When attestors find a packet on some other chain, they sign the `Packet` and publishes the signature on the database. The users can then collect those signatures from the database and can directly consume those packets to mint corresponding assets via supported services such as `Token Service` program. | ||
Similarly, supported services can `publish` messages that will be transferred to the destination chain. It has the following functions: | ||
|
||
## Token Service | ||
|
||
Token Service validates the incoming messages and passes it to the Token Bridge to `publish` or `consume`. Also since Token Service imports MTSP, token service has to fulfill function of adding and registering new tokens in the MTSP without needing to deploy separate program for Tokens. This makes it redundant to deploy new programs for token which doesn't have any special functionality. | ||
|
||
## Token Holding | ||
|
||
This program is responsible for holding disputed funds and transfers for every token that is being received through the bridge. | ||
|
||
## Ownership and Upgradeability | ||
|
||
Each of the above program has a owner that performs admin functions. The owner can be set during initialization and the ownership can be transferred only from the current owner. | ||
|
||
| Programs | Owner | | ||
| ------------- | ---------------------| | ||
| Token Bridge | Bridge Council | | ||
| Token Service | Service Council | | ||
| Token Holding | Token Service | | ||
| MTSP | Token Service | | ||
|
||
### Council Program | ||
|
||
Council is a separate program that acts as a multisig to perform admin functions. Functions from council can be executed only if threshold of members (of council) vote to perform a particular action. | ||
|
||
With the limit in number of variables in SnarkOS, we have split the council and it's functionalities into three programs. | ||
|
||
**1. council.aleo:** The program where the state of the council is stored. It holds the addresses of the council members, current threshold, proposed proposals and the votes on those proposals. It also provides an *external_execute* function for the other council programs to call and verify that the proposal has enough votes to be executed. | ||
|
||
**2. token_service_council.aleo:** This program is the owner of the token_service and can call various parameter changing functions in the token_service if the proposal has enough votes. It calls the external_execute function provided by council.aleo program. | ||
|
||
**3.bridge_counci.aleo:** This program is the owner of the token_bridge and can call various parameter changing functions in the token_bridge if the proposal has enough votes. It also calls the external_execute function provided by council.aleo program. | ||
|
||
For example to release fund from holding contract, council needs to propose release proposal with enough votes to pass the threshold, and calls release function in holding contract which will release assets to the actual receiver. | ||
|
||
# Testing | ||
|
||
We conduct testing using [DokoJS](<](https://github.com/venture23-aleo/doko-js/)>). Tests are scripted in TypeScript and can be found in the [`test`](./test) directory. To execute the tests successfully, you'll need to have DokoJS installed, along with the snarkos node running on the default port (3030). | ||
|
||
## Setup | ||
|
||
Before running the tests, ensure you have the following prerequisites in place: | ||
|
||
**1. Rust:** Refer to the [Installation Guide](https://www.rust-lang.org/tools/install) for assistance with Rust installation. `Used v1.76.0` | ||
|
||
**2. SnarkOS:** Clone the testnet3 branch of snarkOS. Use following clone script instead of default clone script provided in snarkos readme. | ||
|
||
```bash | ||
git clone --branch testnet3 https://github.com/AleoHQ/snarkOS.git --depth 1 | ||
``` | ||
|
||
Follow the instructions afterwards cloning provided in the [Installation Guide](https://github.com/AleoHQ/snarkos?tab=readme-ov-file#22-installation). If you encounter build issues, consider trying the fix provided [here](https://github.com/eqlabs/snarkOS/tree/fix/compile). `Used v2.2.7` | ||
|
||
**3. Leo language:** Get Leo up and running with the help of the [Installation Guide](https://github.com/aleoHQ/leo). | ||
|
||
**4. DokoJS:** Installing DokoJS. You can install DokoJS using npm or from source. `Used v0.0.2` | ||
|
||
##### From NPM | ||
|
||
Install DokoJS globally using npm: | ||
`npm install -g @doko-js/cli@latest` | ||
|
||
##### From Source | ||
|
||
```bash | ||
# Download the source file | ||
git clone https://github.com/venture23-aleo/doko-js.git | ||
|
||
cd doko-js | ||
|
||
# Install the dependencies | ||
pnpm install | ||
|
||
# Build the project | ||
npm run build | ||
|
||
# Install dokojs | ||
npm run install:cli | ||
``` | ||
|
||
## Running Tests | ||
|
||
1. Clone the repository. | ||
|
||
```bash | ||
git clone https://github.com/venture23-aleo/verulink.git | ||
|
||
cd attestor | ||
|
||
# Change branch to update/readme-update-dokojs, after PR is merged git checkout develop | ||
git checkout update/readme-update-dokojs | ||
``` | ||
|
||
2. Install the dependencies and create env file. | ||
|
||
```bash | ||
cd aleo | ||
|
||
# Install the dependencies | ||
npm install | ||
|
||
# Create .env file. 4 private keys on the .env.example are the default private keys on the local devnet with aleo credits. | ||
cp .env.example .env | ||
``` | ||
|
||
3. Compile the programs using the following command: | ||
|
||
```bash | ||
dokojs compile | ||
``` | ||
|
||
3. Just run following on the snarkOS directory where you cloned and build snarkOS. Start the snarkos devnet. More instructions about running devnet can be found [here](https://github.com/aleoHQ/snarkos?tab=readme-ov-file#63-local-devnet). | ||
|
||
```bash | ||
# Settings: 4 validators, clients 0 | ||
./devnet.sh | ||
``` | ||
|
||
5. Run the tests for a specific program `(filename example: 1_tokenBridge.test.ts)` using the following command: | ||
|
||
```bash | ||
npm run test --runInBand -- 1_tokenBridge | ||
``` | ||
|
||
Test are formatted such that first describe block consists of tests that are to be run in execute mode with devnet locally running which requires transition and finalize block both to be run, and second describe block consists of tests that are to be run in evaluate mode and will only check the transition function logic running and it doesn't require devnet to be running. | ||
|
||
So, if you want to run only execute mode test or evaluate mode test then modify the required test files with `describe.skip` for the block which you want to skip. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import dotenv from 'dotenv'; | ||
dotenv.config(); | ||
|
||
export default { | ||
mode: "execute", | ||
mainnet: {}, | ||
networks: { | ||
testnet: { | ||
endpoint: "http:localhost:3030", | ||
accounts: [process.env.ALEO_DEVNET_PRIVATE_KEY1, process.env.ALEO_DEVNET_PRIVATE_KEY2, process.env.ALEO_DEVNET_PRIVATE_KEY3, process.env.ALEO_DEVNET_PRIVATE_KEY4], | ||
priorityFee: 0.01, | ||
}, | ||
// testnet: { | ||
// endpoint: "https://api.explorer.aleo.org/v1", | ||
// accounts: [process.env.ALEO_DEVNET_PRIVATE_KEY1, process.env.ALEO_DEVNET_PRIVATE_KEY2, process.env.ALEO_DEVNET_PRIVATE_KEY3, process.env.ALEO_DEVNET_PRIVATE_KEY4], | ||
// priorityFee: 0.01, | ||
// }, | ||
}, | ||
defaultNetwork: "testnet", | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "presets": ["@babel/preset-env"] } |
Oops, something went wrong.