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

feat: Add alternative snapshot design. #345

Merged
merged 3 commits into from
Jul 3, 2023

Conversation

xxuejie
Copy link
Collaborator

@xxuejie xxuejie commented Jun 2, 2023

This change adds a different snapshot design, that takes advantage of a newly defined trait named DataSource. DataSource is modeled after environmental data that would stay the same and most likely immutable for the entire duration of a CKB-VM program's lifecycle. An example could be the enclosing transaction (ResolvedTransaction in CKB's term) for CKB's smart contracts. No matter where and when we are running the smart contract, the enclosing transaction is always the same. By exploiting this property, we can reduce the size of a snapshot greatly: when a piece of data already exist in the DataSource, we won't need to store the same data in the snapshot. As long as we maintain enough information to locate them from the DataSource, the snapshot can successfully be used to resume the full running state of a CKB-VM Machine.

@xxuejie xxuejie requested a review from mohanson June 2, 2023 05:16
mohanson
mohanson previously approved these changes Jun 6, 2023
@XuJiandong
Copy link
Collaborator

Let us pause: Is it necessary to include this particular feature in the upcoming hard fork?

@xxuejie
Copy link
Collaborator Author

xxuejie commented Jun 6, 2023

Let us pause: Is it necessary to include this particular feature in the upcoming hard fork?

I think this is just an added feature, if you don't use it, it won't affect existing features. Even if you use it in the code, it really is just an implementation detail that does not change any behavior. To answer the question more directly: tt depends on the CKB team if they want to use this in CKB. Maybe they want to use it, maybe not.

@mohanson
Copy link
Collaborator

mohanson commented Jul 3, 2023

Can you fix the conflict?

@xxuejie
Copy link
Collaborator Author

xxuejie commented Jul 3, 2023

I can but have we reached the decision to merge this to develop branch? Or are you merely meant to test this?

@mohanson
Copy link
Collaborator

mohanson commented Jul 3, 2023

I'm about to merge it into the develop branch.

This change adds a different snapshot design, that takes advantage of
a newly defined trait named `DataSource`. DataSource is modeled after
environmental data that would stay the same and most likely immutable
for the entire duration of a CKB-VM program's lifecycle. An example
could be the enclosing transaction (`ResolvedTransaction` in CKB's
term) for CKB's smart contracts. No matter where and when we are
running the smart contract, the enclosing transaction is always the
same. By exploiting this property, we can reduce the size of a
snapshot greatly: when a piece of data already exist in the
DataSource, we won't need to store the same data in the snapshot. As
long as we maintain enough information to locate them from the
DataSource, the snapshot can successfully be used to resume the full
running state of a CKB-VM Machine.
@xxuejie
Copy link
Collaborator Author

xxuejie commented Jul 3, 2023

I'm about to merge it into the develop branch.

Already rebased.

@mohanson mohanson merged commit 4f5d5f0 into nervosnetwork:develop Jul 3, 2023
xxuejie added a commit to xxuejie/ckb-vm that referenced this pull request Jan 22, 2024
…)"

* feat: Add alternative snapshot design.

This change adds a different snapshot design, that takes advantage of
a newly defined trait named `DataSource`. DataSource is modeled after
environmental data that would stay the same and most likely immutable
for the entire duration of a CKB-VM program's lifecycle. An example
could be the enclosing transaction (`ResolvedTransaction` in CKB's
term) for CKB's smart contracts. No matter where and when we are
running the smart contract, the enclosing transaction is always the
same. By exploiting this property, we can reduce the size of a
snapshot greatly: when a piece of data already exist in the
DataSource, we won't need to store the same data in the snapshot. As
long as we maintain enough information to locate them from the
DataSource, the snapshot can successfully be used to resume the full
running state of a CKB-VM Machine.

* test: Ensure resumed VM has the same register and memory data

* fix: Skip full memory comparison in chaos tests
mohanson pushed a commit to libraries/ckb-vm that referenced this pull request Mar 4, 2024
…)"

* feat: Add alternative snapshot design.

This change adds a different snapshot design, that takes advantage of
a newly defined trait named `DataSource`. DataSource is modeled after
environmental data that would stay the same and most likely immutable
for the entire duration of a CKB-VM program's lifecycle. An example
could be the enclosing transaction (`ResolvedTransaction` in CKB's
term) for CKB's smart contracts. No matter where and when we are
running the smart contract, the enclosing transaction is always the
same. By exploiting this property, we can reduce the size of a
snapshot greatly: when a piece of data already exist in the
DataSource, we won't need to store the same data in the snapshot. As
long as we maintain enough information to locate them from the
DataSource, the snapshot can successfully be used to resume the full
running state of a CKB-VM Machine.

* test: Ensure resumed VM has the same register and memory data

* fix: Skip full memory comparison in chaos tests
mohanson pushed a commit to libraries/ckb-vm that referenced this pull request Mar 14, 2024
…)"

* feat: Add alternative snapshot design.

This change adds a different snapshot design, that takes advantage of
a newly defined trait named `DataSource`. DataSource is modeled after
environmental data that would stay the same and most likely immutable
for the entire duration of a CKB-VM program's lifecycle. An example
could be the enclosing transaction (`ResolvedTransaction` in CKB's
term) for CKB's smart contracts. No matter where and when we are
running the smart contract, the enclosing transaction is always the
same. By exploiting this property, we can reduce the size of a
snapshot greatly: when a piece of data already exist in the
DataSource, we won't need to store the same data in the snapshot. As
long as we maintain enough information to locate them from the
DataSource, the snapshot can successfully be used to resume the full
running state of a CKB-VM Machine.

* test: Ensure resumed VM has the same register and memory data

* fix: Skip full memory comparison in chaos tests
mohanson added a commit that referenced this pull request Mar 14, 2024
* backport: Backport "Add alternative snapshot design. (#345)"

* feat: Add alternative snapshot design.

This change adds a different snapshot design, that takes advantage of
a newly defined trait named `DataSource`. DataSource is modeled after
environmental data that would stay the same and most likely immutable
for the entire duration of a CKB-VM program's lifecycle. An example
could be the enclosing transaction (`ResolvedTransaction` in CKB's
term) for CKB's smart contracts. No matter where and when we are
running the smart contract, the enclosing transaction is always the
same. By exploiting this property, we can reduce the size of a
snapshot greatly: when a piece of data already exist in the
DataSource, we won't need to store the same data in the snapshot. As
long as we maintain enough information to locate them from the
DataSource, the snapshot can successfully be used to resume the full
running state of a CKB-VM Machine.

* test: Ensure resumed VM has the same register and memory data

* fix: Skip full memory comparison in chaos tests

* Let snapshots stores the load_reservation_address

---------

Co-authored-by: Xuejie Xiao <xxuejie@gmail.com>
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.

3 participants