mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 13:28:01 -05:00
Add golang.org/x/tools modernize static analyzer and fix violations (#15946)
* Ran gopls modernize to fix everything go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./... * Override rules_go provided dependency for golang.org/x/tools to v0.38.0. To update this, checked out rules_go, then ran `bazel run //go/tools/releaser -- upgrade-dep -mirror=false org_golang_x_tools` and copied the patches. * Fix buildtag violations and ignore buildtag violations in external * Introduce modernize analyzer package. * Add modernize "any" analyzer. * Fix violations of any analyzer * Add modernize "appendclipped" analyzer. * Fix violations of appendclipped * Add modernize "bloop" analyzer. * Add modernize "fmtappendf" analyzer. * Add modernize "forvar" analyzer. * Add modernize "mapsloop" analyzer. * Add modernize "minmax" analyzer. * Fix violations of minmax analyzer * Add modernize "omitzero" analyzer. * Add modernize "rangeint" analyzer. * Fix violations of rangeint. * Add modernize "reflecttypefor" analyzer. * Fix violations of reflecttypefor analyzer. * Add modernize "slicescontains" analyzer. * Add modernize "slicessort" analyzer. * Add modernize "slicesdelete" analyzer. This is disabled by default for now. See https://go.dev/issue/73686. * Add modernize "stringscutprefix" analyzer. * Add modernize "stringsbuilder" analyzer. * Fix violations of stringsbuilder analyzer. * Add modernize "stringsseq" analyzer. * Add modernize "testingcontext" analyzer. * Add modernize "waitgroup" analyzer. * Changelog fragment * gofmt * gazelle * Add modernize "newexpr" analyzer. * Disable newexpr until go1.26 * Add more details in WORKSPACE on how to update the override * @nalepae feedback on min() * gofmt * Fix violations of forvar
This commit is contained in:
@@ -39,7 +39,7 @@ var (
|
||||
)
|
||||
|
||||
// hashKeyFn takes the hex string representation as the key for a headerInfo.
|
||||
func hashKeyFn(obj interface{}) (string, error) {
|
||||
func hashKeyFn(obj any) (string, error) {
|
||||
hInfo, ok := obj.(*types.HeaderInfo)
|
||||
if !ok {
|
||||
return "", ErrNotAHeaderInfo
|
||||
@@ -50,7 +50,7 @@ func hashKeyFn(obj interface{}) (string, error) {
|
||||
|
||||
// heightKeyFn takes the string representation of the block header number as the key
|
||||
// for a headerInfo.
|
||||
func heightKeyFn(obj interface{}) (string, error) {
|
||||
func heightKeyFn(obj any) (string, error) {
|
||||
hInfo, ok := obj.(*types.HeaderInfo)
|
||||
if !ok {
|
||||
return "", ErrNotAHeaderInfo
|
||||
@@ -164,6 +164,6 @@ func trim(queue *cache.FIFO, maxSize uint64) {
|
||||
}
|
||||
|
||||
// popProcessNoopFunc is a no-op function that never returns an error.
|
||||
func popProcessNoopFunc(_ interface{}, _ bool) error {
|
||||
func popProcessNoopFunc(_ any, _ bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ func (s *Service) BlockByTimestamp(ctx context.Context, time uint64) (*types.Hea
|
||||
maxTimeBuffer := searchThreshold * params.BeaconConfig().SecondsPerETH1Block
|
||||
// Terminate if we can't find an acceptable block after
|
||||
// repeated searches.
|
||||
for i := 0; i < repeatedSearches; i++ {
|
||||
for range repeatedSearches {
|
||||
if ctx.Err() != nil {
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ func TestService_BlockNumberByTimestamp(t *testing.T) {
|
||||
params.OverrideBeaconConfig(conf)
|
||||
initialHead, err := testAcc.Backend.Client().HeaderByNumber(ctx, nil)
|
||||
require.NoError(t, err)
|
||||
for i := 0; i < 200; i++ {
|
||||
for range 200 {
|
||||
testAcc.Backend.Commit()
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ func TestService_BlockNumberByTimestampLessTargetTime(t *testing.T) {
|
||||
web3Service = setDefaultMocks(web3Service)
|
||||
web3Service.rpcClient = &mockExecution.RPCClient{Backend: testAcc.Backend}
|
||||
|
||||
for i := 0; i < 200; i++ {
|
||||
for range 200 {
|
||||
testAcc.Backend.Commit()
|
||||
}
|
||||
ctx := t.Context()
|
||||
@@ -296,7 +296,7 @@ func TestService_BlockNumberByTimestampMoreTargetTime(t *testing.T) {
|
||||
web3Service = setDefaultMocks(web3Service)
|
||||
web3Service.rpcClient = &mockExecution.RPCClient{Backend: testAcc.Backend}
|
||||
|
||||
for i := 0; i < 200; i++ {
|
||||
for range 200 {
|
||||
testAcc.Backend.Commit()
|
||||
}
|
||||
ctx := t.Context()
|
||||
|
||||
@@ -475,7 +475,7 @@ func (s *Service) ExecutionBlocksByHashes(ctx context.Context, hashes []common.H
|
||||
newH := h
|
||||
elems = append(elems, gethRPC.BatchElem{
|
||||
Method: BlockByHashMethod,
|
||||
Args: []interface{}{newH, withTxs},
|
||||
Args: []any{newH, withTxs},
|
||||
Result: blk,
|
||||
Error: error(nil),
|
||||
})
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
//go:build go1.18
|
||||
// +build go1.18
|
||||
|
||||
package execution_test
|
||||
|
||||
import (
|
||||
@@ -164,7 +161,7 @@ func FuzzExecutionBlock(f *testing.F) {
|
||||
f.Add(output)
|
||||
|
||||
f.Fuzz(func(t *testing.T, jsonBlob []byte) {
|
||||
gethResp := make(map[string]interface{})
|
||||
gethResp := make(map[string]any)
|
||||
prysmResp := &pb.ExecutionBlock{}
|
||||
gethErr := json.Unmarshal(jsonBlob, &gethResp)
|
||||
prysmErr := json.Unmarshal(jsonBlob, prysmResp)
|
||||
@@ -187,10 +184,10 @@ func FuzzExecutionBlock(f *testing.F) {
|
||||
gethBlob, gethErr := json.Marshal(gethResp)
|
||||
prysmBlob, prysmErr := json.Marshal(prysmResp)
|
||||
assert.Equal(t, gethErr != nil, prysmErr != nil, "geth and prysm unmarshaller return inconsistent errors")
|
||||
newGethResp := make(map[string]interface{})
|
||||
newGethResp := make(map[string]any)
|
||||
newGethErr := json.Unmarshal(prysmBlob, &newGethResp)
|
||||
assert.NoError(t, newGethErr)
|
||||
newGethResp2 := make(map[string]interface{})
|
||||
newGethResp2 := make(map[string]any)
|
||||
newGethErr = json.Unmarshal(gethBlob, &newGethResp2)
|
||||
assert.NoError(t, newGethErr)
|
||||
|
||||
@@ -199,13 +196,13 @@ func FuzzExecutionBlock(f *testing.F) {
|
||||
})
|
||||
}
|
||||
|
||||
func isBogusTransactionHash(blk *pb.ExecutionBlock, jsonMap map[string]interface{}) bool {
|
||||
func isBogusTransactionHash(blk *pb.ExecutionBlock, jsonMap map[string]any) bool {
|
||||
if blk.Transactions == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
for i, tx := range blk.Transactions {
|
||||
jsonTx, ok := jsonMap["transactions"].([]interface{})[i].(map[string]interface{})
|
||||
jsonTx, ok := jsonMap["transactions"].([]any)[i].(map[string]any)
|
||||
if !ok {
|
||||
return true
|
||||
}
|
||||
@@ -244,13 +241,13 @@ func compareHeaders(t *testing.T, jsonBlob []byte) {
|
||||
assert.DeepEqual(t, newGethResp, newGethResp2)
|
||||
}
|
||||
|
||||
func validateBlockConsistency(execBlock *pb.ExecutionBlock, jsonMap map[string]interface{}) error {
|
||||
func validateBlockConsistency(execBlock *pb.ExecutionBlock, jsonMap map[string]any) error {
|
||||
blockVal := reflect.ValueOf(execBlock).Elem()
|
||||
bType := reflect.TypeOf(execBlock).Elem()
|
||||
bType := reflect.TypeFor[pb.ExecutionBlock]()
|
||||
|
||||
fieldnum := bType.NumField()
|
||||
|
||||
for i := 0; i < fieldnum; i++ {
|
||||
for i := range fieldnum {
|
||||
field := bType.Field(i)
|
||||
fName := field.Tag.Get("json")
|
||||
if field.Name == "Header" {
|
||||
@@ -278,12 +275,12 @@ func validateBlockConsistency(execBlock *pb.ExecutionBlock, jsonMap map[string]i
|
||||
return nil
|
||||
}
|
||||
|
||||
func jsonFieldsAreValid(execBlock *pb.ExecutionBlock, jsonMap map[string]interface{}) (bool, error) {
|
||||
bType := reflect.TypeOf(execBlock).Elem()
|
||||
func jsonFieldsAreValid(execBlock *pb.ExecutionBlock, jsonMap map[string]any) (bool, error) {
|
||||
bType := reflect.TypeFor[pb.ExecutionBlock]()
|
||||
|
||||
fieldnum := bType.NumField()
|
||||
|
||||
for i := 0; i < fieldnum; i++ {
|
||||
for i := range fieldnum {
|
||||
field := bType.Field(i)
|
||||
fName := field.Tag.Get("json")
|
||||
if field.Name == "Header" {
|
||||
|
||||
@@ -56,7 +56,7 @@ func (RPCClientBad) BatchCall([]rpc.BatchElem) error {
|
||||
return errors.New("rpc client is not initialized")
|
||||
}
|
||||
|
||||
func (RPCClientBad) CallContext(context.Context, interface{}, string, ...interface{}) error {
|
||||
func (RPCClientBad) CallContext(context.Context, any, string, ...any) error {
|
||||
return ethereum.NotFound
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ func TestClient_HTTP(t *testing.T) {
|
||||
require.Equal(t, true, strings.Contains(
|
||||
jsonRequestString, string(reqArg),
|
||||
))
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": want,
|
||||
@@ -238,7 +238,7 @@ func TestClient_HTTP(t *testing.T) {
|
||||
require.Equal(t, true, strings.Contains(
|
||||
jsonRequestString, string(reqArg),
|
||||
))
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": want,
|
||||
@@ -291,7 +291,7 @@ func TestClient_HTTP(t *testing.T) {
|
||||
require.Equal(t, true, strings.Contains(
|
||||
jsonRequestString, string(reqArg),
|
||||
))
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": want,
|
||||
@@ -346,7 +346,7 @@ func TestClient_HTTP(t *testing.T) {
|
||||
require.Equal(t, true, strings.Contains(
|
||||
jsonRequestString, string(reqArg),
|
||||
))
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": want,
|
||||
@@ -428,7 +428,7 @@ func TestClient_HTTP(t *testing.T) {
|
||||
require.Equal(t, true, strings.Contains(
|
||||
jsonRequestString, string(reqArg),
|
||||
))
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": want,
|
||||
@@ -939,7 +939,7 @@ func TestClient_HTTP(t *testing.T) {
|
||||
defer func() {
|
||||
require.NoError(t, r.Body.Close())
|
||||
}()
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": want,
|
||||
@@ -977,7 +977,7 @@ func TestClient_HTTP(t *testing.T) {
|
||||
require.Equal(t, true, strings.Contains(
|
||||
jsonRequestString, fmt.Sprintf("%#x", arg),
|
||||
))
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": want,
|
||||
@@ -1039,7 +1039,7 @@ func TestReconstructFullBellatrixBlock(t *testing.T) {
|
||||
payload, ok := fix["ExecutionPayload"].(*pb.ExecutionPayload)
|
||||
require.Equal(t, true, ok)
|
||||
|
||||
jsonPayload := make(map[string]interface{})
|
||||
jsonPayload := make(map[string]any)
|
||||
tx := gethtypes.NewTransaction(
|
||||
0,
|
||||
common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"),
|
||||
@@ -1064,10 +1064,10 @@ func TestReconstructFullBellatrixBlock(t *testing.T) {
|
||||
defer func() {
|
||||
require.NoError(t, r.Body.Close())
|
||||
}()
|
||||
respJSON := map[string]interface{}{
|
||||
respJSON := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": []map[string]interface{}{jsonPayload},
|
||||
"result": []map[string]any{jsonPayload},
|
||||
}
|
||||
require.NoError(t, json.NewEncoder(w).Encode(respJSON))
|
||||
}))
|
||||
@@ -1131,7 +1131,7 @@ func TestReconstructFullBellatrixBlockBatch(t *testing.T) {
|
||||
payload, ok := fix["ExecutionPayload"].(*pb.ExecutionPayload)
|
||||
require.Equal(t, true, ok)
|
||||
|
||||
jsonPayload := make(map[string]interface{})
|
||||
jsonPayload := make(map[string]any)
|
||||
tx := gethtypes.NewTransaction(
|
||||
0,
|
||||
common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"),
|
||||
@@ -1168,10 +1168,10 @@ func TestReconstructFullBellatrixBlockBatch(t *testing.T) {
|
||||
require.NoError(t, r.Body.Close())
|
||||
}()
|
||||
|
||||
respJSON := map[string]interface{}{
|
||||
respJSON := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": []map[string]interface{}{jsonPayload},
|
||||
"result": []map[string]any{jsonPayload},
|
||||
}
|
||||
require.NoError(t, json.NewEncoder(w).Encode(respJSON))
|
||||
|
||||
@@ -1206,7 +1206,7 @@ func TestReconstructFullBellatrixBlockBatch(t *testing.T) {
|
||||
payload, ok := fix["ExecutionPayload"].(*pb.ExecutionPayload)
|
||||
require.Equal(t, true, ok)
|
||||
|
||||
jsonPayload := make(map[string]interface{})
|
||||
jsonPayload := make(map[string]any)
|
||||
tx := gethtypes.NewTransaction(
|
||||
0,
|
||||
common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"),
|
||||
@@ -1241,10 +1241,10 @@ func TestReconstructFullBellatrixBlockBatch(t *testing.T) {
|
||||
require.NoError(t, r.Body.Close())
|
||||
}()
|
||||
|
||||
respJSON := map[string]interface{}{
|
||||
respJSON := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": []map[string]interface{}{},
|
||||
"result": []map[string]any{},
|
||||
}
|
||||
require.NoError(t, json.NewEncoder(w).Encode(respJSON))
|
||||
|
||||
@@ -1473,7 +1473,7 @@ func (c *customError) Timeout() bool {
|
||||
|
||||
type dataError struct {
|
||||
code int
|
||||
data interface{}
|
||||
data any
|
||||
}
|
||||
|
||||
func (c *dataError) ErrorCode() int {
|
||||
@@ -1484,7 +1484,7 @@ func (*dataError) Error() string {
|
||||
return "something went wrong"
|
||||
}
|
||||
|
||||
func (c *dataError) ErrorData() interface{} {
|
||||
func (c *dataError) ErrorData() any {
|
||||
return c.data
|
||||
}
|
||||
|
||||
@@ -1576,9 +1576,9 @@ func newTestIPCServer(t *testing.T) *rpc.Server {
|
||||
return server
|
||||
}
|
||||
|
||||
func fixtures() map[string]interface{} {
|
||||
func fixtures() map[string]any {
|
||||
s := fixturesStruct()
|
||||
return map[string]interface{}{
|
||||
return map[string]any{
|
||||
"ExecutionBlock": s.ExecutionBlock,
|
||||
"ExecutionPayloadBody": s.ExecutionPayloadBody,
|
||||
"ExecutionPayload": s.ExecutionPayload,
|
||||
@@ -2173,7 +2173,7 @@ func forkchoiceUpdateSetup(t *testing.T, fcs *pb.ForkchoiceState, att *pb.Payloa
|
||||
require.Equal(t, true, strings.Contains(
|
||||
jsonRequestString, string(payloadAttrsReq),
|
||||
))
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": res,
|
||||
@@ -2212,7 +2212,7 @@ func forkchoiceUpdateSetupV2(t *testing.T, fcs *pb.ForkchoiceState, att *pb.Payl
|
||||
require.Equal(t, true, strings.Contains(
|
||||
jsonRequestString, string(payloadAttrsReq),
|
||||
))
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": res,
|
||||
@@ -2246,7 +2246,7 @@ func newPayloadSetup(t *testing.T, status *pb.PayloadStatus, payload *pb.Executi
|
||||
require.Equal(t, true, strings.Contains(
|
||||
jsonRequestString, string(reqArg),
|
||||
))
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": status,
|
||||
@@ -2280,7 +2280,7 @@ func newPayloadV2Setup(t *testing.T, status *pb.PayloadStatus, payload *pb.Execu
|
||||
require.Equal(t, true, strings.Contains(
|
||||
jsonRequestString, string(reqArg),
|
||||
))
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": status,
|
||||
@@ -2314,7 +2314,7 @@ func newPayloadV3Setup(t *testing.T, status *pb.PayloadStatus, payload *pb.Execu
|
||||
require.Equal(t, true, strings.Contains(
|
||||
jsonRequestString, string(reqArg),
|
||||
))
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": status,
|
||||
@@ -2362,7 +2362,7 @@ func newPayloadV4Setup(t *testing.T, status *pb.PayloadStatus, payload *pb.Execu
|
||||
jsonRequestString, string(jsonRequests),
|
||||
))
|
||||
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": status,
|
||||
@@ -2418,7 +2418,7 @@ func Test_ExchangeCapabilities(t *testing.T) {
|
||||
defer func() {
|
||||
require.NoError(t, r.Body.Close())
|
||||
}()
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": []string{},
|
||||
@@ -2451,7 +2451,7 @@ func Test_ExchangeCapabilities(t *testing.T) {
|
||||
require.NoError(t, r.Body.Close())
|
||||
}()
|
||||
|
||||
resp := map[string]interface{}{
|
||||
resp := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": []string{"A", "B", "C"},
|
||||
@@ -2509,7 +2509,7 @@ func TestReconstructBlobSidecars(t *testing.T) {
|
||||
require.Equal(t, 0, len(verifiedBlobs))
|
||||
})
|
||||
|
||||
client.capabilityCache = &capabilityCache{capabilities: map[string]interface{}{GetBlobsV1: nil}}
|
||||
client.capabilityCache = &capabilityCache{capabilities: map[string]any{GetBlobsV1: nil}}
|
||||
|
||||
t.Run("recovered 6 missing blobs", func(t *testing.T) {
|
||||
srv := createBlobServer(t, 6)
|
||||
@@ -2652,10 +2652,10 @@ func createBlobServer(t *testing.T, numBlobs int, callbackFuncs ...func()) *http
|
||||
|
||||
blobs := make([]pb.BlobAndProofJson, numBlobs)
|
||||
for i := range blobs {
|
||||
blobs[i] = pb.BlobAndProofJson{Blob: []byte(fmt.Sprintf("blob%d", i+1)), KzgProof: []byte(fmt.Sprintf("proof%d", i+1))}
|
||||
blobs[i] = pb.BlobAndProofJson{Blob: fmt.Appendf(nil, "blob%d", i+1), KzgProof: fmt.Appendf(nil, "proof%d", i+1)}
|
||||
}
|
||||
|
||||
respJSON := map[string]interface{}{
|
||||
respJSON := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": blobs,
|
||||
@@ -2689,7 +2689,7 @@ func createBlobServerV2(t *testing.T, numBlobs int, blobMasks []bool) *httptest.
|
||||
}
|
||||
}
|
||||
|
||||
respJSON := map[string]interface{}{
|
||||
respJSON := map[string]any{
|
||||
"jsonrpc": "2.0",
|
||||
"id": 1,
|
||||
"result": blobAndCellProofs,
|
||||
@@ -2705,7 +2705,7 @@ func setupRpcClient(t *testing.T, url string, client *Service) (*rpc.Client, *Se
|
||||
require.NoError(t, err)
|
||||
|
||||
client.rpcClient = rpcClient
|
||||
client.capabilityCache = &capabilityCache{capabilities: map[string]interface{}{GetBlobsV1: nil}}
|
||||
client.capabilityCache = &capabilityCache{capabilities: map[string]any{GetBlobsV1: nil}}
|
||||
client.blobVerifier = testNewBlobVerifier()
|
||||
|
||||
return rpcClient, client
|
||||
@@ -2713,7 +2713,7 @@ func setupRpcClient(t *testing.T, url string, client *Service) (*rpc.Client, *Se
|
||||
|
||||
func setupRpcClientV2(t *testing.T, url string, client *Service) (*rpc.Client, *Service) {
|
||||
rpcClient, client := setupRpcClient(t, url, client)
|
||||
client.capabilityCache = &capabilityCache{capabilities: map[string]interface{}{GetBlobsV2: nil}}
|
||||
client.capabilityCache = &capabilityCache{capabilities: map[string]any{GetBlobsV2: nil}}
|
||||
return rpcClient, client
|
||||
}
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@ func TestProcessETH2GenesisLog_8DuplicatePubkeys(t *testing.T) {
|
||||
// 64 Validators are used as size required for beacon-chain to start. This number
|
||||
// is defined in the deposit contract as the number required for the testnet. The actual number
|
||||
// is 2**14
|
||||
for i := 0; i < depositsReqForChainStart; i++ {
|
||||
for range depositsReqForChainStart {
|
||||
testAcc.TxOpts.Value = mock.Amount32Eth()
|
||||
_, err = testAcc.Contract.Deposit(testAcc.TxOpts, data.PublicKey, data.WithdrawalCredentials, data.Signature, depositRoots[0])
|
||||
require.NoError(t, err, "Could not deposit to deposit contract")
|
||||
@@ -325,7 +325,7 @@ func TestProcessETH2GenesisLog(t *testing.T) {
|
||||
// 64 Validators are used as size required for beacon-chain to start. This number
|
||||
// is defined in the deposit contract as the number required for the testnet. The actual number
|
||||
// is 2**14
|
||||
for i := 0; i < depositsReqForChainStart; i++ {
|
||||
for i := range depositsReqForChainStart {
|
||||
data := deposits[i].Data
|
||||
testAcc.TxOpts.Value = mock.Amount32Eth()
|
||||
testAcc.TxOpts.GasLimit = 1000000
|
||||
@@ -429,7 +429,7 @@ func TestProcessETH2GenesisLog_CorrectNumOfDeposits(t *testing.T) {
|
||||
// 64 Validators are used as size required for beacon-chain to start. This number
|
||||
// is defined in the deposit contract as the number required for the testnet. The actual number
|
||||
// is 2**14
|
||||
for i := 0; i < totalNumOfDeposits; i++ {
|
||||
for i := range totalNumOfDeposits {
|
||||
data := deposits[i].Data
|
||||
testAcc.TxOpts.Value = mock.Amount32Eth()
|
||||
testAcc.TxOpts.GasLimit = 1000000
|
||||
@@ -530,7 +530,7 @@ func TestProcessLogs_DepositRequestsStarted(t *testing.T) {
|
||||
// 64 Validators are used as size required for beacon-chain to start. This number
|
||||
// is defined in the deposit contract as the number required for the testnet. The actual number
|
||||
// is 2**14
|
||||
for i := 0; i < totalNumOfDeposits; i++ {
|
||||
for i := range totalNumOfDeposits {
|
||||
data := deposits[i].Data
|
||||
testAcc.TxOpts.Value = mock.Amount32Eth()
|
||||
testAcc.TxOpts.GasLimit = 1000000
|
||||
@@ -616,7 +616,7 @@ func TestProcessETH2GenesisLog_LargePeriodOfNoLogs(t *testing.T) {
|
||||
// 64 Validators are used as size required for beacon-chain to start. This number
|
||||
// is defined in the deposit contract as the number required for the testnet. The actual number
|
||||
// is 2**14
|
||||
for i := 0; i < totalNumOfDeposits; i++ {
|
||||
for i := range totalNumOfDeposits {
|
||||
data := deposits[i].Data
|
||||
testAcc.TxOpts.Value = mock.Amount32Eth()
|
||||
testAcc.TxOpts.GasLimit = 1000000
|
||||
@@ -629,7 +629,7 @@ func TestProcessETH2GenesisLog_LargePeriodOfNoLogs(t *testing.T) {
|
||||
}
|
||||
}
|
||||
// Forward the chain to 'mine' blocks without logs
|
||||
for i := uint64(0); i < 1500; i++ {
|
||||
for range uint64(1500) {
|
||||
testAcc.Backend.Commit()
|
||||
}
|
||||
genesisBlock, err := testAcc.Backend.Client().BlockByNumber(t.Context(), nil)
|
||||
|
||||
@@ -15,9 +15,9 @@ import (
|
||||
var mockHandlerDefaultName = "__default__"
|
||||
|
||||
type jsonError struct {
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
Code int `json:"code"`
|
||||
Message string `json:"message"`
|
||||
Data any `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
type jsonrpcMessage struct {
|
||||
@@ -154,12 +154,12 @@ func TestParseRequest(t *testing.T) {
|
||||
})
|
||||
|
||||
result := make([]*pb.ExecutionPayloadBody, 0)
|
||||
var args []interface{}
|
||||
var args []any
|
||||
if len(c.byteArgs) > 0 {
|
||||
args = []interface{}{c.byteArgs}
|
||||
args = []any{c.byteArgs}
|
||||
}
|
||||
if len(c.hexArgs) > 0 {
|
||||
args = make([]interface{}, len(c.hexArgs))
|
||||
args = make([]any, len(c.hexArgs))
|
||||
for i := range c.hexArgs {
|
||||
args[i] = c.hexArgs[i]
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ func computeRanges(hbns []hashBlockNumber) []byRangeReq {
|
||||
ranges := make([]byRangeReq, 0)
|
||||
start := hbns[0].n
|
||||
count := uint64(0)
|
||||
for i := 0; i < len(hbns); i++ {
|
||||
for i := range hbns {
|
||||
if hbns[i].n == start+count {
|
||||
count++
|
||||
continue
|
||||
|
||||
@@ -103,7 +103,7 @@ type Chain interface {
|
||||
type RPCClient interface {
|
||||
Close()
|
||||
BatchCall(b []gethRPC.BatchElem) error
|
||||
CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error
|
||||
CallContext(ctx context.Context, result any, method string, args ...any) error
|
||||
}
|
||||
|
||||
type RPCClientEmpty struct {
|
||||
@@ -114,7 +114,7 @@ func (RPCClientEmpty) BatchCall([]gethRPC.BatchElem) error {
|
||||
return errors.New("rpc client is not initialized")
|
||||
}
|
||||
|
||||
func (RPCClientEmpty) CallContext(context.Context, interface{}, string, ...interface{}) error {
|
||||
func (RPCClientEmpty) CallContext(context.Context, any, string, ...any) error {
|
||||
return errors.New("rpc client is not initialized")
|
||||
}
|
||||
|
||||
@@ -426,7 +426,7 @@ func (s *Service) batchRequestHeaders(startBlock, endBlock uint64) ([]*types.Hea
|
||||
header := &types.HeaderInfo{}
|
||||
elems = append(elems, gethRPC.BatchElem{
|
||||
Method: "eth_getBlockByNumber",
|
||||
Args: []interface{}{hexutil.EncodeBig(new(big.Int).SetUint64(i)), false},
|
||||
Args: []any{hexutil.EncodeBig(new(big.Int).SetUint64(i)), false},
|
||||
Result: header,
|
||||
Error: error(nil),
|
||||
})
|
||||
@@ -922,7 +922,7 @@ func newBlobVerifierFromInitializer(ini *verification.Initializer) verification.
|
||||
}
|
||||
|
||||
type capabilityCache struct {
|
||||
capabilities map[string]interface{}
|
||||
capabilities map[string]any
|
||||
capabilitiesLock sync.RWMutex
|
||||
}
|
||||
|
||||
@@ -931,7 +931,7 @@ func (c *capabilityCache) save(cs []string) {
|
||||
defer c.capabilitiesLock.Unlock()
|
||||
|
||||
if c.capabilities == nil {
|
||||
c.capabilities = make(map[string]interface{})
|
||||
c.capabilities = make(map[string]any)
|
||||
}
|
||||
|
||||
for _, capability := range cs {
|
||||
|
||||
@@ -61,7 +61,7 @@ func (g *goodLogger) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQ
|
||||
func (g *goodLogger) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]gethTypes.Log, error) {
|
||||
if g.backend == nil {
|
||||
logs := make([]gethTypes.Log, 3)
|
||||
for i := 0; i < len(logs); i++ {
|
||||
for i := range logs {
|
||||
logs[i].Address = common.Address{}
|
||||
logs[i].Topics = make([]common.Hash, 5)
|
||||
logs[i].Topics[0] = common.Hash{'a'}
|
||||
@@ -246,7 +246,7 @@ func TestFollowBlock_OK(t *testing.T) {
|
||||
numToForward := uint64(2)
|
||||
expectedHeight := numToForward + baseHeight
|
||||
// forward 2 blocks
|
||||
for i := uint64(0); i < numToForward; i++ {
|
||||
for range numToForward {
|
||||
testAcc.Backend.Commit()
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ func TestLogTillGenesis_OK(t *testing.T) {
|
||||
|
||||
web3Service.rpcClient = &mockExecution.RPCClient{Backend: testAcc.Backend}
|
||||
web3Service.httpLogger = testAcc.Backend.Client()
|
||||
for i := 0; i < 30; i++ {
|
||||
for range 30 {
|
||||
testAcc.Backend.Commit()
|
||||
}
|
||||
web3Service.latestEth1Data = ðpb.LatestETH1Data{LastRequestedBlock: 0}
|
||||
@@ -498,7 +498,7 @@ func TestNewService_EarliestVotingBlock(t *testing.T) {
|
||||
|
||||
numToForward := 1500
|
||||
// forward 1500 blocks
|
||||
for i := 0; i < numToForward; i++ {
|
||||
for range numToForward {
|
||||
testAcc.Backend.Commit()
|
||||
}
|
||||
currHeader, err := testAcc.Backend.Client().HeaderByNumber(t.Context(), nil)
|
||||
@@ -695,7 +695,7 @@ func TestService_ValidateDepositContainers(t *testing.T) {
|
||||
name: "ordered containers",
|
||||
ctrsFunc: func() []*ethpb.DepositContainer {
|
||||
ctrs := make([]*ethpb.DepositContainer, 0)
|
||||
for i := 0; i < 10; i++ {
|
||||
for i := range 10 {
|
||||
ctrs = append(ctrs, ðpb.DepositContainer{Index: int64(i), Eth1BlockHeight: uint64(i + 10)})
|
||||
}
|
||||
return ctrs
|
||||
@@ -717,7 +717,7 @@ func TestService_ValidateDepositContainers(t *testing.T) {
|
||||
name: "skipped containers",
|
||||
ctrsFunc: func() []*ethpb.DepositContainer {
|
||||
ctrs := make([]*ethpb.DepositContainer, 0)
|
||||
for i := 0; i < 10; i++ {
|
||||
for i := range 10 {
|
||||
if i == 5 || i == 7 {
|
||||
continue
|
||||
}
|
||||
@@ -833,7 +833,7 @@ func (s *slowRPCClient) BatchCall(b []rpc.BatchElem) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *slowRPCClient) CallContext(_ context.Context, _ interface{}, _ string, _ ...interface{}) error {
|
||||
func (s *slowRPCClient) CallContext(_ context.Context, _ any, _ string, _ ...any) error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
@@ -869,7 +869,7 @@ func TestService_migrateOldDepositTree(t *testing.T) {
|
||||
dt, err := trie.NewTrie(32)
|
||||
require.NoError(t, err)
|
||||
|
||||
for i := 0; i < totalDeposits; i++ {
|
||||
for i := range totalDeposits {
|
||||
err := dt.Insert(input[:], i)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ type RPCClient struct {
|
||||
|
||||
func (*RPCClient) Close() {}
|
||||
|
||||
func (r *RPCClient) CallContext(ctx context.Context, obj interface{}, methodName string, args ...interface{}) error {
|
||||
func (r *RPCClient) CallContext(ctx context.Context, obj any, methodName string, args ...any) error {
|
||||
if r.BlockNumMap != nil && methodName == "eth_getBlockByNumber" {
|
||||
val, ok := args[0].(string)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user