mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
Computes core.Genesis.ToBlock().Hash() on the maintained EVM path, replacing the legacy coreth-based state/cmd verifiers (which no longer build against the current stack). Used to close the mainnet regenesis launch gate: canonical genesis/configs/mainnet/cchain.json and the deployed k8s cChainGenesis both compute 0x3f4fa2a0...ec61e (== RLP block-0), state root 0x2d1cedac. Co-authored-by: Hanzo Dev <[email protected]>
38 lines
917 B
Go
38 lines
917 B
Go
// Command ghash computes the canonical block-0 hash of one or more C-Chain
|
|
// genesis JSON files via luxfi/evm core.Genesis.ToBlock — the production path
|
|
// (geth v1.20.1), replacing the legacy coreth-based verifier.
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/luxfi/evm/core"
|
|
)
|
|
|
|
func hashOf(path string) (out string) {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
out = fmt.Sprintf("panic: %v", r)
|
|
}
|
|
}()
|
|
data, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return fmt.Sprintf("read error: %v", err)
|
|
}
|
|
var g core.Genesis
|
|
if err := json.Unmarshal(data, &g); err != nil {
|
|
return fmt.Sprintf("unmarshal error: %v", err)
|
|
}
|
|
b := g.ToBlock()
|
|
return fmt.Sprintf("block-0 = %s (allocs=%d ts=0x%x skipPMF=%v)",
|
|
b.Hash().Hex(), len(g.Alloc), g.Timestamp, g.SkipPostMergeFields)
|
|
}
|
|
|
|
func main() {
|
|
for _, path := range os.Args[1:] {
|
|
fmt.Printf("%s\n %s\n", path, hashOf(path))
|
|
}
|
|
}
|