-
Notifications
You must be signed in to change notification settings - Fork 28
feat: implement p2p layer and broadcast flashblocks #275
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
Open
noot
wants to merge
24
commits into
main
Choose a base branch
from
noot/p2p
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,155
−1,094
Open
Changes from 19 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
7914369
initial p2p node impl in p2p crate
noot a082367
update args and add p2p node to flashblocks service
noot 960ecf7
send built flashblocks to p2p layer
noot c03416d
implement generic message in p2p crate, concrete message in builder
noot 5428121
implement incoming streams handler
noot 847180e
implement PayloadHandler for handling incoming p2p payloads
noot fa98c77
support multiple stream protocols
noot 590927c
make agent version configurable
noot 192340d
merge w main
noot 7ae5778
fmt
noot 5b77ff1
clippy
noot 3b66510
add known peers flag
noot 380a5c1
update error handling for better logging in payload builder
noot f522f4f
merge w main
noot 2ee1855
change p2p hex string to file path; add documentation for p2p crate
noot b20f773
fix optional flags
noot 35715c7
update Message trait to have custom to/from string
noot 1b1f345
cargo update
noot 2b0e5cd
fix copilot issues
noot 696030a
fix copilot issues
noot 9fd7548
fix derive_more
noot 3237890
fix copilot issues
noot 1badb92
regenerate Cargo.lock
noot 1a8fd45
merge w main
noot 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,60 @@ | ||
use alloy_primitives::U256; | ||
use reth::{core::primitives::SealedBlock, payload::PayloadId}; | ||
use reth_optimism_payload_builder::OpBuiltPayload as RethOpBuiltPayload; | ||
use reth_optimism_primitives::OpBlock; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub(super) const AGENT_VERSION: &str = "op-rbuilder/1.0.0"; | ||
pub(super) const FLASHBLOCKS_STREAM_PROTOCOL: p2p::StreamProtocol = | ||
p2p::StreamProtocol::new("/flashblocks/1.0.0"); | ||
|
||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | ||
pub(super) enum Message { | ||
OpBuiltPayload(OpBuiltPayload), | ||
} | ||
|
||
impl p2p::Message for Message { | ||
fn protocol(&self) -> p2p::StreamProtocol { | ||
FLASHBLOCKS_STREAM_PROTOCOL | ||
} | ||
} | ||
|
||
/// Internal type analogous to [`reth_optimism_payload_builder::OpBuiltPayload`] | ||
/// which additionally implements `Serialize` and `Deserialize` for p2p transmission. | ||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] | ||
pub(crate) struct OpBuiltPayload { | ||
/// Identifier of the payload | ||
pub(crate) id: PayloadId, | ||
/// Sealed block | ||
pub(crate) block: SealedBlock<OpBlock>, | ||
/// The fees of the block | ||
pub(crate) fees: U256, | ||
} | ||
|
||
impl From<RethOpBuiltPayload> for Message { | ||
fn from(value: RethOpBuiltPayload) -> Self { | ||
Message::OpBuiltPayload(value.into()) | ||
} | ||
} | ||
|
||
impl From<OpBuiltPayload> for Message { | ||
fn from(value: OpBuiltPayload) -> Self { | ||
Message::OpBuiltPayload(value) | ||
} | ||
} | ||
|
||
impl From<OpBuiltPayload> for RethOpBuiltPayload { | ||
fn from(value: OpBuiltPayload) -> Self { | ||
RethOpBuiltPayload::new(value.id, value.block.into(), value.fees, None) | ||
} | ||
} | ||
|
||
impl From<RethOpBuiltPayload> for OpBuiltPayload { | ||
fn from(value: RethOpBuiltPayload) -> Self { | ||
OpBuiltPayload { | ||
id: value.id(), | ||
block: value.block().clone(), | ||
fees: value.fees(), | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
are the versions meant to be updated manually