feat: deployer-from-mnemonic utility modes (--print-key, EVM⇄Substrate twin) + fix wrong documented prod twin#267
Open
hanwencheng wants to merge 2 commits into
Open
feat: deployer-from-mnemonic utility modes (--print-key, EVM⇄Substrate twin) + fix wrong documented prod twin#267hanwencheng wants to merge 2 commits into
hanwencheng wants to merge 2 commits into
Conversation
… conversion; fix wrong documented prod twin
- --print-key: derive + print the private key to stdout only, nothing
written, no key-file comparison (safe for scanning --index candidates)
- --evm-to-substrate <0xADDR>: print the Heima Substrate twin
(blake2_256("evm:" || addr), Frontier HashedAddressMapping) as JSON
with raw hex + SS58 prefix 31/131/42 - python3 stdlib only
- --substrate-to-evm <SS58|0xHEX32> [--verify-evm 0xADDR]: checksum-
verified decode + twin verification (the reverse mapping is a one-way
hash with no inverse, so verify-a-candidate is the honest equivalent)
- mnemonic flow now prints the derived address's Substrate twin (the
account to fund for EVM gas)
- delete scripts/evm-to-substrate-address.mjs: superseded; it required
@PolkaDot deps never recorded in any package.json (could not run);
the python implementation is output-identical (verified against the
@PolkaDot libs installed in a sandbox)
- docs/spec/deployed-contracts.md: CORRECT the prod deployer twin -
47NGSq...C1M3 was NOT the hashed twin of 0xdE6449...63Bc; the real
twin is 47hNCTi9Jrs86atvDj9AhY67X2vQEDzzHAvzapKvUpxXz6EX
- docs/ci-setup.md: document the utility modes
…i-setup.md (keep both: utility-modes block + main's §2b test-deployer rotation)
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.
What
Extends
scripts/heima-deployer-from-mnemonic.shwith three standalone utility modes and fixes a wrong address in the docs.New script modes
--print-key— derive the private key from a mnemonic and print it to stdout only: nothing written to disk, no key-file comparison. Address/path/twin go to stderr so stdout stays pipeable. Safe for scanning--index Ncandidates when a derived address doesn't match the existing key file.--evm-to-substrate <0xADDR>— print the Heima Substrate twin of an EVM address (FrontierHashedAddressMapping<BlakeTwo256>:account32 = blake2_256("evm:" ‖ eth_bytes)) as JSON: raw 32-byte hex + SS58 prefix 31 (mainnet) / 131 (Paseo) / 42 (generic). The twin is the account you send HEI to when funding an EVM address. python3 stdlib only — no@polkadotdeps, no foundry needed.--substrate-to-evm <SS58|0xHEX32>[--verify-evm 0xADDR]— checksum-verified SS58 decode + re-encodings. The EVM preimage cannot be computed back (one-way hash), so the honest reverse is verification:--verify-evmexits 0 iff the Substrate account IS that EVM address's twin.twin:line) — funding info at hand immediately.--helpnow prints the whole header via awk (no more stale hand-maintained sed line range).Removed
scripts/evm-to-substrate-address.mjs— superseded. It imported@polkadot/keyring/@polkadot/util-cryptowhich were never recorded in any package.json and never installed, so it could not run as shipped. The python replacement is output-identical: verified by installing the@polkadotdeps in a sandbox and diffing — both produce47hNCTi9…/0x392331f7…for the prod deployer.Doc fix (found during verification)
docs/spec/deployed-contracts.mdlisted the prod deployer's Substrate twin as47NGSq6JE5ZSnymGNa4nFVjWbsuhTfoSKN2jtpk28mUyC1M3— that is not the twin of0xdE6449…63Bc. Two independent implementations (the@polkadotlibs and the new python) agree the real twin is47hNCTi9Jrs86atvDj9AhY67X2vQEDzzHAvzapKvUpxXz6EX. The old value is likely the mnemonic's sr25519 address — exactly the mix-up the old.mjsheader warned about. HEI sent to it would not credit the deployer's EVM balance. Corrected with an explicit correction note.docs/ci-setup.md§2 documents all the new modes with copy-paste examples.Verification
--evm-to-substrate 0xdE6449…63Bcoutput is byte-identical to the original@polkadot-based.mjs(run in a sandbox with deps installed)decode(47hNCTi9…)→ re-encode reproduces input exactly, checksum verified, prefix 31 parsed--verify-evmMATCH → exit 0, NO-MATCH → exit 1--print-keywith the Anvil test mnemonic prints the canonical index-0 key;ls -la ~/.agentkeyssnapshot before/after proves zero disk writes[ -n … ] && echoset-e footgun avoided (twin lines useif-form, so a python3-less box still prints the key)bash -nclean; no dangling references to the deleted.mjsWhat landed
scripts/heima-deployer-from-mnemonic.sh— all modes abovescripts/evm-to-substrate-address.mjs— deleted (superseded)docs/spec/deployed-contracts.md— twin corrected + new command pointerdocs/ci-setup.md— utility-modes sectionWhat did NOT land
Nothing — all intended changes shipped.
🤖 Generated with Claude Code