diff --git a/cmd/cons/commands/clique.go b/cmd/cons/commands/clique.go index afc0ef0e252a79e6400f6681dff5ca64ea681d59..4cecd887df1b01f4634617f558191c085c36b148 100644 --- a/cmd/cons/commands/clique.go +++ b/cmd/cons/commands/clique.go @@ -124,6 +124,12 @@ func grpcCliqueServer(ctx context.Context, testServer bool) (*CliqueServerImpl, grpc.KeepaliveParams(keepalive.ServerParameters{ Time: 10 * time.Minute, }), + // Don't drop the connection, settings accordign to this comment on GitHub + // https://github.com/grpc/grpc-go/issues/3171#issuecomment-552796779 + grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ + MinTime: 10 * time.Second, + PermitWithoutStream: true, + }), grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(streamInterceptors...)), grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(unaryInterceptors...)), } diff --git a/cmd/integration/commands/stages.go b/cmd/integration/commands/stages.go index 69d3c281b86b5e2678040cb90320d6e73172eaea..76968f6604085adbd48f8e0078e66c9d63e89f26 100644 --- a/cmd/integration/commands/stages.go +++ b/cmd/integration/commands/stages.go @@ -1,6 +1,7 @@ package commands import ( + "bytes" "context" "fmt" "path" @@ -8,6 +9,7 @@ import ( "strings" "github.com/c2h5oh/datasize" + common2 "github.com/ledgerwatch/erigon-lib/common" "github.com/ledgerwatch/erigon-lib/etl" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon/cmd/sentry/download" @@ -16,6 +18,8 @@ import ( "github.com/ledgerwatch/erigon/consensus" "github.com/ledgerwatch/erigon/consensus/ethash" "github.com/ledgerwatch/erigon/core" + "github.com/ledgerwatch/erigon/core/rawdb" + "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/eth/ethconfig" "github.com/ledgerwatch/erigon/eth/fetcher" @@ -30,6 +34,7 @@ import ( stages2 "github.com/ledgerwatch/erigon/turbo/stages" "github.com/ledgerwatch/erigon/turbo/txpool" "github.com/ledgerwatch/log/v3" + "github.com/ledgerwatch/secp256k1" "github.com/spf13/cobra" ) @@ -262,6 +267,7 @@ func init() { withChain(cmdPrintStages) rootCmd.AddCommand(cmdPrintStages) + withIntegrityChecks(cmdStageSenders) withReset(cmdStageSenders) withBlock(cmdStageSenders) withUnwind(cmdStageSenders) @@ -401,6 +407,42 @@ func stageSenders(db kv.RwDB, ctx context.Context) error { } defer tx.Rollback() + if integritySlow { + secp256k1.ContextForThread(1) + for i := block; ; i++ { + if err := common2.Stopped(ctx.Done()); err != nil { + return err + } + withoutSenders, _ := rawdb.ReadBlockByNumber(tx, i) + if withoutSenders == nil { + break + } + txs := withoutSenders.Transactions() + _, senders, _ := rawdb.ReadBlockByNumberWithSenders(tx, i) + if txs.Len() != len(senders) { + log.Error("not equal amount of senders", "block", i, "db", len(senders), "expect", txs.Len()) + return nil + } + if txs.Len() == 0 { + continue + } + signer := types.MakeSigner(chainConfig, i) + for j := 0; j < txs.Len(); j++ { + from, err := signer.Sender(txs[j]) + if err != nil { + return err + } + if !bytes.Equal(from[:], senders[j][:]) { + log.Error("wrong sender", "block", i, "tx", j, "db", fmt.Sprintf("%x", senders[j]), "expect", fmt.Sprintf("%x", from)) + } + } + if i%10 == 0 { + log.Info("checked", "block", i) + } + } + return nil + } + if reset { err = resetSenders(tx) if err != nil { diff --git a/cmd/integration/commands/testing.go b/cmd/integration/commands/testing.go index 07fdb44bb579a7be20fe361fe12cb26d93210b38..d4e3f077a33fb0c978f984d13ac053a37db70dcd 100644 --- a/cmd/integration/commands/testing.go +++ b/cmd/integration/commands/testing.go @@ -108,6 +108,12 @@ func grpcTestDriverServer(ctx context.Context, testingAddr string) (*TestDriverS grpc.KeepaliveParams(keepalive.ServerParameters{ Time: 10 * time.Minute, }), + // Don't drop the connection, settings accordign to this comment on GitHub + // https://github.com/grpc/grpc-go/issues/3171#issuecomment-552796779 + grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ + MinTime: 10 * time.Second, + PermitWithoutStream: true, + }), grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(streamInterceptors...)), grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(unaryInterceptors...)), } diff --git a/cmd/rpcdaemon/commands/eth_block.go b/cmd/rpcdaemon/commands/eth_block.go index f8be0e82c59d0026a8329b285f1b410d69b29d1e..c2f3710f0b3534db07584a9d33c03bee17be7b92 100644 --- a/cmd/rpcdaemon/commands/eth_block.go +++ b/cmd/rpcdaemon/commands/eth_block.go @@ -215,7 +215,7 @@ func (api *APIImpl) GetBlockByHash(ctx context.Context, numberOrHash rpc.BlockNu additionalFields := make(map[string]interface{}) - block, err := rawdb.ReadBlockByHash(tx, hash) + block, _, err := rawdb.ReadBlockByHashWithSenders(tx, hash) if err != nil { return nil, err } diff --git a/cmd/snapshots/downloader/commands/root.go b/cmd/snapshots/downloader/commands/root.go index eaf659270d631648b5834721f6d6cf4d7541179d..9ebd244fa4cdec5dc5c5d7fc6f356f6cb52f000a 100644 --- a/cmd/snapshots/downloader/commands/root.go +++ b/cmd/snapshots/downloader/commands/root.go @@ -132,6 +132,12 @@ func runDownloader(cmd *cobra.Command, args []string) error { grpc.KeepaliveParams(keepalive.ServerParameters{ Time: 10 * time.Minute, }), + // Don't drop the connection, settings accordign to this comment on GitHub + // https://github.com/grpc/grpc-go/issues/3171#issuecomment-552796779 + grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ + MinTime: 10 * time.Second, + PermitWithoutStream: true, + }), grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(streamInterceptors...)), grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(unaryInterceptors...)), } diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 8741b4778f84084114b21a012a08e7035aad743f..b2181e2d9b100afd699a877186f96e5a6993554c 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -848,7 +848,11 @@ func newRPCTransaction(tx types.Transaction, blockHash common.Hash, blockNumber } } signer := types.LatestSignerForChainID(chainId.ToBig()) - result.From, _ = tx.Sender(*signer) + var err error + result.From, err = tx.Sender(*signer) + if err != nil { + log.Warn("sender recovery", "err", err) + } if blockHash != (common.Hash{}) { result.BlockHash = &blockHash result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber))