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,8 +166,9 @@ 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{}
//
// contract TestConstructor {
// constructor(uint256 a, uint256 b) public{}
// }
func TestConstructor(t *testing.T) {
json := `[{ "inputs": [{"internalType": "uint256","name": "a","type": "uint256" },{ "internalType": "uint256","name": "b","type": "uint256"}],"stateMutability": "nonpayable","type": "constructor"}]`
@ -710,16 +712,19 @@ 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);
// function receive(bytes memo) external payable {
// received(msg.sender, msg.value, memo);
// receivedAddr(msg.sender);
// }
// }
//
// contract T {
// event received(address sender, uint amount, bytes memo);
// event receivedAddr(address sender);
// function receive(bytes memo) external payable {
// received(msg.sender, msg.value, memo);
// 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]}
//
// 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"}]`
abi, err := JSON(strings.NewReader(abiJSON))
@ -1064,8 +1069,9 @@ 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);
//
// contract DuplicateEvent {
// event send(uint256 a);
// event send0();
// event send();
// }
@ -1092,7 +1098,8 @@ 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 {
//
// contract TestEvent {
// event send(uint256, uint256);
// }
func TestUnnamedEventParam(t *testing.T) {

View File

@ -94,17 +94,17 @@ func TestSimulatedBackend(t *testing.T) {
var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
// the following is based on this contract:
// contract T {
// event received(address sender, uint amount, bytes memo);
// event receivedAddr(address sender);
// the following is based on this contract:
// contract T {
// event received(address sender, uint amount, bytes memo);
// event receivedAddr(address sender);
//
// function receive(bytes calldata memo) external payable returns (string memory res) {
// emit received(msg.sender, msg.value, memo);
// emit receivedAddr(msg.sender);
// return "hello world";
// }
// }
// function receive(bytes calldata memo) external payable returns (string memory res) {
// emit received(msg.sender, msg.value, memo);
// emit receivedAddr(msg.sender);
// return "hello world";
// }
// }
const abiJSON = `[ { "constant": false, "inputs": [ { "name": "memo", "type": "bytes" } ], "name": "receive", "outputs": [ { "name": "res", "type": "string" } ], "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" } ]`
const abiBin = `0x608060405234801561001057600080fd5b506102a0806100206000396000f3fe60806040526004361061003b576000357c010000000000000000000000000000000000000000000000000000000090048063a69b6ed014610040575b600080fd5b6100b76004803603602081101561005657600080fd5b810190808035906020019064010000000081111561007357600080fd5b82018360208201111561008557600080fd5b803590602001918460018302840111640100000000831117156100a757600080fd5b9091929391929390505050610132565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f75780820151818401526020810190506100dc565b50505050905090810190601f1680156101245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60607f75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed33348585604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509550505050505060405180910390a17f46923992397eac56cf13058aced2a1871933622717e27b24eabc13bf9dd329c833604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a16040805190810160405280600b81526020017f68656c6c6f20776f726c6400000000000000000000000000000000000000000081525090509291505056fea165627a7a72305820ff0c57dad254cfeda48c9cfb47f1353a558bccb4d1bc31da1dae69315772d29e0029`
const deployedCode = `60806040526004361061003b576000357c010000000000000000000000000000000000000000000000000000000090048063a69b6ed014610040575b600080fd5b6100b76004803603602081101561005657600080fd5b810190808035906020019064010000000081111561007357600080fd5b82018360208201111561008557600080fd5b803590602001918460018302840111640100000000831117156100a757600080fd5b9091929391929390505050610132565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f75780820151818401526020810190506100dc565b50505050905090810190601f1680156101245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60607f75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed33348585604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509550505050505060405180910390a17f46923992397eac56cf13058aced2a1871933622717e27b24eabc13bf9dd329c833604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a16040805190810160405280600b81526020017f68656c6c6f20776f726c6400000000000000000000000000000000000000000081525090509291505056fea165627a7a72305820ff0c57dad254cfeda48c9cfb47f1353a558bccb4d1bc31da1dae69315772d29e0029`
@ -954,7 +954,8 @@ 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]}
//
// 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)
sim := simTestBackend(t, testAddr)

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" + "\""),
// }
//
// 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.
//
// 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.
//
// 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

@ -233,7 +233,7 @@ var printTorrentHashes = &cobra.Command{
},
}
//nolint
// nolint
func removePieceCompletionStorage(snapDir string) {
_ = os.RemoveAll(filepath.Join(snapDir, "db"))
_ = os.RemoveAll(filepath.Join(snapDir, ".torrent.db"))

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
}
@ -446,8 +446,9 @@ func getTransaction(txJson commands.RPCTransaction) (types.Transaction, error) {
// signUnsignedTransactions converts the input txs to canonical transactions.
//
// The transactions can have two forms, either
// 1. unsigned or
// 2. signed
// 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"
@ -212,7 +211,7 @@ type mdbx_db struct {
txnID uint64 /* txnid of last committed modification */
}
//nolint // database size-related parameters, used as placeholder, doesn't have any meaning in this code
// nolint // database size-related parameters, used as placeholder, doesn't have any meaning in this code
type mdbx_geo struct {
grow_pv uint16 //nolint
shrink_pv uint16 //nolint

View File

@ -344,7 +344,7 @@ func absIntAndJumpImprecision() {
runCfgAnly("AndJumpImprecision00", s)
}
//17891 transactions, 588 bytecode len
// 17891 transactions, 588 bytecode len
func absIntTestSmallImprecision2() {
const s = "6080604052600436106100405763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166393e84cd98114610045575b600080fd5b34801561005157600080fd5b5061005a61005c565b005b60008060008060008060008060008060008060008073a62142888aba8370742be823c1782d17a0389da173ffffffffffffffffffffffffffffffffffffffff1663747dff426040518163ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004016101c060405180830381600087803b1580156100ea57600080fd5b505af11580156100fe573d6000803e3d6000fd5b505050506040513d6101c081101561011557600080fd5b8101908080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291908051906020019092919080519060200190929190805190602001909291905050509d509d509d509d509d509d509d509d509d509d509d509d509d509d508673ffffffffffffffffffffffffffffffffffffffff167318a0451ea56fd4ff58f59837e9ec30f346ffdca573ffffffffffffffffffffffffffffffffffffffff161415151561021057fe5b50505050505050505050505050505600a165627a7a72305820ec5e1703d3b74688c3350622a2bcfc097615733fa5f8df7adf51d66ebf42d0260029"
runCfgAnly("SmallImprecision02", s)

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

@ -19,21 +19,20 @@
// Here is an example of creating a 2 node network with the first node
// connected to the second:
//
// $ p2psim node create
// Created node01
// $ p2psim node create
// Created node01
//
// $ p2psim node start node01
// Started node01
// $ p2psim node start node01
// Started node01
//
// $ p2psim node create
// Created node02
// $ p2psim node create
// Created node02
//
// $ p2psim node start node02
// Started node02
//
// $ p2psim node connect node01 node02
// Connected node01 to node02
// $ p2psim node start node02
// Started node02
//
// $ p2psim node connect node01 node02
// Connected node01 to node02
package main
import (

View File

@ -43,10 +43,11 @@ 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
// result[3] - hex encoded block number
//
// 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
// result[3] - hex encoded block number
func (api *APIImpl) GetWork(ctx context.Context) ([4]string, error) {
var res [4]string
repl, err := api.mining.GetWork(ctx, &txpool.GetWorkRequest{})

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

@ -578,14 +578,15 @@ func (vals *ValidatorSet) updateWithChangeSet(changes []*bor.Validator, allowDel
// UpdateWithChangeSet attempts to update the validator set with 'changes'.
// It performs the following steps:
// - validates the changes making sure there are no duplicates and splits them in updates and deletes
// - verifies that applying the changes will not result in errors
// - computes the total voting power BEFORE removals to ensure that in the next steps the priorities
// across old and newly added validators are fair
// - computes the priorities of new validators against the final set
// - applies the updates against the validator set
// - applies the removals against the validator set
// - performs scaling and centering of priority values
// - validates the changes making sure there are no duplicates and splits them in updates and deletes
// - verifies that applying the changes will not result in errors
// - computes the total voting power BEFORE removals to ensure that in the next steps the priorities
// across old and newly added validators are fair
// - computes the priorities of new validators against the final set
// - 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,10 +43,11 @@ 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
// result[3] - hex encoded block number
//
// 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
// result[3] - hex encoded block number
func (api *APIImpl) GetWork(ctx context.Context) ([4]string, error) {
var res [4]string
repl, err := api.mining.GetWork(ctx, &txpool.GetWorkRequest{})

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

@ -578,14 +578,15 @@ func (vals *ValidatorSet) updateWithChangeSet(changes []*bor.Validator, allowDel
// UpdateWithChangeSet attempts to update the validator set with 'changes'.
// It performs the following steps:
// - validates the changes making sure there are no duplicates and splits them in updates and deletes
// - verifies that applying the changes will not result in errors
// - computes the total voting power BEFORE removals to ensure that in the next steps the priorities
// across old and newly added validators are fair
// - computes the priorities of new validators against the final set
// - applies the updates against the validator set
// - applies the removals against the validator set
// - performs scaling and centering of priority values
// - validates the changes making sure there are no duplicates and splits them in updates and deletes
// - verifies that applying the changes will not result in errors
// - computes the total voting power BEFORE removals to ensure that in the next steps the priorities
// across old and newly added validators are fair
// - computes the priorities of new validators against the final set
// - 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
//
// 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,9 +12,10 @@ 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
//
// 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
func BenchEthCall(erigonURL, gethURL string, needCompare, latest bool, blockFrom, blockTo uint64, recordFile string, errorFile string) {
setRoutes(erigonURL, gethURL)
var client = &http.Client{

View File

@ -13,9 +13,10 @@ 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
//
// 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
func BenchEthGetLogs(erigonURL, gethURL string, needCompare bool, blockFrom uint64, blockTo uint64, recordFile string, errorFile string) {
setRoutes(erigonURL, gethURL)
var client = &http.Client{

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

@ -57,8 +57,8 @@ var opcodeTracerCmd = &cobra.Command{
},
}
//const MaxUint = ^uint(0)
//const MaxUint64 = ^uint64(0)
// const MaxUint = ^uint(0)
// const MaxUint64 = ^uint64(0)
const MaxUint16 = ^uint16(0)
type opcode struct {

View File

@ -851,7 +851,7 @@ func ParseNodesFromURLs(urls []string) ([]*enode.Node, error) {
}
// NewP2PConfig
// - doesn't setup bootnodes - they will set when genesisHash will know
// - doesn't setup bootnodes - they will set when genesisHash will know
func NewP2PConfig(
nodiscover bool,
dirs datadir.Dirs,
@ -1182,7 +1182,7 @@ func setGPO(ctx *cli.Context, cfg *gasprice.Config) {
}
}
//nolint
// nolint
func setGPOCobra(f *pflag.FlagSet, cfg *gasprice.Config) {
if v := f.Int(GpoBlocksFlag.Name, GpoBlocksFlag.Value, GpoBlocksFlag.Usage); v != nil {
cfg.Blocks = *v

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

@ -6,7 +6,7 @@ import (
"github.com/ledgerwatch/erigon/core/types"
)
//nolint
// nolint
func Transactions(ts1, ts2 types.Transactions) {
fmt.Printf("==== Transactions ====\n")
fmt.Printf("len(Transactions): %d, %d\n", len(ts1), len(ts2))
@ -26,7 +26,7 @@ func Transactions(ts1, ts2 types.Transactions) {
}
}
//nolint
// nolint
func Receipts(rs1, rs2 types.Receipts) {
fmt.Printf("==== Receipts ====\n")
fmt.Printf("len(Receipts): %d, %d\n", len(rs1), len(rs2))
@ -75,7 +75,7 @@ func Receipts(rs1, rs2 types.Receipts) {
}
}
//nolint
// nolint
func Headers(h1, h2 *types.Header) {
fmt.Printf("==== Header ====\n")
fmt.Printf("root: %x, %x\n", h1.Root, h2.Root)

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

@ -245,10 +245,10 @@ func U256Bytes(n *big.Int) []byte {
// S256 interprets x as a two's complement number.
// x must not exceed 256 bits (the result is undefined if it does) and is not modified.
//
// S256(0) = 0
// S256(1) = 1
// S256(2**255) = -2**255
// S256(2**256-1) = -1
// S256(0) = 0
// S256(1) = 1
// S256(2**255) = -2**255
// S256(2**256-1) = -1
func S256(x *big.Int) *big.Int {
if x.Cmp(tt255) < 0 {
return x

View File

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

View File

@ -140,7 +140,7 @@ type PermissionedStep struct {
type ReceivedStepHashes map[uint64]map[common.Address]common.Hash //BTreeMap<(u64, Address), H256>
//nolint
// nolint
func (r ReceivedStepHashes) get(step uint64, author common.Address) (common.Hash, bool) {
res, ok := r[step]
if !ok {
@ -150,7 +150,7 @@ func (r ReceivedStepHashes) get(step uint64, author common.Address) (common.Hash
return result, ok
}
//nolint
// nolint
func (r ReceivedStepHashes) insert(step uint64, author common.Address, blockHash common.Hash) {
res, ok := r[step]
if !ok {
@ -160,7 +160,7 @@ func (r ReceivedStepHashes) insert(step uint64, author common.Address, blockHash
res[author] = blockHash
}
//nolint
// nolint
func (r ReceivedStepHashes) dropAncient(step uint64) {
for i := range r {
if i < step {
@ -169,7 +169,7 @@ func (r ReceivedStepHashes) dropAncient(step uint64) {
}
}
//nolint
// nolint
type EpochManager struct {
epochTransitionHash common.Hash // H256,
epochTransitionNumber uint64 // BlockNumber
@ -188,7 +188,7 @@ func (e *EpochManager) noteNewEpoch() { e.force = true }
// zoomValidators - Zooms to the epoch after the header with the given hash. Returns true if succeeded, false otherwise.
// It's analog of zoom_to_after function in OE, but doesn't require external locking
//nolint
// nolint
func (e *EpochManager) zoomToAfter(chain consensus.ChainHeaderReader, er consensus.EpochReader, validators ValidatorSet, hash common.Hash, call consensus.SystemCall) (*RollingFinality, uint64, bool) {
var lastWasParent bool
if e.finalityChecker.lastPushed != nil {
@ -246,12 +246,12 @@ func (e *EpochManager) zoomToAfter(chain consensus.ChainHeaderReader, er consens
return e.finalityChecker, e.epochTransitionNumber, true
}
/// Get the transition to the epoch the given parent hash is part of
/// or transitions to.
/// This will give the epoch that any children of this parent belong to.
///
/// The block corresponding the the parent hash must be stored already.
//nolint
// / Get the transition to the epoch the given parent hash is part of
// / or transitions to.
// / This will give the epoch that any children of this parent belong to.
// /
// / The block corresponding the the parent hash must be stored already.
// nolint
func epochTransitionFor2(chain consensus.ChainHeaderReader, e consensus.EpochReader, parentHash common.Hash) (transition EpochTransition, ok bool) {
//TODO: probably this version of func doesn't support non-canonical epoch transitions
h := chain.GetHeaderByHash(parentHash)
@ -268,7 +268,7 @@ func epochTransitionFor2(chain consensus.ChainHeaderReader, e consensus.EpochRea
return EpochTransition{BlockNumber: num, BlockHash: hash, ProofRlp: transitionProof}, true
}
//nolint
// nolint
func epochTransitionFor(chain consensus.ChainHeaderReader, e consensus.EpochReader, parentHash common.Hash) (transition EpochTransition, ok bool) {
// slow path: loop back block by block
for {
@ -321,7 +321,7 @@ func epochTransitionFor(chain consensus.ChainHeaderReader, e consensus.EpochRead
}
// AuRa
//nolint
// nolint
type AuRa struct {
db kv.RwDB // Database to store and retrieve snapshot checkpoints
exitCh chan struct{}
@ -522,7 +522,7 @@ func (c *AuRa) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Hea
return nil
}
//nolint
// nolint
func (c *AuRa) hasReceivedStepHashes(step uint64, author common.Address, newHash common.Hash) bool {
/*
self
@ -534,7 +534,7 @@ func (c *AuRa) hasReceivedStepHashes(step uint64, author common.Address, newHash
return false
}
//nolint
// nolint
func (c *AuRa) insertReceivedStepHashes(step uint64, author common.Address, newHash common.Hash) {
/*
self.received_step_hashes
@ -543,7 +543,7 @@ func (c *AuRa) insertReceivedStepHashes(step uint64, author common.Address, newH
*/
}
//nolint
// nolint
func (c *AuRa) verifyFamily(chain consensus.ChainHeaderReader, e consensus.EpochReader, header *types.Header, call consensus.Call, syscall consensus.SystemCall) error {
// TODO: I call it from Initialize - because looks like no much reason to have separated "verifyFamily" call
@ -830,7 +830,7 @@ func (c *AuRa) Initialize(config *params.ChainConfig, chain consensus.ChainHeade
}
//word `signal epoch` == word `pending epoch`
// word `signal epoch` == word `pending epoch`
func (c *AuRa) Finalize(config *params.ChainConfig, header *types.Header, state *state.IntraBlockState,
txs types.Transactions, uncles []*types.Header, receipts types.Receipts, e consensus.EpochReader,
chain consensus.ChainHeaderReader, syscall consensus.SystemCall,
@ -1200,7 +1200,7 @@ func (c *AuRa) epochSet(chain consensus.ChainHeaderReader, e consensus.EpochRead
return finalityChecker.signers, epochTransitionNumber, nil
}
//nolint
// nolint
func headerStep(current *types.Header) (val uint64, err error) {
if len(current.Seal) < 1 {
panic("was either checked with verify_block_basic or is genesis; has 2 fields; qed (Make sure the spec file has a correct genesis seal)")
@ -1235,7 +1235,8 @@ 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
//
// sqrt(U256::max_value()) + parent_step - current_step + current_empty_steps
func calculateScore(parentStep, currentStep, currentEmptySteps uint64) *uint256.Int {
maxU128 := uint256.NewInt(0).SetAllOne()
maxU128 = maxU128.Rsh(maxU128, 128)
@ -1268,7 +1269,7 @@ func (c *AuRa) APIs(chain consensus.ChainHeaderReader) []rpc.API {
}
}
//nolint
// nolint
func (c *AuRa) emptySteps(fromStep, toStep uint64, parentHash common.Hash) []EmptyStep {
from := EmptyStep{step: fromStep + 1, parentHash: parentHash}
to := EmptyStep{step: toStep}
@ -1376,7 +1377,7 @@ func blockRewardAbi() abi.ABI {
// the `parent_hash` in order to save space. The included signature is of the original empty step
// message, which can be reconstructed by using the parent hash of the block in which this sealed
// empty message is inc luded.
//nolint
// nolint
type SealedEmptyStep struct {
signature []byte // H520
step uint64
@ -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`
// instead whose hash points to block `bA`.
// * 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 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`
// instead whose hash points to block `bA`.
// - 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
@ -1480,7 +1481,7 @@ func (s *EmptyStep) verify(validators ValidatorSet) (bool, error) { //nolint
return true, nil
}
//nolint
// nolint
func (s *EmptyStep) author() (common.Address, error) {
sRlp, err := EmptyStepRlp(s.step, s.parentHash)
if err != nil {
@ -1538,7 +1539,7 @@ func EmptyStepRlp(step uint64, parentHash common.Hash) ([]byte, error) {
return rlp.EncodeToBytes(A{s: step, h: parentHash})
}
//nolint
// nolint
type unAssembledHeader struct {
hash common.Hash
number uint64
@ -1568,7 +1569,7 @@ func (u unAssembledHeaders) Front() *unAssembledHeader {
// RollingFinality checker for authority round consensus.
// Stores a chain of unfinalized hashes that can be pushed onto.
//nolint
// nolint
type RollingFinality struct {
headers unAssembledHeaders //nolint
signers *SimpleList

View File

@ -18,77 +18,78 @@ import (
)
/*
#[test]
fn block_reward_contract() {
let spec = Spec::new_test_round_block_reward_contract();
let tap = Arc::new(AccountProvider::transient_provider());
#[test]
let addr1 = tap.insert_account(keccak("1").into(), &"1".into()).unwrap();
fn block_reward_contract() {
let spec = Spec::new_test_round_block_reward_contract();
let tap = Arc::new(AccountProvider::transient_provider());
let engine = &*spec.engine;
let genesis_header = spec.genesis_header();
let db1 = spec
.ensure_db_good(get_temp_state_db(), &Default::default())
.unwrap();
let db2 = spec
.ensure_db_good(get_temp_state_db(), &Default::default())
.unwrap();
let addr1 = tap.insert_account(keccak("1").into(), &"1".into()).unwrap();
let last_hashes = Arc::new(vec![genesis_header.hash()]);
let engine = &*spec.engine;
let genesis_header = spec.genesis_header();
let db1 = spec
.ensure_db_good(get_temp_state_db(), &Default::default())
.unwrap();
let db2 = spec
.ensure_db_good(get_temp_state_db(), &Default::default())
.unwrap();
let client = generate_dummy_client_with_spec(Spec::new_test_round_block_reward_contract);
engine.register_client(Arc::downgrade(&client) as _);
let last_hashes = Arc::new(vec![genesis_header.hash()]);
// step 2
let b1 = OpenBlock::new(
engine,
Default::default(),
false,
db1,
&genesis_header,
last_hashes.clone(),
addr1,
(3141562.into(), 31415620.into()),
vec![],
false,
None,
)
.unwrap();
let b1 = b1.close_and_lock().unwrap();
let client = generate_dummy_client_with_spec(Spec::new_test_round_block_reward_contract);
engine.register_client(Arc::downgrade(&client) as _);
// since the block is empty it isn't sealed and we generate empty steps
engine.set_signer(Some(Box::new((tap.clone(), addr1, "1".into()))));
assert_eq!(engine.generate_seal(&b1, &genesis_header), Seal::None);
engine.step();
// step 2
let b1 = OpenBlock::new(
engine,
Default::default(),
false,
db1,
&genesis_header,
last_hashes.clone(),
addr1,
(3141562.into(), 31415620.into()),
vec![],
false,
None,
)
.unwrap();
let b1 = b1.close_and_lock().unwrap();
// step 3
// the signer of the accumulated empty step message should be rewarded
let b2 = OpenBlock::new(
engine,
Default::default(),
false,
db2,
&genesis_header,
last_hashes.clone(),
addr1,
(3141562.into(), 31415620.into()),
vec![],
false,
None,
)
.unwrap();
let addr1_balance = b2.state.balance(&addr1).unwrap();
// since the block is empty it isn't sealed and we generate empty steps
engine.set_signer(Some(Box::new((tap.clone(), addr1, "1".into()))));
assert_eq!(engine.generate_seal(&b1, &genesis_header), Seal::None);
engine.step();
// after closing the block `addr1` should be reward twice, one for the included empty step
// message and another for block creation
let b2 = b2.close_and_lock().unwrap();
// step 3
// the signer of the accumulated empty step message should be rewarded
let b2 = OpenBlock::new(
engine,
Default::default(),
false,
db2,
&genesis_header,
last_hashes.clone(),
addr1,
(3141562.into(), 31415620.into()),
vec![],
false,
None,
)
.unwrap();
let addr1_balance = b2.state.balance(&addr1).unwrap();
// the contract rewards (1000 + kind) for each benefactor/reward kind
assert_eq!(
b2.state.balance(&addr1).unwrap(),
addr1_balance + (1000 + 0) + (1000 + 2),
)
}
// after closing the block `addr1` should be reward twice, one for the included empty step
// message and another for block creation
let b2 = b2.close_and_lock().unwrap();
// the contract rewards (1000 + kind) for each benefactor/reward kind
assert_eq!(
b2.state.balance(&addr1).unwrap(),
addr1_balance + (1000 + 0) + (1000 + 2),
)
}
*/
func TestRewardContract(t *testing.T) {
t.Skip("not ready yet")

View File

@ -45,7 +45,7 @@ type SealRegular SealKind
// Engine does not generate seal for this block right now.
type None SealKind
/// The type of sealing the engine is currently able to perform.
// / The type of sealing the engine is currently able to perform.
type SealingState uint8
const (

View File

@ -73,7 +73,7 @@ func newValidatorSetFromJson(j *ValidatorSetJson, posdaoTransition *uint64) Vali
return nil
}
//TODO: StepDuration and BlockReward - now are uint64, but it can be an object in non-sokol consensus
// TODO: StepDuration and BlockReward - now are uint64, but it can be an object in non-sokol consensus
type JsonSpec struct {
StepDuration *uint64 `json:"stepDuration"` // Block duration, in seconds.
Validators *ValidatorSetJson `json:"validators"` // Valid authorities

View File

@ -22,7 +22,7 @@ import (
"go.uber.org/atomic"
)
//nolint
// nolint
type CallResults struct {
data []byte
proof [][]byte
@ -192,7 +192,7 @@ func count(s ValidatorSet, h common.Hash, call consensus.Call) (uint64, error) {
return s.countWithCaller(h, call)
}
//nolint
// nolint
type MultiItem struct {
num uint64
hash common.Hash
@ -274,7 +274,7 @@ func (s *Multi) onCloseBlock(header *types.Header, address common.Address) error
}
// TODO: do we need add `proof` argument?
//nolint
// nolint
func (s *Multi) epochSet(firstInEpoch bool, num uint64, proof []byte, call consensus.SystemCall) (SimpleList, common.Hash, error) {
setBlock, set := s.correctSetByNumber(num)
firstInEpoch = setBlock == num
@ -333,20 +333,20 @@ func NewSimpleList(validators []common.Address) *SimpleList {
return &SimpleList{validators: validators}
}
//nolint
// nolint
type ReportQueueItem struct {
addr common.Address
blockNum uint64
data []byte
}
//nolint
// nolint
type ReportQueue struct {
mu sync.RWMutex
list *list.List
}
//nolint
// nolint
func (q *ReportQueue) push(addr common.Address, blockNum uint64, data []byte) {
q.mu.Lock()
defer q.mu.Unlock()
@ -354,7 +354,7 @@ func (q *ReportQueue) push(addr common.Address, blockNum uint64, data []byte) {
}
// Filters reports of validators that have already been reported or are banned.
//nolint
// nolint
func (q *ReportQueue) filter(abi aurainterfaces.ValidatorSetABI, client client, ourAddr, contractAddr common.Address) error {
q.mu.Lock()
defer q.mu.Unlock()
@ -384,7 +384,7 @@ func (q *ReportQueue) filter(abi aurainterfaces.ValidatorSetABI, client client,
}
// Removes reports from the queue if it contains more than `MAX_QUEUED_REPORTS` entries.
//nolint
// nolint
func (q *ReportQueue) truncate() {
// The maximum number of reports to keep queued.
const MaxQueuedReports = 10
@ -405,7 +405,7 @@ func (q *ReportQueue) truncate() {
}
// The validator contract should have the following interface:
//nolint
// nolint
type ValidatorSafeContract struct {
contractAddress common.Address
validators *lru.Cache // RwLock<MemoryLruCache<H256, SimpleList>>,
@ -439,7 +439,7 @@ func NewValidatorSafeContract(contractAddress common.Address, posdaoTransition *
// but with the same parameters.
//
// Returns a list of contract calls to be pushed onto the new block.
//func generateEngineTransactions(_firstInEpoch bool, _header *types.Header, _call SystemCall) -> Result<Vec<(Address, Bytes)>, EthcoreError>
// func generateEngineTransactions(_firstInEpoch bool, _header *types.Header, _call SystemCall) -> Result<Vec<(Address, Bytes)>, EthcoreError>
func (s *ValidatorSafeContract) epochSet(firstInEpoch bool, num uint64, setProof []byte, call consensus.SystemCall) (SimpleList, common.Hash, error) {
if firstInEpoch {
var proof FirstValidatorSetProof
@ -512,7 +512,7 @@ func (s *ValidatorSafeContract) epochSet(firstInEpoch bool, num uint64, setProof
}
// check a first proof: fetch the validator set at the given block.
//nolint
// nolint
func checkFirstValidatorSetProof(contract_address common.Address, oldHeader *types.Header, dbItems [][]byte) ([]common.Address, error) {
/*
fn check_first_proof(
@ -579,7 +579,7 @@ func checkFirstValidatorSetProof(contract_address common.Address, oldHeader *typ
// inter-contract proofs are a header and receipts.
// checking will involve ensuring that the receipts match the header and
// extracting the validator set from the receipts.
//nolint
// nolint
func (s *ValidatorSafeContract) defaultCaller(blockHash common.Hash) (Call, error) {
return func(addr common.Address, data []byte) (CallResults, error) {
return s.client.CallAtBlockHash(blockHash, addr, data)

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

@ -577,14 +577,15 @@ func (vals *ValidatorSet) updateWithChangeSet(changes []*Validator, allowDeletes
// UpdateWithChangeSet attempts to update the validator set with 'changes'.
// It performs the following steps:
// - validates the changes making sure there are no duplicates and splits them in updates and deletes
// - verifies that applying the changes will not result in errors
// - computes the total voting power BEFORE removals to ensure that in the next steps the priorities
// across old and newly added validators are fair
// - computes the priorities of new validators against the final set
// - applies the updates against the validator set
// - applies the removals against the validator set
// - performs scaling and centering of priority values
// - validates the changes making sure there are no duplicates and splits them in updates and deletes
// - verifies that applying the changes will not result in errors
// - computes the total voting power BEFORE removals to ensure that in the next steps the priorities
// across old and newly added validators are fair
// - computes the priorities of new validators against the final set
// - 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,10 +34,11 @@ 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
// result[3] - hex encoded block number
//
// 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
// result[3] - hex encoded block number
func (api *API) GetWork() ([4]string, error) {
if api.ethash.remote == nil {
return [4]string{}, errors.New("not supported")

View File

@ -220,10 +220,11 @@ 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
// result[3], hex encoded block number
//
// 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
// result[3], hex encoded block number
func (s *remoteSealer) makeWork(block *types.Block) {
hash := s.ethash.SealHash(block.Header())
s.currentWork[0] = hash.Hex()

View File

@ -42,10 +42,11 @@ 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
// unique extra-data set.
//
// 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
// unique extra-data set.
func VerifyDAOHeaderExtraData(config *params.ChainConfig, header *types.Header) error {
// Short circuit validation if the node doesn't care about the DAO fork
if config.DAOForkBlock == nil {

View File

@ -149,7 +149,7 @@ func (s *Snapshot) copy() *Snapshot {
return cpy
}
//nolint
// nolint
func (s *Snapshot) isMajorityFork(forkHash string) bool {
ally := 0
for _, h := range s.RecentForkHashes {

View File

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

View File

@ -166,10 +166,10 @@ func (e *GenesisMismatchError) Error() string {
// CommitGenesisBlock writes or updates the genesis block in db.
// The block that will be used is:
//
// genesis == nil genesis != nil
// +------------------------------------------
// db has no genesis | main-net default | genesis
// db has genesis | from DB | genesis (if compatible)
// genesis == nil genesis != nil
// +------------------------------------------
// db has no genesis | main-net default | genesis
// db has genesis | from DB | genesis (if compatible)
//
// The stored chain configuration will be updated if it is compatible (i.e. does not
// specify a fork block below the local head block). In case of a conflict, the
@ -695,7 +695,7 @@ func DefaultMumbaiGenesisBlock() *Genesis {
}
}
//DefaultBorMainnet returns the Bor Mainnet network gensis block.
// DefaultBorMainnet returns the Bor Mainnet network gensis block.
func DefaultBorMainnetGenesisBlock() *Genesis {
return &Genesis{
Config: params.BorMainnetChainConfig,
@ -743,8 +743,9 @@ func DefaultGnosisGenesisBlock() *Genesis {
}
// Pre-calculated version of:
// DevnetSignPrivateKey = crypto.HexToECDSA(sha256.Sum256([]byte("erigon devnet key")))
// DevnetEtherbase=crypto.PubkeyToAddress(DevnetSignPrivateKey.PublicKey)
//
// DevnetSignPrivateKey = crypto.HexToECDSA(sha256.Sum256([]byte("erigon devnet key")))
// DevnetEtherbase=crypto.PubkeyToAddress(DevnetSignPrivateKey.PublicKey)
var DevnetSignPrivateKey, _ = crypto.HexToECDSA("26e86e45f6fc45ec6e2ecd128cec80fa1d1505e5507dcd2ae58c3130a7a97b48")
var DevnetEtherbase = common.HexToAddress("67b1d87101671b127f5f8714789c7192f7ad340e")

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.
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
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

@ -1012,7 +1012,7 @@ func TestEip2200Gas(t *testing.T) {
require.NoError(t, err)
}
//Create contract, drop trie, reload trie from disk and add block with contract call
// Create contract, drop trie, reload trie from disk and add block with contract call
func TestWrongIncarnation(t *testing.T) {
// Configure and generate a sample block chain
var (
@ -1125,7 +1125,7 @@ func TestWrongIncarnation(t *testing.T) {
require.NoError(t, err)
}
//create acc, deploy to it contract, reorg to state without contract
// create acc, deploy to it contract, reorg to state without contract
func TestWrongIncarnation2(t *testing.T) {
// Configure and generate a sample block chain
var (

View File

@ -583,8 +583,8 @@ func (sdb *IntraBlockState) createObject(addr common.Address, previous *stateObj
// CreateAccount is called during the EVM CREATE operation. The situation might arise that
// a contract does the following:
//
// 1. sends funds to sha(account ++ (nonce + 1))
// 2. tx_create(sha(account ++ nonce)) (note that this gets the address of 1)
// 1. sends funds to sha(account ++ (nonce + 1))
// 2. tx_create(sha(account ++ nonce)) (note that this gets the address of 1)
//
// Carrying over the balance ensures that Ether doesn't disappear.
func (sdb *IntraBlockState) CreateAccount(addr common.Address, contractCreation bool) {

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
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)
@ -332,13 +334,13 @@ func (st *StateTransition) preCheck(gasBailout bool) error {
// TransitionDb will transition the state by applying the current message and
// returning the evm execution result with following fields.
//
// - used gas:
// total gas used (including gas being refunded)
// - returndata:
// the returned data from evm
// - concrete execution error:
// various **EVM** error which aborts the execution,
// e.g. ErrOutOfGas, ErrExecutionReverted
// - used gas:
// total gas used (including gas being refunded)
// - returndata:
// the returned data from evm
// - concrete execution error:
// various **EVM** error which aborts the execution,
// e.g. ErrOutOfGas, ErrExecutionReverted
//
// However if any consensus issue encountered, return the error directly with
// nil evm execution result.

View File

@ -131,7 +131,7 @@ func AbsValueDestringify(s string) AbsValue {
return AbsValue{}
}
//////////////////////////////////////////////////
// ////////////////////////////////////////////////
type astack struct {
values []AbsValue
hash uint64
@ -295,7 +295,7 @@ func (state *astate) Add(stack *astack) {
//////////////////////////////////////////////////
//-1 block id is invalid jump
// -1 block id is invalid jump
type CfgProofState struct {
Pc int
Stacks [][]string
@ -361,15 +361,15 @@ func (proof *CfgProof) ToString() string {
return string(proof.Serialize())
}
//block.{Entry|Exit}.Pc in code, block.{Succs|Preds} in some block.{Entry}.Pc
//Entry <= Exit
//No overlap of blocks
//Must have block starting at 0 with a empty state
//Succs,Preds consistency
//No duplicate succs
//No duplicate preds
//succs are sorted
//preds are sorted
// block.{Entry|Exit}.Pc in code, block.{Succs|Preds} in some block.{Entry}.Pc
// Entry <= Exit
// No overlap of blocks
// Must have block starting at 0 with a empty state
// Succs,Preds consistency
// No duplicate succs
// No duplicate preds
// succs are sorted
// preds are sorted
func (proof *CfgProof) isValid() bool {
return true
}

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