Compare commits
1 Commits
v1.4.13
...
integratio
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d33ca4f108 |
28
CHANGELOG.md
28
CHANGELOG.md
@@ -1,31 +1,4 @@
|
||||
# Changelog
|
||||
## v1.4.13
|
||||
|
||||
### BUGFIX
|
||||
* [\#2602](https://github.com/bnb-chain/bsc/pull/2602) fix: prune-state when specify --triesInMemory 32
|
||||
* [\#2579](https://github.com/bnb-chain/bsc/pull/00025790) fix: only take non-mempool tx to calculate bid price
|
||||
|
||||
### FEATURE
|
||||
* [\#2634](https://github.com/bnb-chain/bsc/pull/2634) config: setup Testnet Bohr hardfork date
|
||||
* [\#2482](https://github.com/bnb-chain/bsc/pull/2482) BEP-341: Validators can produce consecutive blocks
|
||||
* [\#2502](https://github.com/bnb-chain/bsc/pull/2502) BEP-402: Complete Missing Fields in Block Header to Generate Signature
|
||||
* [\#2558](https://github.com/bnb-chain/bsc/pull/2558) BEP-404: Clear Miner History when Switching Validators Set
|
||||
* [\#2605](https://github.com/bnb-chain/bsc/pull/2605) feat: add bohr upgrade contracts bytecode
|
||||
* [\#2614](https://github.com/bnb-chain/bsc/pull/2614) fix: update stakehub bytecode after zero address agent issue fixed
|
||||
* [\#2608](https://github.com/bnb-chain/bsc/pull/2608) consensus/parlia: modify mining time for last block in one turn
|
||||
* [\#2618](https://github.com/bnb-chain/bsc/pull/2618) consensus/parlia: exclude inturn validator when calculate backoffTime
|
||||
* [\#2621](https://github.com/bnb-chain/bsc/pull/2621) core: not record zero hash beacon block root with Parlia engine
|
||||
|
||||
### IMPROVEMENT
|
||||
* [\#2589](https://github.com/bnb-chain/bsc/pull/2589) core/vote: vote before committing state and writing block
|
||||
* [\#2596](https://github.com/bnb-chain/bsc/pull/2596) core: improve the network stability when double sign happens
|
||||
* [\#2600](https://github.com/bnb-chain/bsc/pull/2600) core: cache block after wroten into db
|
||||
* [\#2629](https://github.com/bnb-chain/bsc/pull/2629) utils: add GetTopAddr to analyse large traffic
|
||||
* [\#2591](https://github.com/bnb-chain/bsc/pull/2591) consensus/parlia: add GetJustifiedNumber and GetFinalizedNumber
|
||||
* [\#2611](https://github.com/bnb-chain/bsc/pull/2611) cmd/utils: add new flag OverridePassedForkTime
|
||||
* [\#2603](https://github.com/bnb-chain/bsc/pull/2603) faucet: rate limit initial implementation
|
||||
* [\#2622](https://github.com/bnb-chain/bsc/pull/2622) tests: fix evm-test CI
|
||||
* [\#2628](https://github.com/bnb-chain/bsc/pull/2628) Makefile: use docker compose v2 instead of v1
|
||||
|
||||
## v1.4.12
|
||||
|
||||
@@ -62,6 +35,7 @@
|
||||
* [\#2534](https://github.com/bnb-chain/bsc/pull/2534) fix: nil pointer when clear simulating bid
|
||||
* [\#2535](https://github.com/bnb-chain/bsc/pull/2535) upgrade: add HaberFix hardfork
|
||||
|
||||
|
||||
## v1.4.10
|
||||
### FEATURE
|
||||
NA
|
||||
|
||||
@@ -54,7 +54,7 @@ const (
|
||||
inMemoryHeaders = 86400 // Number of recent headers to keep in memory for double sign detection,
|
||||
|
||||
checkpointInterval = 1024 // Number of blocks after which to save the snapshot to the database
|
||||
defaultEpochLength = uint64(200) // Default number of blocks of checkpoint to update validatorSet from contract
|
||||
defaultEpochLength = uint64(100) // Default number of blocks of checkpoint to update validatorSet from contract
|
||||
defaultTurnLength = uint8(1) // Default consecutive number of blocks a validator receives priority for block production
|
||||
|
||||
extraVanity = 32 // Fixed number of extra-data prefix bytes reserved for signer vanity
|
||||
@@ -739,28 +739,13 @@ func (p *Parlia) snapshot(chain consensus.ChainHeaderReader, number uint64, hash
|
||||
}
|
||||
}
|
||||
|
||||
// If we're at the genesis, snapshot the initial state. Alternatively if we have
|
||||
// piled up more headers than allowed to be reorged (chain reinit from a freezer),
|
||||
// consider the checkpoint trusted and snapshot it.
|
||||
// An offset `p.config.Epoch - 1` can ensure getting the right validators.
|
||||
if number == 0 || ((number+1)%p.config.Epoch == 0 && (len(headers) > int(params.FullImmutabilityThreshold))) {
|
||||
var (
|
||||
checkpoint *types.Header
|
||||
blockHash common.Hash
|
||||
)
|
||||
if number == 0 {
|
||||
checkpoint = chain.GetHeaderByNumber(0)
|
||||
if checkpoint != nil {
|
||||
blockHash = checkpoint.Hash()
|
||||
}
|
||||
} else {
|
||||
checkpoint = chain.GetHeaderByNumber(number + 1 - p.config.Epoch)
|
||||
blockHeader := chain.GetHeaderByNumber(number)
|
||||
if blockHeader != nil {
|
||||
blockHash = blockHeader.Hash()
|
||||
}
|
||||
}
|
||||
if checkpoint != nil && blockHash != (common.Hash{}) {
|
||||
// If we're at the genesis, snapshot the initial state.
|
||||
if number == 0 {
|
||||
checkpoint := chain.GetHeaderByNumber(number)
|
||||
if checkpoint != nil {
|
||||
// get checkpoint data
|
||||
hash := checkpoint.Hash()
|
||||
|
||||
// get validators from headers
|
||||
validators, voteAddrs, err := parseValidators(checkpoint, p.chainConfig, p.config)
|
||||
if err != nil {
|
||||
@@ -768,27 +753,11 @@ func (p *Parlia) snapshot(chain consensus.ChainHeaderReader, number uint64, hash
|
||||
}
|
||||
|
||||
// new snapshot
|
||||
snap = newSnapshot(p.config, p.signatures, number, blockHash, validators, voteAddrs, p.ethAPI)
|
||||
|
||||
// get turnLength from headers and use that for new turnLength
|
||||
turnLength, err := parseTurnLength(checkpoint, p.chainConfig, p.config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if turnLength != nil {
|
||||
snap.TurnLength = *turnLength
|
||||
}
|
||||
|
||||
// snap.Recents is currently empty, which affects the following:
|
||||
// a. The function SignRecently - This is acceptable since an empty snap.Recents results in a more lenient check.
|
||||
// b. The function blockTimeVerifyForRamanujanFork - This is also acceptable as it won't be invoked during `snap.apply`.
|
||||
// c. This may cause a mismatch in the slash systemtx, but the transaction list is not verified during `snap.apply`.
|
||||
|
||||
// snap.Attestation is nil, but Snapshot.updateAttestation will handle it correctly.
|
||||
snap = newSnapshot(p.config, p.signatures, number, hash, validators, voteAddrs, p.ethAPI)
|
||||
if err := snap.store(p.db); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Info("Stored checkpoint snapshot to disk", "number", number, "hash", blockHash)
|
||||
log.Info("Stored checkpoint snapshot to disk", "number", number, "hash", hash)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ package core
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/triedb/versadb"
|
||||
"io"
|
||||
"math/big"
|
||||
"runtime"
|
||||
@@ -196,6 +197,11 @@ func (c *CacheConfig) triedbConfig() *triedb.Config {
|
||||
JournalFile: c.JournalFile,
|
||||
}
|
||||
}
|
||||
if c.StateScheme == rawdb.VersaScheme {
|
||||
config.VersaDB = &versadb.Config{
|
||||
CleanCacheSize: c.TrieCleanLimit * 1024 * 1024,
|
||||
}
|
||||
}
|
||||
return config
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ const HashScheme = "hash"
|
||||
// on extra state diffs to survive deep reorg.
|
||||
const PathScheme = "path"
|
||||
|
||||
const VersaScheme = "versa"
|
||||
|
||||
// hasher is used to compute the sha256 hash of the provided data.
|
||||
type hasher struct{ sha crypto.KeccakState }
|
||||
|
||||
|
||||
@@ -195,6 +195,10 @@ func (db *cachingDB) OpenTrie(root common.Hash) (Trie, error) {
|
||||
if db.triedb.IsVerkle() {
|
||||
return trie.NewVerkleTrie(root, db.triedb, utils.NewPointCache(commitmentCacheItems))
|
||||
}
|
||||
// TODO, trie handler instead of tree pointer
|
||||
if db.triedb.IsVersionedState() {
|
||||
return trie.NewVersionTrie(root, db.triedb)
|
||||
}
|
||||
tr, err := trie.NewStateTrie(trie.StateTrieID(root), db.triedb)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -214,6 +218,10 @@ func (db *cachingDB) OpenStorageTrie(stateRoot common.Hash, address common.Addre
|
||||
if db.triedb.IsVerkle() {
|
||||
return self, nil
|
||||
}
|
||||
// TODO
|
||||
if db.triedb.IsVersionedState() {
|
||||
return trie.NewVersionTrie(root, db.triedb)
|
||||
}
|
||||
tr, err := trie.NewStateTrie(trie.StorageTrieID(stateRoot, crypto.Keccak256Hash(address.Bytes()), root), db.triedb)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
1
go.sum
1
go.sum
@@ -326,6 +326,7 @@ github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R
|
||||
github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
|
||||
github.com/evanphx/json-patch v4.9.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
|
||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||
|
||||
@@ -195,7 +195,7 @@ var (
|
||||
CancunTime: newUint64(1713330442), // 2024-04-17 05:07:22 AM UTC
|
||||
HaberTime: newUint64(1716962820), // 2024-05-29 06:07:00 AM UTC
|
||||
HaberFixTime: newUint64(1719986788), // 2024-07-03 06:06:28 AM UTC
|
||||
BohrTime: newUint64(1724116996), // 2024-08-20 01:23:16 AM UTC
|
||||
BohrTime: nil,
|
||||
|
||||
Parlia: &ParliaConfig{
|
||||
Period: 3,
|
||||
|
||||
@@ -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 = 13 // Patch version component of the current release
|
||||
VersionPatch = 12 // Patch version component of the current release
|
||||
VersionMeta = "" // Version metadata to append to the version string
|
||||
)
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ type ID struct {
|
||||
StateRoot common.Hash // The root of the corresponding state(block.root)
|
||||
Owner common.Hash // The contract address hash which the trie belongs to
|
||||
Root common.Hash // The root hash of trie
|
||||
Version uint64 // The version of a Versa tree
|
||||
}
|
||||
|
||||
// StateTrieID constructs an identifier for state trie with the provided state root.
|
||||
|
||||
119
trie/version_trie.go
Normal file
119
trie/version_trie.go
Normal file
@@ -0,0 +1,119 @@
|
||||
package trie
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/triedb/database"
|
||||
)
|
||||
|
||||
// VersionTrie is a wrapper around version state that implements the trie.Trie
|
||||
// interface so that version trees can be reused verbatim.
|
||||
type VersionTrie struct {
|
||||
db database.Database
|
||||
reader *trieReader
|
||||
//tree TreeHandler
|
||||
}
|
||||
|
||||
// NewVersionTrie constructs a version state tree based on the specified root hash.
|
||||
func NewVersionTrie(root common.Hash, db database.Database) (*VersionTrie, error) {
|
||||
reader, err := newTrieReader(root, common.Hash{}, db)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO
|
||||
// Open a tree
|
||||
// tree, err := OpenTree(state StateHandler, version int64, owner common.Hash, root common.Hash)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &VersionTrie{
|
||||
db: db,
|
||||
reader: reader,
|
||||
// tree: tree,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// GetKey returns the sha3 preimage of a hashed key that was previously used
|
||||
// to store a value.
|
||||
func (t *VersionTrie) GetKey(key []byte) []byte {
|
||||
return key
|
||||
}
|
||||
|
||||
// GetAccount implements state.Trie, retrieving the account with the specified
|
||||
// account address. If the specified account is not in the tree, nil will
|
||||
// be returned. If the tree is corrupted, an error will be returned.
|
||||
func (t *VersionTrie) GetAccount(address common.Address) (*types.StateAccount, error) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// GetStorage returns the value for key stored in the trie. The value bytes
|
||||
// must not be modified by the caller. If a node was not found in the database,
|
||||
// a trie.MissingNodeError is returned.
|
||||
func (t *VersionTrie) GetStorage(addr common.Address, key []byte) ([]byte, error) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// UpdateAccount abstracts an account write to the trie. It encodes the
|
||||
// provided account object with associated algorithm and then updates it
|
||||
// in the trie with provided address.
|
||||
func (t *VersionTrie) UpdateAccount(address common.Address, account *types.StateAccount) error {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// UpdateStorage associates key with value in the trie. If value has length zero,
|
||||
// any existing value is deleted from the trie. The value bytes must not be modified
|
||||
// by the caller while they are stored in the trie. If a node was not found in the
|
||||
// database, a trie.MissingNodeError is returned.
|
||||
func (t *VersionTrie) UpdateStorage(addr common.Address, key, value []byte) error {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// DeleteAccount abstracts an account deletion from the trie.
|
||||
func (t *VersionTrie) DeleteAccount(address common.Address) error {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// DeleteStorage removes any existing value for key from the trie. If a node
|
||||
// was not found in the database, a trie.MissingNodeError is returned.
|
||||
func (t *VersionTrie) DeleteStorage(addr common.Address, key []byte) error {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// UpdateContractCode abstracts code write to the trie. It is expected
|
||||
// to be moved to the stateWriter interface when the latter is ready.
|
||||
func (t *VersionTrie) UpdateContractCode(address common.Address, codeHash common.Hash, code []byte) error {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Hash returns the root hash of the trie. It does not write to the database and
|
||||
// can be used even if the trie doesn't have one.
|
||||
func (t *VersionTrie) Hash() common.Hash {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Commit collects all dirty nodes in the trie and replace them with the
|
||||
// corresponding node hash.
|
||||
func (t *VersionTrie) Commit(collectLeaf bool) (common.Hash, error) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// NodeIterator returns an iterator that returns nodes of the trie. Iteration
|
||||
// starts at the key after the given start key. And error will be returned
|
||||
// if fails to create node iterator.
|
||||
func (t *VersionTrie) NodeIterator(startKey []byte) (trie.NodeIterator, error) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Prove constructs a Merkle proof for key. The result contains all encoded nodes
|
||||
// on the path to the value at key. The value itself is also included in the last
|
||||
// node and can be retrieved by verifying the proof.
|
||||
//
|
||||
// If the trie does not contain a value for key, the returned proof contains all
|
||||
// nodes of the longest existing prefix of the key (at least the root), ending
|
||||
// with the node that proves the absence of the key.
|
||||
func (t *VersionTrie) Prove(key []byte, proofDb ethdb.KeyValueWriter) error {
|
||||
// TODO
|
||||
}
|
||||
@@ -18,6 +18,7 @@ package triedb
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/ethereum/go-ethereum/triedb/versadb"
|
||||
"strings"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
@@ -37,9 +38,11 @@ type Config struct {
|
||||
Preimages bool // Flag whether the preimage of node key is recorded
|
||||
Cache int
|
||||
NoTries bool
|
||||
IsVerkle bool // Flag whether the db is holding a verkle tree
|
||||
HashDB *hashdb.Config // Configs for hash-based scheme
|
||||
PathDB *pathdb.Config // Configs for experimental path-based scheme
|
||||
IsVerkle bool // Flag whether the db is holding a verkle tree
|
||||
IsVersa bool
|
||||
HashDB *hashdb.Config // Configs for hash-based scheme
|
||||
PathDB *pathdb.Config // Configs for experimental path-based scheme
|
||||
VersaDB *versadb.Config // TODO, Richard
|
||||
}
|
||||
|
||||
// HashDefaults represents a config for using hash-based scheme with
|
||||
@@ -148,6 +151,11 @@ func NewDatabase(diskdb ethdb.Database, config *Config) *Database {
|
||||
config.PathDB = pathdb.Defaults
|
||||
}
|
||||
db.backend = pathdb.New(triediskdb, config.PathDB)
|
||||
} else if strings.Compare(dbScheme, rawdb.VersaScheme) == 0 {
|
||||
if config.VersaDB == nil {
|
||||
config.VersaDB = versadb.Defaults
|
||||
}
|
||||
db.backend = versadb.New(triediskdb, config.VersaDB)
|
||||
} else {
|
||||
var resolver hashdb.ChildResolver
|
||||
if config.IsVerkle {
|
||||
@@ -409,3 +417,8 @@ func (db *Database) GetAllRooHash() [][]string {
|
||||
func (db *Database) IsVerkle() bool {
|
||||
return db.config.IsVerkle
|
||||
}
|
||||
|
||||
// IsVersionedState returns the indicator if the database is holding a versioned state.
|
||||
func (db *Database) IsVersionedState() bool {
|
||||
return db.config.IsVersa
|
||||
}
|
||||
|
||||
82
triedb/versadb/database.go
Normal file
82
triedb/versadb/database.go
Normal file
@@ -0,0 +1,82 @@
|
||||
package versadb
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/trie/trienode"
|
||||
"github.com/ethereum/go-ethereum/trie/triestate"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// maxDiffLayers is the maximum diff layers allowed in the layer tree.
|
||||
maxDiffLayers = 128
|
||||
)
|
||||
|
||||
// Config contains the settings for database.
|
||||
type Config struct {
|
||||
CleanCacheSize int // Maximum memory allowance (in bytes) for caching clean nodes
|
||||
}
|
||||
|
||||
// Defaults is the default setting for database if it's not specified. ,
|
||||
var Defaults = &Config{
|
||||
CleanCacheSize: 0,
|
||||
}
|
||||
|
||||
type Database struct {
|
||||
// readOnly is the flag whether the mutation is allowed to be applied.
|
||||
// It will be set automatically when the database is journaled during
|
||||
// the shutdown to reject all following unexpected mutations.
|
||||
readOnly bool // Flag if database is opened in read only mode
|
||||
config *Config // Configuration for database
|
||||
lock sync.RWMutex // Lock to prevent mutations from happening at the same time
|
||||
}
|
||||
|
||||
// New initializes the version state database.
|
||||
func New(diskdb ethdb.Database, config *Config) *Database {
|
||||
if config == nil {
|
||||
config = Defaults
|
||||
}
|
||||
// TODO
|
||||
db := VersaDB.NewVersaDB(nil)
|
||||
return db
|
||||
}
|
||||
|
||||
// Scheme returns the identifier of used storage scheme.
|
||||
func (db *Database) Scheme() string {
|
||||
return rawdb.VersaScheme
|
||||
}
|
||||
|
||||
// Initialized returns an indicator if the state data is already initialized
|
||||
// according to the state scheme.
|
||||
func (db *Database) Initialized(genesisRoot common.Hash) bool {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Size returns the current storage size of the memory cache in front of the
|
||||
// persistent database layer.
|
||||
func (db *Database) Size() (common.StorageSize, common.StorageSize, common.StorageSize) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Update performs a state transition by committing dirty nodes contained
|
||||
// in the given set in order to update state from the specified parent to
|
||||
// the specified root.
|
||||
//
|
||||
// The passed in maps(nodes, states) will be retained to avoid copying
|
||||
// everything. Therefore, these maps must not be changed afterwards.
|
||||
func (db *Database) Update(root common.Hash, parent common.Hash, block uint64, nodes *trienode.MergedNodeSet, states *triestate.Set) error {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Commit writes all relevant trie nodes belonging to the specified state
|
||||
// to disk. Report specifies whether logs will be displayed in info level.
|
||||
func (db *Database) Commit(root common.Hash, report bool) error {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// Close closes the trie database backend and releases all held resources.
|
||||
func (db *Database) Close() error {
|
||||
// TODO
|
||||
}
|
||||
Reference in New Issue
Block a user