feat: let localnet fork from a remote datasource - #28
Open
beeman wants to merge 1 commit into
Open
Conversation
Expose the validator engines' datasource support through the localnet command instead of always starting an empty, offline chain. --network forks from a public cluster (devnet, mainnet, or testnet) and --rpc-url from any RPC endpoint; surfpool then fetches every account lazily at its original address, while --clone and --clone-upgradeable-program name what the test-validator clones up front, with mainnet translated to the mainnet-beta moniker it expects. Invalid combinations — both datasource flags, clone flags with surfpool, clone flags with no datasource — are rejected after the engine is resolved, since it may be inherited from a running container. The datasource is recorded in a container label so status reports it and a later start refuses to reuse a running validator as a datasource it was not started with; attaching to a validator we did not start says the options do not apply rather than pretending they did.
🦋 Changeset detectedLatest commit: 404b399 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
This file contains hidden or 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
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.
Summary
solana-mobile localnetalways started the validator as an empty, isolated chain: the surfpool engine was launched with a hardcoded--offline, and neither engine's datasource flags were reachable through the command. This exposes them.--network devnet|mainnet|testnetforks the validator from a public cluster, and--rpc-url <url>from any RPC endpoint. With surfpool, every account the app touches — programs included, at their original addresses — is fetched from that cluster on first access, and the validator reports the cluster's genesis hash.solana-test-validatordoes not fetch lazily, so there the datasource is cloned up front:--clone <address>and--clone-upgradeable-program <address>(both repeatable) name what to copy in, and the network id is translated to themainnet-betamoniker the validator expects. The image's default command is replaced when arguments are passed, so the binary name is repeated in front of the flags.localnet.datasourcecontainer label, solocalnet statusreports it and a laterlocalnet startrefuses to reuse a running validator as a datasource it was not started with — the same shape as the existing engine conflict. A matching or omitted datasource reuses cleanly.Verification
|inside an RPC URL), reuse conflicts, the attach caveat, and CLI flag parsing.--network devnetand asserts the reported genesis hash is devnet's (EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG) and the label survives a real Docker round trip; verified passing locally.solana-test-validator --url devnet --clone <mint>served the cloned account.