diff --git a/Makefile b/Makefile index 3086b96cc80..0369d7217de 100644 --- a/Makefile +++ b/Makefile @@ -125,12 +125,9 @@ clean: # You need to put $GOBIN (or $GOPATH/bin) in your PATH to use 'go generate'. devtools: - # See: ./cmd/hack/binary-deps/main.go env GOBIN= go install golang.org/x/tools/cmd/stringer env GOBIN= go install github.com/kevinburke/go-bindata/go-bindata env GOBIN= go install github.com/fjl/gencodec - env GOBIN= go install google.golang.org/protobuf/cmd/protoc-gen-go # generates proto messages - env GOBIN= go install google.golang.org/grpc/cmd/protoc-gen-go-grpc # generates grpc services env GOBIN= go install ./cmd/abigen @type "npm" 2> /dev/null || echo 'Please install node.js and npm' @type "solc" 2> /dev/null || echo 'Please install solc' @@ -140,6 +137,11 @@ bindings: go generate ./tests/contracts/ go generate ./cmd/tester/contracts/ go generate ./core/state/contracts/ + +grpc: + # See also: ./cmd/hack/binary-deps/main.go + env GOBIN= go install google.golang.org/protobuf/cmd/protoc-gen-go # generates proto messages + env GOBIN= go install google.golang.org/grpc/cmd/protoc-gen-go-grpc # generates grpc services go generate ./ethdb simulator-genesis: diff --git a/cmd/rpcdaemon/Readme.md b/cmd/rpcdaemon/Readme.md index 5487524010b..6d3c6976fdf 100644 --- a/cmd/rpcdaemon/Readme.md +++ b/cmd/rpcdaemon/Readme.md @@ -33,3 +33,9 @@ It should return something like this (depending on how far your turbo-geth node ```` {"jsonrpc":"2.0","id":1,"result":823909} ```` + +### For Developers + +**Code generation**: `go.mod` stores right version of generators, use `mage grpc` to install it and generate code. + +`protoc` version not managed but recommended version is 3.*, [install instruction](https://grpc.io/docs/protoc-installation/) \ No newline at end of file diff --git a/cmd/rpcdaemon/commands/daemon.go b/cmd/rpcdaemon/commands/daemon.go index d162f9e81b4..9b3f83b8c80 100644 --- a/cmd/rpcdaemon/commands/daemon.go +++ b/cmd/rpcdaemon/commands/daemon.go @@ -8,7 +8,7 @@ import ( "github.com/ledgerwatch/turbo-geth/common" "github.com/ledgerwatch/turbo-geth/common/hexutil" "github.com/ledgerwatch/turbo-geth/core/rawdb" - "github.com/ledgerwatch/turbo-geth/eth/stagedsync/stages" + "github.com/ledgerwatch/turbo-geth/core/types" "github.com/ledgerwatch/turbo-geth/ethdb" "github.com/ledgerwatch/turbo-geth/rpc" "github.com/ledgerwatch/turbo-geth/turbo/adapter/ethapi" @@ -17,17 +17,9 @@ import ( // GetBlockByNumber see https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbynumber // see internal/ethapi.PublicBlockChainAPI.GetBlockByNumber func (api *APIImpl) GetBlockByNumber(ctx context.Context, number rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) { - var blockNum uint64 - if number == rpc.LatestBlockNumber || number == rpc.PendingBlockNumber { - var err error - blockNum, _, err = stages.GetStageProgress(api.dbReader, stages.Execution) - if err != nil { - return nil, fmt.Errorf("getting latest block number: %v", err) - } - } else if number == rpc.EarliestBlockNumber { - blockNum = 0 - } else { - blockNum = uint64(number.Int64()) + blockNum, err := getBlockNumber(number, api.dbReader) + if err != nil { + return nil, err } additionalFields := make(map[string]interface{}) @@ -71,6 +63,24 @@ func (api *APIImpl) GetBlockByHash(ctx context.Context, hash common.Hash, fullTx return response, err } +func (api *APIImpl) GetHeaderByNumber(_ context.Context, number rpc.BlockNumber) (*types.Header, error) { + header := rawdb.ReadHeaderByNumber(api.dbReader, uint64(number.Int64())) + if header == nil { + return nil, fmt.Errorf("block header not found: %d", number.Int64()) + } + + return header, nil +} + +func (api *APIImpl) GetHeaderByHash(_ context.Context, hash common.Hash) (*types.Header, error) { + header := rawdb.ReadHeaderByHash(api.dbReader, hash) + if header == nil { + return nil, fmt.Errorf("block header not found: %s", hash.String()) + } + + return header, nil +} + func APIList(db ethdb.KV, eth ethdb.Backend, cfg cli.Flags, customApiList []rpc.API) []rpc.API { var defaultAPIList []rpc.API diff --git a/cmd/rpcdaemon/commands/eth_api.go b/cmd/rpcdaemon/commands/eth_api.go index c3749ef2d15..dbbbe26487c 100644 --- a/cmd/rpcdaemon/commands/eth_api.go +++ b/cmd/rpcdaemon/commands/eth_api.go @@ -4,6 +4,8 @@ import ( "context" "fmt" + "github.com/ledgerwatch/turbo-geth/eth/filters" + "github.com/ledgerwatch/turbo-geth/common" "github.com/ledgerwatch/turbo-geth/common/hexutil" "github.com/ledgerwatch/turbo-geth/core" @@ -23,7 +25,7 @@ type EthAPI interface { GetBlockByHash(ctx context.Context, hash common.Hash, fullTx bool) (map[string]interface{}, error) GetBalance(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) - GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error) + GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*types.Log, error) Call(ctx context.Context, args ethapi.CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *map[common.Address]ethapi.Account) (hexutil.Bytes, error) EstimateGas(ctx context.Context, args ethapi.CallArgs) (hexutil.Uint64, error) SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error) @@ -83,18 +85,11 @@ func (api *APIImpl) Syncing(ctx context.Context) (interface{}, error) { } func (api *APIImpl) GetBlockTransactionCountByNumber(ctx context.Context, blockNr rpc.BlockNumber) (*hexutil.Uint, error) { - var blockNum uint64 - if blockNr == rpc.LatestBlockNumber || blockNr == rpc.PendingBlockNumber { - var err error - blockNum, _, err = stages.GetStageProgress(api.dbReader, stages.Execution) - if err != nil { - return nil, fmt.Errorf("getting latest block number: %v", err) - } - } else if blockNr == rpc.EarliestBlockNumber { - blockNum = 0 - } else { - blockNum = uint64(blockNr.Int64()) + blockNum, err := getBlockNumber(blockNr, api.dbReader) + if err != nil { + return nil, err } + block := rawdb.ReadBlockByNumber(api.dbReader, blockNum) if block == nil { return nil, fmt.Errorf("block not found: %d", blockNum) diff --git a/cmd/rpcdaemon/commands/get_chain_config.go b/cmd/rpcdaemon/commands/get_chain_config.go new file mode 100644 index 00000000000..b861a87d0b8 --- /dev/null +++ b/cmd/rpcdaemon/commands/get_chain_config.go @@ -0,0 +1,11 @@ +package commands + +import ( + "github.com/ledgerwatch/turbo-geth/core/rawdb" + "github.com/ledgerwatch/turbo-geth/params" +) + +func getChainConfig(db rawdb.DatabaseReader) *params.ChainConfig { + genesisHash := rawdb.ReadBlockByNumber(db, 0).Hash() + return rawdb.ReadChainConfig(db, genesisHash) +} diff --git a/cmd/rpcdaemon/commands/get_receipts.go b/cmd/rpcdaemon/commands/get_receipts.go index c9ec9746a9f..17fa625ac56 100644 --- a/cmd/rpcdaemon/commands/get_receipts.go +++ b/cmd/rpcdaemon/commands/get_receipts.go @@ -2,19 +2,23 @@ package commands import ( "context" + "errors" "fmt" - - "github.com/ledgerwatch/turbo-geth/turbo/adapter" - "github.com/ledgerwatch/turbo-geth/turbo/transactions" + "math/big" "github.com/ledgerwatch/turbo-geth/common" "github.com/ledgerwatch/turbo-geth/common/hexutil" "github.com/ledgerwatch/turbo-geth/core" + "github.com/ledgerwatch/turbo-geth/core/bloombits" "github.com/ledgerwatch/turbo-geth/core/rawdb" "github.com/ledgerwatch/turbo-geth/core/types" "github.com/ledgerwatch/turbo-geth/core/vm" + "github.com/ledgerwatch/turbo-geth/eth/filters" "github.com/ledgerwatch/turbo-geth/ethdb" "github.com/ledgerwatch/turbo-geth/params" + "github.com/ledgerwatch/turbo-geth/rpc" + "github.com/ledgerwatch/turbo-geth/turbo/adapter" + "github.com/ledgerwatch/turbo-geth/turbo/transactions" ) func GetReceipts(ctx context.Context, db rawdb.DatabaseReader, cfg *params.ChainConfig, hash common.Hash) (types.Receipts, error) { @@ -30,8 +34,7 @@ func GetReceipts(ctx context.Context, db rawdb.DatabaseReader, cfg *params.Chain cc := adapter.NewChainContext(db) bc := adapter.NewBlockGetter(db) - genesisHash := rawdb.ReadBlockByNumber(db, 0).Hash() - chainConfig := rawdb.ReadChainConfig(db, genesisHash) + chainConfig := getChainConfig(db) _, _, ibs, dbstate, err := transactions.ComputeTxEnv(ctx, bc, chainConfig, cc, db.(ethdb.HasKV).KV(), hash, 0) if err != nil { return nil, err @@ -54,7 +57,7 @@ func GetReceipts(ctx context.Context, db rawdb.DatabaseReader, cfg *params.Chain return receipts, nil } -func (api *APIImpl) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.Log, error) { +func (api *APIImpl) GetLogsByHash(ctx context.Context, hash common.Hash) ([][]*types.Log, error) { number := rawdb.ReadHeaderNumber(api.dbReader, hash) if number == nil { return nil, fmt.Errorf("block not found: %x", hash) @@ -73,6 +76,97 @@ func (api *APIImpl) GetLogs(ctx context.Context, hash common.Hash) ([][]*types.L return logs, nil } +// Filter can be used to retrieve and filter logs. +type Filter struct { + addresses []common.Address + topics [][]common.Hash + + block common.Hash // Block hash if filtering a single block + begin, end int64 // Range interval if filtering multiple blocks + + matcher *bloombits.Matcher +} + +func NewBlockFilter(block common.Hash, addresses []common.Address, topics [][]common.Hash) *Filter { + // Create a generic filter and convert it into a block filter + filter := newFilter(addresses, topics) + filter.block = block + return filter +} + +// newFilter creates a generic filter that can either filter based on a block hash, +// or based on range queries. The search criteria needs to be explicitly set. +func newFilter(addresses []common.Address, topics [][]common.Hash) *Filter { + return &Filter{ + addresses: addresses, + topics: topics, + } +} + +// GetLogs returns logs matching the given argument that are stored within the state. +func (api *APIImpl) GetLogs(ctx context.Context, crit filters.FilterCriteria) ([]*types.Log, error) { + var filter *Filter + if crit.BlockHash != nil { + // Block filter requested, construct a single-shot filter + filter = NewBlockFilter(*crit.BlockHash, crit.Addresses, crit.Topics) + } else { + // Convert the RPC block numbers into internal representations + latest, err := getLatestBlockNumber(api.dbReader) + if err != nil { + return nil, err + } + + begin := int64(latest) + if crit.FromBlock != nil { + begin = crit.FromBlock.Int64() + } + end := int64(latest) + if crit.ToBlock != nil { + end = crit.ToBlock.Int64() + } + + filter = NewRangeFilter(begin, end, crit.Addresses, crit.Topics) + } + // Run the filter and return all the logs + logs, err := filter.Logs(ctx, api) + if err != nil { + return nil, err + } + return returnLogs(logs), err +} + +// NewRangeFilter creates a new filter which uses a bloom filter on blocks to +// figure out whether a particular block is interesting or not. +func NewRangeFilter(begin, end int64, addresses []common.Address, topics [][]common.Hash) *Filter { + // Flatten the address and topic filter clauses into a single bloombits filter + // system. Since the bloombits are not positional, nil topics are permitted, + // which get flattened into a nil byte slice. + filters := make([][][]byte, 0, len(addresses)) + if len(addresses) > 0 { + filter := make([][]byte, len(addresses)) + for i, address := range addresses { + filter[i] = address.Bytes() + } + filters = append(filters, filter) + } + for _, topicList := range topics { + filter := make([][]byte, len(topicList)) + for i, topic := range topicList { + filter[i] = topic.Bytes() + } + filters = append(filters, filter) + } + + // Create a generic filter and convert it into a range filter + filter := newFilter(addresses, topics) + + filter.matcher = bloombits.NewMatcher(params.BloomBitsBlocks, filters) + filter.begin = begin + filter.end = end + + return filter +} + func (api *APIImpl) GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) { // Retrieve the transaction and assemble its EVM context tx, blockHash, blockNumber, txIndex := rawdb.ReadTransaction(api.dbReader, hash) @@ -139,3 +233,215 @@ func (api *APIImpl) GetTransactionReceipt(ctx context.Context, hash common.Hash) } return fields, nil } + +// Logs searches the blockchain for matching log entries, returning all from the +// first block that contains matches, updating the start of the filter accordingly. +func (f *Filter) Logs(ctx context.Context, api *APIImpl) ([]*types.Log, error) { + // If we're doing singleton block filtering, execute and return + if f.block != (common.Hash{}) { + header, err := api.GetHeaderByHash(ctx, f.block) + if err != nil { + return nil, err + } + if header == nil { + return nil, errors.New("unknown block") + } + return f.blockLogs(ctx, header, api) + } + + // Figure out the limits of the filter range + latest, err := getLatestBlockNumber(api.dbReader) + if err != nil { + return nil, err + } + + if f.begin == -1 { + f.begin = int64(latest) + } + end := uint64(f.end) + if f.end == -1 { + end = latest + } + + // Gather all indexed logs, and finish with non indexed ones + var logs []*types.Log + size, sections, _ := api.ethBackend.BloomStatus() + + if indexed := sections * size; indexed > uint64(f.begin) { + if indexed > end { + logs, err = f.indexedLogs(ctx, end, api) + } else { + logs, err = f.indexedLogs(ctx, indexed-1, api) + } + if err != nil { + return logs, err + } + } + rest, err := f.unindexedLogs(ctx, end, api) + logs = append(logs, rest...) + return logs, err +} + +// indexedLogs returns the logs matching the filter criteria based on the bloom +// bits indexed available locally or via the network. +func (f *Filter) indexedLogs(ctx context.Context, end uint64, api *APIImpl) ([]*types.Log, error) { + // Iterate over the matches until exhausted or context closed + var logs []*types.Log + + for num := f.begin; num < int64(end)+1; num++ { + // Retrieve the suggested block and pull any truly matching logs + header, err := api.GetHeaderByNumber(ctx, rpc.BlockNumber(num)) + if header == nil || err != nil { + return logs, err + } + found, err := f.checkMatches(ctx, header, api) + if err != nil { + return logs, err + } + logs = append(logs, found...) + } + + return logs, nil +} + +// unindexedLogs returns the logs matching the filter criteria based on raw block +// iteration and bloom matching. +func (f *Filter) unindexedLogs(ctx context.Context, end uint64, api *APIImpl) ([]*types.Log, error) { + var logs []*types.Log + + for ; f.begin <= int64(end); f.begin++ { + header, err := api.GetHeaderByNumber(ctx, rpc.BlockNumber(f.begin)) + if header == nil || err != nil { + return logs, err + } + found, err := f.blockLogs(ctx, header, api) + if err != nil { + return logs, err + } + logs = append(logs, found...) + } + return logs, nil +} + +// blockLogs returns the logs matching the filter criteria within a single block. +func (f *Filter) blockLogs(ctx context.Context, header *types.Header, api *APIImpl) (logs []*types.Log, err error) { + if bloomFilter(header.Bloom, f.addresses, f.topics) { + found, err := f.checkMatches(ctx, header, api) + if err != nil { + return logs, err + } + logs = append(logs, found...) + } + return logs, nil +} + +// checkMatches checks if the receipts belonging to the given header contain any log events that +// match the filter criteria. This function is called when the bloom filter signals a potential match. +func (f *Filter) checkMatches(ctx context.Context, header *types.Header, api *APIImpl) (logs []*types.Log, err error) { + // Get the logs of the block + logsList, err := api.GetLogsByHash(ctx, header.Hash()) + if err != nil { + return nil, err + } + unfiltered := make([]*types.Log, 0, len(logsList)) + for _, logs := range logsList { + unfiltered = append(unfiltered, logs...) + } + logs = filterLogs(unfiltered, nil, nil, f.addresses, f.topics) + if len(logs) > 0 { + // We have matching logs, check if we need to resolve full logs via the light client + if logs[0].TxHash == (common.Hash{}) { + chainConfig := getChainConfig(api.dbReader) + receipts := rawdb.ReadReceipts(api.dbReader, header.Hash(), header.Number.Uint64(), chainConfig) + unfiltered = unfiltered[:0] + for _, receipt := range receipts { + unfiltered = append(unfiltered, receipt.Logs...) + } + logs = filterLogs(unfiltered, nil, nil, f.addresses, f.topics) + } + return logs, nil + } + return nil, nil +} + +func includes(addresses []common.Address, a common.Address) bool { + for _, addr := range addresses { + if addr == a { + return true + } + } + + return false +} + +// filterLogs creates a slice of logs matching the given criteria. +func filterLogs(logs []*types.Log, fromBlock, toBlock *big.Int, addresses []common.Address, topics [][]common.Hash) []*types.Log { + var ret []*types.Log +Logs: + for _, log := range logs { + if fromBlock != nil && fromBlock.Int64() >= 0 && fromBlock.Uint64() > log.BlockNumber { + continue + } + if toBlock != nil && toBlock.Int64() >= 0 && toBlock.Uint64() < log.BlockNumber { + continue + } + + if len(addresses) > 0 && !includes(addresses, log.Address) { + continue + } + // If the to filtered topics is greater than the amount of topics in logs, skip. + if len(topics) > len(log.Topics) { + continue Logs + } + for i, sub := range topics { + match := len(sub) == 0 // empty rule set == wildcard + for _, topic := range sub { + if log.Topics[i] == topic { + match = true + break + } + } + if !match { + continue Logs + } + } + ret = append(ret, log) + } + return ret +} + +func bloomFilter(bloom types.Bloom, addresses []common.Address, topics [][]common.Hash) bool { + if len(addresses) > 0 { + var included bool + for _, addr := range addresses { + if types.BloomLookup(bloom, addr) { + included = true + break + } + } + if !included { + return false + } + } + + for _, sub := range topics { + included := len(sub) == 0 // empty rule set == wildcard + for _, topic := range sub { + if types.BloomLookup(bloom, topic) { + included = true + break + } + } + if !included { + return false + } + } + return true +} + +func returnLogs(logs []*types.Log) []*types.Log { + if logs == nil { + return []*types.Log{} + } + return logs +} diff --git a/cmd/rpcdaemon/commands/rpc_block.go b/cmd/rpcdaemon/commands/rpc_block.go new file mode 100644 index 00000000000..d5cca45f313 --- /dev/null +++ b/cmd/rpcdaemon/commands/rpc_block.go @@ -0,0 +1,35 @@ +package commands + +import ( + "fmt" + + "github.com/ledgerwatch/turbo-geth/core/rawdb" + "github.com/ledgerwatch/turbo-geth/eth/stagedsync/stages" + "github.com/ledgerwatch/turbo-geth/rpc" +) + +func getBlockNumber(number rpc.BlockNumber, dbReader rawdb.DatabaseReader) (uint64, error) { + var blockNum uint64 + var err error + if number == rpc.LatestBlockNumber || number == rpc.PendingBlockNumber { + blockNum, err = getLatestBlockNumber(dbReader) + if err != nil { + return 0, err + } + } else if number == rpc.EarliestBlockNumber { + blockNum = 0 + } else { + blockNum = uint64(number.Int64()) + } + + return blockNum, nil +} + +func getLatestBlockNumber(dbReader rawdb.DatabaseReader) (uint64, error) { + blockNum, _, err := stages.GetStageProgress(dbReader, stages.Execution) + if err != nil { + return 0, fmt.Errorf("getting latest block number: %v", err) + } + + return blockNum, nil +} diff --git a/core/eth_backend.go b/core/eth_backend.go index 579b73ee8e1..fcd975cdc1e 100644 --- a/core/eth_backend.go +++ b/core/eth_backend.go @@ -14,6 +14,7 @@ type Backend interface { TxPool() *TxPool Etherbase() (common.Address, error) NetVersion() (uint64, error) + BloomIndexer() *ChainIndexer } func NewEthBackend(eth Backend) *EthBackend { @@ -28,3 +29,7 @@ func (back *EthBackend) AddLocal(signedtx []byte) ([]byte, error) { return tx.Hash().Bytes(), back.TxPool().AddLocal(tx) } + +func (back *EthBackend) BloomStatus() (uint64, uint64, common.Hash) { + return back.Backend.BloomIndexer().Sections() +} diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 1a214472a15..03b3fbf469d 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -588,6 +588,23 @@ func ReadBlockByHash(db DatabaseReader, hash common.Hash) *types.Block { return ReadBlock(db, hash, *number) } +func ReadHeaderByNumber(db DatabaseReader, number uint64) *types.Header { + hash := ReadCanonicalHash(db, number) + if hash == (common.Hash{}) { + return nil + } + + return ReadHeader(db, hash, number) +} + +func ReadHeaderByHash(db DatabaseReader, hash common.Hash) *types.Header { + number := ReadHeaderNumber(db, hash) + if number == nil { + return nil + } + return ReadHeader(db, hash, *number) +} + // FIXME: implement in Turbo-Geth // WriteAncientBlock writes entire block data into ancient store and returns the total written size. func WriteAncientBlock(db DatabaseWriter, block *types.Block, receipts types.Receipts, td *big.Int) int { diff --git a/eth/filters/filter.go b/eth/filters/filter.go index ce88db7765c..948f01c246c 100644 --- a/eth/filters/filter.go +++ b/eth/filters/filter.go @@ -287,10 +287,10 @@ func filterLogs(logs []*types.Log, fromBlock, toBlock *big.Int, addresses []comm var ret []*types.Log Logs: for _, log := range logs { - if fromBlock != nil && fromBlock.Int64() >= 0 && fromBlock.Uint64() > log.BlockNumber { + if fromBlock != nil && fromBlock.Int64() >= 0 && uint64(fromBlock.Int64()) > log.BlockNumber { continue } - if toBlock != nil && toBlock.Int64() >= 0 && toBlock.Uint64() < log.BlockNumber { + if toBlock != nil && toBlock.Int64() >= 0 && uint64(toBlock.Int64()) < log.BlockNumber { continue } diff --git a/ethdb/kv_abstract.go b/ethdb/kv_abstract.go index ff65e1b0a5d..f2acc87019a 100644 --- a/ethdb/kv_abstract.go +++ b/ethdb/kv_abstract.go @@ -70,6 +70,7 @@ type Backend interface { AddLocal([]byte) ([]byte, error) Etherbase() (common.Address, error) NetVersion() (uint64, error) + BloomStatus() (uint64, uint64, common.Hash) } type DbProvider uint8 diff --git a/ethdb/kv_remote.go b/ethdb/kv_remote.go index 13b32b5bf25..cb6565da2e3 100644 --- a/ethdb/kv_remote.go +++ b/ethdb/kv_remote.go @@ -365,3 +365,8 @@ func (back *RemoteBackend) NetVersion() (uint64, error) { return res.Id, nil } + +func (back *RemoteBackend) BloomStatus() (uint64, uint64, common.Hash) { + res, _ := back.remoteEthBackend.BloomStatus(context.Background(), &remote.BloomStatusRequest{}) + return res.Size, res.Sections, common.BytesToHash(res.Hash) +} diff --git a/ethdb/remote/ethbackend.pb.go b/ethdb/remote/ethbackend.pb.go index 72d13a943eb..8d1ab1a4194 100644 --- a/ethdb/remote/ethbackend.pb.go +++ b/ethdb/remote/ethbackend.pb.go @@ -119,6 +119,107 @@ func (x *AddReply) GetHash() []byte { return nil } +type BloomStatusRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *BloomStatusRequest) Reset() { + *x = BloomStatusRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_remote_ethbackend_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BloomStatusRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BloomStatusRequest) ProtoMessage() {} + +func (x *BloomStatusRequest) ProtoReflect() protoreflect.Message { + mi := &file_remote_ethbackend_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BloomStatusRequest.ProtoReflect.Descriptor instead. +func (*BloomStatusRequest) Descriptor() ([]byte, []int) { + return file_remote_ethbackend_proto_rawDescGZIP(), []int{2} +} + +type BloomStatusReply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Size uint64 `protobuf:"varint,1,opt,name=size,proto3" json:"size,omitempty"` + Sections uint64 `protobuf:"varint,2,opt,name=sections,proto3" json:"sections,omitempty"` + Hash []byte `protobuf:"bytes,3,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (x *BloomStatusReply) Reset() { + *x = BloomStatusReply{} + if protoimpl.UnsafeEnabled { + mi := &file_remote_ethbackend_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *BloomStatusReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*BloomStatusReply) ProtoMessage() {} + +func (x *BloomStatusReply) ProtoReflect() protoreflect.Message { + mi := &file_remote_ethbackend_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use BloomStatusReply.ProtoReflect.Descriptor instead. +func (*BloomStatusReply) Descriptor() ([]byte, []int) { + return file_remote_ethbackend_proto_rawDescGZIP(), []int{3} +} + +func (x *BloomStatusReply) GetSize() uint64 { + if x != nil { + return x.Size + } + return 0 +} + +func (x *BloomStatusReply) GetSections() uint64 { + if x != nil { + return x.Sections + } + return 0 +} + +func (x *BloomStatusReply) GetHash() []byte { + if x != nil { + return x.Hash + } + return nil +} + type EtherbaseRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -128,7 +229,7 @@ type EtherbaseRequest struct { func (x *EtherbaseRequest) Reset() { *x = EtherbaseRequest{} if protoimpl.UnsafeEnabled { - mi := &file_remote_ethbackend_proto_msgTypes[2] + mi := &file_remote_ethbackend_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -141,7 +242,7 @@ func (x *EtherbaseRequest) String() string { func (*EtherbaseRequest) ProtoMessage() {} func (x *EtherbaseRequest) ProtoReflect() protoreflect.Message { - mi := &file_remote_ethbackend_proto_msgTypes[2] + mi := &file_remote_ethbackend_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -154,7 +255,7 @@ func (x *EtherbaseRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use EtherbaseRequest.ProtoReflect.Descriptor instead. func (*EtherbaseRequest) Descriptor() ([]byte, []int) { - return file_remote_ethbackend_proto_rawDescGZIP(), []int{2} + return file_remote_ethbackend_proto_rawDescGZIP(), []int{4} } type EtherbaseReply struct { @@ -168,7 +269,7 @@ type EtherbaseReply struct { func (x *EtherbaseReply) Reset() { *x = EtherbaseReply{} if protoimpl.UnsafeEnabled { - mi := &file_remote_ethbackend_proto_msgTypes[3] + mi := &file_remote_ethbackend_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -181,7 +282,7 @@ func (x *EtherbaseReply) String() string { func (*EtherbaseReply) ProtoMessage() {} func (x *EtherbaseReply) ProtoReflect() protoreflect.Message { - mi := &file_remote_ethbackend_proto_msgTypes[3] + mi := &file_remote_ethbackend_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -194,7 +295,7 @@ func (x *EtherbaseReply) ProtoReflect() protoreflect.Message { // Deprecated: Use EtherbaseReply.ProtoReflect.Descriptor instead. func (*EtherbaseReply) Descriptor() ([]byte, []int) { - return file_remote_ethbackend_proto_rawDescGZIP(), []int{3} + return file_remote_ethbackend_proto_rawDescGZIP(), []int{5} } func (x *EtherbaseReply) GetHash() []byte { @@ -213,7 +314,7 @@ type NetVersionRequest struct { func (x *NetVersionRequest) Reset() { *x = NetVersionRequest{} if protoimpl.UnsafeEnabled { - mi := &file_remote_ethbackend_proto_msgTypes[4] + mi := &file_remote_ethbackend_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -226,7 +327,7 @@ func (x *NetVersionRequest) String() string { func (*NetVersionRequest) ProtoMessage() {} func (x *NetVersionRequest) ProtoReflect() protoreflect.Message { - mi := &file_remote_ethbackend_proto_msgTypes[4] + mi := &file_remote_ethbackend_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -239,7 +340,7 @@ func (x *NetVersionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use NetVersionRequest.ProtoReflect.Descriptor instead. func (*NetVersionRequest) Descriptor() ([]byte, []int) { - return file_remote_ethbackend_proto_rawDescGZIP(), []int{4} + return file_remote_ethbackend_proto_rawDescGZIP(), []int{6} } type NetVersionReply struct { @@ -253,7 +354,7 @@ type NetVersionReply struct { func (x *NetVersionReply) Reset() { *x = NetVersionReply{} if protoimpl.UnsafeEnabled { - mi := &file_remote_ethbackend_proto_msgTypes[5] + mi := &file_remote_ethbackend_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -266,7 +367,7 @@ func (x *NetVersionReply) String() string { func (*NetVersionReply) ProtoMessage() {} func (x *NetVersionReply) ProtoReflect() protoreflect.Message { - mi := &file_remote_ethbackend_proto_msgTypes[5] + mi := &file_remote_ethbackend_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -279,7 +380,7 @@ func (x *NetVersionReply) ProtoReflect() protoreflect.Message { // Deprecated: Use NetVersionReply.ProtoReflect.Descriptor instead. func (*NetVersionReply) Descriptor() ([]byte, []int) { - return file_remote_ethbackend_proto_rawDescGZIP(), []int{5} + return file_remote_ethbackend_proto_rawDescGZIP(), []int{7} } func (x *NetVersionReply) GetId() uint64 { @@ -298,30 +399,41 @@ var file_remote_ethbackend_proto_rawDesc = []byte{ 0x0a, 0x08, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x74, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x64, 0x74, 0x78, 0x22, 0x1e, 0x0a, 0x08, 0x41, 0x64, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x22, 0x12, 0x0a, 0x10, 0x45, 0x74, - 0x68, 0x65, 0x72, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x24, - 0x0a, 0x0e, 0x45, 0x74, 0x68, 0x65, 0x72, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, - 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, - 0x68, 0x61, 0x73, 0x68, 0x22, 0x13, 0x0a, 0x11, 0x4e, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x21, 0x0a, 0x0f, 0x4e, 0x65, 0x74, - 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x0e, 0x0a, 0x02, - 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x32, 0xb9, 0x01, 0x0a, - 0x0a, 0x45, 0x54, 0x48, 0x42, 0x41, 0x43, 0x4b, 0x45, 0x4e, 0x44, 0x12, 0x2a, 0x0a, 0x03, 0x41, - 0x64, 0x64, 0x12, 0x11, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x54, 0x78, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x41, - 0x64, 0x64, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x3d, 0x0a, 0x09, 0x45, 0x74, 0x68, 0x65, 0x72, - 0x62, 0x61, 0x73, 0x65, 0x12, 0x18, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x45, 0x74, - 0x68, 0x65, 0x72, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, - 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x45, 0x74, 0x68, 0x65, 0x72, 0x62, 0x61, 0x73, - 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x40, 0x0a, 0x0a, 0x4e, 0x65, 0x74, 0x56, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x4e, 0x65, - 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x17, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x4e, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x31, 0x0a, 0x10, 0x69, 0x6f, 0x2e, 0x74, - 0x75, 0x72, 0x62, 0x6f, 0x2d, 0x67, 0x65, 0x74, 0x68, 0x2e, 0x64, 0x62, 0x42, 0x0a, 0x45, 0x54, - 0x48, 0x42, 0x41, 0x43, 0x4b, 0x45, 0x4e, 0x44, 0x50, 0x01, 0x5a, 0x0f, 0x2e, 0x2f, 0x72, 0x65, - 0x6d, 0x6f, 0x74, 0x65, 0x3b, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x22, 0x14, 0x0a, 0x12, 0x42, 0x6c, + 0x6f, 0x6f, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x22, 0x56, 0x0a, 0x10, 0x42, 0x6c, 0x6f, 0x6f, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, + 0x65, 0x70, 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0c, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x22, 0x12, 0x0a, 0x10, 0x45, 0x74, 0x68, 0x65, + 0x72, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x24, 0x0a, 0x0e, + 0x45, 0x74, 0x68, 0x65, 0x72, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x12, + 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x68, 0x61, + 0x73, 0x68, 0x22, 0x13, 0x0a, 0x11, 0x4e, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x21, 0x0a, 0x0f, 0x4e, 0x65, 0x74, 0x56, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x32, 0xfe, 0x01, 0x0a, 0x0a, 0x45, + 0x54, 0x48, 0x42, 0x41, 0x43, 0x4b, 0x45, 0x4e, 0x44, 0x12, 0x2a, 0x0a, 0x03, 0x41, 0x64, 0x64, + 0x12, 0x11, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x54, 0x78, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x41, 0x64, 0x64, + 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x3d, 0x0a, 0x09, 0x45, 0x74, 0x68, 0x65, 0x72, 0x62, 0x61, + 0x73, 0x65, 0x12, 0x18, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x45, 0x74, 0x68, 0x65, + 0x72, 0x62, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, + 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x45, 0x74, 0x68, 0x65, 0x72, 0x62, 0x61, 0x73, 0x65, 0x52, + 0x65, 0x70, 0x6c, 0x79, 0x12, 0x40, 0x0a, 0x0a, 0x4e, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x12, 0x19, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x4e, 0x65, 0x74, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, + 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x4e, 0x65, 0x74, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x43, 0x0a, 0x0b, 0x42, 0x6c, 0x6f, 0x6f, 0x6d, 0x53, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1a, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x42, + 0x6c, 0x6f, 0x6f, 0x6d, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x2e, 0x42, 0x6c, 0x6f, 0x6f, 0x6d, + 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x31, 0x0a, 0x10, 0x69, + 0x6f, 0x2e, 0x74, 0x75, 0x72, 0x62, 0x6f, 0x2d, 0x67, 0x65, 0x74, 0x68, 0x2e, 0x64, 0x62, 0x42, + 0x0a, 0x45, 0x54, 0x48, 0x42, 0x41, 0x43, 0x4b, 0x45, 0x4e, 0x44, 0x50, 0x01, 0x5a, 0x0f, 0x2e, + 0x2f, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3b, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -336,24 +448,28 @@ func file_remote_ethbackend_proto_rawDescGZIP() []byte { return file_remote_ethbackend_proto_rawDescData } -var file_remote_ethbackend_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_remote_ethbackend_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_remote_ethbackend_proto_goTypes = []interface{}{ - (*TxRequest)(nil), // 0: remote.TxRequest - (*AddReply)(nil), // 1: remote.AddReply - (*EtherbaseRequest)(nil), // 2: remote.EtherbaseRequest - (*EtherbaseReply)(nil), // 3: remote.EtherbaseReply - (*NetVersionRequest)(nil), // 4: remote.NetVersionRequest - (*NetVersionReply)(nil), // 5: remote.NetVersionReply + (*TxRequest)(nil), // 0: remote.TxRequest + (*AddReply)(nil), // 1: remote.AddReply + (*BloomStatusRequest)(nil), // 2: remote.BloomStatusRequest + (*BloomStatusReply)(nil), // 3: remote.BloomStatusReply + (*EtherbaseRequest)(nil), // 4: remote.EtherbaseRequest + (*EtherbaseReply)(nil), // 5: remote.EtherbaseReply + (*NetVersionRequest)(nil), // 6: remote.NetVersionRequest + (*NetVersionReply)(nil), // 7: remote.NetVersionReply } var file_remote_ethbackend_proto_depIdxs = []int32{ 0, // 0: remote.ETHBACKEND.Add:input_type -> remote.TxRequest - 2, // 1: remote.ETHBACKEND.Etherbase:input_type -> remote.EtherbaseRequest - 4, // 2: remote.ETHBACKEND.NetVersion:input_type -> remote.NetVersionRequest - 1, // 3: remote.ETHBACKEND.Add:output_type -> remote.AddReply - 3, // 4: remote.ETHBACKEND.Etherbase:output_type -> remote.EtherbaseReply - 5, // 5: remote.ETHBACKEND.NetVersion:output_type -> remote.NetVersionReply - 3, // [3:6] is the sub-list for method output_type - 0, // [0:3] is the sub-list for method input_type + 4, // 1: remote.ETHBACKEND.Etherbase:input_type -> remote.EtherbaseRequest + 6, // 2: remote.ETHBACKEND.NetVersion:input_type -> remote.NetVersionRequest + 2, // 3: remote.ETHBACKEND.BloomStatus:input_type -> remote.BloomStatusRequest + 1, // 4: remote.ETHBACKEND.Add:output_type -> remote.AddReply + 5, // 5: remote.ETHBACKEND.Etherbase:output_type -> remote.EtherbaseReply + 7, // 6: remote.ETHBACKEND.NetVersion:output_type -> remote.NetVersionReply + 3, // 7: remote.ETHBACKEND.BloomStatus:output_type -> remote.BloomStatusReply + 4, // [4:8] is the sub-list for method output_type + 0, // [0:4] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -390,7 +506,7 @@ func file_remote_ethbackend_proto_init() { } } file_remote_ethbackend_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EtherbaseRequest); i { + switch v := v.(*BloomStatusRequest); i { case 0: return &v.state case 1: @@ -402,7 +518,7 @@ func file_remote_ethbackend_proto_init() { } } file_remote_ethbackend_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*EtherbaseReply); i { + switch v := v.(*BloomStatusReply); i { case 0: return &v.state case 1: @@ -414,7 +530,7 @@ func file_remote_ethbackend_proto_init() { } } file_remote_ethbackend_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*NetVersionRequest); i { + switch v := v.(*EtherbaseRequest); i { case 0: return &v.state case 1: @@ -426,6 +542,30 @@ func file_remote_ethbackend_proto_init() { } } file_remote_ethbackend_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EtherbaseReply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_remote_ethbackend_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NetVersionRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_remote_ethbackend_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*NetVersionReply); i { case 0: return &v.state @@ -444,7 +584,7 @@ func file_remote_ethbackend_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_remote_ethbackend_proto_rawDesc, NumEnums: 0, - NumMessages: 6, + NumMessages: 8, NumExtensions: 0, NumServices: 1, }, diff --git a/ethdb/remote/ethbackend.proto b/ethdb/remote/ethbackend.proto index 395dab8aaff..6db987f6c03 100644 --- a/ethdb/remote/ethbackend.proto +++ b/ethdb/remote/ethbackend.proto @@ -11,6 +11,7 @@ service ETHBACKEND { rpc Add(TxRequest) returns (AddReply); rpc Etherbase(EtherbaseRequest) returns (EtherbaseReply); rpc NetVersion(NetVersionRequest) returns (NetVersionReply); + rpc BloomStatus(BloomStatusRequest) returns (BloomStatusReply); } message TxRequest { @@ -21,6 +22,15 @@ message AddReply { bytes hash = 1; } +message BloomStatusRequest { +} + +message BloomStatusReply { + uint64 size = 1; + uint64 sections = 2; + bytes hash = 3; +} + message EtherbaseRequest { } diff --git a/ethdb/remote/ethbackend_grpc.pb.go b/ethdb/remote/ethbackend_grpc.pb.go index 1878f650ebc..b0d376e81f4 100644 --- a/ethdb/remote/ethbackend_grpc.pb.go +++ b/ethdb/remote/ethbackend_grpc.pb.go @@ -20,6 +20,7 @@ type ETHBACKENDClient interface { Add(ctx context.Context, in *TxRequest, opts ...grpc.CallOption) (*AddReply, error) Etherbase(ctx context.Context, in *EtherbaseRequest, opts ...grpc.CallOption) (*EtherbaseReply, error) NetVersion(ctx context.Context, in *NetVersionRequest, opts ...grpc.CallOption) (*NetVersionReply, error) + BloomStatus(ctx context.Context, in *BloomStatusRequest, opts ...grpc.CallOption) (*BloomStatusReply, error) } type eTHBACKENDClient struct { @@ -57,6 +58,15 @@ func (c *eTHBACKENDClient) NetVersion(ctx context.Context, in *NetVersionRequest return out, nil } +func (c *eTHBACKENDClient) BloomStatus(ctx context.Context, in *BloomStatusRequest, opts ...grpc.CallOption) (*BloomStatusReply, error) { + out := new(BloomStatusReply) + err := c.cc.Invoke(ctx, "/remote.ETHBACKEND/BloomStatus", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ETHBACKENDServer is the server API for ETHBACKEND service. // All implementations must embed UnimplementedETHBACKENDServer // for forward compatibility @@ -64,6 +74,7 @@ type ETHBACKENDServer interface { Add(context.Context, *TxRequest) (*AddReply, error) Etherbase(context.Context, *EtherbaseRequest) (*EtherbaseReply, error) NetVersion(context.Context, *NetVersionRequest) (*NetVersionReply, error) + BloomStatus(context.Context, *BloomStatusRequest) (*BloomStatusReply, error) mustEmbedUnimplementedETHBACKENDServer() } @@ -80,6 +91,9 @@ func (*UnimplementedETHBACKENDServer) Etherbase(context.Context, *EtherbaseReque func (*UnimplementedETHBACKENDServer) NetVersion(context.Context, *NetVersionRequest) (*NetVersionReply, error) { return nil, status.Errorf(codes.Unimplemented, "method NetVersion not implemented") } +func (*UnimplementedETHBACKENDServer) BloomStatus(context.Context, *BloomStatusRequest) (*BloomStatusReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method BloomStatus not implemented") +} func (*UnimplementedETHBACKENDServer) mustEmbedUnimplementedETHBACKENDServer() {} func RegisterETHBACKENDServer(s *grpc.Server, srv ETHBACKENDServer) { @@ -140,6 +154,24 @@ func _ETHBACKEND_NetVersion_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _ETHBACKEND_BloomStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(BloomStatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ETHBACKENDServer).BloomStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/remote.ETHBACKEND/BloomStatus", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ETHBACKENDServer).BloomStatus(ctx, req.(*BloomStatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _ETHBACKEND_serviceDesc = grpc.ServiceDesc{ ServiceName: "remote.ETHBACKEND", HandlerType: (*ETHBACKENDServer)(nil), @@ -156,6 +188,10 @@ var _ETHBACKEND_serviceDesc = grpc.ServiceDesc{ MethodName: "NetVersion", Handler: _ETHBACKEND_NetVersion_Handler, }, + { + MethodName: "BloomStatus", + Handler: _ETHBACKEND_BloomStatus_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "remote/ethbackend.proto", diff --git a/ethdb/remote/remotedbserver/ethbackend.go b/ethdb/remote/remotedbserver/ethbackend.go index 085b55c3c75..9eb0e391de1 100644 --- a/ethdb/remote/remotedbserver/ethbackend.go +++ b/ethdb/remote/remotedbserver/ethbackend.go @@ -7,6 +7,7 @@ import ( "github.com/ledgerwatch/turbo-geth/core" "github.com/ledgerwatch/turbo-geth/core/types" "github.com/ledgerwatch/turbo-geth/ethdb/remote" + "github.com/ledgerwatch/turbo-geth/params" "github.com/ledgerwatch/turbo-geth/rlp" ) @@ -55,3 +56,9 @@ func (s *EthBackendServer) NetVersion(_ context.Context, _ *remote.NetVersionReq } return &remote.NetVersionReply{Id: id}, nil } + +func (s *EthBackendServer) BloomStatus(_ context.Context, _ *remote.BloomStatusRequest) (*remote.BloomStatusReply, error) { + sections, _, _ := s.eth.BloomIndexer().Sections() + + return &remote.BloomStatusReply{Size: params.BloomBitsBlocks, Sections: sections}, nil +}