Skip to content

Commit

Permalink
Merge pull request #2380 from bnb-chain/develop
Browse files Browse the repository at this point in the history
Draft release v1.4.5
  • Loading branch information
zzzckck authored Apr 9, 2024
2 parents 46df9b4 + 4e9f699 commit 060e5c6
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 20 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Changelog
## v1.4.5
### FEATURE
* [\#2378](https://github.com/bnb-chain/bsc/pull/2378) config: setup Testnet Tycho(Cancun) hardfork date

### IMPROVEMENT
* [\#2333](https://github.com/bnb-chain/bsc/pull/2333) remove code that will not be executed
* [\#2369](https://github.com/bnb-chain/bsc/pull/2369) core: stateDb has no trie and no snap return err

### BUGFIX
* [\#2359](https://github.com/bnb-chain/bsc/pull/2359) triedb: do not open state freezer under notries

## v1.4.4
### FEATURE
* [\#2279](https://github.com/bnb-chain/bsc/pull/2279) BlobTx: implement EIP-4844 on BSC
Expand Down
3 changes: 0 additions & 3 deletions accounts/keystore/account_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ func TestUpdatedKeyfileContents(t *testing.T) {
// Now replace file contents
if err := forceCopyFile(file, cachetestAccounts[1].URL.Path); err != nil {
t.Fatal(err)
return
}
wantAccounts = []accounts.Account{cachetestAccounts[1]}
wantAccounts[0].URL = accounts.URL{Scheme: KeyStoreScheme, Path: file}
Expand All @@ -374,7 +373,6 @@ func TestUpdatedKeyfileContents(t *testing.T) {
// Now replace file contents again
if err := forceCopyFile(file, cachetestAccounts[2].URL.Path); err != nil {
t.Fatal(err)
return
}
wantAccounts = []accounts.Account{cachetestAccounts[2]}
wantAccounts[0].URL = accounts.URL{Scheme: KeyStoreScheme, Path: file}
Expand All @@ -390,7 +388,6 @@ func TestUpdatedKeyfileContents(t *testing.T) {
// Now replace file contents with crap
if err := os.WriteFile(file, []byte("foo"), 0600); err != nil {
t.Fatal(err)
return
}
if err := waitForAccounts([]accounts.Account{}, ks); err != nil {
t.Errorf("Emptying account file failed")
Expand Down
1 change: 0 additions & 1 deletion consensus/clique/snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ func (tt *cliqueTest) run(t *testing.T) {
for j := 0; j < len(batches)-1; j++ {
if k, err := chain.InsertChain(batches[j]); err != nil {
t.Fatalf("failed to import batch %d, block %d: %v", j, k, err)
break
}
}
if _, err = chain.InsertChain(batches[len(batches)-1]); err != tt.failure {
Expand Down
15 changes: 14 additions & 1 deletion core/blockchain_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,20 @@ func (bc *BlockChain) State() (*state.StateDB, error) {

// StateAt returns a new mutable state based on a particular point in time.
func (bc *BlockChain) StateAt(root common.Hash) (*state.StateDB, error) {
return state.New(root, bc.stateCache, bc.snaps)
stateDb, err := state.New(root, bc.stateCache, bc.snaps)
if err != nil {
return nil, err
}

// If there's no trie and the specified snapshot is not available, getting
// any state will by default return nil.
// Instead of that, it will be more useful to return an error to indicate
// the state is not available.
if stateDb.NoTrie() && stateDb.GetSnap() == nil {
return nil, errors.New("state is not available")
}

return stateDb, err
}

// Config retrieves the chain's fork configuration.
Expand Down
4 changes: 4 additions & 0 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,10 @@ func (s *StateDB) convertAccountSet(set map[common.Address]*types.StateAccount)
return ret
}

func (s *StateDB) GetSnap() snapshot.Snapshot {
return s.snap
}

// copySet returns a deep-copied set.
func copySet[k comparable](set map[k][]byte) map[k][]byte {
copied := make(map[k][]byte, len(set))
Expand Down
1 change: 0 additions & 1 deletion eth/fetcher/block_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,6 @@ func testInvalidNumberAnnouncement(t *testing.T, light bool) {
continue
case <-time.After(1 * time.Second):
t.Fatal("announce timeout")
return
}
}
}
Expand Down
1 change: 0 additions & 1 deletion eth/filters/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func benchmarkBloomBits(b *testing.B, sectionSize uint64) {
hash := rawdb.ReadCanonicalHash(db, i)
if header = rawdb.ReadHeader(db, hash, i); header == nil {
b.Fatalf("Error creating bloomBits data")
return
}
bc.AddBloom(uint(i-sectionIdx*sectionSize), header.Bloom)
}
Expand Down
2 changes: 0 additions & 2 deletions p2p/discover/v5_udp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -822,12 +822,10 @@ func (test *udpV5Test) waitPacketOut(validate interface{}) (closed bool) {
}
if err == errTimeout {
test.t.Fatalf("timed out waiting for %v", exptype)
return false
}
ln := test.nodesByIP[string(dgram.to.IP)]
if ln == nil {
test.t.Fatalf("attempt to send to non-existing node %v", &dgram.to)
return false
}
codec := &testCodec{test: test, id: ln.ID()}
frame, p, err := codec.decodeFrame(dgram.data)
Expand Down
12 changes: 5 additions & 7 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,11 @@ var (
LondonBlock: big.NewInt(31103030),
HertzBlock: big.NewInt(31103030),
HertzfixBlock: big.NewInt(35682300),
// UnixTime: 1702972800 is December 19, 2023 8:00:00 AM UTC
ShanghaiTime: newUint64(1702972800),
KeplerTime: newUint64(1702972800),
FeynmanTime: newUint64(1710136800),
FeynmanFixTime: newUint64(1711342800),
// TODO(GalaIO): enable cancun fork time later
//CancunTime: newUint64(),
ShanghaiTime: newUint64(1702972800), // 2023-12-19 8:00:00 AM UTC
KeplerTime: newUint64(1702972800),
FeynmanTime: newUint64(1710136800), // 2024-03-11 6:00:00 AM UTC
FeynmanFixTime: newUint64(1711342800), // 2024-03-25 5:00:00 AM UTC
CancunTime: newUint64(1713330442), // 2024-04-17 05:07:22 AM UTC

Parlia: &ParliaConfig{
Period: 3,
Expand Down
2 changes: 1 addition & 1 deletion params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 4 // Minor version component of the current release
VersionPatch = 4 // Patch version component of the current release
VersionPatch = 5 // Patch version component of the current release
VersionMeta = "" // Version metadata to append to the version string
)

Expand Down
2 changes: 0 additions & 2 deletions tests/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,9 @@ func runBenchmarkFile(b *testing.B, path string) {
m := make(map[string]StateTest)
if err := readJSONFile(path, &m); err != nil {
b.Fatal(err)
return
}
if len(m) != 1 {
b.Fatal("expected single benchmark in a file")
return
}
for _, t := range m {
t := t
Expand Down
3 changes: 3 additions & 0 deletions triedb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ func NewDatabase(diskdb ethdb.Database, config *Config) *Database {
config.HashDB = hashdb.Defaults
}
}
if config.PathDB != nil && config.NoTries {
config.PathDB.NoTries = true
}
var preimages *preimageStore
if config.Preimages {
preimages = newPreimageStore(triediskdb)
Expand Down
3 changes: 2 additions & 1 deletion triedb/pathdb/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type Config struct {
CleanCacheSize int // Maximum memory allowance (in bytes) for caching clean nodes
DirtyCacheSize int // Maximum memory allowance (in bytes) for caching dirty nodes
ReadOnly bool // Flag whether the database is opened in read only mode.
NoTries bool
}

// sanitize checks the provided user configurations and changes anything that's
Expand Down Expand Up @@ -174,7 +175,7 @@ func New(diskdb ethdb.Database, config *Config) *Database {
// Because the freezer can only be opened once at the same time, this
// mechanism also ensures that at most one **non-readOnly** database
// is opened at the same time to prevent accidental mutation.
if ancient, err := diskdb.AncientDatadir(); err == nil && ancient != "" && !db.readOnly {
if ancient, err := diskdb.AncientDatadir(); err == nil && ancient != "" && !db.readOnly && !config.NoTries {
offset := uint64(0) // differ from in block data, only metadata is used in state data
freezer, err := rawdb.NewStateFreezer(ancient, false, offset)
if err != nil {
Expand Down

0 comments on commit 060e5c6

Please sign in to comment.