-
Notifications
You must be signed in to change notification settings - Fork 40
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
[DPA-1458]: feat(solana): auto deploy programs #1519
Conversation
By using `--upgradeable-program` , we can auto deploy programs detected in the mounted path `/programs`, this reduces the need for consumer of this library to have to deploy the programs themselves, especially with go sdk where deploying a program is not straightforward and involves a decent amount of code, the alternative is to ssh into the docker container and run `solana deploy ...` but this involves an extra step. JIRA: https://smartcontract-it.atlassian.net/browse/DPA-1458
bf0560e
to
4fd8d9a
Compare
@@ -21,6 +21,10 @@ type Input struct { | |||
// publickey to mint when solana-test-validator starts | |||
PublicKey string `toml:"public_key"` | |||
ContractsDir string `toml:"contracts_dir"` | |||
// programs to deploy on solana-test-validator start | |||
// a map of program name to program id | |||
// there needs to be a matching .so file in contracts_dir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah,
[solana_config.solana_programs]
mcm = "6UmMZr5MEqiKWD5jqTJd1WCR5kT8oZuFYBLJFi1o6GQX"
expects the file <contracts_dir>/mcm.so
and it will use 6UmMZr5MEqiKWD5jqTJd1WCR5kT8oZuFYBLJFi1o6GQX
as the program id , so it can be looked up later for testing.
also, should programs reside in the root of contracts_dir or in <contracts_dir>/programs?
No strong opinions, i think contracts are programs in solana, but i was basically following the convention in chainlink-ccip
# value is the program id to set for the deployed program instead of auto generating | ||
# useful for deterministic testing | ||
[blockchain_a.solana_programs] | ||
mcm = "6UmMZr5MEqiKWD5jqTJd1WCR5kT8oZuFYBLJFi1o6GQX" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think you might expand that topic a bit? for example:
- how should one load a program with auto-generated id?
- where should one get that program id from, if auto-generation is not desired?
- in what way is testing deterministic with static program id? what indeterminism there would be if I used different program ids for programs that are the same, i.e. with the same bytecode? or is program id derived from the bytecode somehow?
it's more than fine to just outline these topics in broad strokes and linking to resources which describe them in more details
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks,
how should one load a program with auto-generated id?
then we do it the normal way, we just do solana deploy program then the program will be deployed with its own program id.
where should one get that program id from, if auto-generation is not desired?
basically just any public key, but usually the developer of the solana program will have one set , eg here for mcm
in what way is testing deterministic with static program id? what indeterminism there would be if I used different program ids for programs that are the same, i.e. with the same bytecode? or is program id derived from the bytecode somehow?
basically during testing, we want to look up the deployed program based on the program id,
eg
data, accErr := s.SolanaClient.GetAccountInfoWithOpts(ctx, <PROGRAM_ID>, &rpc.GetAccountInfoOpts{
Commitment: config.DefaultCommitment,
})
If we dont tell solana to deploy a program with a certain program id, then we wont be able to look it up easily during testing since it is auto generated.
If we tell solana to deploy a program with a provided program id, then we can just look it up easily during testing.
Hope this make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added more info to the solana.md
, let me know if that is enough or you prefer it to be in other places too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if possible, please improve documentation (see comment), otherwise 👍
By using `--upgradeable-program` , we can auto deploy programs detected in the mounted path `/programs`, this reduces the need for consumer of this library to have to deploy the programs themselves, especially with go sdk where deploying a program is not straightforward and involves a decent amount of code, the alternative is to ssh into the docker container and run `solana deploy ...` but this involves an extra step. Inspired from https://github.com/smartcontractkit/chainlink-ccip/blob/609f7b0c9734b3cfc1d1a1aea0fd1ddf4c90bd0c/chains/solana/contracts/tests/testutils/anchor.go#L72-L72 JIRA: https://smartcontract-it.atlassian.net/browse/DPA-1458
017bdc3
to
85388d4
Compare
Quality Gate passedIssues Measures |
By using
--upgradeable-program
, we can auto deploy programs detected in the mounted path/programs
, this reduces the need for consumer of this library to have to deploy the programs themselves, especially with go sdk where deploying a program is not straightforward and involves a decent amount of code, the alternative is to ssh into the docker container and runsolana deploy ...
but this involves an extra step.Inspired from https://github.com/smartcontractkit/chainlink-ccip/blob/609f7b0c9734b3cfc1d1a1aea0fd1ddf4c90bd0c/chains/solana/contracts/tests/testutils/anchor.go#L72-L72
JIRA: https://smartcontract-it.atlassian.net/browse/DPA-1458
Below is a summarization created by an LLM (gpt-4-0125-preview). Be mindful of hallucinations and verify accuracy.
Why
The changes introduce a new feature to deploy upgradeable Solana programs at the start of the Solana test validator. This enhancement allows users to specify a map of Solana program names to their corresponding program IDs directly in the blockchain configuration, facilitating a more dynamic and flexible test setup.
What
SolanaPrograms map[string]string
to theInput
struct to allow specifying Solana programs to deploy upon test validator start.solana-test-validator
command with flags for deploying specified Solana programs. This includes iterating over theSolanaPrograms
map from the configuration and appending program deployment flags to the validator startup command.