diff --git a/core/bor_blockchain.go b/core/bor_blockchain.go index e0525b8365..1a5ce39e62 100644 --- a/core/bor_blockchain.go +++ b/core/bor_blockchain.go @@ -1,7 +1,6 @@ package core import ( - "fmt" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" @@ -9,7 +8,6 @@ import ( // GetBorReceiptByHash retrieves the bor block receipt in a given block. func (bc *BlockChain) GetBorReceiptByHash(hash common.Hash) *types.Receipt { - fmt.Printf(">>>>> GetBorBlockReceiptBorBlockchain\n") if receipt, ok := bc.borReceiptsCache.Get(hash); ok { return receipt } diff --git a/eth/bor_api_backend.go b/eth/bor_api_backend.go index d4cef2aec8..d320b45527 100644 --- a/eth/bor_api_backend.go +++ b/eth/bor_api_backend.go @@ -20,7 +20,6 @@ var errBorEngineNotAvailable error = errors.New("Only available in Bor engine") // GetRootHash returns root hash for given start and end block func (b *EthAPIBackend) GetRootHash(ctx context.Context, starBlockNr uint64, endBlockNr uint64) (string, error) { var api *bor.API - fmt.Printf(">>>>> GetRootHashApiBackend\n") for _, _api := range b.eth.Engine().APIs(b.eth.BlockChain()) { if _api.Namespace == "bor" { @@ -43,7 +42,6 @@ func (b *EthAPIBackend) GetRootHash(ctx context.Context, starBlockNr uint64, end // GetVoteOnHash returns the vote on hash func (b *EthAPIBackend) GetVoteOnHash(ctx context.Context, starBlockNr uint64, endBlockNr uint64, hash string, milestoneId string) (bool, error) { var api *bor.API - fmt.Printf(">>>>> GetVoteOnHashApiBackend\n") for _, _api := range b.eth.Engine().APIs(b.eth.BlockChain()) { if _api.Namespace == "bor" { @@ -92,7 +90,6 @@ func (b *EthAPIBackend) GetVoteOnHash(ctx context.Context, starBlockNr uint64, e // GetBorBlockReceipt returns bor block receipt func (b *EthAPIBackend) GetBorBlockReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error) { - fmt.Printf(">>>>> GetBorBlockReceiptApiBackend\n") receipt := b.eth.blockchain.GetBorReceiptByHash(hash) if receipt == nil { @@ -104,7 +101,6 @@ func (b *EthAPIBackend) GetBorBlockReceipt(ctx context.Context, hash common.Hash // GetBorBlockLogs returns bor block logs func (b *EthAPIBackend) GetBorBlockLogs(ctx context.Context, hash common.Hash) ([]*types.Log, error) { - fmt.Printf(">>>>> GetBorBlockLogsApiBackend\n") receipt := b.eth.blockchain.GetBorReceiptByHash(hash) if receipt == nil { return nil, nil @@ -115,25 +111,21 @@ func (b *EthAPIBackend) GetBorBlockLogs(ctx context.Context, hash common.Hash) ( // GetBorBlockTransaction returns bor block tx func (b *EthAPIBackend) GetBorBlockTransaction(ctx context.Context, hash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) { - fmt.Printf(">>>>> GetBorBlockTransactionApiBackend\n") tx, blockHash, blockNumber, index := rawdb.ReadBorTransaction(b.eth.ChainDb(), hash) return tx, blockHash, blockNumber, index, nil } func (b *EthAPIBackend) GetBorBlockTransactionWithBlockHash(ctx context.Context, txHash common.Hash, blockHash common.Hash) (*types.Transaction, common.Hash, uint64, uint64, error) { - fmt.Printf(">>>>> GetBorBlockTransactionWithBlockHashApiBackend\n") tx, blockHash, blockNumber, index := rawdb.ReadBorTransactionWithBlockHash(b.eth.ChainDb(), txHash, blockHash) return tx, blockHash, blockNumber, index, nil } // SubscribeStateSyncEvent subscribes to state sync event func (b *EthAPIBackend) SubscribeStateSyncEvent(ch chan<- core.StateSyncEvent) event.Subscription { - fmt.Printf(">>>>> SubscribeStateSyncEventApiBackend\n") return b.eth.BlockChain().SubscribeStateSyncEvent(ch) } // SubscribeChain2HeadEvent subscribes to reorg/head/fork event func (b *EthAPIBackend) SubscribeChain2HeadEvent(ch chan<- core.Chain2HeadEvent) event.Subscription { - fmt.Printf(">>>>> SubscribeChain2HeadEventApiBackend\n") return b.eth.BlockChain().SubscribeChain2HeadEvent(ch) } diff --git a/internal/cli/server/api_service.go b/internal/cli/server/api_service.go index c59fcf5187..57813072e5 100644 --- a/internal/cli/server/api_service.go +++ b/internal/cli/server/api_service.go @@ -12,22 +12,26 @@ import ( ) func (s *Server) GetRootHash(ctx context.Context, req *protobor.GetRootHashRequest) (*protobor.GetRootHashResponse, error) { - fmt.Printf(">>>>> GetRootHash: %v\n", req) + fmt.Printf(">>>>> GetRootHash: req %v\n", req) rootHash, err := s.backend.APIBackend.GetRootHash(ctx, req.StartBlockNumber, req.EndBlockNumber) if err != nil { + fmt.Printf(">>>>> GetRootHash: err %v\n", err) return nil, err } + fmt.Printf(">>>>> GetRootHash: returning\n") return &protobor.GetRootHashResponse{RootHash: rootHash}, nil } func (s *Server) GetVoteOnHash(ctx context.Context, req *protobor.GetVoteOnHashRequest) (*protobor.GetVoteOnHashResponse, error) { - fmt.Printf(">>>>> GetVoteOnHash: %v\n", req) + fmt.Printf(">>>>> GetVoteOnHash: req %v\n", req) vote, err := s.backend.APIBackend.GetVoteOnHash(ctx, req.StartBlockNumber, req.EndBlockNumber, req.Hash, req.MilestoneId) if err != nil { + fmt.Printf(">>>>> GetVoteOnHash: err %v\n", err) return nil, err } + fmt.Printf(">>>>> GetVoteOnHash: returning\n") return &protobor.GetVoteOnHashResponse{Response: vote}, nil } @@ -40,22 +44,26 @@ func headerToProtoborHeader(h *types.Header) *protobor.Header { } func (s *Server) HeaderByNumber(ctx context.Context, req *protobor.GetHeaderByNumberRequest) (*protobor.GetHeaderByNumberResponse, error) { - fmt.Printf(">>>>> HeaderByNumber: %v\n", req) + fmt.Printf(">>>>> HeaderByNumber: req %v\n", req) header, err := s.backend.APIBackend.HeaderByNumber(ctx, rpc.BlockNumber(req.Number)) if err != nil { + fmt.Printf(">>>>> HeaderByNumber: err %v\n", err) return nil, err } + fmt.Printf(">>>>> HeaderByNumber: returning\n") return &protobor.GetHeaderByNumberResponse{Header: headerToProtoborHeader(header)}, nil } func (s *Server) BlockByNumber(ctx context.Context, req *protobor.GetBlockByNumberRequest) (*protobor.GetBlockByNumberResponse, error) { - fmt.Printf(">>>>> BlockByNumber: %v\n", req) + fmt.Printf(">>>>> BlockByNumber: req %v\n", req) block, err := s.backend.APIBackend.BlockByNumber(ctx, rpc.BlockNumber(req.Number)) if err != nil { + fmt.Printf(">>>>> BlockByNumber: err %v\n", err) return nil, err } + fmt.Printf(">>>>> BlockByNumber: returning\n") return &protobor.GetBlockByNumberResponse{Block: blockToProtoBlock(block)}, nil } @@ -66,34 +74,41 @@ func blockToProtoBlock(h *types.Block) *protobor.Block { } func (s *Server) TransactionReceipt(ctx context.Context, req *protobor.ReceiptRequest) (*protobor.ReceiptResponse, error) { - fmt.Printf(">>>>> TransactionReceipt: %v\n", req) + fmt.Printf(">>>>> TransactionReceipt: req %v\n", req) _, blockHash, _, txnIndex, err := s.backend.APIBackend.GetTransaction(ctx, protoutil.ConvertH256ToHash(req.Hash)) if err != nil { + fmt.Printf(">>>>> TransactionReceipt: err1 %v\n", err) return nil, err } receipts, err := s.backend.APIBackend.GetReceipts(ctx, blockHash) if err != nil { + fmt.Printf(">>>>> TransactionReceipt: err2 %v\n", err) return nil, err } if receipts == nil { + fmt.Printf(">>>>> TransactionReceipt: err3 %v\n", errors.New("no receipts found")) return nil, errors.New("no receipts found") } if len(receipts) <= int(txnIndex) { + fmt.Printf(">>>>> TransactionReceipt: err4 %v\n", errors.New("transaction index out of bounds")) return nil, errors.New("transaction index out of bounds") } + fmt.Printf(">>>>> TransactionReceipt: returning\n") return &protobor.ReceiptResponse{Receipt: ConvertReceiptToProtoReceipt(receipts[txnIndex])}, nil } func (s *Server) BorBlockReceipt(ctx context.Context, req *protobor.ReceiptRequest) (*protobor.ReceiptResponse, error) { - fmt.Printf(">>>>> BorBlockReceipt: %v\n", req) + fmt.Printf(">>>>> BorBlockReceipt: req %v\n", req) receipt, err := s.backend.APIBackend.GetBorBlockReceipt(ctx, protoutil.ConvertH256ToHash(req.Hash)) if err != nil { + fmt.Printf(">>>>> BorBlockReceipt: err %v\n", err) return nil, err } + fmt.Printf(">>>>> BorBlockReceipt: returning\n") return &protobor.ReceiptResponse{Receipt: ConvertReceiptToProtoReceipt(receipt)}, nil } diff --git a/internal/cli/server/utils.go b/internal/cli/server/utils.go index e001da0c9b..aa461c9e92 100644 --- a/internal/cli/server/utils.go +++ b/internal/cli/server/utils.go @@ -1,7 +1,6 @@ package server import ( - "fmt" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/internal/cli/server/proto" @@ -13,7 +12,6 @@ import ( ) func PeerInfoToPeer(info *p2p.PeerInfo) *proto.Peer { - fmt.Printf(">>>>> PeerInfoToPeer: %v\n", info) return &proto.Peer{ Id: info.ID, Enode: info.Enode, @@ -26,14 +24,12 @@ func PeerInfoToPeer(info *p2p.PeerInfo) *proto.Peer { } func ConvertBloomToProtoBloom(bloom types.Bloom) *protobor.Bloom { - fmt.Printf(">>>>> ConvertBloomToProtoBloom: %v\n", bloom) return &protobor.Bloom{ Bloom: bloom.Bytes(), } } func ConvertLogsToProtoLogs(logs []*types.Log) []*protobor.Log { - fmt.Printf(">>>>> ConvertLogsToProtoLogs: %v\n", logs) var protoLogs []*protobor.Log for _, log := range logs { protoLog := &protobor.Log{ @@ -54,7 +50,6 @@ func ConvertLogsToProtoLogs(logs []*types.Log) []*protobor.Log { } func ConvertTopicsToProtoTopics(topics []common.Hash) []*protocommon.H256 { - fmt.Printf(">>>>> ConvertTopicsToProtoTopics: %v\n", topics) var protoTopics []*protocommon.H256 for _, topic := range topics { protoTopics = append(protoTopics, protoutil.ConvertHashToH256(topic)) @@ -64,7 +59,6 @@ func ConvertTopicsToProtoTopics(topics []common.Hash) []*protocommon.H256 { } func ConvertReceiptToProtoReceipt(receipt *types.Receipt) *protobor.Receipt { - fmt.Printf(">>>>> ConvertReceiptToProtoReceipt: %v\n", receipt) return &protobor.Receipt{ Type: uint64(receipt.Type), PostState: receipt.PostState,