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: runtime: Add read_only getter #1127

Merged
merged 1 commit into from
Jan 30, 2023
Merged

feat: runtime: Add read_only getter #1127

merged 1 commit into from
Jan 30, 2023

Conversation

arajasek
Copy link
Contributor

@arajasek arajasek commented Jan 29, 2023

Extracted from next. Needs:

This PR simply introduces a getter to the Runtime to indicate whether an invocation is in READ_ONLY mode, and updates the test framework to consider this status as part of execution.

This PR is a pre-factor necessary for landing the changes involved in the FEVM FIPs -- it introduces new functionality, but doesn't start to use it anywhere.

@arajasek arajasek requested a review from anorth January 29, 2023 18:21
@arajasek arajasek changed the title feat: runtime: Support READ_ONLY flag feat: runtime: Add read_only getter Jan 29, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #1127 (532b4b5) into asr/send-generalized (b711fb6) will decrease coverage by 0.03%.
The diff coverage is 59.09%.

Additional details and impacted files

Impacted file tree graph

@@                   Coverage Diff                    @@
##           asr/send-generalized    #1127      +/-   ##
========================================================
- Coverage                 89.00%   88.97%   -0.03%     
========================================================
  Files                        95       95              
  Lines                     19782    19803      +21     
========================================================
+ Hits                      17607    17620      +13     
- Misses                     2175     2183       +8     
Impacted Files Coverage Δ
runtime/src/runtime/mod.rs 64.51% <ø> (ø)
runtime/src/test_utils.rs 81.83% <0.00%> (-0.39%) ⬇️
test_vm/src/lib.rs 85.99% <72.22%> (-0.28%) ⬇️
state/src/check.rs 87.00% <0.00%> (+0.26%) ⬆️

runtime/src/runtime/mod.rs Outdated Show resolved Hide resolved
runtime/src/test_utils.rs Show resolved Hide resolved
ExitCode::USR_READ_ONLY,
format!("cannot create actor {target} in read-only mode"),
));
}
Copy link
Member

Choose a reason for hiding this comment

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

Can you point to the spec for read-only? Depending on what it says, I would expect either:

  • no checks like this, but something at the end of an invocation that restores the state root to its pre-invocation value, or
  • a lot more checks in create, transaction, new_actor_address, create_actor, delete_actor` (or something lower down that propagates through these) that actively prevent modifications.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spec: https://github.com/filecoin-project/FIPs/blob/322604f79c2447a4906ed2fc959e43aaedeccb46/FIPS/fip-0054.md#changed-syscalls

You're right. I've added checks to create, create_actor, transaction, set_state_root and invoke.

I'm tweaking the behaviour of the test_vm's new_actor_address to be read-only, which is how it's actually implemented. The increment in moving to create_actor which is where it belongs.

Copy link
Member

@anorth anorth left a comment

Choose a reason for hiding this comment

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

Thanks, the main change looks good. Ok as is, but a potential improvement:

It struck me while reviewing the test VM that a single check inside self.v.set_actor() would suffice to catch all the read-only cases (after a bit of re-ordering to ensure that was the first modification that the VM processes). But I see why we want the read_only flag to be in the invocation context rather than the self.v VM. One step better might be to implement a wrapper self.set_actor which does the check then calls through to self.v. This wouldn't prevent someone making a mistake, but make future modifications somewhat more likely to be correct. A step further would be to hide self.v even further inside the context so someone can't call directly by accident; but probably not worth it.

Base automatically changed from asr/send-generalized to master January 30, 2023 21:46
@arajasek arajasek merged commit b47f5f7 into master Jan 30, 2023
@arajasek arajasek deleted the asr/read-only branch January 30, 2023 22:11
shamb0 pushed a commit to shamb0/builtin-actors that referenced this pull request Jan 31, 2023
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