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

FIP-0088: Add support for upgradable actors #873

Closed
wants to merge 4 commits into from
Closed

Conversation

fridrik01
Copy link
Contributor

@fridrik01 fridrik01 commented Nov 27, 2023

@fridrik01 fridrik01 force-pushed the actor-upgrades branch 2 times, most recently from f67f17f to b3cf913 Compare November 27, 2023 17:33
FIPS/fip-actor-upgrades.md Outdated Show resolved Hide resolved
FIPS/fip-actor-upgrades.md Show resolved Hide resolved
FIPS/fip-actor-upgrades.md Outdated Show resolved Hide resolved
FIPS/fip-actor-upgrades.md Show resolved Hide resolved
FIPS/fip-actor-upgrades.md Outdated Show resolved Hide resolved
@fridrik01 fridrik01 changed the title [WIP] FIP-XXX: Add support for upgradable actors FIP-XXX: Add support for upgradable actors Dec 15, 2023
@fridrik01 fridrik01 marked this pull request as ready for review December 15, 2023 17:49
@jennijuju
Copy link
Member

Peer q: how can we leverage this with buitin actors? anyways to simplify network upgrade process when simple actor code change involved?

@jennijuju
Copy link
Member

jennijuju commented Jan 4, 2024

editor: FIP itself has all the components needed clearly written. Approving this as a DRAFT with one editorial clarification request.

However, I think we need more discussion on whether this is a desired feature on Filecoin network (before it can be considered for last call)& have better understanding on security implications for network application users when user actors aren't immutable. i.e: Defi and so on. See here


## Incentive Considerations

This FIP does not materially impact incentives in any way.
Copy link
Collaborator

@kaitlin-beegle kaitlin-beegle Jan 4, 2024

Choose a reason for hiding this comment

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

Is this true? I'm curious how this change may impact the logic around timing and resource use for network upgrades, as well as the prioritization of certain changes.

If actors' code can be much more efficiently upgraded, shouldn't we technically be able to push more updates/small changes more quickly?

This change may not effect cryptoeconomics, but I might request we add a line about affecting the logic of what gets included for upgrades. Ultimately a small nit; the approval of the draft shouldn't be gated on this topic.

Copy link
Member

Choose a reason for hiding this comment

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

@kaitlin-beegle I don't think I get why those are incentive considerations rather than product considerations.

Copy link
Collaborator

@kaitlin-beegle kaitlin-beegle left a comment

Choose a reason for hiding this comment

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

[Editorial Review] - A few small nits and open questions, nothing major. Editorially, this looks good to proceed.

@jennijuju
Copy link
Member

However, I think we need more discussion on whether this is a desired feature on Filecoin network (before it can be considered for last call)& have better understanding on security implications for network application users when user actors aren't immutable. i.e: Defi and so on. See here

please discard this comment - thanks to the clarification here

FIPS/fip-actor-upgrades.md Outdated Show resolved Hide resolved
FIPS/fip-actor-upgrades.md Outdated Show resolved Hide resolved
FIPS/fip-actor-upgrades.md Outdated Show resolved Hide resolved
FIPS/fip-actor-upgrades.md Outdated Show resolved Hide resolved
FIPS/fip-actor-upgrades.md Outdated Show resolved Hide resolved
FIPS/fip-actor-upgrades.md Outdated Show resolved Hide resolved

## Incentive Considerations

This FIP does not materially impact incentives in any way.
Copy link
Member

Choose a reason for hiding this comment

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

@kaitlin-beegle I don't think I get why those are incentive considerations rather than product considerations.

FIPS/fip-actor-upgrades.md Outdated Show resolved Hide resolved
FIPS/fip-actor-upgrades.md Outdated Show resolved Hide resolved
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.

I came away with some confusion over how this mechanism is specified to work, and thus what properties it has. Some of my comments below may make incorrect assertions, but if so these signal that the text is confusing.

The `UpgradeInfo` struct is defined as follows:

```rust
#[derive(Clone, Debug, Copy, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)]
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I don't think these Rust codegen things are relevant to the FIP.


When a target actor's `upgrade` Wasm entrypoint is called, it can make necessary state tree changes from the calling if needed to its actor code. The `UpgradeInfo` struct provided by the FVM runtime can be used to check what code CID its upgrading from. A successful return from the `upgrade` entrypoint instructs the FVM that it should proceed with the upgrade. The target actor can reject the upgrade by calling `sdk::vm::exit()`` before returning from the upgrade entrypoint.

### New upgrade_actor syscall
Copy link
Member

Choose a reason for hiding this comment

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

Nit: the entry point and syscall are presented in the opposite order to which they happen in during an upgrade, which makes grokking the flow a bit harder. I drew a completely wrong idea about the upgrade method until I finished reading the syscall spec.

6. Start a new Call Manager transaction:
1. Validate that the calling actor has not been deleted. If so, the syscall fails with a "IllegalOperation" (2) syscall error.
2. Update the actor in the state tree with the new `new_code_cid` keeping the same `state`, `sequence` and `balance`.
3. Invoke the target actor's `upgrade` entrypoint.
Copy link
Member

Choose a reason for hiding this comment

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

Please be very clear which code is invoked here. Since the prior step changed the code CID, I'm assuming it's the new code, but "target actor" also makes it sound like the old code.


### New upgrade Wasm Entrypoint

We introduce a new optional `upgrade` Wasm entrypoint. Deployed actors must implement this entrypoint to be a valid upgrade target. It is defined as follows:
Copy link
Member

Choose a reason for hiding this comment

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

Why must deployed actors implement it? It's not invoked on deployed actors, it's invoked on the new code. The algorithm below does not specify any check that the deployed actors implement this entry point

}
```

When a target actor's `upgrade` Wasm entrypoint is called, it can make necessary state tree changes from the calling if needed to its actor code. The `UpgradeInfo` struct provided by the FVM runtime can be used to check what code CID its upgrading from. A successful return from the `upgrade` entrypoint instructs the FVM that it should proceed with the upgrade. The target actor can reject the upgrade by calling `sdk::vm::exit()`` before returning from the upgrade entrypoint.
Copy link
Member

Choose a reason for hiding this comment

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

This first sentence is a bit unclear

Suggested change
When a target actor's `upgrade` Wasm entrypoint is called, it can make necessary state tree changes from the calling if needed to its actor code. The `UpgradeInfo` struct provided by the FVM runtime can be used to check what code CID its upgrading from. A successful return from the `upgrade` entrypoint instructs the FVM that it should proceed with the upgrade. The target actor can reject the upgrade by calling `sdk::vm::exit()`` before returning from the upgrade entrypoint.
When the `upgrade` entry point is invoked in the new code, it can make any necessary state tree changes required by that new code. The `UpgradeInfo` struct provided by the FVM runtime can be used to check what code CID its upgrading from. A successful return from the `upgrade` entrypoint instructs the FVM that it should proceed with the upgrade. The new code can abort the upgrade operation by calling `sdk::vm::exit()`.


### New upgrade_actor syscall

We introduce a new `upgrade_actor` syscall which calls the `upgrade` Wasm entrypoint of the calling actor and then atomically replaces the code CID of the calling actor with the provided code CID, and returns the exit code and block of the return. It is defined as follows:
Copy link
Member

Choose a reason for hiding this comment

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

The algorithm below specifies the opposite order of things: the code is changed then upgrade is invoked (in the new code). The opposite order makes sense, since the old code can't possibly know what state schema is required by the new code, while the new code can know both schemas.


Upgradable actors pose potential security risks, as users can replace deployed actors' code. However, measures are in place to minimize these risks:

- Upgradable actors are opt-in by default, ensuring no impact on currently deployed actors.
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand from the text above how this is enforced.

Copy link
Member

Choose a reason for hiding this comment

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

Update: the text above doesn't say this, but I now do understand. It's opt-in because an actor code must have some path that invokes the upgrade syscall in order to be upgradeable. The stuff about requiring the upgrade entrypoint still seems wrong, but the fact that actors can only upgrade themselves means that an actor can be determined to be non-upgradeable by lack of such a call (up to malicious obfuscation, etc).

I suggest this mechanism and property be spelled out more clearly.

@jsoares jsoares changed the title FIP-XXX: Add support for upgradable actors FIP-0088: Add support for upgradable actors Feb 8, 2024
@jsoares
Copy link
Member

jsoares commented Feb 8, 2024

Assigned FIP-0088; please update the FIP frontmatter, title heading, and readme.md accordingly. @anorth's review also raises important points that should be addressed before merging.

@jsoares
Copy link
Member

jsoares commented Mar 15, 2024

@fridrik01 Review comments have been pending for 5 weeks now. Could you clarify the status and ETA?

@fridrik01 fridrik01 closed this Mar 18, 2024
@fridrik01
Copy link
Contributor Author

Closing, will open once I have addressed the comments, likely next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ☑️ Done (Archive)
Development

Successfully merging this pull request may close these issues.

7 participants