1

What are the technical differences between offchain views vs onchain entry points? I know one of the differences is that onchain entry points mutate while offchain views don't. Are there any other differences or guarantees?

The reason I'm asking is because I'm trying to figure out whether something like this would work:

Currently I have 2 contracts. 1 FA2 token one and the other 1 that manages data based on the ownership of a specific token. My particular concern is about potential race conditions that happen while the ownership of a token is transferred.

Scenario where Owner A sells token to Owner B. At the same time owner A invokes a function in the other contract which calls an offchain view to check the ownership. Is it possible for the other contract to continue with the operation if by that point the token had already changed hands? Also, is there a better way of checking for ownership in such a scenario?

1 Answer 1

3

You basically have no guarantee of synchronicity for several reasons.

  1. We’re talking about a blockchain with no instant finality (yet) so a transaction can be “reversed” in the (real world) future so when you send a transaction, you don’t know if it will still be there in 30 or 1000 blocks.
  2. Off chain views use a node that may or may not be synchronized with the blockchain (whatever this may mean, related to 1). So the off chain view may be lagging, leading or in an incompatible state compared to what you sent as a transaction.
  3. Off chain views somewhat require more trust than regular transactions: you know that at one point, you can trust your transaction if it remains in a long valid chain. For off chain views, you need to trust the node instantly.

What is magical is that these concerns do not really depend on off chain views. These are direct concerns associated with interacting with a blockchain.

What can be done?

  1. Having a decent infrastructure to somewhat build trust for your node.
  2. Designing your contract so that consequences of interactions are self verifying in the future (ensuring that a mistake in the off chain views has no material consequences).
  3. When you interact with entry points, you point to a recent block and basically say “I’m comfortable with this transaction if this block is valid”. There is no such thing by default with off chain views but it only depends on users to implement those as well.
2
  • 1
    are offchain views described on a whitepaper somewhere? just curious to learn more about the low level details if possible
    – JJJ
    Apr 11, 2021 at 17:19
  • 1
    They are defined in tzip.tezosagora.org/proposal/tzip-16. There is also a very nice explorer and other resources: tzcomet.io/#/explorer.
    – FFF
    Apr 11, 2021 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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