-
Notifications
You must be signed in to change notification settings - Fork 150
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
Integrate stakepool with wapod workers #1584
Open
kvinwang
wants to merge
25
commits into
master
Choose a base branch
from
wapod
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kvinwang
changed the title
Integrate with wapod workers
Integrate stakepool with wapod workers
Jul 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduction
This PR integrate wapod workers to phala chain.
Only the chain runtime changes is included in this PR. The corresponding out-of-tree code of
wapod-pherry
,wapod-types
and thebenchmark
app can be reviewed here: Phala-Network/wapo#1Concepts
The program running in TEE as a wasm host runtime, it can execute wasm programs by calling it's RPC. It is an implementation of Worker v3.
Each time a worker restarts, it will get a new session with associate metrics data reset. A
session_id
is the unique id identify a session wihch is generated assession_id = hash(rand_nonce, previous_metrics_nonce)
, where rand_nonce is a random bytes32 generated on-the-fly andprevious_metrics_nonce
is the nonce in last time a metrics of the worker was reported if any, leave empty if no metrics for the worker was reported yet.The wasm program that be deployed in the worker.
When an app is deployed in a worker, a session is created and a random bytes32 is is generated as
session id
. If the app is removed from the worker, the session is destroyed and a redeployment will get a new session (id).A description of how to launch an App, including
wasm code hash
,arguments
,env vars
,required resources
.etc.Unique id of an App, calulated from hash of App manifest.
The worker meters the resource usage, (such as CPU, IO usage) of each App, and output signed metrics for them.
A request of app deployment put on-chain. Including the app manifest and the payment info for deployment.
A special App registered on chain that used to benchmark workers. Wapod-pherry deploys it to the worker and get benchmark score from it then submit to the chain.
Similar to the heartbeat of pruntime v2 but is simulated on-chain when benchmark scores are reported.
The computaion workflow
Worker registeration
Worker v3 share the same chain API as pruntime v2 to register workers, where the remote attestation is done.
Beside the traditional registration, the following extra information is required to be submitted on chain for a worker:
metrics_none
fetched on chain as input. and submit the new session info to the chain.Ticket based - market mode
Steps
Related pallet calls:
worker_list_create
,worker_list_add_workers
,ticket_create
,ticket_close
,ticket_settle
.Benchmark based - v2 compatible mode
Steps
p_init
.HeartbeatV3
message to the GK if the worker is added to a stakepool.Related pallet calls:
benchmark_app_add
,benchmark_app_set_recommended
,benchmark_app_set
,benchmark_score_submit
,benchmark_app_remove
.Changes in GK
Static V switch
A mq message
SetStaticV
added to switch the GK to static v mode, in which mode the v never increase.HeartbeatV3
When handling the new added
HeartbeatV3
in GK, it is no longer required to be 1:1 map from hearbeat to challenge, any on heartbeat will flush the waiting heartbeat queue.