diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1457062053..59c650e8b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -207,7 +207,12 @@ jobs: - name: Upload combined results uses: actions/upload-artifact@v4 with: - name: Unit Test Results ${{ matrix.target.os }}-${{ matrix.target.cpu }} + # upload-artifact requires avoiding "/", because "To maintain file + # system agnostic behavior, these characters are intentionally not + # allowed to prevent potential problems with downloads on different + # file systems". However, GitHub Actions workflows do not support a + # usual assortment of string functions. + name: Unit Test Results ${{ matrix.target.os }}-${{ matrix.target.cpu }}-${{ matrix.branch == 'upstream/version-2-0' && 'version-2-0' || matrix.branch }} path: build/*.xml devbuild: diff --git a/beacon_chain/consensus_object_pools/blockchain_dag.nim b/beacon_chain/consensus_object_pools/blockchain_dag.nim index 0a5fe0627b..369560b921 100644 --- a/beacon_chain/consensus_object_pools/blockchain_dag.nim +++ b/beacon_chain/consensus_object_pools/blockchain_dag.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2024 Status Research & Development GmbH +# Copyright (c) 2018-2025 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). @@ -1639,11 +1639,11 @@ template forkAtEpoch*(dag: ChainDAGRef, epoch: Epoch): Fork = forkAtEpoch(dag.cfg, epoch) proc getBlockRange*( - dag: ChainDAGRef, startSlot: Slot, skipStep: uint64, + dag: ChainDAGRef, startSlot: Slot, output: var openArray[BlockId]): Natural = ## This function populates an `output` buffer of blocks ## with a slots ranging from `startSlot` up to, but not including, - ## `startSlot + skipStep * output.len`, skipping any slots that don't have + ## `startSlot + output.len`, skipping any slots that don't have ## a block. ## ## Blocks will be written to `output` from the end without gaps, even if @@ -1657,7 +1657,7 @@ proc getBlockRange*( headSlot = dag.head.slot trace "getBlockRange entered", - head = shortLog(dag.head.root), requestedCount, startSlot, skipStep, headSlot + head = shortLog(dag.head.root), requestedCount, startSlot, headSlot if startSlot < dag.backfill.slot: debug "Got request for pre-backfill slot", @@ -1671,11 +1671,9 @@ proc getBlockRange*( runway = uint64(headSlot - startSlot) # This is the number of blocks that will follow the start block - extraSlots = min(runway div skipStep, requestedCount - 1) + extraSlots = min(runway, requestedCount - 1) - # If `skipStep` is very large, `extraSlots` should be 0 from - # the previous line, so `endSlot` will be equal to `startSlot`: - endSlot = startSlot + extraSlots * skipStep + endSlot = startSlot + extraSlots var curSlot = endSlot @@ -1687,7 +1685,7 @@ proc getBlockRange*( if bs.isSome and bs.get().isProposed(): o -= 1 output[o] = bs.get().bid - curSlot -= skipStep + curSlot -= 1 # Handle start slot separately (to avoid underflow when computing curSlot) let bs = dag.getBlockIdAtSlot(startSlot) diff --git a/beacon_chain/nimbus_beacon_node.nim b/beacon_chain/nimbus_beacon_node.nim index 7e772037cd..7aaf93ca48 100644 --- a/beacon_chain/nimbus_beacon_node.nim +++ b/beacon_chain/nimbus_beacon_node.nim @@ -1595,7 +1595,7 @@ proc pruneBlobs(node: BeaconNode, slot: Slot) = var blocks: array[SLOTS_PER_EPOCH.int, BlockId] var count = 0 let startIndex = node.dag.getBlockRange( - blobPruneEpoch.start_slot, 1, blocks.toOpenArray(0, SLOTS_PER_EPOCH - 1)) + blobPruneEpoch.start_slot, blocks.toOpenArray(0, SLOTS_PER_EPOCH - 1)) for i in startIndex.. "${DATA_DIR}/deposit_contract_block_hash.txt" -for NUM_NODE in $(seq 1 $NUM_NODES); do +for NUM_NODE in $(seq 1 "${NUM_NODES}"); do NODE_DATA_DIR="${DATA_DIR}/node${NUM_NODE}" rm -rf "${NODE_DATA_DIR}" scripts/makedir.sh "${NODE_DATA_DIR}" 2>&1 @@ -922,7 +919,7 @@ DIRECTPEER_ENR=$( cp "$SCRIPTS_DIR/$CONST_PRESET-non-overriden-config.yaml" "$RUNTIME_CONFIG_FILE" # TODO the runtime config file should be used during deposit generation as well! -echo Wrote $RUNTIME_CONFIG_FILE: +echo Wrote "${RUNTIME_CONFIG_FILE}": tee -a "$RUNTIME_CONFIG_FILE" < "${DATA_DIR}/logs/nimbus_light_client.${NUM_LC}.jsonl" & PID=$! PIDS_TO_WAIT="${PIDS_TO_WAIT},${PID}" diff --git a/scripts/repo_paths.sh b/scripts/repo_paths.sh deleted file mode 100644 index ccd817de7a..0000000000 --- a/scripts/repo_paths.sh +++ /dev/null @@ -1,24 +0,0 @@ -if [ -z "${REPO_PATHS_SOURCED:-}" ]; then -REPO_PATHS_SOURCED=1 - -SCRIPTS_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd) -BUILD_DIR=$(cd "$SCRIPTS_DIR/../build" &> /dev/null && pwd) - -data_dir_for_network() { - NETWORK_ID=$(cat "$NETWORK/genesis.json" | jq '.config.chainId') - echo "$BUILD_DIR/data/$NETWORK_ID" -} - -create_data_dir_for_network() { - NETWORK_DIR=$(data_dir_for_network) - mkdir -p "$NETWORK_DIR" - echo "$NETWORK_DIR" -} - -create_jwt_token() { - if [ ! -f "$1" ]; then - openssl rand -hex 32 | tr -d "\n" > "$1" - fi -} - -fi diff --git a/tests/test_blockchain_dag.nim b/tests/test_blockchain_dag.nim index 70e6baadc1..146fd20e24 100644 --- a/tests/test_blockchain_dag.nim +++ b/tests/test_blockchain_dag.nim @@ -1,5 +1,5 @@ # beacon_chain -# Copyright (c) 2018-2024 Status Research & Development GmbH +# Copyright (c) 2018-2025 Status Research & Development GmbH # Licensed and distributed under either of # * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). @@ -147,41 +147,17 @@ suite "Block pool processing" & preset(): var blocks: array[3, BlockId] check: - dag.getBlockRange(Slot(0), 1, blocks.toOpenArray(0, 0)) == 0 + dag.getBlockRange(Slot(0), blocks.toOpenArray(0, 0)) == 0 blocks[0..<1] == [dag.tail] - dag.getBlockRange(Slot(0), 1, blocks.toOpenArray(0, 1)) == 0 + dag.getBlockRange(Slot(0), blocks.toOpenArray(0, 1)) == 0 blocks[0..<2] == [dag.tail, b1Add[].bid] - dag.getBlockRange(Slot(0), 2, blocks.toOpenArray(0, 1)) == 0 - blocks[0..<2] == [dag.tail, b2Add[].bid] - - dag.getBlockRange(Slot(0), 3, blocks.toOpenArray(0, 1)) == 1 - blocks[1..<2] == [dag.tail] # block 3 is missing! - - dag.getBlockRange(Slot(2), 2, blocks.toOpenArray(0, 1)) == 0 - blocks[0..<2] == [b2Add[].bid, b4Add[].bid] # block 3 is missing! - - # large skip step - dag.getBlockRange(Slot(0), uint64.high, blocks.toOpenArray(0, 2)) == 2 - blocks[2..2] == [dag.tail] - - # large skip step - dag.getBlockRange(Slot(2), uint64.high, blocks.toOpenArray(0, 1)) == 1 - blocks[1..1] == [b2Add[].bid] - - # empty length - dag.getBlockRange(Slot(2), 2, blocks.toOpenArray(0, -1)) == 0 - # No blocks in sight - dag.getBlockRange(Slot(5), 1, blocks.toOpenArray(0, 1)) == 2 + dag.getBlockRange(Slot(5), blocks.toOpenArray(0, 1)) == 2 # No blocks in sight - dag.getBlockRange(Slot(uint64.high), 1, blocks.toOpenArray(0, 1)) == 2 - - # No blocks in sight either due to gaps - dag.getBlockRange(Slot(3), 2, blocks.toOpenArray(0, 1)) == 2 - blocks[2..<2].len == 0 + dag.getBlockRange(Slot(uint64.high), blocks.toOpenArray(0, 1)) == 2 # A fork forces the clearance state to a point where it cannot be advanced let