You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, vm.core.hash::ComputePrincipal is extremely simplistic: it just calculates the principal address using the hash of the template and spawn args (pubkey, for wallet). This is more or less the same thing we do on the Spacemesh mainnet, and it's fine for the v1 Athena testnet, where the simple wallet is the only template.
However, we need to do something more sophisticated when we begin allowing other kinds of templates to be deployed (i.e., when we begin allowing spawn that isn't self-spawn). The issue here is that, as things stand today, each and every template can only be spawned once with a given set of params (immutable state). This is fine for a wallet, but it's not fine for many other types of programs: e.g., it would not allow two different people to both spawn an ERC-20-style fungible token with the same params (token name, decimals, etc.).
The correct way to do this is to include both spawning principal account and nonce in the principal computation. This has the added benefit that, if the same principal spawns exactly the same program again (same template, same args), it'll get a new address. This should be permitted.
In other words, the computation should be:
HASH(template || principal || spawnArgs || nonce)
We can't do this today because it doesn't work for self-spawn: computing the principal cannot require the principal! I see a couple of options:
Just use special handling for self-spawn txs: in only this case, calculate principal using the current, simpler method (i.e., assume empty principal and nonce)
and/or
Allow a template (such as a wallet) to mark itself as a "singleton", meaning it uses a simpler principal computation, and, as described above, cannot be spawned twice with the same set of args
The text was updated successfully, but these errors were encountered:
Right now, vm.core.hash::ComputePrincipal is extremely simplistic: it just calculates the principal address using the hash of the template and spawn args (pubkey, for wallet). This is more or less the same thing we do on the Spacemesh mainnet, and it's fine for the v1 Athena testnet, where the simple wallet is the only template.
However, we need to do something more sophisticated when we begin allowing other kinds of templates to be deployed (i.e., when we begin allowing spawn that isn't self-spawn). The issue here is that, as things stand today, each and every template can only be spawned once with a given set of params (immutable state). This is fine for a wallet, but it's not fine for many other types of programs: e.g., it would not allow two different people to both spawn an ERC-20-style fungible token with the same params (token name, decimals, etc.).
The correct way to do this is to include both spawning principal account and nonce in the principal computation. This has the added benefit that, if the same principal spawns exactly the same program again (same template, same args), it'll get a new address. This should be permitted.
In other words, the computation should be:
HASH(template || principal || spawnArgs || nonce)
We can't do this today because it doesn't work for self-spawn: computing the principal cannot require the principal! I see a couple of options:
and/or
The text was updated successfully, but these errors were encountered: