go-spacemesh icon indicating copy to clipboard operation
go-spacemesh copied to clipboard

vm: include nonce in self-spawn txs

Open dshulyak opened this issue 2 years ago • 2 comments

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

dshulyak avatar Jul 29 '22 15:07 dshulyak

See discussion thread in https://github.com/spacemeshos/go-spacemesh/issues/3272

lrettig avatar Jul 29 '22 19:07 lrettig

btw the only time when self spawn can get consumed without spawning account is due to https://github.com/spacemeshos/go-spacemesh/issues/3391

dshulyak avatar Aug 01 '22 15:08 dshulyak

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.

noamnelke avatar Aug 17 '22 08:08 noamnelke

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.

lrettig avatar Aug 17 '22 17:08 lrettig