Skip to content

Commit

Permalink
adapt codebase to newer dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
khorolets committed Jun 20, 2024
1 parent ee7104b commit 1aade9a
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 17 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
1 change: 1 addition & 0 deletions rpc-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions rpc-server/src/modules/network/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
Expand All @@ -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,
})
}

Expand Down Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions rpc-server/src/modules/network/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ 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,
shuffle_shard_assignment_for_chunk_producers: protocol_config_view
.shuffle_shard_assignment_for_chunk_producers,
},
validator_max_kickout_stake_perc: protocol_config_view.max_kickout_stake_perc,
}
Expand Down
38 changes: 26 additions & 12 deletions rpc-server/src/modules/queries/contract_runner/code_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,6 @@ impl near_vm_runner::logic::External for CodeStorage {
Ok(self.validators.values().sum())
}

fn create_receipt(
&mut self,
_receipt_indices: Vec<near_vm_runner::logic::types::ReceiptIndex>,
_receiver_id: near_primitives::types::AccountId,
) -> Result<near_vm_runner::logic::types::ReceiptIndex> {
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,
_receipt_index: near_vm_runner::logic::types::ReceiptIndex,
Expand Down Expand Up @@ -292,4 +280,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<near_vm_runner::logic::types::ReceiptIndex>,
_receiver_id: near_primitives::types::AccountId,
) -> Result<near_vm_runner::logic::types::ReceiptIndex> {
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<u8>,
) -> Result<bool> {
panic!("Prohibited in view. `submit_promise_resume_data`");
}
}

0 comments on commit 1aade9a

Please sign in to comment.