-
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
[Refactor] 3: Switch legacy to coordinator #239
Conversation
Changes unknown |
a685fff
to
03e7677
Compare
03e7677
to
7970184
Compare
ce9a7dd
to
09a1df3
Compare
92455e6
to
f361ed2
Compare
09a1df3
to
4a09ecb
Compare
f361ed2
to
a7fc02f
Compare
4a09ecb
to
269a518
Compare
a7fc02f
to
b037837
Compare
28d258d
to
25012a1
Compare
294d4e7
to
4454c92
Compare
25012a1
to
26433c1
Compare
30842fa
to
b306471
Compare
26433c1
to
25e9b7b
Compare
b306471
to
fabaa54
Compare
25e9b7b
to
bd92200
Compare
0bb5c40
to
9de7a38
Compare
crates/shared/src/state.rs
Outdated
@@ -159,6 +159,24 @@ where | |||
<Types::BlockPayload as BlockPayload<Types>>::from_bytes(encoded_txns, metadata); | |||
let txn_commitments = block_payload.transaction_commitments(metadata); | |||
|
|||
let views_since_nonempty_block = if txn_commitments.is_empty() { |
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 used by legacy builder to decide whether we want to build empty block to prioritize finalization.
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 was moved to its own file. The only change is making it atomic to reduce amount of locks we juggle in the legacy builder.
crates/legacy/src/block_store.rs
Outdated
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 file factors out the blocks
and block_cache
fields of legacy's GlobalState
.
The only actual change made is instead of Lru this uses the tiered map, so that we can prune blocks we know we won't need instead of hoping our Lru size is just right and we don't evict blocks we may yet need but also don't keep around too many blocks we'll never need again.
/// `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> { |
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 was moved to the shared crate and refactored a bit.
crates/legacy/src/lib.rs
Outdated
|
||
// TODO: Update commitment calculation with the new `commit`. | ||
// <https://github.com/EspressoSystems/marketplace-builder-core/issues/143> | ||
trait LegacyCommit<T: NodeType> { |
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.
We don't need this anymore!
crates/legacy/src/service.rs
Outdated
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.
Where most of the actual refactoring happened.
@@ -41,6 +42,28 @@ pub use marketplace_builder_shared::utils::EventServiceStream; | |||
|
|||
use crate::hooks::BuilderHooks; | |||
|
|||
/// Configuration to initialize the builder | |||
#[derive(Debug, Clone)] | |||
pub struct BuilderConfig<Types: NodeType> { |
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.
Sneaked in a config for the service instead of passing a bajilion parameters to the constructor
pub mod basic_test; | ||
pub mod integration; | ||
pub mod order_test; | ||
|
||
pub(crate) struct SimulatedChainState { |
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.
Moved to shared crate, so that legacy tests can take advantage of this as well.
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 a big one! I left many comments but structure-wise this looks really good.
#[repr(C)] | ||
pub(crate) struct MutableState { | ||
pub max_block_size: u64, | ||
pub last_block_size_increment: u64, |
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.
Is it possible to have a comment on what last_block_size_increment
is about?
/// If increment period has elapsed or `force` flag is set, | ||
/// increment [`Self::max_block_size`] by current value * [`Self::MAX_BLOCK_SIZE_CHANGE_DIVISOR`] | ||
/// with [`Self::protocol_max_block_size`] as a ceiling | ||
pub fn try_increment_block_size(&self, force: bool) { |
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.
What's the use case of this function? Just trying to get more understanding on the design motivation of try_increment_block_size
and decrement_block_size
.
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.
I added some docs to the BlockSizeLimits
struct itself, LMK if they don't clear it up enough
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.
Thanks for the detailed comment!
crates/marketplace/src/hooks.rs
Outdated
@@ -4,8 +4,29 @@ use async_trait::async_trait; | |||
use hotshot::types::Event; | |||
use hotshot_types::traits::node_implementation::NodeType; | |||
|
|||
/// A trait for hooks into the builder service. Used to further customize | |||
/// builder behaviour in ways not possible in builder core. | |||
/// If you don't such customisation, use [`NoHooks`]. |
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.
Nit: "If you don't use such"
1c00c95
to
fb34e1b
Compare
fb34e1b
to
1f1f21a
Compare
self.parent_block_references.last_nonempty_view | ||
} else { | ||
// This block is non-empty | ||
Some(quorum_proposal.view_number) |
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.
IIRC in the previous commit you updated self.parent_block_references.last_nonempty_view
as well. Should we keep it?
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.
Sorry, not sure I understand what you mean. Could you please clarify?
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.
As discussed today this actually looks good!
f32ceb8
to
7cf96d9
Compare
663aeb0
to
11d282b
Compare
11d282b
to
d418ff6
Compare
Closes #206
This PR:
Switches legacy builder to builder state coordinator.
This PR does not:
Key places to review: