internal/ethapi: handle prague system calls in eth_simulate (#31176)
eth_simulate was not processing prague system calls for history contract and EL requests resulting in inaccurate stateRoot and requestsRoot fields in the block.
This commit is contained in:
parent
c8781be762
commit
b1f88ef9bd
|
@ -194,6 +194,10 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
|
||||||
if precompiles != nil {
|
if precompiles != nil {
|
||||||
evm.SetPrecompiles(precompiles)
|
evm.SetPrecompiles(precompiles)
|
||||||
}
|
}
|
||||||
|
if sim.chainConfig.IsPrague(header.Number, header.Time) || sim.chainConfig.IsVerkle(header.Number, header.Time) {
|
||||||
|
core.ProcessParentBlockHash(header.ParentHash, evm)
|
||||||
|
}
|
||||||
|
var allLogs []*types.Log
|
||||||
for i, call := range block.Calls {
|
for i, call := range block.Calls {
|
||||||
if err := ctx.Err(); err != nil {
|
if err := ctx.Err(); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
@ -234,9 +238,23 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
callRes.Status = hexutil.Uint64(types.ReceiptStatusSuccessful)
|
callRes.Status = hexutil.Uint64(types.ReceiptStatusSuccessful)
|
||||||
|
allLogs = append(allLogs, callRes.Logs...)
|
||||||
}
|
}
|
||||||
callResults[i] = callRes
|
callResults[i] = callRes
|
||||||
}
|
}
|
||||||
|
var requests [][]byte
|
||||||
|
// Process EIP-7685 requests
|
||||||
|
if sim.chainConfig.IsPrague(header.Number, header.Time) {
|
||||||
|
requests = [][]byte{}
|
||||||
|
// EIP-6110
|
||||||
|
if err := core.ParseDepositLogs(&requests, allLogs, sim.chainConfig); err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
// EIP-7002
|
||||||
|
core.ProcessWithdrawalQueue(&requests, evm)
|
||||||
|
// EIP-7251
|
||||||
|
core.ProcessConsolidationQueue(&requests, evm)
|
||||||
|
}
|
||||||
header.Root = sim.state.IntermediateRoot(true)
|
header.Root = sim.state.IntermediateRoot(true)
|
||||||
header.GasUsed = gasUsed
|
header.GasUsed = gasUsed
|
||||||
if sim.chainConfig.IsCancun(header.Number, header.Time) {
|
if sim.chainConfig.IsCancun(header.Number, header.Time) {
|
||||||
|
@ -246,6 +264,10 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
|
||||||
if sim.chainConfig.IsShanghai(header.Number, header.Time) {
|
if sim.chainConfig.IsShanghai(header.Number, header.Time) {
|
||||||
withdrawals = make([]*types.Withdrawal, 0)
|
withdrawals = make([]*types.Withdrawal, 0)
|
||||||
}
|
}
|
||||||
|
if requests != nil {
|
||||||
|
reqHash := types.CalcRequestsHash(requests)
|
||||||
|
header.RequestsHash = &reqHash
|
||||||
|
}
|
||||||
b := types.NewBlock(header, &types.Body{Transactions: txes, Withdrawals: withdrawals}, receipts, trie.NewStackTrie(nil))
|
b := types.NewBlock(header, &types.Body{Transactions: txes, Withdrawals: withdrawals}, receipts, trie.NewStackTrie(nil))
|
||||||
repairLogs(callResults, b.Hash())
|
repairLogs(callResults, b.Hash())
|
||||||
return b, callResults, nil
|
return b, callResults, nil
|
||||||
|
|
Loading…
Reference in New Issue