forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reference Oracle Implementation (MystenLabs#12854)
## Description This PR implements the off chain part of an oracle Proof of Concept. ## Test Plan Tested in different networks. --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes This PR implements the off chain part of an oracle Proof of Concept. --------- Co-authored-by: jk jensen <[email protected]>
- Loading branch information
1 parent
331fa2d
commit 68b28fb
Showing
13 changed files
with
1,078 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
[package] | ||
name = "sui-oracle" | ||
version.workspace = true | ||
authors = ["Mysten Labs <[email protected]>"] | ||
license = "Apache-2.0" | ||
publish = false | ||
edition = "2021" | ||
|
||
[dependencies] | ||
axum.workspace = true | ||
anyhow = { version = "1.0.64", features = ["backtrace"] } | ||
clap = { version = "3.2.17", features = ["derive"] } | ||
prometheus = "0.13.3" | ||
tokio = { workspace = true, features = ["full"] } | ||
tracing = "0.1.36" | ||
once_cell.workspace = true | ||
futures = "0.3.23" | ||
reqwest = { version = "0.11.13", default_features= false, features = ["blocking", "json", "rustls-tls"] } | ||
serde = { version = "1.0.144", features = ["derive", "rc"] } | ||
serde_json = { version = "1.0.1"} | ||
jsonpath_lib = "0.3.0" | ||
chrono.workspace = true | ||
serde_with = "2.1.0" | ||
tap.workspace = true | ||
bcs.workspace = true | ||
|
||
sui-config = { path = "../sui-config" } | ||
sui-json = { path = "../sui-json" } | ||
sui-json-rpc = { path = "../sui-json-rpc" } | ||
sui-json-rpc-types = { path = "../sui-json-rpc-types" } | ||
sui-sdk = { path = "../sui-sdk" } | ||
sui-types = { path = "../sui-types" } | ||
mysten-metrics = { path = "../mysten-metrics" } | ||
move-core-types.workspace = true | ||
telemetry-subscribers.workspace = true | ||
workspace-hack = { version = "0.1", path = "../workspace-hack" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# sui-oracle | ||
|
||
This oracle is intended to serve as general reference and informational purposes only. We make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability, or availability of the information provided by the oracle. | ||
|
||
Any reliance on such information by a user is strictly at the user’s own risk. We do not assume any responsibility for errors, omissions, or inaccuracies in the information and shall not be liable for any loss or damage arising from or related to its use. | ||
|
||
The information provided through this oracle does not constitute professional, investment or legal advice. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use serde::{Deserialize, Serialize}; | ||
use std::collections::HashMap; | ||
use std::net::SocketAddr; | ||
use std::time::Duration; | ||
use sui_config::Config; | ||
use sui_types::base_types::ObjectID; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct DataSourceConfig { | ||
pub url: String, | ||
pub json_path: String, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct UploadFeedConfig { | ||
pub submission_interval: Duration, | ||
pub data_source_config: DataSourceConfig, | ||
pub upload_parameters: UploadParameters, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct UploadParameters { | ||
pub write_package_id: ObjectID, | ||
pub write_module_name: String, | ||
pub write_function_name: String, | ||
pub write_data_provider_object_id: ObjectID, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct DownloadFeedConfigs { | ||
pub read_interval: Option<Duration>, | ||
pub read_feeds: HashMap<String, ObjectID>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
#[serde(rename_all = "kebab-case")] | ||
pub struct OracleNodeConfig { | ||
pub gas_object_id: ObjectID, | ||
pub upload_feeds: HashMap<String, HashMap<String, UploadFeedConfig>>, | ||
pub download_feeds: DownloadFeedConfigs, | ||
|
||
#[serde(default = "default_metrics_address")] | ||
pub metrics_address: SocketAddr, | ||
} | ||
|
||
fn default_metrics_address() -> SocketAddr { | ||
use std::net::{IpAddr, Ipv4Addr}; | ||
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)), 9400) | ||
} | ||
|
||
impl Config for OracleNodeConfig {} |
Oops, something went wrong.