Skip to content

Commit

Permalink
Merge branch 'master' into stefan/inc_pw_gen
Browse files Browse the repository at this point in the history
  • Loading branch information
stedfn authored Dec 17, 2024
2 parents 29d9e66 + 7712f8b commit c6e9b09
Show file tree
Hide file tree
Showing 45 changed files with 763 additions and 358 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,25 @@ jobs:
fail_ci_if_error: true
flags: pytests,upgradability,linux

windows_public_libraries_check:
name: "Windows check for building public libraries"
runs-on: "windows-latest"
publishable_packages_check:
name: "Cargo check publishable packages separately"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- name: Linux
id: linux
os: ubuntu-latest
- name: Windows
id: win
os: windows-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: just
- run: just check_build_public_libraries
- run: just check-publishable-separately
- run: just check-publishable-separately --no-default-features
- run: just check-publishable-separately --all-features
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ rand_hc = "0.3.1"
rand_xorshift = "0.3"
rayon = "1.5"
redis = "0.23.0"
reed-solomon-erasure = "6.0.0"
reed-solomon-erasure = { version = "6.0.0", features = ["simd-accel"] }
regex = "1.7.1"
region = "3.0"
reqwest = { version = "0.11.14", features = ["blocking"] }
Expand Down
10 changes: 7 additions & 3 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ platform_excludes := if os() == "macos" {
}

nightly_flags := "--features nightly,test_features"
public_libraries := "-p near-primitives -p near-crypto -p near-jsonrpc-primitives -p near-chain-configs -p near-primitives-core"

export RUST_BACKTRACE := env("RUST_BACKTRACE", "short")
ci_hack_nextest_profile := if env("CI_HACKS", "0") == "1" { "--profile ci" } else { "" }
Expand Down Expand Up @@ -150,5 +149,10 @@ check-protocol-schema:
env {{protocol_schema_env}} cargo test -p protocol-schema-check --profile dev-artifacts
env {{protocol_schema_env}} cargo run -p protocol-schema-check --profile dev-artifacts

check_build_public_libraries:
cargo check {{public_libraries}}
publishable := "cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.publish == null or (.publish | length > 0)) | .name'"
check-publishable-separately *OPTIONS:
#!/usr/bin/env bash
for pkg in $({{ publishable }}); do
echo "Checking $pkg..."
cargo check -p $pkg {{ OPTIONS }}
done
1 change: 1 addition & 0 deletions chain/chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ workspace = true

[dependencies]
actix.workspace = true
anyhow.workspace = true
borsh.workspace = true
bytesize.workspace = true
chrono.workspace = true
Expand Down
27 changes: 26 additions & 1 deletion chain/chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3838,6 +3838,24 @@ impl Chain {
)))
}

fn min_chunk_prev_height(&self, block: &Block) -> Result<BlockHeight, Error> {
let mut ret = None;
for chunk in block.chunks().iter_raw() {
let prev_height = if chunk.prev_block_hash() == &CryptoHash::default() {
0
} else {
let prev_header = self.get_block_header(chunk.prev_block_hash())?;
prev_header.height()
};
if let Some(min_height) = ret {
ret = Some(std::cmp::min(min_height, prev_height));
} else {
ret = Some(prev_height);
}
}
Ok(ret.unwrap_or(0))
}

/// Function to create or delete a snapshot if necessary.
/// TODO: this function calls head() inside of start_process_block_impl(), consider moving this to be called right after HEAD gets updated
fn process_snapshot(&mut self) -> Result<(), Error> {
Expand All @@ -3847,14 +3865,21 @@ impl Chain {
SnapshotAction::MakeSnapshot(prev_hash) => {
let prev_block = self.get_block(&prev_hash)?;
let prev_prev_hash = prev_block.header().prev_hash();
let min_chunk_prev_height = self.min_chunk_prev_height(&prev_block)?;
let epoch_height =
self.epoch_manager.get_epoch_height_from_prev_block(prev_prev_hash)?;
let shard_layout =
&self.epoch_manager.get_shard_layout_from_prev_block(prev_prev_hash)?;
let shard_uids = shard_layout.shard_uids().enumerate().collect();

let make_snapshot_callback = &snapshot_callbacks.make_snapshot_callback;
make_snapshot_callback(*prev_prev_hash, epoch_height, shard_uids, prev_block);
make_snapshot_callback(
*prev_prev_hash,
min_chunk_prev_height,
epoch_height,
shard_uids,
prev_block,
);
}
SnapshotAction::DeleteSnapshot => {
let delete_snapshot_callback = &snapshot_callbacks.delete_snapshot_callback;
Expand Down
Loading

0 comments on commit c6e9b09

Please sign in to comment.