go1.19 gofmt (#4988)

This commit is contained in:
Alex Sharov 2022-08-10 19:04:13 +07:00 committed by GitHub
parent 0beb295745
commit 351cd49c21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
163 changed files with 741 additions and 639 deletions

View File

@ -60,7 +60,7 @@ jobs:
if: runner.os == 'Linux'
uses: golangci/golangci-lint-action@v3
with:
version: v1.47
version: v1.48
- name: Test
run: make test

View File

@ -155,7 +155,7 @@ lintci:
## lintci-deps: (re)installs golangci-lint to build/bin/golangci-lint
lintci-deps:
rm -f ./build/bin/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.47.2
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.48.0
## clean: cleans the go cache, build dir, libmdbx db dir
clean:

View File

@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//
//nolint:scopelint
package abi
@ -165,6 +166,7 @@ func TestInvalidABI(t *testing.T) {
// TestConstructor tests a constructor function.
// The test is based on the following contract:
//
// contract TestConstructor {
// constructor(uint256 a, uint256 b) public{}
// }
@ -710,6 +712,7 @@ func TestBareEvents(t *testing.T) {
}
// TestUnpackEvent is based on this contract:
//
// contract T {
// event received(address sender, uint amount, bytes memo);
// event receivedAddr(address sender);
@ -718,7 +721,9 @@ func TestBareEvents(t *testing.T) {
// receivedAddr(msg.sender);
// }
// }
//
// When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt:
//
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
func TestUnpackEvent(t *testing.T) {
const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]`
@ -1064,6 +1069,7 @@ func TestDoubleDuplicateMethodNames(t *testing.T) {
// TestDoubleDuplicateEventNames checks that if send0 already exists, there won't be a name
// conflict and that the second send event will be renamed send1.
// The test runs the abi of the following contract.
//
// contract DuplicateEvent {
// event send(uint256 a);
// event send0();
@ -1092,6 +1098,7 @@ func TestDoubleDuplicateEventNames(t *testing.T) {
// TestUnnamedEventParam checks that an event with unnamed parameters is
// correctly handled.
// The test runs the abi of the following contract.
//
// contract TestEvent {
// event send(uint256, uint256);
// }

View File

@ -954,6 +954,7 @@ func TestSimulatedBackend_CodeAt(t *testing.T) {
}
// When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt:
//
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
func TestSimulatedBackend_PendingAndCallContract(t *testing.T) {
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)

View File

@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//
//nolint:scopelint
package abi

View File

@ -28,11 +28,13 @@ import (
// given type
// e.g. turn
// var fields []reflect.StructField
//
// fields = append(fields, reflect.StructField{
// Name: "X",
// Type: reflect.TypeOf(new(big.Int)),
// Tag: reflect.StructTag("json:\"" + "x" + "\""),
// }
//
// into
// type TupleT struct { X *big.Int }
func ConvertType(in interface{}, proto interface{}) interface{} {
@ -178,10 +180,14 @@ func setStruct(dst, src reflect.Value) error {
// mapArgNamesToStructFields maps a slice of argument names to struct fields.
// first round: for each Exportable field that contains a `abi:""` tag
//
// and this field name exists in the given argument name list, pair them together.
//
// second round: for each argument name that has not been already linked,
//
// find what variable is expected to be mapped into, if it exists and has not been
// used, pair them.
//
// Note this function assumes the given value is a struct value.
func mapArgNamesToStructFields(argNames []string, value reflect.Value) (map[string]string, error) {
typ := value.Type()

View File

@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//
//nolint:scopelint
package abi

View File

@ -21,10 +21,11 @@ import (
"crypto/ecdsa"
"flag"
"fmt"
"github.com/ledgerwatch/erigon-lib/common"
"net"
"os"
"github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon/cmd/utils"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/p2p/discover"

View File

@ -2,6 +2,7 @@ package commands
import (
"fmt"
"github.com/spf13/cobra"
)

View File

@ -2,9 +2,10 @@ package commands
import (
"fmt"
"sync"
"github.com/ledgerwatch/erigon/cmd/devnettest/services"
"github.com/spf13/cobra"
"sync"
)
var (

View File

@ -2,9 +2,10 @@ package commands
import (
"fmt"
"github.com/ledgerwatch/erigon/cmd/devnettest/services"
"strings"
"github.com/ledgerwatch/erigon/cmd/devnettest/services"
"github.com/ledgerwatch/erigon/cmd/devnettest/requests"
"github.com/ledgerwatch/erigon/common"
"github.com/spf13/cobra"

View File

@ -2,6 +2,7 @@ package commands
import (
"fmt"
"github.com/ledgerwatch/erigon/cmd/devnettest/requests"
"github.com/spf13/cobra"
)

View File

@ -4,13 +4,14 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/ledgerwatch/erigon/cmd/devnettest/utils"
"io"
"net/http"
"strconv"
"strings"
"time"
"github.com/ledgerwatch/erigon/cmd/devnettest/utils"
"github.com/ledgerwatch/erigon/cmd/rpctest/rpctest"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/core/types"

View File

@ -2,6 +2,7 @@ package services
import (
"fmt"
"github.com/ledgerwatch/erigon/cmd/devnettest/requests"
"github.com/ledgerwatch/erigon/common"
)

View File

@ -3,11 +3,12 @@ package services
import (
"context"
"fmt"
"github.com/ledgerwatch/erigon/cmd/devnettest/utils"
"math/big"
"os/exec"
"time"
"github.com/ledgerwatch/erigon/cmd/devnettest/utils"
"github.com/holiman/uint256"
"github.com/ledgerwatch/erigon/accounts/abi/bind"
"github.com/ledgerwatch/erigon/accounts/abi/bind/backends"

View File

@ -3,6 +3,7 @@ package services
import (
"context"
"fmt"
"github.com/ledgerwatch/erigon/cmd/devnettest/utils"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/rpc"

View File

@ -380,7 +380,7 @@ func getTransaction(txJson commands.RPCTransaction) (types.Transaction, error) {
switch txJson.Type {
case types.LegacyTxType, types.AccessListTxType:
var toAddr common.Address = common.Address{}
var toAddr = common.Address{}
if txJson.To != nil {
toAddr = *txJson.To
}
@ -448,6 +448,7 @@ func getTransaction(txJson commands.RPCTransaction) (types.Transaction, error) {
// The transactions can have two forms, either
// 1. unsigned or
// 2. signed
//
// For (1), r, s, v, need so be zero, and the `secretKey` needs to be set.
// If so, we sign it here and now, with the given `secretKey`
// If the condition above is not met, then it's considered a signed transaction.

View File

@ -19,10 +19,11 @@ package main
import (
"fmt"
"github.com/ledgerwatch/log/v3"
"math/big"
"os"
"github.com/ledgerwatch/log/v3"
"github.com/ledgerwatch/erigon/cmd/evm/internal/t8ntool"
"github.com/ledgerwatch/erigon/cmd/utils"
"github.com/ledgerwatch/erigon/internal/flags"

View File

@ -5,7 +5,6 @@ import (
"bytes"
"context"
"encoding/binary"
// "errors"
"fmt"
"io"

View File

@ -2,10 +2,11 @@ package database
import (
"context"
"github.com/ledgerwatch/erigon/cmd/observer/utils"
"github.com/ledgerwatch/log/v3"
"math/rand"
"time"
"github.com/ledgerwatch/erigon/cmd/observer/utils"
"github.com/ledgerwatch/log/v3"
)
type DBRetrier struct {

View File

@ -5,10 +5,11 @@ import (
"database/sql"
"errors"
"fmt"
_ "modernc.org/sqlite"
"net"
"strings"
"time"
_ "modernc.org/sqlite"
)
type DBSQLite struct {

View File

@ -2,11 +2,12 @@ package database
import (
"context"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"net"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestDBSQLiteInsertAndFind(t *testing.T) {

View File

@ -4,6 +4,8 @@ import (
"context"
"errors"
"fmt"
"path/filepath"
"github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon/cmd/observer/database"
"github.com/ledgerwatch/erigon/cmd/observer/observer"
@ -11,7 +13,6 @@ import (
"github.com/ledgerwatch/erigon/cmd/utils"
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/log/v3"
"path/filepath"
)
func mainWithFlags(ctx context.Context, flags observer.CommandFlags) error {

View File

@ -3,12 +3,13 @@ package observer
import (
"context"
"errors"
"runtime"
"time"
"github.com/ledgerwatch/erigon/cmd/utils"
"github.com/ledgerwatch/erigon/internal/debug"
"github.com/spf13/cobra"
"github.com/urfave/cli"
"runtime"
"time"
)
type CommandFlags struct {

View File

@ -5,13 +5,14 @@ import (
"crypto/ecdsa"
"errors"
"fmt"
"sync/atomic"
"time"
"github.com/ledgerwatch/erigon/cmd/observer/database"
"github.com/ledgerwatch/erigon/cmd/observer/observer/node_utils"
"github.com/ledgerwatch/erigon/cmd/observer/utils"
"github.com/ledgerwatch/log/v3"
"golang.org/x/sync/semaphore"
"sync/atomic"
"time"
)
type Diplomacy struct {

View File

@ -4,11 +4,12 @@ import (
"context"
"crypto/ecdsa"
"errors"
"time"
"github.com/ledgerwatch/erigon/cmd/observer/database"
"github.com/ledgerwatch/erigon/p2p"
"github.com/ledgerwatch/erigon/p2p/enode"
"github.com/ledgerwatch/log/v3"
"time"
)
type Diplomat struct {

View File

@ -2,13 +2,14 @@ package observer
import (
"context"
"testing"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/eth/protocols/eth"
"github.com/ledgerwatch/erigon/p2p/enode"
"github.com/ledgerwatch/erigon/params"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)
func TestHandshake(t *testing.T) {

View File

@ -5,14 +5,15 @@ import (
"crypto/ecdsa"
"errors"
"fmt"
"strings"
"time"
"github.com/ledgerwatch/erigon/cmd/observer/utils"
"github.com/ledgerwatch/erigon/core/forkid"
"github.com/ledgerwatch/erigon/eth/protocols/eth"
"github.com/ledgerwatch/erigon/p2p/enode"
"github.com/ledgerwatch/log/v3"
"golang.org/x/sync/semaphore"
"strings"
"time"
)
type DiscV4Transport interface {

View File

@ -3,10 +3,11 @@ package observer
import (
"context"
"crypto/ecdsa"
"time"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/p2p/enode"
"github.com/ledgerwatch/log/v3"
"time"
)
func keygen(

View File

@ -2,12 +2,13 @@ package observer
import (
"context"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/log/v3"
"github.com/stretchr/testify/assert"
"runtime"
"testing"
"time"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/log/v3"
"github.com/stretchr/testify/assert"
)
func TestKeygen(t *testing.T) {

View File

@ -2,11 +2,12 @@ package node_utils
import (
"fmt"
"net"
"github.com/ledgerwatch/erigon/cmd/observer/database"
"github.com/ledgerwatch/erigon/cmd/observer/utils"
"github.com/ledgerwatch/erigon/p2p/enode"
"github.com/ledgerwatch/erigon/p2p/enr"
"net"
)
func MakeNodeAddr(node *enode.Node) database.NodeAddr {

View File

@ -3,9 +3,10 @@ package node_utils
import (
"errors"
"fmt"
"net/url"
"github.com/ledgerwatch/erigon/cmd/observer/database"
"github.com/ledgerwatch/erigon/p2p/enode"
"net/url"
)
func NodeID(node *enode.Node) (database.NodeID, error) {

View File

@ -3,6 +3,8 @@ package sentry_candidates
import (
"context"
"fmt"
"time"
"github.com/ledgerwatch/erigon/cmd/observer/database"
"github.com/ledgerwatch/erigon/cmd/observer/observer/node_utils"
"github.com/ledgerwatch/erigon/cmd/observer/utils"
@ -10,7 +12,6 @@ import (
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/log/v3"
"github.com/nxadm/tail"
"time"
)
type Intake struct {

View File

@ -4,12 +4,13 @@ import (
"bufio"
"context"
"encoding/json"
"github.com/ledgerwatch/erigon/eth/protocols/eth"
"github.com/nxadm/tail"
"io"
"strconv"
"strings"
"time"
"github.com/ledgerwatch/erigon/eth/protocols/eth"
"github.com/nxadm/tail"
)
type Log struct {

View File

@ -2,11 +2,12 @@ package sentry_candidates
import (
"context"
"strings"
"testing"
"github.com/nxadm/tail"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"strings"
"testing"
)
func TestLogRead(t *testing.T) {

View File

@ -5,6 +5,9 @@ import (
"crypto/ecdsa"
"errors"
"fmt"
"net"
"path/filepath"
"github.com/ledgerwatch/erigon/cmd/utils"
"github.com/ledgerwatch/erigon/common/debug"
"github.com/ledgerwatch/erigon/core/forkid"
@ -17,8 +20,6 @@ import (
"github.com/ledgerwatch/erigon/p2p/netutil"
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/log/v3"
"net"
"path/filepath"
)
type Server struct {

View File

@ -3,10 +3,11 @@ package observer
import (
"context"
"errors"
"time"
"github.com/ledgerwatch/erigon/cmd/observer/database"
"github.com/ledgerwatch/erigon/cmd/observer/utils"
"github.com/ledgerwatch/log/v3"
"time"
)
func StatusLoggerLoop(ctx context.Context, db database.DB, networkID uint, period time.Duration, logger log.Logger) {

View File

@ -3,9 +3,10 @@ package reports
import (
"context"
"fmt"
"github.com/ledgerwatch/erigon/cmd/observer/database"
"math"
"strings"
"github.com/ledgerwatch/erigon/cmd/observer/database"
)
type ClientsEstimateReportEntry struct {

View File

@ -3,9 +3,10 @@ package reports
import (
"context"
"fmt"
"strings"
"github.com/ledgerwatch/erigon/cmd/observer/database"
"github.com/ledgerwatch/erigon/cmd/observer/observer"
"strings"
)
type ClientsReportEntry struct {

View File

@ -2,6 +2,7 @@ package reports
import (
"context"
"github.com/ledgerwatch/erigon/cmd/utils"
"github.com/spf13/cobra"
"github.com/urfave/cli"

View File

@ -3,11 +3,12 @@ package reports
import (
"context"
"fmt"
"github.com/ledgerwatch/erigon/cmd/observer/database"
"github.com/ledgerwatch/erigon/cmd/observer/observer/sentry_candidates"
"net/url"
"os"
"strings"
"github.com/ledgerwatch/erigon/cmd/observer/database"
"github.com/ledgerwatch/erigon/cmd/observer/observer/sentry_candidates"
)
type SentryCandidatesReport struct {

View File

@ -3,8 +3,9 @@ package reports
import (
"context"
"fmt"
"github.com/ledgerwatch/erigon/cmd/observer/database"
"strings"
"github.com/ledgerwatch/erigon/cmd/observer/database"
)
type StatusReport struct {

View File

@ -4,6 +4,7 @@ import (
"crypto/ecdsa"
"encoding/hex"
"fmt"
"github.com/ledgerwatch/erigon/crypto"
"github.com/ledgerwatch/erigon/p2p/enode"
)

View File

@ -2,8 +2,9 @@ package utils
import (
"context"
"github.com/ledgerwatch/log/v3"
"time"
"github.com/ledgerwatch/log/v3"
)
func Retry(

View File

@ -33,7 +33,6 @@
//
// $ p2psim node connect node01 node02
// Connected node01 to node02
//
package main
import (

View File

@ -43,6 +43,7 @@ func (api *APIImpl) Mining(ctx context.Context) (bool, error) {
// GetWork returns a work package for external miner.
//
// The work package consists of 3 strings:
//
// result[0] - 32 bytes hex encoded current block header pow-hash
// result[1] - 32 bytes hex encoded seed hash used for DAG
// result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty

View File

@ -2,6 +2,7 @@ package commands
import (
"context"
"github.com/ledgerwatch/erigon-lib/gointerfaces/starknet"
"github.com/ledgerwatch/erigon-lib/gointerfaces/txpool"
"github.com/ledgerwatch/erigon/common/hexutil"

View File

@ -2,13 +2,14 @@ package commands
import (
"context"
"reflect"
"strings"
"github.com/ledgerwatch/erigon-lib/gointerfaces/starknet"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/rpc"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/wrapperspb"
"reflect"
"strings"
)
type StarknetGrpcCallArgs struct {

View File

@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
txPoolProto "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/common/hexutil"

View File

@ -586,6 +586,7 @@ func (vals *ValidatorSet) updateWithChangeSet(changes []*bor.Validator, allowDel
// - applies the updates against the validator set
// - applies the removals against the validator set
// - performs scaling and centering of priority values
//
// If an error is detected during verification steps, it is returned and the validator set
// is not changed.
func (vals *ValidatorSet) UpdateWithChangeSet(changes []*bor.Validator) error {

View File

@ -2,6 +2,7 @@ package commands
import (
"context"
ethFilters "github.com/ledgerwatch/erigon/eth/filters"
"github.com/ledgerwatch/erigon-lib/kv"

View File

@ -3,6 +3,9 @@ package commands
import (
"context"
"fmt"
"sort"
"time"
"github.com/RoaringBitmap/roaring/roaring64"
"github.com/ledgerwatch/erigon/core"
"github.com/ledgerwatch/erigon/core/rawdb"
@ -13,8 +16,6 @@ import (
"github.com/ledgerwatch/erigon/rpc"
"github.com/ledgerwatch/erigon/turbo/transactions"
"github.com/ledgerwatch/log/v3"
"sort"
"time"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/core/types"

View File

@ -43,6 +43,7 @@ func (api *APIImpl) Mining(ctx context.Context) (bool, error) {
// GetWork returns a work package for external miner.
//
// The work package consists of 3 strings:
//
// result[0] - 32 bytes hex encoded current block header pow-hash
// result[1] - 32 bytes hex encoded seed hash used for DAG
// result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty

View File

@ -2,6 +2,7 @@ package commands
import (
"context"
"github.com/ledgerwatch/erigon-lib/gointerfaces/starknet"
"github.com/ledgerwatch/erigon-lib/gointerfaces/txpool"
"github.com/ledgerwatch/erigon/common/hexutil"

View File

@ -2,13 +2,14 @@ package commands
import (
"context"
"reflect"
"strings"
"github.com/ledgerwatch/erigon-lib/gointerfaces/starknet"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/rpc"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/wrapperspb"
"reflect"
"strings"
)
type StarknetGrpcCallArgs struct {

View File

@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
txPoolProto "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/common/hexutil"

View File

@ -586,6 +586,7 @@ func (vals *ValidatorSet) updateWithChangeSet(changes []*bor.Validator, allowDel
// - applies the updates against the validator set
// - applies the removals against the validator set
// - performs scaling and centering of priority values
//
// If an error is detected during verification steps, it is returned and the validator set
// is not changed.
func (vals *ValidatorSet) UpdateWithChangeSet(changes []*bor.Validator) error {

View File

@ -19,7 +19,9 @@ var routes map[string]string
// but also can be used for comparing RPCDaemon with Geth
// parameters:
// needCompare - if false - doesn't call Erigon and doesn't compare responses
//
// use false value - to generate vegeta files, it's faster but we can generate vegeta files for Geth and Erigon
//
// fullTest - if false - then call only methods which RPCDaemon currently supports
func Bench1(erigonURL, gethURL string, needCompare bool, fullTest bool, blockFrom uint64, blockTo uint64, recordFile string) {
setRoutes(erigonURL, gethURL)

View File

@ -3,10 +3,11 @@ package rpctest
import (
"encoding/base64"
"fmt"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/core/state"
"net/http"
"time"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/core/state"
)
func Bench3(erigon_url, geth_url string) {

View File

@ -2,9 +2,10 @@ package rpctest
import (
"fmt"
"github.com/ledgerwatch/erigon/common"
"net/http"
"time"
"github.com/ledgerwatch/erigon/common"
)
func Bench4(erigon_url string) {

View File

@ -2,9 +2,10 @@ package rpctest
import (
"fmt"
"github.com/ledgerwatch/erigon/common"
"net/http"
"time"
"github.com/ledgerwatch/erigon/common"
)
func Bench6(erigon_url string) {

View File

@ -12,6 +12,7 @@ import (
// but also can be used for comparing RPCDaemon with Geth or infura
// parameters:
// needCompare - if false - doesn't call Erigon and doesn't compare responses
//
// false value - to generate vegeta files, it's faster but we can generate vegeta files for Geth and Erigon
// recordFile stores all eth_call returned with success
// errorFile stores information when erigon and geth doesn't return same data

View File

@ -13,6 +13,7 @@ import (
// but also can be used for comparing RPCDaemon with Geth or infura
// parameters:
// needCompare - if false - doesn't call Erigon and doesn't compare responses
//
// false value - to generate vegeta files, it's faster but we can generate vegeta files for Geth and Erigon
// recordFile stores all eth_getlogs returned with success
// errorFile stores information when erigon and geth doesn't return same data

View File

@ -40,7 +40,7 @@ func compareBlocks(b, bg *EthBlockByNumber) bool {
return false
}
if (tx.To == nil && txg.To != nil) || (tx.To != nil && txg.To == nil) {
fmt.Printf("Tx %d different To nilness: %t %t\n", i, (tx.To == nil), (txg.To == nil))
fmt.Printf("Tx %d different To nilness: %t %t\n", i, tx.To == nil, txg.To == nil)
return false
}
if tx.To != nil && txg.To != nil && *tx.To != *txg.To {
@ -89,8 +89,8 @@ func compareTraces(trace, traceg *EthTxTrace) bool {
}
func compareJsonValues(prefix string, v, vg *fastjson.Value) error {
var vType fastjson.Type = fastjson.TypeNull
var vgType fastjson.Type = fastjson.TypeNull
var vType = fastjson.TypeNull
var vgType = fastjson.TypeNull
if v != nil {
vType = v.Type()
}
@ -205,8 +205,8 @@ func compareErrors(errVal *fastjson.Value, errValg *fastjson.Value, methodName s
return fmt.Errorf("different result (Erigon) returns OK, while G/OE returns error code=%d message=%s", errValg.GetInt("code"), errValg.GetStringBytes("message"))
}
} else {
s1 := strings.ToUpper(string((errVal.GetStringBytes("message"))))
s2 := strings.ToUpper(string((errValg.GetStringBytes("message"))))
s1 := strings.ToUpper(string(errVal.GetStringBytes("message")))
s2 := strings.ToUpper(string(errValg.GetStringBytes("message")))
if strings.Compare(s1, s2) != 0 {
if errs != nil {
fmt.Printf("different error-message for method %s, errCtx: %s\n", methodName, errCtx)

View File

@ -7,6 +7,8 @@ import (
"encoding/hex"
"errors"
"fmt"
"io/fs"
"github.com/holiman/uint256"
"github.com/ledgerwatch/erigon-lib/kv"
"github.com/ledgerwatch/erigon/common"
@ -17,7 +19,6 @@ import (
"github.com/ledgerwatch/erigon/params"
"github.com/ledgerwatch/erigon/rlp"
"github.com/ledgerwatch/erigon/turbo/adapter"
"io/fs"
)
var (

View File

@ -4,11 +4,12 @@ import (
"bytes"
"context"
"encoding/hex"
"github.com/ledgerwatch/erigon-lib/kv/memdb"
"github.com/ledgerwatch/erigon/cmd/starknet/services"
"testing"
"testing/fstest"
"github.com/ledgerwatch/erigon-lib/kv/memdb"
"github.com/ledgerwatch/erigon/cmd/starknet/services"
"github.com/ledgerwatch/erigon/crypto"
)

View File

@ -204,7 +204,7 @@ func Erigon22(genesis *core.Genesis, logger log.Logger) error {
}
var inputBlockNum, outputBlockNum uint64
// Go-routine gathering results from the workers
var maxTxNum uint64 = txNums[len(txNums)-1]
var maxTxNum = txNums[len(txNums)-1]
if workerCount > 1 {
go func() {
defer func() {

View File

@ -18,10 +18,11 @@ package bitutil
import (
"bytes"
"github.com/ledgerwatch/log/v3"
"math/rand"
"testing"
"github.com/ledgerwatch/log/v3"
"github.com/ledgerwatch/erigon/common/hexutil"
)

View File

@ -22,10 +22,11 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/ledgerwatch/log/v3"
"os/exec"
"strconv"
"strings"
"github.com/ledgerwatch/log/v3"
)
// Solidity contains information about the solidity compiler.

View File

@ -14,7 +14,6 @@ func AccountIndexChunkKey(key []byte, blockNumber uint64) []byte {
return blockNumBytes
}
//
func StorageIndexChunkKey(key []byte, blockNumber uint64) []byte {
//remove incarnation and add block number
blockNumBytes := make([]byte, common.AddressLength+common.HashLength+8)

View File

@ -18,7 +18,7 @@
Package hexutil implements hex encoding with 0x prefix.
This encoding is used by the Ethereum RPC API to transport binary data in JSON payloads.
Encoding Rules
# Encoding Rules
All hex data must have prefix "0x".

View File

@ -19,7 +19,6 @@ package mclock
import (
"time"
_ "unsafe" // for go:linkname
)

View File

@ -1235,6 +1235,7 @@ func (c *AuRa) CalcDifficulty(chain consensus.ChainHeaderReader, time, parentTim
}
// calculateScore - analog of PoW difficulty:
//
// sqrt(U256::max_value()) + parent_step - current_step + current_empty_steps
func calculateScore(parentStep, currentStep, currentEmptySteps uint64) *uint256.Int {
maxU128 := uint256.NewInt(0).SetAllOne()
@ -1423,12 +1424,12 @@ func headerEmptyStepsRaw(header *types.Header) []byte {
//
// An empty step message is created _instead of_ a block if there are no pending transactions.
// It cannot itself be a parent, and `parent_hash` always points to the most recent block. E.g.:
// * Validator A creates block `bA`.
// * Validator B has no pending transactions, so it signs an empty step message `mB`
// - Validator A creates block `bA`.
// - Validator B has no pending transactions, so it signs an empty step message `mB`
// instead whose hash points to block `bA`.
// * Validator C also has no pending transactions, so it also signs an empty step message `mC`
// - Validator C also has no pending transactions, so it also signs an empty step message `mC`
// instead whose hash points to block `bA`.
// * Validator D creates block `bD`. The parent is block `bA`, and the header includes `mB` and `mC`.
// - Validator D creates block `bD`. The parent is block `bA`, and the header includes `mB` and `mC`.
type EmptyStep struct {
// The signature of the other two fields, by the message's author.
signature []byte // H520

View File

@ -19,6 +19,7 @@ import (
/*
#[test]
fn block_reward_contract() {
let spec = Spec::new_test_round_block_reward_contract();
let tap = Arc::new(AccountProvider::transient_provider());

View File

@ -1081,7 +1081,7 @@ func (c *Bor) getSpanForBlock(blockNum uint64) (*HeimdallSpan, error) {
} else {
for span.StartBlock > blockNum {
// Span wit low enough block number is not loaded
var spanID uint64 = span.ID - 1
var spanID = span.ID - 1
var heimdallSpan HeimdallSpan
log.Info("Span with low enough block number is not loaded", "fetching span", spanID)
response, err := c.HeimdallClient.FetchWithRetry(c.execCtx, fmt.Sprintf("bor/span/%d", spanID), "")

View File

@ -36,7 +36,7 @@ func ConvertTo32(input []byte) (output [32]byte, err error) {
return
}
func Convert(input []([32]byte)) [][]byte {
func Convert(input [][32]byte) [][]byte {
var output [][]byte
for _, in := range input {
newInput := make([]byte, len(in[:]))

View File

@ -585,6 +585,7 @@ func (vals *ValidatorSet) updateWithChangeSet(changes []*Validator, allowDeletes
// - applies the updates against the validator set
// - applies the removals against the validator set
// - performs scaling and centering of priority values
//
// If an error is detected during verification steps, it is returned and the validator set
// is not changed.
func (vals *ValidatorSet) UpdateWithChangeSet(changes []*Validator) error {

View File

@ -34,6 +34,7 @@ type API struct {
// GetWork returns a work package for external miner.
//
// The work package consists of 3 strings:
//
// result[0] - 32 bytes hex encoded current block header pow-hash
// result[1] - 32 bytes hex encoded seed hash used for DAG
// result[2] - 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty

View File

@ -220,6 +220,7 @@ func (s *remoteSealer) loop() {
// makeWork creates a work package for external miner.
//
// The work package consists of 3 strings:
//
// result[0], 32 bytes hex encoded current block header pow-hash
// result[1], 32 bytes hex encoded seed hash used for DAG
// result[2], 32 bytes hex encoded boundary condition ("target"), 2^256/difficulty

View File

@ -42,6 +42,7 @@ var (
// ensure it conforms to DAO hard-fork rules.
//
// DAO hard-fork extension to the header validity:
//
// a) if the node is no-fork, do not accept blocks in the [fork, fork+10) range
// with the fork specific extra-data set
// b) if the node is pro-fork, require blocks in the specific range to have the

View File

@ -17,9 +17,8 @@
package asm
import (
"testing"
"encoding/hex"
"testing"
)
// Tests disassembling the instructions for valid evm code

View File

@ -743,6 +743,7 @@ func DefaultGnosisGenesisBlock() *Genesis {
}
// Pre-calculated version of:
//
// DevnetSignPrivateKey = crypto.HexToECDSA(sha256.Sum256([]byte("erigon devnet key")))
// DevnetEtherbase=crypto.PubkeyToAddress(DevnetSignPrivateKey.PublicKey)
var DevnetSignPrivateKey, _ = crypto.HexToECDSA("26e86e45f6fc45ec6e2ecd128cec80fa1d1505e5507dcd2ae58c3130a7a97b48")

View File

@ -17,12 +17,10 @@
//go:build none
/*
The mkalloc tool creates the genesis allocation constants in genesis_alloc.go
It outputs a const declaration that contains an RLP-encoded list of (address, balance) tuples.
go run mkalloc.go genesis.json
*/
package main

View File

@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//
//nolint:errcheck,prealloc
package core

View File

@ -35,7 +35,7 @@ import (
// 0xcdb5bf0b4b51093e1c994f471921f88623c9d3e1b6aa2782049f53a0048f2b32 (block 11079912)
// 0x21ab7bf7245a87eae265124aaf180d91133377e47db2b1a4866493ec4b371150 (block 13119520)
var analysisBlocks map[string][]uint64 = map[string][]uint64{
var analysisBlocks = map[string][]uint64{
networkname.MainnetChainName: {5_800_596, 6_426_298, 6_426_432, 11_079_912, 13_119_520, 15_081_051},
networkname.BSCChainName: {19_278_044},
networkname.BorMainnetChainName: {29_447_463},

View File

@ -1,9 +1,10 @@
package state
import (
"testing"
"github.com/ledgerwatch/erigon-lib/kv/memdb"
"github.com/ledgerwatch/erigon/common"
"testing"
)
func verifyAddrs(t *testing.T, s *IntraBlockState, astrings ...string) {

View File

@ -45,8 +45,10 @@ The state transitioning model does all the necessary work to work out a valid ne
3) Create a new state object if the recipient is \0*32
4) Value transfer
== If contract creation ==
4a) Attempt to run transaction data
4b) If valid, use result as code for the new state object
== end ==
5) Run Script section
6) Derive new state root
@ -257,7 +259,7 @@ func (st *StateTransition) buyGas(gasBailout bool) error {
return fmt.Errorf("%w: address %v", ErrInsufficientFunds, st.msg.From().Hex())
}
}
var subBalance bool = false
var subBalance = false
if have, want := st.state.GetBalance(st.msg.From()), balanceCheck; have.Cmp(want) < 0 {
if !gasBailout {
return fmt.Errorf("%w: address %v have %v want %v", ErrInsufficientFunds, st.msg.From().Hex(), have, want)

View File

@ -2,9 +2,10 @@ package vm
import (
"errors"
"github.com/holiman/uint256"
"log"
"reflect"
"github.com/holiman/uint256"
)
type CfgOpSem struct {

View File

@ -17,10 +17,11 @@
package vm
import (
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/core/types"
"math/big"
"time"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/core/types"
)
// accessList is an accumulator for the set of accounts and storage slots an EVM

View File

@ -289,6 +289,7 @@ var (
// modexpMultComplexity implements bigModexp multComplexity formula, as defined in EIP-198
//
// def mult_complexity(x):
//
// if x <= 64: return x ** 2
// elif x <= 1024: return x ** 2 // 4 + 96 * x - 3072
// else: return x ** 2 // 16 + 480 * x - 199680
@ -614,7 +615,7 @@ func (c *blake2F) Run(input []byte) ([]byte, error) {
// Parse the input into the Blake2b call parameters
var (
rounds = binary.BigEndian.Uint32(input[0:4])
final = (input[212] == blake2FFinalBlockBytes)
final = input[212] == blake2FFinalBlockBytes
h [8]uint64
m [16]uint64

View File

@ -415,16 +415,21 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
// opExtCodeHash returns the code hash of a specified account.
// There are several cases when the function is called, while we can relay everything
// to `state.GetCodeHash` function to ensure the correctness.
//
// (1) Caller tries to get the code hash of a normal contract account, state
//
// should return the relative code hash and set it as the result.
//
// (2) Caller tries to get the code hash of a non-existent account, state should
//
// return common.Hash{} and zero will be set as the result.
//
// (3) Caller tries to get the code hash for an account without contract code,
//
// state should return emptyCodeHash(0xc5d246...) as the result.
//
// (4) Caller tries to get the code hash of a precompiled account, the result
//
// should be zero or emptyCodeHash.
//
// It is worth noting that in order to avoid unnecessary create and clean,
@ -434,9 +439,11 @@ func opExtCodeCopy(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext)
// customized chain, the return value will be zero.
//
// (5) Caller tries to get the code hash for an account which is marked as suicided
//
// in the current transaction, the code hash of this account should be returned.
//
// (6) Caller tries to get the code hash for an account which is marked as deleted,
//
// this account should be regarded as a non-existent account and zero should be returned.
func opExtCodeHash(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]byte, error) {
slot := scope.Stack.Peek()

View File

@ -74,6 +74,7 @@ type EVMInterpreter struct {
}
// structcheck doesn't see embedding
//
//nolint:structcheck
type VM struct {
evm *EVM

View File

@ -1,7 +1,6 @@
// Package iavl implements a versioned, snapshottable (immutable) AVL+ tree
// for persisting key-value pairs.
//
//
// Basic usage of MutableTree.
//
// import "github.com/tendermint/iavl"
@ -45,5 +44,4 @@
// Can't create a proof of absence for a version we no longer have:
//
// _, proof, err = tree.GetVersionedWithProof([]byte("tom"), 1) // nil, nil, error
//
package iavl

View File

@ -244,7 +244,7 @@ type Sync struct {
}
// Chains where snapshots are enabled by default
var ChainsWithSnapshots map[string]struct{} = map[string]struct{}{
var ChainsWithSnapshots = map[string]struct{}{
networkname.MainnetChainName: {},
networkname.BSCChainName: {},
networkname.GoerliChainName: {},

View File

@ -198,6 +198,7 @@ func (oracle *Oracle) resolveBlockRange(ctx context.Context, lastBlock rpc.Block
// block, sorted in ascending order and weighted by gas used.
// - baseFee: base fee per gas in the given block
// - gasUsedRatio: gasUsed/gasLimit in the given block
//
// Note: baseFee includes the next block after the newest of the returned range, because this
// value can be derived from the newest block.
func (oracle *Oracle) FeeHistory(ctx context.Context, blocks int, unresolvedLastBlock rpc.BlockNumber, rewardPercentiles []float64) (*big.Int, [][]*big.Int, []*big.Int, []float64, error) {

View File

@ -18,6 +18,7 @@ package eth
import (
"fmt"
"github.com/ledgerwatch/erigon/common"
"github.com/ledgerwatch/erigon/core/forkid"
"github.com/ledgerwatch/erigon/p2p/enr"

View File

@ -85,7 +85,7 @@ func AnswerGetBlockHeadersQuery(db kv.Tx, query *GetBlockHeadersPacket, blockRea
unknown = true
} else {
query.Origin.Hash, query.Origin.Number = rawdb.ReadAncestor(db, query.Origin.Hash, query.Origin.Number, ancestor, &maxNonCanonical, blockReader)
unknown = (query.Origin.Hash == common.Hash{})
unknown = query.Origin.Hash == common.Hash{}
}
case hashMode && !query.Reverse:
// Hash based traversal towards the leaf block

View File

@ -152,7 +152,7 @@ func NotifyNewHeaders(ctx context.Context, finishStageBeforeSync uint64, finishS
}
notifyFrom++
var notifyTo uint64 = notifyFrom
var notifyTo = notifyFrom
var headersRlp [][]byte
if err := tx.ForEach(kv.Headers, dbutils.EncodeBlockNumber(notifyFrom), func(k, headerRLP []byte) error {
if len(headerRLP) == 0 {

View File

@ -1,8 +1,9 @@
package tracers
import (
"github.com/dop251/goja"
"unsafe"
"github.com/dop251/goja"
)
type JSVM struct {

View File

@ -1,8 +1,9 @@
package tracers
import (
"github.com/stretchr/testify/assert"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSwap(t *testing.T) {

Some files were not shown because too many files have changed in this diff Show More