Skip to content

Commit 821e7d2

Browse files
committed
add version byte prefix to group id
1 parent 9e49854 commit 821e7d2

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

beacon_node/lighthouse_network/src/types/partial.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use ssz_types::VariableList;
66
use std::collections::HashSet;
77
use std::fmt::Debug;
88
use std::sync::Arc;
9-
use types::EthSpec;
109
use types::data::partial_data_column_sidecar::{CellBitmap, PartialDataColumn};
1110
use types::partial_data_column_sidecar::PartialDataColumnSidecar;
11+
use types::{EthSpec, Hash256};
1212

1313
pub type HeaderSentSet = Arc<Mutex<HashSet<PeerId>>>;
1414

@@ -102,7 +102,10 @@ impl<E: EthSpec> From<CellBitmap<E>> for CellBitmapMetadata<E> {
102102

103103
impl<E: EthSpec> Partial for OutgoingPartialColumn<E> {
104104
fn group_id(&self) -> Vec<u8> {
105-
self.partial_column.block_root.as_slice().to_vec()
105+
let mut group_id = Vec::with_capacity(Hash256::len_bytes() + 1);
106+
group_id.push(0);
107+
group_id.extend_from_slice(self.partial_column.block_root.as_slice());
108+
group_id
106109
}
107110

108111
fn metadata(&self) -> Vec<u8> {

beacon_node/lighthouse_network/src/types/pubsub.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,10 @@ pub fn decode_partial<E: EthSpec>(
427427
) -> Result<PartialDataColumn<E>, String> {
428428
match topic.kind() {
429429
GossipKind::DataColumnSidecar(id) => {
430-
let block_root = Hash256::from_ssz_bytes(group)
430+
if group.first() != Some(&0) {
431+
return Err(format!("Unknown data column format: {:?}", group.first()));
432+
}
433+
let block_root = Hash256::from_ssz_bytes(&group[1..])
431434
.map_err(|e| format!("Error decoding group: {:?}", e))?;
432435
let sidecar = PartialDataColumnSidecar::from_ssz_bytes(data)
433436
.map_err(|e| format!("Error decoding sidecar: {:?}", e))?;

0 commit comments

Comments
 (0)