Skip to content

[HOLD] Add an example custom kernel defining a custom syscall - #630

Closed
fridrik01 wants to merge 3 commits into
mainfrom
custom-kernel
Closed

[HOLD] Add an example custom kernel defining a custom syscall#630
fridrik01 wants to merge 3 commits into
mainfrom
custom-kernel

Conversation

@fridrik01

@fridrik01 fridrik01 commented Jan 25, 2024

Copy link
Copy Markdown
Contributor

DO NOT MERGE

This is PR is part of a pluggable syscall tutorial which we will share later and contains the final source code after following the tutorial.

Context
This PR replaces the current Fendermint FVM kernel with a new custom kernel which implements a new syscall and shows how you can use this syscall from a new custom actor which we load at genesis.

More specifically, this PR:

  • Implement a new `CustomKernelImpl FVM kernel which extends the default kernel.
  • Implement a new syscall called my_custom_syscall on the new kernel
  • Switches out the DefaultKernel used in Fendermint with this new custom kernel
  • Creates a new customsyscall actor which demonstrates calling the new syscall
  • Updates fendermint to load this new actor at genesis and run it at each epoch

Test plan
You can test this new kernel/syscall/actor by running one of our integration tests.

First you need to have docker installed, then compile a local docker image with this PR checked out:

cd fendermint
make docker-build

After the fendermint docker image has been built, you can run one of the integration tests

cd fendermint/testing/smoke-test
# creates the docker containers
cargo make setup
# runs the integration test
cargo make test

View fendermint logs and see the output generated by calling the customsyscall actor in each epoch:

docker ps
CONTAINER ID   IMAGE                       COMMAND
8da423d8bb1e   fendermint:latest           "fendermint --networ…"
...

View the docker logs:

docker logs 8da423d8bb1e
...
customsyscall actor returned: 21

You can now run cargo make teardown to stop the container.

@fridrik01
fridrik01 requested a review from a team January 25, 2024 16:22
@fridrik01
fridrik01 marked this pull request as ready for review January 25, 2024 16:22
Comment thread fendermint/vm/interpreter/src/fvm/examples/mycustomkernel.rs
@fridrik01
fridrik01 requested a review from a team January 26, 2024 18:18
Comment thread fendermint/vm/interpreter/src/fvm/examples/mycustomkernel.rs Outdated
Comment thread fendermint/vm/interpreter/src/fvm/examples/mycustomkernel.rs
Comment thread fendermint/vm/interpreter/src/fvm/examples/mycustomkernel.rs Outdated
@fridrik01
fridrik01 force-pushed the custom-kernel branch 3 times, most recently from 6e6d902 to 23833c8 Compare February 8, 2024 18:11
@fridrik01
fridrik01 marked this pull request as draft February 8, 2024 18:12
@maciejwitowski maciejwitowski changed the title Add an example custom kernel defining a custom syscall [HOLD] Add an example custom kernel defining a custom syscall Mar 6, 2024
Based on feedback, this commit:
- Renames DefaultCustomKernel to CustomKernelImpl which makes it
clearer what its doing
- Updates the custom kernel to extend the DefaultKernel instead of
the FilecoinKernel which should not be needed inside IPC. This
simplifies the code a lot.
@fridrik01

Copy link
Copy Markdown
Contributor Author

This PR can be closed as its for documentation purposes

@fridrik01 fridrik01 closed this Mar 22, 2024
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.

5 participants