Skip to content

Commit

Permalink
Merge branch 'main' into feat-solidity-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
EvolveArt authored Nov 5, 2024
2 parents 969d705 + cf5e34b commit a6ba97c
Show file tree
Hide file tree
Showing 99 changed files with 1,784 additions and 10,753 deletions.
46 changes: 22 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
# Pragma
# Pragma V2

[![GitHub Actions][gha-badge]][gha] [![codecov](https://codecov.io/gh/astraly-labs/pragma-monorepo/branch/main/graph/badge.svg?)](https://codecov.io/gh/astraly-labs/pragma-monorepo) [![Foundry][foundry-badge]][foundry] [![License: MIT][license-badge]][license]
[![GitHub Actions][gha-badge]][gha] [![Foundry][foundry-badge]][foundry] [![License: MIT][license-badge]][license]

[gha]: https://github.com/astraly-labs/pragma-monorepo/actions
[gha-badge]: https://github.com/PaulRBerg/prb-math/actions/workflows/ci.yml/badge.svg
[codecov-badge]: https://img.shields.io/codecov/c/github/astraly-labs/pragma-monorepo
[foundry]: https://getfoundry.sh/
[foundry-badge]: https://img.shields.io/badge/Built%20with-Foundry-FFDB1C.svg
[license]: https://www.apache.org/licenses/LICENSE-2.0
[license-badge]: https://img.shields.io/badge/License-Apache-blue.svg
[license]: https://opensource.org/license/mit
[license-badge]: https://img.shields.io/badge/License-MIT-blue.svg

## Rust

<a href="./rust/pragma-cli/">Pragma CLI</a>

CLI used to interact with the Pragma protocol.

- Register yourself as a data provider
- Schedule new data feeds
- Connect pragma to your protocol

<a href="./rust/theoros/">Theoros</a>

Request the API to construct the calldata necessary for cross-chain updates.
Expand All @@ -28,6 +20,16 @@ Request the API to construct the calldata necessary for cross-chain updates.
- Retrieves the signatures of the Hyperlane Validators
- Constructs the calldata for data feeds requested through HTTP/WebSocket

## Cairo

<a href="./cairo/oracle">Pragma Oracle</a>

Core Contacts of the Pragma Oracle.

<a href="./cairo/dispatcher">Pragma Dispatcher</a>

Wrapper around the Pragma Oracle that allows us to dispatch feed updates through Hyperlane.

## Solidity

<a href="./solidity/">Solidity SDK</a>
Expand All @@ -37,22 +39,18 @@ Solidity contracts & libraries.
- Set of contracts used to store data relayed from Pragma chain using Hyperlane.
- SDK that can be used by EVM protocols looking to integrate Pragma.

## Local Development
## Typescript

### Foundry
<a href="./typescript/theoros-sdk/">Theoros SDK</a>

First ensure you have Foundry installed on your machine.
A SDK used to query data from Theoros in a simple way.

Run the following to install `foundryup`:
- Fetch the latest calldata using either REST or Websocket endpoints.

```bash
curl -L https://foundry.paradigm.xyz | bash
```
<a href="./typescript/pragma-deployer/">Pragma Deployer</a>

Then run `foundryup` to install `forge`, `cast`, `anvil` and `chisel`.
The main scripts used to deploy all our contracts (Cairo, Solidity, ...) are located there.

```bash
foundryup
```
<a href="./typescript/pragma-scripts/">Pragma Scripts</a>

Check out the [Foundry Book](https://book.getfoundry.sh/getting-started/installation) for more information.
Utils scripts that we use to make some actions on-chain.
4 changes: 2 additions & 2 deletions deployments/holesky/pragma.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"Hyperlane": "0x8bA20dB35218bEF1c33Ae6bd129a07f157c71B2D",
"Pragma": "0x50fEbf423F5Fc61C2512bb5F9c6B1878d37C50DF"
"Hyperlane": "0x330ec0B08B74a4F34Fd76B0917A55169885624Be",
"Pragma": "0xcD025F607AdB9542B77C69A29B7b9Aa32Bf06811"
}
4 changes: 4 additions & 0 deletions deployments/sepolia/pragma.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"Hyperlane": "0x858FA2FacF63A3e529cAb4F5a02ceaFb590db2c1",
"Pragma": "0x78EA64467F0C4DB1b08b6A2E880f92135Deb4126"
}
43 changes: 43 additions & 0 deletions infra/theoros/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

FROM public.ecr.aws/docker/library/rust:1.81.0-slim-bookworm AS build

ARG PACKAGE_NAME=theoros

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential pkg-config libssl-dev protobuf-compiler curl libprotobuf-dev && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install -y bash curl && curl -1sLf \
'https://dl.cloudsmith.io/public/infisical/infisical-cli/setup.deb.sh' | bash \
&& apt-get update && apt-get install -y infisical

WORKDIR /app

COPY ./rust .

RUN cargo build --release --package ${PACKAGE_NAME}

FROM public.ecr.aws/docker/library/debian:bookworm-slim

RUN apt-get update && apt-get install -y --no-install-recommends \
libssl-dev wget ca-certificates && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN groupadd pragma

RUN useradd -g pragma pragma

USER pragma

WORKDIR /home/pragma
EXPOSE 3000
EXPOSE 8080
COPY --from=build /usr/bin/infisical /usr/bin/infisical
COPY infra/theoros/entrypoint.sh /home/pragma/entrypoint.sh
# Copy artifacts from base image
COPY --from=build /app/target/release/theoros /usr/local/bin/

ENTRYPOINT ["/bin/bash","/home/pragma/entrypoint.sh"]
29 changes: 29 additions & 0 deletions infra/theoros/buildspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws --version
- aws ecr get-login-password --region $ECR_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com
- REPOSITORY_URI=$AWS_ACCOUNT_ID.dkr.ecr.$ECR_REGION.amazonaws.com/$ECR_REPOSITORY_NAME
- COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
- IMAGE_TAG=${COMMIT_HASH:=latest}
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- ls -ltr
- docker build -f infra/theoros/Dockerfile -t $REPOSITORY_URI:latest .
- docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
post_build:
commands:
- echo Pushing the Docker images...
- docker push $REPOSITORY_URI:latest
- docker push $REPOSITORY_URI:$IMAGE_TAG
- echo Writing image definitions file...
- printf '[{"name":"%s","imageUri":"%s"}]' $ECS_CONTAINER_NAME $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
artifacts:
files:
- imagedefinitions.json
- infra/theoros/config.yml
discard-paths: yes
9 changes: 9 additions & 0 deletions infra/theoros/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
path: "/"
container_port: 3000,8080
health_check_path: "/health"
container_environment:
- region: "eu-west-3"
- prefix: "/conf/{{ SERVICE_NAME }}/{{ RUN_ENV }}"
- keys:
- INFISICAL_ENV
- INFISICAL_APP_PATH
7 changes: 7 additions & 0 deletions infra/theoros/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -euo pipefail
export INFISICAL_TOKEN=$(infisical login --method=universal-auth --client-id=${INFISICAL_CLIENT_ID} --client-secret=${INFISICAL_CLIENT_SECRET} --silent --plain)
infisical export --projectId=${INFISICAL_PROJECT_ID} --env=${INFISICAL_ENV} --path=${INFISICAL_APP_PATH} > .env
source .env
wget ${EVM_URL} -O evm_config.yaml
exec theoros ${ARGS}
4 changes: 0 additions & 4 deletions monorepo.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
"name": "theoros",
"path": "rust/theoros",
},
{
"name": "pragma-cli",
"path": "rust/pragma-cli",
},
{
"name": "pragma-utils",
"path": "rust/pragma-utils",
Expand Down
Loading

0 comments on commit a6ba97c

Please sign in to comment.