From 537d29068807dc2db8e193615e9279d2d2917ea9 Mon Sep 17 00:00:00 2001 From: Bohdan Khorolets Date: Thu, 20 Jun 2024 15:54:59 +0300 Subject: [PATCH] adapt codebase to newer dependencies --- Cargo.lock | 1 + Cargo.toml | 1 + rpc-server/Cargo.toml | 1 + rpc-server/src/modules/network/methods.rs | 18 +++++-- rpc-server/src/modules/network/mod.rs | 1 + .../queries/contract_runner/code_storage.rs | 48 ++++++++++++++----- 6 files changed, 54 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index eafd4516..e707c6c1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6557,6 +6557,7 @@ dependencies = [ "lazy_static", "lru 0.12.3", "mimalloc", + "near-async", "near-chain-configs 1.40.0", "near-crypto 1.40.0", "near-indexer-primitives", diff --git a/Cargo.toml b/Cargo.toml index 1cada766..9c59624e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,7 @@ readnode-primitives = { path = "readnode-primitives" } epoch-indexer = { path = "epoch-indexer" } # Please, update the supported nearcore version in .cargo/config.toml file +near-async = { git = 'https://github.com/kobayurii/nearcore.git', branch = "1.40.0-fork" } near-indexer = { git = 'https://github.com/kobayurii/nearcore.git', branch = "1.40.0-fork" } near-client = { git = 'https://github.com/kobayurii/nearcore.git', branch = "1.40.0-fork" } near-o11y = { git = 'https://github.com/kobayurii/nearcore.git', branch = "1.40.0-fork" } diff --git a/rpc-server/Cargo.toml b/rpc-server/Cargo.toml index 3f6fe022..3f6ba263 100644 --- a/rpc-server/Cargo.toml +++ b/rpc-server/Cargo.toml @@ -43,6 +43,7 @@ configuration.workspace = true database.workspace = true readnode-primitives.workspace = true +near-async.workspace = true near-chain-configs.workspace = true near-crypto.workspace = true near-jsonrpc.workspace = true diff --git a/rpc-server/src/modules/network/methods.rs b/rpc-server/src/modules/network/methods.rs index 65922e52..01ce5127 100644 --- a/rpc-server/src/modules/network/methods.rs +++ b/rpc-server/src/modules/network/methods.rs @@ -53,14 +53,20 @@ pub async fn status( latest_block_hash: final_block.block_hash, latest_block_height: final_block.block_height, latest_state_root: final_block.state_root, - latest_block_time: near_primitives::utils::from_timestamp(final_block.block_timestamp), - // Always false because read_node is not need to sync + latest_block_time: near_async::time::Utc::from_unix_timestamp_nanos( + final_block.block_timestamp as i128, + ) + .unwrap(), + // Always false because read-rpc does not need to sync syncing: false, earliest_block_hash: Some(data.genesis_info.genesis_block_cache.block_hash), earliest_block_height: Some(data.genesis_info.genesis_block_cache.block_height), - earliest_block_time: Some(near_primitives::utils::from_timestamp( - data.genesis_info.genesis_block_cache.block_timestamp, - )), + earliest_block_time: Some( + near_async::time::Utc::from_unix_timestamp_nanos( + data.genesis_info.genesis_block_cache.block_timestamp as i128, + ) + .unwrap(), + ), epoch_id: Some(near_primitives::types::EpochId(final_block.epoch_id)), epoch_start_height: Some(validators.epoch_start_height), }, @@ -73,6 +79,7 @@ pub async fn status( uptime_sec: chrono::Utc::now().timestamp() - data.boot_time_seconds, // Not using for status method detailed_debug_status: None, + genesis_hash: data.genesis_info.genesis_block_cache.block_hash, }) } @@ -369,6 +376,7 @@ async fn protocol_config_call( fees: runtime_config.fees.clone(), wasm_config: runtime_config.wasm_config.clone(), account_creation_config: runtime_config.account_creation_config.clone(), + storage_proof_size_soft_limit: runtime_config.storage_proof_size_soft_limit, }, }; protocol_config.into() diff --git a/rpc-server/src/modules/network/mod.rs b/rpc-server/src/modules/network/mod.rs index 0155f8a7..f6c9097b 100644 --- a/rpc-server/src/modules/network/mod.rs +++ b/rpc-server/src/modules/network/mod.rs @@ -24,6 +24,7 @@ pub async fn epoch_config_from_protocol_config_view( num_chunk_only_producer_seats: protocol_config_view.num_chunk_only_producer_seats, minimum_validators_per_shard: protocol_config_view.minimum_validators_per_shard, minimum_stake_ratio: protocol_config_view.minimum_stake_ratio, + ..Default::default() }, validator_max_kickout_stake_perc: protocol_config_view.max_kickout_stake_perc, } diff --git a/rpc-server/src/modules/queries/contract_runner/code_storage.rs b/rpc-server/src/modules/queries/contract_runner/code_storage.rs index ecd86267..3762f5d6 100644 --- a/rpc-server/src/modules/queries/contract_runner/code_storage.rs +++ b/rpc-server/src/modules/queries/contract_runner/code_storage.rs @@ -196,17 +196,17 @@ impl near_vm_runner::logic::External for CodeStorage { Ok(self.validators.values().sum()) } - fn create_receipt( - &mut self, - _receipt_indices: Vec, - _receiver_id: near_primitives::types::AccountId, - ) -> Result { - Err(near_vm_runner::logic::VMLogicError::HostError( - near_vm_runner::logic::HostError::ProhibitedInView { - method_name: String::from("create_receipt"), - }, - )) - } + // fn create_receipt( + // &mut self, + // _receipt_indices: Vec, + // _receiver_id: near_primitives::types::AccountId, + // ) -> Result { + // Err(near_vm_runner::logic::VMLogicError::HostError( + // near_vm_runner::logic::HostError::ProhibitedInView { + // method_name: String::from("create_receipt"), + // }, + // )) + // } fn append_action_create_account( &mut self, @@ -292,4 +292,30 @@ impl near_vm_runner::logic::External for CodeStorage { ) -> &near_primitives::types::AccountId { panic!("Prohibited in view. `get_receipt_receiver`"); } + + fn create_action_receipt( + &mut self, + _receipt_indices: Vec, + _receiver_id: near_primitives::types::AccountId, + ) -> Result { + panic!("Prohibited in view. `create_action_receipt`"); + } + + fn create_promise_yield_receipt( + &mut self, + _receiver_id: near_primitives::types::AccountId, + ) -> Result<( + near_vm_runner::logic::types::ReceiptIndex, + near_indexer_primitives::CryptoHash, + )> { + panic!("Prohibited in view. `create_promise_yield_receipt`"); + } + + fn submit_promise_resume_data( + &mut self, + _data_id: near_indexer_primitives::CryptoHash, + _data: Vec, + ) -> Result { + panic!("Prohibited in view. `submit_promise_resume_data`"); + } }