go-spacemesh
go-spacemesh copied to clipboard
vm: include nonce in self-spawn txs
nonce was implicitly decoded by parse_payload of the template as 0. it leads to hairy edge cases if self-spawn fails but got consumed.
also enables https://github.com/spacemeshos/go-spacemesh/issues/3339
See discussion thread in https://github.com/spacemeshos/go-spacemesh/issues/3272
btw the only time when self spawn can get consumed without spawning account is due to https://github.com/spacemeshos/go-spacemesh/issues/3391
How would this work? I don't understand how a nonce can be consumed on a failed self-spawn - if it failed there's no account that can track the nonce.
To be clear: stubs should only have a balance. Even if we implement simple nonces for genesis, we want to be consistent with the eventual design, where each template might handle nonces differently - tracking nonces on stubs breaks that.
This only happens in one narrow case: the stub exists, and it has enough funds to cover the gas for verify, and verify passes, but not enough gas to cover the cost of the actual spawn. In this case, the stub should have a nonce and it should be no issue to increment it. See https://community.spacemesh.io/t/corner-case-ineffective-self-spawn-tx/287.