Skip to content

Commit

Permalink
Fix formatting only
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmygchen committed Dec 15, 2022
1 parent 6c85b16 commit e90db2d
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 41 deletions.
90 changes: 60 additions & 30 deletions beacon_node/execution_layer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,18 +796,28 @@ impl<T: EthSpec> ExecutionLayer<T> {
self.inner.builder_profit_threshold,
spec,
) {
Ok(()) => Ok(ProvenancedPayload::Builder(
match relay.version.unwrap() {
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => {
Ok(()) => {
Ok(ProvenancedPayload::Builder(match relay.version.unwrap() {
ForkName::Base
| ForkName::Altair
| ForkName::Merge
| ForkName::Capella => {
BlockProposalContents::Payload(header)
}
ForkName::Eip4844 => BlockProposalContents::PayloadAndBlobs {
payload: header,
blobs: VariableList::default(),
kzg_commitments: relay.data.message.blob_kzg_commitments().unwrap().clone()
},
}
)),
ForkName::Eip4844 => {
BlockProposalContents::PayloadAndBlobs {
payload: header,
blobs: VariableList::default(),
kzg_commitments: relay
.data
.message
.blob_kzg_commitments()
.unwrap()
.clone(),
}
}
}))
}
Err(reason) if !reason.payload_invalid() => {
info!(
self.log(),
Expand Down Expand Up @@ -857,32 +867,52 @@ impl<T: EthSpec> ExecutionLayer<T> {
self.inner.builder_profit_threshold,
spec,
) {
Ok(()) => Ok(ProvenancedPayload::Builder(
match relay.version.unwrap() {
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => {
Ok(()) => {
Ok(ProvenancedPayload::Builder(match relay.version.unwrap() {
ForkName::Base
| ForkName::Altair
| ForkName::Merge
| ForkName::Capella => {
BlockProposalContents::Payload(header)
}
ForkName::Eip4844 => BlockProposalContents::PayloadAndBlobs {
payload: header,
blobs: VariableList::default(),
kzg_commitments: relay.data.message.blob_kzg_commitments().unwrap().clone(),
},
}
)),
ForkName::Eip4844 => {
BlockProposalContents::PayloadAndBlobs {
payload: header,
blobs: VariableList::default(),
kzg_commitments: relay
.data
.message
.blob_kzg_commitments()
.unwrap()
.clone(),
}
}
}))
}
// If the payload is valid then use it. The local EE failed
// to produce a payload so we have no alternative.
Err(e) if !e.payload_invalid() => Ok(ProvenancedPayload::Builder(
match relay.version.unwrap() {
ForkName::Base | ForkName::Altair | ForkName::Merge | ForkName::Capella => {
Err(e) if !e.payload_invalid() => {
Ok(ProvenancedPayload::Builder(match relay.version.unwrap() {
ForkName::Base
| ForkName::Altair
| ForkName::Merge
| ForkName::Capella => {
BlockProposalContents::Payload(header)
}
ForkName::Eip4844 => BlockProposalContents::PayloadAndBlobs {
payload: header,
blobs: VariableList::default(),
kzg_commitments: relay.data.message.blob_kzg_commitments().unwrap().clone(),
},
}
)),
ForkName::Eip4844 => {
BlockProposalContents::PayloadAndBlobs {
payload: header,
blobs: VariableList::default(),
kzg_commitments: relay
.data
.message
.blob_kzg_commitments()
.unwrap()
.clone(),
}
}
}))
}
Err(reason) => {
metrics::inc_counter_vec(
&metrics::EXECUTION_LAYER_GET_PAYLOAD_BUILDER_REJECTIONS,
Expand Down
24 changes: 13 additions & 11 deletions consensus/types/src/builder_bid.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::KzgCommitment;
use crate::{
AbstractExecPayload, ChainSpec, EthSpec, ExecPayload, ExecutionPayloadHeader, SignedRoot,
Uint256
Uint256,
};
use bls::PublicKeyBytes;
use bls::Signature;
Expand All @@ -17,14 +17,16 @@ use tree_hash_derive::TreeHash;
#[superstruct(
variants(Merge, Capella, Eip4844),
variant_attributes(
derive(
PartialEq, Debug, Serialize, Deserialize, TreeHash, Clone
),
derive(PartialEq, Debug, Serialize, Deserialize, TreeHash, Clone),
serde(bound = "E: EthSpec, Payload: ExecPayload<E>", deny_unknown_fields)
)
)]
#[derive(PartialEq, Debug, Serialize, Deserialize, TreeHash, Clone)]
#[serde(bound = "E: EthSpec, Payload: ExecPayload<E>", deny_unknown_fields, untagged)]
#[serde(
bound = "E: EthSpec, Payload: ExecPayload<E>",
deny_unknown_fields,
untagged
)]
#[tree_hash(enum_behaviour = "transparent")]
pub struct BuilderBid<E: EthSpec, Payload: AbstractExecPayload<E>> {
#[superstruct(only(Merge), partial_getter(rename = "payload_merge"))]
Expand Down Expand Up @@ -106,17 +108,18 @@ impl<E: EthSpec, Payload: AbstractExecPayload<E>> SignedBuilderBid<E, Payload> {
}
}


#[cfg(test)]
mod tests {
use crate::{BlindedPayload, MainnetEthSpec};
use super::*;
use crate::{BlindedPayload, MainnetEthSpec};

pub fn deserialize_bid<E: EthSpec, Payload: AbstractExecPayload<E>>(str: &str) -> Result<BuilderBid<E, Payload>, Error> {
pub fn deserialize_bid<E: EthSpec, Payload: AbstractExecPayload<E>>(
str: &str,
) -> Result<BuilderBid<E, Payload>, Error> {
let bid = serde_json::from_str(str)?;
Ok(bid)
}

#[test]
fn test_deserialize_builder_bid_merge() {
let str = r#"{
Expand All @@ -143,7 +146,6 @@ mod tests {
assert!(result.is_ok());
}


#[test]
#[cfg(feature = "withdrawals")]
fn test_deserialize_builder_bid_capella() {
Expand Down Expand Up @@ -203,4 +205,4 @@ mod tests {
let result = deserialize_bid::<MainnetEthSpec, BlindedPayload<MainnetEthSpec>>(str);
assert!(result.is_ok());
}
}
}

0 comments on commit e90db2d

Please sign in to comment.