Replies: 2 comments 1 reply
-
Thanks for the questions.
The API will tell you when there's a reorg. This should be a distinct event and it should tell you the layer as of which the reorg occurred. In order to figure out which transactions are valid, and to know the canonical state of the chain after this point, you (as a client) should assume nothing and walk the entire chain forward since the point of the reorg. After the reorg event appears in the API you may also query the current state of a particular account or transaction and assume that this has been updated as well. (CC @kacpersaw) You'd know there's been a reorg if the "state hash" for a layer changed, and/or if the canonical block ID for a given layer changed. Please also see https://github.com/spacemeshos/wiki/wiki/Integration-guide#reorgs-and-canonicity.
In case of a reorg it's not safe to assume anything, other than that anything may have changed. Some txs may have been invalidated, other new ones may have appeared, etc. Unlike a chain-based protocol like Bitcoin, it's not the case that, in case of a reorg in Spacemesh, all intervening blocks and transactions are immediately invaliated.
Blocks in Spacemesh don't appear at random times as in Bitcoin. Instead Spacemesh miners cooperate to produce blocks deterministically and predictably, once each layer. The only way competing blocks could appear "at the same time" is if there's an attack or a serious, temporary violation of security assumptions such as a long-lived chain split. So, no, frequent short reorgs should definitely not happen on Spacemesh the way they do on other chains. As in Bitcoin there's no theoretical limit to how long a reorg could be - there could theoretically always be a longer chain that you're not aware of. As in Bitcoin, however, in practical terms the likelihood of this happening falls rapidly with each new layer that appears.
A transaction may be included multiple times in multiple blocks, including in different layers and including after a reorg, but it will only be applied (i.e., will only be effective) the first time it appears: Lines 239 to 256 in a2cdfd3 Regarding "other implications" - you may thus safely assume that a tx will never be executed twice, even after a reorg. But as I said above you can't make many other assumptions after a reorg. Blocks may or may not be invalidated, new blocks may appear, txs may or may not be ineffective and new ones may appear, etc. HTH, let us know if you have other questions! |
Beta Was this translation helpful? Give feedback.
-
I'll close this for now but feel free to reopen if there are other questions |
Beta Was this translation helpful? Give feedback.
-
Hey, community. I've been wondering to understand how spacemesh reorganisations differ from blockchains like ethereum or bitcoin. I have several questions and would be grateful if somebody responds on them.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions