From b8381cfd3a3ec120c0b21751eb0fe6948687d956 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Fri, 27 Aug 2021 11:00:56 +0700 Subject: [PATCH] add state check assert routine --- txpool/fetch.go | 3 +-- txpool/packets.go | 7 +++++++ txpool/pool.go | 7 ------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/txpool/fetch.go b/txpool/fetch.go index b50783177..d2169d0f4 100644 --- a/txpool/fetch.go +++ b/txpool/fetch.go @@ -66,7 +66,6 @@ var DefaultTimings = Timings{ // SentryClient here is an interface, it is suitable for mocking in tests (mock will need // to implement all the functions of the SentryClient interface). func NewFetch(ctx context.Context, sentryClients []sentry.SentryClient, pool Pool, senders *SendersCache, stateChangesClient remote.KVClient, coreDB kv.RoDB, db kv.RwDB) *Fetch { - pooledTxsParseCtx := NewTxParseContext() return &Fetch{ ctx: ctx, sentryClients: sentryClients, @@ -76,7 +75,7 @@ func NewFetch(ctx context.Context, sentryClients []sentry.SentryClient, pool Poo db: db, stateChangesClient: stateChangesClient, stateChangesParseCtx: NewTxParseContext(), - pooledTxsParseCtx: pooledTxsParseCtx, + pooledTxsParseCtx: NewTxParseContext(), } } diff --git a/txpool/packets.go b/txpool/packets.go index 63cfa1da0..0ea5b57b5 100644 --- a/txpool/packets.go +++ b/txpool/packets.go @@ -17,6 +17,7 @@ package txpool import ( + "bytes" "errors" "fmt" @@ -192,6 +193,12 @@ func ParsePooledTransactions65(payload []byte, pos int, ctx *TxParseContext, txS } return 0, err } + if ASSERT { + if bytes.Equal(txSlots.txs[i].idHash[:], EmptyAddr[:]) { + fmt.Printf("etmpy: %#v\n", txSlots.txs[i]) + panic("?????") + } + } } return pos, nil } diff --git a/txpool/pool.go b/txpool/pool.go index 5932386eb..86218495b 100644 --- a/txpool/pool.go +++ b/txpool/pool.go @@ -913,13 +913,6 @@ func (p *TxPool) OnNewTxs(ctx context.Context, coreDB kv.RoDB, newTxs TxSlots, s return err } - if ASSERT { - for i := range p.senders.senderIDs { - if bytes.Equal([]byte(i), EmptyAddr[:]) { - panic(8) - } - } - } protocolBaseFee, pendingBaseFee := p.protocolBaseFee.Load(), p.pendingBaseFee.Load() if protocolBaseFee == 0 || pendingBaseFee == 0 { return fmt.Errorf("non-zero base fee: %d,%d", protocolBaseFee, pendingBaseFee)