-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP * Still chasing a bug * One down, one to go * ... and done. * Cleanup and finishing touches * Fixing the post-merge code, and one missed issue in the pre-merge code. * Some clarifying name changes. * Removing bincode dependency where applicable * cleanup of some (not quite all) remaining bincode invocations * dependency versioning tags and cleanup * bump version * Bumping anticipated version * Now with new VBS * branch => tag on dependencies * Update lock? * Cargo.lock update * Apparently `just * lint` runs with --features="hotshot-testing" enabled * integrate new storage type * fix build, tie up stragglers, modifying tasks next * merge latest stable tabs * merge latest tags and fix method signatures * Update *-disco * Dependencies updated to tags * Add builder-api and types to repo * fix doc * hs-builder-api -> hotshot-builder-api * fmt --------- Co-authored-by: Nathan F Yospe <[email protected]> Co-authored-by: Jarred Parr <[email protected]>
- Loading branch information
1 parent
b0adec3
commit 8bf55cf
Showing
53 changed files
with
6,251 additions
and
290 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[package] | ||
name = "hotshot-builder-api" | ||
version = "0.1.6" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
async-trait = { workspace = true } | ||
clap = { version = "4.4", features = ["derive", "env"] } | ||
derive_more = "0.99" | ||
futures = "0.3" | ||
hotshot-types = { path = "../types" } | ||
serde = { workspace = true } | ||
snafu = { workspace = true } | ||
tagged-base64 = { workspace = true } | ||
tide-disco = { workspace = true } | ||
toml = { workspace = true } | ||
versioned-binary-serialization = { workspace = true } |
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,4 @@ | ||
# hotshot-builder-api | ||
Minimal dependencies shared API definitions for HotShot Builder protocol | ||
|
||
# HotShot Consensus Module |
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,65 @@ | ||
# Copyright (c) 2024 Espresso Systems (espressosys.com) | ||
# This file is part of the HotShot Builder Protocol. | ||
# | ||
# MIT License | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
|
||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
[meta] | ||
NAME = "hs-builder-get" | ||
DESCRIPTION = "" | ||
FORMAT_VERSION = "0.1.0" | ||
|
||
[route.available_blocks] | ||
PATH = ["availableblocks/:parent_hash"] | ||
":parent_hash" = "TaggedBase64" | ||
DOC = """ | ||
Get descriptions for all block candidates based on a specific parent block. | ||
Returns | ||
``` | ||
[ | ||
"block_metadata": { | ||
"block_hash": TaggedBase64, | ||
"block_size": integer, | ||
"offered_fee": integer, | ||
}, | ||
] | ||
``` | ||
""" | ||
|
||
[route.claim_block] | ||
PATH = ["claimblock/:block_hash/:signature"] | ||
":block_hash" = "TaggedBase64" | ||
":signature" = "TaggedBase64" | ||
DOC = """ | ||
Get the specified block candidate. | ||
Returns application-specific encoded transactions type | ||
""" | ||
|
||
[route.claim_header_input] | ||
PATH = ["claimheaderinput/:block_hash/:signature"] | ||
":block_hash" = "TaggedBase64" | ||
":signature" = "TaggedBase64" | ||
DOC = """ | ||
Get the specified block candidate. | ||
Returns application-specific block header type | ||
""" |
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,33 @@ | ||
# Copyright (c) 2024 Espresso Systems (espressosys.com) | ||
# This file is part of the HotShot Builder Protocol. | ||
# | ||
# MIT License | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
|
||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
|
||
[meta] | ||
NAME = "hs-builder-submit" | ||
DESCRIPTION = "" | ||
FORMAT_VERSION = "0.1.0" | ||
|
||
[route.submit_txn] | ||
PATH = ["/submit"] | ||
METHOD = "POST" | ||
DOC = "Submit a transaction to builder's private mempool." |
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,59 @@ | ||
// Copyright (c) 2022 Espresso Systems (espressosys.com) | ||
// This file is part of the HotShot Query Service library. | ||
// | ||
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU | ||
// General Public License as published by the Free Software Foundation, either version 3 of the | ||
// License, or (at your option) any later version. | ||
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
// even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
// General Public License for more details. | ||
// You should have received a copy of the GNU General Public License along with this program. If not, | ||
// see <https://www.gnu.org/licenses/>. | ||
|
||
use std::fs; | ||
use std::path::Path; | ||
use tide_disco::api::{Api, ApiError}; | ||
use toml::{map::Entry, Value}; | ||
use versioned_binary_serialization::version::StaticVersionType; | ||
|
||
pub(crate) fn load_api<State, Error, Ver: StaticVersionType>( | ||
path: Option<impl AsRef<Path>>, | ||
default: &str, | ||
extensions: impl IntoIterator<Item = Value>, | ||
) -> Result<Api<State, Error, Ver>, ApiError> { | ||
let mut toml = match path { | ||
Some(path) => load_toml(path.as_ref())?, | ||
None => toml::from_str(default).map_err(|err| ApiError::CannotReadToml { | ||
reason: err.to_string(), | ||
})?, | ||
}; | ||
for extension in extensions { | ||
merge_toml(&mut toml, extension); | ||
} | ||
Api::new(toml) | ||
} | ||
|
||
fn merge_toml(into: &mut Value, from: Value) { | ||
if let (Value::Table(into), Value::Table(from)) = (into, from) { | ||
for (key, value) in from { | ||
match into.entry(key) { | ||
Entry::Occupied(mut entry) => merge_toml(entry.get_mut(), value), | ||
Entry::Vacant(entry) => { | ||
entry.insert(value); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
fn load_toml(path: &Path) -> Result<Value, ApiError> { | ||
let bytes = fs::read(path).map_err(|err| ApiError::CannotReadToml { | ||
reason: err.to_string(), | ||
})?; | ||
let string = std::str::from_utf8(&bytes).map_err(|err| ApiError::CannotReadToml { | ||
reason: err.to_string(), | ||
})?; | ||
toml::from_str(string).map_err(|err| ApiError::CannotReadToml { | ||
reason: err.to_string(), | ||
}) | ||
} |
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,38 @@ | ||
use std::{hash::Hash, marker::PhantomData}; | ||
|
||
use hotshot_types::{ | ||
traits::{node_implementation::NodeType, signature_key::SignatureKey, BlockPayload}, | ||
utils::BuilderCommitment, | ||
vid::VidCommitment, | ||
}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)] | ||
#[serde(bound = "")] | ||
pub struct AvailableBlockInfo<I: NodeType> { | ||
pub block_hash: BuilderCommitment, | ||
pub block_size: u64, | ||
pub offered_fee: u64, | ||
pub signature: <<I as NodeType>::SignatureKey as SignatureKey>::PureAssembledSignatureType, | ||
pub sender: <I as NodeType>::SignatureKey, | ||
pub _phantom: PhantomData<I>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)] | ||
#[serde(bound = "")] | ||
pub struct AvailableBlockData<I: NodeType> { | ||
pub block_payload: <I as NodeType>::BlockPayload, | ||
pub metadata: <<I as NodeType>::BlockPayload as BlockPayload>::Metadata, | ||
pub signature: <<I as NodeType>::SignatureKey as SignatureKey>::PureAssembledSignatureType, | ||
pub sender: <I as NodeType>::SignatureKey, | ||
pub _phantom: PhantomData<I>, | ||
} | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, Hash)] | ||
#[serde(bound = "")] | ||
pub struct AvailableBlockHeaderInput<I: NodeType> { | ||
pub vid_commitment: VidCommitment, | ||
pub signature: <<I as NodeType>::SignatureKey as SignatureKey>::PureAssembledSignatureType, | ||
pub sender: <I as NodeType>::SignatureKey, | ||
pub _phantom: PhantomData<I>, | ||
} |
Oops, something went wrong.