Skip to content

Commit e918be5

Browse files
authored
Merge pull request #38 from firstbatchxyz/erhant/perf-rfks
feat: repo performance refactors
2 parents 5bf9940 + bb0bf74 commit e918be5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1164
-1049
lines changed

Cargo.lock

Lines changed: 29 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
[package]
2-
name = "dria-oracle"
3-
description = "Dria Knowledge Network Oracle Node"
4-
version = "0.2.2"
1+
[workspace]
2+
resolver = "2"
3+
members = ["core", "contracts", "storage"]
4+
default-members = ["core"]
5+
6+
[workspace.package]
57
edition = "2021"
8+
version = "0.2.32"
69
license = "Apache-2.0"
710
readme = "README.md"
11+
authors = ["erhant"]
812

9-
[features]
10-
anvil = ["alloy/node-bindings"]
11-
12-
[dependencies]
13+
[workspace.dependencies]
1314
# core
1415
alloy = { version = "0.8.0", features = ["full", "node-bindings"] }
1516
alloy-chains = "0.1.24"
@@ -42,11 +43,3 @@ hex = "0.4.3"
4243
hex-literal = "0.4.1"
4344
serde = "1.0.204"
4445
serde_json = "1.0.122"
45-
46-
# cli
47-
clap = { version = "4.5.13", features = ["derive", "env"] }
48-
49-
# arweave uploader
50-
# TODO: there are many unused stuff here, but everything breaks if you use the minimal set
51-
# because Bundlr SDK is not maintained at all
52-
bundlr-sdk = { version = "0.5.0" }

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ endif
77
###############################################################################
88
.PHONY: launch # | Run with INFO logging & release mode
99
launch:
10-
cargo run --release start
10+
cargo run --release serve
1111

1212
.PHONY: run # | Run with INFO logging
1313
run:
14-
cargo run start
14+
cargo run serve
1515

1616
.PHONY: debug # | Run with crate-level DEBUG logging & info-level workflows
1717
debug:
18-
RUST_LOG=none,dria_oracle=debug,dkn_workflows=debug,ollama_workflows=info cargo run start
18+
RUST_LOG=none,dria_oracle=debug,dkn_workflows=debug,ollama_workflows=info cargo run serve
1919

2020
###############################################################################
2121
.PHONY: install # | Install to path

README.md

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ Create an `.env` file by copying `.env.example`. You have to fill the following
3131
> The contract addresses are determined with respect to the chain connected via RPC URL, but you can override it via `COORDINATOR_ADDRESS` environment variable.
3232
> In any case, you should not need to do this.
3333
34+
> [!TIP]
35+
>
36+
> You can have multiple environment files, and specify them explicitly with the `-e` argument, e.g.
37+
>
38+
> ```sh
39+
> # base sepolia
40+
> dria-oracle -e ./.env.base-sepolia registrations
41+
>
42+
> # base mainnet
43+
> dria-oracle -e ./.env.base-mainnet registrations
44+
> ```
45+
3446
### Arweave
3547
3648
You can save gas costs using [Arweave](https://arweave.org/):
@@ -66,8 +78,7 @@ The CLI provides several methods to interact with the oracle contracts.
6678

6779
> [!TIP]
6880
>
69-
> By default logs will be `info` level, but you can add a `DEBUG=1` env variable and it will use `debug` level instead.
70-
> You can set `RUST_LOG` variable yourself as well.
81+
> You can enable debug-level logs with the `-d` option.
7182
7283
### Registration
7384

@@ -92,11 +103,11 @@ dria-oracle unregister validator
92103
93104
### Launching the Node
94105

95-
We launch our node using the `start` command, followed by models of our choice and the oracle type that we would like to serve.
106+
We launch our node using the `serve` command, followed by models of our choice and the oracle type that we would like to serve.
96107
If we provide no oracle types, it will default to the ones that we are registered to.
97108

98109
```sh
99-
dria-oracle start -m=gpt-4o-mini -m=llama3.1:latest
110+
dria-oracle serve -m=gpt-4o-mini -m=llama3.1:latest
100111
```
101112

102113
You can terminate the application from the terminal as usual (e.g. CTRL+C) to quit the node.
@@ -109,20 +120,20 @@ Following the same logic, the Oracle node can read task inputs from Arweave as w
109120

110121
### Viewing Tasks
111122

112-
You can view the status of a task by its task id:
123+
You can `view` the details of a task by its task id:
113124

114125
```sh
115126
dria-oracle view <task-id>
116127
```
117128

118-
You can also view the task status updates between blocks with the `tasks` command.
119-
It accepts `--from` and `--to` arguments to indicate block numbers or tags, defaults from `earliest` block to `latest` block.
129+
You can also view the task status updates between blocks with the same command, by providing `from` and `to` blocks,
130+
which defaults from `earliest` block to `latest` block if none is provided.
120131

121132
```sh
122-
dria-oracle tasks # earliest to latest
123-
dria-oracle tasks --from=100 # 100 to latest
124-
dria-oracle tasks --to=100 # earliest to 100
125-
dria-oracle tasks --from=100 --to=200 # 100 to 200
133+
dria-oracle view # earliest to latest
134+
dria-oracle view --from=100 # 100 to latest
135+
dria-oracle view --to=100 # earliest to 100
136+
dria-oracle view --from=100 --to=200 # 100 to 200
126137
```
127138

128139
### Balance & Rewards
@@ -157,22 +168,6 @@ It mainly takes an input argument, followed by multiple model arguments:
157168
dria-oracle request "What is 2+2?" gpt-4o-mini phi3:3.8b
158169
```
159170

160-
The `request` command takes the following options:
161-
162-
- `--difficulty` for the proof-of-work difficulty for oracles that are responding to this request; the higher this is the more fees it will take to make the request.
163-
- `--num-gens` number of generations requested.
164-
- `--num-vals` number of validations required per request.
165-
166-
> [!NOTE]
167-
>
168-
> Making a request from the Oracle node is mainly for testing purposes, and you are not expected to use this command at all. Furthermore, it is only used to make plaintext requests, instead of larger ones via Arweave or more complex ones via Workflows.
169-
170-
There are 3 types of requests:
171-
172-
- **String**: simple text
173-
- **Chat**: an object of the form `{history_id: number, content: string}` which uses a previous task as history; TODO: history > nextTaskId handled?
174-
- **Workflow**: a stringified Workflow object
175-
176171
## Development
177172

178173
If you would like to contribute, please create an issue first! To start developing, clone the repository:

contracts/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "dria-oracle-contracts"
3+
description = "Dria Oracle Contract Interfaces"
4+
version.workspace = true
5+
edition.workspace = true
6+
license.workspace = true
7+
authors.workspace = true
8+
9+
[dependencies]
10+
alloy.workspace = true
11+
alloy-chains.workspace = true
12+
eyre.workspace = true
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/contracts/addresses.rs renamed to contracts/src/addresses.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ impl std::fmt::Display for ContractAddresses {
2929
/// Will return an error if the chain is not supported, i.e. a coordinator address
3030
/// is not deployed there.
3131
pub fn get_coordinator_address(chain: NamedChain) -> eyre::Result<Address> {
32-
3332
let addresses = match chain {
3433
NamedChain::AnvilHardhat => address!("9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"),
3534
NamedChain::BaseSepolia => address!("13f977bde221b470d3ae055cde7e1f84debfe202"),

0 commit comments

Comments
 (0)