mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 10:50:44 +00:00
core, beacon: fix engine API and genesis init
This commit is contained in:
parent
43a50656dd
commit
2169065ba6
7 changed files with 119 additions and 102 deletions
|
|
@ -35,6 +35,7 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) {
|
||||||
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
|
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
|
||||||
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
|
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
|
||||||
SlotNumber *hexutil.Uint64 `json:"slotNumber,omitempty"`
|
SlotNumber *hexutil.Uint64 `json:"slotNumber,omitempty"`
|
||||||
|
BlockAccessListHash *common.Hash `json:"blockAccessListHash,omitempty"`
|
||||||
}
|
}
|
||||||
var enc ExecutableData
|
var enc ExecutableData
|
||||||
enc.ParentHash = e.ParentHash
|
enc.ParentHash = e.ParentHash
|
||||||
|
|
@ -60,6 +61,7 @@ func (e ExecutableData) MarshalJSON() ([]byte, error) {
|
||||||
enc.BlobGasUsed = (*hexutil.Uint64)(e.BlobGasUsed)
|
enc.BlobGasUsed = (*hexutil.Uint64)(e.BlobGasUsed)
|
||||||
enc.ExcessBlobGas = (*hexutil.Uint64)(e.ExcessBlobGas)
|
enc.ExcessBlobGas = (*hexutil.Uint64)(e.ExcessBlobGas)
|
||||||
enc.SlotNumber = (*hexutil.Uint64)(e.SlotNumber)
|
enc.SlotNumber = (*hexutil.Uint64)(e.SlotNumber)
|
||||||
|
enc.BlockAccessListHash = e.BlockAccessListHash
|
||||||
return json.Marshal(&enc)
|
return json.Marshal(&enc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,6 +86,7 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error {
|
||||||
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
|
BlobGasUsed *hexutil.Uint64 `json:"blobGasUsed"`
|
||||||
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
|
ExcessBlobGas *hexutil.Uint64 `json:"excessBlobGas"`
|
||||||
SlotNumber *hexutil.Uint64 `json:"slotNumber,omitempty"`
|
SlotNumber *hexutil.Uint64 `json:"slotNumber,omitempty"`
|
||||||
|
BlockAccessListHash *common.Hash `json:"blockAccessListHash,omitempty"`
|
||||||
}
|
}
|
||||||
var dec ExecutableData
|
var dec ExecutableData
|
||||||
if err := json.Unmarshal(input, &dec); err != nil {
|
if err := json.Unmarshal(input, &dec); err != nil {
|
||||||
|
|
@ -160,5 +163,8 @@ func (e *ExecutableData) UnmarshalJSON(input []byte) error {
|
||||||
if dec.SlotNumber != nil {
|
if dec.SlotNumber != nil {
|
||||||
e.SlotNumber = (*uint64)(dec.SlotNumber)
|
e.SlotNumber = (*uint64)(dec.SlotNumber)
|
||||||
}
|
}
|
||||||
|
if dec.BlockAccessListHash != nil {
|
||||||
|
e.BlockAccessListHash = dec.BlockAccessListHash
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ type ExecutableData struct {
|
||||||
BlobGasUsed *uint64 `json:"blobGasUsed"`
|
BlobGasUsed *uint64 `json:"blobGasUsed"`
|
||||||
ExcessBlobGas *uint64 `json:"excessBlobGas"`
|
ExcessBlobGas *uint64 `json:"excessBlobGas"`
|
||||||
SlotNumber *uint64 `json:"slotNumber,omitempty"`
|
SlotNumber *uint64 `json:"slotNumber,omitempty"`
|
||||||
|
BlockAccessListHash *common.Hash `json:"blockAccessListHash,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSON type overrides for executableData.
|
// JSON type overrides for executableData.
|
||||||
|
|
@ -325,6 +326,7 @@ func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.H
|
||||||
ParentBeaconRoot: beaconRoot,
|
ParentBeaconRoot: beaconRoot,
|
||||||
RequestsHash: requestsHash,
|
RequestsHash: requestsHash,
|
||||||
SlotNumber: data.SlotNumber,
|
SlotNumber: data.SlotNumber,
|
||||||
|
BlockAccessListHash: data.BlockAccessListHash,
|
||||||
}
|
}
|
||||||
return types.NewBlockWithHeader(header).
|
return types.NewBlockWithHeader(header).
|
||||||
WithBody(types.Body{Transactions: txs, Uncles: nil, Withdrawals: data.Withdrawals}),
|
WithBody(types.Body{Transactions: txs, Uncles: nil, Withdrawals: data.Withdrawals}),
|
||||||
|
|
@ -353,6 +355,7 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, sidecars []*types.
|
||||||
BlobGasUsed: block.BlobGasUsed(),
|
BlobGasUsed: block.BlobGasUsed(),
|
||||||
ExcessBlobGas: block.ExcessBlobGas(),
|
ExcessBlobGas: block.ExcessBlobGas(),
|
||||||
SlotNumber: block.SlotNumber(),
|
SlotNumber: block.SlotNumber(),
|
||||||
|
BlockAccessListHash: block.BlockAccessListHash(),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add blobs.
|
// Add blobs.
|
||||||
|
|
|
||||||
|
|
@ -555,6 +555,7 @@ func (g *Genesis) toBlockWithRoot(root common.Hash) *types.Block {
|
||||||
if head.SlotNumber == nil {
|
if head.SlotNumber == nil {
|
||||||
head.SlotNumber = new(uint64)
|
head.SlotNumber = new(uint64)
|
||||||
}
|
}
|
||||||
|
head.BlockAccessListHash = &types.EmptyBlockAccessListHash
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return types.NewBlock(head, &types.Body{Withdrawals: withdrawals}, nil, trie.NewStackTrie(nil))
|
return types.NewBlock(head, &types.Body{Withdrawals: withdrawals}, nil, trie.NewStackTrie(nil))
|
||||||
|
|
|
||||||
|
|
@ -416,12 +416,12 @@ func AssembleBlock(chain consensus.ChainHeaderReader, header *types.Header, stat
|
||||||
// Assign the post-transition state root
|
// Assign the post-transition state root
|
||||||
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
|
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
|
||||||
|
|
||||||
|
if !chain.Config().IsAmsterdam(header.Number, header.Time) {
|
||||||
|
return types.NewBlock(header, body, receipts, trie.NewStackTrie(nil))
|
||||||
|
}
|
||||||
// Assign the BlockAccessListHash if Amsterdam has been enabled
|
// Assign the BlockAccessListHash if Amsterdam has been enabled
|
||||||
var bal *bal.BlockAccessList
|
bal := blockAccessList.ToEncodingObj()
|
||||||
if chain.Config().IsAmsterdam(header.Number, header.Time) {
|
|
||||||
bal = blockAccessList.ToEncodingObj()
|
|
||||||
balHash := bal.Hash()
|
balHash := bal.Hash()
|
||||||
header.BlockAccessListHash = &balHash
|
header.BlockAccessListHash = &balHash
|
||||||
}
|
|
||||||
return types.NewBlock(header, body, receipts, trie.NewStackTrie(nil)).WithAccessListUnsafe(bal)
|
return types.NewBlock(header, body, receipts, trie.NewStackTrie(nil)).WithAccessListUnsafe(bal)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,5 +59,8 @@ type ProcessResult struct {
|
||||||
Requests [][]byte
|
Requests [][]byte
|
||||||
Logs []*types.Log
|
Logs []*types.Log
|
||||||
GasUsed uint64
|
GasUsed uint64
|
||||||
|
|
||||||
|
// BAL is only meaningful for post-Amsterdam blocks. Please ensure
|
||||||
|
// fork validation is performed before accessing it.
|
||||||
Bal *bal.ConstructionBlockAccessList
|
Bal *bal.ConstructionBlockAccessList
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -415,6 +415,7 @@ func (b *Block) BaseFee() *big.Int {
|
||||||
|
|
||||||
func (b *Block) BeaconRoot() *common.Hash { return b.header.ParentBeaconRoot }
|
func (b *Block) BeaconRoot() *common.Hash { return b.header.ParentBeaconRoot }
|
||||||
func (b *Block) RequestsHash() *common.Hash { return b.header.RequestsHash }
|
func (b *Block) RequestsHash() *common.Hash { return b.header.RequestsHash }
|
||||||
|
func (b *Block) BlockAccessListHash() *common.Hash { return b.header.BlockAccessListHash }
|
||||||
|
|
||||||
func (b *Block) ExcessBlobGas() *uint64 {
|
func (b *Block) ExcessBlobGas() *uint64 {
|
||||||
var excessBlobGas *uint64
|
var excessBlobGas *uint64
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,9 @@ var (
|
||||||
// EmptyRequestsHash is the known hash of an empty request set, sha256("").
|
// EmptyRequestsHash is the known hash of an empty request set, sha256("").
|
||||||
EmptyRequestsHash = common.HexToHash("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
|
EmptyRequestsHash = common.HexToHash("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
|
||||||
|
|
||||||
|
// EmptyBlockAccessListHash is the known hash of an empty block accessList, keccak256(rlp.encode([])).
|
||||||
|
EmptyBlockAccessListHash = common.HexToHash("0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347")
|
||||||
|
|
||||||
// EmptyBinaryHash is the known hash of an empty binary trie.
|
// EmptyBinaryHash is the known hash of an empty binary trie.
|
||||||
EmptyBinaryHash = common.Hash{}
|
EmptyBinaryHash = common.Hash{}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue