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(core, runtime): Builtin actors framework #3624

Merged
merged 41 commits into from
Feb 26, 2024
Merged

Conversation

ekovalev
Copy link
Member

@ekovalev ekovalev commented Dec 26, 2023

Following the discussion on reworking the original approach to builtin actors (#3504), a new extensible framework for Runtime builtin actors is proposed.

A set of BuiltinActor's is defined as the pallet_gear_builtin_actor::Config trait associated type - a tuple consisting of custom types each of which must implement the pallet_gear_builtin_actor::BuiltinActor trait (similar to how migrations or signed extras are defined in the Runtime). Those can be pallets (if access to on-chain storage is required) or any other custom types.
To enable messages routing to a specific builtin actor, the latter must be registered with the pallet_gear::Config::<T>::BuiltinRouter associated type that implements the pallet_gear::builtin::BuiltinRouter trait and provides the lookup() function to derive the respective BuiltinId based on the message destination address (ProgramId).
This functionality is provided by the gear_builtin_actor pallet.

The BuiltinId must be unique across all actors: it is claimed by a builtin actor itself as the actor's type's associated constant. The gear-builtin-actor pallet provides the register_actor() function that would check if there are conflicting BuiltinId's. This should be the preferred way to register an actor during Runtime upgrades.

This PR includes:

  • builtin actor framework implementation: new assoc. type in the Gear pallet and the GearBuiltinActor pallet
  • unit tests (more can be add in the future)
  • migration template to register new actors
  • RPC to query actors' ProgramId's
  • docs
  • adjustment of the calculate_gas_info() for the case of a builtin actor.

Examples of actual "production" builtin actor (like staking-proxy one) are beyond the scope of this PR and will be added subsequently.

@ekovalev ekovalev added A1-inprogress Issue is in progress or PR draft is not ready to be reviewed D2-node Gear Node C1-feature Feature request labels Dec 26, 2023
@ekovalev ekovalev changed the title Builtin actors framework feat(core, runtime) Builtin actors framework Dec 26, 2023
@ekovalev ekovalev changed the title feat(core, runtime) Builtin actors framework feat(core, runtime): Builtin actors framework Dec 27, 2023
@ekovalev ekovalev marked this pull request as ready for review January 5, 2024 22:39
@ekovalev ekovalev added A0-pleasereview PR is ready to be reviewed by the team and removed A1-inprogress Issue is in progress or PR draft is not ready to be reviewed labels Jan 5, 2024
@ekovalev ekovalev added A0-pleasereview PR is ready to be reviewed by the team and removed A3-gotissues PR occurred to have issues after the review labels Feb 5, 2024
Copy link
Member

@breathx breathx left a comment

Choose a reason for hiding this comment

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

pallets/gear-builtin is still under review and will be submitted asap

core-processor/src/precharge.rs Show resolved Hide resolved
node/authorship/src/tests.rs Outdated Show resolved Hide resolved
pallets/gear-builtin/Cargo.toml Show resolved Hide resolved
pallets/gear-builtin/rpc/Cargo.toml Outdated Show resolved Hide resolved
pallets/gear-builtin/rpc/Cargo.toml Show resolved Hide resolved
pallets/gear/src/lib.rs Outdated Show resolved Hide resolved
runtime/vara/src/lib.rs Outdated Show resolved Hide resolved
runtime/vara/src/lib.rs Show resolved Hide resolved
pallets/gear-builtin/src/benchmarking.rs Outdated Show resolved Hide resolved
pallets/gear-builtin/src/benchmarking.rs Outdated Show resolved Hide resolved
Copy link
Member

@breathx breathx left a comment

Choose a reason for hiding this comment

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

pallets/gear-builtin/src/tests/* to be reviewed after suggested changes applied/discussed

pallets/gear-builtin/src/lib.rs Outdated Show resolved Hide resolved
pallets/gear-builtin/src/lib.rs Show resolved Hide resolved
pallets/gear-builtin/src/lib.rs Outdated Show resolved Hide resolved
pallets/gear-builtin/src/lib.rs Outdated Show resolved Hide resolved
pallets/gear-builtin/src/lib.rs Outdated Show resolved Hide resolved
pallets/gear-builtin/src/lib.rs Outdated Show resolved Hide resolved
pallets/gear-builtin/src/lib.rs Show resolved Hide resolved
pallets/gear-builtin/src/lib.rs Show resolved Hide resolved
pallets/gear-builtin/src/lib.rs Show resolved Hide resolved
pallets/gear-builtin/src/lib.rs Outdated Show resolved Hide resolved
pallets/gear-builtin/rpc/runtime-api/src/lib.rs Outdated Show resolved Hide resolved
pallets/gear-builtin/src/lib.rs Show resolved Hide resolved
pallets/gear-builtin/src/lib.rs Show resolved Hide resolved
pallets/gear-builtin/src/lib.rs Show resolved Hide resolved
pallets/gear-builtin/src/tests/basic.rs Show resolved Hide resolved
@breathx
Copy link
Member

breathx commented Feb 26, 2024

Awesome and huge work done!

@breathx breathx added A2-mergeoncegreen PR is ready to merge after CI passes and removed A0-pleasereview PR is ready to be reviewed by the team labels Feb 26, 2024
@ekovalev ekovalev merged commit 5dcc1e0 into master Feb 26, 2024
13 checks passed
@ekovalev ekovalev deleted the ek-builtin-framework branch February 26, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A2-mergeoncegreen PR is ready to merge after CI passes C1-feature Feature request D2-node Gear Node
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants