From f699cd23792f808916e9c0620d34c8a5301a0ea0 Mon Sep 17 00:00:00 2001 From: elliothllm <143621200+elliothllm@users.noreply.github.com> Date: Mon, 10 Feb 2025 15:44:06 +0000 Subject: [PATCH] tweak(tx-pool-grpc): add sub pool type to panic (#1731) tweak(tx-pool-grpc): log error but still if not valid type tweak(tx-pool-grpc): add sender --- zk/txpool/txpool_grpc_server.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/zk/txpool/txpool_grpc_server.go b/zk/txpool/txpool_grpc_server.go index 3d06b3ebf86..5c662ceb150 100644 --- a/zk/txpool/txpool_grpc_server.go +++ b/zk/txpool/txpool_grpc_server.go @@ -123,7 +123,7 @@ func convertSubPoolType(t SubPoolType) txpool_proto.AllReply_TxnType { case QueuedSubPool: return txpool_proto.AllReply_QUEUED default: - panic("unknown") + panic(fmt.Sprintf("unknown sub pool type: %s", t)) } } func (s *GrpcServer) All(ctx context.Context, _ *txpool_proto.AllRequest) (*txpool_proto.AllReply, error) { @@ -134,7 +134,16 @@ func (s *GrpcServer) All(ctx context.Context, _ *txpool_proto.AllRequest) (*txpo defer tx.Rollback() reply := &txpool_proto.AllReply{} reply.Txs = make([]*txpool_proto.AllReply_Tx, 0, 32) + validSubPoolTypes := map[SubPoolType]txpool_proto.AllReply_TxnType{ + PendingSubPool: txpool_proto.AllReply_PENDING, + BaseFeeSubPool: txpool_proto.AllReply_BASE_FEE, + QueuedSubPool: txpool_proto.AllReply_QUEUED, + } s.txPool.deprecatedForEach(ctx, func(rlp []byte, sender common.Address, t SubPoolType) { + if _, ok := validSubPoolTypes[t]; !ok { + log.Warn("Unknown sub pool type", "type", t, "sender", sender) + return + } reply.Txs = append(reply.Txs, &txpool_proto.AllReply_Tx{ Sender: gointerfaces.ConvertAddressToH160(sender), TxnType: convertSubPoolType(t),