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

Implement Pink #399

Merged
merged 43 commits into from
Oct 19, 2021
Merged

Implement Pink #399

merged 43 commits into from
Oct 19, 2021

Conversation

kvinwang
Copy link
Collaborator

@kvinwang kvinwang commented Aug 16, 2021

State: The core of the substrate pallet-contract runs in enclave without any modification now.

  • woker: ink runtime, contract deploy (grouped), query, command
  • gk: contract management
  • ink: mq egress
  • ink: side task

How to play

1. Compile and run pRuntime, pherry and phala-node.

2. Force register the worker as GK with sudo.

image
image

3. Compile an ink project to get an ink wasm binary.

4. Instantiate the ink.

 4.1 Create the message binary with debug-cli:

    ./target/release/debug-cli pink deploy 3a3d45dc55b57bf542f4c6ff41af080ec675317f4ed50ae1d2713bf9f892692d ./crates/pink/tests/fixtures/flip/flip.wasm 0xed4b9d1b

 4.2 Copy the above command output and push the instantiate message to phala/pink/gk/request.

image

5. Check the instantiate status.

We can see the following pRuntime log on instantiate success:

[INFO  phactory::system] pink instantiate status: InstantiateStatus { nonce: [0, 1], owner: 0x8eaf04151687736326c9fea17e25fc5287613693c912909cb226aa4794f26a48, result: Ok(ContractInfo { id: 0xcb54f9c36bc2b29c706295fadaf6864e9eb6964325b2185b6124f5645f94423d, group_id: 0x0000000000000000000000000000000000000000000000000000000000000001, pubkey: 566e290abb84f4950a89c21450ad196b2ef2acef67ce73e6a336598e167cb739 (5E22hY2d...) }) }

Or check the chain-state to get the contract id and pubkey:
image

6. Query the ink.

After the ink contract has been instantiated, we can play with it via query or command.
Use debug-cli for a basic query:

$ ./target/release/debug-cli pink query 0x5fdb70f765123c7ab29a9c311d423e7eb0cc1a3aaaeff6702278e6ac9b9836de 0x2f865bd9
return: (00)

Or use the js-sdk for more featured functions.

@kvinwang kvinwang changed the base branch from master to refactor-phactory-api October 18, 2021 07:57
@kvinwang kvinwang marked this pull request as ready for review October 18, 2021 07:58
@kvinwang kvinwang requested review from shelvenzhou and h4x3rotab and removed request for shelvenzhou October 18, 2021 08:02
Base automatically changed from refactor-phactory-api to master October 18, 2021 08:44
@shelvenzhou
Copy link
Contributor

Finish key management in #546

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.

None yet

2 participants