What does Response for View Function request look like? Does Validator give any prooves that the execution was done correctly?

  • You don't need to execute a view function in a transaction, since no mining is required. You can simply call it. Jan 5 at 12:12
  • 1
    @goodvibration I (as a client) ask the Validator to execute it. Are there any prooves that he read the correct blockchain state? Jan 5 at 12:29
  • An RPC always reads the correct blockchain state as far as I know (and you can even specify a block number, to get the result at that specific point in time (though that requires an archive node)). Jan 5 at 13:00
  • @goodvibration But what if the Validator is fault? Jan 5 at 15:01

In theory it is possible to prove that the result of a view function is accurate at the time of a certain block number, without running a full node. The technique is similar to Bitcoin's SPV.

Note that the problem is not the entire execution of the view function's code, but fetching and verifying the blockchain state that is needed to execute the view function. Once you have fetched and verified the needed state, you can execute the view function locally to get the result.

First you need to fetch the block header, and verify that its hash and its proof-of-work are correct. The block header contains the state root hash: this is the hash of the roots of the trees of hashes of the entire blockchain state, including address balances, contract code and contract storage.

You need to fetch and verify the paths of hashes through these trees for every piece of chain state accessed by the view function.

Then you can execute the view function locally and be certain about its value, without having to trust anyone.

Unfortunately I don't know if there are any libraries or API's that make this easy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.