-
Couldn't load subscription status.
- Fork 30
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
Changes from 23 commits
7914369
a082367
960ecf7
c03416d
5428121
847180e
fa98c77
590927c
192340d
7ae5778
5b77ff1
3b66510
380a5c1
f522f4f
2ee1855
b20f773
35715c7
1b1f345
2b0e5cd
696030a
9fd7548
3237890
1badb92
1a8fd45
6e6d9de
2525f48
3e9ea53
0d30052
9a9b31d
9ebf706
31c527c
7bb5c80
5313e7d
0311b4d
669507a
061067c
6c28ec4
9bbc4a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| 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"); | ||
|
Comment on lines
+7
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are the versions meant to be updated manually There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes they are, if a breaking change was to be made to the stream protocol, this would be updated. that also allows for nodes to potentially support multiple versions of the protocol for backwards-compatibility |
||
|
|
||
| #[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(), | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.