feat: let a caller supply the mycelium key and ip seed when deploying a vm - #1548
feat: let a caller supply the mycelium key and ip seed when deploying a vm#1548mik-tf wants to merge 3 commits into
Conversation
… a vm A vm's mycelium address is determined by two values: the mycelium key on its network, and the ip seed on the machine. `deploy vm` generates both on every run and offers no way to supply them, so a deployment that is destroyed and rebuilt always comes back on a different address. That matters wherever the address is depended on from outside the deployment. The type carrying the network key already documents the intent — it is provided by the user so it can later be moved to other nodes without losing the key — but nothing on the command line could act on it. `deploy vm` now accepts `--mycelium-key` (hex, 32 bytes) and `--mycelium-seed` (hex, 6 bytes). Both paths honour them: the light network and machine as well as the classic ones. Omitting them generates a fresh value exactly as before, so every existing caller is unaffected. They have to be supplied together, and cobra enforces that alongside the parsing function, because either one on its own still moves the address and would leave a caller with a machine that is not where they expect it. A key or seed of the wrong length, or one that is not hex, is refused with the expected length named. Supplying an identity while mycelium is disabled is refused rather than quietly ignored. The kubernetes deploy path passes no key and generates as it did before, its command line having no way to express one. Signed-by: mik-tf <mik-tf@noreply.invalid>
Records the two new flags alongside the other optional ones, and adds a short section on why they exist: a mycelium address depends on the network key and the machine's ip seed, both of which are generated per deployment unless supplied, so a redeployed vm normally moves. Notes the two constraints a user will otherwise meet by trial: the flags have to be given together, since either alone still changes the address, and the key is private material worth storing deliberately if a redeployment is intended. Signed-by: mik-tf <mik-tf@noreply.invalid>
|
Two checks are red here — Both fail inside The nil pointer panic that follows is downstream of that error rather than a separate defect. Written up with the suggested fix in #1549. Three things that place it outside this branch:
The checks covering the changed code are green: Signed-by: mik-tf mik-tf@noreply.invalid |
…d line The mycelium key is a credential: whoever holds it can answer at the address it defines. `--mycelium-key` takes the value directly, which puts it on the command line, where it is readable by anything that can list processes for as long as the deploy runs. That is a poor place for a value whose whole purpose is to let a rebuilt machine reclaim an address. `deploy vm` now also accepts `--mycelium-key-env`, which names an environment variable holding the hex key and reads it from there. The two are mutually exclusive, and supplying neither still generates a key exactly as before, so every existing caller is unaffected. The ip seed deliberately gets no equivalent. It selects an address within the network the key defines, so knowing it grants nothing, and a second way to pass a value that is not secret would be cost without benefit. Errors on this path name the variable and never its contents, and are returned rather than logged, because an error sink that ships elsewhere is not somewhere a caller can predict. A variable that is unset and one that is empty are reported separately: both are caller mistakes, and the alternative to naming them is falling back to generating a key, which hands back a machine on an address the caller did not choose and believes it did. Cobra's requirement that the key and seed be given together is now expressed only in the parsing function. The grammar became "either a key or a variable naming one, together with a seed", which the flag-group helpers cannot state; the parsing function already carried the rule independently and is tested for it directly. Signed-by: mik-tf <mik-tf@noreply.invalid>
|
A third commit has landed on this branch — flagging it here rather than letting it turn up in a re-read. It adds The reason is that the key is a credential rather than a parameter: an address is a pure function of it, so whoever holds it can answer at that address. A value passed as an argument is readable from the process table by anything on the machine for as long as the command runs, and a deploy runs for minutes. That is not something later care can undo, which is why it seemed worth fixing at the same time as the flags that make the key worth supplying at all. Details, so the diff is easy to read:
One change worth calling out because it touches existing behaviour: the requirement that key and seed be supplied together now lives only in Happy to split this into its own PR stacked on top if you would rather review the original two commits alone — just say so and I will move it. |
Description
A VM's mycelium address is determined by two values: the mycelium key on its network, and the ip seed on the machine.
tfcmd deploy vmgenerates both on every run and offers no way to supply them, so a VM that is canceled and deployed again always comes back on a different address.That matters wherever something outside the deployment refers to a VM by its address — a peer that has it pinned, a record that outlives the machine, or a replacement expected to take over from the one it replaces.
zos.Mycelium.Keyalready documents the intent:The grid client supports it on both paths —
ZNetLight.MyceliumKeysandVMLight.MyceliumIPSeed, and their classic equivalents — and the values reach the wire. Only the command line had no way to express them.This adds
--mycelium-keyand--mycelium-seedtodeploy vm. Omitting them generates a fresh value exactly as before, so existing callers are unaffected.This was verified against mainnet rather than reasoned about. Three deployments were made with one fixed key and seed pair, on dedicated nodes that advertise
zmachine-lightand not classiczmachine. Between each one the VM was canceled and its address confirmed unreachable, so every deployment was genuinely new — each created fresh contract ids:5c5:681f:d60b:505:ff0f:9f4f:753f:5521The third case is the one that matters: a different machine in a different country answered on the address its predecessor had. All six contracts were canceled by id afterwards.
Changes
grid-cli/cmd/deploy_vm.go--mycelium-key(hex, 32 bytes) and--mycelium-seed(hex, 6 bytes) flags ondeploy vmparseMyceliumIdentitydecodes and validates them; empty means generate, which is the prior behaviour--myceliumis disabled is refused rather than silently ignoredgrid-cli/internal/cmd/deploy.gobuildNetworkandbuildNetworkLightaccept an optional key and fall back toRandomMyceliumKeywhen it is emptyDeployVMandDeployVMLightthread it throughDeployKubernetesClusterpasses none and generates as before, its command line having no way to express onegrid-cli/cmd/deploy_vm_test.go— unit tests for the parsing and validation rulesgrid-cli/docs/vm.md— the two flags, plus a short section on keeping an address across deploymentsRelated Issues
None filed upstream — happy to open one if you would prefer the discussion there.
Checklist