Skip to content

Commit 9e38fd5

Browse files
authored
Merge pull request #1 from ethereum/master
Finalize New Ecosystem to Run
2 parents 5dd0fe2 + 15ff378 commit 9e38fd5

File tree

19 files changed

+187
-37
lines changed

19 files changed

+187
-37
lines changed

cmd/geth/config.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"github.com/ethereum/go-ethereum/beacon/blsync"
3636
"github.com/ethereum/go-ethereum/cmd/utils"
3737
"github.com/ethereum/go-ethereum/common"
38-
"github.com/ethereum/go-ethereum/common/hexutil"
3938
"github.com/ethereum/go-ethereum/crypto"
4039
"github.com/ethereum/go-ethereum/eth/catalyst"
4140
"github.com/ethereum/go-ethereum/eth/ethconfig"
@@ -273,11 +272,11 @@ func makeFullNode(ctx *cli.Context) *node.Node {
273272
// Configure synchronization override service
274273
var synctarget common.Hash
275274
if ctx.IsSet(utils.SyncTargetFlag.Name) {
276-
hex := hexutil.MustDecode(ctx.String(utils.SyncTargetFlag.Name))
277-
if len(hex) != common.HashLength {
278-
utils.Fatalf("invalid sync target length: have %d, want %d", len(hex), common.HashLength)
275+
target := ctx.String(utils.SyncTargetFlag.Name)
276+
if !common.IsHexHash(target) {
277+
utils.Fatalf("sync target hash is not a valid hex hash: %s", target)
279278
}
280-
synctarget = common.BytesToHash(hex)
279+
synctarget = common.HexToHash(target)
281280
}
282281
utils.RegisterSyncOverrideService(stack, eth, synctarget, ctx.Bool(utils.ExitWhenSyncedFlag.Name))
283282

cmd/geth/snapshot.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,11 +639,11 @@ func snapshotExportPreimages(ctx *cli.Context) error {
639639

640640
var root common.Hash
641641
if ctx.NArg() > 1 {
642-
rootBytes := common.FromHex(ctx.Args().Get(1))
643-
if len(rootBytes) != common.HashLength {
642+
hash := ctx.Args().Get(1)
643+
if !common.IsHexHash(hash) {
644644
return fmt.Errorf("invalid hash: %s", ctx.Args().Get(1))
645645
}
646-
root = common.BytesToHash(rootBytes)
646+
root = common.HexToHash(hash)
647647
} else {
648648
headBlock := rawdb.ReadHeadBlock(chaindb)
649649
if headBlock == nil {

cmd/keeper/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
1919
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
2020
github.com/emicklei/dot v1.6.2 // indirect
21-
github.com/ethereum/c-kzg-4844/v2 v2.1.3 // indirect
21+
github.com/ethereum/c-kzg-4844/v2 v2.1.5 // indirect
2222
github.com/ethereum/go-bigmodexpfix v0.0.0-20250911101455-f9e208c548ab // indirect
2323
github.com/ethereum/go-verkle v0.2.2 // indirect
2424
github.com/ferranbt/fastssz v0.1.4 // indirect

cmd/keeper/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1
4242
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
4343
github.com/emicklei/dot v1.6.2 h1:08GN+DD79cy/tzN6uLCT84+2Wk9u+wvqP+Hkx/dIR8A=
4444
github.com/emicklei/dot v1.6.2/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s=
45-
github.com/ethereum/c-kzg-4844/v2 v2.1.3 h1:DQ21UU0VSsuGy8+pcMJHDS0CV1bKmJmxsJYK8l3MiLU=
46-
github.com/ethereum/c-kzg-4844/v2 v2.1.3/go.mod h1:fyNcYI/yAuLWJxf4uzVtS8VDKeoAaRM8G/+ADz/pRdA=
45+
github.com/ethereum/c-kzg-4844/v2 v2.1.5 h1:aVtoLK5xwJ6c5RiqO8g8ptJ5KU+2Hdquf6G3aXiHh5s=
46+
github.com/ethereum/c-kzg-4844/v2 v2.1.5/go.mod h1:u59hRTTah4Co6i9fDWtiCjTrblJv0UwsqZKCc0GfgUs=
4747
github.com/ethereum/go-bigmodexpfix v0.0.0-20250911101455-f9e208c548ab h1:rvv6MJhy07IMfEKuARQ9TKojGqLVNxQajaXEp/BoqSk=
4848
github.com/ethereum/go-bigmodexpfix v0.0.0-20250911101455-f9e208c548ab/go.mod h1:IuLm4IsPipXKF7CW5Lzf68PIbZ5yl7FFd74l/E0o9A8=
4949
github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cnFk8=

common/format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (t PrettyAge) String() string {
6969
result, prec := "", 0
7070

7171
for _, unit := range ageUnits {
72-
if diff > unit.Size {
72+
if diff >= unit.Size {
7373
result = fmt.Sprintf("%s%d%s", result, diff/unit.Size, unit.Symbol)
7474
diff %= unit.Size
7575

common/path.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@
1717
package common
1818

1919
import (
20+
"errors"
21+
"io/fs"
2022
"os"
2123
"path/filepath"
2224
)
2325

2426
// FileExist checks if a file exists at filePath.
2527
func FileExist(filePath string) bool {
2628
_, err := os.Stat(filePath)
27-
if err != nil && os.IsNotExist(err) {
28-
return false
29-
}
30-
return true
29+
return !errors.Is(err, fs.ErrNotExist)
3130
}
3231

3332
// AbsolutePath returns datadir + filename, or filename if it is absolute.

common/size.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ type StorageSize float64
2626

2727
// String implements the stringer interface.
2828
func (s StorageSize) String() string {
29-
if s > 1099511627776 {
29+
if s >= 1099511627776 {
3030
return fmt.Sprintf("%.2f TiB", s/1099511627776)
31-
} else if s > 1073741824 {
31+
} else if s >= 1073741824 {
3232
return fmt.Sprintf("%.2f GiB", s/1073741824)
33-
} else if s > 1048576 {
33+
} else if s >= 1048576 {
3434
return fmt.Sprintf("%.2f MiB", s/1048576)
35-
} else if s > 1024 {
35+
} else if s >= 1024 {
3636
return fmt.Sprintf("%.2f KiB", s/1024)
3737
} else {
3838
return fmt.Sprintf("%.2f B", s)
@@ -42,13 +42,13 @@ func (s StorageSize) String() string {
4242
// TerminalString implements log.TerminalStringer, formatting a string for console
4343
// output during logging.
4444
func (s StorageSize) TerminalString() string {
45-
if s > 1099511627776 {
45+
if s >= 1099511627776 {
4646
return fmt.Sprintf("%.2fTiB", s/1099511627776)
47-
} else if s > 1073741824 {
47+
} else if s >= 1073741824 {
4848
return fmt.Sprintf("%.2fGiB", s/1073741824)
49-
} else if s > 1048576 {
49+
} else if s >= 1048576 {
5050
return fmt.Sprintf("%.2fMiB", s/1048576)
51-
} else if s > 1024 {
51+
} else if s >= 1024 {
5252
return fmt.Sprintf("%.2fKiB", s/1024)
5353
} else {
5454
return fmt.Sprintf("%.2fB", s)

common/types.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ func BigToHash(b *big.Int) Hash { return BytesToHash(b.Bytes()) }
7171
// If b is larger than len(h), b will be cropped from the left.
7272
func HexToHash(s string) Hash { return BytesToHash(FromHex(s)) }
7373

74+
// IsHexHash verifies whether a string can represent a valid hex-encoded
75+
// Ethereum hash or not.
76+
func IsHexHash(s string) bool {
77+
if has0xPrefix(s) {
78+
s = s[2:]
79+
}
80+
return len(s) == 2*HashLength && isHex(s)
81+
}
82+
7483
// Cmp compares two hashes.
7584
func (h Hash) Cmp(other Hash) int {
7685
return bytes.Compare(h[:], other[:])

core/forkid/forkid_test.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,16 @@ func TestCreation(t *testing.T) {
7676
{20000000, 1681338454, ID{Hash: checksumToBytes(0xf0afd0e3), Next: 1681338455}}, // Last Gray Glacier block
7777
{20000000, 1681338455, ID{Hash: checksumToBytes(0xdce96c2d), Next: 1710338135}}, // First Shanghai block
7878
{30000000, 1710338134, ID{Hash: checksumToBytes(0xdce96c2d), Next: 1710338135}}, // Last Shanghai block
79-
{40000000, 1710338135, ID{Hash: checksumToBytes(0x9f3d2254), Next: 1746612311}}, // First Cancun block
79+
{30000000, 1710338135, ID{Hash: checksumToBytes(0x9f3d2254), Next: 1746612311}}, // First Cancun block
8080
{30000000, 1746022486, ID{Hash: checksumToBytes(0x9f3d2254), Next: 1746612311}}, // Last Cancun block
81-
{30000000, 1746612311, ID{Hash: checksumToBytes(0xc376cf8b), Next: 0}}, // First Prague block
82-
{50000000, 2000000000, ID{Hash: checksumToBytes(0xc376cf8b), Next: 0}}, // Future Prague block
81+
{30000000, 1746612311, ID{Hash: checksumToBytes(0xc376cf8b), Next: 1764798551}}, // First Prague block
82+
{30000000, 1764798550, ID{Hash: checksumToBytes(0xc376cf8b), Next: 1764798551}}, // Last Prague block
83+
{30000000, 1764798551, ID{Hash: checksumToBytes(0x5167e2a6), Next: 1765290071}}, // First Osaka block
84+
{30000000, 1765290070, ID{Hash: checksumToBytes(0x5167e2a6), Next: 1765290071}}, // Last Osaka block
85+
{30000000, 1765290071, ID{Hash: checksumToBytes(0xcba2a1c0), Next: 1767747671}}, // First BPO1 block
86+
{30000000, 1767747670, ID{Hash: checksumToBytes(0xcba2a1c0), Next: 1767747671}}, // Last BPO1 block
87+
{30000000, 1767747671, ID{Hash: checksumToBytes(0x07c9462e), Next: 0}}, // First BPO2 block
88+
{50000000, 2000000000, ID{Hash: checksumToBytes(0x07c9462e), Next: 0}}, // Future BPO2 block
8389
},
8490
},
8591
// Sepolia test cases
@@ -162,6 +168,9 @@ func TestValidation(t *testing.T) {
162168
legacyConfig.ShanghaiTime = nil
163169
legacyConfig.CancunTime = nil
164170
legacyConfig.PragueTime = nil
171+
legacyConfig.OsakaTime = nil
172+
legacyConfig.BPO1Time = nil
173+
legacyConfig.BPO2Time = nil
165174

166175
tests := []struct {
167176
config *params.ChainConfig
@@ -361,11 +370,11 @@ func TestValidation(t *testing.T) {
361370
// Local is mainnet Shanghai, remote is random Shanghai.
362371
{params.MainnetChainConfig, 20000000, 1681338455, ID{Hash: checksumToBytes(0x12345678), Next: 0}, ErrLocalIncompatibleOrStale},
363372

364-
// Local is mainnet Prague, far in the future. Remote announces Gopherium (non existing fork)
373+
// Local is mainnet BPO2, far in the future. Remote announces Gopherium (non existing fork)
365374
// at some future timestamp 8888888888, for itself, but past block for local. Local is incompatible.
366375
//
367376
// This case detects non-upgraded nodes with majority hash power (typical Ropsten mess).
368-
{params.MainnetChainConfig, 88888888, 8888888888, ID{Hash: checksumToBytes(0xc376cf8b), Next: 8888888888}, ErrLocalIncompatibleOrStale},
377+
{params.MainnetChainConfig, 88888888, 8888888888, ID{Hash: checksumToBytes(0x07c9462e), Next: 8888888888}, ErrLocalIncompatibleOrStale},
369378

370379
// Local is mainnet Shanghai. Remote is also in Shanghai, but announces Gopherium (non existing
371380
// fork) at timestamp 1668000000, before Cancun. Local is incompatible.

core/rawdb/ancient_utils.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,23 @@ func inspectFreezers(db ethdb.Database) ([]freezerInfo, error) {
105105
}
106106
infos = append(infos, info)
107107

108+
case MerkleTrienodeFreezerName, VerkleTrienodeFreezerName:
109+
datadir, err := db.AncientDatadir()
110+
if err != nil {
111+
return nil, err
112+
}
113+
f, err := NewTrienodeFreezer(datadir, freezer == VerkleTrienodeFreezerName, true)
114+
if err != nil {
115+
continue // might be possible the trienode freezer is not existent
116+
}
117+
defer f.Close()
118+
119+
info, err := inspect(freezer, trienodeFreezerTableConfigs, f)
120+
if err != nil {
121+
return nil, err
122+
}
123+
infos = append(infos, info)
124+
108125
default:
109126
return nil, fmt.Errorf("unknown freezer, supported ones: %v", freezers)
110127
}

0 commit comments

Comments
 (0)