Skip to content

Commit 0b85d86

Browse files
committed
cleanup
1 parent 7e6df3a commit 0b85d86

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

beacon_node/execution_layer/src/engine_api/json_structures.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,8 @@ pub enum RequestsError {
352352

353353
/// Format of `ExecutionRequests` received over the engine api.
354354
///
355-
/// Array of ssz-encoded requests list encoded as hex bytes.
356-
/// The prefix of the request type is used to index into the array.
357-
///
358-
/// For e.g. [0xab, 0xcd, 0xef]
359-
/// Here, 0xab are the deposits bytes (prefix and index == 0)
360-
/// 0xcd are the withdrawals bytes (prefix and index == 1)
361-
/// 0xef are the consolidations bytes (prefix and index == 2)
355+
/// Array of ssz-encoded requests list encoded as hex bytes prefixed
356+
/// with a `RequestType`
362357
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
363358
#[serde(transparent)]
364359
pub struct JsonExecutionRequests(pub Vec<String>);
@@ -383,10 +378,10 @@ impl<E: EthSpec> TryFrom<JsonExecutionRequests> for ExecutionRequests<E> {
383378
return Err(RequestsError::EmptyRequest(i));
384379
}
385380
// Elements of the list **MUST** be ordered by `request_type` in ascending order
386-
let current_prefix = RequestType::from_prefix(*prefix_byte)
381+
let current_prefix = RequestType::from_u8(*prefix_byte)
387382
.ok_or(RequestsError::InvalidPrefix(*prefix_byte))?;
388383
if let Some(prev) = prev_prefix {
389-
if prev.to_prefix() >= current_prefix.to_prefix() {
384+
if prev.to_u8() >= current_prefix.to_u8() {
390385
return Err(RequestsError::InvalidOrdering);
391386
}
392387
}

consensus/types/src/execution_requests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ impl<E: EthSpec> ExecutionRequests<E> {
4646
let mut requests_list = Vec::new();
4747
if !self.deposits.is_empty() {
4848
requests_list.push(Bytes::from_iter(
49-
[RequestType::Deposit.to_prefix()]
49+
[RequestType::Deposit.to_u8()]
5050
.into_iter()
5151
.chain(self.deposits.as_ssz_bytes()),
5252
));
5353
}
5454
if !self.withdrawals.is_empty() {
5555
requests_list.push(Bytes::from_iter(
56-
[RequestType::Withdrawal.to_prefix()]
56+
[RequestType::Withdrawal.to_u8()]
5757
.into_iter()
5858
.chain(self.withdrawals.as_ssz_bytes()),
5959
));
6060
}
6161
if !self.consolidations.is_empty() {
6262
requests_list.push(Bytes::from_iter(
63-
[RequestType::Consolidation.to_prefix()]
63+
[RequestType::Consolidation.to_u8()]
6464
.into_iter()
6565
.chain(self.consolidations.as_ssz_bytes()),
6666
));
@@ -86,7 +86,7 @@ impl<E: EthSpec> ExecutionRequests<E> {
8686
}
8787
}
8888

89-
/// This is used to index into the `execution_requests` array.
89+
/// The prefix types for `ExecutionRequest` objects.
9090
#[derive(Debug, Copy, Clone)]
9191
pub enum RequestType {
9292
Deposit,
@@ -95,15 +95,15 @@ pub enum RequestType {
9595
}
9696

9797
impl RequestType {
98-
pub fn from_prefix(prefix: u8) -> Option<Self> {
98+
pub fn from_u8(prefix: u8) -> Option<Self> {
9999
match prefix {
100100
0 => Some(Self::Deposit),
101101
1 => Some(Self::Withdrawal),
102102
2 => Some(Self::Consolidation),
103103
_ => None,
104104
}
105105
}
106-
pub fn to_prefix(&self) -> u8 {
106+
pub fn to_u8(&self) -> u8 {
107107
match self {
108108
Self::Deposit => 0,
109109
Self::Withdrawal => 1,

0 commit comments

Comments
 (0)