This repository has been archived by the owner on Aug 14, 2023. It is now read-only.
Adjust verify
for Self-Spawn
#479
Labels
verify
for Self-Spawn
#479
Depends on #470 #467 (from the
Simple Coin Iteration 3
)In this SMIP, we want to extend the
verify
of theRuntime
to work forSelf-Spawn
transactions.(and not only for
Non-Self Spawn
ones).Running
verify
inSelf-Spawn
mode is unique because thePrincipal
account is in aPending
state (see #467).It has no
Template
it's associated with yet.The way to make it work is to make the
Runtime
execute theverify
functionally.We know what code needs to run for
verify
(since theTemplate
is specified at theSpawn
transaction).Additionally, we know that we are only allowed reads from the
Immutable Storage
of the-to-be-self-spawnedAccount.
Even though the
Account
isn't active and has no Storage yet, we can make thatverify
behave as if it had Storage.We'll use the
immutable_data
supplied in theSpawn Transaction,
add another layer of indirection to the Storage host functions, and it should work.To add that layer of indirection, we'd bypass the
AccountStorage
and leverage theFuncData struct
we've introduced in #470. Until now, theimmutable_data
was being ignored - not anymore...Implementation Proposal
In #470, we had this code:
Now the
read
should in high-level work such as this:We essentially reuse the same logic as in issue #471.
Given the
immutable_data
buffer and theImmutable Storage Section Layout,
we should be able to extract the required variable.We need to load that
Layout
only once to optimize the code.So the above line of code:
The loading of the
Immutable Storage Section Layout
should be done externally.Probably it should become part of the
FuncData
.It is better to make it optional (of type
Option<FixedLayout>
) since we want to have it only forSelf-Spawn Verify
.In any other case, we just hit the
AccountStorage
directly.Before the
ctor
runningWe've another leftover from issue #477 that we need to fill in.
Here is the code appearing under #477.
We need to do the following:
The text was updated successfully, but these errors were encountered: