Skip to content

Commit

Permalink
chore: rust 1.83 (#12558)
Browse files Browse the repository at this point in the history
  • Loading branch information
nagisa authored Dec 6, 2024
1 parent feb8393 commit e02eed8
Show file tree
Hide file tree
Showing 39 changed files with 230 additions and 262 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- uses: actions/checkout@v4

# Install all the required tools
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: just,cargo-nextest,cargo-llvm-cov

Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
with:
python-version: 3.11
cache: pip
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: cargo-llvm-cov
- run: pip3 install --user -r pytest/requirements.txt
Expand All @@ -110,7 +110,7 @@ jobs:
with:
python-version: 3.11
cache: pip
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: cargo-llvm-cov
- run: pip3 install --user -r pytest/requirements.txt
Expand Down Expand Up @@ -140,7 +140,7 @@ jobs:
with:
python-version: 3.11
cache: pip
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: cargo-llvm-cov
- run: pip3 install --user -r pytest/requirements.txt
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
with:
python-version: 3.11
cache: pip
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: cargo-llvm-cov
- run: pip3 install --user -r pytest/requirements.txt
Expand All @@ -194,7 +194,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: just
- uses: actions/setup-python@v5
Expand All @@ -213,7 +213,7 @@ jobs:
with:
python-version: 3.11
cache: pip
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: cargo-llvm-cov
- run: pip3 install --user -r pytest/requirements.txt
Expand All @@ -235,7 +235,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: just
- run: just check-protocol-schema
Expand All @@ -245,7 +245,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: just
- run: just check-cargo-fmt
Expand All @@ -255,7 +255,7 @@ jobs:
runs-on: ubuntu-22.04-8core
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: just
- run: just check-cargo-clippy
Expand All @@ -265,7 +265,7 @@ jobs:
runs-on: ubuntu-22.04-8core
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: just
- run: just doctests
Expand All @@ -275,7 +275,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: just,cargo-deny
- run: just check-cargo-deny
Expand All @@ -285,7 +285,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: just
- run: just check-themis
Expand All @@ -295,7 +295,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: just
- run: just check-non-default
Expand All @@ -305,7 +305,7 @@ jobs:
runs-on: ubuntu-22.04-8core
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: just,cargo-udeps
- run: just check-cargo-udeps
Expand All @@ -315,7 +315,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: cargo-audit
- run: cargo audit -D warnings
Expand All @@ -340,7 +340,7 @@ jobs:
pattern: coverage-profraw-*
path: coverage/profraw
merge-multiple: true
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: cargo-llvm-cov
- uses: actions/setup-python@v5
Expand Down Expand Up @@ -431,7 +431,7 @@ jobs:
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@9b5b983efc779f85e5e5d11539f005e85ccb27ff
- uses: taiki-e/install-action@5ce83af8b5520828f63d83d98df0eea6a66c7978
with:
tool: just
- run: just check_build_public_libraries
2 changes: 1 addition & 1 deletion 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 @@ -2,7 +2,7 @@
version = "0.0.0" # managed by cargo-workspaces, see below
authors = ["Near Inc <[email protected]>"]
edition = "2021"
rust-version = "1.82.0"
rust-version = "1.83.0"
repository = "https://github.com/near/nearcore"
license = "MIT OR Apache-2.0"

Expand Down
23 changes: 10 additions & 13 deletions chain/chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1342,7 +1342,7 @@ impl Chain {
let merkle_paths =
Block::compute_chunk_headers_root(block.chunks().iter_deprecated()).1;
let merkle_proof =
merkle_paths.get(shard_index).ok_or_else(|| Error::InvalidShardId(shard_id))?;
merkle_paths.get(shard_index).ok_or(Error::InvalidShardId(shard_id))?;
let chunk_proof = ChunkProofs {
block_header: borsh::to_vec(&block.header()).expect("Failed to serialize"),
merkle_proof: merkle_proof.clone(),
Expand Down Expand Up @@ -2582,8 +2582,7 @@ impl Chain {
// Chunk header here is the same chunk header as at the `current` height.
let sync_prev_hash = sync_prev_block.hash();
let chunks = sync_prev_block.chunks();
let chunk_header =
chunks.get(prev_shard_index).ok_or_else(|| Error::InvalidShardId(shard_id))?;
let chunk_header = chunks.get(prev_shard_index).ok_or(Error::InvalidShardId(shard_id))?;
let (chunk_headers_root, chunk_proofs) = merklize(
&sync_prev_block
.chunks()
Expand All @@ -2596,10 +2595,8 @@ impl Chain {
assert_eq!(&chunk_headers_root, sync_prev_block.header().chunk_headers_root());

let chunk = self.get_chunk_clone_from_header(chunk_header)?;
let chunk_proof = chunk_proofs
.get(prev_shard_index)
.ok_or_else(|| Error::InvalidShardId(shard_id))?
.clone();
let chunk_proof =
chunk_proofs.get(prev_shard_index).ok_or(Error::InvalidShardId(shard_id))?.clone();
let block_header =
self.get_block_header_on_chain_by_height(&sync_hash, chunk_header.height_included())?;

Expand All @@ -2611,7 +2608,7 @@ impl Chain {
let prev_chunk_header = prev_block
.chunks()
.get(prev_shard_index)
.ok_or_else(|| Error::InvalidShardId(shard_id))?
.ok_or(Error::InvalidShardId(shard_id))?
.clone();
let (prev_chunk_headers_root, prev_chunk_proofs) = merklize(
&prev_block
Expand All @@ -2626,7 +2623,7 @@ impl Chain {

let prev_chunk_proof = prev_chunk_proofs
.get(prev_shard_index)
.ok_or_else(|| Error::InvalidShardId(shard_id))?
.ok_or(Error::InvalidShardId(shard_id))?
.clone();
let prev_chunk_height_included = prev_chunk_header.height_included();

Expand Down Expand Up @@ -2789,7 +2786,7 @@ impl Chain {
let state_root = prev_block
.chunks()
.get(shard_index)
.ok_or_else(|| Error::InvalidShardId(shard_id))?
.ok_or(Error::InvalidShardId(shard_id))?
.prev_state_root();
let prev_hash = *prev_block.hash();
let prev_prev_hash = *prev_block.header().prev_hash();
Expand Down Expand Up @@ -3400,7 +3397,7 @@ impl Chain {
None
}
})
.unwrap_or_else(|| FinalExecutionStatus::Started)
.unwrap_or(FinalExecutionStatus::Started)
}

/// Collect all the execution outcomes existing at the current moment
Expand Down Expand Up @@ -3675,7 +3672,7 @@ impl Chain {
let chunk_header = block
.chunks()
.get(shard_index)
.ok_or_else(|| Error::InvalidShardId(shard_id))?
.ok_or(Error::InvalidShardId(shard_id))?
.clone();
invalid_chunks.push(chunk_header);
}
Expand Down Expand Up @@ -4230,7 +4227,7 @@ impl Chain {
for &shard_id in shard_ids.iter() {
let shard_index = shard_layout.get_shard_index(shard_id)?;
let chunk_header =
&chunks.get(shard_index).ok_or_else(|| Error::InvalidShardId(shard_id))?;
&chunks.get(shard_index).ok_or(Error::InvalidShardId(shard_id))?;
if chunk_header.height_included() == block.header().height() {
return Ok(Some((block_hash, shard_id)));
}
Expand Down
8 changes: 5 additions & 3 deletions chain/chain/src/resharding/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,10 @@ impl ReshardingManager {
.store
.get_ser(DBCol::ChunkExtra, &key)
.map_err(|e| Error::DBNotFoundErr(e.to_string()))?;
value.ok_or(Error::DBNotFoundErr(
format_args!("CHUNK EXTRA: {}:{:?}", block_hash, shard_uid).to_string(),
))
value.ok_or_else(|| {
Error::DBNotFoundErr(
format_args!("CHUNK EXTRA: {}:{:?}", block_hash, shard_uid).to_string(),
)
})
}
}
4 changes: 2 additions & 2 deletions chain/chain/src/store/merkle_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ impl MerkleProofAccess for Store {
}

fn get_block_hash_from_ordinal(&self, block_ordinal: NumBlocks) -> Result<CryptoHash, Error> {
self.get_ser::<CryptoHash>(DBCol::BlockOrdinal, &index_to_bytes(block_ordinal))?.ok_or(
Error::Other(format!("Could not find block hash from ordinal {}", block_ordinal)),
self.get_ser::<CryptoHash>(DBCol::BlockOrdinal, &index_to_bytes(block_ordinal))?.ok_or_else(
|| Error::Other(format!("Could not find block hash from ordinal {}", block_ordinal)),
)
}
}
Expand Down
6 changes: 1 addition & 5 deletions chain/chain/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,7 @@ pub trait ChainStoreAccess {
let mut shard_index = shard_layout.get_shard_index(shard_id)?;
loop {
let block_header = self.get_block_header(&candidate_hash)?;
if *block_header
.chunk_mask()
.get(shard_index)
.ok_or_else(|| Error::InvalidShardId(shard_id))?
{
if *block_header.chunk_mask().get(shard_index).ok_or(Error::InvalidShardId(shard_id))? {
break Ok(*block_header.epoch_id());
}
candidate_hash = *block_header.prev_hash();
Expand Down
14 changes: 6 additions & 8 deletions chain/chain/src/test_utils/kv_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,8 @@ impl MockEpochManager {
if prev_hash == CryptoHash::default() {
return Ok((EpochId(prev_hash), 0, EpochId(prev_hash)));
}
let prev_block_header = self
.get_block_header(&prev_hash)?
.ok_or_else(|| EpochError::MissingBlock(prev_hash))?;
let prev_block_header =
self.get_block_header(&prev_hash)?.ok_or(EpochError::MissingBlock(prev_hash))?;

let mut hash_to_epoch = self.hash_to_epoch.write().unwrap();
let mut hash_to_next_epoch_approvals_req =
Expand Down Expand Up @@ -303,7 +302,7 @@ impl MockEpochManager {
.read()
.unwrap()
.get(epoch_id)
.ok_or_else(|| EpochError::EpochOutOfBounds(*epoch_id))? as usize
.ok_or(EpochError::EpochOutOfBounds(*epoch_id))? as usize
% self.validators_by_valset.len())
}

Expand Down Expand Up @@ -581,9 +580,8 @@ impl EpochManagerAdapter for MockEpochManager {
if parent_hash == &CryptoHash::default() {
return Ok(true);
}
let prev_block_header = self
.get_block_header(parent_hash)?
.ok_or_else(|| EpochError::MissingBlock(*parent_hash))?;
let prev_block_header =
self.get_block_header(parent_hash)?.ok_or(EpochError::MissingBlock(*parent_hash))?;
let prev_prev_hash = *prev_block_header.prev_hash();
Ok(self.get_epoch_and_valset(*parent_hash)?.0
!= self.get_epoch_and_valset(prev_prev_hash)?.0)
Expand Down Expand Up @@ -693,7 +691,7 @@ impl EpochManagerAdapter for MockEpochManager {
loop {
let header = self
.get_block_header(&candidate_hash)?
.ok_or_else(|| EpochError::MissingBlock(candidate_hash))?;
.ok_or(EpochError::MissingBlock(candidate_hash))?;
candidate_hash = *header.prev_hash();
if self.is_next_block_epoch_start(&candidate_hash)? {
break Ok(self.get_epoch_and_valset(candidate_hash)?.0);
Expand Down
6 changes: 3 additions & 3 deletions chain/client/src/chunk_inclusion_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ impl ChunkInclusionTracker {

fn get_chunk_info(&self, chunk_hash: &ChunkHash) -> Result<&ChunkInfo, Error> {
// It should never happen that we are missing the key in chunk_hash_to_chunk_info
self.chunk_hash_to_chunk_info
.get(chunk_hash)
.ok_or(Error::Other(format!("missing key {:?} in ChunkInclusionTracker", chunk_hash)))
self.chunk_hash_to_chunk_info.get(chunk_hash).ok_or_else(|| {
Error::Other(format!("missing key {:?} in ChunkInclusionTracker", chunk_hash))
})
}

pub fn get_chunk_header_and_endorsements(
Expand Down
6 changes: 2 additions & 4 deletions chain/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,12 +747,10 @@ impl Client {
*chunk_header.height_included_mut() = height;
*chunk_headers
.get_mut(shard_index)
.ok_or_else(|| near_chain_primitives::Error::InvalidShardId(shard_id))? =
chunk_header;
.ok_or(near_chain_primitives::Error::InvalidShardId(shard_id))? = chunk_header;
*chunk_endorsements
.get_mut(shard_index)
.ok_or_else(|| near_chain_primitives::Error::InvalidShardId(shard_id))? =
chunk_endorsement;
.ok_or(near_chain_primitives::Error::InvalidShardId(shard_id))? = chunk_endorsement;
}

let prev_header = &prev_block.header();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ impl Client {
let shard_id = chunk_header.shard_id();
let _span = tracing::debug_span!(target: "client", "send_chunk_state_witness", chunk_hash=?chunk_header.chunk_hash(), ?shard_id).entered();

let my_signer =
validator_signer.as_ref().ok_or(Error::NotAValidator(format!("send state witness")))?;
let my_signer = validator_signer
.as_ref()
.ok_or_else(|| Error::NotAValidator(format!("send state witness")))?;
let CreateWitnessResult { state_witness, main_transition_shard_id, contract_updates } =
self.create_state_witness(
my_signer.validator_id().clone(),
Expand Down Expand Up @@ -389,7 +390,7 @@ impl Client {
let from_chunk_hash = from_block
.chunks()
.get(from_shard_index)
.ok_or_else(|| Error::InvalidShardId(proof.1.from_shard_id))?
.ok_or(Error::InvalidShardId(proof.1.from_shard_id))?
.chunk_hash();
let insert_res =
source_receipt_proofs.insert(from_chunk_hash.clone(), proof.clone());
Expand Down
Loading

0 comments on commit e02eed8

Please sign in to comment.