Skip to content

Commit 0e80706

Browse files
committed
Simplify things and update tests
1 parent 770e1e5 commit 0e80706

File tree

11 files changed

+152
-139
lines changed

11 files changed

+152
-139
lines changed

beacon_node/beacon_chain/src/builder.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use std::time::Duration;
4040
use store::{Error as StoreError, HotColdDB, ItemStore, KeyValueStoreOp};
4141
use task_executor::{ShutdownReason, TaskExecutor};
4242
use tracing::{debug, error, info};
43-
use types::data_column_custody_group::{CustodyIndex, get_custody_groups_ordered};
43+
use types::data_column_custody_group::CustodyIndex;
4444
use types::{
4545
BeaconBlock, BeaconState, BlobSidecarList, ChainSpec, DataColumnSidecarList, Epoch, EthSpec,
4646
FixedBytesExtended, Hash256, Signature, SignedBeaconBlock, Slot,
@@ -103,7 +103,7 @@ pub struct BeaconChainBuilder<T: BeaconChainTypes> {
103103
task_executor: Option<TaskExecutor>,
104104
validator_monitor_config: Option<ValidatorMonitorConfig>,
105105
node_custody_type: NodeCustodyType,
106-
node_id: Option<[u8; 32]>,
106+
all_custody_groups_ordered: Option<Vec<CustodyIndex>>,
107107
rng: Option<Box<dyn RngCore + Send>>,
108108
}
109109

@@ -143,7 +143,7 @@ where
143143
task_executor: None,
144144
validator_monitor_config: None,
145145
node_custody_type: NodeCustodyType::Fullnode,
146-
node_id: None,
146+
all_custody_groups_ordered: None,
147147
rng: None,
148148
}
149149
}
@@ -650,8 +650,13 @@ where
650650
self
651651
}
652652

653-
pub fn node_id(mut self, node_id: [u8; 32]) -> Self {
654-
self.node_id = Some(node_id);
653+
/// Sets the custody group order for this node.
654+
/// This is used to determine the data columns the node is required to custody.
655+
pub fn all_custody_groups_ordered(
656+
mut self,
657+
all_custody_groups_ordered: Vec<CustodyIndex>,
658+
) -> Self {
659+
self.all_custody_groups_ordered = Some(all_custody_groups_ordered);
655660
self
656661
}
657662

@@ -748,7 +753,9 @@ where
748753
.genesis_state_root
749754
.ok_or("Cannot build without a genesis state root")?;
750755
let validator_monitor_config = self.validator_monitor_config.unwrap_or_default();
751-
let node_id = self.node_id.ok_or("Cannot build without a node id")?;
756+
let all_custody_groups_ordered = self
757+
.all_custody_groups_ordered
758+
.ok_or("Cannot build without ordered custody groups")?;
752759
let rng = self.rng.ok_or("Cannot build without an RNG")?;
753760
let beacon_proposer_cache: Arc<Mutex<BeaconProposerCache>> = <_>::default();
754761

@@ -938,10 +945,6 @@ where
938945
}
939946
};
940947

941-
let all_custody_groups_ordered =
942-
get_custody_groups_ordered(node_id, self.spec.number_of_custody_groups, &self.spec)
943-
.map_err(|e| format!("Failed to compute custody groups: {:?}", e))?;
944-
945948
// Load the persisted custody context from the db and initialize
946949
// the context for this run
947950
let (custody_context, cgc_changed_opt) = if let Some(custody) =

0 commit comments

Comments
 (0)