Delete RuntimeVariableList::from_vec (#7930)

This method is a footgun because it truncates the list. It is the source of a recent bug:

- https://github.com/sigp/lighthouse/pull/7927


  - Delete uses of `RuntimeVariableList::from_vec` and replace them with `::new` which does validation and can fail.
- Propagate errors where possible, unwrap in tests and use `expect` for obviously-safe uses (in `chain_spec.rs`).
This commit is contained in:
Michael Sproul
2025-08-27 16:52:14 +10:00
committed by GitHub
parent ccf03e1c88
commit d235f2c697
15 changed files with 89 additions and 60 deletions

View File

@@ -831,7 +831,7 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
// BlocksByRoot Request
let rpc_request =
RequestType::BlocksByRoot(BlocksByRootRequest::V2(BlocksByRootRequestV2 {
block_roots: RuntimeVariableList::from_vec(
block_roots: RuntimeVariableList::new(
vec![
Hash256::zero(),
Hash256::zero(),
@@ -841,7 +841,8 @@ fn test_tcp_blocks_by_root_chunked_rpc() {
Hash256::zero(),
],
spec.max_request_blocks(current_fork_name),
),
)
.unwrap(),
}));
// BlocksByRoot Response
@@ -991,7 +992,8 @@ fn test_tcp_columns_by_root_chunked_rpc() {
max_request_blocks
],
max_request_blocks,
);
)
.unwrap();
let req_bytes = req.data_column_ids.as_ssz_bytes();
let req_decoded = DataColumnsByRootRequest {
data_column_ids: <RuntimeVariableList<DataColumnsByRootIdentifier<E>>>::from_ssz_bytes(
@@ -1281,7 +1283,7 @@ fn test_tcp_blocks_by_root_chunked_rpc_terminates_correctly() {
// BlocksByRoot Request
let rpc_request =
RequestType::BlocksByRoot(BlocksByRootRequest::V2(BlocksByRootRequestV2 {
block_roots: RuntimeVariableList::from_vec(
block_roots: RuntimeVariableList::new(
vec![
Hash256::zero(),
Hash256::zero(),
@@ -1295,7 +1297,8 @@ fn test_tcp_blocks_by_root_chunked_rpc_terminates_correctly() {
Hash256::zero(),
],
spec.max_request_blocks(current_fork),
),
)
.unwrap(),
}));
// BlocksByRoot Response