mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
all: rename BeaconRoot -> ParentBeaconRoot
This commit is contained in:
parent
d51660bcc9
commit
22adccb439
10 changed files with 83 additions and 83 deletions
|
|
@ -226,7 +226,7 @@ func ExecutableDataToBlock(params ExecutableData, versionedHashes []common.Hash,
|
|||
WithdrawalsHash: withdrawalsRoot,
|
||||
ExcessBlobGas: params.ExcessBlobGas,
|
||||
BlobGasUsed: params.BlobGasUsed,
|
||||
BeaconRoot: beaconRoot,
|
||||
ParentBeaconRoot: beaconRoot,
|
||||
}
|
||||
block := types.NewBlockWithHeader(header).WithBody(txs, nil /* uncles */).WithWithdrawals(params.Withdrawals)
|
||||
if block.Hash() != params.BlockHash {
|
||||
|
|
|
|||
|
|
@ -277,11 +277,11 @@ func (beacon *Beacon) verifyHeader(chain consensus.ChainHeaderReader, header, pa
|
|||
return fmt.Errorf("invalid excessBlobGas: have %d, expected nil", header.ExcessBlobGas)
|
||||
case header.BlobGasUsed != nil:
|
||||
return fmt.Errorf("invalid blobGasUsed: have %d, expected nil", header.BlobGasUsed)
|
||||
case header.BeaconRoot != nil:
|
||||
return fmt.Errorf("invalid beaconRoot, have %#x, expected nil", header.BeaconRoot)
|
||||
case header.ParentBeaconRoot != nil:
|
||||
return fmt.Errorf("invalid parentBeaconRoot, have %#x, expected nil", header.ParentBeaconRoot)
|
||||
}
|
||||
} else {
|
||||
if header.BeaconRoot == nil {
|
||||
if header.ParentBeaconRoot == nil {
|
||||
return errors.New("header is missing beaconRoot")
|
||||
}
|
||||
if err := eip4844.VerifyEIP4844Header(parent, header); err != nil {
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ func makeHeader(chain consensus.ChainReader, parent *types.Block, state *state.S
|
|||
excessBlobGas := eip4844.CalcExcessBlobGas(parentExcessBlobGas, parentBlobGasUsed)
|
||||
header.ExcessBlobGas = &excessBlobGas
|
||||
header.BlobGasUsed = new(uint64)
|
||||
header.BeaconRoot = new(common.Hash)
|
||||
header.ParentBeaconRoot = new(common.Hash)
|
||||
}
|
||||
return header
|
||||
}
|
||||
|
|
|
|||
|
|
@ -486,7 +486,7 @@ func (g *Genesis) ToBlock() *types.Block {
|
|||
// EIP-4788: The parentBeaconBlockRoot of the genesis block is always
|
||||
// the zero hash. This is because the genesis block does not have a parent
|
||||
// by definition.
|
||||
head.BeaconRoot = new(common.Hash)
|
||||
head.ParentBeaconRoot = new(common.Hash)
|
||||
// EIP-4844 fields
|
||||
head.ExcessBlobGas = g.ExcessBlobGas
|
||||
head.BlobGasUsed = g.BlobGasUsed
|
||||
|
|
|
|||
|
|
@ -412,7 +412,7 @@ func GenerateBadBlock(parent *types.Block, engine consensus.Engine, txs types.Tr
|
|||
header.BlobGasUsed = &used
|
||||
|
||||
beaconRoot := common.HexToHash("0xbeac00")
|
||||
header.BeaconRoot = &beaconRoot
|
||||
header.ParentBeaconRoot = &beaconRoot
|
||||
}
|
||||
// Assemble and return the final block for sealing
|
||||
if config.IsShanghai(header.Number, header.Time) {
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ type Header struct {
|
|||
// ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers.
|
||||
ExcessBlobGas *uint64 `json:"excessBlobGas" rlp:"optional"`
|
||||
|
||||
// BeaconRoot was added by EIP-4788 and is ignored in legacy headers.
|
||||
BeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"`
|
||||
// ParentBeaconRoot was added by EIP-4788 and is ignored in legacy headers.
|
||||
ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"`
|
||||
}
|
||||
|
||||
// field type overrides for gencodec
|
||||
|
|
@ -300,9 +300,9 @@ func CopyHeader(h *Header) *Header {
|
|||
cpy.BlobGasUsed = new(uint64)
|
||||
*cpy.BlobGasUsed = *h.BlobGasUsed
|
||||
}
|
||||
if h.BeaconRoot != nil {
|
||||
cpy.BeaconRoot = new(common.Hash)
|
||||
*cpy.BeaconRoot = *h.BeaconRoot
|
||||
if h.ParentBeaconRoot != nil {
|
||||
cpy.ParentBeaconRoot = new(common.Hash)
|
||||
*cpy.ParentBeaconRoot = *h.ParentBeaconRoot
|
||||
}
|
||||
return &cpy
|
||||
}
|
||||
|
|
@ -383,7 +383,7 @@ func (b *Block) BaseFee() *big.Int {
|
|||
return new(big.Int).Set(b.header.BaseFee)
|
||||
}
|
||||
|
||||
func (b *Block) BeaconRoot() *common.Hash { return b.header.BeaconRoot }
|
||||
func (b *Block) BeaconRoot() *common.Hash { return b.header.ParentBeaconRoot }
|
||||
|
||||
func (b *Block) ExcessBlobGas() *uint64 {
|
||||
var excessBlobGas *uint64
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func (h Header) MarshalJSON() ([]byte, error) {
|
|||
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
||||
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"`
|
||||
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"`
|
||||
BeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"`
|
||||
ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"`
|
||||
Hash common.Hash `json:"hash"`
|
||||
}
|
||||
var enc Header
|
||||
|
|
@ -58,7 +58,7 @@ func (h Header) MarshalJSON() ([]byte, error) {
|
|||
enc.WithdrawalsHash = h.WithdrawalsHash
|
||||
enc.BlobGasUsed = (*hexutil.Uint64)(h.BlobGasUsed)
|
||||
enc.ExcessBlobGas = (*hexutil.Uint64)(h.ExcessBlobGas)
|
||||
enc.BeaconRoot = h.BeaconRoot
|
||||
enc.ParentBeaconRoot = h.ParentBeaconRoot
|
||||
enc.Hash = h.Hash()
|
||||
return json.Marshal(&enc)
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ func (h *Header) UnmarshalJSON(input []byte) error {
|
|||
WithdrawalsHash *common.Hash `json:"withdrawalsRoot" rlp:"optional"`
|
||||
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed" rlp:"optional"`
|
||||
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas" rlp:"optional"`
|
||||
BeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"`
|
||||
ParentBeaconRoot *common.Hash `json:"parentBeaconBlockRoot" rlp:"optional"`
|
||||
}
|
||||
var dec Header
|
||||
if err := json.Unmarshal(input, &dec); err != nil {
|
||||
|
|
@ -160,8 +160,8 @@ func (h *Header) UnmarshalJSON(input []byte) error {
|
|||
if dec.ExcessBlobGas != nil {
|
||||
h.ExcessBlobGas = (*uint64)(dec.ExcessBlobGas)
|
||||
}
|
||||
if dec.BeaconRoot != nil {
|
||||
h.BeaconRoot = dec.BeaconRoot
|
||||
if dec.ParentBeaconRoot != nil {
|
||||
h.ParentBeaconRoot = dec.ParentBeaconRoot
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ func (obj *Header) EncodeRLP(_w io.Writer) error {
|
|||
_tmp2 := obj.WithdrawalsHash != nil
|
||||
_tmp3 := obj.BlobGasUsed != nil
|
||||
_tmp4 := obj.ExcessBlobGas != nil
|
||||
_tmp5 := obj.BeaconRoot != nil
|
||||
_tmp5 := obj.ParentBeaconRoot != nil
|
||||
if _tmp1 || _tmp2 || _tmp3 || _tmp4 || _tmp5 {
|
||||
if obj.BaseFee == nil {
|
||||
w.Write(rlp.EmptyString)
|
||||
|
|
@ -77,10 +77,10 @@ func (obj *Header) EncodeRLP(_w io.Writer) error {
|
|||
}
|
||||
}
|
||||
if _tmp5 {
|
||||
if obj.BeaconRoot == nil {
|
||||
if obj.ParentBeaconRoot == nil {
|
||||
w.Write([]byte{0x80})
|
||||
} else {
|
||||
w.WriteBytes(obj.BeaconRoot[:])
|
||||
w.WriteBytes(obj.ParentBeaconRoot[:])
|
||||
}
|
||||
}
|
||||
w.ListEnd(_tmp0)
|
||||
|
|
|
|||
|
|
@ -1345,8 +1345,8 @@ func RPCMarshalHeader(head *types.Header) map[string]interface{} {
|
|||
if head.ExcessBlobGas != nil {
|
||||
result["excessBlobGas"] = hexutil.Uint64(*head.ExcessBlobGas)
|
||||
}
|
||||
if head.BeaconRoot != nil {
|
||||
result["parentBeaconBlockRoot"] = head.BeaconRoot
|
||||
if head.ParentBeaconRoot != nil {
|
||||
result["parentBeaconBlockRoot"] = head.ParentBeaconRoot
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -947,7 +947,7 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) {
|
|||
}
|
||||
header.BlobGasUsed = new(uint64)
|
||||
header.ExcessBlobGas = &excessBlobGas
|
||||
header.BeaconRoot = genParams.beaconRoot
|
||||
header.ParentBeaconRoot = genParams.beaconRoot
|
||||
}
|
||||
// Run the consensus preparation with the default or customized consensus engine.
|
||||
if err := w.engine.Prepare(w.chain, header); err != nil {
|
||||
|
|
@ -962,10 +962,10 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) {
|
|||
log.Error("Failed to create sealing context", "err", err)
|
||||
return nil, err
|
||||
}
|
||||
if header.BeaconRoot != nil {
|
||||
if header.ParentBeaconRoot != nil {
|
||||
context := core.NewEVMBlockContext(header, w.chain, nil)
|
||||
vmenv := vm.NewEVM(context, vm.TxContext{}, env.state, w.chainConfig, vm.Config{})
|
||||
core.ProcessBeaconBlockRoot(*header.BeaconRoot, vmenv, env.state)
|
||||
core.ProcessBeaconBlockRoot(*header.ParentBeaconRoot, vmenv, env.state)
|
||||
}
|
||||
return env, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue