Skip to content
Open
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
23 changes: 22 additions & 1 deletion jrpc2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,13 @@ func (c *cache) get(nocache bool, ctx context.Context, url string, start, limit
return seg.d, nil
}

// some EVM implementations may not produce a block for a given epoch,
// especially in testnet context; treat eth_getBlockByNumber's "null round"
// failure as an empty block so the indexer cursor can advance past the gap
func isNullRoundError(e Error) bool {
return e.Code == 12 && strings.Contains(e.Message, "null round")
}

func (c *Client) blocks(ctx context.Context, url string, start, limit uint64) ([]eth.Block, error) {
var (
t0 = time.Now()
Expand All @@ -570,6 +577,10 @@ func (c *Client) blocks(ctx context.Context, url string, start, limit uint64) ([
}
for i := range resps {
if resps[i].Error.Exists() {
if isNullRoundError(resps[i].Error) {
blocks[i].Header.Number = eth.Uint64(start + uint64(i))
continue
}
const tag = "eth_getBlockByNumber"
return nil, fmt.Errorf("rpc=%s %w", tag, resps[i].Error)
}
Expand Down Expand Up @@ -634,6 +645,10 @@ func (c *Client) headers(ctx context.Context, url string, start, limit uint64) (
}
for i := range resps {
if resps[i].Error.Exists() {
if isNullRoundError(resps[i].Error) {
blocks[i].Header.Number = eth.Uint64(start + uint64(i))
continue
}
const tag = "eth_getBlockByNumber/headers"
return nil, fmt.Errorf("rpc=%s %w", tag, resps[i].Error)
}
Expand Down Expand Up @@ -787,7 +802,13 @@ func (c *Client) logs(ctx context.Context, url string, filter *glf.Filter, bm bl
)
switch {
case hresp.Error.Exists():
return fmt.Errorf("rpc=eth_getLogs/eth_getBlockByNumber %w", lresp.Error)
if isNullRoundError(hresp.Error) {
if b, ok := bm[toBlock]; ok {
b.Header.Number = eth.Uint64(toBlock)
}
break
}
return fmt.Errorf("rpc=eth_getBlockByNumber %w", hresp.Error)
case lresp.Error.Exists():
return fmt.Errorf("rpc=eth_getLogs %w", lresp.Error)
case hresp.Header == nil:
Expand Down