Skip to content

Commit 6aa2348

Browse files
Merge pull request ethereum#286 from roberto-bayardo/nother-merge
merge upstream geth v1.13.10 and v1.13.11 commits into op-geth
2 parents c19c873 + da80ca3 commit 6aa2348

File tree

162 files changed

+2261
-1583
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+2261
-1583
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
## Go Ethereum
22

3-
Official Golang execution layer implementation of the Ethereum protocol.
3+
Golang execution layer implementation of the Ethereum protocol.
44

55
[![API Reference](
6-
https://camo.githubusercontent.com/915b7be44ada53c290eb157634330494ebe3e30a/68747470733a2f2f676f646f632e6f72672f6769746875622e636f6d2f676f6c616e672f6764646f3f7374617475732e737667
6+
https://pkg.go.dev/badge/github.com/ethereum/go-ethereum
77
)](https://pkg.go.dev/github.com/ethereum/go-ethereum?tab=doc)
88
[![Go Report Card](https://goreportcard.com/badge/github.com/ethereum/go-ethereum)](https://goreportcard.com/report/github.com/ethereum/go-ethereum)
99
[![Travis](https://travis-ci.com/ethereum/go-ethereum.svg?branch=master)](https://travis-ci.com/ethereum/go-ethereum)

accounts/abi/bind/backends/simulated.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ func (b *SimulatedBackend) Fork(ctx context.Context, parentHash common.Hash) err
4545
// Deprecated: please use simulated.Backend from package
4646
// github.com/ethereum/go-ethereum/ethclient/simulated instead.
4747
func NewSimulatedBackend(alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
48-
b := simulated.New(alloc, gasLimit)
48+
b := simulated.NewBackend(alloc, simulated.WithBlockGasLimit(gasLimit))
4949
return &SimulatedBackend{
5050
Backend: b,
5151
Client: b.Client(),
5252
}
5353
}
5454

5555
func NewSimulatedBackendFromConfig(cfg ethconfig.Config) *SimulatedBackend {
56-
b := simulated.NewFromConfig(cfg)
56+
b := simulated.NewBackendFromConfig(cfg)
5757
return &SimulatedBackend{
5858
Backend: b,
5959
Client: b.Client(),

accounts/abi/bind/util_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,10 @@ var waitDeployedTests = map[string]struct {
5656
func TestWaitDeployed(t *testing.T) {
5757
t.Parallel()
5858
for name, test := range waitDeployedTests {
59-
backend := simulated.New(
59+
backend := simulated.NewBackend(
6060
core.GenesisAlloc{
6161
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000000000)},
6262
},
63-
10000000,
6463
)
6564
defer backend.Close()
6665

@@ -102,11 +101,10 @@ func TestWaitDeployed(t *testing.T) {
102101
}
103102

104103
func TestWaitDeployedCornerCases(t *testing.T) {
105-
backend := simulated.New(
104+
backend := simulated.NewBackend(
106105
core.GenesisAlloc{
107106
crypto.PubkeyToAddress(testKey.PublicKey): {Balance: big.NewInt(10000000000000000)},
108107
},
109-
10000000,
110108
)
111109
defer backend.Close()
112110

accounts/usbwallet/ledger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func (w *ledgerDriver) ledgerDerive(derivationPath []uint32) (common.Address, er
279279
}
280280
hexstr := reply[1 : 1+int(reply[0])]
281281

282-
// Decode the hex sting into an Ethereum address and return
282+
// Decode the hex string into an Ethereum address and return
283283
var address common.Address
284284
if _, err = hex.Decode(address[:], hexstr); err != nil {
285285
return common.Address{}, err

beacon/engine/types.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ import (
2626
"github.com/ethereum/go-ethereum/trie"
2727
)
2828

29+
// PayloadVersion denotes the version of PayloadAttributes used to request the
30+
// building of the payload to commence.
31+
type PayloadVersion byte
32+
33+
var (
34+
PayloadV1 PayloadVersion = 0x1
35+
PayloadV2 PayloadVersion = 0x2
36+
PayloadV3 PayloadVersion = 0x3
37+
)
38+
2939
//go:generate go run github.com/fjl/gencodec -type PayloadAttributes -field-override payloadAttributesMarshaling -out gen_blockparams.go
3040

3141
// PayloadAttributes describes the environment context in which a block should
@@ -129,6 +139,21 @@ type TransitionConfigurationV1 struct {
129139
// PayloadID is an identifier of the payload build process
130140
type PayloadID [8]byte
131141

142+
// Version returns the payload version associated with the identifier.
143+
func (b PayloadID) Version() PayloadVersion {
144+
return PayloadVersion(b[0])
145+
}
146+
147+
// Is returns whether the identifier matches any of provided payload versions.
148+
func (b PayloadID) Is(versions ...PayloadVersion) bool {
149+
for _, v := range versions {
150+
if v == b.Version() {
151+
return true
152+
}
153+
}
154+
return false
155+
}
156+
132157
func (b PayloadID) String() string {
133158
return hexutil.Encode(b[:])
134159
}

build/nsis.geth.nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# - NSIS Large Strings build, http://nsis.sourceforge.net/Special_Builds
2121
# - SFP, http://nsis.sourceforge.net/NSIS_Simple_Firewall_Plugin (put dll in NSIS\Plugins\x86-ansi)
2222
#
23-
# After intalling NSIS extra the NSIS Large Strings build zip and replace the makensis.exe and the
23+
# After installing NSIS extra the NSIS Large Strings build zip and replace the makensis.exe and the
2424
# files found in Stub.
2525
#
2626
# based on: http://nsis.sourceforge.net/A_simple_installer_with_start_menu_shortcut_and_uninstaller

cmd/devp2p/internal/ethtest/suite.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ func (s *Suite) EthTests() []utesting.Test {
7676
{Name: "TestMaliciousHandshake", Fn: s.TestMaliciousHandshake},
7777
{Name: "TestMaliciousStatus", Fn: s.TestMaliciousStatus},
7878
// test transactions
79+
{Name: "TestLargeTxRequest", Fn: s.TestLargeTxRequest, Slow: true},
7980
{Name: "TestTransaction", Fn: s.TestTransaction},
8081
{Name: "TestInvalidTxs", Fn: s.TestInvalidTxs},
81-
{Name: "TestLargeTxRequest", Fn: s.TestLargeTxRequest},
8282
{Name: "TestNewPooledTxs", Fn: s.TestNewPooledTxs},
8383
{Name: "TestBlobViolations", Fn: s.TestBlobViolations},
8484
}

cmd/devp2p/internal/ethtest/suite_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ func TestEthSuite(t *testing.T) {
6363
}
6464
for _, test := range suite.EthTests() {
6565
t.Run(test.Name, func(t *testing.T) {
66+
if test.Slow && testing.Short() {
67+
t.Skipf("%s: skipping in -short mode", test.Name)
68+
}
6669
result := utesting.RunTests([]utesting.Test{{Name: test.Name, Fn: test.Fn}}, os.Stdout)
6770
if result[0].Failed {
6871
t.Fatal()

cmd/devp2p/internal/v4test/discv4tests.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ func FindnodeAmplificationWrongIP(t *utesting.T) {
497497
// If we receive a NEIGHBORS response, the attack worked and the test fails.
498498
reply, _, _ := te.read(te.l2)
499499
if reply != nil {
500-
t.Error("Got NEIGHORS response for FINDNODE from wrong IP")
500+
t.Error("Got NEIGHBORS response for FINDNODE from wrong IP")
501501
}
502502
}
503503

cmd/evm/internal/t8ntool/execution.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"github.com/ethereum/go-ethereum/params"
3737
"github.com/ethereum/go-ethereum/rlp"
3838
"github.com/ethereum/go-ethereum/trie"
39+
"github.com/holiman/uint256"
3940
"golang.org/x/crypto/sha3"
4041
)
4142

@@ -308,15 +309,15 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
308309
reward.Sub(reward, new(big.Int).SetUint64(ommer.Delta))
309310
reward.Mul(reward, blockReward)
310311
reward.Div(reward, big.NewInt(8))
311-
statedb.AddBalance(ommer.Address, reward)
312+
statedb.AddBalance(ommer.Address, uint256.MustFromBig(reward))
312313
}
313-
statedb.AddBalance(pre.Env.Coinbase, minerReward)
314+
statedb.AddBalance(pre.Env.Coinbase, uint256.MustFromBig(minerReward))
314315
}
315316
// Apply withdrawals
316317
for _, w := range pre.Env.Withdrawals {
317318
// Amount is in gwei, turn into wei
318319
amount := new(big.Int).Mul(new(big.Int).SetUint64(w.Amount), big.NewInt(params.GWei))
319-
statedb.AddBalance(w.Address, amount)
320+
statedb.AddBalance(w.Address, uint256.MustFromBig(amount))
320321
}
321322
// Commit block
322323
root, err := statedb.Commit(vmContext.BlockNumber.Uint64(), chainConfig.IsEIP158(vmContext.BlockNumber))
@@ -359,7 +360,7 @@ func MakePreState(db ethdb.Database, accounts core.GenesisAlloc) *state.StateDB
359360
for addr, a := range accounts {
360361
statedb.SetCode(addr, a.Code)
361362
statedb.SetNonce(addr, a.Nonce)
362-
statedb.SetBalance(addr, a.Balance)
363+
statedb.SetBalance(addr, uint256.MustFromBig(a.Balance))
363364
for k, v := range a.Storage {
364365
statedb.SetState(addr, k, v)
365366
}

cmd/evm/internal/t8ntool/transition.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func Transition(ctx *cli.Context) error {
188188
if err != nil {
189189
return err
190190
}
191-
// Dump the excution result
191+
// Dump the execution result
192192
collector := make(Alloc)
193193
s.DumpToCollector(collector, nil)
194194
return dispatchOutput(ctx, baseDir, result, collector, body)
@@ -280,7 +280,7 @@ func (g Alloc) OnAccount(addr *common.Address, dumpAccount state.DumpAccount) {
280280
if addr == nil {
281281
return
282282
}
283-
balance, _ := new(big.Int).SetString(dumpAccount.Balance, 10)
283+
balance, _ := new(big.Int).SetString(dumpAccount.Balance, 0)
284284
var storage map[common.Hash]common.Hash
285285
if dumpAccount.Storage != nil {
286286
storage = make(map[common.Hash]common.Hash)

cmd/geth/logtestcmd_active.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"time"
2727

2828
"github.com/ethereum/go-ethereum/common"
29-
"github.com/ethereum/go-ethereum/internal/debug"
3029
"github.com/ethereum/go-ethereum/log"
3130
"github.com/holiman/uint256"
3231
"github.com/urfave/cli/v2"
@@ -51,9 +50,6 @@ func (c customQuotedStringer) String() string {
5150
// logTest is an entry point which spits out some logs. This is used by testing
5251
// to verify expected outputs
5352
func logTest(ctx *cli.Context) error {
54-
// clear field padding map
55-
debug.ResetLogging()
56-
5753
{ // big.Int
5854
ba, _ := new(big.Int).SetString("111222333444555678999", 10) // "111,222,333,444,555,678,999"
5955
bb, _ := new(big.Int).SetString("-111222333444555678999", 10) // "-111,222,333,444,555,678,999"

cmd/geth/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU General Public License
1515
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
1616

17-
// geth is the official command-line client for Ethereum.
17+
// geth is a command-line client for Ethereum.
1818
package main
1919

2020
import (

cmd/rlpdump/main.go

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ import (
2525
"flag"
2626
"fmt"
2727
"io"
28+
"math"
2829
"os"
30+
"strconv"
2931
"strings"
3032

3133
"github.com/ethereum/go-ethereum/common"
@@ -37,6 +39,7 @@ var (
3739
reverseMode = flag.Bool("reverse", false, "convert ASCII to rlp")
3840
noASCII = flag.Bool("noascii", false, "don't print ASCII strings readably")
3941
single = flag.Bool("single", false, "print only the first element, discard the rest")
42+
showpos = flag.Bool("pos", false, "display element byte posititions")
4043
)
4144

4245
func init() {
@@ -52,31 +55,37 @@ If the filename is omitted, data is read from stdin.`)
5255
func main() {
5356
flag.Parse()
5457

55-
var r io.Reader
58+
var r *inStream
5659
switch {
5760
case *hexMode != "":
5861
data, err := hex.DecodeString(strings.TrimPrefix(*hexMode, "0x"))
5962
if err != nil {
6063
die(err)
6164
}
62-
r = bytes.NewReader(data)
65+
r = newInStream(bytes.NewReader(data), int64(len(data)))
6366

6467
case flag.NArg() == 0:
65-
r = os.Stdin
68+
r = newInStream(bufio.NewReader(os.Stdin), 0)
6669

6770
case flag.NArg() == 1:
6871
fd, err := os.Open(flag.Arg(0))
6972
if err != nil {
7073
die(err)
7174
}
7275
defer fd.Close()
73-
r = fd
76+
var size int64
77+
finfo, err := fd.Stat()
78+
if err == nil {
79+
size = finfo.Size()
80+
}
81+
r = newInStream(bufio.NewReader(fd), size)
7482

7583
default:
7684
fmt.Fprintln(os.Stderr, "Error: too many arguments")
7785
flag.Usage()
7886
os.Exit(2)
7987
}
88+
8089
out := os.Stdout
8190
if *reverseMode {
8291
data, err := textToRlp(r)
@@ -93,10 +102,10 @@ func main() {
93102
}
94103
}
95104

96-
func rlpToText(r io.Reader, out io.Writer) error {
97-
s := rlp.NewStream(r, 0)
105+
func rlpToText(in *inStream, out io.Writer) error {
106+
stream := rlp.NewStream(in, 0)
98107
for {
99-
if err := dump(s, 0, out); err != nil {
108+
if err := dump(in, stream, 0, out); err != nil {
100109
if err != io.EOF {
101110
return err
102111
}
@@ -110,7 +119,10 @@ func rlpToText(r io.Reader, out io.Writer) error {
110119
return nil
111120
}
112121

113-
func dump(s *rlp.Stream, depth int, out io.Writer) error {
122+
func dump(in *inStream, s *rlp.Stream, depth int, out io.Writer) error {
123+
if *showpos {
124+
fmt.Fprintf(out, "%s: ", in.posLabel())
125+
}
114126
kind, size, err := s.Kind()
115127
if err != nil {
116128
return err
@@ -137,7 +149,7 @@ func dump(s *rlp.Stream, depth int, out io.Writer) error {
137149
if i > 0 {
138150
fmt.Fprint(out, ",\n")
139151
}
140-
if err := dump(s, depth+1, out); err == rlp.EOL {
152+
if err := dump(in, s, depth+1, out); err == rlp.EOL {
141153
break
142154
} else if err != nil {
143155
return err
@@ -208,3 +220,36 @@ func textToRlp(r io.Reader) ([]byte, error) {
208220
data, err := rlp.EncodeToBytes(obj[0])
209221
return data, err
210222
}
223+
224+
type inStream struct {
225+
br rlp.ByteReader
226+
pos int
227+
columns int
228+
}
229+
230+
func newInStream(br rlp.ByteReader, totalSize int64) *inStream {
231+
col := int(math.Ceil(math.Log10(float64(totalSize))))
232+
return &inStream{br: br, columns: col}
233+
}
234+
235+
func (rc *inStream) Read(b []byte) (n int, err error) {
236+
n, err = rc.br.Read(b)
237+
rc.pos += n
238+
return n, err
239+
}
240+
241+
func (rc *inStream) ReadByte() (byte, error) {
242+
b, err := rc.br.ReadByte()
243+
if err == nil {
244+
rc.pos++
245+
}
246+
return b, err
247+
}
248+
249+
func (rc *inStream) posLabel() string {
250+
l := strconv.FormatInt(int64(rc.pos), 10)
251+
if len(l) < rc.columns {
252+
l = strings.Repeat(" ", rc.columns-len(l)) + l
253+
}
254+
return l
255+
}

cmd/rlpdump/rlpdump_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ func TestRoundtrip(t *testing.T) {
3434
"0xc780c0c1c0825208",
3535
} {
3636
var out strings.Builder
37-
err := rlpToText(bytes.NewReader(common.FromHex(want)), &out)
37+
in := newInStream(bytes.NewReader(common.FromHex(want)), 0)
38+
err := rlpToText(in, &out)
3839
if err != nil {
3940
t.Fatal(err)
4041
}

common/big.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616

1717
package common
1818

19-
import "math/big"
19+
import (
20+
"math/big"
21+
22+
"github.com/holiman/uint256"
23+
)
2024

2125
// Common big integers often used
2226
var (
@@ -27,4 +31,6 @@ var (
2731
Big32 = big.NewInt(32)
2832
Big256 = big.NewInt(256)
2933
Big257 = big.NewInt(257)
34+
35+
U2560 = uint256.NewInt(0)
3036
)

0 commit comments

Comments
 (0)