Skip to content

Commit

Permalink
Zero ParentBeaconBlockRoot in genesis (#7958)
Browse files Browse the repository at this point in the history
  • Loading branch information
somnathb1 authored and AskAlexSharov committed Sep 6, 2023
1 parent bf57f52 commit 43502a8
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 57 deletions.
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"`

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

0 comments on commit 43502a8

Please sign in to comment.