mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
all: remove empty items in requests commitment
This commit is contained in:
parent
a11b4bebcb
commit
fdaa7015ef
7 changed files with 54 additions and 35 deletions
|
|
@ -265,15 +265,7 @@ func ExecutableDataToBlockNoHash(data ExecutableData, versionedHashes []common.H
|
||||||
|
|
||||||
var requestsHash *common.Hash
|
var requestsHash *common.Hash
|
||||||
if requests != nil {
|
if requests != nil {
|
||||||
// Put back request type byte.
|
h := types.CalcRequestsHash(requests)
|
||||||
typedRequests := make([][]byte, len(requests))
|
|
||||||
for i, reqdata := range requests {
|
|
||||||
typedReqdata := make([]byte, len(reqdata)+1)
|
|
||||||
typedReqdata[0] = byte(i)
|
|
||||||
copy(typedReqdata[1:], reqdata)
|
|
||||||
typedRequests[i] = typedReqdata
|
|
||||||
}
|
|
||||||
h := types.CalcRequestsHash(typedRequests)
|
|
||||||
requestsHash = &h
|
requestsHash = &h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -343,20 +335,11 @@ func BlockToExecutableData(block *types.Block, fees *big.Int, sidecars []*types.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove type byte in requests.
|
|
||||||
var plainRequests [][]byte
|
|
||||||
if requests != nil {
|
|
||||||
plainRequests = make([][]byte, len(requests))
|
|
||||||
for i, reqdata := range requests {
|
|
||||||
plainRequests[i] = reqdata[1:]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return &ExecutionPayloadEnvelope{
|
return &ExecutionPayloadEnvelope{
|
||||||
ExecutionPayload: data,
|
ExecutionPayload: data,
|
||||||
BlockValue: fees,
|
BlockValue: fees,
|
||||||
BlobsBundle: &bundle,
|
BlobsBundle: &bundle,
|
||||||
Requests: plainRequests,
|
Requests: requests,
|
||||||
Override: false,
|
Override: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -366,6 +366,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
||||||
// Gather the execution-layer triggered requests.
|
// Gather the execution-layer triggered requests.
|
||||||
var requests [][]byte
|
var requests [][]byte
|
||||||
if chainConfig.IsPrague(vmContext.BlockNumber, vmContext.Time) {
|
if chainConfig.IsPrague(vmContext.BlockNumber, vmContext.Time) {
|
||||||
|
requests = [][]byte{}
|
||||||
// EIP-6110 deposits
|
// EIP-6110 deposits
|
||||||
var allLogs []*types.Log
|
var allLogs []*types.Log
|
||||||
for _, receipt := range receipts {
|
for _, receipt := range receipts {
|
||||||
|
|
@ -375,12 +376,19 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("could not parse requests logs: %v", err))
|
return nil, nil, nil, NewError(ErrorEVM, fmt.Errorf("could not parse requests logs: %v", err))
|
||||||
}
|
}
|
||||||
|
if depositRequests != nil {
|
||||||
requests = append(requests, depositRequests)
|
requests = append(requests, depositRequests)
|
||||||
|
}
|
||||||
// EIP-7002 withdrawals
|
// EIP-7002 withdrawals
|
||||||
requests = append(requests, core.ProcessWithdrawalQueue(evm))
|
withdrawalRequests := core.ProcessWithdrawalQueue(evm)
|
||||||
|
if withdrawalRequests != nil {
|
||||||
|
requests = append(requests, withdrawalRequests)
|
||||||
|
}
|
||||||
// EIP-7251 consolidations
|
// EIP-7251 consolidations
|
||||||
requests = append(requests, core.ProcessConsolidationQueue(evm))
|
consolidationRequests := core.ProcessConsolidationQueue(evm)
|
||||||
|
if consolidationRequests != nil {
|
||||||
|
requests = append(requests, consolidationRequests)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit block
|
// Commit block
|
||||||
|
|
|
||||||
|
|
@ -349,6 +349,7 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
|
||||||
|
|
||||||
var requests [][]byte
|
var requests [][]byte
|
||||||
if config.IsPrague(b.header.Number, b.header.Time) {
|
if config.IsPrague(b.header.Number, b.header.Time) {
|
||||||
|
requests = [][]byte{}
|
||||||
// EIP-6110 deposits
|
// EIP-6110 deposits
|
||||||
var blockLogs []*types.Log
|
var blockLogs []*types.Log
|
||||||
for _, r := range b.receipts {
|
for _, r := range b.receipts {
|
||||||
|
|
@ -358,17 +359,23 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("failed to parse deposit log: %v", err))
|
panic(fmt.Sprintf("failed to parse deposit log: %v", err))
|
||||||
}
|
}
|
||||||
|
if depositRequests != nil {
|
||||||
requests = append(requests, depositRequests)
|
requests = append(requests, depositRequests)
|
||||||
|
}
|
||||||
// create EVM for system calls
|
// create EVM for system calls
|
||||||
blockContext := NewEVMBlockContext(b.header, cm, &b.header.Coinbase)
|
blockContext := NewEVMBlockContext(b.header, cm, &b.header.Coinbase)
|
||||||
evm := vm.NewEVM(blockContext, statedb, cm.config, vm.Config{})
|
evm := vm.NewEVM(blockContext, statedb, cm.config, vm.Config{})
|
||||||
// EIP-7002 withdrawals
|
// EIP-7002 withdrawals
|
||||||
withdrawalRequests := ProcessWithdrawalQueue(evm)
|
withdrawalRequests := ProcessWithdrawalQueue(evm)
|
||||||
|
if withdrawalRequests != nil {
|
||||||
requests = append(requests, withdrawalRequests)
|
requests = append(requests, withdrawalRequests)
|
||||||
|
}
|
||||||
// EIP-7251 consolidations
|
// EIP-7251 consolidations
|
||||||
consolidationRequests := ProcessConsolidationQueue(evm)
|
consolidationRequests := ProcessConsolidationQueue(evm)
|
||||||
|
if consolidationRequests != nil {
|
||||||
requests = append(requests, consolidationRequests)
|
requests = append(requests, consolidationRequests)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if requests != nil {
|
if requests != nil {
|
||||||
reqHash := types.CalcRequestsHash(requests)
|
reqHash := types.CalcRequestsHash(requests)
|
||||||
b.header.RequestsHash = &reqHash
|
b.header.RequestsHash = &reqHash
|
||||||
|
|
|
||||||
|
|
@ -472,9 +472,7 @@ func (g *Genesis) toBlockWithRoot(root common.Hash) *types.Block {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if conf.IsPrague(num, g.Timestamp) {
|
if conf.IsPrague(num, g.Timestamp) {
|
||||||
emptyRequests := [][]byte{{0x00}, {0x01}, {0x02}}
|
head.RequestsHash = &types.EmptyRequestsHash
|
||||||
rhash := types.CalcRequestsHash(emptyRequests)
|
|
||||||
head.RequestsHash = &rhash
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return types.NewBlock(head, &types.Body{Withdrawals: withdrawals}, nil, trie.NewStackTrie(nil))
|
return types.NewBlock(head, &types.Body{Withdrawals: withdrawals}, nil, trie.NewStackTrie(nil))
|
||||||
|
|
|
||||||
|
|
@ -106,19 +106,26 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
||||||
// Read requests if Prague is enabled.
|
// Read requests if Prague is enabled.
|
||||||
var requests [][]byte
|
var requests [][]byte
|
||||||
if p.config.IsPrague(block.Number(), block.Time()) {
|
if p.config.IsPrague(block.Number(), block.Time()) {
|
||||||
|
requests = [][]byte{}
|
||||||
// EIP-6110 deposits
|
// EIP-6110 deposits
|
||||||
depositRequests, err := ParseDepositLogs(allLogs, p.config)
|
depositRequests, err := ParseDepositLogs(allLogs, p.config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if depositRequests != nil {
|
||||||
requests = append(requests, depositRequests)
|
requests = append(requests, depositRequests)
|
||||||
|
}
|
||||||
// EIP-7002 withdrawals
|
// EIP-7002 withdrawals
|
||||||
withdrawalRequests := ProcessWithdrawalQueue(evm)
|
withdrawalRequests := ProcessWithdrawalQueue(evm)
|
||||||
|
if withdrawalRequests != nil {
|
||||||
requests = append(requests, withdrawalRequests)
|
requests = append(requests, withdrawalRequests)
|
||||||
|
}
|
||||||
// EIP-7251 consolidations
|
// EIP-7251 consolidations
|
||||||
consolidationRequests := ProcessConsolidationQueue(evm)
|
consolidationRequests := ProcessConsolidationQueue(evm)
|
||||||
|
if consolidationRequests != nil {
|
||||||
requests = append(requests, consolidationRequests)
|
requests = append(requests, consolidationRequests)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
|
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
|
||||||
p.chain.engine.Finalize(p.chain, header, tracingStateDB, block.Body())
|
p.chain.engine.Finalize(p.chain, header, tracingStateDB, block.Body())
|
||||||
|
|
@ -302,6 +309,9 @@ func processRequestsSystemCall(evm *vm.EVM, requestType byte, addr common.Addres
|
||||||
evm.StateDB.AddAddressToAccessList(addr)
|
evm.StateDB.AddAddressToAccessList(addr)
|
||||||
ret, _, _ := evm.Call(vm.AccountRef(msg.From), *msg.To, msg.Data, 30_000_000, common.U2560)
|
ret, _, _ := evm.Call(vm.AccountRef(msg.From), *msg.To, msg.Data, 30_000_000, common.U2560)
|
||||||
evm.StateDB.Finalise(true)
|
evm.StateDB.Finalise(true)
|
||||||
|
if len(ret) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Create withdrawals requestsData with prefix 0x01
|
// Create withdrawals requestsData with prefix 0x01
|
||||||
requestsData := make([]byte, len(ret)+1)
|
requestsData := make([]byte, len(ret)+1)
|
||||||
|
|
@ -323,5 +333,8 @@ func ParseDepositLogs(logs []*types.Log, config *params.ChainConfig) ([]byte, er
|
||||||
deposits = append(deposits, request...)
|
deposits = append(deposits, request...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(deposits) == 1 {
|
||||||
|
deposits = nil
|
||||||
|
}
|
||||||
return deposits, nil
|
return deposits, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,9 @@ var (
|
||||||
// EmptyWithdrawalsHash is the known hash of the empty withdrawal set.
|
// EmptyWithdrawalsHash is the known hash of the empty withdrawal set.
|
||||||
EmptyWithdrawalsHash = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
|
EmptyWithdrawalsHash = common.HexToHash("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
|
||||||
|
|
||||||
|
// EmptyRequestsHash is the known hash of an empty request set, sha256("").
|
||||||
|
EmptyRequestsHash = common.HexToHash("e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
|
||||||
|
|
||||||
// EmptyVerkleHash is the known hash of an empty verkle trie.
|
// EmptyVerkleHash is the known hash of an empty verkle trie.
|
||||||
EmptyVerkleHash = common.Hash{}
|
EmptyVerkleHash = common.Hash{}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -121,19 +121,26 @@ func (miner *Miner) generateWork(params *generateParams, witness bool) *newPaylo
|
||||||
// Collect consensus-layer requests if Prague is enabled.
|
// Collect consensus-layer requests if Prague is enabled.
|
||||||
var requests [][]byte
|
var requests [][]byte
|
||||||
if miner.chainConfig.IsPrague(work.header.Number, work.header.Time) {
|
if miner.chainConfig.IsPrague(work.header.Number, work.header.Time) {
|
||||||
|
requests = [][]byte{}
|
||||||
// EIP-6110 deposits
|
// EIP-6110 deposits
|
||||||
depositRequests, err := core.ParseDepositLogs(allLogs, miner.chainConfig)
|
depositRequests, err := core.ParseDepositLogs(allLogs, miner.chainConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &newPayloadResult{err: err}
|
return &newPayloadResult{err: err}
|
||||||
}
|
}
|
||||||
|
if depositRequests != nil {
|
||||||
requests = append(requests, depositRequests)
|
requests = append(requests, depositRequests)
|
||||||
|
}
|
||||||
// EIP-7002 withdrawals
|
// EIP-7002 withdrawals
|
||||||
withdrawalRequests := core.ProcessWithdrawalQueue(work.evm)
|
withdrawalRequests := core.ProcessWithdrawalQueue(work.evm)
|
||||||
|
if withdrawalRequests != nil {
|
||||||
requests = append(requests, withdrawalRequests)
|
requests = append(requests, withdrawalRequests)
|
||||||
|
}
|
||||||
// EIP-7251 consolidations
|
// EIP-7251 consolidations
|
||||||
consolidationRequests := core.ProcessConsolidationQueue(work.evm)
|
consolidationRequests := core.ProcessConsolidationQueue(work.evm)
|
||||||
|
if consolidationRequests != nil {
|
||||||
requests = append(requests, consolidationRequests)
|
requests = append(requests, consolidationRequests)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if requests != nil {
|
if requests != nil {
|
||||||
reqHash := types.CalcRequestsHash(requests)
|
reqHash := types.CalcRequestsHash(requests)
|
||||||
work.header.RequestsHash = &reqHash
|
work.header.RequestsHash = &reqHash
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue