diff --git a/substrate/client/service/src/client/client.rs b/substrate/client/service/src/client/client.rs
index 6a75fad628681640bf2fb628f5f1e593a0888b37..4b28b39931756b5bfaadfb63c9009f6fec1dda5b 100644
--- a/substrate/client/service/src/client/client.rs
+++ b/substrate/client/service/src/client/client.rs
@@ -481,8 +481,7 @@ where
 	}
 
 	/// Get the code at a given block.
-	pub fn code_at(&self, id: &BlockId<Block>) -> sp_blockchain::Result<Vec<u8>> {
-		let hash = self.backend.blockchain().expect_block_hash_from_id(id)?;
+	pub fn code_at(&self, hash: Block::Hash) -> sp_blockchain::Result<Vec<u8>> {
 		Ok(StorageProvider::storage(self, hash, &StorageKey(well_known_keys::CODE.to_vec()))?
 			.expect(
 				"None is returned if there's no value stored for the given key;\
@@ -1746,9 +1745,8 @@ where
 		CallExecutor::runtime_version(&self.executor, hash).map_err(Into::into)
 	}
 
-	fn state_at(&self, at: &BlockId<Block>) -> Result<Self::StateBackend, sp_api::ApiError> {
-		let hash = self.backend.blockchain().expect_block_hash_from_id(at)?;
-		self.state_at(hash).map_err(Into::into)
+	fn state_at(&self, at: Block::Hash) -> Result<Self::StateBackend, sp_api::ApiError> {
+		self.state_at(at).map_err(Into::into)
 	}
 }
 
diff --git a/substrate/primitives/api/src/lib.rs b/substrate/primitives/api/src/lib.rs
index 4ff4becb80f482c2dafe84693242244b253d6039..ad9a9b18118599398976a131b02dcf2b70e37cbd 100644
--- a/substrate/primitives/api/src/lib.rs
+++ b/substrate/primitives/api/src/lib.rs
@@ -622,7 +622,7 @@ pub trait CallApiAt<Block: BlockT> {
 	fn runtime_version_at(&self, at: &BlockId<Block>) -> Result<RuntimeVersion, ApiError>;
 
 	/// Get the state `at` the given block.
-	fn state_at(&self, at: &BlockId<Block>) -> Result<Self::StateBackend, ApiError>;
+	fn state_at(&self, at: Block::Hash) -> Result<Self::StateBackend, ApiError>;
 }
 
 /// Auxiliary wrapper that holds an api instance and binds it to the given lifetime.
diff --git a/substrate/primitives/api/test/tests/runtime_calls.rs b/substrate/primitives/api/test/tests/runtime_calls.rs
index 2ac88c7e6c04f8492bf259ffe3f2d311ddbfc276..3d355c474773640923440c08f47e05b3f48cfbcb 100644
--- a/substrate/primitives/api/test/tests/runtime_calls.rs
+++ b/substrate/primitives/api/test/tests/runtime_calls.rs
@@ -147,13 +147,12 @@ fn record_proof_works() {
 		.set_execution_strategy(ExecutionStrategy::Both)
 		.build_with_longest_chain();
 
-	let block_id = BlockId::Number(client.chain_info().best_number);
 	let storage_root =
 		*futures::executor::block_on(longest_chain.best_chain()).unwrap().state_root();
 
 	let runtime_code = sp_core::traits::RuntimeCode {
 		code_fetcher: &sp_core::traits::WrappedRuntimeCode(
-			client.code_at(&block_id).unwrap().into(),
+			client.code_at(client.chain_info().best_hash).unwrap().into(),
 		),
 		hash: vec![1],
 		heap_pages: None,
@@ -167,6 +166,7 @@ fn record_proof_works() {
 	}
 	.into_signed_tx();
 
+	let block_id = BlockId::Hash(client.chain_info().best_hash);
 	// Build the block and record proof
 	let mut builder = client
 		.new_block_at(&block_id, Default::default(), true)