-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
p2p receipts #11010
p2p receipts #11010
Changes from 26 commits
eea467a
9ff21c9
35a3f1f
f05ba60
28274e1
c917eb0
cf7fc0b
132d101
ddc0aae
7cf43ac
61ea076
894855e
c965d3f
f5740fe
9f1bb35
e879bd8
6072d54
8604911
490c1a8
0d23573
625a62c
d7c5fff
e25c4ec
ba044f6
74ab518
2107f89
6d3b7da
b632521
68b09d5
b2c0f15
0620327
7bd5c20
7626b76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,7 +146,6 @@ func (f *Fetch) receiveMessageLoop(sentryClient sentry.SentryClient) { | |
f.logger.Warn("[txpool.recvMessage] sentry not ready yet", "err", err) | ||
continue | ||
} | ||
|
||
if err := f.receiveMessage(f.ctx, sentryClient); err != nil { | ||
if grpcutil.IsRetryLater(err) || grpcutil.IsEndOfStream(err) { | ||
time.Sleep(3 * time.Second) | ||
|
@@ -175,10 +174,11 @@ func (f *Fetch) receiveMessage(ctx context.Context, sentryClient sentry.SentryCl | |
} | ||
return err | ||
} | ||
|
||
println("receive message") | ||
var req *sentry.InboundMessage | ||
for req, err = stream.Recv(); ; req, err = stream.Recv() { | ||
if err != nil { | ||
f.logger.Error("[txpool.receiveMessage]", "err", err) | ||
select { | ||
case <-f.ctx.Done(): | ||
return ctx.Err() | ||
|
@@ -187,18 +187,21 @@ func (f *Fetch) receiveMessage(ctx context.Context, sentryClient sentry.SentryCl | |
return err | ||
} | ||
if req == nil { | ||
f.logger.Warn("[txpool.receiveMessage]", "req nil") | ||
return nil | ||
} | ||
f.logger.Info("[txpool.receiveMessage]", "req", req) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed because it's useless for majority of situations |
||
if err := f.handleInboundMessage(streamCtx, req, sentryClient); err != nil { | ||
if grpcutil.IsRetryLater(err) || grpcutil.IsEndOfStream(err) { | ||
time.Sleep(3 * time.Second) | ||
continue | ||
} | ||
f.logger.Debug("[txpool.fetch] Handling incoming message", "msg", req.Id.String(), "err", err) | ||
f.logger.Debug("[txpool.fetch] Handling incoming message", "msg", string(req.Data), "reqID", req.Id.String(), "err", err) | ||
} | ||
if f.wg != nil { | ||
f.wg.Done() | ||
} | ||
f.logger.Info("[txpool.fetch] Handling incoming message", "msg", string(req.Data), "reqID", req.Id.String(), "err", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. erigon handling tons of concurrent requests - from RPC and from P2P. no much reason to log them all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also this change is not related to current PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,11 +22,10 @@ package eth | |
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/ledgerwatch/erigon-lib/chain" | ||
libcommon "github.com/ledgerwatch/erigon-lib/common" | ||
"github.com/ledgerwatch/erigon-lib/kv" | ||
"github.com/ledgerwatch/erigon-lib/log/v3" | ||
|
||
"github.com/ledgerwatch/erigon/common" | ||
"github.com/ledgerwatch/erigon/core/rawdb" | ||
"github.com/ledgerwatch/erigon/core/types" | ||
|
@@ -160,12 +159,17 @@ func AnswerGetBlockBodiesQuery(db kv.Tx, query GetBlockBodiesPacket, blockReader | |
return bodies | ||
} | ||
|
||
func AnswerGetReceiptsQuery(br services.FullBlockReader, db kv.Tx, query GetReceiptsPacket) ([]rlp.RawValue, error) { //nolint:unparam | ||
type ReceiptsGetter interface { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done in an another file |
||
GetReceipts(ctx context.Context, cfg *chain.Config, tx kv.Tx, block *types.Block, senders []libcommon.Address) (types.Receipts, error) | ||
} | ||
|
||
func AnswerGetReceiptsQuery(ctx context.Context, cfg *chain.Config, receiptsGetter ReceiptsGetter, br services.FullBlockReader, db kv.Tx, query GetReceiptsPacket) ([]rlp.RawValue, error) { //nolint:unparam | ||
// Gather state data until the fetch or network limits is reached | ||
var ( | ||
bytes int | ||
receipts []rlp.RawValue | ||
) | ||
|
||
for lookups, hash := range query { | ||
if bytes >= softResponseLimit || len(receipts) >= maxReceiptsServe || | ||
lookups >= 2*maxReceiptsServe { | ||
|
@@ -183,16 +187,18 @@ func AnswerGetReceiptsQuery(br services.FullBlockReader, db kv.Tx, query GetRece | |
if b == nil { | ||
return nil, nil | ||
} | ||
results := rawdb.ReadReceipts(db, b, s) | ||
if results == nil { | ||
header, err := rawdb.ReadHeaderByHash(db, hash) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if header == nil || header.ReceiptHash != types.EmptyRootHash { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems this optimization lost. maybe move it inside generator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done but not in generator because it's query response optimization, not receipt |
||
continue | ||
} | ||
|
||
results, err := receiptsGetter.GetReceipts(ctx, cfg, db, b, s) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// For debug | ||
//println("receipts:") | ||
//for _, result := range results { | ||
// println(result.String()) | ||
//} | ||
|
||
// If known, encode and queue for response packet | ||
if encoded, err := rlp.EncodeToBytes(results); err != nil { | ||
return nil, fmt.Errorf("failed to encode receipt: %w", err) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
users using our logs for understanding - is erigon working or not.
Error log level - means node can't work without user's actions.
This error is self-recoverable and can be at Debug level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set to debug lvl