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

Cargo registry service for deploying programs #33570

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

pgarg66
Copy link
Contributor

@pgarg66 pgarg66 commented Oct 6, 2023

Problem

Need convenient mechanism to hook up cargo publish command for on-chain program. The users should be able to deploy programs to the blockchain using cargo publish.

Summary of Changes

This PR implements a custom Cargo registry service. It provides a registry endpoint for cargo commands, and uses Solana's RPC client to interface with the blockchain.

Steps to use the service

Optionally, run the test-validator
Run the service
  1. Generate keypairs for payer and authority accounts.
  2. Fund the payer's account (e.g. airdrop if using test-validator).
  3. Start the server
solana-cargo-registry -a authority.keypair -k payer.keypair -u <rpc endpoint URL> -p <available local TCP port>
Update on-chain program's cargo.toml

Insert following under [package] section of the toml file.

include = [
    "**/*.rs",
    "out/**.so",
    "out/**.json",
    "Cargo.toml",
]
Update cargo config file to add the registry

Create (or update existing) .cargo/config by adding the following. <server-port> must be replaced with <available local TCP port> value from solana-cargo-registry command.

[registries]
my-registry = { index = "http://0.0.0.0:<server-port>/git" }

[net]
git-fetch-with-cli = true
Build on-chain program
  1. Build the on-chain program for sbf-v2 arch.
  2. It's important to generate the output to ./out/ folder for now.
cargo build-sbf  --sbf-out-dir ./out/ --arch sbfv2
One time login to the registry server
cargo login --registry my-registry

When prompted for access token, just enter any string.

Publish the program
cargo publish --registry my-registry

@pgarg66 pgarg66 force-pushed the cargo-registry branch 3 times, most recently from b117c86 to e96bd73 Compare October 7, 2023 20:32
@codecov
Copy link

codecov bot commented Oct 7, 2023

Codecov Report

Merging #33570 (4d85196) into master (c588f25) will increase coverage by 0.1%.
The diff coverage is 50.0%.

@@            Coverage Diff            @@
##           master   #33570     +/-   ##
=========================================
+ Coverage    81.7%    81.9%   +0.1%     
=========================================
  Files         807      807             
  Lines      218283   217911    -372     
=========================================
+ Hits       178485   178490      +5     
+ Misses      39798    39421    -377     

@pgarg66 pgarg66 marked this pull request as ready for review October 8, 2023 02:42
@pgarg66 pgarg66 requested review from alessandrod and Lichtso October 8, 2023 02:44
@Lichtso
Copy link
Contributor

Lichtso commented Oct 9, 2023

Looking very good over all!

Is GIT used for the fetch API? I thought we wanted to implement the sparse protocol instead.

@pgarg66
Copy link
Contributor Author

pgarg66 commented Oct 9, 2023

Looking very good over all!

Is GIT used for the fetch API? I thought we wanted to implement the sparse protocol instead.

Yes, still planning to use sparse index. GIT index is a placeholder for now. An index implementation was necessary for publish command handling. And, GIT based implementation is better documented.

@pgarg66 pgarg66 merged commit 4c664a8 into solana-labs:master Oct 9, 2023
27 checks passed
@pgarg66 pgarg66 deleted the cargo-registry branch October 9, 2023 21:32
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.

2 participants