Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: Enable verbose load test logging to highlight breakage #1106

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion accounts/abi/bind/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
var (
// ErrNoCode is returned by call and transact operations for which the requested
// recipient contract to operate on does not exist in the state db or does not
// have any code associated with it (i.e. self-destructed).
// have any code associated with it (i.e. suicided).
ErrNoCode = errors.New("no contract code at given address")

// ErrNoAcceptedState is raised when attempting to perform a accepted state action
Expand Down
22 changes: 12 additions & 10 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ import (
var (
_ bind.AcceptedContractCaller = (*SimulatedBackend)(nil)
_ bind.ContractBackend = (*SimulatedBackend)(nil)
_ bind.ContractFilterer = (*SimulatedBackend)(nil)
_ bind.ContractTransactor = (*SimulatedBackend)(nil)
_ bind.DeployBackend = (*SimulatedBackend)(nil)

_ interfaces.ChainReader = (*SimulatedBackend)(nil)
Expand Down Expand Up @@ -145,7 +147,7 @@ func (b *SimulatedBackend) Close() error {
return nil
}

// Commit imports all the accepted transactions as a single block and starts a
// Commit imports all the pending transactions as a single block and starts a
// fresh new state.
func (b *SimulatedBackend) Commit(accept bool) common.Hash {
b.mu.Lock()
Expand All @@ -169,7 +171,7 @@ func (b *SimulatedBackend) Commit(accept bool) common.Hash {
return blockHash
}

// Rollback aborts all accepted transactions, reverting to the last committed state.
// Rollback aborts all pending transactions, reverting to the last committed state.
func (b *SimulatedBackend) Rollback() {
b.mu.Lock()
defer b.mu.Unlock()
Expand Down Expand Up @@ -204,7 +206,7 @@ func (b *SimulatedBackend) Fork(ctx context.Context, parent common.Hash) error {
defer b.mu.Unlock()

if len(b.acceptedBlock.Transactions()) != 0 {
return errors.New("accepted block dirty")
return errors.New("pending block dirty")
}
block, err := b.blockByHash(ctx, parent)
if err != nil {
Expand Down Expand Up @@ -291,10 +293,10 @@ func (b *SimulatedBackend) TransactionReceipt(ctx context.Context, txHash common
return receipt, nil
}

// TransactionByHash checks the pool of accepted transactions in addition to the
// blockchain. The isAccepted return value indicates whether the transaction has been
// TransactionByHash checks the pool of pending transactions in addition to the
// blockchain. The isPending return value indicates whether the transaction has been
// mined yet. Note that the transaction may not be part of the canonical chain even if
// it's not accepted.
// it's not pending.
func (b *SimulatedBackend) TransactionByHash(ctx context.Context, txHash common.Hash) (*types.Transaction, bool, error) {
b.mu.Lock()
defer b.mu.Unlock()
Expand Down Expand Up @@ -535,7 +537,7 @@ func (b *SimulatedBackend) SuggestGasTipCap(ctx context.Context) (*big.Int, erro
return big.NewInt(1), nil
}

// EstimateGas executes the requested code against the currently accepted block/state and
// EstimateGas executes the requested code against the currently pending block/state and
// returns the used amount of gas.
func (b *SimulatedBackend) EstimateGas(ctx context.Context, call interfaces.CallMsg) (uint64, error) {
b.mu.Lock()
Expand Down Expand Up @@ -639,7 +641,7 @@ func (b *SimulatedBackend) EstimateGas(ctx context.Context, call interfaces.Call
return hi, nil
}

// callContract implements common code between normal and accepted contract calls.
// callContract implements common code between normal and pending contract calls.
// state is modified during execution, make sure to copy it if necessary.
func (b *SimulatedBackend) callContract(ctx context.Context, call interfaces.CallMsg, header *types.Header, stateDB *state.StateDB) (*core.ExecutionResult, error) {
// Gas prices post 1559 need to be initialized
Expand Down Expand Up @@ -709,7 +711,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call interfaces.Cal
return core.ApplyMessage(vmEnv, msg, gasPool)
}

// SendTransaction updates the accepted block to include the given transaction.
// SendTransaction updates the pending block to include the given transaction.
func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error {
b.mu.Lock()
defer b.mu.Unlock()
Expand Down Expand Up @@ -852,7 +854,7 @@ func (b *SimulatedBackend) AdjustTime(adjustment time.Duration) error {
}
block := b.blockchain.GetBlockByHash(b.acceptedBlock.ParentHash())
if block == nil {
return errors.New("could not find parent")
return fmt.Errorf("could not find parent")
}

blocks, _, _ := core.GenerateChain(b.config, block, dummy.NewFaker(), b.database, 1, 10, func(number int, block *core.BlockGen) {
Expand Down
1 change: 0 additions & 1 deletion accounts/abi/bind/backends/simulated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ func TestAdjustTime(t *testing.T) {
func TestNewAdjustTimeFail(t *testing.T) {
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
sim := simTestBackend(testAddr)
defer sim.blockchain.Stop()

// Create tx and send
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/bind/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func BindHelper(types []string, abis []string, bytecodes []string, fsigs []map[s
normalized := original
normalizedName := methodNormalizer[lang](alias(aliases, original.Name))
// Ensure there is no duplicated identifier
var identifiers = callIdentifiers
identifiers := callIdentifiers
if !original.IsConstant() {
identifiers = transactIdentifiers
}
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type Error struct {
str string

// Sig contains the string signature according to the ABI spec.
// e.g. error foo(uint32 a, int b) = "foo(uint32,int256)"
// e.g. error foo(uint32 a, int b) = "foo(uint32,int256)"
// Please note that "int" is substitute for its canonical representation "int256"
Sig string

Expand Down
1 change: 0 additions & 1 deletion accounts/abi/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ type Event struct {
// e.g. event foo(uint32 a, int b) = "foo(uint32,int256)"
// Please note that "int" is substitute for its canonical representation "int256"
Sig string

// ID returns the canonical representation of the event's signature used by the
// abi definition to identify event names and types.
ID common.Hash
Expand Down
2 changes: 1 addition & 1 deletion accounts/abi/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func mapArgNamesToStructFields(argNames []string, value reflect.Value) (map[stri
structFieldName := ToCamelCase(argName)

if structFieldName == "" {
return nil, errors.New("abi: purely underscored output cannot unpack to struct")
return nil, fmt.Errorf("abi: purely underscored output cannot unpack to struct")
}

// this abi has already been paired, skip it... unless there exists another, yet unassigned
Expand Down
6 changes: 3 additions & 3 deletions accounts/abi/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var (
func NewType(t string, internalType string, components []ArgumentMarshaling) (typ Type, err error) {
// check that array brackets are equal if they exist
if strings.Count(t, "[") != strings.Count(t, "]") {
return Type{}, errors.New("invalid arg type in abi")
return Type{}, fmt.Errorf("invalid arg type in abi")
}
typ.stringKind = t

Expand Down Expand Up @@ -119,7 +119,7 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
}
typ.stringKind = embeddedType.stringKind + sliced
} else {
return Type{}, errors.New("invalid formatting of array type")
return Type{}, fmt.Errorf("invalid formatting of array type")
}
return typ, err
}
Expand Down Expand Up @@ -356,7 +356,7 @@ func (t Type) pack(v reflect.Value) ([]byte, error) {
}
}

// requiresLengthPrefix returns whether the type requires any sort of length
// requireLengthPrefix returns whether the type requires any sort of length
// prefixing.
func (t Type) requiresLengthPrefix() bool {
return t.T == StringTy || t.T == BytesTy || t.T == SliceTy
Expand Down
7 changes: 3 additions & 4 deletions accounts/abi/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ package abi

import (
"encoding/binary"
"errors"
"fmt"
"math"
"math/big"
Expand Down Expand Up @@ -136,7 +135,7 @@ func readBool(word []byte) (bool, error) {
// readFunctionType enforces that standard by always presenting it as a 24-array (address + sig = 24 bytes)
func readFunctionType(t Type, word []byte) (funcTy [24]byte, err error) {
if t.T != FunctionTy {
return [24]byte{}, errors.New("abi: invalid type in call to make function type byte array")
return [24]byte{}, fmt.Errorf("abi: invalid type in call to make function type byte array")
}
if garbage := binary.BigEndian.Uint64(word[24:32]); garbage != 0 {
err = fmt.Errorf("abi: got improperly encoded function type, got %v", word)
Expand All @@ -149,7 +148,7 @@ func readFunctionType(t Type, word []byte) (funcTy [24]byte, err error) {
// ReadFixedBytes uses reflection to create a fixed array to be read from.
func ReadFixedBytes(t Type, word []byte) (interface{}, error) {
if t.T != FixedBytesTy {
return nil, errors.New("abi: invalid type in call to make fixed byte array")
return nil, fmt.Errorf("abi: invalid type in call to make fixed byte array")
}
// convert
array := reflect.New(t.GetType()).Elem()
Expand Down Expand Up @@ -177,7 +176,7 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error)
// declare our array
refSlice = reflect.New(t.GetType()).Elem()
} else {
return nil, errors.New("abi: invalid type in array/slice unpacking stage")
return nil, fmt.Errorf("abi: invalid type in array/slice unpacking stage")
}

// Arrays have packed elements, resulting in longer unpack steps.
Expand Down
13 changes: 6 additions & 7 deletions accounts/external/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
package external

import (
"errors"
"fmt"
"math/big"
"sync"
Expand Down Expand Up @@ -109,11 +108,11 @@ func (api *ExternalSigner) Status() (string, error) {
}

func (api *ExternalSigner) Open(passphrase string) error {
return errors.New("operation not supported on external signers")
return fmt.Errorf("operation not supported on external signers")
}

func (api *ExternalSigner) Close() error {
return errors.New("operation not supported on external signers")
return fmt.Errorf("operation not supported on external signers")
}

func (api *ExternalSigner) Accounts() []accounts.Account {
Expand Down Expand Up @@ -156,7 +155,7 @@ func (api *ExternalSigner) Contains(account accounts.Account) bool {
}

func (api *ExternalSigner) Derive(path accounts.DerivationPath, pin bool) (accounts.Account, error) {
return accounts.Account{}, errors.New("operation not supported on external signers")
return accounts.Account{}, fmt.Errorf("operation not supported on external signers")
}

func (api *ExternalSigner) SelfDerive(bases []accounts.DerivationPath, chain interfaces.ChainStateReader) {
Expand Down Expand Up @@ -253,14 +252,14 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
}

func (api *ExternalSigner) SignTextWithPassphrase(account accounts.Account, passphrase string, text []byte) ([]byte, error) {
return []byte{}, errors.New("password-operations not supported on external signers")
return []byte{}, fmt.Errorf("password-operations not supported on external signers")
}

func (api *ExternalSigner) SignTxWithPassphrase(account accounts.Account, passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) {
return nil, errors.New("password-operations not supported on external signers")
return nil, fmt.Errorf("password-operations not supported on external signers")
}
func (api *ExternalSigner) SignDataWithPassphrase(account accounts.Account, passphrase, mimeType string, data []byte) ([]byte, error) {
return nil, errors.New("password-operations not supported on external signers")
return nil, fmt.Errorf("password-operations not supported on external signers")
}

func (api *ExternalSigner) listAccounts() ([]common.Address, error) {
Expand Down
14 changes: 7 additions & 7 deletions accounts/keystore/account_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ import (
mapset "github.com/deckarep/golang-set/v2"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"golang.org/x/exp/slices"
)

// Minimum amount of time between cache reloads. This limit applies if the platform does
// not support change notifications. It also applies if the keystore directory does not
// exist yet, the code will attempt to create a watcher at most this often.
const minReloadInterval = 2 * time.Second

// byURL defines the sorting order for accounts.
func byURL(a, b accounts.Account) int {
return a.URL.Cmp(b.URL)
}
type accountsByURL []accounts.Account

func (s accountsByURL) Len() int { return len(s) }
func (s accountsByURL) Less(i, j int) bool { return s[i].URL.Cmp(s[j].URL) < 0 }
func (s accountsByURL) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

// AmbiguousAddrError is returned when attempting to unlock
// an address for which more than one file exists.
Expand All @@ -77,7 +77,7 @@ type accountCache struct {
keydir string
watcher *watcher
mu sync.Mutex
all []accounts.Account
all accountsByURL
byAddr map[common.Address][]accounts.Account
throttle *time.Timer
notify chan struct{}
Expand Down Expand Up @@ -204,7 +204,7 @@ func (ac *accountCache) find(a accounts.Account) (accounts.Account, error) {
default:
err := &AmbiguousAddrError{Addr: a.Address, Matches: make([]accounts.Account, len(matches))}
copy(err.Matches, matches)
slices.SortFunc(err.Matches, byURL)
sort.Sort(accountsByURL(err.Matches))
return accounts.Account{}, err
}
}
Expand Down
7 changes: 3 additions & 4 deletions accounts/keystore/account_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,19 @@
package keystore

import (
"errors"
"fmt"
"math/rand"
"os"
"path/filepath"
"reflect"
"sort"
"testing"
"time"

"github.com/ava-labs/subnet-evm/accounts"
"github.com/cespare/cp"
"github.com/davecgh/go-spew/spew"
"github.com/ethereum/go-ethereum/common"
"golang.org/x/exp/slices"
)

var (
Expand Down Expand Up @@ -85,7 +84,7 @@ func waitForAccounts(wantAccounts []accounts.Account, ks *KeyStore) error {
select {
case <-ks.changes:
default:
return errors.New("wasn't notified of new accounts")
return fmt.Errorf("wasn't notified of new accounts")
}
return nil
}
Expand Down Expand Up @@ -213,7 +212,7 @@ func TestCacheAddDeleteOrder(t *testing.T) {
// Check that the account list is sorted by filename.
wantAccounts := make([]accounts.Account, len(accs))
copy(wantAccounts, accs)
slices.SortFunc(wantAccounts, byURL)
sort.Sort(accountsByURL(wantAccounts))
list := cache.accounts()
if !reflect.DeepEqual(list, wantAccounts) {
t.Fatalf("got accounts: %s\nwant %s", spew.Sdump(accs), spew.Sdump(wantAccounts))
Expand Down
10 changes: 5 additions & 5 deletions accounts/keystore/keystore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"math/rand"
"os"
"runtime"
"sort"
"strings"
"sync"
"sync/atomic"
Expand All @@ -40,7 +41,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/event"
"golang.org/x/exp/slices"
)

var testSigData = make([]byte, 32)
Expand Down Expand Up @@ -410,19 +410,19 @@ func TestImportRace(t *testing.T) {
t.Fatalf("failed to export account: %v", acc)
}
_, ks2 := tmpKeyStore(t, true)
var atom atomic.Uint32
var atom uint32
var wg sync.WaitGroup
wg.Add(2)
for i := 0; i < 2; i++ {
go func() {
defer wg.Done()
if _, err := ks2.Import(json, "new", "new"); err != nil {
atom.Add(1)
atomic.AddUint32(&atom, 1)
}
}()
}
wg.Wait()
if atom.Load() != 1 {
if atom != 1 {
t.Errorf("Import is racy")
}
}
Expand All @@ -437,7 +437,7 @@ func checkAccounts(t *testing.T, live map[common.Address]accounts.Account, walle
for _, account := range live {
liveList = append(liveList, account)
}
slices.SortFunc(liveList, byURL)
sort.Sort(accountsByURL(liveList))
for j, wallet := range wallets {
if accs := wallet.Accounts(); len(accs) != 1 {
t.Errorf("wallet %d: contains invalid number of accounts: have %d, want 1", j, len(accs))
Expand Down
7 changes: 2 additions & 5 deletions accounts/keystore/passphrase.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,10 @@ func DecryptKey(keyjson []byte, auth string) (*Key, error) {
if err != nil {
return nil, err
}
key, err := crypto.ToECDSA(keyBytes)
if err != nil {
return nil, fmt.Errorf("invalid key: %w", err)
}
key := crypto.ToECDSAUnsafe(keyBytes)
id, err := uuid.FromBytes(keyId)
if err != nil {
return nil, fmt.Errorf("invalid UUID: %w", err)
return nil, err
}
return &Key{
Id: id,
Expand Down
Loading
Loading