mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
Lux mainnet C-Chain canonical genesis hash is
0x3f4fa2a0b0ce089f52bf0ae9199c75ffdd76ecafc987794050cb0d286f1ec61e,
matching the 1,082,781-block historic RLP export at
lux-mainnet-96369.rlp. The genesis JSON activates Cancun at
genesis time (cancunTime=0) for MCOPY etc., but the genesis BLOCK
itself predates Cancun and must use the 16-field pre-Shanghai
header format to preserve hash continuity with the historic chain.
luxfi/geth's core.Genesis exposes SkipPostMergeFields for exactly
this case. luxfi/evm shipped the JSON unmarshaling but ignored the
flag in toBlock(), so any post-merge field that fork-activates at
genesis time (ParentBeaconRoot, ExcessBlobGas, BlobGasUsed,
WithdrawalsHash) gets baked into the header and shifts the
computed genesis hash, e.g. to 0x1ade42ec…. luxd then panics
during EnsureGenesisState because the resulting state root has no
parent in pathdb's layertree ("triedb parent
[0x56e81f17…] layer missing"), which blocks mainnet C-Chain
bootstrap and admin_importChain.
Mirror the upstream geth pattern: gate the entire Shanghai+
post-merge field assignment block with `if !g.SkipPostMergeFields`,
and round-trip the flag through MarshalJSON/UnmarshalJSON in
gen_genesis.go.
Verification (TestSkipPostMergeFieldsGenesisHash pins both):
- `skipPostMergeFields: true` → 0x3f4fa2a0… (canonical, RLP block 0)
- flag absent / false → different hash (gate is active)
162 lines
6.4 KiB
Go
162 lines
6.4 KiB
Go
// Code generated by github.com/fjl/gencodec. DO NOT EDIT.
|
|
|
|
package core
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"math/big"
|
|
|
|
"github.com/luxfi/evm/params"
|
|
"github.com/luxfi/geth/common"
|
|
"github.com/luxfi/geth/common/hexutil"
|
|
"github.com/luxfi/geth/core/types"
|
|
"github.com/luxfi/math"
|
|
)
|
|
|
|
var _ = (*genesisSpecMarshaling)(nil)
|
|
|
|
// MarshalJSON marshals as JSON.
|
|
func (g Genesis) MarshalJSON() ([]byte, error) {
|
|
type Genesis struct {
|
|
Config *params.ChainConfig `json:"config"`
|
|
Nonce math.HexOrDecimal64 `json:"nonce"`
|
|
Timestamp math.HexOrDecimal64 `json:"timestamp"`
|
|
ExtraData hexutil.Bytes `json:"extraData"`
|
|
GasLimit math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"`
|
|
Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"`
|
|
Mixhash common.Hash `json:"mixHash"`
|
|
Coinbase common.Address `json:"coinbase"`
|
|
Alloc map[common.UnprefixedAddress]types.Account `json:"alloc" gencodec:"required"`
|
|
AirdropHash common.Hash `json:"airdropHash"`
|
|
AirdropAmount *math.HexOrDecimal256 `json:"airdropAmount"`
|
|
AirdropData []byte `json:"-"`
|
|
Number math.HexOrDecimal64 `json:"number"`
|
|
GasUsed math.HexOrDecimal64 `json:"gasUsed"`
|
|
ParentHash common.Hash `json:"parentHash"`
|
|
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"`
|
|
ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"`
|
|
BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"`
|
|
SkipPostMergeFields bool `json:"skipPostMergeFields,omitempty"`
|
|
}
|
|
var enc Genesis
|
|
enc.Config = g.Config
|
|
enc.Nonce = math.HexOrDecimal64(g.Nonce)
|
|
enc.Timestamp = math.HexOrDecimal64(g.Timestamp)
|
|
enc.ExtraData = g.ExtraData
|
|
enc.GasLimit = math.HexOrDecimal64(g.GasLimit)
|
|
enc.Difficulty = (*math.HexOrDecimal256)(g.Difficulty)
|
|
enc.Mixhash = g.Mixhash
|
|
enc.Coinbase = g.Coinbase
|
|
if g.Alloc != nil {
|
|
enc.Alloc = make(map[common.UnprefixedAddress]types.Account, len(g.Alloc))
|
|
for k, v := range g.Alloc {
|
|
enc.Alloc[common.UnprefixedAddress(k)] = v
|
|
}
|
|
}
|
|
enc.AirdropHash = g.AirdropHash
|
|
enc.AirdropAmount = (*math.HexOrDecimal256)(g.AirdropAmount)
|
|
enc.AirdropData = g.AirdropData
|
|
enc.Number = math.HexOrDecimal64(g.Number)
|
|
enc.GasUsed = math.HexOrDecimal64(g.GasUsed)
|
|
enc.ParentHash = g.ParentHash
|
|
enc.BaseFee = (*math.HexOrDecimal256)(g.BaseFee)
|
|
enc.ExcessBlobGas = (*math.HexOrDecimal64)(g.ExcessBlobGas)
|
|
enc.BlobGasUsed = (*math.HexOrDecimal64)(g.BlobGasUsed)
|
|
enc.SkipPostMergeFields = g.SkipPostMergeFields
|
|
return json.Marshal(&enc)
|
|
}
|
|
|
|
// UnmarshalJSON unmarshals from JSON.
|
|
func (g *Genesis) UnmarshalJSON(input []byte) error {
|
|
type Genesis struct {
|
|
Config *params.ChainConfig `json:"config"`
|
|
Nonce *math.HexOrDecimal64 `json:"nonce"`
|
|
Timestamp *math.HexOrDecimal64 `json:"timestamp"`
|
|
ExtraData *hexutil.Bytes `json:"extraData"`
|
|
GasLimit *math.HexOrDecimal64 `json:"gasLimit" gencodec:"required"`
|
|
Difficulty *math.HexOrDecimal256 `json:"difficulty" gencodec:"required"`
|
|
Mixhash *common.Hash `json:"mixHash"`
|
|
Coinbase *common.Address `json:"coinbase"`
|
|
Alloc map[common.UnprefixedAddress]types.Account `json:"alloc" gencodec:"required"`
|
|
AirdropHash *common.Hash `json:"airdropHash"`
|
|
AirdropAmount *math.HexOrDecimal256 `json:"airdropAmount"`
|
|
AirdropData []byte `json:"-"`
|
|
Number *math.HexOrDecimal64 `json:"number"`
|
|
GasUsed *math.HexOrDecimal64 `json:"gasUsed"`
|
|
ParentHash *common.Hash `json:"parentHash"`
|
|
BaseFee *math.HexOrDecimal256 `json:"baseFeePerGas"`
|
|
ExcessBlobGas *math.HexOrDecimal64 `json:"excessBlobGas"`
|
|
BlobGasUsed *math.HexOrDecimal64 `json:"blobGasUsed"`
|
|
SkipPostMergeFields *bool `json:"skipPostMergeFields,omitempty"`
|
|
}
|
|
var dec Genesis
|
|
if err := json.Unmarshal(input, &dec); err != nil {
|
|
return err
|
|
}
|
|
if dec.Config != nil {
|
|
g.Config = dec.Config
|
|
}
|
|
if dec.Nonce != nil {
|
|
g.Nonce = uint64(*dec.Nonce)
|
|
}
|
|
if dec.Timestamp != nil {
|
|
g.Timestamp = uint64(*dec.Timestamp)
|
|
}
|
|
if dec.ExtraData != nil {
|
|
g.ExtraData = *dec.ExtraData
|
|
}
|
|
if dec.GasLimit == nil {
|
|
return errors.New("missing required field 'gasLimit' for Genesis")
|
|
}
|
|
g.GasLimit = uint64(*dec.GasLimit)
|
|
if dec.Difficulty == nil {
|
|
return errors.New("missing required field 'difficulty' for Genesis")
|
|
}
|
|
g.Difficulty = (*big.Int)(dec.Difficulty)
|
|
if dec.Mixhash != nil {
|
|
g.Mixhash = *dec.Mixhash
|
|
}
|
|
if dec.Coinbase != nil {
|
|
g.Coinbase = *dec.Coinbase
|
|
}
|
|
if dec.Alloc == nil {
|
|
return errors.New("missing required field 'alloc' for Genesis")
|
|
}
|
|
g.Alloc = make(types.GenesisAlloc, len(dec.Alloc))
|
|
for k, v := range dec.Alloc {
|
|
g.Alloc[common.Address(k)] = v
|
|
}
|
|
if dec.AirdropHash != nil {
|
|
g.AirdropHash = *dec.AirdropHash
|
|
}
|
|
if dec.AirdropAmount != nil {
|
|
g.AirdropAmount = (*big.Int)(dec.AirdropAmount)
|
|
}
|
|
if dec.AirdropData != nil {
|
|
g.AirdropData = dec.AirdropData
|
|
}
|
|
if dec.Number != nil {
|
|
g.Number = uint64(*dec.Number)
|
|
}
|
|
if dec.GasUsed != nil {
|
|
g.GasUsed = uint64(*dec.GasUsed)
|
|
}
|
|
if dec.ParentHash != nil {
|
|
g.ParentHash = *dec.ParentHash
|
|
}
|
|
if dec.BaseFee != nil {
|
|
g.BaseFee = (*big.Int)(dec.BaseFee)
|
|
}
|
|
if dec.ExcessBlobGas != nil {
|
|
g.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas)
|
|
}
|
|
if dec.BlobGasUsed != nil {
|
|
g.BlobGasUsed = (*uint64)(dec.BlobGasUsed)
|
|
}
|
|
if dec.SkipPostMergeFields != nil {
|
|
g.SkipPostMergeFields = *dec.SkipPostMergeFields
|
|
}
|
|
return nil
|
|
}
|