[RPC] Replace go-ethereum/rpc module with harmony/eth/rpc (#3983)

* [rpc] fix some test cases

* fix test cases

* [rpc] use harmony/eth/rpc for customized changes

* [RPC] replace one more use of RPC at accounts module

* [RPC] fix test cases
pull/3985/head
Jacky Wang 3 years ago committed by GitHub
parent 5ed3a539c0
commit af5eaa8d0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      accounts/external/backend.go
  2. 2
      api/service/manager_test.go
  3. 3
      eth/rpc/json.go
  4. 4
      eth/rpc/types.go
  5. 12
      eth/rpc/types_test.go
  6. 2
      hmy/blockchain.go
  7. 2
      hmy/gasprice.go
  8. 2
      hmy/staking.go
  9. 2
      hmy/tracer.go
  10. 2
      hmy/transaction.go
  11. 2
      node/api.go
  12. 2
      rosetta/services/account.go
  13. 8
      rosetta/services/block.go
  14. 2
      rosetta/services/call_service.go
  15. 5
      rosetta/services/construction_check.go
  16. 2
      rosetta/services/network.go
  17. 2
      rpc/blockchain.go
  18. 2
      rpc/contract.go
  19. 2
      rpc/eth/rpc.go
  20. 2
      rpc/filters/api.go
  21. 2
      rpc/filters/filter.go
  22. 2
      rpc/filters/filter_criteria.go
  23. 2
      rpc/filters/filter_system.go
  24. 2
      rpc/harmony.go
  25. 2
      rpc/net.go
  26. 2
      rpc/pool.go
  27. 2
      rpc/private_debug.go
  28. 2
      rpc/public_debug.go
  29. 2
      rpc/rpc.go
  30. 5
      rpc/staking.go
  31. 2
      rpc/tracer.go
  32. 2
      rpc/tracerParity.go
  33. 6
      rpc/transaction.go
  34. 2
      rpc/types.go
  35. 2
      rpc/v1/legacy.go
  36. 2
      rpc/v2/legacy.go
  37. 2
      rpc/web3.go

@ -26,10 +26,10 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/signer/core"
"github.com/harmony-one/harmony/accounts"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/eth/rpc"
)
// ExternalBackend is a struct for external backend

@ -6,7 +6,7 @@ import (
"strings"
"testing"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
)
func TestManager_StartServices(t *testing.T) {

@ -20,7 +20,6 @@ import (
"bytes"
"context"
"encoding/json"
std_json "encoding/json"
"errors"
"fmt"
"io"
@ -240,7 +239,7 @@ func parseMessage(raw json.RawMessage) ([]*jsonrpcMessage, bool) {
json.Unmarshal(raw, &msgs[0])
return msgs, false
}
dec := std_json.NewDecoder(bytes.NewReader(raw))
dec := json.NewDecoder(bytes.NewReader(raw))
dec.Token() // skip '['
var msgs []*jsonrpcMessage
for dec.More() {

@ -21,7 +21,6 @@ import (
"encoding/json"
"fmt"
"math"
"strconv"
"strings"
"github.com/ethereum/go-ethereum/common"
@ -93,8 +92,7 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error {
return nil
}
input = strings.TrimPrefix(strings.ToLower(input), "0x")
blckNum, err := strconv.ParseInt(input, 10, 64)
blckNum, err := hexutil.DecodeUint64(input)
if err != nil {
return err
}

@ -33,13 +33,13 @@ func TestBlockNumberJSONUnmarshal(t *testing.T) {
0: {`"0x"`, true, BlockNumber(0)},
1: {`"0x0"`, false, BlockNumber(0)},
2: {`"0X1"`, false, BlockNumber(1)},
3: {`"0x00"`, false, BlockNumber(0)},
4: {`"0x01"`, false, BlockNumber(1)},
3: {`"0x00"`, true, BlockNumber(0)},
4: {`"0x01"`, true, BlockNumber(0)},
5: {`"0x1"`, false, BlockNumber(1)},
6: {`"0x12"`, false, BlockNumber(12)},
7: {`"0x7fffffffffffffff"`, true, BlockNumber(0)},
8: {`"0x8000000000000000"`, false, BlockNumber(8000000000000000)},
9: {"0", false, BlockNumber(0)},
6: {`"0x12"`, false, BlockNumber(18)},
7: {`"0x7fffffffffffffff"`, false, BlockNumber(math.MaxInt64)},
8: {`"0x8000000000000000"`, true, BlockNumber(0)},
9: {"0", true, BlockNumber(0)},
10: {`"ff"`, true, BlockNumber(0)},
11: {`"pending"`, false, PendingBlockNumber},
12: {`"latest"`, false, LatestBlockNumber},

@ -8,7 +8,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/bloombits"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/block"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/rawdb"
@ -16,6 +15,7 @@ import (
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/crypto/bls"
internal_bls "github.com/harmony-one/harmony/crypto/bls"
"github.com/harmony-one/harmony/eth/rpc"
internal_common "github.com/harmony-one/harmony/internal/common"
"github.com/harmony-one/harmony/internal/params"
"github.com/harmony-one/harmony/internal/utils"

@ -23,8 +23,8 @@ import (
"sort"
"sync"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/block"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/internal/utils"
"github.com/ethereum/go-ethereum/common"

@ -7,11 +7,11 @@ import (
"sync"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/block"
"github.com/harmony-one/harmony/consensus/quorum"
"github.com/harmony-one/harmony/core/rawdb"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/internal/chain"
internalCommon "github.com/harmony-one/harmony/internal/common"
"github.com/harmony-one/harmony/numeric"

@ -30,12 +30,12 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/trie"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/state"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/core/vm"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy/tracers"
"github.com/harmony-one/harmony/internal/utils"
)

@ -4,10 +4,10 @@ import (
"context"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/rawdb"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/eth/rpc"
)
// SendTx ...

@ -1,9 +1,9 @@
package node
import (
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/consensus/quorum"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
"github.com/harmony-one/harmony/rosetta"
hmy_rpc "github.com/harmony-one/harmony/rpc"

@ -8,9 +8,9 @@ import (
"github.com/coinbase/rosetta-sdk-go/server"
"github.com/coinbase/rosetta-sdk-go/types"
ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rpc"
hmyTypes "github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
internalCommon "github.com/harmony-one/harmony/internal/common"
"github.com/harmony-one/harmony/rosetta/common"

@ -14,9 +14,9 @@ import (
"github.com/harmony-one/harmony/core/rawdb"
hmytypes "github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/core/vm"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
"github.com/harmony-one/harmony/rosetta/common"
"github.com/harmony-one/harmony/rpc"
stakingTypes "github.com/harmony-one/harmony/staking/types"
)
@ -67,7 +67,7 @@ func (s *BlockAPI) Block(
if blk.NumberU64() == 0 {
prevBlockID = currBlockID
} else {
prevBlock, err := s.hmy.BlockByNumber(ctx, rpc.BlockNumber(blk.Number().Int64()-1).EthBlockNumber())
prevBlock, err := s.hmy.BlockByNumber(ctx, rpc.BlockNumber(blk.Number().Int64()-1))
if err != nil {
return nil, common.NewError(common.CatchAllError, map[string]interface{}{
"message": err.Error(),
@ -157,7 +157,7 @@ func (s *BlockAPI) BlockTransaction(
}
return response, rosettaError2
}
state, _, err := s.hmy.StateAndHeaderByNumber(ctx, rpc.BlockNumber(request.BlockIdentifier.Index).EthBlockNumber())
state, _, err := s.hmy.StateAndHeaderByNumber(ctx, rpc.BlockNumber(request.BlockIdentifier.Index))
if state == nil || err != nil {
return nil, common.NewError(common.BlockNotFoundError, map[string]interface{}{
"message": fmt.Sprintf("block state not found for block %v", request.BlockIdentifier.Index),
@ -320,7 +320,7 @@ func getBlock(
requestBlockHash := ethcommon.HexToHash(*blockID.Hash)
blk, err = hmy.GetBlock(ctx, requestBlockHash)
} else if blockID.Index != nil {
blk, err = hmy.BlockByNumber(ctx, rpc.BlockNumber(*blockID.Index).EthBlockNumber())
blk, err = hmy.BlockByNumber(ctx, rpc.BlockNumber(*blockID.Index))
} else {
return nil, &common.BlockNotFoundError
}

@ -6,7 +6,7 @@ import (
"github.com/coinbase/rosetta-sdk-go/server"
"github.com/coinbase/rosetta-sdk-go/types"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
internal_common "github.com/harmony-one/harmony/internal/common"
"github.com/harmony-one/harmony/rosetta/common"

@ -6,14 +6,13 @@ import (
"fmt"
"math/big"
"github.com/harmony-one/harmony/core"
"github.com/coinbase/rosetta-sdk-go/types"
ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
ethRpc "github.com/ethereum/go-ethereum/rpc"
"github.com/pkg/errors"
"github.com/harmony-one/harmony/core"
ethRpc "github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/internal/params"
"github.com/harmony-one/harmony/rosetta/common"
"github.com/harmony-one/harmony/rpc"

@ -9,10 +9,10 @@ import (
"github.com/coinbase/rosetta-sdk-go/server"
"github.com/coinbase/rosetta-sdk-go/types"
"github.com/ethereum/go-ethereum/rpc"
"github.com/libp2p/go-libp2p-core/peer"
"github.com/harmony-one/harmony/block"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
"github.com/harmony-one/harmony/rosetta/common"

@ -13,7 +13,6 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
lru "github.com/hashicorp/golang-lru"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
@ -21,6 +20,7 @@ import (
"github.com/harmony-one/harmony/core/types"
internal_bls "github.com/harmony-one/harmony/crypto/bls"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
"github.com/harmony-one/harmony/internal/chain"
internal_common "github.com/harmony-one/harmony/internal/common"

@ -12,9 +12,9 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/common/denominations"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
hmyCommon "github.com/harmony-one/harmony/internal/common"
"github.com/harmony-one/harmony/internal/utils"

@ -4,7 +4,7 @@ import (
"context"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
internal_common "github.com/harmony-one/harmony/internal/common"
)

@ -8,9 +8,9 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/block"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/eth/rpc"
hmy_rpc "github.com/harmony-one/harmony/rpc"
)

@ -26,10 +26,10 @@ import (
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/block"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/eth/rpc"
)
// Backend provides the APIs needed for filter

@ -9,7 +9,7 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
)
// FilterCriteria represents a request to create a new filter.

@ -28,11 +28,11 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/block"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/rawdb"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/eth/rpc"
)
// Type determines the kind of filter and is used to put the filter in to

@ -5,7 +5,7 @@ import (
"math/big"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
)

@ -5,7 +5,7 @@ import (
"fmt"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
"github.com/harmony-one/harmony/internal/utils"
"github.com/harmony-one/harmony/p2p"

@ -13,9 +13,9 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
common2 "github.com/harmony-one/harmony/internal/common"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"

@ -3,7 +3,7 @@ package rpc
import (
"context"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
)

@ -4,7 +4,7 @@ import (
"context"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
"github.com/harmony-one/harmony/internal/utils"
)

@ -6,7 +6,7 @@ import (
"strings"
"time"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
"github.com/harmony-one/harmony/internal/utils"

@ -5,14 +5,13 @@ import (
"math/big"
"reflect"
lru "github.com/hashicorp/golang-lru"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/time/rate"
lru "github.com/hashicorp/golang-lru"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
internal_common "github.com/harmony-one/harmony/internal/common"
"github.com/harmony-one/harmony/shard"

@ -25,10 +25,10 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/rawdb"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
)

@ -6,7 +6,7 @@ import (
"errors"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
)

@ -6,16 +6,16 @@ import (
"math/big"
"strings"
"github.com/pkg/errors"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
"github.com/pkg/errors"
"github.com/harmony-one/harmony/accounts/abi"
"github.com/harmony-one/harmony/core"
"github.com/harmony-one/harmony/core/rawdb"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/core/vm"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
internal_common "github.com/harmony-one/harmony/internal/common"
"github.com/harmony-one/harmony/internal/params"

@ -17,9 +17,9 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/block"
"github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/internal/utils"
"github.com/harmony-one/harmony/numeric"
"github.com/harmony-one/harmony/shard"

@ -4,7 +4,7 @@ import (
"context"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
internal_common "github.com/harmony-one/harmony/internal/common"
)

@ -4,7 +4,7 @@ import (
"context"
"math/big"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
"github.com/harmony-one/harmony/hmy"
internal_common "github.com/harmony-one/harmony/internal/common"
)

@ -3,7 +3,7 @@ package rpc
import (
"context"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/eth/rpc"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
)

Loading…
Cancel
Save