-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move legacy and refactored legacy to separate crates #271
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
File renamed without changes.
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 |
---|---|---|
@@ -1,5 +1,75 @@ | ||
#[cfg_attr(legacy_builder_refactored, path = "refactored/lib.rs")] | ||
#[cfg_attr(not(legacy_builder_refactored), path = "old/lib.rs")] | ||
mod implementation; | ||
// Copyright (c) 2024 Espresso Systems (espressosys.com) | ||
// This file is part of the HotShot Builder Protocol. | ||
// | ||
|
||
pub use implementation::*; | ||
// Builder Phase 1 | ||
// It mainly provides three API services to hotshot proposers: | ||
// 1. Serves a proposer(leader)'s request to provide blocks information | ||
// 2. Serves a proposer(leader)'s request to provide the full blocks information | ||
// 3. Serves a proposer(leader)'s request to provide the block header information | ||
|
||
// It also provides one API services external users: | ||
// 1. Serves a user's request to submit a private transaction | ||
|
||
// providing the core services to support above API services | ||
pub mod builder_state; | ||
|
||
// Core interaction with the HotShot network | ||
pub mod service; | ||
|
||
// tracking the testing | ||
#[cfg(test)] | ||
pub mod testing; | ||
|
||
use hotshot_builder_api::v0_1::builder::BuildError; | ||
use tokio::sync::mpsc::UnboundedReceiver; | ||
|
||
/// `WaitAndKeep` is a helper enum that allows for the lazy polling of a single | ||
/// value from an unbound receiver. | ||
#[derive(Debug)] | ||
pub enum WaitAndKeep<T> { | ||
Keep(T), | ||
Wait(UnboundedReceiver<T>), | ||
} | ||
|
||
#[derive(Debug)] | ||
pub(crate) enum WaitAndKeepGetError { | ||
FailedToResolvedVidCommitmentFromChannel, | ||
} | ||
|
||
impl From<WaitAndKeepGetError> for BuildError { | ||
fn from(e: WaitAndKeepGetError) -> Self { | ||
match e { | ||
WaitAndKeepGetError::FailedToResolvedVidCommitmentFromChannel => { | ||
BuildError::Error("failed to resolve VidCommitment from channel".to_string()) | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl<T: Clone> WaitAndKeep<T> { | ||
/// get will return a clone of the value that is already stored within the | ||
/// value of `WaitAndKeep::Keep` if the value is already resolved. Otherwise | ||
/// it will poll the next value from the channel and replace the locally | ||
/// stored `WaitAndKeep::Wait` with the resolved value as a `WaitAndKeep::Keep`. | ||
/// | ||
/// Note: This pattern seems very similar to a Future, and ultimately | ||
/// returns a future. It's not clear why this needs to be implemented | ||
/// in such a way and not just implemented as a boxed future. | ||
pub(crate) async fn get(&mut self) -> Result<T, WaitAndKeepGetError> { | ||
match self { | ||
WaitAndKeep::Keep(t) => Ok(t.clone()), | ||
WaitAndKeep::Wait(fut) => { | ||
let got = fut | ||
.recv() | ||
.await | ||
.ok_or(WaitAndKeepGetError::FailedToResolvedVidCommitmentFromChannel); | ||
if let Ok(got) = &got { | ||
let mut replace = WaitAndKeep::Keep(got.clone()); | ||
core::mem::swap(self, &mut replace); | ||
} | ||
got | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,45 @@ | ||
[package] | ||
name = "hotshot-builder-core-refactored" | ||
version = { workspace = true } | ||
edition = { workspace = true } | ||
|
||
[dependencies] | ||
marketplace-builder-shared = { path = "../shared" } | ||
|
||
anyhow = { workspace = true } | ||
async-broadcast = { workspace = true } | ||
async-lock = { workspace = true } | ||
async-trait = { workspace = true } | ||
atomic = "0.6" | ||
bincode = { workspace = true } | ||
bytemuck = { version = "1.19", features = ["derive"] } | ||
coarsetime = "0.1.34" | ||
committable = { workspace = true } | ||
derive_more = { workspace = true, features = ["deref", "deref_mut", "debug"] } | ||
futures = { workspace = true } | ||
hotshot = { workspace = true } | ||
hotshot-builder-api = { workspace = true } | ||
hotshot-types = { workspace = true } | ||
lru = { workspace = true } | ||
once_cell = { workspace = true } | ||
serde = { workspace = true, features = ["derive"] } | ||
sha2 = { workspace = true } | ||
tagged-base64 = { workspace = true } | ||
tide-disco = { workspace = true } | ||
tokio = { workspace = true } | ||
tracing = { workspace = true } | ||
tracing-subscriber = { workspace = true } | ||
vbs = { workspace = true } | ||
|
||
[dev-dependencies] | ||
hotshot-example-types = { workspace = true } | ||
hotshot-macros = { workspace = true } | ||
hotshot-task-impls = { workspace = true } | ||
hotshot-testing = { workspace = true } | ||
num_cpus = { workspace = true } | ||
portpicker = { workspace = true } | ||
tracing-test = { workspace = true } | ||
url = { workspace = true } | ||
|
||
[lints] | ||
workspace = true |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just moving
crates/legacy/src/old/lib.rs
->crates/legacy/src/lib.rs
, git isn't smart enough to realize what happened and thinks I changed it.