-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring and go-client imporvements
- Loading branch information
1 parent
1b30f24
commit 100c73f
Showing
225 changed files
with
15,880 additions
and
22,734 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,47 @@ | ||
name: container-images | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
tags: [ "v*" ] | ||
|
||
jobs: | ||
build-container-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- uses: docker/setup-qemu-action@v3 | ||
- uses: docker/setup-buildx-action@v3 | ||
|
||
- run: echo "IMAGE_TAG=latest" >> $GITHUB_ENV | ||
if: github.ref_name == 'main' | ||
- run: echo "IMAGE_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
|
||
- name: Login to ghcr.io | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: set lower case repository | ||
run: | | ||
echo "REPOSITORY_LC=${REPOSITORY,,}" >>${GITHUB_ENV} | ||
env: | ||
REPOSITORY: '${{ github.repository }}' | ||
|
||
- name: Build and push default image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: go-client # Because GH actions are for kids and put protection on everything; https://stackoverflow.com/a/71159809/11276254 | ||
file: go-client/Dockerfile | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: | | ||
ghcr.io/${{ env.REPOSITORY_LC }}/go-client:${{ env.IMAGE_TAG }} |
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
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,34 +1,69 @@ | ||
workflow: | ||
rules: | ||
- if: '$CI_OPEN_MERGE_REQUESTS != null && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "webide")' | ||
when: never | ||
- when: always | ||
rules: | ||
- if: '$CI_OPEN_MERGE_REQUESTS != null && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "webide")' | ||
when: never | ||
- when: always | ||
|
||
.test: | ||
stage: test | ||
image: node:18 | ||
cache: | ||
- key: | ||
files: | ||
- yarn.lock | ||
paths: | ||
- node_modules/ | ||
policy: pull | ||
before_script: | ||
- yarn install --immutable | ||
- yarn compile | ||
# lint-ts-simulation: | ||
# image: node:18 | ||
# before_script: | ||
# - cd ts-simulation | ||
# script: | ||
# - yarn install --immutable | ||
# - yarn lint | ||
|
||
lint: | ||
extends: .test | ||
script: | ||
- yarn lint | ||
# test-ts-simulation: | ||
# extends: .lint-ts-simulation | ||
# before_script: | ||
# - cd ts-simulation | ||
# script: | ||
# - yarn install --immutable | ||
# - yarn test | ||
|
||
test: | ||
extends: .test | ||
script: | ||
- yarn test | ||
lint-py-visualizer: | ||
image: python:3.12 | ||
before_script: | ||
- curl -sSL https://install.python-poetry.org | python3 - | ||
- export PATH="/root/.local/bin:$PATH" | ||
- cd py-visualizer | ||
script: | ||
- poetry install --no-root | ||
- poetry run ruff check --fix | ||
|
||
test-coverage: | ||
extends: .test | ||
script: | ||
- yarn test-coverage | ||
lint-go-client: | ||
image: golang:1.21.0 | ||
before_script: | ||
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.57.2 | ||
- cd go-client | ||
script: | ||
- go vet ./... | ||
- go fmt ./... | ||
- go mod tidy | ||
- go mod verify | ||
- golangci-lint run | ||
|
||
test-go-client: | ||
image: golang:1.21.0 | ||
before_script: | ||
- cd go-client | ||
script: | ||
- go test -v provider/random_provider_test.go | ||
- go test -v provider/feed_provider_test.go | ||
- go test -v sortition/sortition_test.go | ||
|
||
test-go-client-docker: | ||
image: docker | ||
services: | ||
- docker:dind | ||
variables: | ||
DOCKER_HOST: tcp://docker:2375 | ||
DOCKER_TLS_CERTDIR: "" | ||
DOCKER_DRIVER: overlay2 | ||
before_script: | ||
- cd go-client/tests | ||
script: | ||
- docker compose up ganache --detach | ||
- VALUE_PROVIDER_IMPL=random docker compose up value-provider --detach | ||
- docker compose up test-client --exit-code-from test-client | ||
- docker compose stop ganache | ||
- docker compose stop value-provider |
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 @@ | ||
[submodule "flare-smart-contracts-v2"] | ||
path = flare-smart-contracts-v2 | ||
url = git@gitlab.com:flarenetwork/flare-smart-contracts-v2.git | ||
branch = fast_updates |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,103 +1,21 @@ | ||
# FTSO Fast Updates | ||
|
||
This repo contains MVP of an implementation of the new Fast Updates proposal. | ||
This repo contains all the client side code associated with the new FTSO Fast Updates protocol. The Fast Updates smart contracts are pulled in from [flarenetwork/flare-smart-contracts-v2](https://gitlab.com/flarenetwork/flare-smart-contracts-v2). | ||
|
||
## Setup | ||
## go-client | ||
|
||
### Node.JS | ||
The go-client is a FTSO Fast Updates client implementation in Golang. It is responsible for generating the sortition proof and submitting the updates to the Flare blockchain. | ||
|
||
Install [NVM](https://github.com/nvm-sh/nvm), and Node v18 (LTS): | ||
The full README can be found at [go-client/README.md](./go-client/README.md) | ||
|
||
```bash | ||
nvm install 18 | ||
``` | ||
## py-visualizer | ||
|
||
### Yarn | ||
The py-visualizer is a FTSO Fast Updates Visualizer implemented in Python. It is used to provide a real-time visualization of the time-series feeds generated by the Fast Updates client. | ||
|
||
Install dependencies with `yarn`: | ||
The full README can be found at [py-visualizer/README.md](./py-visualizer/README.md) | ||
|
||
```bash | ||
corepack enable | ||
yarn install | ||
``` | ||
## ts-simulation | ||
|
||
### Project | ||
The ts-simulation is a FTSO Fast Updates Simulation implemented in TypeScript. It is used to optimize and test new contract parameters. It can be used alongside py-visualizer to visualize the Fast Updates protocol in action. | ||
|
||
To compile smart contracts: | ||
|
||
```bash | ||
yarn compile | ||
``` | ||
|
||
To format with prettier: | ||
|
||
```bash | ||
yarn format | ||
``` | ||
|
||
To lint with eslint: | ||
|
||
```bash | ||
yarn lint | ||
``` | ||
|
||
## Docker | ||
|
||
To build a docker image, run: | ||
|
||
```bash | ||
docker build -t fast-updates . | ||
``` | ||
|
||
To test the protocol using docker, navigate to the `test` directory and run docker compose: | ||
|
||
```bash | ||
cd test | ||
docker compose up | ||
``` | ||
|
||
## Simulating locally | ||
|
||
Start the chain: | ||
|
||
```bash | ||
yarn hardhat node | ||
``` | ||
|
||
Deploy the contracts and run the admin daemon: | ||
|
||
```bash | ||
yarn hardhat deploy-contracts --network localhost && yarn hardhat run-admin-daemon --network localhost | ||
``` | ||
|
||
Run the fast updates providers: | ||
|
||
```bash | ||
yarn ts-node client/run-fast-updates-provider.ts $ID --network localhost | ||
``` | ||
|
||
where `$ID` is the ID of the provider (1, 2, ...) | ||
|
||
## Visualizer | ||
|
||
Uses `dash` and `plotly` to render a live graph of the price feed in the browser, along with monitoring error rates of individual providers. Follow the instructions in `visualizer/README.md` to install and run the visualizer. | ||
|
||
## Simulating with Docker | ||
|
||
A simulation of the protocol using docker is available. It includes deploying and setting a chain node, | ||
deploying contracts, running a daemon, and running multiple fast updates providers. Navigate to | ||
`deployment/simulation` (assuming that the docker image `fast-updates` was build, as explained above) | ||
and run docker compose: | ||
|
||
```bash | ||
cd deployment | ||
docker compose up | ||
``` | ||
|
||
## Notes | ||
|
||
Strict type checked (in addition to strict mode) is enforced throughout the project (see `tsconfig.json` and `.eslintrc.js`). | ||
|
||
For testing purposes (under `test/`), `typechain-truffle` is used to generate typechain artifacts from the contracts. The contracts are locally instantiated and used in the tests. | ||
|
||
For deployment purposes (under `deployment/`), `typechain-web3-v1` is used to interact with the contracts. | ||
The full README can be found at [ts-simulation/README.md](./ts-simulation/README.md) |
Oops, something went wrong.