Merge branch 'v1.2.3-candidate' of github.com:maticnetwork/bor into eip7212

This commit is contained in:
Arpit Temani 2024-01-19 17:31:39 +05:30
commit 59fa8cb9ac
21 changed files with 46 additions and 114 deletions

View file

@ -23,3 +23,4 @@ borDockerBuildContext: "../../bor"
heimdallDockerBuildContext: "https://github.com/maticnetwork/heimdall.git#develop" heimdallDockerBuildContext: "https://github.com/maticnetwork/heimdall.git#develop"
sprintSizeBlockNumber: sprintSizeBlockNumber:
- '0' - '0'
devnetBorFlags: config,config,config

View file

@ -217,7 +217,7 @@ jobs:
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: '16.17.1' node-version: '18.19.0'
cache: 'npm' cache: 'npm'
cache-dependency-path: | cache-dependency-path: |
matic-cli/package-lock.json matic-cli/package-lock.json
@ -231,7 +231,7 @@ jobs:
npm install --prefer-offline --no-audit --progress=false npm install --prefer-offline --no-audit --progress=false
mkdir devnet mkdir devnet
cd devnet cd devnet
../bin/matic-cli setup devnet -c ../../bor/.github/matic-cli-config.yml ../bin/matic-cli.js setup devnet -c ../../bor/.github/matic-cli-config.yml
- name: Launch devnet - name: Launch devnet
run: | run: |

View file

@ -1,6 +1,2 @@
<<<<<<< HEAD
These files examplify a transition where a transaction (executed on block 5) requests These files examplify a transition where a transaction (executed on block 5) requests
=======
These files exemplify a transition where a transaction (executed on block 5) requests
>>>>>>> bed84606583893fdb698cc1b5058cc47b4dbd837
the blockhash for block `1`. the blockhash for block `1`.

View file

@ -1,7 +1,3 @@
<<<<<<< HEAD
These files examplify a transition where a transaction (executed on block 5) requests
=======
These files exemplify a transition where a transaction (executed on block 5) requests These files exemplify a transition where a transaction (executed on block 5) requests
>>>>>>> bed84606583893fdb698cc1b5058cc47b4dbd837
the blockhash for block `4`, but where the hash for that block is missing. the blockhash for block `4`, but where the hash for that block is missing.
It's expected that executing these should cause `exit` with errorcode `4`. It's expected that executing these should cause `exit` with errorcode `4`.

View file

@ -236,13 +236,14 @@ type BlockChain struct {
stopping atomic.Bool // false if chain is running, true when stopped stopping atomic.Bool // false if chain is running, true when stopped
procInterrupt atomic.Bool // interrupt signaler for block processing procInterrupt atomic.Bool // interrupt signaler for block processing
engine consensus.Engine engine consensus.Engine
validator Validator // Block and state validator interface validator Validator // Block and state validator interface
prefetcher Prefetcher prefetcher Prefetcher
processor Processor // Block transaction processor interface processor Processor // Block transaction processor interface
parallelProcessor Processor // Parallel block transaction processor interface parallelProcessor Processor // Parallel block transaction processor interface
forker *ForkChoice parallelSpeculativeProcesses int // Number of parallel speculative processes
vmConfig vm.Config forker *ForkChoice
vmConfig vm.Config
// Bor related changes // Bor related changes
borReceiptsCache *lru.Cache[common.Hash, *types.Receipt] // Cache for the most recent bor receipt receipts per block borReceiptsCache *lru.Cache[common.Hash, *types.Receipt] // Cache for the most recent bor receipt receipts per block
@ -408,7 +409,8 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
// The first thing the node will do is reconstruct the verification data for // The first thing the node will do is reconstruct the verification data for
// the head block (ethash cache or clique voting snapshot). Might as well do // the head block (ethash cache or clique voting snapshot). Might as well do
// it in advance. // it in advance.
bc.engine.VerifyHeader(bc, bc.CurrentHeader()) // BOR - commented out intentionally
// bc.engine.VerifyHeader(bc, bc.CurrentHeader())
// Check the current state of the block hashes and make sure that we do not have any of the bad blocks in our chain // Check the current state of the block hashes and make sure that we do not have any of the bad blocks in our chain
for hash := range BadHashes { for hash := range BadHashes {
@ -481,7 +483,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
} }
// NewParallelBlockChain , similar to NewBlockChain, creates a new blockchain object, but with a parallel state processor // NewParallelBlockChain , similar to NewBlockChain, creates a new blockchain object, but with a parallel state processor
func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis, overrides *ChainOverrides, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(header *types.Header) bool, txLookupLimit *uint64, checker ethereum.ChainValidator) (*BlockChain, error) { func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis, overrides *ChainOverrides, engine consensus.Engine, vmConfig vm.Config, shouldPreserve func(header *types.Header) bool, txLookupLimit *uint64, checker ethereum.ChainValidator, numprocs int) (*BlockChain, error) {
bc, err := NewBlockChain(db, cacheConfig, genesis, overrides, engine, vmConfig, shouldPreserve, txLookupLimit, checker) bc, err := NewBlockChain(db, cacheConfig, genesis, overrides, engine, vmConfig, shouldPreserve, txLookupLimit, checker)
if err != nil { if err != nil {
@ -500,6 +502,7 @@ func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis
} }
bc.parallelProcessor = NewParallelStateProcessor(chainConfig, bc, engine) bc.parallelProcessor = NewParallelStateProcessor(chainConfig, bc, engine)
bc.parallelSpeculativeProcesses = numprocs
return bc, nil return bc, nil
} }
@ -2139,15 +2142,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
parent = bc.GetHeader(block.ParentHash(), block.NumberU64()-1) parent = bc.GetHeader(block.ParentHash(), block.NumberU64()-1)
} }
statedb, err := state.New(parent.Root, bc.stateCache, bc.snaps)
if err != nil {
return it.index, err
}
// Enable prefetching to pull in trie node paths while processing transactions
statedb.StartPrefetcher("chain")
activeState = statedb
// If we have a followup block, run that against the current state to pre-cache // If we have a followup block, run that against the current state to pre-cache
// transactions and probabilistically some of the account/storage trie nodes. // transactions and probabilistically some of the account/storage trie nodes.
var followupInterrupt atomic.Bool var followupInterrupt atomic.Bool

View file

@ -364,7 +364,7 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
backupStateDB := statedb.Copy() backupStateDB := statedb.Copy()
profile := false profile := false
result, err := blockstm.ExecuteParallel(tasks, profile, metadata, cfg.ParallelSpeculativeProcesses, interruptCtx) result, err := blockstm.ExecuteParallel(tasks, profile, metadata, p.bc.parallelSpeculativeProcesses, interruptCtx)
if err == nil && profile && result.Deps != nil { if err == nil && profile && result.Deps != nil {
_, weight := result.Deps.LongestPath(*result.Stats) _, weight := result.Deps.LongestPath(*result.Stats)
@ -398,7 +398,7 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
t.totalUsedGas = usedGas t.totalUsedGas = usedGas
} }
_, err = blockstm.ExecuteParallel(tasks, false, metadata, cfg.ParallelSpeculativeProcesses, interruptCtx) _, err = blockstm.ExecuteParallel(tasks, false, metadata, p.bc.parallelSpeculativeProcesses, interruptCtx)
break break
} }

View file

@ -85,14 +85,12 @@ func NewPruner(db ethdb.Database, config Config) (*Pruner, error) {
if headBlock == nil { if headBlock == nil {
return nil, errors.New("failed to load head block") return nil, errors.New("failed to load head block")
} }
snapconfig := snapshot.Config{ snapconfig := snapshot.Config{
CacheSize: 256, CacheSize: 256,
Recovery: false, Recovery: false,
NoBuild: true, NoBuild: true,
AsyncBuild: false, AsyncBuild: false,
} }
snaptree, err := snapshot.New(snapconfig, db, trie.NewDatabase(db), headBlock.Root()) snaptree, err := snapshot.New(snapconfig, db, trie.NewDatabase(db), headBlock.Root())
if err != nil { if err != nil {
return nil, err // The relevant snapshot(s) might not exist return nil, err // The relevant snapshot(s) might not exist
@ -102,12 +100,10 @@ func NewPruner(db ethdb.Database, config Config) (*Pruner, error) {
log.Warn("Sanitizing bloomfilter size", "provided(MB)", config.BloomSize, "updated(MB)", 256) log.Warn("Sanitizing bloomfilter size", "provided(MB)", config.BloomSize, "updated(MB)", 256)
config.BloomSize = 256 config.BloomSize = 256
} }
stateBloom, err := newStateBloomWithSize(config.BloomSize) stateBloom, err := newStateBloomWithSize(config.BloomSize)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &Pruner{ return &Pruner{
config: config, config: config,
chainHeader: headBlock.Header(), chainHeader: headBlock.Header(),
@ -133,7 +129,6 @@ func prune(snaptree *snapshot.Tree, root common.Hash, maindb ethdb.Database, sta
batch = maindb.NewBatch() batch = maindb.NewBatch()
iter = maindb.NewIterator(nil, nil) iter = maindb.NewIterator(nil, nil)
) )
for iter.Next() { for iter.Next() {
key := iter.Key() key := iter.Key()
@ -147,7 +142,6 @@ func prune(snaptree *snapshot.Tree, root common.Hash, maindb ethdb.Database, sta
if isCode { if isCode {
checkKey = codeKey checkKey = codeKey
} }
if _, exist := middleStateRoots[common.BytesToHash(checkKey)]; exist { if _, exist := middleStateRoots[common.BytesToHash(checkKey)]; exist {
log.Debug("Forcibly delete the middle state roots", "hash", common.BytesToHash(checkKey)) log.Debug("Forcibly delete the middle state roots", "hash", common.BytesToHash(checkKey))
} else { } else {
@ -155,26 +149,21 @@ func prune(snaptree *snapshot.Tree, root common.Hash, maindb ethdb.Database, sta
continue continue
} }
} }
count += 1 count += 1
size += common.StorageSize(len(key) + len(iter.Value())) size += common.StorageSize(len(key) + len(iter.Value()))
batch.Delete(key) batch.Delete(key)
var eta time.Duration // Realistically will never remain uninited var eta time.Duration // Realistically will never remain uninited
if done := binary.BigEndian.Uint64(key[:8]); done > 0 { if done := binary.BigEndian.Uint64(key[:8]); done > 0 {
var ( var (
left = math.MaxUint64 - binary.BigEndian.Uint64(key[:8]) left = math.MaxUint64 - binary.BigEndian.Uint64(key[:8])
speed = done/uint64(time.Since(pstart)/time.Millisecond+1) + 1 // +1s to avoid division by zero speed = done/uint64(time.Since(pstart)/time.Millisecond+1) + 1 // +1s to avoid division by zero
) )
eta = time.Duration(left/speed) * time.Millisecond eta = time.Duration(left/speed) * time.Millisecond
} }
if time.Since(logged) > 8*time.Second { if time.Since(logged) > 8*time.Second {
log.Info("Pruning state data", "nodes", count, "size", size, log.Info("Pruning state data", "nodes", count, "size", size,
"elapsed", common.PrettyDuration(time.Since(pstart)), "eta", common.PrettyDuration(eta)) "elapsed", common.PrettyDuration(time.Since(pstart)), "eta", common.PrettyDuration(eta))
logged = time.Now() logged = time.Now()
} }
// Recreate the iterator after every batch commit in order // Recreate the iterator after every batch commit in order
@ -188,12 +177,10 @@ func prune(snaptree *snapshot.Tree, root common.Hash, maindb ethdb.Database, sta
} }
} }
} }
if batch.ValueSize() > 0 { if batch.ValueSize() > 0 {
batch.Write() batch.Write()
batch.Reset() batch.Reset()
} }
iter.Release() iter.Release()
log.Info("Pruned state data", "nodes", count, "size", size, "elapsed", common.PrettyDuration(time.Since(pstart))) log.Info("Pruned state data", "nodes", count, "size", size, "elapsed", common.PrettyDuration(time.Since(pstart)))
@ -220,19 +207,15 @@ func prune(snaptree *snapshot.Tree, root common.Hash, maindb ethdb.Database, sta
// Note for small pruning, the compaction is skipped. // Note for small pruning, the compaction is skipped.
if count >= rangeCompactionThreshold { if count >= rangeCompactionThreshold {
cstart := time.Now() cstart := time.Now()
for b := 0x00; b <= 0xf0; b += 0x10 { for b := 0x00; b <= 0xf0; b += 0x10 {
var ( var (
start = []byte{byte(b)} start = []byte{byte(b)}
end = []byte{byte(b + 0x10)} end = []byte{byte(b + 0x10)}
) )
if b == 0xf0 { if b == 0xf0 {
end = nil end = nil
} }
log.Info("Compacting database", "range", fmt.Sprintf("%#x-%#x", start, end), "elapsed", common.PrettyDuration(time.Since(cstart))) log.Info("Compacting database", "range", fmt.Sprintf("%#x-%#x", start, end), "elapsed", common.PrettyDuration(time.Since(cstart)))
if err := maindb.Compact(start, end); err != nil { if err := maindb.Compact(start, end); err != nil {
log.Error("Database compaction failed", "error", err) log.Error("Database compaction failed", "error", err)
return err return err
@ -240,16 +223,13 @@ func prune(snaptree *snapshot.Tree, root common.Hash, maindb ethdb.Database, sta
} }
log.Info("Database compaction finished", "elapsed", common.PrettyDuration(time.Since(cstart))) log.Info("Database compaction finished", "elapsed", common.PrettyDuration(time.Since(cstart)))
} }
log.Info("State pruning successful", "pruned", size, "elapsed", common.PrettyDuration(time.Since(start))) log.Info("State pruning successful", "pruned", size, "elapsed", common.PrettyDuration(time.Since(start)))
return nil return nil
} }
// Prune deletes all historical state nodes except the nodes belong to the // Prune deletes all historical state nodes except the nodes belong to the
// specified state version. If user doesn't specify the state version, use // specified state version. If user doesn't specify the state version, use
// the bottom-most snapshot diff layer as the target. // the bottom-most snapshot diff layer as the target.
// nolint:nestif
func (p *Pruner) Prune(root common.Hash) error { func (p *Pruner) Prune(root common.Hash) error {
// If the state bloom filter is already committed previously, // If the state bloom filter is already committed previously,
// reuse it for pruning instead of generating a new one. It's // reuse it for pruning instead of generating a new one. It's
@ -259,7 +239,6 @@ func (p *Pruner) Prune(root common.Hash) error {
if err != nil { if err != nil {
return err return err
} }
if stateBloomRoot != (common.Hash{}) { if stateBloomRoot != (common.Hash{}) {
return RecoverPruning(p.config.Datadir, p.db) return RecoverPruning(p.config.Datadir, p.db)
} }
@ -298,23 +277,18 @@ func (p *Pruner) Prune(root common.Hash) error {
// state available, but we don't want to use the topmost state // state available, but we don't want to use the topmost state
// as the pruning target. // as the pruning target.
var found bool var found bool
for i := len(layers) - 2; i >= 2; i-- { for i := len(layers) - 2; i >= 2; i-- {
if rawdb.HasLegacyTrieNode(p.db, layers[i].Root()) { if rawdb.HasLegacyTrieNode(p.db, layers[i].Root()) {
root = layers[i].Root() root = layers[i].Root()
found = true found = true
log.Info("Selecting middle-layer as the pruning target", "root", root, "depth", i) log.Info("Selecting middle-layer as the pruning target", "root", root, "depth", i)
break break
} }
} }
if !found { if !found {
if len(layers) > 0 { if len(layers) > 0 {
return errors.New("no snapshot paired state") return errors.New("no snapshot paired state")
} }
return fmt.Errorf("associated state[%x] is not present", root) return fmt.Errorf("associated state[%x] is not present", root)
} }
} else { } else {
@ -327,18 +301,15 @@ func (p *Pruner) Prune(root common.Hash) error {
// All the state roots of the middle layer should be forcibly pruned, // All the state roots of the middle layer should be forcibly pruned,
// otherwise the dangling state will be left. // otherwise the dangling state will be left.
middleRoots := make(map[common.Hash]struct{}) middleRoots := make(map[common.Hash]struct{})
for _, layer := range layers { for _, layer := range layers {
if layer.Root() == root { if layer.Root() == root {
break break
} }
middleRoots[layer.Root()] = struct{}{} middleRoots[layer.Root()] = struct{}{}
} }
// Traverse the target state, re-construct the whole state trie and // Traverse the target state, re-construct the whole state trie and
// commit to the given bloom filter. // commit to the given bloom filter.
start := time.Now() start := time.Now()
if err := snapshot.GenerateTrie(p.snaptree, root, p.db, p.stateBloom); err != nil { if err := snapshot.GenerateTrie(p.snaptree, root, p.db, p.stateBloom); err != nil {
return err return err
} }
@ -347,17 +318,13 @@ func (p *Pruner) Prune(root common.Hash) error {
if err := extractGenesis(p.db, p.stateBloom); err != nil { if err := extractGenesis(p.db, p.stateBloom); err != nil {
return err return err
} }
filterName := bloomFilterName(p.config.Datadir, root) filterName := bloomFilterName(p.config.Datadir, root)
log.Info("Writing state bloom to disk", "name", filterName) log.Info("Writing state bloom to disk", "name", filterName)
if err := p.stateBloom.Commit(filterName, filterName+stateBloomFileTempSuffix); err != nil { if err := p.stateBloom.Commit(filterName, filterName+stateBloomFileTempSuffix); err != nil {
return err return err
} }
log.Info("State bloom filter committed", "name", filterName) log.Info("State bloom filter committed", "name", filterName)
return prune(p.snaptree, root, p.db, p.stateBloom, filterName, middleRoots, start) return prune(p.snaptree, root, p.db, p.stateBloom, filterName, middleRoots, start)
} }
@ -373,11 +340,9 @@ func RecoverPruning(datadir string, db ethdb.Database) error {
if err != nil { if err != nil {
return err return err
} }
if stateBloomPath == "" { if stateBloomPath == "" {
return nil // nothing to recover return nil // nothing to recover
} }
headBlock := rawdb.ReadHeadBlock(db) headBlock := rawdb.ReadHeadBlock(db)
if headBlock == nil { if headBlock == nil {
return errors.New("failed to load head block") return errors.New("failed to load head block")
@ -396,17 +361,14 @@ func RecoverPruning(datadir string, db ethdb.Database) error {
NoBuild: true, NoBuild: true,
AsyncBuild: false, AsyncBuild: false,
} }
snaptree, err := snapshot.New(snapconfig, db, trie.NewDatabase(db), headBlock.Root()) snaptree, err := snapshot.New(snapconfig, db, trie.NewDatabase(db), headBlock.Root())
if err != nil { if err != nil {
return err // The relevant snapshot(s) might not exist return err // The relevant snapshot(s) might not exist
} }
stateBloom, err := NewStateBloomFromDisk(stateBloomPath) stateBloom, err := NewStateBloomFromDisk(stateBloomPath)
if err != nil { if err != nil {
return err return err
} }
log.Info("Loaded state bloom filter", "path", stateBloomPath) log.Info("Loaded state bloom filter", "path", stateBloomPath)
// All the state roots of the middle layers should be forcibly pruned, // All the state roots of the middle layers should be forcibly pruned,
@ -416,21 +378,17 @@ func RecoverPruning(datadir string, db ethdb.Database) error {
layers = snaptree.Snapshots(headBlock.Root(), 128, true) layers = snaptree.Snapshots(headBlock.Root(), 128, true)
middleRoots = make(map[common.Hash]struct{}) middleRoots = make(map[common.Hash]struct{})
) )
for _, layer := range layers { for _, layer := range layers {
if layer.Root() == stateBloomRoot { if layer.Root() == stateBloomRoot {
found = true found = true
break break
} }
middleRoots[layer.Root()] = struct{}{} middleRoots[layer.Root()] = struct{}{}
} }
if !found { if !found {
log.Error("Pruning target state is not existent") log.Error("Pruning target state is not existent")
return errors.New("non-existent target state") return errors.New("non-existent target state")
} }
return prune(snaptree, stateBloomRoot, db, stateBloom, stateBloomPath, middleRoots, time.Now()) return prune(snaptree, stateBloomRoot, db, stateBloom, stateBloomPath, middleRoots, time.Now())
} }
@ -441,12 +399,10 @@ func extractGenesis(db ethdb.Database, stateBloom *stateBloom) error {
if genesisHash == (common.Hash{}) { if genesisHash == (common.Hash{}) {
return errors.New("missing genesis hash") return errors.New("missing genesis hash")
} }
genesis := rawdb.ReadBlock(db, genesisHash, 0) genesis := rawdb.ReadBlock(db, genesisHash, 0)
if genesis == nil { if genesis == nil {
return errors.New("missing genesis block") return errors.New("missing genesis block")
} }
t, err := trie.NewStateTrie(trie.StateTrieID(genesis.Root()), trie.NewDatabase(db)) t, err := trie.NewStateTrie(trie.StateTrieID(genesis.Root()), trie.NewDatabase(db))
if err != nil { if err != nil {
return err return err
@ -469,10 +425,8 @@ func extractGenesis(db ethdb.Database, stateBloom *stateBloom) error {
if err := rlp.DecodeBytes(accIter.LeafBlob(), &acc); err != nil { if err := rlp.DecodeBytes(accIter.LeafBlob(), &acc); err != nil {
return err return err
} }
if acc.Root != types.EmptyRootHash { if acc.Root != types.EmptyRootHash {
id := trie.StorageTrieID(genesis.Root(), common.BytesToHash(accIter.LeafKey()), acc.Root) id := trie.StorageTrieID(genesis.Root(), common.BytesToHash(accIter.LeafKey()), acc.Root)
storageTrie, err := trie.NewStateTrie(id, trie.NewDatabase(db)) storageTrie, err := trie.NewStateTrie(id, trie.NewDatabase(db))
if err != nil { if err != nil {
return err return err
@ -487,18 +441,15 @@ func extractGenesis(db ethdb.Database, stateBloom *stateBloom) error {
stateBloom.Put(hash.Bytes(), nil) stateBloom.Put(hash.Bytes(), nil)
} }
} }
if storageIter.Error() != nil { if storageIter.Error() != nil {
return storageIter.Error() return storageIter.Error()
} }
} }
if !bytes.Equal(acc.CodeHash, types.EmptyCodeHash.Bytes()) { if !bytes.Equal(acc.CodeHash, types.EmptyCodeHash.Bytes()) {
stateBloom.Put(acc.CodeHash, nil) stateBloom.Put(acc.CodeHash, nil)
} }
} }
} }
return accIter.Error() return accIter.Error()
} }
@ -511,7 +462,6 @@ func isBloomFilter(filename string) (bool, common.Hash) {
if strings.HasPrefix(filename, stateBloomFilePrefix) && strings.HasSuffix(filename, stateBloomFileSuffix) { if strings.HasPrefix(filename, stateBloomFilePrefix) && strings.HasSuffix(filename, stateBloomFileSuffix) {
return true, common.HexToHash(filename[len(stateBloomFilePrefix)+1 : len(filename)-len(stateBloomFileSuffix)-1]) return true, common.HexToHash(filename[len(stateBloomFilePrefix)+1 : len(filename)-len(stateBloomFileSuffix)-1])
} }
return false, common.Hash{} return false, common.Hash{}
} }
@ -520,7 +470,6 @@ func findBloomFilter(datadir string) (string, common.Hash, error) {
stateBloomPath string stateBloomPath string
stateBloomRoot common.Hash stateBloomRoot common.Hash
) )
if err := filepath.Walk(datadir, func(path string, info os.FileInfo, err error) error { if err := filepath.Walk(datadir, func(path string, info os.FileInfo, err error) error {
if info != nil && !info.IsDir() { if info != nil && !info.IsDir() {
ok, root := isBloomFilter(path) ok, root := isBloomFilter(path)
@ -533,6 +482,5 @@ func findBloomFilter(datadir string) (string, common.Hash, error) {
}); err != nil { }); err != nil {
return "", common.Hash{}, err return "", common.Hash{}, err
} }
return stateBloomPath, stateBloomRoot, nil return stateBloomPath, stateBloomRoot, nil
} }

View file

@ -52,10 +52,6 @@ type Config struct {
NoBaseFee bool // Forces the EIP-1559 baseFee to 0 (needed for 0 price calls) NoBaseFee bool // Forces the EIP-1559 baseFee to 0 (needed for 0 price calls)
EnablePreimageRecording bool // Enables recording of SHA3/keccak preimages EnablePreimageRecording bool // Enables recording of SHA3/keccak preimages
ExtraEips []int // Additional EIPS that are to be enabled ExtraEips []int // Additional EIPS that are to be enabled
// parallel EVM configs
ParallelEnable bool
ParallelSpeculativeProcesses int
} }
// ScopeContext contains the things that are per-call, such as stack and memory, // ScopeContext contains the things that are per-call, such as stack and memory,

View file

@ -229,6 +229,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
TrieTimeLimit: config.TrieTimeout, TrieTimeLimit: config.TrieTimeout,
SnapshotLimit: config.SnapshotCache, SnapshotLimit: config.SnapshotCache,
Preimages: config.Preimages, Preimages: config.Preimages,
TriesInMemory: config.TriesInMemory,
} }
) )
@ -237,7 +238,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
// check if Parallel EVM is enabled // check if Parallel EVM is enabled
// if enabled, use parallel state processor // if enabled, use parallel state processor
if config.ParallelEVM.Enable { if config.ParallelEVM.Enable {
eth.blockchain, err = core.NewParallelBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit, checker) eth.blockchain, err = core.NewParallelBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit, checker, config.ParallelEVM.SpeculativeProcesses)
} else { } else {
eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit, checker) eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit, checker)
} }

6
go.mod
View file

@ -81,11 +81,11 @@ require (
github.com/tyler-smith/go-bip39 v1.1.0 github.com/tyler-smith/go-bip39 v1.1.0
github.com/urfave/cli/v2 v2.24.1 github.com/urfave/cli/v2 v2.24.1
go.uber.org/automaxprocs v1.5.2 go.uber.org/automaxprocs v1.5.2
golang.org/x/crypto v0.14.0 golang.org/x/crypto v0.17.0
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad golang.org/x/exp v0.0.0-20230810033253-352e893a4cad
golang.org/x/sync v0.3.0 golang.org/x/sync v0.3.0
golang.org/x/sys v0.13.0 golang.org/x/sys v0.15.0
golang.org/x/text v0.13.0 golang.org/x/text v0.14.0
golang.org/x/time v0.3.0 golang.org/x/time v0.3.0
golang.org/x/tools v0.10.0 golang.org/x/tools v0.10.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0 gopkg.in/natefinch/lumberjack.v2 v2.0.0

12
go.sum
View file

@ -2256,8 +2256,8 @@ golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
@ -2618,8 +2618,8 @@ golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
@ -2651,8 +2651,8 @@ golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

View file

@ -3,8 +3,8 @@ set -e
while true while true
do do
peers=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec 'admin.peers'") peers=$(docker exec bor0 bash -c "bor attach /root/var/lib/bor/data/bor.ipc -exec 'admin.peers'")
block=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec 'eth.blockNumber'") block=$(docker exec bor0 bash -c "bor attach /root/var/lib/bor/data/bor.ipc -exec 'eth.blockNumber'")
if [[ -n "$peers" ]] && [[ -n "$block" ]]; then if [[ -n "$peers" ]] && [[ -n "$block" ]]; then
break break

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
set -e set -e
balanceInit=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'") balanceInit=$(docker exec bor0 bash -c "bor attach /root/var/lib/bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'")
stateSyncFound="false" stateSyncFound="false"
checkpointFound="false" checkpointFound="false"
@ -11,7 +11,7 @@ start_time=$SECONDS
while true while true
do do
balance=$(docker exec bor0 bash -c "bor attach /root/.bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'") balance=$(docker exec bor0 bash -c "bor attach /root/var/lib/bor/data/bor.ipc -exec 'Math.round(web3.fromWei(eth.getBalance(eth.accounts[0])))'")
if ! [[ "$balance" =~ ^[0-9]+$ ]]; then if ! [[ "$balance" =~ ^[0-9]+$ ]]; then
echo "Something is wrong! Can't find the balance of first account in bor network." echo "Something is wrong! Can't find the balance of first account in bor network."

View file

@ -949,7 +949,7 @@ func BenchmarkBorMiningBlockSTMMetadata(b *testing.B) {
db2 := rawdb.NewMemoryDatabase() db2 := rawdb.NewMemoryDatabase()
back.genesis.MustCommit(db2) back.genesis.MustCommit(db2)
chain, _ := core.NewParallelBlockChain(db2, nil, back.genesis, nil, engine, vm.Config{ParallelEnable: true, ParallelSpeculativeProcesses: 8}, nil, nil, nil) chain, _ := core.NewParallelBlockChain(db2, nil, back.genesis, nil, engine, vm.Config{}, nil, nil, nil, 8)
defer chain.Stop() defer chain.Stop()
// Ignore empty commit here for less noise. // Ignore empty commit here for less noise.

View file

@ -1,5 +1,5 @@
Source: bor Source: bor
Version: 1.2.0-beta Version: 1.2.2
Section: develop Section: develop
Priority: standard Priority: standard
Maintainer: Polygon <release-team@polygon.technology> Maintainer: Polygon <release-team@polygon.technology>

View file

@ -1,5 +1,5 @@
Source: bor Source: bor
Version: 1.2.0-beta Version: 1.2.2
Section: develop Section: develop
Priority: standard Priority: standard
Maintainer: Polygon <release-team@polygon.technology> Maintainer: Polygon <release-team@polygon.technology>

View file

@ -1,5 +1,5 @@
Source: bor-profile Source: bor-profile
Version: 1.2.0-beta Version: 1.2.2
Section: develop Section: develop
Priority: standard Priority: standard
Maintainer: Polygon <release-team@polygon.technology> Maintainer: Polygon <release-team@polygon.technology>

View file

@ -1,5 +1,5 @@
Source: bor-profile Source: bor-profile
Version: 1.2.0-beta Version: 1.2.2
Section: develop Section: develop
Priority: standard Priority: standard
Maintainer: Polygon <release-team@polygon.technology> Maintainer: Polygon <release-team@polygon.technology>

View file

@ -1,5 +1,5 @@
Source: bor-profile Source: bor-profile
Version: 1.2.0-beta Version: 1.2.2
Section: develop Section: develop
Priority: standard Priority: standard
Maintainer: Polygon <release-team@polygon.technology> Maintainer: Polygon <release-team@polygon.technology>

View file

@ -1,5 +1,5 @@
Source: bor-profile Source: bor-profile
Version: 1.2.0-beta Version: 1.2.2
Section: develop Section: develop
Priority: standard Priority: standard
Maintainer: Polygon <release-team@polygon.technology> Maintainer: Polygon <release-team@polygon.technology>

View file

@ -21,10 +21,10 @@ import (
) )
const ( const (
VersionMajor = 1 // Major version component of the current release VersionMajor = 1 // Major version component of the current release
VersionMinor = 2 // Minor version component of the current release VersionMinor = 2 // Minor version component of the current release
VersionPatch = 0 // Patch version component of the current release VersionPatch = 2 // Patch version component of the current release
VersionMeta = "beta" // Version metadata to append to the version string VersionMeta = "" // Version metadata to append to the version string
) )
var GitCommit string var GitCommit string