Skip to content

Commit

Permalink
turbo/execution: drop td lookup in getters (#12832)
Browse files Browse the repository at this point in the history
Since we started prunning TD (roughly after 100,000 blocks) there is no
longer any point in keeping the TD lookups in some of the
ExecutionModule read APIs such as `GetHeader`, `GetBody`, etc.

Those lookups actually also break the APIs for use cases in which some
components need to read block data older than the prune point of the TD.
In those cases Ive observed we return errors when in reality the data is
there (in snapshots) and is accessible otherwise.
  • Loading branch information
taratorio authored Nov 21, 2024
1 parent 7d16e2b commit 336260e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
22 changes: 0 additions & 22 deletions turbo/execution/eth1/ethereum_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,6 @@ func NewEthereumExecutionModule(blockReader services.FullBlockReader, db kv.RwDB
}

func (e *EthereumExecutionModule) getHeader(ctx context.Context, tx kv.Tx, blockHash libcommon.Hash, blockNumber uint64) (*types.Header, error) {
td, err := rawdb.ReadTd(tx, blockHash, blockNumber)
if err != nil {
return nil, err
}
if td == nil {
return nil, nil
}

if e.blockReader == nil {
return rawdb.ReadHeader(tx, blockHash, blockNumber), nil
}
Expand All @@ -142,13 +134,6 @@ func (e *EthereumExecutionModule) getTD(_ context.Context, tx kv.Tx, blockHash l
}

func (e *EthereumExecutionModule) getBody(ctx context.Context, tx kv.Tx, blockHash libcommon.Hash, blockNumber uint64) (*types.Body, error) {
td, err := rawdb.ReadTd(tx, blockHash, blockNumber)
if err != nil {
return nil, err
}
if td == nil {
return nil, nil
}
if e.blockReader == nil {
body, _, _ := rawdb.ReadBody(tx, blockHash, blockNumber)
return body, nil
Expand All @@ -175,13 +160,6 @@ func (e *EthereumExecutionModule) canonicalHash(ctx context.Context, tx kv.Tx, b
}
}

td, err := rawdb.ReadTd(tx, canonical, blockNumber)
if err != nil {
return libcommon.Hash{}, err
}
if td == nil {
return libcommon.Hash{}, nil
}
return canonical, nil
}

Expand Down
7 changes: 0 additions & 7 deletions turbo/execution/eth1/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,6 @@ func (e *EthereumExecutionModule) GetBody(ctx context.Context, req *execution.Ge
if err != nil {
return nil, fmt.Errorf("ethereumExecutionModule.GetBody: parseSegmentRequest error %w", err)
}
td, err := rawdb.ReadTd(tx, blockHash, blockNumber)
if err != nil {
return nil, fmt.Errorf("ethereumExecutionModule.GetBody: ReadTd error %w", err)
}
if td == nil {
return &execution.GetBodyResponse{Body: nil}, nil
}
body, err := e.getBody(ctx, tx, blockHash, blockNumber)
if err != nil {
return nil, fmt.Errorf("ethereumExecutionModule.GetBody: getBody error %w", err)
Expand Down

0 comments on commit 336260e

Please sign in to comment.