Skip to content

Commit

Permalink
Merge pull request #37 from allora-network/kush/community-edits
Browse files Browse the repository at this point in the history
Kush/community edits
  • Loading branch information
ericjaurena authored Jul 18, 2024
2 parents eaf1b11 + 01804a2 commit 4bddd62
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 75 deletions.
2 changes: 1 addition & 1 deletion pages/community/contribute.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Developers

[Our open-source repos](https://github.com/allora-network) all follow the [same contribution guidelines](https://github.com/allora-network/allora-chain/blob/main/CONTRIBUTING.md), including these docs themselves. CHECKOUT
[Our open-source repos](https://github.com/allora-network) all follow the [same contribution guidelines](https://github.com/allora-network/allora-chain/blob/main/CONTRIBUTING.md), including these docs themselves.

Our [Discord](https://discord.gg/allora) is great for speaking directly with the core Allora developers, coordinating with fellow [Developer Advocates](https://www.allora.network/blog/introducing-the-allora-network-community-advocate-program), and keeping up to date with the latest regarding all things Allora.

Expand Down
3 changes: 3 additions & 0 deletions pages/community/resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@
- **Troubleshooting a worker node**
- https://medium.com/@casual1st/allora-worker-node-tshoot-655f46d9165d

- **Worker node migration (Testnet v2)**
- https://medium.com/@nodescribe/allora-worker-node-step-by-step-guide-ccb29d90e01f
- https://github.com/casual1st/alloraworkersetup/blob/main/testnetmigrator.sh
3 changes: 2 additions & 1 deletion pages/devs/consumers/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"offchain-query-existing-topics": "How to Query Existing Workers Off-Chain",
"onchain-query-existing-data": "How to Query Topic Data On-Chain",
"consumer-contracts": "Consumer Contracts",
"existing-consumers": "Existing Consumers"
"existing-consumers": "Existing Consumers",
"walkthrough-use-topic-inference": "Walkthrough: Using a Topic Inference on-chain"
}
2 changes: 1 addition & 1 deletion pages/devs/consumers/offchain-query-existing-topics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Querying through this API is considered a safe request because it queries a sign
</Callout> */}

Let's break down this request body:
- https://api.upshot.xyz/v2/allora/adapter/: The generic API request URL
- https://api.upshot.xyz/v2/allora/consumer/: The generic API request URL
- `arbitrum-42161`: The target chain and chain ID to query the signed inference from
- Currently 2 target chains available:
- `ethereum-11155111`
Expand Down
103 changes: 103 additions & 0 deletions pages/devs/consumers/walkthrough-use-topic-inference.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Walkthrough: Using a Topic Inference on-chain

Follow these instructions to bring the most recent inference data on-chain for a given topic.

## Complete Example:

```solidity
/**
* @notice Example for calling a protocol function with topic inference data
*
* @param protocolFunctionArgument An argument for the protocol function
* @param alloraNetworkInferenceData The signed data from the Allora Consumer
*/
function callProtocolFunctionWithAlloraTopicInference(
uint256 protocolFunctionArgument,
AlloraConsumerNetworkInferenceData calldata alloraNetworkInferenceData
) external payable {
(
uint256 value,
uint256[] memory confidenceIntervalPercentiles,
uint256[] memory confidenceIntervalValues,
) = IAlloraConsumer(<Consumer Contract Address>).verifyNetworkInference(alloraNetworkInferenceData);
_protocolFunctionRequiringPredictionValue(
protocolFunctionArgument,
value,
confidenceIntervalPercentiles,
confidenceIntervalValues
);
}
```

## Step by Step Guide:

1. Create an Upshot API key by [creating an account](https://developer.upshot.xyz/signup).
2. Call the Consumer Inference API using the `topicId` found in the [deployed topics list](./existing-topics) and the correct chainId. For example, if you use sepolia, you would provide `ethereum-11155111`.

```shell
curl -X 'GET' --url 'https://api.upshot.xyz/v2/allora/consumer/<chainId>?allora_topic_id=<topicId>' -H 'accept: application/json' -H 'x-api-key: <apiKey>'
```

Here is an example response:
```json
{
"request_id": "b52b7c20-57ae-4852-bdbb-8f39cf317974",
"status": true,
"data": {
"signature": "0x99b8b75f875a9ecc09fc499073656407458d464edeceb384686dba990ed785d841e6510b578d253a6e19a20503d1ec1e3c38b4c60980ff3b4df9ce3335ebd3851b",
"inference_data": {
"network_inference": "3365485208027959000000",
"confidence_interval_percentiles": ["2280000000000000000", "15870000000000000000", "50000000000000000000", "84130000000000000000", "97720000000000000000"],
"confidence_interval_values": ["2280000000000000000", "15870000000000000000", "50000000000000000000", "84130000000000000000", "97720000000000000000"],
"topic_id": "9",
"timestamp": "1719866777",
"extra_data": "0x"
}
}
}
```

3. Construct a call to the Allora Consumer contract on the chain of your choice (options listed under [deployments](./existing-consumers)) using the returned `signature` and `network-inference` as follows:

## Creating the Transaction:

Note you be doing something more like `callProtocolFunctionWithAlloraTopicInference` in the example above, so you would want to construct your call to that contract in a similar way to the following. You can find the complete example [here](https://github.com/allora-network/allora-consumer/blob/main/script/verifyDataExampleSimple.ts).

```typescript
const alloraConsumer =
(new AlloraConsumer__factory())
.attach(ALLORA_CONSUMER_ADDRESS)
.connect(senderWallet) as AlloraConsumer

const tx = await alloraConsumer.verifyNetworkInference({
signature: '0x99b8b75f875a9ecc09fc499073656407458d464edeceb384686dba990ed785d841e6510b578d253a6e19a20503d1ec1e3c38b4c60980ff3b4df9ce3335ebd3851b',
networkInference: {
topicId: 9,
timestamp: 1719866777,
extraData: ethers.toUtf8Bytes(''),
networkInference: '3365485208027959000000',
confidenceIntervalPercentiles:['2280000000000000000', '15870000000000000000', '50000000000000000000', '84130000000000000000', '97720000000000000000' ],
confidenceIntervalValues:[ '3016256807053656000000', '3029849059956295000000', '3049738780726754000000', '3148682039955208400000', '3278333171848616500000' ],
},
extraData: ethers.toUtf8Bytes(''),
})

console.info('tx hash:', tx.hash)
console.info('Awaiting tx confirmation...')

const result = await tx.wait()

console.info('tx receipt:', result)
```


## Notes

- The API endpoint uses `snake_case`, while the smart contract uses `camelCase` for attribute names.
- Ethers.js does not accept `''` for `extraData`. Empty `extraData` should be denoted with `'0x'`.

## Code Links

- [Open source consumer code](https://github.com/allora-network/allora-consumer/blob/main/src/)
- [IAlloraConsumer](https://github.com/allora-network/allora-consumer/blob/main/src/interface/IAlloraConsumer.sol), including the structs used for Solidity code.
62 changes: 0 additions & 62 deletions pages/devs/workers/build-and-deploy-worker-with-node-runners.mdx

This file was deleted.

10 changes: 5 additions & 5 deletions pages/devs/workers/deploy-worker/deploy-worker-with-allocmd.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ First, [install `allocmd`](/devs/get-started/installation/cli#installing-allocmd

Next, initialize the CLI to bootstrap all the needed components to get your worker running. The following command will handle the initialization process. It will create all the files in the appropriate directories and generate identities for your node to be used for local development.

```shell
allocmd generate worker --name <workerName> --topic <topicId> --env dev --network allora-testnet-1
cd <workerName>/worker
```

> Note: if you're facing `Permission denied` issues, please try to create the folders before running the `allocmd generate` command:
> ```shell
> mkdir -p <workerName>/worker/data/head
Expand All @@ -26,6 +21,11 @@ cd <workerName>/worker
> chmod -R 777 ./<workerName>/worker/data/worker
> ```
```shell
allocmd generate worker --name <workerName> --topic <topicId> --env dev --network allora-testnet-1
cd <workerName>/worker
```
Before running this command you will have to [pick the topic Id](/devs/get-started/existing-topics) you wish to generate inference for after which you can run this command with the topic Id. The command will auto-create some files, the most important of which is the `dev-docker-compose.yaml`file which is an already complete docker-compose that you can run immediately to see your worker and head nodes running on your local machine. You can edit the files as you wish. For instance, the `main.py` is meant for you to call your inference server, hence you will have to edit the sample code with actual URLs and logic as you prefer.

After you have written and tested your logic in `main.py`, you can then run
Expand Down
8 changes: 5 additions & 3 deletions pages/home/explore.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ Examples of intelligence include, but are not limited to:

## Learn More


<Cards>
<Card title="Home" href="/home/explore" />
<Card title="Developers" href="/devs/get-started/setup-wallet" />
<Card title="Community" href="/community/contribute" />
</Cards>

<Cards>
<Card title="Overview" href="/home/overview" />
<Card title="Participants" href="/home/participants" />
<Card title="Layers of the Network" href="/home/layers" />
<Card title="Tokenomics" href="/home/tokenomics" />
<Card title="Whitepaper" href="https://whitepaper.assets.allora.network/whitepaper.pdf" />
</Cards>

{/* Allora brings together
Expand Down
10 changes: 8 additions & 2 deletions pages/home/tokenomics.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Callout } from 'nextra/components'

# Allora Tokenomics

The Allora token (ALLO) is minted by the Allora Network to facilitate the exchange of value by network participants.
Expand All @@ -8,8 +10,12 @@ The ALLO token incorporates a Pay-What-You-Want (PWYW) model to allow token hold

Token holders have the autonomy to decide the amount of ALLO they wish to pay for a given inference, which encourages token holders to contribute to the network's ecosystem according to their perceived value of the service.

Flexible price discovery across topics (less opinionated) - how the market reaches an agreed-upon price
running an LLM is a different (heterogeneous) resource provision compared to something like ethereum which is homogeneous (each opcode has a fixed price).
<Callout type="info">
**Important Note**: If participants choose to pay **zero** fees for a particular topic, the weight of that topic tends to zero. As a result, participants within that topic **receive no rewards**, and the token emission will be redistributed over other topics. This mechanism ensures that topics with no fee payments do not sustain themselves, driving healthy competition and price discovery across the network.
</Callout>

Flexible price discovery across topics is a less opinionated method that allows the market to reach an agreed-upon price through natural negotiation and market dynamics. Running a Large Language Model (LLM) involves a different, heterogeneous resource provision compared to something like Ethereum, which is homogeneous since each opcode in Ethereum has a fixed price.

## Token Emissions

### Bitcoin-like Emission Schedule
Expand Down

0 comments on commit 4bddd62

Please sign in to comment.