Remote Pool: add mining rpc, test pending txs stream (#2685)

This commit is contained in:
Alex Sharov 2021-09-15 09:09:19 +07:00 committed by GitHub
parent ced5965ef7
commit ec14cba611
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 11 deletions

View File

@ -384,12 +384,12 @@ func (ff *Filters) OnNewTx(reply *txpool.OnAddReply) {
defer ff.mu.RUnlock()
txs := make([]types.Transaction, len(reply.RplTxs))
for i, rplTx := range reply.RplTxs {
for i, rlpTx := range reply.RplTxs {
var decodeErr error
txs[i], decodeErr = types.UnmarshalTransactionFromBinary(rplTx)
txs[i], decodeErr = types.UnmarshalTransactionFromBinary(rlpTx)
if decodeErr != nil {
// ignoring what we can't unmarshal
log.Warn("OnNewTx rpc filters, unprocessable payload", "err", decodeErr)
log.Warn("OnNewTx rpc filters, unprocessable payload", "err", decodeErr, "data", fmt.Sprintf("%x", rlpTx))
break
}
}

View File

@ -15,8 +15,10 @@ import (
"github.com/ledgerwatch/erigon-lib/kv/remotedb"
"github.com/ledgerwatch/erigon-lib/txpool"
"github.com/ledgerwatch/erigon-lib/txpool/txpooluitl"
"github.com/ledgerwatch/erigon/cmd/rpcdaemon/rpcdaemontest"
"github.com/ledgerwatch/erigon/cmd/utils"
"github.com/ledgerwatch/erigon/common/paths"
"github.com/ledgerwatch/erigon/ethdb/privateapi"
"github.com/ledgerwatch/erigon/ethdb/remotedbserver"
"github.com/ledgerwatch/erigon/internal/debug"
"github.com/ledgerwatch/log/v3"
@ -93,8 +95,8 @@ var rootCmd = &cobra.Command{
cfg := txpool.DefaultConfig
cfg.DBDir = path.Join(datadir, "txpool")
cfg.LogEvery = 5 * time.Minute
cfg.CommitEvery = 5 * time.Minute
cfg.LogEvery = 30 * time.Second
cfg.CommitEvery = 30 * time.Second
cacheConfig := kvcache.DefaultCoherentCacheConfig
cacheConfig.MetricsLabel = "txpool"
@ -114,10 +116,10 @@ var rootCmd = &cobra.Command{
if casted, ok := backend.engine.(*ethash.Ethash); ok {
ethashApi = casted.APIs(nil)[1].Service.(*ethash.API)
}
miningGrpcServer := privateapi.NewMiningServer(cmd.Context(), &rpcdaemontest.IsMiningMock{}, ethashApi)
*/
miningGrpcServer := privateapi.NewMiningServer(cmd.Context(), &rpcdaemontest.IsMiningMock{}, nil)
grpcServer, err := txpool.StartGrpc(txpoolGrpcServer, nil, txpoolApiAddr, nil)
grpcServer, err := txpool.StartGrpc(txpoolGrpcServer, miningGrpcServer, txpoolApiAddr, nil)
if err != nil {
return err
}

View File

@ -33,7 +33,9 @@ import (
libcommon "github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon-lib/direct"
"github.com/ledgerwatch/erigon-lib/etl"
"github.com/ledgerwatch/erigon-lib/gointerfaces"
"github.com/ledgerwatch/erigon-lib/gointerfaces/grpcutil"
"github.com/ledgerwatch/erigon-lib/gointerfaces/remote"
"github.com/ledgerwatch/erigon-lib/gointerfaces/sentry"
txpool_proto "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool"
"github.com/ledgerwatch/erigon-lib/kv"
@ -649,7 +651,9 @@ func (s *Ethereum) StartMining(ctx context.Context, db kv.RwDB, mining *stagedsy
if hh.BaseFee != nil {
baseFee = hh.BaseFee.Uint64()
}
return s.txPool2.OnNewBlock(context.Background(), nil, txpool2.TxSlots{}, txpool2.TxSlots{}, baseFee, hh.Number.Uint64(), hh.Hash())
return s.txPool2.OnNewBlock(context.Background(), &remote.StateChange{
BlockHeight: hh.Number.Uint64(), BlockHash: gointerfaces.ConvertHashToH256(hh.Hash()),
}, txpool2.TxSlots{}, txpool2.TxSlots{}, baseFee)
}); err != nil {
return err
}

2
go.mod
View File

@ -38,7 +38,7 @@ require (
github.com/julienschmidt/httprouter v1.3.0
github.com/kevinburke/go-bindata v3.21.0+incompatible
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/ledgerwatch/erigon-lib v0.0.0-20210913065323-1b66a410bef3
github.com/ledgerwatch/erigon-lib v0.0.0-20210914145433-c35be2a22677
github.com/ledgerwatch/log/v3 v3.3.0
github.com/ledgerwatch/secp256k1 v0.0.0-20210626115225-cd5cd00ed72d
github.com/logrusorgru/aurora/v3 v3.0.0

4
go.sum
View File

@ -493,8 +493,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/ledgerwatch/erigon-lib v0.0.0-20210913065323-1b66a410bef3 h1:LEE17DjFV3+2pRin3snY9mOXiNCJnaUXLU4HWuzu5RY=
github.com/ledgerwatch/erigon-lib v0.0.0-20210913065323-1b66a410bef3/go.mod h1:GiYMKOrTi4T2feH10Fvu8QTbvLm/GOckYzUmuk9WU8s=
github.com/ledgerwatch/erigon-lib v0.0.0-20210914145433-c35be2a22677 h1:6b4eTdKUqxVXjlXp9HENcWh3f/WZ1hJ8V3ZTaTkCOWI=
github.com/ledgerwatch/erigon-lib v0.0.0-20210914145433-c35be2a22677/go.mod h1:GiYMKOrTi4T2feH10Fvu8QTbvLm/GOckYzUmuk9WU8s=
github.com/ledgerwatch/log/v3 v3.3.0 h1:k8N/3NQLILr8CKCMyza261vLFKU7VA+nMNNb0wVyQSc=
github.com/ledgerwatch/log/v3 v3.3.0/go.mod h1:J58eOHHrIYHxl7LKkRsb/0YibKwtLfauUryl5SLRGm0=
github.com/ledgerwatch/secp256k1 v0.0.0-20210626115225-cd5cd00ed72d h1:/IKMrJdfRsoYNc36PXqP4xMH3vhW/8IQyBKGQbKZUno=