Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract temporary and permanent storage changes #123

Merged
merged 4 commits into from
Sep 26, 2024
Merged

Conversation

thpani
Copy link
Collaborator

@thpani thpani commented Sep 10, 2024

Preparatory change towards #54.
Closes #121
Closes #126

In the fetcher, extract all ledger entry changes from a transaction, i.e, including

  • changes to temporary and persistent storage, and
  • changes to other contracts than the (root-)invoked contract.

The result is two (pre- & post-state) nested maps keyed by

  1. contract address
  2. 'instance' | 'persistent' | 'temporary'
  3. the ScVal key, SDK-transformed to a native JS val and .toString()ed

The resulting maps are only propagated to Solarkraft on-disk storage, and not yet used for instrumentation. In particular, we still populate fields and oldFields by projecting the above maps to the instance storage of the root-invocation contract ID.

Tests:
Update the setter contract to store all fields in instance, persistent and temporary storage.

Note that the presence of fields is different between instance and persistent/temporary:
instance is a single LedgerEntry, thus all instance fields are present if a single instance field changes.
persistent/temporary have one LedgerEntry per field, thus they are only present in the transaction if that field is changed.

We should follow up with case studies to determine user needs:

Copy link
Contributor

@konnov konnov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Absence of tests worries me a bit though :)

solarkraft/src/fetcher/callDecoder.ts Show resolved Hide resolved
@thpani
Copy link
Collaborator Author

thpani commented Sep 24, 2024

Looks good. Absence of tests worries me a bit though :)

Oh, I didn't notice I requested a review already 😅
I'll still add tests, just wanted to save the progress before my vacation.

@thpani thpani marked this pull request as draft September 24, 2024 07:40
@thpani thpani marked this pull request as ready for review September 24, 2024 14:31
@thpani thpani requested a review from konnov September 24, 2024 14:31
@thpani
Copy link
Collaborator Author

thpani commented Sep 24, 2024

@konnov I've added persistent/temporary fields in the setter contract and to the tests.
More details on persistent/temporary behavior in the PR desc.

PTAL

@konnov konnov merged commit 0a76dc1 into main Sep 26, 2024
3 checks passed
@konnov konnov deleted the th/storage-perm-temp branch September 26, 2024 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetch persistent and temporary storage Fetch other contract's storage changes
2 participants