Skip to content

Commit

Permalink
v0.2.0 (#29)
Browse files Browse the repository at this point in the history
* add changelog + security

* Deployment (#10)

* add changelog + security (#9)

* added dockerfile

* fix bug on build

* change the wkdir to /data

* change the wkdir to /

* fix typo

* back to /node

* push to dockerhub instead

* deployment done

---------

Co-authored-by: Kenny P <[email protected]>

* use internal network dns

* Deployment (#13)

* change the wkdir to /data

* change the wkdir to /

* fix typo

* back to /node

* deploy 2 reputer and workers for topic 1

* random

* API Adapter with README ORA-2066 (#12)

* API Adapter with README

* move API adapter readme inside dir

* Config file/env var + factory adapters + minor fixes

* updating readme to tell you to copy the env file and fill it out before running docker-compose (#14)

* readme changes (#15)

* chore: fix typos README.md (#17)

Hello, I found some typos in README.md

"intentend" to "intended"

"be use" to "be used"

And there were also missing space in "InferenceEndpointis required if InferenceEntrypoint is defined.". This canged for "InferenceEndpoint is required if InferenceEntrypoint is defined."

Hope this helps.

Signed-off-by: osrm <[email protected]>

* update dependencies, do not print conf (#18)

* Cleanups (#16)

* cleanups

* efficient deployment updates

* fix bug

---------

Co-authored-by: Kenny <[email protected]>

* fix issues with docker-compose initialize

* readme fix

* forecast should return nodeValue

* Update dependencies + reputer nonce fix (#19)

* fix deprecated docker compose command

* string interpolation

* uniform backoff (#21)

* uniform backoff

* README update

* Update and rename start.docker to init.docker (#22)

* Update and rename start.docker to init.docker

on devnet, when running the command:

```
chmod +x start.docker
./start.docker
```

 the worker node won't register because it is not funded. The wallet for the worker node is being created and the node is attempting to register to the network in one go. However, for the user this will never work. What they will have to do is
1. run the command
2. kill the terminal
3. fund their wallet
4. rerun the chmod command

The fix proposed is:

1. run init.docker to generate address and then you can get the address funded manually
2. run docker compose --build separately to start your services

Signed-off-by: kush-alloralabs <[email protected]>

* Update README.md

Signed-off-by: kush-alloralabs <[email protected]>

* Update README.md

Signed-off-by: kush-alloralabs <[email protected]>

---------

Signed-off-by: kush-alloralabs <[email protected]>

* fix the conflicting account issues

* add pull request template

* correct the wkdir for source github actions

* allow devs pass in their existing wallets and don't override

* fix startup edgecase

* Diego/fix merge conflicts (main-dev) (#25)

* add changelog + security (#9)

* release v0.1.0 (#23)

* add changelog + security

* Deployment (#10)

* add changelog + security (#9)

* added dockerfile

* fix bug on build

* change the wkdir to /data

* change the wkdir to /

* fix typo

* back to /node

* push to dockerhub instead

* deployment done

---------

Co-authored-by: Kenny P <[email protected]>

* use internal network dns

* Deployment (#13)

* change the wkdir to /data

* change the wkdir to /

* fix typo

* back to /node

* deploy 2 reputer and workers for topic 1

* random

* API Adapter with README ORA-2066 (#12)

* API Adapter with README

* move API adapter readme inside dir

* Config file/env var + factory adapters + minor fixes

* updating readme to tell you to copy the env file and fill it out before running docker-compose (#14)

* readme changes (#15)

* chore: fix typos README.md (#17)

Hello, I found some typos in README.md

"intentend" to "intended"

"be use" to "be used"

And there were also missing space in "InferenceEndpointis required if InferenceEntrypoint is defined.". This canged for "InferenceEndpoint is required if InferenceEntrypoint is defined."

Hope this helps.

Signed-off-by: osrm <[email protected]>

* update dependencies, do not print conf (#18)

* Cleanups (#16)

* cleanups

* efficient deployment updates

* fix bug

---------

Co-authored-by: Kenny <[email protected]>

* fix issues with docker-compose initialize

* readme fix

* forecast should return nodeValue

* Update dependencies + reputer nonce fix (#19)

* fix deprecated docker compose command

* string interpolation

* uniform backoff (#21)

* uniform backoff

* README update

* Update and rename start.docker to init.docker (#22)

* Update and rename start.docker to init.docker

on devnet, when running the command:

```
chmod +x start.docker
./start.docker
```

 the worker node won't register because it is not funded. The wallet for the worker node is being created and the node is attempting to register to the network in one go. However, for the user this will never work. What they will have to do is
1. run the command
2. kill the terminal
3. fund their wallet
4. rerun the chmod command

The fix proposed is:

1. run init.docker to generate address and then you can get the address funded manually
2. run docker compose --build separately to start your services

Signed-off-by: kush-alloralabs <[email protected]>

* Update README.md

Signed-off-by: kush-alloralabs <[email protected]>

* Update README.md

Signed-off-by: kush-alloralabs <[email protected]>

---------

Signed-off-by: kush-alloralabs <[email protected]>

* fix the conflicting account issues

* add pull request template

* correct the wkdir for source github actions

---------

Signed-off-by: osrm <[email protected]>
Signed-off-by: kush-alloralabs <[email protected]>
Co-authored-by: Kenny <[email protected]>
Co-authored-by: Kenny P <[email protected]>
Co-authored-by: Diego C <[email protected]>
Co-authored-by: Madison Williams <[email protected]>
Co-authored-by: osrm <[email protected]>
Co-authored-by: kush-alloralabs <[email protected]>

* remove usage of init.docker

* fix readme conflicts

* fix readme conflicts

* use offchain-node as name

---------

Signed-off-by: osrm <[email protected]>
Signed-off-by: kush-alloralabs <[email protected]>
Co-authored-by: Kenny P <[email protected]>
Co-authored-by: Tobi Okedeji <[email protected]>
Co-authored-by: Kenny <[email protected]>
Co-authored-by: Madison Williams <[email protected]>
Co-authored-by: osrm <[email protected]>
Co-authored-by: kush-alloralabs <[email protected]>

* Update config.example.json (#27)

https://upshotworld.slack.com/archives/C06TUMEP3LM/p1723139422909399

By default we should have the worker and reputer run on the same port so that both work in the simplest path.

Signed-off-by: kush-alloralabs <[email protected]>

* Metrics (#28)

* added metrics to offchain node

* expose metrics port on 2112

* update readme

* typo

---------

Co-authored-by: Kenny <[email protected]>

* update changelog + pr template

---------

Signed-off-by: osrm <[email protected]>
Signed-off-by: kush-alloralabs <[email protected]>
Co-authored-by: Tobi Okedeji <[email protected]>
Co-authored-by: Diego C <[email protected]>
Co-authored-by: Madison Williams <[email protected]>
Co-authored-by: osrm <[email protected]>
Co-authored-by: kush-alloralabs <[email protected]>
  • Loading branch information
6 people authored Aug 10, 2024
1 parent 551f6a0 commit 8ca515e
Show file tree
Hide file tree
Showing 13 changed files with 184 additions and 88 deletions.
47 changes: 10 additions & 37 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,18 @@
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v ✰ Thanks for creating a PR! ✰
v Before smashing the submit button please review the checkboxes.
v If a checkbox is n/a - please still include it but + a little note why
v If your PR doesn't close an issue, that's OK! Just remove the Closes: #XXX line!
v ✰ Thanks for creating a PR! You're awesome! ✰
v Please note that maintainers will only review those PRs with a completed PR template.
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -->

Closes: #XXX
## Purpose of Changes and their Description

## What is the purpose of the change
## Link(s) to Ticket(s) or Issue(s) resolved by this PR

> Add a description of the overall background and high level changes that this PR introduces
## Are these changes tested and documented?

*(E.g.: This pull request improves documentation of area A by adding ....)*
- [ ] If tested, please describe how. If not, why tests are not needed.
- [ ] If documented, please describe where. If not, describe why docs are not needed.
- [ ] Added to `Unreleased` section of `CHANGELOG.md`?

## Testing and Verifying
## Still Left Todo

*(Please pick one of the following options)*

This change is a trivial rework / code cleanup without any test coverage.

*(or)*

This change is already covered by existing tests, such as *(please describe tests)*.

*(or)*

This change added tests and can be verified as follows:

*(example:)*
- *Added unit test that validates ...*
- *Added integration tests for end-to-end deployment with ...*
- *Extended integration test for ...*
- *Manually verified the change by ...*

## Documentation and Release Note

- [ ] Does this pull request introduce a new feature or user-facing behavior changes?


Where is the change documented?
- [ ] Specification (`x/{module}/README.md`)
- [ ] Allora documentation site `docs.allora.network` source code at: `https://github.com/allora-network/docs`
- [ ] Code comments?
- [ ] N/A
*Fill this out if this is a Draft PR so others can help.*
74 changes: 44 additions & 30 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,62 @@
<!--
Guiding Principles:
Changelogs are for humans, not machines.
There should be an entry for every single version.
The same types of changes should be grouped.
Versions and sections should be linkable.
The latest version comes first.
The release date of each version is displayed.
Mention whether you follow Semantic Versioning.
Mention whether you follow Semantic Versioning (we do at and after v1.0.0).
Usage:
Change log entries are to be added to the Unreleased section under the
appropriate stanza (see below). Each entry should ideally include a tag and
the Github issue reference in the following format:
* (<tag>) \#<issue-number> message
The issue numbers will later be link-ified during the release process so you do
not have to worry about including a link manually, but you can if you wish.
Change log entries are to be added to the Unreleased section
under the appropriate stanza (see below).
Each entry should ideally include the Github issue or PR reference.
The issue numbers will later be link-ified during the
release process so you do not have to worry about including
a link manually, but you can if you wish.
Types of changes (Stanzas):
"Features" for new features.
"Improvements" for changes in existing functionality.
"Deprecated" for soon-to-be removed features.
"Bug Fixes" for any bug fixes.
"Client Breaking" for breaking Protobuf, gRPC and REST routes used by end-users.
"CLI Breaking" for breaking CLI commands.
"API Breaking" for breaking exported APIs used by developers building on SDK.
"State Machine Breaking" for any changes that result in a different AppState given same genesisState and txList.
* __Added__ for new features.
* __Changed__ for changes in existing functionality that did not aim to resolve bugs.
* __Deprecated__ for soon-to-be removed features.
* __Removed__ for now removed features.
* __Fixed__ for any bug fixes that did not threaten user funds or chain continuity.
* __Security__ for any bug fixes that did threaten user funds or chain continuity.
Breaking changes affecting client, API, and state should be mentioned in the release notes.
Ref: https://keepachangelog.com/en/1.0.0/
Ref: https://github.com/osmosis-labs/osmosis/blob/main/CHANGELOG.md
-->

# Changelog

<!-- EXAMPLES:
## v5.7.1 & v5.7.2
sei-chain
* [#1779](https://github.com/sei-protocol/sei-chain/pull/1779) Fix subscribe logs empty params crash
* [#1783](https://github.com/sei-protocol/sei-chain/pull/1783) Add meaningful message for eth_call balance override overflow
* [#1783](https://github.com/sei-protocol/sei-chain/pull/1784) Fix log index on synthetic receipt
* [#1775](https://github.com/sei-protocol/sei-chain/pull/1775) Disallow sending to direct cast addr after association
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) for all versions `v1.0.0` and beyond (still considered experimental prior to v1.0.0).

## [Unreleased]

## v0.2.0

### Added

* Metrics center for monitoring and alerting via Prometheus
* Edgecase fixes
* UX improvements e.g. JSON support (no Golang interactions needed)

### Removed

### Fixed

sei-wasmd
* [60](https://github.com/sei-protocol/sei-wasmd/pull/60) Query penalty fixes
### Security

sei-tendermint
* [#237](https://github.com/sei-protocol/sei-tendermint/pull/237) Add metrics for total txs bytes in mempool
## v0.1.0

## v5.7.0
sei-chain
* [#1731](https://github.com/sei-protocol/sei-chain/pull/1731) Remove 1-hop limit
* [#1663](https://github.com/sei-protocol/sei-chain/pull/1663) Retain pointer address on upgrade -->
Genesis release.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ chmod +x start.local
./start.local
```

## Prometheus Metrics
Some metrics has been provided for in the node. You can access them with port `:2112/metrics`. Here are the following list of existing metrics:
- `allora_worker_inference_request_count`: The total number of times worker requests inference from source
- `allora_worker_forecast_request_count`: The total number of times worker requests forecast from source
- `allora_reputer_truth_request_count`: The total number of times reputer requests truth from source
- `allora_worker_data_build_count`: The total number of times worker built data successfully
- `allora_reputer_data_build_count`: The total number of times worker built data successfully
- `allora_worker_chain_submission_count`: The total number of worker commits to the chain
- `allora_reputer_chain_submission_count`: The total number of reputer commits to the chain

> Please note that we will keep updating the list as more metrics are being added
## How to configure

Expand Down
2 changes: 1 addition & 1 deletion config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"loopSeconds": 30,
"minStake": 100000,
"parameters": {
"SourceOfTruthEndpoint": "http://source:8888/truth/{Token}/{BlockHeight}",
"SourceOfTruthEndpoint": "http://source:8000/truth/{Token}/{BlockHeight}",
"Token": "ethereum"
}
}
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ services:
node:
container_name: offchain_node
build: .
ports:
- "2112:2112"
volumes:
- ./data:/data
depends_on:
Expand Down
23 changes: 23 additions & 0 deletions lib/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,26 @@ package lib
const SECONDS_PER_BLOCK = 5 // each block is this many seconds
const ADDRESS_PREFIX = "allo" // each address prefixed by this
const DEFAULT_BOND_DENOM = "uallo"
const ALLORA_OFFCHAIN_NODE_CONFIG_JSON = "ALLORA_OFFCHAIN_NODE_CONFIG_JSON"
const ALLORA_OFFCHAIN_NODE_CONFIG_FILE_PATH = "ALLORA_OFFCHAIN_NODE_CONFIG_FILE_PATH"

const (
InferenceRequestCount string = "allora_worker_inference_request_count"
ForecastRequestCount string = "allora_worker_forecast_request_count"
TruthRequestCount string = "allora_reputer_truth_request_count"
WorkerDataBuildCount string = "allora_worker_data_build_count"
ReputerDataBuildCount string = "allora_reputer_data_build_count"
WorkerChainSubmissionCount string = "allora_worker_chain_submission_count"
ReputerChainSubmissionCount string = "allora_reputer_chain_submission_count"
)

// A struct that holds the name and help text for a prometheus counter
var COUNTER_DATA = []MetricsCounter{
{InferenceRequestCount, "The total number of times worker requests inference from source"},
{ForecastRequestCount, "The total number of times worker requests forecast from source"},
{TruthRequestCount, "The total number of times reputer requests truth from source"},
{WorkerDataBuildCount, "The total number of times worker built data successfully"},
{ReputerDataBuildCount, "The total number of times worker built data successfully"},
{WorkerChainSubmissionCount, "The total number of worker commits to the chain"},
{ReputerChainSubmissionCount, "The total number of reputer commits to the chain"},
}
20 changes: 10 additions & 10 deletions lib/domain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import (

// Properties manually provided by the user as part of UserConfig
type WalletConfig struct {
Address string // will be overwritten by the keystore. This is the 1 value that is auto-generated in this struct
AddressKeyName string // load a address by key from the keystore
AddressRestoreMnemonic string
AlloraHomeDir string // home directory for the allora keystore
Gas string // gas to use for the allora client
GasAdjustment float64 // gas adjustment to use for the allora client
NodeRpc string // rpc node for allora chain
MaxRetries int64 // retry to get data from chain up to this many times per query or tx
Delay int64 // minimum of uniform distribution that is sampled then used to calcluate exponential backoff for txs (in seconds)
SubmitTx bool // useful for dev/testing. set to false to run in dry-run processes without committing to the chain
Address string // will be overwritten by the keystore. This is the 1 value that is auto-generated in this struct
AddressKeyName string // load a address by key from the keystore
AddressRestoreMnemonic string
AlloraHomeDir string // home directory for the allora keystore
Gas string // gas to use for the allora client
GasAdjustment float64 // gas adjustment to use for the allora client
NodeRpc string // rpc node for allora chain
MaxRetries int64 // retry to get data from chain up to this many times per query or tx
Delay int64 // minimum of uniform distribution that is sampled then used to calcluate exponential backoff for txs (in seconds)
SubmitTx bool // useful for dev/testing. set to false to run in dry-run processes without committing to the chain
}

// Properties auto-generated based on what the user has provided in WalletConfig fields of UserConfig
Expand Down
63 changes: 63 additions & 0 deletions lib/metrics_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package lib

import (
"net/http"
"strconv"

"github.com/rs/zerolog/log"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

type MetricsCounter struct {
Name string
Help string
}

type Metrics struct {
Counters []MetricsCounter
CounterMap map[string]*prometheus.CounterVec
}

func NewMetrics(counters []MetricsCounter) *Metrics {
return &Metrics{
Counters: counters,
CounterMap: make(map[string]*prometheus.CounterVec),
}
}

func (metrics *Metrics) RegisterMetricsCounters() {

for _, counter := range metrics.Counters {
counterVec := prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: counter.Name,
Help: counter.Help,
},
[]string{"address", "topic"},
)

prometheus.MustRegister(counterVec)
metrics.CounterMap[counter.Name] = counterVec
}
}

func (metrics Metrics) StartMetricsServer(port string) {
http.Handle("/metrics", promhttp.Handler())
go func() {
log.Info().Msgf("Starting metrics server on %s", port)
if err := http.ListenAndServe(port, nil); err != nil {
log.Error().Err(err).Msg("Could not start metric server")
return
}

log.Info().Msg("Metrics server stopped")
}()
}

func (metrics *Metrics) IncrementMetricsCounter(counterName string, address string, topic uint64) {
counter := metrics.CounterMap[counterName].WithLabelValues(address, strconv.FormatUint(topic, 10))
counter.Inc()
log.Info().Msgf("Incremented counter %s for address %s and topic %d", counterName, address, topic)
}
19 changes: 11 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@ import (
"fmt"
"os"

"github.com/joho/godotenv"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/joho/godotenv"
)

const ALLORA_OFFCHAIN_NODE_CONFIG_JSON = "ALLORA_OFFCHAIN_NODE_CONFIG_JSON"
const ALLORA_OFFCHAIN_NODE_CONFIG_FILE_PATH = "ALLORA_OFFCHAIN_NODE_CONFIG_FILE_PATH"

func ConvertEntrypointsToInstances(userConfig lib.UserConfig) error {
/// Initialize adapters using the factory function
for i, worker := range userConfig.Worker {
Expand Down Expand Up @@ -52,15 +49,19 @@ func ConvertEntrypointsToInstances(userConfig lib.UserConfig) error {

func main() {
if dotErr := godotenv.Load(); dotErr != nil {
log.Error().Err(dotErr).Msg("Error loading .env file")
log.Info().Msg("Unable to load .env file")
}

// UNIX Time is faster and smaller than most timestamps
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
log.Info().Msg("Starting allora offchain node...")

metrics := lib.NewMetrics(lib.COUNTER_DATA)
metrics.RegisterMetricsCounters()
metrics.StartMetricsServer(":2112")

finalUserConfig := lib.UserConfig{}
alloraJsonConfig := os.Getenv(ALLORA_OFFCHAIN_NODE_CONFIG_JSON)
alloraJsonConfig := os.Getenv(lib.ALLORA_OFFCHAIN_NODE_CONFIG_JSON)
if alloraJsonConfig != "" {
log.Info().Msg("Config using JSON env var")
// completely reset UserConfig
Expand All @@ -69,10 +70,10 @@ func main() {
log.Fatal().Err(err).Msg("Failed to parse JSON config file from Config")
return
}
} else if os.Getenv(ALLORA_OFFCHAIN_NODE_CONFIG_FILE_PATH) != "" {
} else if os.Getenv(lib.ALLORA_OFFCHAIN_NODE_CONFIG_FILE_PATH) != "" {
log.Info().Msg("Config using JSON config file")
// parse file defined in CONFIG_FILE_PATH into UserConfig
file, err := os.Open(os.Getenv(ALLORA_OFFCHAIN_NODE_CONFIG_FILE_PATH))
file, err := os.Open(os.Getenv(lib.ALLORA_OFFCHAIN_NODE_CONFIG_FILE_PATH))
if err != nil {
log.Fatal().Err(err).Msg("Failed to open JSON config file")
return
Expand Down Expand Up @@ -101,5 +102,7 @@ func main() {
log.Fatal().Err(err).Msg("Failed to initialize use case, exiting")
return
}

spawner.Metrics = *metrics
spawner.Spawn()
}
3 changes: 3 additions & 0 deletions usecase/build_commit_reputer_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ func (suite *UseCaseSuite) BuildCommitReputerPayload(reputer lib.ReputerConfig,
log.Error().Err(err).Uint64("topicId", reputer.TopicId).Msg("Failed to get source truth from reputer")
return false, err
}
suite.Metrics.IncrementMetricsCounter(lib.TruthRequestCount, suite.Node.Chain.Address, reputer.TopicId)

lossBundle, err := suite.ComputeLossBundle(sourceTruth, valueBundle, reputer)
if err != nil {
log.Error().Err(err).Uint64("topicId", reputer.TopicId).Msg("Failed to compute loss bundle")
return false, err
}
suite.Metrics.IncrementMetricsCounter(lib.ReputerDataBuildCount, suite.Node.Chain.Address, reputer.TopicId)

signedValueBundle, err := suite.SignReputerValueBundle(&lossBundle)
if err != nil {
Expand All @@ -62,6 +64,7 @@ func (suite *UseCaseSuite) BuildCommitReputerPayload(reputer lib.ReputerConfig,
log.Error().Err(err).Uint64("topicId", reputer.TopicId).Msgf("Error sending Reputer Data to chain: %s", err)
return false, err
}
suite.Metrics.IncrementMetricsCounter(lib.ReputerChainSubmissionCount, suite.Node.Chain.Address, reputer.TopicId)
} else {
log.Info().Uint64("topicId", reputer.TopicId).Msg("SubmitTx=false; Skipping sending Reputer Data to chain")
}
Expand Down
Loading

0 comments on commit 8ca515e

Please sign in to comment.