Skip to content
Open
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 rpc/jsonrpc/debug_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (api *DebugAPIImpl) GetModifiedAccountsByNumber(ctx context.Context, startN
return nil, err
}

startNum, _, _, err := rpchelper.GetBlockNumber(ctx, rpc.BlockNumberOrHashWithNumber(startNumber), tx, api._blockReader, api.filters)
startNum, _, _, err := rpchelper.GetBlockNumber(ctx, rpc.BlockNumberOrHashWithNumber(startNumber), tx, api._blockReader, nil)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change looks so weird

if err != nil {
return nil, err
}
Expand All @@ -344,7 +344,7 @@ func (api *DebugAPIImpl) GetModifiedAccountsByNumber(ctx context.Context, startN
}

// Two params: Geth compares state at startNum vs endNum → blocks (startNum, endNum].
endNum, _, _, err := rpchelper.GetBlockNumber(ctx, rpc.BlockNumberOrHashWithNumber(*endNumber), tx, api._blockReader, api.filters)
endNum, _, _, err := rpchelper.GetBlockNumber(ctx, rpc.BlockNumberOrHashWithNumber(*endNumber), tx, api._blockReader, nil)
if err != nil {
return nil, err
}
Expand Down
8 changes: 5 additions & 3 deletions rpc/jsonrpc/debug_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,8 +971,9 @@ func TestGetModifiedAccountsByNumber(t *testing.T) {
result, err = api.GetModifiedAccountsByNumber(m.Ctx, rpc.FinalizedBlockNumber, nil)
require.NoError(t, err)
require.NotEmpty(t, result)
})

// Non-nil filters with a LastPendingBlock exceeding latest executed block should return an error
t.Run("pending tag uses committed view", func(t *testing.T) {
ff := rpchelper.New(t.Context(), rpchelper.FiltersConfig{}, nil, nil, nil, func() {}, log.New(), nil)
pendingBlock := types.NewBlockWithHeader(&types.Header{Number: *uint256.NewInt(100)})
payload, err := rlp.EncodeToBytes(pendingBlock)
Expand All @@ -982,8 +983,9 @@ func TestGetModifiedAccountsByNumber(t *testing.T) {
baseWithFilters := NewBaseApi(ff, m.StateCache, m.BlockReader, m.Engine, nil, &rpccfg.BaseApiConfig{Dirs: m.Dirs})
apiWithFilters := NewPrivateDebugAPI(baseWithFilters, m.DB, nil, &rpccfg.DebugApiConfig{})

_, err = apiWithFilters.GetModifiedAccountsByNumber(m.Ctx, rpc.PendingBlockNumber, nil)
require.Error(t, err)
result, err := apiWithFilters.GetModifiedAccountsByNumber(m.Ctx, rpc.PendingBlockNumber, nil)
require.NoError(t, err)
require.NotEmpty(t, result)
})
}

Expand Down
23 changes: 23 additions & 0 deletions rpc/jsonrpc/overlay_race_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
"github.com/erigontech/erigon/node/gointerfaces/txpoolproto"
"github.com/erigontech/erigon/node/shards"
"github.com/erigontech/erigon/rpc"
"github.com/erigontech/erigon/rpc/rpccfg"
"github.com/erigontech/erigon/rpc/rpchelper"
)

Expand Down Expand Up @@ -98,6 +99,7 @@ func newOverlayAheadTestAPI(t *testing.T) (base *BaseAPI, m *execmoduletester.Ex
// enough for the reader paths under test to resolve this header as current.
require.NoError(t, rawdb.WriteHeader(overlay, overlayHeader))
require.NoError(t, rawdb.WriteHeadHeaderHash(overlay, hash))
rawdb.WriteForkchoiceHead(overlay, hash)
require.NoError(t, rawdb.WriteCanonicalHash(overlay, hash, overlayNumber))
require.NoError(t, rawdb.WriteBody(overlay, hash, overlayNumber, &types.Body{}))

Expand Down Expand Up @@ -159,6 +161,27 @@ func TestGetBlockByTimestamp_SeesOverlayHead(t *testing.T) {
"must resolve to the overlay head block, not the stale MDBX-committed head")
}

func TestGetModifiedAccountsByNumber_UsesCommittedStartTag(t *testing.T) {
t.Parallel()
base, m, _ := newOverlayAheadTestAPI(t)
api := NewPrivateDebugAPI(base, m.DB, nil, &rpccfg.DebugApiConfig{})

result, err := api.GetModifiedAccountsByNumber(m.Ctx, rpc.LatestBlockNumber, nil)
require.NoError(t, err)
require.NotEmpty(t, result)
}

func TestGetModifiedAccountsByNumber_UsesCommittedEndTag(t *testing.T) {
t.Parallel()
base, m, _ := newOverlayAheadTestAPI(t)
api := NewPrivateDebugAPI(base, m.DB, nil, &rpccfg.DebugApiConfig{})
latest := rpc.LatestBlockNumber

result, err := api.GetModifiedAccountsByNumber(m.Ctx, rpc.EarliestBlockNumber, &latest)
require.NoError(t, err)
require.NotEmpty(t, result)
}

// TestGetTransactionByHash_PendingTx_UsesOverlayHead pins that the pending-tx
// fallback in GetTransactionByHash reads the current header through the block
// overlay: the returned tx's gas price (derived from that header's base fee)
Expand Down
Loading