Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero ParentBeaconBlockRoot in genesis #7958

Merged
merged 8 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/genesis_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,13 @@ func GenesisToBlock(g *types.Genesis, tmpDir string) (*types.Block, *state.Intra
head.BaseFee = new(big.Int).SetUint64(params.InitialBaseFee)
}
}
if g.Config.IsCancun(g.Timestamp) {
if g.ParentBeaconBlockRoot == nil {
head.ParentBeaconBlockRoot = &libcommon.Hash{}
} else {
head.ParentBeaconBlockRoot = g.ParentBeaconBlockRoot
}
}

var withdrawals []*types.Withdrawal
if g.Config != nil && (g.Config.IsShanghai(g.Timestamp)) {
Expand Down
91 changes: 48 additions & 43 deletions core/types/gen_genesis.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 15 additions & 14 deletions core/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,21 @@ var ErrGenesisNoConfig = errors.New("genesis has no chain configuration")
// Genesis specifies the header fields, state of a genesis block. It also defines hard
// fork switch-over blocks through the chain configuration.
type Genesis struct {
Config *chain.Config `json:"config"`
Nonce uint64 `json:"nonce"`
Timestamp uint64 `json:"timestamp"`
ExtraData []byte `json:"extraData"`
GasLimit uint64 `json:"gasLimit" gencodec:"required"`
Difficulty *big.Int `json:"difficulty" gencodec:"required"`
Mixhash common.Hash `json:"mixHash"`
Coinbase common.Address `json:"coinbase"`
BaseFee *big.Int `json:"baseFeePerGas"`
BlobGasUsed *uint64 `json:"blobGasUsed"`
ExcessBlobGas *uint64 `json:"excessBlobGas"`
Alloc GenesisAlloc `json:"alloc" gencodec:"required"`
AuRaStep uint64 `json:"auRaStep"`
AuRaSeal []byte `json:"auRaSeal"`
Config *chain.Config `json:"config"`
Nonce uint64 `json:"nonce"`
Timestamp uint64 `json:"timestamp"`
ExtraData []byte `json:"extraData"`
GasLimit uint64 `json:"gasLimit" gencodec:"required"`
Difficulty *big.Int `json:"difficulty" gencodec:"required"`
Mixhash common.Hash `json:"mixHash"`
Coinbase common.Address `json:"coinbase"`
BaseFee *big.Int `json:"baseFeePerGas"`
BlobGasUsed *uint64 `json:"blobGasUsed"`
ExcessBlobGas *uint64 `json:"excessBlobGas"`
Alloc GenesisAlloc `json:"alloc" gencodec:"required"`
AuRaStep uint64 `json:"auRaStep"`
AuRaSeal []byte `json:"auRaSeal"`
ParentBeaconBlockRoot *common.Hash `json:"parentBeaconBlockRoot"`
somnathb1 marked this conversation as resolved.
Show resolved Hide resolved

// These fields are used for consensus tests. Please don't use them
// in actual genesis blocks.
Expand Down
Loading