Is it possible to retrieve the latest finalized block from a non-finalized block and its information? Using the Polkadot JS App we can check the chain state using the hash of the block, and using the Polkadot API we can retrieve the latest finalized head and proceed with some operations, but is it possible to do so from, for example, a pallet? Let's say I want to block some actions on a pallet storage until the last modification made on the same storage have been finalized.
I assume that you have a BABE+GRANDPA chain in mind.
This may be not trivial since GRANDPA, the part of the consensus protocol that is responsible for finalization, works asynchronously and also different nodes can have different views on it.
Because of that there is no such a host function that a pallet can call in the Substrate Client to ask such info. It would plainly be non-deterministic.
A block producer may include an inherent which says what was the finalized block at the time of the block creation. If done naively, however, nothing prevents block producers to cheat and put anything there.
Theoretically, the block producer may submit GRANDPA proofs on-chain where they are checked. This should solve the problem.
Practically, however, I believe Substrate doesn't support that at the moment.