Skip to content

Commit c3d9ca6

Browse files
authored
all: release go-ethereum v1.13.7
2 parents da6cdaf + 3fd5688 commit c3d9ca6

File tree

10 files changed

+135
-39
lines changed

10 files changed

+135
-39
lines changed

.travis.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@ jobs:
99
- azure-osx
1010

1111
include:
12-
# This builder only tests code linters on latest version of Go
13-
- stage: lint
14-
os: linux
15-
dist: bionic
16-
go: 1.21.x
17-
env:
18-
- lint
19-
git:
20-
submodules: false # avoid cloning ethereum/tests
21-
script:
22-
- go run build/ci.go lint
23-
2412
# These builders create the Docker sub-images for multi-arch push and each
2513
# will attempt to push the multi-arch image if they are the last builder
2614
- stage: build

build/ci.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ func doLint(cmdline []string) {
366366

367367
linter := downloadLinter(*cachedir)
368368
lflags := []string{"run", "--config", ".golangci.yml"}
369-
build.MustRunCommand(linter, append(lflags, packages...)...)
369+
build.MustRunCommandWithOutput(linter, append(lflags, packages...)...)
370370
fmt.Println("You have achieved perfection.")
371371
}
372372

core/rawdb/freezer_table.go

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,20 @@ func (t *freezerTable) truncateHead(items uint64) error {
467467
return nil
468468
}
469469

470+
// sizeHidden returns the total data size of hidden items in the freezer table.
471+
// This function assumes the lock is already held.
472+
func (t *freezerTable) sizeHidden() (uint64, error) {
473+
hidden, offset := t.itemHidden.Load(), t.itemOffset.Load()
474+
if hidden <= offset {
475+
return 0, nil
476+
}
477+
indices, err := t.getIndices(hidden-1, 1)
478+
if err != nil {
479+
return 0, err
480+
}
481+
return uint64(indices[1].offset), nil
482+
}
483+
470484
// truncateTail discards any recent data before the provided threshold number.
471485
func (t *freezerTable) truncateTail(items uint64) error {
472486
t.lock.Lock()
@@ -495,6 +509,12 @@ func (t *freezerTable) truncateTail(items uint64) error {
495509
newTail.unmarshalBinary(buffer)
496510
newTailId = newTail.filenum
497511
}
512+
// Save the old size for metrics tracking. This needs to be done
513+
// before any updates to either itemHidden or itemOffset.
514+
oldSize, err := t.sizeNolock()
515+
if err != nil {
516+
return err
517+
}
498518
// Update the virtual tail marker and hidden these entries in table.
499519
t.itemHidden.Store(items)
500520
if err := writeMetadata(t.meta, newMetadata(items)); err != nil {
@@ -509,18 +529,12 @@ func (t *freezerTable) truncateTail(items uint64) error {
509529
if t.tailId > newTailId {
510530
return fmt.Errorf("invalid index, tail-file %d, item-file %d", t.tailId, newTailId)
511531
}
512-
// Hidden items exceed the current tail file, drop the relevant
513-
// data files. We need to truncate, save the old size for metrics
514-
// tracking.
515-
oldSize, err := t.sizeNolock()
516-
if err != nil {
517-
return err
518-
}
519532
// Count how many items can be deleted from the file.
520533
var (
521534
newDeleted = items
522535
deleted = t.itemOffset.Load()
523536
)
537+
// Hidden items exceed the current tail file, drop the relevant data files.
524538
for current := items - 1; current >= deleted; current -= 1 {
525539
if _, err := t.index.ReadAt(buffer, int64((current-deleted+1)*indexEntrySize)); err != nil {
526540
return err
@@ -680,6 +694,7 @@ func (t *freezerTable) releaseFilesBefore(num uint32, remove bool) {
680694
func (t *freezerTable) getIndices(from, count uint64) ([]*indexEntry, error) {
681695
// Apply the table-offset
682696
from = from - t.itemOffset.Load()
697+
683698
// For reading N items, we need N+1 indices.
684699
buffer := make([]byte, (count+1)*indexEntrySize)
685700
if _, err := t.index.ReadAt(buffer, int64(from*indexEntrySize)); err != nil {
@@ -870,14 +885,18 @@ func (t *freezerTable) size() (uint64, error) {
870885
return t.sizeNolock()
871886
}
872887

873-
// sizeNolock returns the total data size in the freezer table without obtaining
874-
// the mutex first.
888+
// sizeNolock returns the total data size in the freezer table. This function
889+
// assumes the lock is already held.
875890
func (t *freezerTable) sizeNolock() (uint64, error) {
876891
stat, err := t.index.Stat()
877892
if err != nil {
878893
return 0, err
879894
}
880-
total := uint64(t.maxFileSize)*uint64(t.headId-t.tailId) + uint64(t.headBytes) + uint64(stat.Size())
895+
hidden, err := t.sizeHidden()
896+
if err != nil {
897+
return 0, err
898+
}
899+
total := uint64(t.maxFileSize)*uint64(t.headId-t.tailId) + uint64(t.headBytes) + uint64(stat.Size()) - hidden
881900
return total, nil
882901
}
883902

core/rawdb/freezer_table_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,13 @@ func TestFreezerOffset(t *testing.T) {
658658
}
659659
}
660660

661+
func assertTableSize(t *testing.T, f *freezerTable, size int) {
662+
t.Helper()
663+
if got, err := f.size(); got != uint64(size) {
664+
t.Fatalf("expected size of %d bytes, got %d, err: %v", size, got, err)
665+
}
666+
}
667+
661668
func TestTruncateTail(t *testing.T) {
662669
t.Parallel()
663670
rm, wm, sg := metrics.NewMeter(), metrics.NewMeter(), metrics.NewGauge()
@@ -692,6 +699,9 @@ func TestTruncateTail(t *testing.T) {
692699
5: getChunk(20, 0xaa),
693700
6: getChunk(20, 0x11),
694701
})
702+
// maxFileSize*fileCount + headBytes + indexFileSize - hiddenBytes
703+
expected := 20*7 + 48 - 0
704+
assertTableSize(t, f, expected)
695705

696706
// truncate single element( item 0 ), deletion is only supported at file level
697707
f.truncateTail(1)
@@ -707,6 +717,8 @@ func TestTruncateTail(t *testing.T) {
707717
5: getChunk(20, 0xaa),
708718
6: getChunk(20, 0x11),
709719
})
720+
expected = 20*7 + 48 - 20
721+
assertTableSize(t, f, expected)
710722

711723
// Reopen the table, the deletion information should be persisted as well
712724
f.Close()
@@ -739,6 +751,8 @@ func TestTruncateTail(t *testing.T) {
739751
5: getChunk(20, 0xaa),
740752
6: getChunk(20, 0x11),
741753
})
754+
expected = 20*5 + 36 - 0
755+
assertTableSize(t, f, expected)
742756

743757
// Reopen the table, the above testing should still pass
744758
f.Close()
@@ -760,6 +774,23 @@ func TestTruncateTail(t *testing.T) {
760774
6: getChunk(20, 0x11),
761775
})
762776

777+
// truncate 3 more elements( item 2, 3, 4), the file 1 should be deleted
778+
// file 2 should only contain item 5
779+
f.truncateTail(5)
780+
checkRetrieveError(t, f, map[uint64]error{
781+
0: errOutOfBounds,
782+
1: errOutOfBounds,
783+
2: errOutOfBounds,
784+
3: errOutOfBounds,
785+
4: errOutOfBounds,
786+
})
787+
checkRetrieve(t, f, map[uint64][]byte{
788+
5: getChunk(20, 0xaa),
789+
6: getChunk(20, 0x11),
790+
})
791+
expected = 20*3 + 24 - 20
792+
assertTableSize(t, f, expected)
793+
763794
// truncate all, the entire freezer should be deleted
764795
f.truncateTail(7)
765796
checkRetrieveError(t, f, map[uint64]error{
@@ -771,6 +802,8 @@ func TestTruncateTail(t *testing.T) {
771802
5: errOutOfBounds,
772803
6: errOutOfBounds,
773804
})
805+
expected = 12
806+
assertTableSize(t, f, expected)
774807
}
775808

776809
func TestTruncateHead(t *testing.T) {

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ require (
6262
github.com/tyler-smith/go-bip39 v1.1.0
6363
github.com/urfave/cli/v2 v2.25.7
6464
go.uber.org/automaxprocs v1.5.2
65-
golang.org/x/crypto v0.15.0
65+
golang.org/x/crypto v0.17.0
6666
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
6767
golang.org/x/sync v0.5.0
68-
golang.org/x/sys v0.14.0
68+
golang.org/x/sys v0.15.0
6969
golang.org/x/text v0.14.0
7070
golang.org/x/time v0.3.0
7171
golang.org/x/tools v0.15.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
614614
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
615615
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
616616
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
617-
golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=
618-
golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g=
617+
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
618+
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
619619
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
620620
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
621621
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@@ -774,8 +774,8 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc
774774
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
775775
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
776776
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
777-
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
778-
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
777+
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
778+
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
779779
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
780780
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
781781
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=

internal/build/util.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,25 @@ func MustRunCommand(cmd string, args ...string) {
6868
MustRun(exec.Command(cmd, args...))
6969
}
7070

71+
func MustRunCommandWithOutput(cmd string, args ...string) {
72+
var done chan bool
73+
// This is a little loop to generate some output, so CI does not tear down the
74+
// process after 300 seconds.
75+
go func() {
76+
for i := 0; i < 15; i++ {
77+
fmt.Printf("Waiting for command %q\n", cmd)
78+
select {
79+
case <-time.After(time.Minute):
80+
break
81+
case <-done:
82+
return
83+
}
84+
}
85+
}()
86+
MustRun(exec.Command(cmd, args...))
87+
close(done)
88+
}
89+
7190
var warnedAboutGit bool
7291

7392
// RunGit runs a git subcommand and returns its output.

internal/ethapi/transaction_args.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,35 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro
137137
if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) {
138138
return errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
139139
}
140-
// If the tx has completely specified a fee mechanism, no default is needed. This allows users
141-
// who are not yet synced past London to get defaults for other tx values. See
142-
// https://github.com/ethereum/go-ethereum/pull/23274 for more information.
140+
// If the tx has completely specified a fee mechanism, no default is needed.
141+
// This allows users who are not yet synced past London to get defaults for
142+
// other tx values. See https://github.com/ethereum/go-ethereum/pull/23274
143+
// for more information.
143144
eip1559ParamsSet := args.MaxFeePerGas != nil && args.MaxPriorityFeePerGas != nil
144-
if (args.GasPrice != nil && !eip1559ParamsSet) || (args.GasPrice == nil && eip1559ParamsSet) {
145-
// Sanity check the EIP-1559 fee parameters if present.
146-
if args.GasPrice == nil && args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 {
145+
146+
// Sanity check the EIP-1559 fee parameters if present.
147+
if args.GasPrice == nil && eip1559ParamsSet {
148+
if args.MaxFeePerGas.ToInt().Sign() == 0 {
149+
return errors.New("maxFeePerGas must be non-zero")
150+
}
151+
if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 {
147152
return fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas)
148153
}
149-
return nil
154+
return nil // No need to set anything, user already set MaxFeePerGas and MaxPriorityFeePerGas
150155
}
151-
// Now attempt to fill in default value depending on whether London is active or not.
156+
// Sanity check the non-EIP-1559 fee parameters.
152157
head := b.CurrentHeader()
153-
if b.ChainConfig().IsLondon(head.Number) {
158+
isLondon := b.ChainConfig().IsLondon(head.Number)
159+
if args.GasPrice != nil && !eip1559ParamsSet {
160+
// Zero gas-price is not allowed after London fork
161+
if args.GasPrice.ToInt().Sign() == 0 && isLondon {
162+
return errors.New("gasPrice must be non-zero after london fork")
163+
}
164+
return nil // No need to set anything, user already set GasPrice
165+
}
166+
167+
// Now attempt to fill in default value depending on whether London is active or not.
168+
if isLondon {
154169
// London is active, set maxPriorityFeePerGas and maxFeePerGas.
155170
if err := args.setLondonFeeDefaults(ctx, head, b); err != nil {
156171
return err

internal/ethapi/transaction_args_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func TestSetFeeDefaults(t *testing.T) {
5252

5353
var (
5454
b = newBackendMock()
55+
zero = (*hexutil.Big)(big.NewInt(0))
5556
fortytwo = (*hexutil.Big)(big.NewInt(42))
5657
maxFee = (*hexutil.Big)(new(big.Int).Add(new(big.Int).Mul(b.current.BaseFee, big.NewInt(2)), fortytwo.ToInt()))
5758
al = &types.AccessList{types.AccessTuple{Address: common.Address{0xaa}, StorageKeys: []common.Hash{{0x01}}}}
@@ -66,13 +67,27 @@ func TestSetFeeDefaults(t *testing.T) {
6667
&TransactionArgs{GasPrice: fortytwo},
6768
nil,
6869
},
70+
{
71+
"legacy tx pre-London with zero price",
72+
false,
73+
&TransactionArgs{GasPrice: zero},
74+
&TransactionArgs{GasPrice: zero},
75+
nil,
76+
},
6977
{
7078
"legacy tx post-London, explicit gas price",
7179
true,
7280
&TransactionArgs{GasPrice: fortytwo},
7381
&TransactionArgs{GasPrice: fortytwo},
7482
nil,
7583
},
84+
{
85+
"legacy tx post-London with zero price",
86+
true,
87+
&TransactionArgs{GasPrice: zero},
88+
nil,
89+
errors.New("gasPrice must be non-zero after london fork"),
90+
},
7691

7792
// Access list txs
7893
{
@@ -161,6 +176,13 @@ func TestSetFeeDefaults(t *testing.T) {
161176
nil,
162177
errors.New("maxFeePerGas (0x7) < maxPriorityFeePerGas (0x2a)"),
163178
},
179+
{
180+
"dynamic fee tx post-London, explicit gas price",
181+
true,
182+
&TransactionArgs{MaxFeePerGas: zero, MaxPriorityFeePerGas: zero},
183+
nil,
184+
errors.New("maxFeePerGas must be non-zero"),
185+
},
164186

165187
// Misc
166188
{

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
const (
2424
VersionMajor = 1 // Major version component of the current release
2525
VersionMinor = 13 // Minor version component of the current release
26-
VersionPatch = 6 // Patch version component of the current release
26+
VersionPatch = 7 // Patch version component of the current release
2727
VersionMeta = "stable" // Version metadata to append to the version string
2828
)
2929

0 commit comments

Comments
 (0)