From 3c7177bb9df42686eb76b9c2c6bf02fff2ce9a51 Mon Sep 17 00:00:00 2001 From: Marcelo Diop-Gonzalez Date: Thu, 10 Oct 2024 09:58:39 -0400 Subject: [PATCH] 2.3.0 (#12201) bump version string and cherry pick https://github.com/near/nearcore/pull/12197 --------- Co-authored-by: Saketh Are --- Cargo.lock | 178 +++++++++--------- Cargo.toml | 2 +- chain/chain/src/chain.rs | 40 +--- chain/client/src/view_client_actor.rs | 30 +-- core/primitives/src/state_sync.rs | 5 +- .../src/tests/client/sync_state_nodes.rs | 43 +---- 6 files changed, 101 insertions(+), 197 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac3b6884d64..318d28e62a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1321,7 +1321,7 @@ checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "chainsync-loadtest" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "anyhow", @@ -1485,7 +1485,7 @@ dependencies = [ [[package]] name = "cold-store-tool" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "borsh 1.2.0", @@ -1518,7 +1518,7 @@ dependencies = [ [[package]] name = "congestion-model" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "bytesize", "chrono", @@ -2360,7 +2360,7 @@ dependencies = [ [[package]] name = "estimator-warehouse" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "chrono", @@ -2762,7 +2762,7 @@ dependencies = [ [[package]] name = "genesis-csv-to-json" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "chrono", "clap", @@ -2779,7 +2779,7 @@ dependencies = [ [[package]] name = "genesis-populate" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "borsh 1.2.0", "clap", @@ -3194,7 +3194,7 @@ dependencies = [ [[package]] name = "indexer-example" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "anyhow", @@ -3269,7 +3269,7 @@ dependencies = [ [[package]] name = "integration-tests" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "actix-rt", @@ -3418,7 +3418,7 @@ checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" [[package]] name = "keypair-generator" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "clap", "near-crypto", @@ -3852,7 +3852,7 @@ dependencies = [ [[package]] name = "mock-node" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "actix-rt", @@ -3922,7 +3922,7 @@ dependencies = [ [[package]] name = "near-actix-test-utils" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix-rt", "near-store", @@ -3930,7 +3930,7 @@ dependencies = [ [[package]] name = "near-amend-genesis" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "borsh 1.2.0", @@ -3949,7 +3949,7 @@ dependencies = [ [[package]] name = "near-async" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "derive-enum-from-into", @@ -3970,7 +3970,7 @@ dependencies = [ [[package]] name = "near-async-derive" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "pretty_assertions", "proc-macro2", @@ -3980,7 +3980,7 @@ dependencies = [ [[package]] name = "near-cache" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "bencher", "lru 0.12.3", @@ -3989,7 +3989,7 @@ dependencies = [ [[package]] name = "near-chain" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "assert_matches", @@ -4040,7 +4040,7 @@ dependencies = [ [[package]] name = "near-chain-configs" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "bytesize", @@ -4063,7 +4063,7 @@ dependencies = [ [[package]] name = "near-chain-primitives" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "near-crypto", "near-primitives", @@ -4075,7 +4075,7 @@ dependencies = [ [[package]] name = "near-chunks" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "assert_matches", @@ -4108,7 +4108,7 @@ dependencies = [ [[package]] name = "near-chunks-primitives" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "near-chain-primitives", "near-primitives", @@ -4116,7 +4116,7 @@ dependencies = [ [[package]] name = "near-client" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "actix-rt", @@ -4175,7 +4175,7 @@ dependencies = [ [[package]] name = "near-client-primitives" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "chrono", @@ -4196,7 +4196,7 @@ dependencies = [ [[package]] name = "near-config-utils" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "json_comments", @@ -4206,7 +4206,7 @@ dependencies = [ [[package]] name = "near-crypto" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "blake2", "bolero", @@ -4234,7 +4234,7 @@ dependencies = [ [[package]] name = "near-database-tool" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "borsh 1.2.0", @@ -4260,7 +4260,7 @@ dependencies = [ [[package]] name = "near-dyn-configs" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "near-chain-configs", @@ -4278,7 +4278,7 @@ dependencies = [ [[package]] name = "near-epoch-manager" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "borsh 1.2.0", "chrono", @@ -4304,7 +4304,7 @@ dependencies = [ [[package]] name = "near-flat-storage" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "borsh 1.2.0", @@ -4322,14 +4322,14 @@ dependencies = [ [[package]] name = "near-fmt" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "near-primitives-core", ] [[package]] name = "near-fork-network" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "anyhow", @@ -4355,7 +4355,7 @@ dependencies = [ [[package]] name = "near-indexer" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "anyhow", @@ -4381,7 +4381,7 @@ dependencies = [ [[package]] name = "near-indexer-primitives" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "near-primitives", "serde", @@ -4390,7 +4390,7 @@ dependencies = [ [[package]] name = "near-jsonrpc" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "actix-cors", @@ -4420,7 +4420,7 @@ dependencies = [ [[package]] name = "near-jsonrpc-adversarial-primitives" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "near-primitives", "serde", @@ -4428,7 +4428,7 @@ dependencies = [ [[package]] name = "near-jsonrpc-client" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix-http", "awc", @@ -4441,7 +4441,7 @@ dependencies = [ [[package]] name = "near-jsonrpc-fuzz" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "arbitrary", @@ -4459,7 +4459,7 @@ dependencies = [ [[package]] name = "near-jsonrpc-primitives" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "arbitrary", "near-chain-configs", @@ -4475,7 +4475,7 @@ dependencies = [ [[package]] name = "near-jsonrpc-tests" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "awc", @@ -4499,7 +4499,7 @@ dependencies = [ [[package]] name = "near-mainnet-res" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "near-account-id", "near-chain-configs", @@ -4509,7 +4509,7 @@ dependencies = [ [[package]] name = "near-mirror" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "actix-rt", @@ -4554,7 +4554,7 @@ dependencies = [ [[package]] name = "near-network" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "anyhow", @@ -4615,7 +4615,7 @@ dependencies = [ [[package]] name = "near-o11y" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "base64 0.21.0", @@ -4644,7 +4644,7 @@ dependencies = [ [[package]] name = "near-parameters" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "assert_matches", "borsh 1.2.0", @@ -4664,7 +4664,7 @@ dependencies = [ [[package]] name = "near-performance-metrics" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "bitflags 1.3.2", @@ -4679,7 +4679,7 @@ dependencies = [ [[package]] name = "near-performance-metrics-macros" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "quote", "syn 2.0.70", @@ -4687,7 +4687,7 @@ dependencies = [ [[package]] name = "near-ping" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix-web", "anyhow", @@ -4705,7 +4705,7 @@ dependencies = [ [[package]] name = "near-pool" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "borsh 1.2.0", "near-crypto", @@ -4716,7 +4716,7 @@ dependencies = [ [[package]] name = "near-primitives" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "arbitrary", "assert_matches", @@ -4764,7 +4764,7 @@ dependencies = [ [[package]] name = "near-primitives-core" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "arbitrary", "base64 0.21.0", @@ -4786,7 +4786,7 @@ dependencies = [ [[package]] name = "near-replay-archive-tool" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "borsh 1.2.0", @@ -4808,7 +4808,7 @@ dependencies = [ [[package]] name = "near-rosetta-rpc" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "actix-cors", @@ -4841,14 +4841,14 @@ dependencies = [ [[package]] name = "near-schema-checker-core" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "inventory", ] [[package]] name = "near-schema-checker-lib" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "inventory", "near-schema-checker-core", @@ -4857,7 +4857,7 @@ dependencies = [ [[package]] name = "near-schema-checker-macro" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "proc-macro2", "quote", @@ -4866,11 +4866,11 @@ dependencies = [ [[package]] name = "near-stable-hasher" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" [[package]] name = "near-state-parts" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "chrono", @@ -4889,7 +4889,7 @@ dependencies = [ [[package]] name = "near-state-parts-dump-check" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "actix-web", @@ -4911,11 +4911,11 @@ dependencies = [ [[package]] name = "near-stdx" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" [[package]] name = "near-store" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "actix-rt", @@ -4963,7 +4963,7 @@ dependencies = [ [[package]] name = "near-telemetry" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "awc", @@ -4981,7 +4981,7 @@ dependencies = [ [[package]] name = "near-test-contracts" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "arbitrary", "rand", @@ -4992,7 +4992,7 @@ dependencies = [ [[package]] name = "near-time" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "serde", "serde_json", @@ -5002,7 +5002,7 @@ dependencies = [ [[package]] name = "near-undo-block" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "chrono", @@ -5018,7 +5018,7 @@ dependencies = [ [[package]] name = "near-vm-compiler" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "enumset", "finite-wasm", @@ -5034,7 +5034,7 @@ dependencies = [ [[package]] name = "near-vm-compiler-singlepass" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "dynasm 2.0.0", "dynasmrt 2.0.0", @@ -5055,7 +5055,7 @@ dependencies = [ [[package]] name = "near-vm-compiler-test-derive" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "pretty_assertions", "proc-macro2", @@ -5066,7 +5066,7 @@ dependencies = [ [[package]] name = "near-vm-engine" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "backtrace", "cfg-if 1.0.0", @@ -5087,7 +5087,7 @@ dependencies = [ [[package]] name = "near-vm-runner" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "arbitrary", @@ -5161,7 +5161,7 @@ dependencies = [ [[package]] name = "near-vm-runner-fuzz" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "arbitrary", "libfuzzer-sys", @@ -5175,7 +5175,7 @@ dependencies = [ [[package]] name = "near-vm-test-api" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "cfg-if 1.0.0", @@ -5204,14 +5204,14 @@ dependencies = [ [[package]] name = "near-vm-test-generator" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", ] [[package]] name = "near-vm-types" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "bolero", "indexmap 1.9.2", @@ -5222,7 +5222,7 @@ dependencies = [ [[package]] name = "near-vm-vm" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "backtrace", "cc", @@ -5242,7 +5242,7 @@ dependencies = [ [[package]] name = "near-vm-wast" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "near-vm-test-api", @@ -5252,7 +5252,7 @@ dependencies = [ [[package]] name = "near-wallet-contract" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "near-primitives-core", @@ -5261,7 +5261,7 @@ dependencies = [ [[package]] name = "nearcore" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "actix-rt", @@ -5328,7 +5328,7 @@ dependencies = [ [[package]] name = "neard" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "anyhow", @@ -5399,7 +5399,7 @@ dependencies = [ [[package]] name = "node-runtime" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "assert_matches", "borsh 1.2.0", @@ -6319,7 +6319,7 @@ dependencies = [ [[package]] name = "protocol-schema-check" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "inventory", "near-chain", @@ -6648,7 +6648,7 @@ dependencies = [ [[package]] name = "restaked" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "clap", "integration-tests", @@ -6753,7 +6753,7 @@ dependencies = [ [[package]] name = "runtime-params-estimator" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "borsh 1.2.0", @@ -6794,7 +6794,7 @@ dependencies = [ [[package]] name = "runtime-tester" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "bolero", "cpu-time", @@ -6821,7 +6821,7 @@ dependencies = [ [[package]] name = "runtime-tester-fuzz" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "libfuzzer-sys", "runtime-tester", @@ -7440,7 +7440,7 @@ dependencies = [ [[package]] name = "speedy_sync" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "borsh 1.2.0", "clap", @@ -7482,7 +7482,7 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "state-viewer" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "actix", "anyhow", @@ -7532,7 +7532,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "storage-usage-delta-calculator" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "near-chain-configs", @@ -7547,7 +7547,7 @@ dependencies = [ [[package]] name = "store-validator" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "clap", "near-chain", @@ -7724,7 +7724,7 @@ dependencies = [ [[package]] name = "testlib" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "near-chain", "near-chain-configs", @@ -7737,7 +7737,7 @@ dependencies = [ [[package]] name = "themis" -version = "2.3.0-rc.1" +version = "2.3.0-rc.2" dependencies = [ "anyhow", "cargo_metadata", diff --git a/Cargo.toml b/Cargo.toml index 0d2067d4fb6..d0ba7fc448a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "2.3.0-rc.1" # managed by cargo-workspaces, see below +version = "2.3.0-rc.2" # managed by cargo-workspaces, see below authors = ["Near Inc "] edition = "2021" rust-version = "1.81.0" diff --git a/chain/chain/src/chain.rs b/chain/chain/src/chain.rs index 1be35c74e95..801d9403a39 100644 --- a/chain/chain/src/chain.rs +++ b/chain/chain/src/chain.rs @@ -34,7 +34,6 @@ use crate::{ Provenance, }; use crate::{metrics, DoomslugThresholdMode}; -use borsh::BorshDeserialize; use crossbeam_channel::{unbounded, Receiver, Sender}; use itertools::Itertools; use lru::LruCache; @@ -70,8 +69,8 @@ use near_primitives::sharding::{ }; use near_primitives::state_part::PartId; use near_primitives::state_sync::{ - get_num_state_parts, BitArray, CachedParts, ReceiptProofResponse, RootProof, - ShardStateSyncResponseHeader, ShardStateSyncResponseHeaderV2, StateHeaderKey, StatePartKey, + get_num_state_parts, ReceiptProofResponse, RootProof, ShardStateSyncResponseHeader, + ShardStateSyncResponseHeaderV2, StateHeaderKey, StatePartKey, }; use near_primitives::stateless_validation::state_witness::{ ChunkStateWitness, ChunkStateWitnessSize, @@ -3938,41 +3937,6 @@ impl Chain { Ok((make_snapshot, delete_snapshot)) } - - /// Returns a description of state parts cached for the given shard of the given epoch. - pub fn get_cached_state_parts( - &self, - sync_hash: CryptoHash, - shard_id: ShardId, - num_parts: u64, - ) -> Result { - let _span = tracing::debug_span!(target: "chain", "get_cached_state_parts").entered(); - // DBCol::StateParts is keyed by StatePartKey: (BlockHash || ShardId || PartId (u64)). - let lower_bound = StatePartKey(sync_hash, shard_id, 0); - let lower_bound = borsh::to_vec(&lower_bound)?; - let upper_bound = StatePartKey(sync_hash, shard_id + 1, 0); - let upper_bound = borsh::to_vec(&upper_bound)?; - let mut num_cached_parts = 0; - let mut bit_array = BitArray::new(num_parts); - for item in self.chain_store.store().iter_range( - DBCol::StateParts, - Some(&lower_bound), - Some(&upper_bound), - ) { - let key = item?.0; - let key = StatePartKey::try_from_slice(&key)?; - let part_id = key.2; - num_cached_parts += 1; - bit_array.set_bit(part_id); - } - Ok(if num_cached_parts == 0 { - CachedParts::NoParts - } else if num_cached_parts == num_parts { - CachedParts::AllParts - } else { - CachedParts::BitArray(bit_array) - }) - } } /// This method calculates the congestion info for the genesis chunks. It uses diff --git a/chain/client/src/view_client_actor.rs b/chain/client/src/view_client_actor.rs index b1151aba4e5..b5f12b26b9a 100644 --- a/chain/client/src/view_client_actor.rs +++ b/chain/client/src/view_client_actor.rs @@ -1358,17 +1358,6 @@ impl Handler for ViewClientActorInner { }; let state_response = match header { Some(header) => { - let num_parts = header.num_state_parts(); - let cached_parts = match self - .chain - .get_cached_state_parts(sync_hash, shard_id, num_parts) - { - Ok(cached_parts) => Some(cached_parts), - Err(err) => { - tracing::error!(target: "sync", ?err, ?sync_hash, shard_id, "Failed to get cached state parts"); - None - } - }; let header = match header { ShardStateSyncResponseHeader::V2(inner) => inner, _ => { @@ -1381,7 +1370,7 @@ impl Handler for ViewClientActorInner { ShardStateSyncResponse::V3(ShardStateSyncResponseV3 { header: Some(header), part: None, - cached_parts, + cached_parts: None, can_generate, }) } @@ -1444,26 +1433,11 @@ impl Handler for ViewClientActorInner { None } }; - let num_parts = part.as_ref().and_then(|_| match self.chain.get_state_response_header(shard_id, sync_hash) { - Ok(header) => Some(header.num_state_parts()), - Err(err) => { - tracing::error!(target: "sync", ?err, ?sync_hash, shard_id, "Failed to get num state parts"); - None - } - }); - let cached_parts = num_parts.and_then(|num_parts| - match self.chain.get_cached_state_parts(sync_hash, shard_id, num_parts) { - Ok(cached_parts) => Some(cached_parts), - Err(err) => { - tracing::error!(target: "sync", ?err, ?sync_hash, shard_id, "Failed to get cached state parts"); - None - } - }); let can_generate = part.is_some(); let state_response = ShardStateSyncResponse::V3(ShardStateSyncResponseV3 { header: None, part, - cached_parts, + cached_parts: None, can_generate, }); let info = diff --git a/core/primitives/src/state_sync.rs b/core/primitives/src/state_sync.rs index 53f3ca22f68..ceeddf337fb 100644 --- a/core/primitives/src/state_sync.rs +++ b/core/primitives/src/state_sync.rs @@ -180,11 +180,8 @@ pub struct ShardStateSyncResponseV2 { pub struct ShardStateSyncResponseV3 { pub header: Option, pub part: Option<(u64, Vec)>, - /// Parts that can be provided **cheaply**. - // Can be `None` only if both `header` and `part` are `None`. + // TODO(saketh): deprecate unused fields cached_parts and can_generate pub cached_parts: Option, - /// Whether the node can provide parts for this epoch of this shard. - /// Assumes that a node can either provide all state parts or no state parts. pub can_generate: bool, } diff --git a/integration-tests/src/tests/client/sync_state_nodes.rs b/integration-tests/src/tests/client/sync_state_nodes.rs index d7473ce51fe..0b27afb0099 100644 --- a/integration-tests/src/tests/client/sync_state_nodes.rs +++ b/integration-tests/src/tests/client/sync_state_nodes.rs @@ -18,7 +18,7 @@ use near_o11y::testonly::{init_integration_logger, init_test_logger}; use near_o11y::WithSpanContextExt; use near_primitives::shard_layout::ShardUId; use near_primitives::state_part::PartId; -use near_primitives::state_sync::{CachedParts, StatePartKey}; +use near_primitives::state_sync::StatePartKey; use near_primitives::transaction::SignedTransaction; use near_primitives::types::{BlockId, BlockReference, EpochId, EpochReference}; use near_primitives::utils::MaybeValidated; @@ -824,7 +824,6 @@ fn test_state_sync_headers() { None => return ControlFlow::Continue(()), }; let state_response = state_response_info.take_state_response(); - let cached_parts = state_response.cached_parts().clone(); let can_generate = state_response.can_generate(); assert!(state_response.part().is_none()); if let Some(_header) = state_response.take_header() { @@ -832,27 +831,14 @@ fn test_state_sync_headers() { tracing::info!( ?sync_hash, shard_id, - ?cached_parts, can_generate, "got header but cannot generate" ); return ControlFlow::Continue(()); } - tracing::info!( - ?sync_hash, - shard_id, - ?cached_parts, - can_generate, - "got header" - ); + tracing::info!(?sync_hash, shard_id, can_generate, "got header"); } else { - tracing::info!( - ?sync_hash, - shard_id, - ?cached_parts, - can_generate, - "got no header" - ); + tracing::info!(?sync_hash, shard_id, can_generate, "got no header"); return ControlFlow::Continue(()); } @@ -881,36 +867,19 @@ fn test_state_sync_headers() { let part = state_response.part().clone(); assert!(state_response.take_header().is_none()); if let Some((part_id, _part)) = part { - if !can_generate - || cached_parts != Some(CachedParts::AllParts) - || part_id != 0 - { + if !can_generate || cached_parts != None || part_id != 0 { tracing::info!( ?sync_hash, shard_id, - ?cached_parts, can_generate, part_id, "got part but shard info is unexpected" ); return ControlFlow::Continue(()); } - tracing::info!( - ?sync_hash, - shard_id, - ?cached_parts, - can_generate, - part_id, - "got part" - ); + tracing::info!(?sync_hash, shard_id, can_generate, part_id, "got part"); } else { - tracing::info!( - ?sync_hash, - shard_id, - ?cached_parts, - can_generate, - "got no part" - ); + tracing::info!(?sync_hash, shard_id, can_generate, "got no part"); return ControlFlow::Continue(()); } }