diff --git a/CHANGELOG.md b/CHANGELOG.md index c6a181673fb4..1dc45f80820c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,18 @@ # Changelog +## v1.3.9 +FEATURE +* [\#2186](https://github.com/bnb-chain/bsc/pull/2186) log: support maxBackups in config.toml + +BUGFIX +* [\#2160](https://github.com/bnb-chain/bsc/pull/2160) cmd: fix dump cli cannot work in path mode +* [\#2183](https://github.com/bnb-chain/bsc/pull/2183) p2p: resolved deadlock on p2p server shutdown + +IMPROVEMENT +* [\#2177](https://github.com/bnb-chain/bsc/pull/0000) build(deps): bump github.com/quic-go/quic-go from 0.39.3 to 0.39.4 +* [\#2185](https://github.com/bnb-chain/bsc/pull/2185) consensus/parlia: set nonce before evm run +* [\#2190](https://github.com/bnb-chain/bsc/pull/2190) fix(legacypool): deprecate already known error +* [\#2195](https://github.com/bnb-chain/bsc/pull/2195) eth/fetcher: downgrade state tx log + ## v1.3.8 FEATURE * [\#2074](https://github.com/bnb-chain/bsc/pull/2074) faucet: new faucet client diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 8b5785baeaf3..9e80bdebde6c 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -18,7 +18,6 @@ package utils import ( - "bufio" "context" "crypto/ecdsa" "encoding/hex" @@ -1904,7 +1903,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { if ctx.IsSet(StateHistoryFlag.Name) { cfg.StateHistory = ctx.Uint64(StateHistoryFlag.Name) } - scheme, err := CompareStateSchemeCLIWithConfig(ctx) + scheme, err := ParseCLIAndConfigStateScheme(ctx.String(StateSchemeFlag.Name), cfg.StateScheme) if err != nil { Fatalf("%v", err) } @@ -2395,11 +2394,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh if gcmode := ctx.String(GCModeFlag.Name); gcmode != "full" && gcmode != "archive" { Fatalf("--%s must be either 'full' or 'archive'", GCModeFlag.Name) } - provided, err := CompareStateSchemeCLIWithConfig(ctx) - if err != nil { - Fatalf("%v", err) - } - scheme, err := rawdb.ParseStateScheme(provided, chainDb) + scheme, err := rawdb.ParseStateScheme(ctx.String(StateSchemeFlag.Name), chainDb) if err != nil { Fatalf("%v", err) } @@ -2468,11 +2463,7 @@ func MakeTrieDatabase(ctx *cli.Context, disk ethdb.Database, preimage bool, read Preimages: preimage, IsVerkle: isVerkle, } - provided, err := CompareStateSchemeCLIWithConfig(ctx) - if err != nil { - Fatalf("%v", err) - } - scheme, err := rawdb.ParseStateScheme(provided, disk) + scheme, err := rawdb.ParseStateScheme(ctx.String(StateSchemeFlag.Name), disk) if err != nil { Fatalf("%v", err) } @@ -2491,27 +2482,15 @@ func MakeTrieDatabase(ctx *cli.Context, disk ethdb.Database, preimage bool, read return trie.NewDatabase(disk, config) } -// CompareStateSchemeCLIWithConfig compare state scheme in CLI with config whether are equal. -func CompareStateSchemeCLIWithConfig(ctx *cli.Context) (string, error) { - var ( - cfgScheme string - err error - ) - if file := ctx.String("config"); file != "" { - // we don't validate cfgScheme because it's already checked in cmd/geth/loadBaseConfig - if cfgScheme, err = scanConfigForStateScheme(file); err != nil { - log.Error("Failed to parse config file", "error", err) - return "", err - } - } - if !ctx.IsSet(StateSchemeFlag.Name) { +// ParseCLIAndConfigStateScheme parses state scheme in CLI and config. +func ParseCLIAndConfigStateScheme(cliScheme, cfgScheme string) (string, error) { + if cliScheme == "" { if cfgScheme != "" { log.Info("Use config state scheme", "config", cfgScheme) } return cfgScheme, nil } - cliScheme := ctx.String(StateSchemeFlag.Name) if !rawdb.ValidateStateScheme(cliScheme) { return "", fmt.Errorf("invalid state scheme in CLI: %s", cliScheme) } @@ -2521,35 +2500,3 @@ func CompareStateSchemeCLIWithConfig(ctx *cli.Context) (string, error) { } return "", fmt.Errorf("incompatible state scheme, CLI: %s, config: %s", cliScheme, cfgScheme) } - -func scanConfigForStateScheme(file string) (string, error) { - f, err := os.Open(file) - if err != nil { - return "", err - } - defer f.Close() - - scanner := bufio.NewScanner(f) - targetStr := "StateScheme" - for scanner.Scan() { - line := scanner.Text() - if strings.Contains(line, targetStr) { - return indexStateScheme(line), nil - } - } - - if err = scanner.Err(); err != nil { - return "", err - } - return "", nil -} - -func indexStateScheme(str string) string { - i1 := strings.Index(str, "\"") - i2 := strings.LastIndex(str, "\"") - - if i1 != -1 && i2 != -1 && i1 < i2 { - return str[i1+1 : i2] - } - return "" -} diff --git a/cmd/utils/flags_test.go b/cmd/utils/flags_test.go index 8f03b423895d..00c73a5264c0 100644 --- a/cmd/utils/flags_test.go +++ b/cmd/utils/flags_test.go @@ -18,13 +18,8 @@ package utils import ( - "os" "reflect" "testing" - - "github.com/stretchr/testify/assert" - - "github.com/ethereum/go-ethereum/core/rawdb" ) func Test_SplitTagsFlag(t *testing.T) { @@ -70,126 +65,3 @@ func Test_SplitTagsFlag(t *testing.T) { }) } } - -func Test_parseConfig(t *testing.T) { - tests := []struct { - name string - fn func() string - wantedResult string - wantedIsErr bool - wantedErrStr string - }{ - { - name: "path", - fn: func() string { - tomlString := `[Eth]NetworkId = 56StateScheme = "path"` - return createTempTomlFile(t, tomlString) - }, - wantedResult: rawdb.PathScheme, - wantedIsErr: false, - wantedErrStr: "", - }, - { - name: "hash", - fn: func() string { - tomlString := `[Eth]NetworkId = 56StateScheme = "hash"` - return createTempTomlFile(t, tomlString) - }, - wantedResult: rawdb.HashScheme, - wantedIsErr: false, - wantedErrStr: "", - }, - { - name: "empty state scheme", - fn: func() string { - tomlString := `[Eth]NetworkId = 56StateScheme = ""` - return createTempTomlFile(t, tomlString) - }, - wantedResult: "", - wantedIsErr: false, - wantedErrStr: "", - }, - { - name: "unset state scheme", - fn: func() string { - tomlString := `[Eth]NetworkId = 56` - return createTempTomlFile(t, tomlString) - }, - wantedResult: "", - wantedIsErr: false, - wantedErrStr: "", - }, - { - name: "failed to open file", - fn: func() string { return "" }, - wantedResult: "", - wantedIsErr: true, - wantedErrStr: "open : no such file or directory", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - result, err := scanConfigForStateScheme(tt.fn()) - if tt.wantedIsErr { - assert.Contains(t, err.Error(), tt.wantedErrStr) - } else { - assert.Nil(t, err) - } - assert.Equal(t, tt.wantedResult, result) - }) - } -} - -// createTempTomlFile is a helper function to create a temp file with the provided TOML content -func createTempTomlFile(t *testing.T, content string) string { - t.Helper() - - dir := t.TempDir() - file, err := os.CreateTemp(dir, "config.toml") - if err != nil { - t.Fatalf("Unable to create temporary file: %v", err) - } - defer file.Close() - - _, err = file.WriteString(content) - if err != nil { - t.Fatalf("Unable to write to temporary file: %v", err) - } - return file.Name() -} - -func Test_parseString(t *testing.T) { - tests := []struct { - name string - arg string - wantResult string - }{ - { - name: "hash string", - arg: "\"hash\"", - wantResult: rawdb.HashScheme, - }, - { - name: "path string", - arg: "\"path\"", - wantResult: rawdb.PathScheme, - }, - { - name: "empty string", - arg: "", - wantResult: "", - }, - { - name: "empty string", - arg: "\"\"", - wantResult: "", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := indexStateScheme(tt.arg); got != tt.wantResult { - t.Errorf("parseString() = %v, want %v", got, tt.wantResult) - } - }) - } -} diff --git a/core/rawdb/accessors_trie.go b/core/rawdb/accessors_trie.go index bc18f1cd71f2..215d63bebb31 100644 --- a/core/rawdb/accessors_trie.go +++ b/core/rawdb/accessors_trie.go @@ -340,7 +340,7 @@ func ParseStateScheme(provided string, disk ethdb.Database) (string, error) { if stored == "" { // use default scheme for empty database, flip it when // path mode is chosen as default - log.Info("State schema set to default", "scheme", "hash") + log.Info("State scheme set to default", "scheme", "hash") return HashScheme, nil } log.Info("State scheme set to already existing disk db", "scheme", stored) diff --git a/params/version.go b/params/version.go index 344df6518a29..4bf65444c1f9 100644 --- a/params/version.go +++ b/params/version.go @@ -23,7 +23,7 @@ import ( const ( VersionMajor = 1 // Major version component of the current release VersionMinor = 3 // Minor version component of the current release - VersionPatch = 8 // Patch version component of the current release + VersionPatch = 9 // Patch version component of the current release VersionMeta = "" // Version metadata to append to the version string )