Skip to content

Commit

Permalink
Merge pull request #127 from smartcontractkit/develop
Browse files Browse the repository at this point in the history
Release v0.1.0 (contracts version) take #2
  • Loading branch information
krebernisak authored Feb 16, 2022
2 parents 0891552 + ac47d98 commit 97f5b57
Show file tree
Hide file tree
Showing 44 changed files with 24,310 additions and 664 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/chaos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ jobs:
key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Build Artifacts
run: |
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.12.4
make contracts_compile
- uses: actions/upload-artifact@master
with:
name: artifacts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Set up (force) Go 1.17
uses: actions/setup-go@v1
with:
go-version: 1.17.2
go-version: 1.17.x
id: go

# Initializes the CodeQL tools for scanning.
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/contracts-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ jobs:
- uses: actions/checkout@v2
- name: Build Artifacts
run: |
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.12.3
# - name: Build Schemas
# run: for d in contracts/*/; do cd "$d"; cargo schema; cd ../..; done
make contracts_compile
- name: Create Release
uses: softprops/action-gh-release@v1
with:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ jobs:
key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Build Artifacts
run: |
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.12.4
make contracts_compile
- uses: actions/upload-artifact@master
with:
name: artifacts
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/e2e_custom_cl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ jobs:
key: ${{ runner.os }}-v2-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Build Artifacts
run: |
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/workspace-optimizer:0.12.4
make contracts_compile
- uses: actions/upload-artifact@master
with:
name: artifacts
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ bin

# test
packages-ts/gauntlet-terra-contracts/codeIds/test*
packages-ts/gauntlet-terra-contracts/networks/.env.test*
tests/e2e/logs
networks/.env.test*
31 changes: 28 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,34 @@ install:
build_js:
yarn install --frozen-lockfile

build_contracts:
build_contracts: contracts_compile contracts_install

contracts_compile: artifacts_clean
./scripts/build-contracts.sh
cp -r artifacts packages-ts/gauntlet-terra-contracts/artifacts/bin

contracts_install: artifacts_curl_deps artifacts_cp_gauntlet artifacts_cp_terrad

artifacts_curl_deps: artifacts_curl_cw20

artifacts_curl_cw20:
curl -Lo artifacts/cw20_base.wasm https://github.com/CosmWasm/cw-plus/releases/download/v0.8.0/cw20_base.wasm

artifacts_cp_gauntlet:
cp -r artifacts/. packages-ts/gauntlet-terra-contracts/artifacts/bin

artifacts_cp_terrad:
cp -r artifacts/. ops/terrad/artifacts

artifacts_clean: artifacts_clean_root artifacts_clean_gauntlet artifacts_clean_terrad

artifacts_clean_root:
rm -rf artifacts/*

artifacts_clean_gauntlet:
rm -rf packages-ts/gauntlet-terra-contracts/artifacts/bin/*

artifacts_clean_terrad:
rm -rf ops/terrad/artifacts/*

build: build_js build_contracts

Expand All @@ -27,4 +52,4 @@ test_ocr:
SELECTED_NETWORKS=localterra NETWORK_SETTINGS=$(shell pwd)/tests/e2e/networks.yaml ginkgo --focus=@ocr tests/e2e/smoke

test_gauntlet:
SELECTED_NETWORKS=localterra NETWORK_SETTINGS=$(shell pwd)/tests/e2e/networks.yaml ginkgo --focus=@gauntlet tests/e2e/smoke
SELECTED_NETWORKS=localterra NETWORK_SETTINGS=$(shell pwd)/tests/e2e/networks.yaml ginkgo --focus=@gauntlet tests/e2e/smoke
45 changes: 45 additions & 0 deletions cmd/monitoring/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Terra on-chain monitor

## Example of running the monitor locally

```bash
TERRA_TENDERMINT_URL="<some terra url>" \
TERRA_FCD_URL="https://fcd.terra.dev/" \
TERRA_NETWORK_NAME="terra-devnet" \
TERRA_NETWORK_ID="terra-devnet" \
TERRA_CHAIN_ID="1" \
TERRA_READ_TIMEOUT="15s" \
TERRA_POLL_INTERVAL="5s" \
TERRA_LINK_TOKEN_ADDRESS="terra1eq0xqc88ceuvw2ztz2a08200he8lrgvnplrcst" \
KAFKA_BROKERS="localhost:29092" \
KAFKA_CLIENT_ID=“terra” \
KAFKA_SECURITY_PROTOCOL="PLAINTEXT" \
KAFKA_SASL_MECHANISM="PLAIN" \
KAFKA_SASL_USERNAME="" \
KAFKA_SASL_PASSWORD="" \
KAFKA_TRANSMISSION_TOPIC="transmission_topic" \
KAFKA_CONFIG_SET_SIMPLIFIED_TOPIC="config_set_simplified" \
SCHEMA_REGISTRY_URL="http://localhost:8989" \
SCHEMA_REGISTRY_USERNAME="" \
SCHEMA_REGISTRY_PASSWORD="" \
HTTP_ADDRESS="localhost:3000" \
FEEDS_URL="http://localhost:4000/feeds.json" \
go run ./cmd/monitoring/main.go
```

## Example of feed configurations returned by weiwatchers.com

```json
[
{
"name": "UST/USD",
"path": "ust-usd",
"symbol": "$",
"heartbeat": 50,
"contract_type": "",
"status": "live",
"contract_address_bech32": "terra1dre5vgujqex83kc4kw3jr6fc6z8erdsqxlsvhk" ,
"multiply": "100000000"
}
]
```
76 changes: 53 additions & 23 deletions cmd/monitoring/main.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,67 @@
package main

import (
// "context"
"context"

// relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring"
// "github.com/smartcontractkit/chainlink-terra/pkg/monitoring"
relayMonitoring "github.com/smartcontractkit/chainlink-relay/pkg/monitoring"
"github.com/smartcontractkit/chainlink-terra/pkg/monitoring"
pkgClient "github.com/smartcontractkit/chainlink-terra/pkg/terra/client"
"github.com/smartcontractkit/chainlink/core/logger"
)

func main() {
// ctx := context.Background()
ctx := context.Background()

log := logger.NewLogger().With("project", "terra")

// terraConfig, err := monitoring.ParseTerraConfig()
// if err != nil {
// log.Fatalw("failed to parse terra specific configuration", "error", err)
// }

// terraSourceFactory, err := monitoring.NewTerraSourceFactory(terraConfig, log.With("component", "source"))
// if err != nil {
// log.Fatalw("failed to initialize Terra source", "error", err)
// }

// relayMonitoring.Entrypoint(
// ctx,
// log,
// terraConfig,
// terraSourceFactory,
// monitoring.TerraFeedParser,
// []relayMonitoring.SourceFactory{},
// []relayMonitoring.ExporterFactory{},
// )
terraConfig, err := monitoring.ParseTerraConfig()
if err != nil {
log.Fatalw("failed to parse terra specific configuration", "error", err)
return
}

client, err := pkgClient.NewClient(
terraConfig.ChainID,
terraConfig.TendermintURL,
terraConfig.ReadTimeout,
log,
)
if err != nil {
log.Fatalw("failed to create a terra client", "error", err)
return
}

envelopeSourceFactory := monitoring.NewEnvelopeSourceFactory(
client,
log.With("component", "source-envelope"),
)
txResultsFactory := monitoring.NewTxResultsSourceFactory(
log.With("component", "source-txresults"),
)

entrypoint, err := relayMonitoring.NewEntrypoint(
ctx,
logWrapper{log},
terraConfig,
envelopeSourceFactory,
txResultsFactory,
monitoring.TerraFeedParser,
)
if err != nil {
log.Fatalw("failed to build entrypoint", "error", err)
return
}

entrypoint.Run()
log.Info("monitor stopped")
}

// adapt core/logger.Logger to monitoring logger.

type logWrapper struct {
logger.Logger
}

func (l logWrapper) With(values ...interface{}) relayMonitoring.Logger {
return logWrapper{l.Logger.With(values...)}
}
6 changes: 3 additions & 3 deletions contracts/ocr2/schema/billing.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "object",
"required": [
"observation_payment_gjuels",
"recommended_gas_price_uluna",
"recommended_gas_price_micro",
"transmission_payment_gjuels"
],
"properties": {
Expand Down Expand Up @@ -38,8 +38,8 @@
"format": "uint64",
"minimum": 0.0
},
"recommended_gas_price_uluna": {
"description": "Should match https://fcd.terra.dev/v1/txs/gas_prices",
"recommended_gas_price_micro": {
"description": "Should match <https://fcd.terra.dev/v1/txs/gas_prices>. For example if reports contain juels_per_luna, then recommended_gas_price is in uLUNA.",
"allOf": [
{
"$ref": "#/definitions/Decimal"
Expand Down
6 changes: 3 additions & 3 deletions contracts/ocr2/schema/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"type": "object",
"required": [
"observation_payment_gjuels",
"recommended_gas_price_uluna",
"recommended_gas_price_micro",
"transmission_payment_gjuels"
],
"properties": {
Expand Down Expand Up @@ -151,8 +151,8 @@
"format": "uint64",
"minimum": 0.0
},
"recommended_gas_price_uluna": {
"description": "Should match https://fcd.terra.dev/v1/txs/gas_prices",
"recommended_gas_price_micro": {
"description": "Should match <https://fcd.terra.dev/v1/txs/gas_prices>. For example if reports contain juels_per_luna, then recommended_gas_price is in uLUNA.",
"allOf": [
{
"$ref": "#/definitions/Decimal"
Expand Down
6 changes: 3 additions & 3 deletions contracts/ocr2/schema/execute_msg.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
"type": "object",
"required": [
"observation_payment_gjuels",
"recommended_gas_price_uluna",
"recommended_gas_price_micro",
"transmission_payment_gjuels"
],
"properties": {
Expand Down Expand Up @@ -459,8 +459,8 @@
"format": "uint64",
"minimum": 0.0
},
"recommended_gas_price_uluna": {
"description": "Should match https://fcd.terra.dev/v1/txs/gas_prices",
"recommended_gas_price_micro": {
"description": "Should match <https://fcd.terra.dev/v1/txs/gas_prices>. For example if reports contain juels_per_luna, then recommended_gas_price is in uLUNA.",
"allOf": [
{
"$ref": "#/definitions/Decimal"
Expand Down
Loading

0 comments on commit 97f5b57

Please sign in to comment.