spacemeshos / svm

SVM - Spacemesh Virtual Machine
https://spacemesh.io
MIT License
85 stars 14 forks source link

WIP - Extending the `Spawn Transaction` to support `Self Spawn` #468

Closed YaronWittenstein closed 2 years ago

YaronWittenstein commented 2 years ago

Depends on: #247 #467 #466

This issue extends the Spawn Transaction behavior to support the Self-Spawn mode.

Running verify as part of the Self-Spawn.

This one is a bit tricky to get right. We want to execute the verify while the Principal is in Pending State. It means it has no Storage yet and no Template attached to it.

run(`Template Address`, `svm_verify`, `Principal`, `verifydata`, `immutable storage`, `initial nonce`)

When this issue is implemented, the Immutable Storage won't exist yet. (it's left for the `Simple Coin Iteration #4).

While writing this

The amount field can be ignored (since it's a self-funding)

However, we still need to

Pseudo code:

if Principal is Active {
  * run the default flow (as today)
}
else if Principal is Pending {
  //
  * Set `Account Template` to the one given at the `Spawn Transaction` (the `Template` field)
  * Mark as Active
  * run the `verify` ???
  * run the default flow (as today)
}
else {
  // Prinicipal doesn't exist
  panic()
}