mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-28 07:36:44 +00:00
Merge branch 'ethereum:master' into portal
This commit is contained in:
commit
75a9bc1b54
19 changed files with 57 additions and 38 deletions
2
accounts/external/backend.go
vendored
2
accounts/external/backend.go
vendored
|
|
@ -239,7 +239,7 @@ func (api *ExternalSigner) SignTx(account accounts.Account, tx *types.Transactio
|
|||
args.BlobHashes = tx.BlobHashes()
|
||||
sidecar := tx.BlobTxSidecar()
|
||||
if sidecar == nil {
|
||||
return nil, fmt.Errorf("blobs must be present for signing")
|
||||
return nil, errors.New("blobs must be present for signing")
|
||||
}
|
||||
args.Blobs = sidecar.Blobs
|
||||
args.Commitments = sidecar.Commitments
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ func (s *Suite) sendTxs(t *utesting.T, txs []*types.Transaction) error {
|
|||
}
|
||||
}
|
||||
|
||||
return fmt.Errorf("timed out waiting for txs")
|
||||
return errors.New("timed out waiting for txs")
|
||||
}
|
||||
|
||||
func (s *Suite) sendInvalidTxs(t *utesting.T, txs []*types.Transaction) error {
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
|
|||
if rbloom != header.Bloom {
|
||||
return fmt.Errorf("invalid bloom (remote: %x local: %x)", header.Bloom, rbloom)
|
||||
}
|
||||
// Tre receipt Trie's root (R = (Tr [[H1, R1], ... [Hn, Rn]]))
|
||||
// The receipt Trie's root (R = (Tr [[H1, R1], ... [Hn, Rn]]))
|
||||
receiptSha := types.DeriveSha(receipts, trie.NewStackTrie(nil))
|
||||
if receiptSha != header.ReceiptHash {
|
||||
return fmt.Errorf("invalid receipt root hash (remote: %x local: %x)", header.ReceiptHash, receiptSha)
|
||||
|
|
|
|||
|
|
@ -439,7 +439,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
|
|||
}
|
||||
|
||||
if alloc == nil {
|
||||
return nil, fmt.Errorf("live blockchain tracer requires genesis alloc to be set")
|
||||
return nil, errors.New("live blockchain tracer requires genesis alloc to be set")
|
||||
}
|
||||
|
||||
bc.logger.OnGenesisBlock(bc.genesisBlock, alloc)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ package core
|
|||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -1966,7 +1966,7 @@ func testSetHeadWithScheme(t *testing.T, tt *rewindTest, snapshots bool, scheme
|
|||
|
||||
// Create a temporary persistent database
|
||||
datadir := t.TempDir()
|
||||
ancient := path.Join(datadir, "ancient")
|
||||
ancient := filepath.Join(datadir, "ancient")
|
||||
|
||||
db, err := rawdb.Open(rawdb.OpenOptions{
|
||||
Directory: datadir,
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ func DeveloperGenesisBlock(gasLimit uint64, faucet *common.Address) *Genesis {
|
|||
Config: &config,
|
||||
GasLimit: gasLimit,
|
||||
BaseFee: big.NewInt(params.InitialBaseFee),
|
||||
Difficulty: big.NewInt(1),
|
||||
Difficulty: big.NewInt(0),
|
||||
Alloc: map[common.Address]types.Account{
|
||||
common.BytesToAddress([]byte{1}): {Balance: big.NewInt(1)}, // ECRecover
|
||||
common.BytesToAddress([]byte{2}): {Balance: big.NewInt(1)}, // SHA256
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -172,7 +171,7 @@ func resolveChainFreezerDir(ancient string) string {
|
|||
// sub folder, if not then two possibilities:
|
||||
// - chain freezer is not initialized
|
||||
// - chain freezer exists in legacy location (root ancient folder)
|
||||
freezer := path.Join(ancient, ChainFreezerName)
|
||||
freezer := filepath.Join(ancient, ChainFreezerName)
|
||||
if !common.FileExist(freezer) {
|
||||
if !common.FileExist(ancient) {
|
||||
// The entire ancient store is not initialized, still use the sub
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import (
|
|||
"math/big"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"testing"
|
||||
|
|
@ -398,11 +397,11 @@ func TestRenameWindows(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f2, err := os.Create(path.Join(dir1, fname2))
|
||||
f2, err := os.Create(filepath.Join(dir1, fname2))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
f3, err := os.Create(path.Join(dir2, fname2))
|
||||
f3, err := os.Create(filepath.Join(dir2, fname2))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -424,15 +423,15 @@ func TestRenameWindows(t *testing.T) {
|
|||
if err := f3.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Rename(f.Name(), path.Join(dir2, fname)); err != nil {
|
||||
if err := os.Rename(f.Name(), filepath.Join(dir2, fname)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.Rename(f2.Name(), path.Join(dir2, fname2)); err != nil {
|
||||
if err := os.Rename(f2.Name(), filepath.Join(dir2, fname2)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Check file contents
|
||||
f, err = os.Open(path.Join(dir2, fname))
|
||||
f, err = os.Open(filepath.Join(dir2, fname))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
@ -446,7 +445,7 @@ func TestRenameWindows(t *testing.T) {
|
|||
t.Errorf("unexpected file contents. Got %v\n", buf)
|
||||
}
|
||||
|
||||
f, err = os.Open(path.Join(dir2, fname2))
|
||||
f, err = os.Open(filepath.Join(dir2, fname2))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -439,13 +439,19 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64,
|
|||
if evm.chainRules.IsBerlin {
|
||||
evm.StateDB.AddAddressToAccessList(address)
|
||||
}
|
||||
// Ensure there's no existing contract already at the designated address
|
||||
// Ensure there's no existing contract already at the designated address.
|
||||
// Account is regarded as existent if any of these three conditions is met:
|
||||
// - the nonce is nonzero
|
||||
// - the code is non-empty
|
||||
// - the storage is non-empty
|
||||
contractHash := evm.StateDB.GetCodeHash(address)
|
||||
if evm.StateDB.GetNonce(address) != 0 || (contractHash != (common.Hash{}) && contractHash != types.EmptyCodeHash) {
|
||||
storageRoot := evm.StateDB.GetStorageRoot(address)
|
||||
if evm.StateDB.GetNonce(address) != 0 ||
|
||||
(contractHash != (common.Hash{}) && contractHash != types.EmptyCodeHash) || // non-empty code
|
||||
(storageRoot != (common.Hash{}) && storageRoot != types.EmptyRootHash) { // non-empty storage
|
||||
if evm.Config.Tracer != nil && evm.Config.Tracer.OnGasChange != nil {
|
||||
evm.Config.Tracer.OnGasChange(gas, 0, tracing.GasChangeCallFailedExecution)
|
||||
}
|
||||
|
||||
return nil, common.Address{}, 0, ErrContractAddressCollision
|
||||
}
|
||||
// Create a new account on the state
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ type StateDB interface {
|
|||
GetCommittedState(common.Address, common.Hash) common.Hash
|
||||
GetState(common.Address, common.Hash) common.Hash
|
||||
SetState(common.Address, common.Hash, common.Hash)
|
||||
GetStorageRoot(addr common.Address) common.Hash
|
||||
|
||||
GetTransientState(addr common.Address, key common.Hash) common.Hash
|
||||
SetTransientState(addr common.Address, key, value common.Hash)
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ func UploadSFTP(identityFile, host, dir string, files []string) error {
|
|||
}
|
||||
in := io.MultiWriter(stdin, os.Stdout)
|
||||
for _, f := range files {
|
||||
fmt.Fprintln(in, "put", f, path.Join(dir, filepath.Base(f)))
|
||||
fmt.Fprintln(in, "put", f, filepath.Join(dir, filepath.Base(f)))
|
||||
}
|
||||
fmt.Fprintln(in, "exit")
|
||||
// Some issue with the PPA sftp server makes it so the server does not
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package era
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/big"
|
||||
|
||||
|
|
@ -80,7 +79,7 @@ func (it *Iterator) Block() (*types.Block, error) {
|
|||
// Receipts returns the receipts for the iterator's current position.
|
||||
func (it *Iterator) Receipts() (types.Receipts, error) {
|
||||
if it.inner.Receipts == nil {
|
||||
return nil, fmt.Errorf("receipts must be non-nil")
|
||||
return nil, errors.New("receipts must be non-nil")
|
||||
}
|
||||
var receipts types.Receipts
|
||||
err := rlp.Decode(it.inner.Receipts, &receipts)
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ func JSONHandler(wr io.Writer) slog.Handler {
|
|||
return JSONHandlerWithLevel(wr, levelMaxVerbosity)
|
||||
}
|
||||
|
||||
// JSONHandler returns a handler which prints records in JSON format that are less than or equal to
|
||||
// JSONHandlerWithLevel returns a handler which prints records in JSON format that are less than or equal to
|
||||
// the specified verbosity level.
|
||||
func JSONHandlerWithLevel(wr io.Writer, level slog.Level) slog.Handler {
|
||||
return slog.NewJSONHandler(wr, &slog.HandlerOptions{
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ type newPayloadResult struct {
|
|||
receipts []*types.Receipt // Receipts collected during construction
|
||||
}
|
||||
|
||||
// generateParams wraps various of settings for generating sealing task.
|
||||
// generateParams wraps various settings for generating sealing task.
|
||||
type generateParams struct {
|
||||
timestamp uint64 // The timestamp for sealing task
|
||||
forceTime bool // Flag whether the given timestamp is immutable or not
|
||||
|
|
@ -131,7 +131,7 @@ func (miner *Miner) prepareWork(genParams *generateParams) (*environment, error)
|
|||
if genParams.parentHash != (common.Hash{}) {
|
||||
block := miner.chain.GetBlockByHash(genParams.parentHash)
|
||||
if block == nil {
|
||||
return nil, fmt.Errorf("missing parent")
|
||||
return nil, errors.New("missing parent")
|
||||
}
|
||||
parent = block.Header()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ func TestAuthEndpoints(t *testing.T) {
|
|||
t.Fatalf("failed to create jwt secret: %v", err)
|
||||
}
|
||||
// Geth must read it from a file, and does not support in-memory JWT secrets, so we create a temporary file.
|
||||
jwtPath := path.Join(t.TempDir(), "jwt_secret")
|
||||
jwtPath := filepath.Join(t.TempDir(), "jwt_secret")
|
||||
if err := os.WriteFile(jwtPath, []byte(hexutil.Encode(secret[:])), 0600); err != nil {
|
||||
t.Fatalf("failed to prepare jwt secret file: %v", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import (
|
|||
"math/big"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -386,16 +387,8 @@ func (typedData *TypedData) HashStruct(primaryType string, data TypedDataMessage
|
|||
// Dependencies returns an array of custom types ordered by their hierarchical reference tree
|
||||
func (typedData *TypedData) Dependencies(primaryType string, found []string) []string {
|
||||
primaryType = strings.TrimSuffix(primaryType, "[]")
|
||||
includes := func(arr []string, str string) bool {
|
||||
for _, obj := range arr {
|
||||
if obj == str {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if includes(found, primaryType) {
|
||||
if slices.Contains(found, primaryType) {
|
||||
return found
|
||||
}
|
||||
if typedData.Types[primaryType] == nil {
|
||||
|
|
@ -404,7 +397,7 @@ func (typedData *TypedData) Dependencies(primaryType string, found []string) []s
|
|||
found = append(found, primaryType)
|
||||
for _, field := range typedData.Types[primaryType] {
|
||||
for _, dep := range typedData.Dependencies(field.Type, found) {
|
||||
if !includes(found, dep) {
|
||||
if !slices.Contains(found, dep) {
|
||||
found = append(found, dep)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import (
|
|||
"math/big"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
|
@ -411,7 +412,7 @@ func TestJsonFiles(t *testing.T) {
|
|||
// crashes or hangs.
|
||||
func TestFuzzerFiles(t *testing.T) {
|
||||
t.Parallel()
|
||||
corpusdir := path.Join("testdata", "fuzzing")
|
||||
corpusdir := filepath.Join("testdata", "fuzzing")
|
||||
testfiles, err := os.ReadDir(corpusdir)
|
||||
if err != nil {
|
||||
t.Fatalf("failed reading files: %v", err)
|
||||
|
|
|
|||
|
|
@ -64,6 +64,14 @@ func TestExecutionSpecBlocktests(t *testing.T) {
|
|||
}
|
||||
bt := new(testMatcher)
|
||||
|
||||
// These tests fail as of https://github.com/ethereum/go-ethereum/pull/28666, since we
|
||||
// no longer delete "leftover storage" when deploying a contract.
|
||||
bt.skipLoad(`^cancun/eip6780_selfdestruct/selfdestruct/self_destructing_initcode_create_tx.json`)
|
||||
bt.skipLoad(`^cancun/eip6780_selfdestruct/selfdestruct/self_destructing_initcode.json`)
|
||||
bt.skipLoad(`^cancun/eip6780_selfdestruct/selfdestruct/recreate_self_destructed_contract_different_txs.json`)
|
||||
bt.skipLoad(`^cancun/eip6780_selfdestruct/selfdestruct/delegatecall_from_new_contract_to_pre_existing_contract.json`)
|
||||
bt.skipLoad(`^cancun/eip6780_selfdestruct/selfdestruct/create_selfdestruct_same_tx.json`)
|
||||
|
||||
bt.walk(t, executionSpecBlockchainTestDir, func(t *testing.T, name string, test *BlockTest) {
|
||||
execBlockTest(t, bt, test)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -54,9 +54,22 @@ func initMatcher(st *testMatcher) {
|
|||
// Uses 1GB RAM per tested fork
|
||||
st.skipLoad(`^stStaticCall/static_Call1MB`)
|
||||
|
||||
// These tests fail as of https://github.com/ethereum/go-ethereum/pull/28666, since we
|
||||
// no longer delete "leftover storage" when deploying a contract.
|
||||
st.skipLoad(`^stSStoreTest/InitCollision\.json`)
|
||||
st.skipLoad(`^stRevertTest/RevertInCreateInInit\.json`)
|
||||
st.skipLoad(`^stExtCodeHash/dynamicAccountOverwriteEmpty\.json`)
|
||||
st.skipLoad(`^stCreate2/create2collisionStorage\.json`)
|
||||
st.skipLoad(`^stCreate2/RevertInCreateInInitCreate2\.json`)
|
||||
|
||||
// Broken tests:
|
||||
// EOF is not part of cancun
|
||||
st.skipLoad(`^stEOF/`)
|
||||
|
||||
// The tests under Pyspecs are the ones that are published as execution-spec tests.
|
||||
// We run these tests separately, no need to _also_ run them as part of the
|
||||
// reference tests.
|
||||
st.skipLoad(`^Pyspecs/`)
|
||||
}
|
||||
|
||||
func TestState(t *testing.T) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue