Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions consensus/beacon/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func isPostMerge(config *params.ChainConfig, blockNum uint64, timestamp uint64)
config.MergeNetsplitBlock != nil && blockNum >= config.MergeNetsplitBlock.Uint64() ||
config.ShanghaiTime != nil && timestamp >= *config.ShanghaiTime ||
// If OP-Stack then bedrock activation number determines when TTD (eth Merge) has been reached.
config.Optimism != nil && config.IsBedrock(new(big.Int).SetUint64(blockNum))
config.IsOptimismBedrock(new(big.Int).SetUint64(blockNum))
}

// Author implements consensus.Engine, returning the verified author of the block.
Expand Down Expand Up @@ -125,7 +125,7 @@ func (beacon *Beacon) VerifyHeader(chain consensus.ChainHeaderReader, header *ty
// Check >0 TDs with pre-merge, --0 TDs with post-merge rules
if header.Difficulty.Sign() > 0 ||
// OP-Stack: transitioned networks must use legacy consensus pre-Bedrock
(cfg.IsOptimism() && !cfg.IsBedrock(header.Number)) {
cfg.IsOptimismBedrock(header.Number) {
return beacon.ethone.VerifyHeader(chain, header)
}
return beacon.verifyHeader(chain, header, parent)
Expand Down
4 changes: 4 additions & 0 deletions fork.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ def:
globs:
- "internal/ethapi/api.go"
- "rpc/errors.go"
- title: eth_simulateV1 API fix
description: Add deposit-nonce tx metadata to results of `eth_simulateV1` API to match rpc block format.
globs:
- "internal/ethapi/simulate.go"
- title: Tracer RPC daisy-chain
description: Forward pre-bedrock tracing calls to legacy node.
globs:
Expand Down
32 changes: 17 additions & 15 deletions internal/ethapi/simulate.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,21 @@ type simBlockResult struct {
chainConfig *params.ChainConfig
Block *types.Block
Calls []simCallResult
Receipts types.Receipts
}

// nulllReceiptGetter is a dummy receipt getter that panics when called.
// It is used to stub out behaviour specific to the OPStack, so that
// preparedReceipts implements GetReceipts with already-set receipts.
// It is used to retrieve receipts to source deposit-tx nonce data during RPC block marshaling.
// simBlockResult.MarshalJSON can use the OPStack RPCMarshalBlock function.
type nullReceiptGetter struct{}
type preparedReceipts types.Receipts

func (nullReceiptGetter) GetReceipts(context.Context, common.Hash) (types.Receipts, error) {
panic("OPStack: not implemented")
func (p preparedReceipts) GetReceipts(context.Context, common.Hash) (types.Receipts, error) {
return types.Receipts(p), nil
}

func (r *simBlockResult) MarshalJSON() ([]byte, error) {
blockData, err := RPCMarshalBlock(context.Background(), r.Block, true, r.fullTx, r.chainConfig, nullReceiptGetter{})
blockData, err := RPCMarshalBlock(context.Background(), r.Block, true, r.fullTx, r.chainConfig,
preparedReceipts(r.Receipts))
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -153,18 +155,18 @@ func (sim *simulator) execute(ctx context.Context, blocks []simBlock) ([]*simBlo
parent = sim.base
)
for bi, block := range blocks {
result, callResults, err := sim.processBlock(ctx, &block, headers[bi], parent, headers[:bi], timeout)
result, callResults, receipts, err := sim.processBlock(ctx, &block, headers[bi], parent, headers[:bi], timeout)
if err != nil {
return nil, err
}
headers[bi] = result.Header()
results[bi] = &simBlockResult{fullTx: sim.fullTx, chainConfig: sim.chainConfig, Block: result, Calls: callResults}
results[bi] = &simBlockResult{fullTx: sim.fullTx, chainConfig: sim.chainConfig, Block: result, Calls: callResults, Receipts: receipts}
parent = result.Header()
}
return results, nil
}

func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header, parent *types.Header, headers []*types.Header, timeout time.Duration) (*types.Block, []simCallResult, error) {
func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header, parent *types.Header, headers []*types.Header, timeout time.Duration) (*types.Block, []simCallResult, types.Receipts, error) {
// Set header fields that depend only on parent block.
// Parent hash is needed for evm.GetHashFn to work.
header.ParentHash = parent.Hash()
Expand Down Expand Up @@ -194,7 +196,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
precompiles := sim.activePrecompiles(sim.base)
// State overrides are applied prior to execution of a block
if err := block.StateOverrides.Apply(sim.state, precompiles); err != nil {
return nil, nil, err
return nil, nil, nil, err
}
var (
gasUsed, blobGasUsed uint64
Expand Down Expand Up @@ -224,10 +226,10 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
var allLogs []*types.Log
for i, call := range block.Calls {
if err := ctx.Err(); err != nil {
return nil, nil, err
return nil, nil, nil, err
}
if err := sim.sanitizeCall(&call, sim.state, header, blockContext, &gasUsed); err != nil {
return nil, nil, err
return nil, nil, nil, err
}
tx := call.ToTransaction(types.DynamicFeeTxType)
txes[i] = tx
Expand All @@ -237,7 +239,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
result, err := applyMessageWithEVM(ctx, evm, msg, timeout, sim.gp)
if err != nil {
txErr := txValidationError(err)
return nil, nil, txErr
return nil, nil, nil, txErr
}
// Update the state with pending changes.
var root []byte
Expand Down Expand Up @@ -272,7 +274,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
requests = [][]byte{}
// EIP-6110
if err := core.ParseDepositLogs(&requests, allLogs, sim.chainConfig); err != nil {
return nil, nil, err
return nil, nil, nil, err
}
// EIP-7002
core.ProcessWithdrawalQueue(&requests, evm)
Expand All @@ -294,7 +296,7 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
}
b := types.NewBlock(header, &types.Body{Transactions: txes, Withdrawals: withdrawals}, receipts, trie.NewStackTrie(nil), sim.chainConfig)
repairLogs(callResults, b.Hash())
return b, callResults, nil
return b, callResults, receipts, nil
}

// repairLogs updates the block hash in the logs present in the result of
Expand Down