Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
balasan committed Mar 27, 2021
1 parent f77ad6e commit c6d83fa
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 263 deletions.
23 changes: 4 additions & 19 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,17 @@ module.exports = {
auto: false,
nav: [
{
title: 'Using the Oracle Module',
title: 'Documentation',
children: [
{
title: 'Tutorial',
title: 'Atom/USD Tutorial',
directory: true,
path: '/tutorial',
},
],
},
{
title: 'Oracle Module Docs',
children: [
{
title: 'Modules',
directory: true,
path: '/modules',
},
],
},
{
title: 'Test with Starport',
children: [
{
title: 'Demo app guide',
title: 'Oracle Module Docs',
directory: true,
path: '/starport',
path: '/modules/oracle',
},
],
},
Expand Down
20 changes: 12 additions & 8 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ aside: true

The Oracle module allows validators to run arbitrary off-chain worker processes and report the results for inclusion in the on-chain state.

For example, you can fetch data from external exchange apis and use it inside on-chain smart contracts.
Unlike onchain smart contracts, offchain workers are able to run non-deterministic code, like fetching exchange price data via an api call, and long-running computations, i.e. AI alogrithms or graph analysis. All of the validators are expected to run the workers and come to a consensus on the results. Exactly how consensus is reached can be decided by the app developer.

## Getting Started
The module is inspired by the [Terra Oracle Module](https://docs.terra.money/dev/spec-oracle.html#concepts) as well as a more recent iteration of it by [Sommelier](https://github.com/PeggyJV/sommelier/tree/main/x/oracle).

- **[The Tutoral](./tutorial/)** is a good place to get started.
## Getting Started

## Module Documentation
- **[The Tutoral](./tutorial)** goes through the steps required to incorporate the Oracle module into your codebase. As an example, we fetch the Atom/USDC price data from Binance and write it on-chain.

- **[Module Documentation](./modules/oracle)**: Describes the high-level architecture and module apis.

## Learn More About Oracles

- This [Terra Blog Post](https://medium.com/stakewithus/terra-oracle-voter-by-stakewith-us-d54a1321beb9) has a nice general overview of core concepts.
- [Terra Oracle Module Docs](https://docs.terra.money/dev/spec-oracle.html#concepts) are also very insightful
- A useful [talk about oracles by Chainlink's Sergey Nazarov](https://youtu.be/UAP6--JTAlU)
- [Sommelier Oracle Module](https://github.com/PeggyJV/sommelier/tree/b2f81e9007db479ac5c88bf4d6edbc17a27120fc/x/oracle)

## Other Resources

- **[Module Directory](../x/)**: Module implementations and their respective documentation.
- **[Specifications](./spec/)**: Specifications of modules and other parts of the Cosmos SDK.
- **[SDK API Reference](https://godoc.org/github.com/cosmos/cosmos-sdk)**: Godocs of the Cosmos SDK.
- **[REST API spec](https://cosmos.network/rpc/)**: List of endpoints to interact with a `gaia` full-node through REST.
- **[Cosmos SDK API Reference](https://godoc.org/github.com/cosmos/cosmos-sdk)**: Godocs of the Cosmos SDK.
219 changes: 0 additions & 219 deletions docs/starport/README.md

This file was deleted.

2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ After some time, check the on-chain Atom-USD price:
$ oracled query atom atomUsd
```

You should see the latest Atom/USD price and the blockHeight at which it was captured.

---

## Starport Docs:
Expand Down
8 changes: 0 additions & 8 deletions x/README.md

This file was deleted.

3 changes: 1 addition & 2 deletions x/atom/keeper/atom.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ func (k Keeper) SetAtomUsd(ctx sdk.Context, atomUsd types.AtomUsd) {
func (k Keeper) GetAtomUsd(ctx sdk.Context) *types.AtomUsd {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.AtomUsdKey)

var atomUsd types.AtomUsd
if len(bz) == 0 {
return nil
}

var atomUsd types.AtomUsd
k.cdc.MustUnmarshalBinaryBare(bz, &atomUsd)
return &atomUsd
}
Expand Down
3 changes: 3 additions & 0 deletions x/atom/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ func (k Keeper) AtomUsd(c context.Context, req *types.QueryAtomUsdRequest) (*typ

ctx := sdk.UnwrapSDKContext(c)
atomUsd := k.GetAtomUsd(ctx)
if atomUsd == nil {
return nil, status.Errorf(codes.NotFound, "No results")
}

return &types.QueryAtomUsdResponse{AtomUsd: atomUsd}, nil
}
10 changes: 3 additions & 7 deletions x/oracle/spec/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ parent:

This document specifies the Oracle module for the Cosmos SDK.

The Oracle module allows validators to run arbitrary off-chain worker processes and report the results for inclusion in the on-chain state.
The Oracle module accepts and stores arbitrary `Claims` submitted by the chain validators. Multiple oracly types can run simultaniously.

Unlike onchain smart contracts, offchain workers are able to run non-deterministic code, like fetching exchange price data via an api call, and long-running computations, i.e. AI alogrithms or graph analysis. All of the validators are expected to run the workers and come to a consensus on the results. Exactly how consensus is reached can be decided by the app developer.
The module includes helper methods to design off-chain workers that supply data to the Oracle module.

The module is inspired by the [Terra Oracle Module](https://docs.terra.money/dev/spec-oracle.html#concepts) as well as a more recent iteration of it by [Sommelier](https://github.com/PeggyJV/sommelier/tree/main/x/oracle).

### Hi-Level Overview

At its core, the Oracle module accepts and stores arbitrary `Claims`. When submitting a claim, a validator casts a vote for the particular claim. The oracle module tracks all Claims by `ClaimType` and voting `Round`. The module includes some helper methods to tally the votes for each round, however it is the responsibility of external modules to implement this logic as needed.
The Oracle modules assists with deciding how a consensus is reached on oracle results, however it is the responsibility of external modules to implement this logic as needed.

## Contents

Expand Down

0 comments on commit c6d83fa

Please sign in to comment.