Merge feature/merge-v1.10.18-attempt-two

This commit is contained in:
philip-morlier
2022-05-25 13:07:38 -07:00
438 changed files with 129587 additions and 152641 deletions
-10
View File
@@ -54,7 +54,6 @@ var (
_ Error = new(invalidRequestError)
_ Error = new(invalidMessageError)
_ Error = new(invalidParamsError)
_ Error = new(CustomError)
)
const defaultErrorCode = -32000
@@ -102,12 +101,3 @@ type invalidParamsError struct{ message string }
func (e *invalidParamsError) ErrorCode() int { return -32602 }
func (e *invalidParamsError) Error() string { return e.message }
type CustomError struct {
Code int
ValidationError string
}
func (e *CustomError) ErrorCode() int { return e.Code }
func (e *CustomError) Error() string { return e.ValidationError }
+1 -1
View File
@@ -345,7 +345,7 @@ func (h *handler) handleCall(cp *callProc, msg *jsonrpcMessage) *jsonrpcMessage
if callb != h.unsubscribeCb {
rpcRequestGauge.Inc(1)
if answer.Error != nil {
failedReqeustGauge.Inc(1)
failedRequestGauge.Inc(1)
} else {
successfulRequestGauge.Inc(1)
}
+2 -3
View File
@@ -23,7 +23,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"mime"
"net/http"
"net/url"
@@ -176,12 +175,12 @@ func (hc *httpConn) doRequest(ctx context.Context, msg interface{}) (io.ReadClos
if err != nil {
return nil, err
}
req, err := http.NewRequestWithContext(ctx, "POST", hc.url, ioutil.NopCloser(bytes.NewReader(body)))
req, err := http.NewRequestWithContext(ctx, "POST", hc.url, io.NopCloser(bytes.NewReader(body)))
if err != nil {
return nil, err
}
req.ContentLength = int64(len(body))
req.GetBody = func() (io.ReadCloser, error) { return ioutil.NopCloser(bytes.NewReader(body)), nil }
req.GetBody = func() (io.ReadCloser, error) { return io.NopCloser(bytes.NewReader(body)), nil }
// set headers
hc.mu.Lock()
+1 -1
View File
@@ -25,7 +25,7 @@ import (
var (
rpcRequestGauge = metrics.NewRegisteredGauge("rpc/requests", nil)
successfulRequestGauge = metrics.NewRegisteredGauge("rpc/success", nil)
failedReqeustGauge = metrics.NewRegisteredGauge("rpc/failure", nil)
failedRequestGauge = metrics.NewRegisteredGauge("rpc/failure", nil)
rpcServingTimer = metrics.NewRegisteredTimer("rpc/duration/all", nil)
)
+3 -3
View File
@@ -20,8 +20,8 @@ import (
"bufio"
"bytes"
"io"
"io/ioutil"
"net"
"os"
"path/filepath"
"strings"
"testing"
@@ -52,7 +52,7 @@ func TestServerRegisterName(t *testing.T) {
}
func TestServer(t *testing.T) {
files, err := ioutil.ReadDir("testdata")
files, err := os.ReadDir("testdata")
if err != nil {
t.Fatal("where'd my testdata go?")
}
@@ -70,7 +70,7 @@ func TestServer(t *testing.T) {
func runTestScript(t *testing.T, file string) {
server := newTestServer()
content, err := ioutil.ReadFile(file)
content, err := os.ReadFile(file)
if err != nil {
t.Fatal(err)
}
+13 -3
View File
@@ -61,9 +61,10 @@ type jsonWriter interface {
type BlockNumber int64
const (
PendingBlockNumber = BlockNumber(-2)
LatestBlockNumber = BlockNumber(-1)
EarliestBlockNumber = BlockNumber(0)
FinalizedBlockNumber = BlockNumber(-3)
PendingBlockNumber = BlockNumber(-2)
LatestBlockNumber = BlockNumber(-1)
EarliestBlockNumber = BlockNumber(0)
)
// UnmarshalJSON parses the given JSON fragment into a BlockNumber. It supports:
@@ -88,6 +89,9 @@ func (bn *BlockNumber) UnmarshalJSON(data []byte) error {
case "pending":
*bn = PendingBlockNumber
return nil
case "finalized":
*bn = FinalizedBlockNumber
return nil
}
blckNum, err := hexutil.DecodeUint64(input)
@@ -112,6 +116,8 @@ func (bn BlockNumber) MarshalText() ([]byte, error) {
return []byte("latest"), nil
case PendingBlockNumber:
return []byte("pending"), nil
case FinalizedBlockNumber:
return []byte("finalized"), nil
default:
return hexutil.Uint64(bn).MarshalText()
}
@@ -158,6 +164,10 @@ func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error {
bn := PendingBlockNumber
bnh.BlockNumber = &bn
return nil
case "finalized":
bn := FinalizedBlockNumber
bnh.BlockNumber = &bn
return nil
default:
if len(input) == 66 {
hash := common.Hash{}