Merge develop branch

This commit is contained in:
kamuikatsurgi 2025-01-31 10:21:37 +05:30
commit 2d2dbcc398
No known key found for this signature in database
40 changed files with 319 additions and 1256 deletions

View file

@ -1,8 +1,7 @@
# NOTE: Uncomment and configure the following 8 fields in case you run a validator:
# `mine`, `etherbase`, `nodiscover`, `maxpeers`, `keystore`, `allow-insecure-unlock`, `password`, `unlock`
chain = "mainnet"
# chain = "mumbai", "amoy"
chain = "mainnet" # Set it to `amoy` for testnet
# identity = "Annon-Identity"
# verbosity = 3
# vmdebug = false
@ -42,13 +41,16 @@ syncmode = "full"
# v4disc = true
# v5disc = false
bootnodes = ["enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303", "enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303"]
# Uncomment below `bootnodes` field for Mumbai bootnode
# bootnodes = ["enode://bdcd4786a616a853b8a041f53496d853c68d99d54ff305615cd91c03cd56895e0a7f6e9f35dbf89131044e2114a9a782b792b5661e3aff07faf125a98606a071@43.200.206.40:30303", "enode://209aaf7ed549cf4a5700fd833da25413f80a1248bd3aa7fe2a87203e3f7b236dd729579e5c8df61c97bf508281bae4969d6de76a7393bcbd04a0af70270333b3@54.216.248.9:30303"]
# Uncomment below `bootnodes` field for Amoy
# bootnodes = ["enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303"]
# bootnodesv4 = []
# bootnodesv5 = []
# static-nodes = []
# trusted-nodes = []
# dns = []
dns = [ "enrtree://AKUEZKN7PSKVNR65FZDHECMKOJQSGPARGTPPBI7WS2VUL4EGR6XPC@pos.polygon-peers.io" ] # For pos mainnet
# Uncomment below `dns` field for Amoy
# dns = [ "enrtree://AKUEZKN7PSKVNR65FZDHECMKOJQSGPARGTPPBI7WS2VUL4EGR6XPC@amoy.polygon-peers.io" ]
# [heimdall]
# url = "http://localhost:1317"
@ -179,6 +181,7 @@ syncmode = "full"
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# [pprof]
# pprof = false

View file

@ -17,7 +17,6 @@
package beacon
import (
"context"
"errors"
"fmt"
"math/big"
@ -398,9 +397,9 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
//
// Note, the method returns immediately and will send the result async. More
// than one result may also be returned depending on the consensus algorithm.
func (beacon *Beacon) Seal(ctx context.Context, chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
func (beacon *Beacon) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
if !beacon.IsPoSHeader(block.Header()) {
return beacon.ethone.Seal(ctx, chain, block, results, stop)
return beacon.ethone.Seal(chain, block, results, stop)
}
// The seal verification is done by the external consensus engine,
// return directly without pushing any block back. In another word

View file

@ -17,13 +17,10 @@ import (
lru "github.com/hashicorp/golang-lru"
"github.com/holiman/uint256"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"golang.org/x/crypto/sha3"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/tracing"
balance_tracing "github.com/ethereum/go-ethereum/core/tracing"
"github.com/ethereum/go-ethereum/consensus"
@ -820,30 +817,28 @@ func (c *Bor) Prepare(chain consensus.ChainHeaderReader, header *types.Header) e
// Finalize implements consensus.Engine, ensuring no uncles are set, nor block
// rewards given.
func (c *Bor) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body) {
headerNumber := header.Number.Uint64()
if body.Withdrawals != nil || header.WithdrawalsHash != nil {
return
}
var (
stateSyncData []*types.StateSyncData
err error
)
headerNumber := header.Number.Uint64()
if body.Withdrawals != nil || header.WithdrawalsHash != nil {
return
}
if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
start := time.Now()
ctx := context.Background()
cx := statefull.ChainContext{Chain: chain, Bor: c}
// check and commit span
if err := c.checkAndCommitSpan(ctx, state, header, cx); err != nil {
if err := c.checkAndCommitSpan(state, header, cx); err != nil {
log.Error("Error while committing span", "error", err)
return
}
if c.HeimdallClient != nil {
// commit states
stateSyncData, err = c.CommitStates(ctx, state, header, cx)
stateSyncData, err = c.CommitStates(state, header, cx)
if err != nil {
log.Error("Error while committing states", "error", err)
return
@ -908,38 +903,28 @@ func (c *Bor) changeContractCodeIfNeeded(headerNumber uint64, state *state.State
// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set,
// nor block rewards given, and returns the final block.
func (c *Bor) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, body *types.Body, receipts []*types.Receipt) (*types.Block, error) {
finalizeCtx, finalizeSpan := tracing.StartSpan(context.Background(), "bor.FinalizeAndAssemble")
defer tracing.EndSpan(finalizeSpan)
headerNumber := header.Number.Uint64()
if body.Withdrawals != nil || header.WithdrawalsHash != nil {
return nil, consensus.ErrUnexpectedWithdrawals
}
stateSyncData := []*types.StateSyncData{}
var err error
var (
stateSyncData []*types.StateSyncData
err error
)
if IsSprintStart(headerNumber, c.config.CalculateSprint(headerNumber)) {
cx := statefull.ChainContext{Chain: chain, Bor: c}
tracing.Exec(finalizeCtx, "", "bor.checkAndCommitSpan", func(ctx context.Context, span trace.Span) {
// check and commit span
err = c.checkAndCommitSpan(finalizeCtx, state, header, cx)
})
if err != nil {
if err = c.checkAndCommitSpan(state, header, cx); err != nil {
log.Error("Error while committing span", "error", err)
return nil, err
}
if c.HeimdallClient != nil {
tracing.Exec(finalizeCtx, "", "bor.checkAndCommitSpan", func(ctx context.Context, span trace.Span) {
// commit states
stateSyncData, err = c.CommitStates(finalizeCtx, state, header, cx)
})
stateSyncData, err = c.CommitStates(state, header, cx)
if err != nil {
log.Error("Error while committing states", "error", err)
return nil, err
@ -947,19 +932,13 @@ func (c *Bor) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *typ
}
}
tracing.Exec(finalizeCtx, "", "bor.changeContractCodeIfNeeded", func(ctx context.Context, span trace.Span) {
err = c.changeContractCodeIfNeeded(headerNumber, state)
})
if err != nil {
if err = c.changeContractCodeIfNeeded(headerNumber, state); err != nil {
log.Error("Error changing contract code", "error", err)
return nil, err
}
// No block rewards in PoA, so the state remains as it is
tracing.Exec(finalizeCtx, "", "bor.IntermediateRoot", func(ctx context.Context, span trace.Span) {
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
})
// Uncles are dropped
header.UncleHash = types.CalcUncleHash(nil)
@ -971,14 +950,6 @@ func (c *Bor) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *typ
bc := chain.(core.BorStateSyncer)
bc.SetStateSync(stateSyncData)
tracing.SetAttributes(
finalizeSpan,
attribute.Int("number", int(header.Number.Int64())),
attribute.String("hash", header.Hash().String()),
attribute.Int("number of txs", len(body.Transactions)),
attribute.Int("gas used", int(block.GasUsed())),
)
// return the final block for sealing
return block, nil
}
@ -994,18 +965,7 @@ func (c *Bor) Authorize(currentSigner common.Address, signFn SignerFn) {
// Seal implements consensus.Engine, attempting to create a sealed block using
// the local signing credentials.
func (c *Bor) Seal(ctx context.Context, chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
_, sealSpan := tracing.StartSpan(ctx, "bor.Seal")
var endSpan bool = true
defer func() {
// Only end span in case of early-returns/errors
if endSpan {
tracing.EndSpan(sealSpan)
}
}()
func (c *Bor) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
header := block.Header()
// Sealing the genesis block is not supported
number := header.Number.Uint64()
@ -1051,7 +1011,7 @@ func (c *Bor) Seal(ctx context.Context, chain consensus.ChainHeaderReader, block
// Wait until sealing is terminated or delay timeout.
log.Info("Waiting for slot to sign and propagate", "number", number, "hash", header.Hash, "delay-in-sec", uint(delay), "delay", common.PrettyDuration(delay))
go func(sealSpan trace.Span) {
go func() {
select {
case <-stop:
log.Debug("Discarding sealing operation for block", "number", number)
@ -1074,27 +1034,13 @@ func (c *Bor) Seal(ctx context.Context, chain consensus.ChainHeaderReader, block
"delay", delay,
"headerDifficulty", header.Difficulty,
)
tracing.SetAttributes(
sealSpan,
attribute.Int("number", int(number)),
attribute.String("hash", header.Hash().String()),
attribute.Int("delay", int(delay.Milliseconds())),
attribute.Int("wiggle", int(wiggle.Milliseconds())),
attribute.Bool("out-of-turn", wiggle > 0),
)
tracing.EndSpan(sealSpan)
}
select {
case results <- block.WithSeal(header):
default:
log.Warn("Sealing result was not read by miner", "number", number, "sealhash", SealHash(header, c.config))
}
}(sealSpan)
// Set the endSpan flag to false, as the go routine will handle it
endSpan = false
}()
return nil
}
@ -1150,11 +1096,11 @@ func (c *Bor) Close() error {
}
func (c *Bor) checkAndCommitSpan(
ctx context.Context,
state *state.StateDB,
header *types.Header,
chain core.ChainContext,
) error {
var ctx = context.Background()
headerNumber := header.Number.Uint64()
span, err := c.spanner.GetCurrentSpan(ctx, header.ParentHash)
@ -1228,7 +1174,6 @@ func (c *Bor) FetchAndCommitSpan(
// CommitStates commit states
func (c *Bor) CommitStates(
ctx context.Context,
state *state.StateDB,
header *types.Header,
chain statefull.ChainContext,
@ -1269,7 +1214,7 @@ func (c *Bor) CommitStates(
"fromID", from,
"to", to.Format(time.RFC3339))
eventRecords, err := c.HeimdallClient.StateSyncEvents(ctx, from, to.Unix())
eventRecords, err := c.HeimdallClient.StateSyncEvents(context.Background(), from, to.Unix())
if err != nil {
log.Error("Error occurred when fetching state sync events", "fromID", from, "to", to.Unix(), "err", err)
}

View file

@ -19,7 +19,6 @@ package clique
import (
"bytes"
"context"
"errors"
"fmt"
"io"
@ -652,7 +651,7 @@ func (c *Clique) Authorize(signer common.Address, signFn SignerFn) {
// Seal implements consensus.Engine, attempting to create a sealed block using
// the local signing credentials.
func (c *Clique) Seal(ctx context.Context, chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
func (c *Clique) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
header := block.Header()
// Sealing the genesis block is not supported

View file

@ -18,7 +18,6 @@
package consensus
import (
"context"
"math/big"
"github.com/ethereum/go-ethereum/common"
@ -103,7 +102,7 @@ type Engine interface {
//
// Note, the method returns immediately and will send the result async. More
// than one result may also be returned depending on the consensus algorithm.
Seal(ctx context.Context, chain ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error
Seal(chain ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error
// SealHash returns the hash of a block prior to it being sealed.
SealHash(header *types.Header) common.Hash

View file

@ -18,7 +18,6 @@
package ethash
import (
"context"
"time"
"github.com/ethereum/go-ethereum/consensus"
@ -81,6 +80,6 @@ func (ethash *Ethash) APIs(chain consensus.ChainHeaderReader) []rpc.API {
// Seal generates a new sealing request for the given input block and pushes
// the result into the given channel. For the ethash engine, this method will
// just panic as sealing is not supported anymore.
func (ethash *Ethash) Seal(ctx context.Context, chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
func (ethash *Ethash) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
panic("ethash (pow) sealing not supported any more")
}

View file

@ -281,6 +281,7 @@ type BlockChain struct {
processor Processor // Block transaction processor interface
parallelProcessor Processor // Parallel block transaction processor interface
parallelSpeculativeProcesses int // Number of parallel speculative processes
enforceParallelProcessor bool
forker *ForkChoice
vmConfig vm.Config
logger *tracing.Hooks
@ -551,7 +552,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
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) {
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, enforce bool) (*BlockChain, error) {
bc, err := NewBlockChain(db, cacheConfig, genesis, overrides, engine, vmConfig, shouldPreserve, txLookupLimit, checker)
if err != nil {
@ -569,6 +570,7 @@ func NewParallelBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis
bc.parallelProcessor = NewParallelStateProcessor(chainConfig, bc, engine)
bc.parallelSpeculativeProcesses = numprocs
bc.enforceParallelProcessor = enforce
return bc, nil
}
@ -604,7 +606,12 @@ func (bc *BlockChain) ProcessBlock(block *types.Block, parent *types.Header) (_
parallel bool
}
resultChan := make(chan Result, 2)
var resultChanLen int = 2
if bc.enforceParallelProcessor {
log.Debug("Processing block using Block STM only", "number", block.NumberU64())
resultChanLen = 1
}
resultChan := make(chan Result, resultChanLen)
processorCount := 0
@ -631,7 +638,7 @@ func (bc *BlockChain) ProcessBlock(block *types.Block, parent *types.Header) (_
}()
}
if bc.processor != nil {
if bc.processor != nil && !bc.enforceParallelProcessor {
statedb, err := state.New(parent.Root, bc.stateCache, bc.snaps)
if err != nil {
return nil, nil, 0, nil, 0, err
@ -1922,18 +1929,18 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
// WriteBlockAndSetHead writes the given block and all associated state to the database,
// and applies the block as the new chain head.
func (bc *BlockChain) WriteBlockAndSetHead(ctx context.Context, block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
func (bc *BlockChain) WriteBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
if !bc.chainmu.TryLock() {
return NonStatTy, errChainStopped
}
defer bc.chainmu.Unlock()
return bc.writeBlockAndSetHead(ctx, block, receipts, logs, state, emitHeadEvent)
return bc.writeBlockAndSetHead(block, receipts, logs, state, emitHeadEvent)
}
// writeBlockAndSetHead is the internal implementation of WriteBlockAndSetHead.
// This function expects the chain mutex to be held.
func (bc *BlockChain) writeBlockAndSetHead(ctx context.Context, block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types.Receipt, logs []*types.Log, state *state.StateDB, emitHeadEvent bool) (status WriteStatus, err error) {
stateSyncLogs, err := bc.writeBlockWithState(block, receipts, logs, state)
if err != nil {
return NonStatTy, err
@ -2386,7 +2393,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
// Before the actual db insertion happens, verify the block against the whitelisted
// milestone and checkpoint. This is to prevent a race condition where a milestone
// or checkpoint was whitelisted while the block execution happened (and wasn't
// available sometime before) and the block turns out to be inavlid (i.e. not
// available sometime before) and the block turns out to be invalid (i.e. not
// honouring the milestone or checkpoint). Use the block itself as current block
// so that it's considered as a `past` chain and the validation doesn't get bypassed.
isValid, err = bc.forker.ValidateReorg(block.Header(), []*types.Header{block.Header()})
@ -2401,7 +2408,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
// Don't set the head, only insert the block
_, err = bc.writeBlockWithState(block, receipts, logs, statedb)
} else {
status, err = bc.writeBlockAndSetHead(context.Background(), block, receipts, logs, statedb, false)
status, err = bc.writeBlockAndSetHead(block, receipts, logs, statedb, false)
}
followupInterrupt.Store(true)
@ -2574,7 +2581,7 @@ func (bc *BlockChain) processBlock(block *types.Block, statedb *state.StateDB, s
// Don't set the head, only insert the block
_, err = bc.writeBlockWithState(block, receipts, logs, statedb)
} else {
status, err = bc.writeBlockAndSetHead(context.Background(), block, receipts, logs, statedb, false)
status, err = bc.writeBlockAndSetHead(block, receipts, logs, statedb, false)
}
if err != nil {
return nil, err

View file

@ -195,11 +195,14 @@ func testBlockChainImport(chain types.Blocks, blockchain *BlockChain) error {
func TestParallelBlockChainImport(t *testing.T) {
t.Parallel()
testParallelBlockChainImport(t, rawdb.HashScheme)
testParallelBlockChainImport(t, rawdb.PathScheme)
testParallelBlockChainImport(t, rawdb.HashScheme, false)
testParallelBlockChainImport(t, rawdb.PathScheme, false)
testParallelBlockChainImport(t, rawdb.HashScheme, true)
testParallelBlockChainImport(t, rawdb.PathScheme, true)
}
func testParallelBlockChainImport(t *testing.T, scheme string) {
func testParallelBlockChainImport(t *testing.T, scheme string, enforceParallelProcessor bool) {
db, _, blockchain, err := newCanonical(ethash.NewFaker(), 10, true, scheme)
blockchain.parallelProcessor = NewParallelStateProcessor(blockchain.chainConfig, blockchain, blockchain.engine)
@ -207,6 +210,8 @@ func testParallelBlockChainImport(t *testing.T, scheme string) {
t.Fatalf("failed to make new canonical chain: %v", err)
}
// If required, enforce parallel block processing and skip serial processing completely
blockchain.enforceParallelProcessor = enforceParallelProcessor
defer blockchain.Stop()
block := blockchain.GetBlockByHash(blockchain.CurrentBlock().Hash())

View file

@ -40,6 +40,7 @@ import (
type ParallelEVMConfig struct {
Enable bool
SpeculativeProcesses int
Enforce bool
}
// StateProcessor is a basic Processor, which takes care of transitioning

View file

@ -217,7 +217,7 @@ func WriteOffsetOfLastAncientFreezer(db ethdb.KeyValueWriter, offset uint64) {
// NewDatabaseWithOnlyFreezer create a freezer db without state
func NewDatabaseWithOnlyFreezer(db ethdb.KeyValueStore, frz, namespace string, readonly bool, newOffSet uint64) (*Freezer, error) {
// Create the idle freezer instance, this operation should be atomic to avoid mismatch between offset and acientDB.
// Create the idle freezer instance, this operation should be atomic to avoid mismatch between offset and ancientDB.
frdb, err := NewChainFreezer(frz, namespace, readonly, newOffSet)
if err != nil {
return nil, err

View file

@ -152,7 +152,7 @@ func NewFreezer(datadir string, namespace string, readonly bool, offset uint64,
}
// Some blocks in ancientDB may have already been frozen and been pruned, so adding the offset to
// reprensent the absolute number of blocks already frozen.
// represent the absolute number of blocks already frozen.
freezer.frozen.Add(offset)
// Create the write batch.

View file

@ -71,9 +71,11 @@ func TestTxIndexer(t *testing.T) {
}
verify := func(db ethdb.Database, expTail uint64, indexer *txIndexer) {
tail := rawdb.ReadTxIndexTail(db)
//nolint: staticcheck
if tail == nil {
t.Fatal("Failed to write tx index tail")
}
//nolint: staticcheck
if *tail != expTail {
t.Fatalf("Unexpected tx index tail, want %v, got %d", expTail, *tail)
}

View file

@ -41,10 +41,12 @@ var (
ErrNoCurrentTx = errors.New("no current tx found in interruptCtx")
)
type InterruptKeyType string
const (
// These are keys for the interruptCtx
InterruptCtxDelayKey = "delay"
InterruptCtxOpcodeDelayKey = "opcodeDelay"
InterruptCtxDelayKey InterruptKeyType = "delay"
InterruptCtxOpcodeDelayKey InterruptKeyType = "opcodeDelay"
// InterruptedTxCacheSize is size of lru cache for interrupted txs
InterruptedTxCacheSize = 90000

View file

@ -204,6 +204,9 @@ func UnmarshalPubkey(pub []byte) (*ecdsa.PublicKey, error) {
if x == nil {
return nil, errInvalidPubkey
}
if !S256().IsOnCurve(x, y) {
return nil, errInvalidPubkey
}
return &ecdsa.PublicKey{Curve: S256(), X: x, Y: y}, nil
}

View file

@ -1,8 +1,8 @@
# This configuration file is for reference and learning purpose only.
# The default value of the flags is provided below (except a few flags which has custom defaults which are explicitly mentioned).
# Recommended values for mainnet and/or mumbai,amoy are also provided.
# Recommended values for mainnet and/or amoy are also provided.
chain = "mainnet" # Name of the chain to sync ("amoy", "mumbai", "mainnet") or path to a genesis file
chain = "mainnet" # Name of the chain to sync ("mainnet" or "amoy") or path to a genesis file
identity = "Annon-Identity" # Name/Identity of the node (default = OS hostname)
verbosity = 3 # Logging verbosity for the server (5=trace|4=debug|3=info|2=warn|1=error|0=crit) (`log-level` was replaced by `verbosity`, and thus will be deprecated soon)
vmdebug = false # Record information useful for VM and contract debugging
@ -153,7 +153,7 @@ devfakeauthor = false # Run miner without validator set authorization
region = "us-north-1"
[cache]
cache = 1024 # Megabytes of memory allocated to internal caching (recommended for mainnet = 4096, default suitable for amoy/mumbai/devnet)
cache = 1024 # Megabytes of memory allocated to internal caching (recommended for mainnet = 4096, default suitable for amoy/devnet)
gc = 25 # Percentage of cache memory allowance to use for trie pruning (default = 25% full mode, 0% archive mode)
snapshot = 10 # Percentage of cache memory allowance to use for snapshot caching (default = 10% full mode, 20% archive mode)
database = 50 # Percentage of cache memory allowance to use for database io
@ -181,6 +181,11 @@ devfakeauthor = false # Run miner without validator set authorization
period = 0 # Block period to use in developer mode (0 = mine only if transaction pending)
gaslimit = 11500000 # Initial block gas limit
[parallelevm]
enable = true # Enables parallel execution using Block STM
procs = 8 # Number of speculative processes (cores) in Block STM
enforce = false # Use only Block STM for execution and skip serial execution
[pprof]
pprof = false # Enable the pprof HTTP server
port = 6060 # pprof HTTP server listening port

View file

@ -66,6 +66,8 @@ The ```bor server``` command runs the Bor client.
- ```parallelevm.enable```: Enable Block STM (default: true)
- ```parallelevm.enforce```: Enforce block processing via Block STM (default: false)
- ```parallelevm.procs```: Number of speculative processes (cores) in Block STM (default: 8)
- ```pprof```: Enable the pprof HTTP server (default: false)

View file

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

View file

@ -559,7 +559,7 @@ func TestIsValidChain(t *testing.T) {
s.ProcessMilestone(tempChain[1].Number.Uint64(), tempChain[1].Hash())
// case10: Try importing a past chain having valid checkpoint, should
// consider the chain as invalid as still lastest milestone is ahead of the chain.
// consider the chain as invalid as still latest milestone is ahead of the chain.
res, err = s.IsValidChain(tempChain[1], chainA)
require.Nil(t, err)
require.Equal(t, res, false, "expected chain to be invalid")

View file

@ -597,6 +597,8 @@ type ParallelEVMConfig struct {
Enable bool `hcl:"enable,optional" toml:"enable,optional"`
SpeculativeProcesses int `hcl:"procs,optional" toml:"procs,optional"`
Enforce bool `hcl:"enforce,optional" toml:"enforce,optional"`
}
func DefaultConfig() *Config {
@ -794,6 +796,7 @@ func DefaultConfig() *Config {
ParallelEVM: &ParallelEVMConfig{
Enable: true,
SpeculativeProcesses: 8,
Enforce: false,
},
}
}
@ -1199,6 +1202,7 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (*
n.ParallelEVM.Enable = c.ParallelEVM.Enable
n.ParallelEVM.SpeculativeProcesses = c.ParallelEVM.SpeculativeProcesses
n.ParallelEVM.Enforce = c.ParallelEVM.Enforce
n.RPCReturnDataLimit = c.RPCReturnDataLimit
if c.Ancient != "" {

View file

@ -986,6 +986,13 @@ func (c *Command) Flags(config *Config) *flagset.Flagset {
Value: &c.cliConfig.ParallelEVM.SpeculativeProcesses,
Default: c.cliConfig.ParallelEVM.SpeculativeProcesses,
})
f.BoolFlag(&flagset.BoolFlag{
Name: "parallelevm.enforce",
Usage: "Enforce block processing via Block STM",
Value: &c.cliConfig.ParallelEVM.Enforce,
Default: c.cliConfig.ParallelEVM.Enforce,
})
f.Uint64Flag(&flagset.Uint64Flag{
Name: "dev.gaslimit",
Usage: "Initial block gas limit",

View file

@ -185,6 +185,7 @@ devfakeauthor = false
[parallelevm]
enable = true
procs = 8
enforce = false
[pprof]
pprof = false

View file

@ -1,762 +0,0 @@
package miner
import (
"context"
"errors"
"fmt"
"os"
"sync"
"sync/atomic"
"time"
// nolint:typecheck
"github.com/ethereum/go-ethereum/common"
cmath "github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/common/tracing"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/blockstm"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/holiman/uint256"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
lru "github.com/hashicorp/golang-lru"
)
// newWorkerWithDelay is newWorker() with extra params to induce artficial delays for tests such as commit-interrupt.
// nolint:staticcheck
func newWorkerWithDelay(config *Config, chainConfig *params.ChainConfig, engine consensus.Engine, eth Backend, mux *event.TypeMux, isLocalBlock func(header *types.Header) bool, init bool, delay uint, opcodeDelay uint) *worker {
worker := &worker{
config: config,
chainConfig: chainConfig,
engine: engine,
eth: eth,
chain: eth.BlockChain(),
mux: mux,
isLocalBlock: isLocalBlock,
coinbase: config.Etherbase,
extra: config.ExtraData,
pendingTasks: make(map[common.Hash]*task),
txsCh: make(chan core.NewTxsEvent, txChanSize),
chainHeadCh: make(chan core.ChainHeadEvent, chainHeadChanSize),
newWorkCh: make(chan *newWorkReq),
getWorkCh: make(chan *getWorkReq),
taskCh: make(chan *task),
resultCh: make(chan *types.Block, resultQueueSize),
startCh: make(chan struct{}, 1),
exitCh: make(chan struct{}),
resubmitIntervalCh: make(chan time.Duration),
resubmitAdjustCh: make(chan *intervalAdjust, resubmitAdjustChanSize),
interruptCommitFlag: config.CommitInterruptFlag,
}
worker.noempty.Store(true)
worker.profileCount = new(int32)
// Subscribe for transaction insertion events (whether from network or resurrects)
worker.txsSub = eth.TxPool().SubscribeTransactions(worker.txsCh, true)
// Subscribe events for blockchain
worker.chainHeadSub = eth.BlockChain().SubscribeChainHeadEvent(worker.chainHeadCh)
interruptedTxCache, err := lru.New(vm.InterruptedTxCacheSize)
if err != nil {
log.Warn("Failed to create interrupted tx cache", "err", err)
}
worker.interruptedTxCache = &vm.TxCache{
Cache: interruptedTxCache,
}
if !worker.interruptCommitFlag {
worker.noempty.Store(false)
}
// Sanitize recommit interval if the user-specified one is too short.
recommit := worker.config.Recommit
if recommit < minRecommitInterval {
log.Warn("Sanitizing miner recommit interval", "provided", recommit, "updated", minRecommitInterval)
recommit = minRecommitInterval
}
worker.recommit = recommit
// Sanitize the timeout config for creating payload.
newpayloadTimeout := worker.config.NewPayloadTimeout
if newpayloadTimeout == 0 {
log.Warn("Sanitizing new payload timeout to default", "provided", newpayloadTimeout, "updated", DefaultConfig.NewPayloadTimeout)
newpayloadTimeout = DefaultConfig.NewPayloadTimeout
}
if newpayloadTimeout < time.Millisecond*100 {
log.Warn("Low payload timeout may cause high amount of non-full blocks", "provided", newpayloadTimeout, "default", DefaultConfig.NewPayloadTimeout)
}
worker.newpayloadTimeout = newpayloadTimeout
ctx := tracing.WithTracer(context.Background(), otel.GetTracerProvider().Tracer("MinerWorker"))
worker.wg.Add(4)
go worker.mainLoopWithDelay(ctx, delay, opcodeDelay)
go worker.newWorkLoop(ctx, recommit)
go worker.resultLoop()
go worker.taskLoop()
// Submit first work to initialize pending state.
if init {
worker.startCh <- struct{}{}
}
return worker
}
// mainLoopWithDelay is mainLoop() with extra params to induce artficial delays for tests such as commit-interrupt.
// nolint:gocognit
func (w *worker) mainLoopWithDelay(ctx context.Context, delay uint, opcodeDelay uint) {
defer w.wg.Done()
defer w.txsSub.Unsubscribe()
defer w.chainHeadSub.Unsubscribe()
defer func() {
if w.current != nil {
w.current.discard()
}
}()
for {
select {
case req := <-w.newWorkCh:
if w.chainConfig.ChainID.Cmp(params.BorMainnetChainConfig.ChainID) == 0 || w.chainConfig.ChainID.Cmp(params.MumbaiChainConfig.ChainID) == 0 {
if w.eth.PeerCount() > 0 {
//nolint:contextcheck
w.commitWorkWithDelay(req.ctx, req.interrupt, req.noempty, req.timestamp, delay, opcodeDelay)
}
} else {
//nolint:contextcheck
w.commitWorkWithDelay(req.ctx, req.interrupt, req.noempty, req.timestamp, delay, opcodeDelay)
}
case req := <-w.getWorkCh:
req.result <- w.generateWork(ctx, req.params)
case ev := <-w.txsCh:
// Apply transactions to the pending state if we're not sealing
//
// Note all transactions received may not be continuous with transactions
// already included in the current sealing block. These transactions will
// be automatically eliminated.
// nolint : nestif
if !w.IsRunning() && w.current != nil {
// If block is already full, abort
if gp := w.current.gasPool; gp != nil && gp.Gas() < params.TxGas {
continue
}
txs := make(map[common.Address][]*txpool.LazyTransaction, len(ev.Txs))
for _, tx := range ev.Txs {
acc, _ := types.Sender(w.current.signer, tx)
txs[acc] = append(txs[acc], &txpool.LazyTransaction{
Pool: w.eth.TxPool(), // We don't know where this came from, yolo resolve from everywhere
Hash: tx.Hash(),
Tx: nil, // Do *not* set this! We need to resolve it later to pull blobs in
Time: tx.Time(),
GasFeeCap: uint256.NewInt(tx.GasFeeCap().Uint64()),
GasTipCap: uint256.NewInt(tx.GasTipCap().Uint64()),
Gas: tx.Gas(),
BlobGas: tx.BlobGas(),
})
}
txset := newTransactionsByPriceAndNonce(w.current.signer, txs, w.current.header.BaseFee)
tcount := w.current.tcount
w.commitTransactions(w.current, txset, nil, nil, new(uint256.Int), context.Background())
// Only update the snapshot if any new transactons were added
// to the pending block
if tcount != w.current.tcount {
w.updateSnapshot(w.current)
}
} else {
// Special case, if the consensus engine is 0 period clique(dev mode),
// submit sealing work here since all empty submission will be rejected
// by clique. Of course the advance sealing(empty submission) is disabled.
if w.chainConfig.Clique != nil && w.chainConfig.Clique.Period == 0 {
w.commitWork(ctx, nil, true, time.Now().Unix())
}
}
w.newTxs.Add(int32(len(ev.Txs)))
// System stopped
case <-w.exitCh:
return
case <-w.txsSub.Err():
return
case <-w.chainHeadSub.Err():
return
}
}
}
// commitWorkWithDelay is commitWork() with extra params to induce artficial delays for tests such as commit-interrupt.
func (w *worker) commitWorkWithDelay(ctx context.Context, interrupt *atomic.Int32, noempty bool, timestamp int64, delay uint, opcodeDelay uint) {
// Abort committing if node is still syncing
if w.syncing.Load() {
return
}
start := time.Now()
var (
work *environment
err error
)
tracing.Exec(ctx, "", "worker.prepareWork", func(ctx context.Context, span trace.Span) {
// Set the coinbase if the worker is running or it's required
var coinbase common.Address
if w.IsRunning() {
coinbase = w.etherbase()
if coinbase == (common.Address{}) {
log.Error("Refusing to mine without etherbase")
return
}
}
work, err = w.prepareWork(&generateParams{
timestamp: uint64(timestamp),
coinbase: coinbase,
})
})
if err != nil {
return
}
// nolint:contextcheck
var interruptCtx = context.Background()
stopFn := func() {}
defer func() {
stopFn()
}()
if !noempty && w.interruptCommitFlag {
block := w.chain.GetBlockByHash(w.chain.CurrentBlock().Hash())
interruptCtx, stopFn = getInterruptTimer(ctx, work, block)
// nolint : staticcheck
interruptCtx = vm.PutCache(interruptCtx, w.interruptedTxCache)
// nolint : staticcheck
interruptCtx = context.WithValue(interruptCtx, vm.InterruptCtxDelayKey, delay)
// nolint : staticcheck
interruptCtx = context.WithValue(interruptCtx, vm.InterruptCtxOpcodeDelayKey, opcodeDelay)
}
ctx, span := tracing.StartSpan(ctx, "commitWork")
defer tracing.EndSpan(span)
tracing.SetAttributes(
span,
attribute.Int("number", int(work.header.Number.Uint64())),
)
// Create an empty block based on temporary copied state for
// sealing in advance without waiting block execution finished.
if !noempty && !w.noempty.Load() {
_ = w.commit(ctx, work.copy(), nil, false, start)
}
// Fill pending transactions from the txpool into the block.
err = w.fillTransactionsWithDelay(ctx, interrupt, work, interruptCtx)
switch {
case err == nil:
// The entire block is filled, decrease resubmit interval in case
// of current interval is larger than the user-specified one.
w.resubmitAdjustCh <- &intervalAdjust{inc: false}
case errors.Is(err, errBlockInterruptedByRecommit):
// Notify resubmit loop to increase resubmitting interval if the
// interruption is due to frequent commits.
gaslimit := work.header.GasLimit
ratio := float64(gaslimit-work.gasPool.Gas()) / float64(gaslimit)
if ratio < 0.1 {
ratio = 0.1
}
w.resubmitAdjustCh <- &intervalAdjust{
ratio: ratio,
inc: true,
}
case errors.Is(err, errBlockInterruptedByNewHead):
// If the block building is interrupted by newhead event, discard it
// totally. Committing the interrupted block introduces unnecessary
// delay, and possibly causes miner to mine on the previous head,
// which could result in higher uncle rate.
work.discard()
return
}
// Submit the generated block for consensus sealing.
_ = w.commit(ctx, work.copy(), w.fullTaskHook, true, start)
// Swap out the old work with the new one, terminating any leftover
// prefetcher processes in the mean time and starting a new one.
if w.current != nil {
w.current.discard()
}
w.current = work
}
// fillTransactionsWithDelay is fillTransactions() with extra params to induce artficial delays for tests such as commit-interrupt.
// nolint:gocognit
func (w *worker) fillTransactionsWithDelay(ctx context.Context, interrupt *atomic.Int32, env *environment, interruptCtx context.Context) error {
ctx, span := tracing.StartSpan(ctx, "fillTransactions")
defer tracing.EndSpan(span)
// Split the pending transactions into locals and remotes
// Fill the block with all available pending transactions.
pending := w.eth.TxPool().Pending(txpool.PendingFilter{})
localTxs, remoteTxs := make(map[common.Address][]*txpool.LazyTransaction), pending
var (
localTxsCount int
remoteTxsCount int
)
// TODO: move to config or RPC
const profiling = false
if profiling {
doneCh := make(chan struct{})
defer func() {
close(doneCh)
}()
go func(number uint64) {
closeFn := func() error {
return nil
}
for {
select {
case <-time.After(150 * time.Millisecond):
// Check if we've not crossed limit
if attempt := atomic.AddInt32(w.profileCount, 1); attempt >= 10 {
log.Info("Completed profiling", "attempt", attempt)
return
}
log.Info("Starting profiling in fill transactions", "number", number)
dir, err := os.MkdirTemp("", fmt.Sprintf("bor-traces-%s-", time.Now().UTC().Format("2006-01-02-150405Z")))
if err != nil {
log.Error("Error in profiling", "path", dir, "number", number, "err", err)
return
}
// grab the cpu profile
closeFnInternal, err := startProfiler("cpu", dir, number)
if err != nil {
log.Error("Error in profiling", "path", dir, "number", number, "err", err)
return
}
closeFn = func() error {
err := closeFnInternal()
log.Info("Completed profiling", "path", dir, "number", number, "error", err)
return nil
}
case <-doneCh:
err := closeFn()
if err != nil {
log.Info("closing fillTransactions", "number", number, "error", err)
}
return
}
}
}(env.header.Number.Uint64())
}
tracing.Exec(ctx, "", "worker.SplittingTransactions", func(ctx context.Context, span trace.Span) {
prePendingTime := time.Now()
pending := w.eth.TxPool().Pending(txpool.PendingFilter{})
remoteTxs = pending
postPendingTime := time.Now()
for _, account := range w.eth.TxPool().Locals() {
if txs := remoteTxs[account]; len(txs) > 0 {
delete(remoteTxs, account)
localTxs[account] = txs
}
}
postLocalsTime := time.Now()
tracing.SetAttributes(
span,
attribute.Int("len of local txs", localTxsCount),
attribute.Int("len of remote txs", remoteTxsCount),
attribute.String("time taken by Pending()", fmt.Sprintf("%v", postPendingTime.Sub(prePendingTime))),
attribute.String("time taken by Locals()", fmt.Sprintf("%v", postLocalsTime.Sub(postPendingTime))),
)
})
var (
localEnvTCount int
remoteEnvTCount int
err error
)
if len(localTxs) > 0 {
var txs *transactionsByPriceAndNonce
tracing.Exec(ctx, "", "worker.LocalTransactionsByPriceAndNonce", func(ctx context.Context, span trace.Span) {
var baseFee *uint256.Int
if env.header.BaseFee != nil {
baseFee = cmath.FromBig(env.header.BaseFee)
}
txs = newTransactionsByPriceAndNonce(env.signer, localTxs, baseFee.ToBig())
tracing.SetAttributes(
span,
attribute.Int("len of tx local Heads", txs.GetTxs()),
)
})
tracing.Exec(ctx, "", "worker.LocalCommitTransactions", func(ctx context.Context, span trace.Span) {
err = w.commitTransactionsWithDelay(env, txs, interrupt, interruptCtx)
})
if err != nil {
return err
}
localEnvTCount = env.tcount
}
if len(remoteTxs) > 0 {
var txs *transactionsByPriceAndNonce
tracing.Exec(ctx, "", "worker.RemoteTransactionsByPriceAndNonce", func(ctx context.Context, span trace.Span) {
var baseFee *uint256.Int
if env.header.BaseFee != nil {
baseFee = cmath.FromBig(env.header.BaseFee)
}
txs = newTransactionsByPriceAndNonce(env.signer, remoteTxs, baseFee.ToBig())
tracing.SetAttributes(
span,
attribute.Int("len of tx remote Heads", txs.GetTxs()),
)
})
tracing.Exec(ctx, "", "worker.RemoteCommitTransactions", func(ctx context.Context, span trace.Span) {
err = w.commitTransactionsWithDelay(env, txs, interrupt, interruptCtx)
})
if err != nil {
return err
}
remoteEnvTCount = env.tcount
}
tracing.SetAttributes(
span,
attribute.Int("len of final local txs ", localEnvTCount),
attribute.Int("len of final remote txs", remoteEnvTCount),
)
return nil
}
// commitTransactionsWithDelay is commitTransactions() with extra params to induce artficial delays for tests such as commit-interrupt.
// nolint:gocognit, unparam
func (w *worker) commitTransactionsWithDelay(env *environment, txs *transactionsByPriceAndNonce, interrupt *atomic.Int32, interruptCtx context.Context) error {
gasLimit := env.header.GasLimit
if env.gasPool == nil {
env.gasPool = new(core.GasPool).AddGas(gasLimit)
}
var coalescedLogs []*types.Log
var depsMVReadList [][]blockstm.ReadDescriptor
var depsMVFullWriteList [][]blockstm.WriteDescriptor
var mvReadMapList []map[blockstm.Key]blockstm.ReadDescriptor
var deps map[int]map[int]bool
chDeps := make(chan blockstm.TxDep)
var count int
var depsWg sync.WaitGroup
EnableMVHashMap := w.chainConfig.IsCancun(env.header.Number)
// create and add empty mvHashMap in statedb
if EnableMVHashMap {
depsMVReadList = [][]blockstm.ReadDescriptor{}
depsMVFullWriteList = [][]blockstm.WriteDescriptor{}
mvReadMapList = []map[blockstm.Key]blockstm.ReadDescriptor{}
deps = map[int]map[int]bool{}
chDeps = make(chan blockstm.TxDep)
count = 0
depsWg.Add(1)
go func(chDeps chan blockstm.TxDep) {
for t := range chDeps {
deps = blockstm.UpdateDeps(deps, t)
}
depsWg.Done()
}(chDeps)
}
var lastTxHash common.Hash
mainloop:
for {
if interruptCtx != nil {
if EnableMVHashMap {
env.state.AddEmptyMVHashMap()
}
// case of interrupting by timeout
select {
case <-interruptCtx.Done():
txCommitInterruptCounter.Inc(1)
log.Warn("Tx Level Interrupt", "hash", lastTxHash)
break mainloop
default:
}
}
// Check interruption signal and abort building if it's fired.
if interrupt != nil {
if signal := interrupt.Load(); signal != commitInterruptNone {
return signalToErr(signal)
}
}
// If we don't have enough gas for any further transactions then we're done.
if env.gasPool.Gas() < params.TxGas {
log.Trace("Not enough gas for further transactions", "have", env.gasPool, "want", params.TxGas)
break
}
// Retrieve the next transaction and abort if all done.
ltx, _ := txs.Peek()
if ltx == nil {
break
}
lastTxHash = ltx.Hash
// If we don't have enough space for the next transaction, skip the account.
if env.gasPool.Gas() < ltx.Gas {
log.Trace("Not enough gas left for transaction", "hash", ltx.Hash, "left", env.gasPool.Gas(), "needed", ltx.Gas)
txs.Pop()
continue
}
if left := uint64(params.MaxBlobGasPerBlock - env.blobs*params.BlobTxBlobGasPerBlob); left < ltx.BlobGas {
log.Trace("Not enough blob gas left for transaction", "hash", ltx.Hash, "left", left, "needed", ltx.BlobGas)
txs.Pop()
continue
}
// Transaction seems to fit, pull it up from the pool
tx := ltx.Resolve()
if tx == nil {
log.Trace("Ignoring evicted transaction", "hash", ltx.Hash)
txs.Pop()
continue
}
// Error may be ignored here. The error has already been checked
// during transaction acceptance is the transaction pool.
from, _ := types.Sender(env.signer, tx)
// not prioritising conditional transaction, yet.
//nolint:nestif
if options := tx.GetOptions(); options != nil {
if err := env.header.ValidateBlockNumberOptionsPIP15(options.BlockNumberMin, options.BlockNumberMax); err != nil {
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
txs.Pop()
continue
}
if err := env.header.ValidateTimestampOptionsPIP15(options.TimestampMin, options.TimestampMax); err != nil {
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
txs.Pop()
continue
}
if err := env.state.ValidateKnownAccounts(options.KnownAccounts); err != nil {
log.Trace("Dropping conditional transaction", "from", from, "hash", tx.Hash(), "reason", err)
txs.Pop()
continue
}
}
// Check whether the tx is replay protected. If we're not in the EIP155 hf
// phase, start ignoring the sender until we do.
if tx.Protected() && !w.chainConfig.IsEIP155(env.header.Number) {
log.Trace("Ignoring replay protected transaction", "hash", ltx.Hash, "eip155", w.chainConfig.EIP155Block)
txs.Pop()
continue
}
// Start executing the transaction
env.state.SetTxContext(tx.Hash(), env.tcount)
logs, err := w.commitTransaction(env, tx, interruptCtx)
if interruptCtx != nil {
if delay := interruptCtx.Value(vm.InterruptCtxDelayKey); delay != nil {
// nolint : durationcheck
time.Sleep(time.Duration(delay.(uint)) * time.Millisecond)
}
}
switch {
case errors.Is(err, core.ErrNonceTooLow):
// New head notification data race between the transaction pool and miner, shift
log.Trace("Skipping transaction with low nonce", "hash", ltx.Hash, "sender", from, "nonce", tx.Nonce())
txs.Shift()
case errors.Is(err, nil):
// Everything ok, collect the logs and shift in the next transaction from the same account
coalescedLogs = append(coalescedLogs, logs...)
env.tcount++
if EnableMVHashMap {
depsMVReadList = append(depsMVReadList, env.state.MVReadList())
depsMVFullWriteList = append(depsMVFullWriteList, env.state.MVFullWriteList())
mvReadMapList = append(mvReadMapList, env.state.MVReadMap())
temp := blockstm.TxDep{
Index: env.tcount - 1,
ReadList: depsMVReadList[count],
FullWriteList: depsMVFullWriteList,
}
chDeps <- temp
count++
}
txs.Shift()
default:
// Transaction is regarded as invalid, drop all consecutive transactions from
// the same sender because of `nonce-too-high` clause.
log.Debug("Transaction failed, account skipped", "hash", ltx.Hash, "err", err)
txs.Pop()
}
if EnableMVHashMap {
env.state.ClearReadMap()
env.state.ClearWriteMap()
}
}
// nolint:nestif
if EnableMVHashMap && w.IsRunning() {
close(chDeps)
depsWg.Wait()
var blockExtraData types.BlockExtraData
tempVanity := env.header.Extra[:types.ExtraVanityLength]
tempSeal := env.header.Extra[len(env.header.Extra)-types.ExtraSealLength:]
if len(mvReadMapList) > 0 {
tempDeps := make([][]uint64, len(mvReadMapList))
for j := range deps[0] {
tempDeps[0] = append(tempDeps[0], uint64(j))
}
delayFlag := true
for i := 1; i <= len(mvReadMapList)-1; i++ {
reads := mvReadMapList[i-1]
_, ok1 := reads[blockstm.NewSubpathKey(env.coinbase, state.BalancePath)]
_, ok2 := reads[blockstm.NewSubpathKey(common.HexToAddress(w.chainConfig.Bor.CalculateBurntContract(env.header.Number.Uint64())), state.BalancePath)]
if ok1 || ok2 {
delayFlag = false
}
for j := range deps[i] {
tempDeps[i] = append(tempDeps[i], uint64(j))
}
}
if err := rlp.DecodeBytes(env.header.Extra[types.ExtraVanityLength:len(env.header.Extra)-types.ExtraSealLength], &blockExtraData); err != nil {
log.Error("error while decoding block extra data", "err", err)
return err
}
if delayFlag {
blockExtraData.TxDependency = tempDeps
} else {
blockExtraData.TxDependency = nil
}
} else {
blockExtraData.TxDependency = nil
}
blockExtraDataBytes, err := rlp.EncodeToBytes(blockExtraData)
if err != nil {
log.Error("error while encoding block extra data: %v", err)
return err
}
env.header.Extra = []byte{}
env.header.Extra = append(tempVanity, blockExtraDataBytes...)
env.header.Extra = append(env.header.Extra, tempSeal...)
}
if !w.IsRunning() && len(coalescedLogs) > 0 {
// We don't push the pendingLogsEvent while we are sealing. The reason is that
// when we are sealing, the worker will regenerate a sealing block every 3 seconds.
// In order to avoid pushing the repeated pendingLog, we disable the pending log pushing.
// make a copy, the state caches the logs and these logs get "upgraded" from pending to mined
// logs by filling in the block hash when the block was mined by the local miner. This can
// cause a race condition if a log was "upgraded" before the PendingLogsEvent is processed.
cpy := make([]*types.Log, len(coalescedLogs))
for i, l := range coalescedLogs {
cpy[i] = new(types.Log)
*cpy[i] = *l
}
w.pendingLogsFeed.Send(cpy)
}
return nil
}

View file

@ -17,15 +17,10 @@
package miner
import (
"bytes"
"context"
"errors"
"fmt"
"math/big"
"os"
"runtime"
"runtime/pprof"
ptrace "runtime/trace"
"sync"
"sync/atomic"
"time"
@ -33,8 +28,6 @@ import (
lru "github.com/hashicorp/golang-lru"
"github.com/holiman/uint256"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/tracing"
@ -155,8 +148,6 @@ func (env *environment) discard() {
// task contains all information for consensus engine sealing and result submitting.
type task struct {
//nolint:containedctx
ctx context.Context
receipts []*types.Receipt
state *state.StateDB
block *types.Block
@ -172,8 +163,6 @@ const (
// newWorkReq represents a request for new sealing work submitting with relative interrupt notifier.
type newWorkReq struct {
//nolint:containedctx
ctx context.Context
interrupt *atomic.Int32
noempty bool
timestamp int64
@ -272,8 +261,9 @@ type worker struct {
fullTaskHook func() // Method to call before pushing the full sealing task.
resubmitHook func(time.Duration, time.Duration) // Method to call upon updating resubmitting interval.
profileCount *int32 // Global count for profiling
interruptCommitFlag bool // Interrupt commit ( Default true )
// Interrupt commit to stop block building on time
interruptCommitFlag bool // Denotes whether interrupt commit is enabled or not
interruptCtx context.Context
interruptedTxCache *vm.TxCache
// noempty is the flag used to control whether the feature of pre-seal empty
@ -311,7 +301,6 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus
interruptCommitFlag: config.CommitInterruptFlag,
}
worker.noempty.Store(true)
worker.profileCount = new(int32)
// Subscribe for transaction insertion events (whether from network or resurrects)
worker.txsSub = eth.TxPool().SubscribeTransactions(worker.txsCh, true)
// Subscribe events for blockchain
@ -322,6 +311,7 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus
log.Warn("Failed to create interrupted tx cache", "err", err)
}
worker.interruptCtx = context.Background()
worker.interruptedTxCache = &vm.TxCache{
Cache: interruptedTxCache,
}
@ -352,12 +342,10 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, engine consensus
worker.newpayloadTimeout = newpayloadTimeout
ctx := tracing.WithTracer(context.Background(), otel.GetTracerProvider().Tracer("MinerWorker"))
worker.wg.Add(4)
go worker.mainLoop(ctx)
go worker.newWorkLoop(ctx, recommit)
go worker.mainLoop()
go worker.newWorkLoop(recommit)
go worker.resultLoop()
go worker.taskLoop()
@ -483,7 +471,7 @@ func recalcRecommit(minRecommit, prev time.Duration, target float64, inc bool) t
// newWorkLoop is a standalone goroutine to submit new sealing work upon received events.
//
//nolint:gocognit
func (w *worker) newWorkLoop(ctx context.Context, recommit time.Duration) {
func (w *worker) newWorkLoop(recommit time.Duration) {
defer w.wg.Done()
var (
@ -498,15 +486,13 @@ func (w *worker) newWorkLoop(ctx context.Context, recommit time.Duration) {
// commit aborts in-flight transaction execution with given signal and resubmits a new one.
commit := func(noempty bool, s int32) {
ctx, span := tracing.Trace(ctx, "worker.newWorkLoop.commit")
tracing.EndSpan(span)
if interrupt != nil {
interrupt.Store(s)
}
interrupt = new(atomic.Int32)
select {
case w.newWorkCh <- &newWorkReq{interrupt: interrupt, timestamp: timestamp, ctx: ctx, noempty: noempty}:
case w.newWorkCh <- &newWorkReq{interrupt: interrupt, timestamp: timestamp, noempty: noempty}:
case <-w.exitCh:
return
}
@ -515,9 +501,6 @@ func (w *worker) newWorkLoop(ctx context.Context, recommit time.Duration) {
}
// clearPending cleans the stale pending tasks.
clearPending := func(number uint64) {
_, span := tracing.Trace(ctx, "worker.newWorkLoop.clearPending")
tracing.EndSpan(span)
w.pendingMu.Lock()
for h, t := range w.pendingTasks {
if t.block.NumberU64()+staleThreshold <= number {
@ -594,7 +577,7 @@ func (w *worker) newWorkLoop(ctx context.Context, recommit time.Duration) {
// the received event. It can support two modes: automatically generate task and
// submit it or return task according to given parameters for various proposes.
// nolint: gocognit, contextcheck
func (w *worker) mainLoop(ctx context.Context) {
func (w *worker) mainLoop() {
defer w.wg.Done()
defer w.txsSub.Unsubscribe()
defer w.chainHeadSub.Unsubscribe()
@ -610,15 +593,15 @@ func (w *worker) mainLoop(ctx context.Context) {
if w.chainConfig.ChainID.Cmp(params.BorMainnetChainConfig.ChainID) == 0 || w.chainConfig.ChainID.Cmp(params.MumbaiChainConfig.ChainID) == 0 || w.chainConfig.ChainID.Cmp(params.AmoyChainConfig.ChainID) == 0 {
if w.eth.PeerCount() > 0 {
//nolint:contextcheck
w.commitWork(req.ctx, req.interrupt, req.noempty, req.timestamp)
w.commitWork(req.interrupt, req.noempty, req.timestamp)
}
} else {
//nolint:contextcheck
w.commitWork(req.ctx, req.interrupt, req.noempty, req.timestamp)
w.commitWork(req.interrupt, req.noempty, req.timestamp)
}
case req := <-w.getWorkCh:
req.result <- w.generateWork(ctx, req.params)
req.result <- w.generateWork(req.params)
case ev := <-w.txsCh:
// Apply transactions to the pending state if we're not sealing
@ -651,7 +634,7 @@ func (w *worker) mainLoop(ctx context.Context) {
tcount := w.current.tcount
w.commitTransactions(w.current, plainTxs, blobTxs, nil, new(uint256.Int), context.Background())
w.commitTransactions(w.current, plainTxs, blobTxs, nil, new(uint256.Int))
// Only update the snapshot if any new transactons were added
// to the pending block
@ -663,7 +646,7 @@ func (w *worker) mainLoop(ctx context.Context) {
// submit sealing work here since all empty submission will be rejected
// by clique. Of course the advance sealing(empty submission) is disabled.
if w.chainConfig.Clique != nil && w.chainConfig.Clique.Period == 0 {
w.commitWork(ctx, nil, true, time.Now().Unix())
w.commitWork(nil, true, time.Now().Unix())
}
}
@ -722,7 +705,7 @@ func (w *worker) taskLoop() {
w.pendingTasks[sealHash] = task
w.pendingMu.Unlock()
if err := w.engine.Seal(task.ctx, w.chain, task.block, w.resultCh, stopCh); err != nil {
if err := w.engine.Seal(w.chain, task.block, w.resultCh, stopCh); err != nil {
log.Warn("Block sealing failed", "err", err)
w.pendingMu.Lock()
delete(w.pendingTasks, sealHash)
@ -783,7 +766,6 @@ func (w *worker) resultLoop() {
err error
)
tracing.Exec(task.ctx, "", "resultLoop", func(ctx context.Context, span trace.Span) {
for i, taskReceipt := range task.receipts {
receipt := new(types.Receipt)
receipts[i] = receipt
@ -808,20 +790,7 @@ func (w *worker) resultLoop() {
logs = append(logs, receipt.Logs...)
}
// Commit block and state to database.
tracing.Exec(ctx, "", "resultLoop.WriteBlockAndSetHead", func(ctx context.Context, span trace.Span) {
_, err = w.chain.WriteBlockAndSetHead(ctx, block, receipts, logs, task.state, true)
})
tracing.SetAttributes(
span,
attribute.String("hash", hash.String()),
attribute.Int("number", int(block.Number().Uint64())),
attribute.Int("txns", block.Transactions().Len()),
attribute.Int("gas used", int(block.GasUsed())),
attribute.Int("elapsed", int(time.Since(task.createdAt).Milliseconds())),
attribute.Bool("error", err != nil),
)
})
_, err = w.chain.WriteBlockAndSetHead(block, receipts, logs, task.state, true)
if err != nil {
log.Error("Failed writing block to chain", "err", err)
@ -891,16 +860,14 @@ func (w *worker) updateSnapshot(env *environment) {
w.snapshotState = env.state.Copy()
}
func (w *worker) commitTransaction(env *environment, tx *types.Transaction, interruptCtx context.Context) ([]*types.Log, error) {
func (w *worker) commitTransaction(env *environment, tx *types.Transaction) ([]*types.Log, error) {
var (
snap = env.state.Snapshot()
gp = env.gasPool.Gas()
)
// nolint : staticcheck
interruptCtx = vm.SetCurrentTxOnContext(interruptCtx, tx.Hash())
receipt, err := core.ApplyTransaction(w.chainConfig, w.chain, &env.coinbase, env.gasPool, env.state, env.header, tx, &env.header.GasUsed, *w.chain.GetVMConfig(), interruptCtx)
w.interruptCtx = vm.SetCurrentTxOnContext(w.interruptCtx, tx.Hash())
receipt, err := core.ApplyTransaction(w.chainConfig, w.chain, &env.coinbase, env.gasPool, env.state, env.header, tx, &env.header.GasUsed, *w.chain.GetVMConfig(), w.interruptCtx)
if err != nil {
env.state.RevertToSnapshot(snap)
env.gasPool.SetGas(gp)
@ -913,7 +880,7 @@ func (w *worker) commitTransaction(env *environment, tx *types.Transaction, inte
return receipt.Logs, nil
}
func (w *worker) commitTransactions(env *environment, plainTxs, blobTxs *transactionsByPriceAndNonce, interrupt *atomic.Int32, minTip *uint256.Int, interruptCtx context.Context) error {
func (w *worker) commitTransactions(env *environment, plainTxs, blobTxs *transactionsByPriceAndNonce, interrupt *atomic.Int32, minTip *uint256.Int) error {
gasLimit := env.header.GasLimit
if env.gasPool == nil {
env.gasPool = new(core.GasPool).AddGas(gasLimit)
@ -963,14 +930,14 @@ mainloop:
}
}
if interruptCtx != nil {
if w.interruptCtx != nil {
if EnableMVHashMap && w.IsRunning() {
env.state.AddEmptyMVHashMap()
}
// case of interrupting by timeout
select {
case <-interruptCtx.Done():
case <-w.interruptCtx.Done():
txCommitInterruptCounter.Inc(1)
log.Warn("Tx Level Interrupt", "hash", lastTxHash)
break mainloop
@ -1077,7 +1044,15 @@ mainloop:
// Start executing the transaction
env.state.SetTxContext(tx.Hash(), env.tcount)
logs, err := w.commitTransaction(env, tx, interruptCtx)
logs, err := w.commitTransaction(env, tx)
// Check if we have a `delay` set in interrup context. It's only set during tests.
if w.interruptCtx != nil {
if delay := w.interruptCtx.Value(vm.InterruptCtxDelayKey); delay != nil {
// nolint : durationcheck
time.Sleep(time.Duration(delay.(uint)) * time.Millisecond)
}
}
switch {
case errors.Is(err, core.ErrNonceTooLow):
@ -1301,80 +1276,13 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) {
return env, nil
}
func startProfiler(profile string, filepath string, number uint64) (func() error, error) {
var (
buf bytes.Buffer
err error
)
closeFn := func() {}
switch profile {
case "cpu":
err = pprof.StartCPUProfile(&buf)
if err == nil {
closeFn = func() {
pprof.StopCPUProfile()
}
}
case "trace":
err = ptrace.Start(&buf)
if err == nil {
closeFn = func() {
ptrace.Stop()
}
}
case "heap":
runtime.GC()
err = pprof.WriteHeapProfile(&buf)
default:
log.Info("Incorrect profile name")
}
if err != nil {
return func() error {
closeFn()
return nil
}, err
}
closeFnNew := func() error {
var err error
closeFn()
if buf.Len() == 0 {
return nil
}
f, err := os.Create(filepath + "/" + profile + "-" + fmt.Sprint(number) + ".prof")
if err != nil {
return err
}
defer f.Close()
_, err = f.Write(buf.Bytes())
return err
}
return closeFnNew, nil
}
// fillTransactions retrieves the pending transactions from the txpool and fills them
// into the given sealing block. The transaction selection and ordering strategy can
// be customized with the plugin in the future.
//
//nolint:gocognit
func (w *worker) fillTransactions(ctx context.Context, interrupt *atomic.Int32, env *environment, interruptCtx context.Context) error {
ctx, span := tracing.StartSpan(ctx, "fillTransactions")
defer tracing.EndSpan(span)
func (w *worker) fillTransactions(interrupt *atomic.Int32, env *environment) error {
w.mu.RLock()
tip := w.tip
w.mu.RUnlock()
@ -1392,79 +1300,10 @@ func (w *worker) fillTransactions(ctx context.Context, interrupt *atomic.Int32,
filter.BlobFee = uint256.MustFromBig(eip4844.CalcBlobFee(*env.header.ExcessBlobGas))
}
var (
localPlainTxsCount int
remotePlainTxsCount int
)
// TODO: move to config or RPC
const profiling = false
if profiling {
doneCh := make(chan struct{})
defer func() {
close(doneCh)
}()
go func(number uint64) {
closeFn := func() error {
return nil
}
for {
select {
case <-time.After(150 * time.Millisecond):
// Check if we've not crossed limit
if attempt := atomic.AddInt32(w.profileCount, 1); attempt >= 10 {
log.Info("Completed profiling", "attempt", attempt)
return
}
log.Info("Starting profiling in fill transactions", "number", number)
dir, err := os.MkdirTemp("", fmt.Sprintf("bor-traces-%s-", time.Now().UTC().Format("2006-01-02-150405Z")))
if err != nil {
log.Error("Error in profiling", "path", dir, "number", number, "err", err)
return
}
// grab the cpu profile
closeFnInternal, err := startProfiler("cpu", dir, number)
if err != nil {
log.Error("Error in profiling", "path", dir, "number", number, "err", err)
return
}
closeFn = func() error {
err := closeFnInternal()
log.Info("Completed profiling", "path", dir, "number", number, "error", err)
return nil
}
case <-doneCh:
err := closeFn()
if err != nil {
log.Info("closing fillTransactions", "number", number, "error", err)
}
return
}
}
}(env.header.Number.Uint64())
}
var (
localPlainTxs, remotePlainTxs, localBlobTxs, remoteBlobTxs map[common.Address][]*txpool.LazyTransaction
)
tracing.Exec(ctx, "", "worker.SplittingTransactions", func(ctx context.Context, span trace.Span) {
prePendingTime := time.Now()
filter.OnlyPlainTxs, filter.OnlyBlobTxs = true, false
pendingPlainTxs := w.eth.TxPool().Pending(filter)
@ -1475,8 +1314,6 @@ func (w *worker) fillTransactions(ctx context.Context, interrupt *atomic.Int32,
localPlainTxs, remotePlainTxs = make(map[common.Address][]*txpool.LazyTransaction), pendingPlainTxs
localBlobTxs, remoteBlobTxs = make(map[common.Address][]*txpool.LazyTransaction), pendingBlobTxs
postPendingTime := time.Now()
for _, account := range w.eth.TxPool().Locals() {
if txs := remotePlainTxs[account]; len(txs) > 0 {
delete(remotePlainTxs, account)
@ -1488,92 +1325,41 @@ func (w *worker) fillTransactions(ctx context.Context, interrupt *atomic.Int32,
}
}
postLocalsTime := time.Now()
tracing.SetAttributes(
span,
attribute.Int("len of local txs", localPlainTxsCount),
attribute.Int("len of remote txs", remotePlainTxsCount),
attribute.String("time taken by Pending()", fmt.Sprintf("%v", postPendingTime.Sub(prePendingTime))),
attribute.String("time taken by Locals()", fmt.Sprintf("%v", postLocalsTime.Sub(postPendingTime))),
)
})
var (
localEnvTCount int
remoteEnvTCount int
err error
)
// Fill the block with all available pending transactions.
if len(localPlainTxs) > 0 || len(localBlobTxs) > 0 {
var plainTxs, blobTxs *transactionsByPriceAndNonce
tracing.Exec(ctx, "", "worker.LocalTransactionsByPriceAndNonce", func(ctx context.Context, span trace.Span) {
plainTxs = newTransactionsByPriceAndNonce(env.signer, localPlainTxs, env.header.BaseFee)
blobTxs = newTransactionsByPriceAndNonce(env.signer, localBlobTxs, env.header.BaseFee)
tracing.SetAttributes(
span,
attribute.Int("len of tx local Heads", plainTxs.GetTxs()),
)
})
tracing.Exec(ctx, "", "worker.LocalCommitTransactions", func(ctx context.Context, span trace.Span) {
err = w.commitTransactions(env, plainTxs, blobTxs, interrupt, new(uint256.Int), interruptCtx)
})
if err != nil {
if err := w.commitTransactions(env, plainTxs, blobTxs, interrupt, new(uint256.Int)); err != nil {
return err
}
localEnvTCount = env.tcount
}
if len(remotePlainTxs) > 0 || len(remoteBlobTxs) > 0 {
var plainTxs, blobTxs *transactionsByPriceAndNonce
tracing.Exec(ctx, "", "worker.RemoteTransactionsByPriceAndNonce", func(ctx context.Context, span trace.Span) {
plainTxs = newTransactionsByPriceAndNonce(env.signer, remotePlainTxs, env.header.BaseFee)
blobTxs = newTransactionsByPriceAndNonce(env.signer, remoteBlobTxs, env.header.BaseFee)
tracing.SetAttributes(
span,
attribute.Int("len of tx remote Heads", plainTxs.GetTxs()),
)
})
tracing.Exec(ctx, "", "worker.RemoteCommitTransactions", func(ctx context.Context, span trace.Span) {
err = w.commitTransactions(env, plainTxs, blobTxs, interrupt, new(uint256.Int), interruptCtx)
})
if err != nil {
if err := w.commitTransactions(env, plainTxs, blobTxs, interrupt, new(uint256.Int)); err != nil {
return err
}
remoteEnvTCount = env.tcount
}
tracing.SetAttributes(
span,
attribute.Int("len of final local txs ", localEnvTCount),
attribute.Int("len of final remote txs", remoteEnvTCount),
)
return nil
}
// generateWork generates a sealing block based on the given parameters.
func (w *worker) generateWork(ctx context.Context, params *generateParams) *newPayloadResult {
func (w *worker) generateWork(params *generateParams) *newPayloadResult {
work, err := w.prepareWork(params)
if err != nil {
return &newPayloadResult{err: err}
}
defer work.discard()
// nolint : contextcheck
var interruptCtx = context.Background()
w.interruptCtx = resetAndCopyInterruptCtx(w.interruptCtx)
if !params.noTxs {
interrupt := new(atomic.Int32)
@ -1582,7 +1368,7 @@ func (w *worker) generateWork(ctx context.Context, params *generateParams) *newP
})
defer timer.Stop()
err := w.fillTransactions(ctx, interrupt, work, interruptCtx)
err := w.fillTransactions(interrupt, work)
if errors.Is(err, errBlockInterruptedByTimeout) {
log.Warn("Block building is interrupted", "allowance", common.PrettyDuration(w.newpayloadTimeout))
}
@ -1605,7 +1391,7 @@ func (w *worker) generateWork(ctx context.Context, params *generateParams) *newP
// commitWork generates several new sealing tasks based on the parent block
// and submit them to the sealer.
func (w *worker) commitWork(ctx context.Context, interrupt *atomic.Int32, noempty bool, timestamp int64) {
func (w *worker) commitWork(interrupt *atomic.Int32, noempty bool, timestamp int64) {
// Abort committing if node is still syncing
if w.syncing.Load() {
return
@ -1617,7 +1403,6 @@ func (w *worker) commitWork(ctx context.Context, interrupt *atomic.Int32, noempt
err error
)
tracing.Exec(ctx, "", "worker.prepareWork", func(ctx context.Context, span trace.Span) {
// Set the coinbase if the worker is running or it's required
var coinbase common.Address
if w.IsRunning() {
@ -1632,15 +1417,11 @@ func (w *worker) commitWork(ctx context.Context, interrupt *atomic.Int32, noempt
timestamp: uint64(timestamp),
coinbase: coinbase,
})
})
if err != nil {
return
}
// nolint:contextcheck
var interruptCtx = context.Background()
w.interruptCtx = resetAndCopyInterruptCtx(w.interruptCtx)
stopFn := func() {}
defer func() {
stopFn()
@ -1648,26 +1429,17 @@ func (w *worker) commitWork(ctx context.Context, interrupt *atomic.Int32, noempt
if !noempty && w.interruptCommitFlag {
block := w.chain.GetBlockByHash(w.chain.CurrentBlock().Hash())
interruptCtx, stopFn = getInterruptTimer(ctx, work, block)
// nolint : staticcheck
interruptCtx = vm.PutCache(interruptCtx, w.interruptedTxCache)
w.interruptCtx, stopFn = getInterruptTimer(w.interruptCtx, work, block)
w.interruptCtx = vm.PutCache(w.interruptCtx, w.interruptedTxCache)
}
ctx, span := tracing.StartSpan(ctx, "commitWork")
defer tracing.EndSpan(span)
tracing.SetAttributes(
span,
attribute.Int("number", int(work.header.Number.Uint64())),
)
// Create an empty block based on temporary copied state for
// sealing in advance without waiting block execution finished.
if !noempty && !w.noempty.Load() {
_ = w.commit(ctx, work.copy(), nil, false, start)
_ = w.commit(work.copy(), nil, false, start)
}
// Fill pending transactions from the txpool into the block.
err = w.fillTransactions(ctx, interrupt, work, interruptCtx)
err = w.fillTransactions(interrupt, work)
switch {
case err == nil:
@ -1698,7 +1470,7 @@ func (w *worker) commitWork(ctx context.Context, interrupt *atomic.Int32, noempt
return
}
// Submit the generated block for consensus sealing.
_ = w.commit(ctx, work.copy(), w.fullTaskHook, true, start)
_ = w.commit(work.copy(), w.fullTaskHook, true, start)
// Swap out the old work with the new one, terminating any leftover
// prefetcher processes in the mean time and starting a new one.
@ -1709,22 +1481,34 @@ func (w *worker) commitWork(ctx context.Context, interrupt *atomic.Int32, noempt
w.current = work
}
func getInterruptTimer(ctx context.Context, work *environment, current *types.Block) (context.Context, func()) {
// resetAndCopyInterruptCtx resets the interrupt context and copies the values set
// from the old one to newly created one. It is necessary to reset context in this way
// to get rid of the older parent timeout context.
func resetAndCopyInterruptCtx(interruptCtx context.Context) context.Context {
// Create a fresh new context and copy values from old one
newCtx := context.Background()
if delay := interruptCtx.Value(vm.InterruptCtxDelayKey); delay != nil {
newCtx = context.WithValue(newCtx, vm.InterruptCtxDelayKey, delay)
}
if opcodeDelay := interruptCtx.Value(vm.InterruptCtxOpcodeDelayKey); opcodeDelay != nil {
newCtx = context.WithValue(newCtx, vm.InterruptCtxOpcodeDelayKey, opcodeDelay)
}
return newCtx
}
func getInterruptTimer(interruptCtx context.Context, work *environment, current *types.Block) (context.Context, func()) {
delay := time.Until(time.Unix(int64(work.header.Time), 0))
interruptCtx, cancel := context.WithTimeout(context.Background(), delay)
interruptCtx, cancel := context.WithTimeout(interruptCtx, delay)
blockNumber := current.NumberU64() + 1
go func() {
select {
case <-interruptCtx.Done():
<-interruptCtx.Done()
if interruptCtx.Err() != context.Canceled {
log.Info("Commit Interrupt. Pre-committing the current block", "block", blockNumber)
cancel()
}
case <-ctx.Done(): // nothing to do
}
}()
return interruptCtx, cancel
@ -1734,11 +1518,8 @@ func getInterruptTimer(ctx context.Context, work *environment, current *types.Bl
// and commits new work if consensus engine is running.
// Note the assumption is held that the mutation is allowed to the passed env, do
// the deep copy first.
func (w *worker) commit(ctx context.Context, env *environment, interval func(), update bool, start time.Time) error {
func (w *worker) commit(env *environment, interval func(), update bool, start time.Time) error {
if w.IsRunning() {
ctx, span := tracing.StartSpan(ctx, "commit")
defer tracing.EndSpan(span)
if interval != nil {
interval()
}
@ -1749,21 +1530,13 @@ func (w *worker) commit(ctx context.Context, env *environment, interval func(),
block, err := w.engine.FinalizeAndAssemble(w.chain, env.header, env.state, &types.Body{
Transactions: env.txs,
}, env.receipts)
tracing.SetAttributes(
span,
attribute.Int("number", int(env.header.Number.Uint64())),
attribute.String("hash", env.header.Hash().String()),
attribute.String("sealhash", w.engine.SealHash(env.header).String()),
attribute.Int("len of env.txs", len(env.txs)),
attribute.Bool("error", err != nil),
)
if err != nil {
return err
}
select {
case w.taskCh <- &task{ctx: ctx, receipts: env.receipts, state: env.state, block: block, createdAt: time.Now()}:
case w.taskCh <- &task{receipts: env.receipts, state: env.state, block: block, createdAt: time.Now()}:
fees := totalFees(block, env.receipts)
feesInEther := new(big.Float).Quo(new(big.Float).SetInt(fees), big.NewFloat(params.Ether))
log.Info("Commit new sealing work", "number", block.Number(), "sealhash", w.engine.SealHash(block.Header()),
@ -1810,6 +1583,12 @@ func (w *worker) adjustResubmitInterval(message *intervalAdjust) {
}
}
// setInterruptCtx sets `value` for given `key` for interrupt commit logic. To be only
// used for e2e unit tests.
func (w *worker) setInterruptCtx(key any, value any) {
w.interruptCtx = context.WithValue(w.interruptCtx, key, value)
}
// copyReceipts makes a deep copy of the given receipts.
func copyReceipts(receipts []*types.Receipt) []*types.Receipt {
result := make([]*types.Receipt, len(receipts))

View file

@ -320,13 +320,10 @@ func (b *testWorkerBackend) newStorageContractCallTx(to common.Address, nonce ui
func newTestWorker(t TensingObject, chainConfig *params.ChainConfig, engine consensus.Engine, db ethdb.Database, noempty bool, delay uint, opcodeDelay uint) (*worker, *testWorkerBackend, func()) {
backend := newTestWorkerBackend(t, chainConfig, engine, db)
backend.txPool.Add(pendingTxs, true, false)
var w *worker
w := newWorker(testConfig, chainConfig, engine, backend, new(event.TypeMux), nil, false)
if delay != 0 || opcodeDelay != 0 {
//nolint:staticcheck
w = newWorkerWithDelay(testConfig, chainConfig, engine, backend, new(event.TypeMux), nil, false, delay, opcodeDelay)
} else {
//nolint:staticcheck
w = newWorker(testConfig, chainConfig, engine, backend, new(event.TypeMux), nil, false)
w.setInterruptCtx(vm.InterruptCtxDelayKey, delay)
w.setInterruptCtx(vm.InterruptCtxOpcodeDelayKey, opcodeDelay)
}
w.setEtherbase(testBankAddress)
// enable empty blocks
@ -771,9 +768,7 @@ func testCommitInterruptExperimentBorContract(t *testing.T, delay uint, txCount
}
wrapped := make([]*types.Transaction, len(txs))
for i, tx := range txs {
wrapped[i] = tx
}
copy(wrapped, txs)
b.TxPool().Add(wrapped, false, false)
@ -783,8 +778,9 @@ func testCommitInterruptExperimentBorContract(t *testing.T, delay uint, txCount
w.stop()
currentBlockNumber := w.current.header.Number.Uint64()
assert.Check(t, txCount >= w.chain.GetBlockByNumber(currentBlockNumber-1).Transactions().Len())
assert.Check(t, 0 < w.chain.GetBlockByNumber(currentBlockNumber-1).Transactions().Len()+1)
prevBlockTxCount := w.chain.GetBlockByNumber(currentBlockNumber - 1).Transactions().Len()
assert.Check(t, prevBlockTxCount > 0)
assert.Check(t, prevBlockTxCount <= txCount)
}
// // nolint : thelper
@ -973,7 +969,7 @@ func BenchmarkBorMiningBlockSTMMetadata(b *testing.B) {
db2 := rawdb.NewMemoryDatabase()
back.genesis.MustCommit(db2, triedb.NewDatabase(db2, triedb.HashDefaults))
chain, _ := core.NewParallelBlockChain(db2, nil, back.genesis, nil, engine, vm.Config{}, nil, nil, nil, 8)
chain, _ := core.NewParallelBlockChain(db2, nil, back.genesis, nil, engine, vm.Config{}, nil, nil, nil, 8, false)
defer chain.Stop()
// Ignore empty commit here for less noise.

View file

@ -169,6 +169,11 @@ gcmode = "archive"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# [pprof]
# pprof = false
# port = 6060

View file

@ -34,7 +34,7 @@ syncmode = "full"
# nodekey = ""
# nodekeyhex = ""
# txarrivalwait = "500ms"
# [p2p.discovery]
[p2p.discovery]
# v4disc = true
# v5disc = false
bootnodes = [ "enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303", "enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303" ]
@ -168,6 +168,11 @@ syncmode = "full"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# [pprof]
# pprof = false
# port = 6060

View file

@ -36,7 +36,7 @@ syncmode = "full"
# nodekey = ""
# nodekeyhex = ""
# txarrivalwait = "500ms"
# [p2p.discovery]
[p2p.discovery]
# v4disc = true
# v5disc = false
bootnodes = [ "enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303", "enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303" ]
@ -170,6 +170,11 @@ syncmode = "full"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# [pprof]
# pprof = false
# port = 6060

View file

@ -36,7 +36,7 @@ syncmode = "full"
# nodekey = ""
# nodekeyhex = ""
# txarrivalwait = "500ms"
# [p2p.discovery]
[p2p.discovery]
# v4disc = true
# v5disc = false
bootnodes = ["enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303", "enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303"]
@ -170,6 +170,11 @@ syncmode = "full"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# [pprof]
# pprof = false
# port = 6060

View file

@ -38,7 +38,7 @@ syncmode = "full"
# nodekey = ""
# nodekeyhex = ""
# txarrivalwait = "500ms"
# [p2p.discovery]
[p2p.discovery]
# v4disc = true
# v5disc = false
bootnodes = ["enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303", "enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303"]
@ -172,6 +172,11 @@ syncmode = "full"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# [pprof]
# pprof = false
# port = 6060

View file

@ -36,7 +36,7 @@ syncmode = "full"
# nodekey = ""
# nodekeyhex = ""
# txarrivalwait = "500ms"
# [p2p.discovery]
[p2p.discovery]
# v4disc = true
# v5disc = false
bootnodes = [ "enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303", "enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303" ]
@ -170,6 +170,11 @@ syncmode = "full"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# [pprof]
# pprof = false
# port = 6060

View file

@ -37,7 +37,7 @@ syncmode = "full"
# nodekey = ""
# nodekeyhex = ""
# txarrivalwait = "500ms"
# [p2p.discovery]
[p2p.discovery]
# v4disc = true
# v5disc = false
bootnodes = [ "enode://b8f1cc9c5d4403703fbf377116469667d2b1823c0daf16b7250aa576bacf399e42c3930ccfcb02c5df6879565a2b8931335565f0e8d3f8e72385ecf4a4bf160a@3.36.224.80:30303", "enode://8729e0c825f3d9cad382555f3e46dcff21af323e89025a0e6312df541f4a9e73abfa562d64906f5e59c51fe6f0501b3e61b07979606c56329c020ed739910759@54.194.245.5:30303" ]
@ -171,6 +171,11 @@ syncmode = "full"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# [pprof]
# pprof = false
# port = 6060

View file

@ -34,14 +34,14 @@ gcmode = "archive"
# nodekey = ""
# nodekeyhex = ""
# txarrivalwait = "500ms"
# [p2p.discovery]
[p2p.discovery]
# v5disc = false
# bootnodesv4 = []
# bootnodesv5 = []
bootnodes = [ "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303" ]
static-nodes = [ "enode://383ec39eb7f7e23538ea846f502602632110a6bcfc7521bfc2b8833f5a190779507d006b28650d83674b75d188cb36bcb3c3e168a0f2b3d98f9a651cc6603146@52.214.229.208:30303", "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://a4a387ad423a2fd0d652808b270082250d3c616b7e8537209584ebad4806dd50ef8dc66a371c85c7f55e6c1f53747edbb11055c8073cfacf312047eaeb328f58@54.171.220.164:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303", "enode://e8fe33b52f90d4bc7a4e75800945df449d1a091bd347c9f11cd1dbcd98ea28cb4c231cb3b1c6feacdabca2aa91f1a6744724b44edc9382c107968792abdef261@52.74.18.182:30303", "enode://b240f1f18e8f3cc61df96a164ba215ea6fc3f00717e4300da6283362a0438bda53f81ecc24c575ff130066d42096319fa027c952681bbb4f003e0bdd5d5b4e61@52.76.37.145:30303", "enode://de55d16b6e1fca28cdd3d11eb0dd89e3b77b96d4722172bd5e04ac255922324076a87748e97bc021af2307dccbb5ef8062389cfcba1845f77219eee7935dea9f@52.74.125.36:30303", "enode://7f2272685fc3e31c8e43c7687dda43ea3192fd310ba01efcb7811d5dc7ad5a64402ea8cd827650e573a174cf29bb69331dffcca6f0b9894ef17eeafabd97a41d@47.128.184.10:30303", "enode://c66e12243b425b63528dd8b1ce87f2f7fbc85f35485e2d8bf6bbf0ec0dcd05b3a582ef62daadbde061b58058735788335d09ed972a451242b9943b85d323c239@63.32.214.97:30303", "enode://bd56c0f00dd37e14ae2b84f5eb50e357d3a2d326bdbb0cbb987411268b3f132288f6c86157fc132c6902d18b9be0de8bbdcd12d926e16232ebadd8e274aae780@52.208.81.179:30303", "enode://2f015d5b1571165975382281a2117a9b514e1b38e87a8116596fc9b3b121a93cfb238eb6f7b3ae30cf9c0154384372745ce9edc09cbc30526ab7e2059f57ddee@54.74.160.230:30303" ]
# trusted-nodes = []
# dns = []
dns = [ "enrtree://AKUEZKN7PSKVNR65FZDHECMKOJQSGPARGTPPBI7WS2VUL4EGR6XPC@amoy.polygon-peers.io" ]
# [heimdall]
# url = "http://localhost:1317"
@ -168,6 +168,11 @@ gcmode = "archive"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# [pprof]
# pprof = false
# port = 6060

View file

@ -33,14 +33,14 @@ syncmode = "full"
# nodekey = ""
# nodekeyhex = ""
# txarrivalwait = "500ms"
# [p2p.discovery]
[p2p.discovery]
# v5disc = false
# bootnodesv4 = []
# bootnodesv5 = []
bootnodes = [ "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303" ]
static-nodes = [ "enode://383ec39eb7f7e23538ea846f502602632110a6bcfc7521bfc2b8833f5a190779507d006b28650d83674b75d188cb36bcb3c3e168a0f2b3d98f9a651cc6603146@52.214.229.208:30303", "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://a4a387ad423a2fd0d652808b270082250d3c616b7e8537209584ebad4806dd50ef8dc66a371c85c7f55e6c1f53747edbb11055c8073cfacf312047eaeb328f58@54.171.220.164:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303", "enode://e8fe33b52f90d4bc7a4e75800945df449d1a091bd347c9f11cd1dbcd98ea28cb4c231cb3b1c6feacdabca2aa91f1a6744724b44edc9382c107968792abdef261@52.74.18.182:30303", "enode://b240f1f18e8f3cc61df96a164ba215ea6fc3f00717e4300da6283362a0438bda53f81ecc24c575ff130066d42096319fa027c952681bbb4f003e0bdd5d5b4e61@52.76.37.145:30303", "enode://de55d16b6e1fca28cdd3d11eb0dd89e3b77b96d4722172bd5e04ac255922324076a87748e97bc021af2307dccbb5ef8062389cfcba1845f77219eee7935dea9f@52.74.125.36:30303", "enode://7f2272685fc3e31c8e43c7687dda43ea3192fd310ba01efcb7811d5dc7ad5a64402ea8cd827650e573a174cf29bb69331dffcca6f0b9894ef17eeafabd97a41d@47.128.184.10:30303", "enode://c66e12243b425b63528dd8b1ce87f2f7fbc85f35485e2d8bf6bbf0ec0dcd05b3a582ef62daadbde061b58058735788335d09ed972a451242b9943b85d323c239@63.32.214.97:30303", "enode://bd56c0f00dd37e14ae2b84f5eb50e357d3a2d326bdbb0cbb987411268b3f132288f6c86157fc132c6902d18b9be0de8bbdcd12d926e16232ebadd8e274aae780@52.208.81.179:30303", "enode://2f015d5b1571165975382281a2117a9b514e1b38e87a8116596fc9b3b121a93cfb238eb6f7b3ae30cf9c0154384372745ce9edc09cbc30526ab7e2059f57ddee@54.74.160.230:30303" ]
# trusted-nodes = []
# dns = []
dns = [ "enrtree://AKUEZKN7PSKVNR65FZDHECMKOJQSGPARGTPPBI7WS2VUL4EGR6XPC@amoy.polygon-peers.io" ]
# [heimdall]
# url = "http://localhost:1317"
@ -167,6 +167,11 @@ syncmode = "full"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# [pprof]
# pprof = false
# port = 6060

View file

@ -34,14 +34,14 @@ syncmode = "full"
# nodekey = ""
# nodekeyhex = ""
# txarrivalwait = "500ms"
# [p2p.discovery]
[p2p.discovery]
# v5disc = false
# bootnodesv4 = []
# bootnodesv5 = []
bootnodes = [ "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303" ]
static-nodes = [ "enode://383ec39eb7f7e23538ea846f502602632110a6bcfc7521bfc2b8833f5a190779507d006b28650d83674b75d188cb36bcb3c3e168a0f2b3d98f9a651cc6603146@52.214.229.208:30303", "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://a4a387ad423a2fd0d652808b270082250d3c616b7e8537209584ebad4806dd50ef8dc66a371c85c7f55e6c1f53747edbb11055c8073cfacf312047eaeb328f58@54.171.220.164:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303", "enode://e8fe33b52f90d4bc7a4e75800945df449d1a091bd347c9f11cd1dbcd98ea28cb4c231cb3b1c6feacdabca2aa91f1a6744724b44edc9382c107968792abdef261@52.74.18.182:30303", "enode://b240f1f18e8f3cc61df96a164ba215ea6fc3f00717e4300da6283362a0438bda53f81ecc24c575ff130066d42096319fa027c952681bbb4f003e0bdd5d5b4e61@52.76.37.145:30303", "enode://de55d16b6e1fca28cdd3d11eb0dd89e3b77b96d4722172bd5e04ac255922324076a87748e97bc021af2307dccbb5ef8062389cfcba1845f77219eee7935dea9f@52.74.125.36:30303", "enode://7f2272685fc3e31c8e43c7687dda43ea3192fd310ba01efcb7811d5dc7ad5a64402ea8cd827650e573a174cf29bb69331dffcca6f0b9894ef17eeafabd97a41d@47.128.184.10:30303", "enode://c66e12243b425b63528dd8b1ce87f2f7fbc85f35485e2d8bf6bbf0ec0dcd05b3a582ef62daadbde061b58058735788335d09ed972a451242b9943b85d323c239@63.32.214.97:30303", "enode://bd56c0f00dd37e14ae2b84f5eb50e357d3a2d326bdbb0cbb987411268b3f132288f6c86157fc132c6902d18b9be0de8bbdcd12d926e16232ebadd8e274aae780@52.208.81.179:30303", "enode://2f015d5b1571165975382281a2117a9b514e1b38e87a8116596fc9b3b121a93cfb238eb6f7b3ae30cf9c0154384372745ce9edc09cbc30526ab7e2059f57ddee@54.74.160.230:30303" ]
# trusted-nodes = []
# dns = []
dns = [ "enrtree://AKUEZKN7PSKVNR65FZDHECMKOJQSGPARGTPPBI7WS2VUL4EGR6XPC@amoy.polygon-peers.io" ]
# [heimdall]
# url = "http://localhost:1317"
@ -168,6 +168,11 @@ syncmode = "full"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# [pprof]
# pprof = false
# port = 6060

View file

@ -35,14 +35,14 @@ syncmode = "full"
# nodekey = ""
# nodekeyhex = ""
# txarrivalwait = "500ms"
# [p2p.discovery]
[p2p.discovery]
# v5disc = false
# bootnodesv4 = []
# bootnodesv5 = []
bootnodes = [ "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303" ]
static-nodes = [ "enode://383ec39eb7f7e23538ea846f502602632110a6bcfc7521bfc2b8833f5a190779507d006b28650d83674b75d188cb36bcb3c3e168a0f2b3d98f9a651cc6603146@52.214.229.208:30303", "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://a4a387ad423a2fd0d652808b270082250d3c616b7e8537209584ebad4806dd50ef8dc66a371c85c7f55e6c1f53747edbb11055c8073cfacf312047eaeb328f58@54.171.220.164:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303", "enode://e8fe33b52f90d4bc7a4e75800945df449d1a091bd347c9f11cd1dbcd98ea28cb4c231cb3b1c6feacdabca2aa91f1a6744724b44edc9382c107968792abdef261@52.74.18.182:30303", "enode://b240f1f18e8f3cc61df96a164ba215ea6fc3f00717e4300da6283362a0438bda53f81ecc24c575ff130066d42096319fa027c952681bbb4f003e0bdd5d5b4e61@52.76.37.145:30303", "enode://de55d16b6e1fca28cdd3d11eb0dd89e3b77b96d4722172bd5e04ac255922324076a87748e97bc021af2307dccbb5ef8062389cfcba1845f77219eee7935dea9f@52.74.125.36:30303", "enode://7f2272685fc3e31c8e43c7687dda43ea3192fd310ba01efcb7811d5dc7ad5a64402ea8cd827650e573a174cf29bb69331dffcca6f0b9894ef17eeafabd97a41d@47.128.184.10:30303", "enode://c66e12243b425b63528dd8b1ce87f2f7fbc85f35485e2d8bf6bbf0ec0dcd05b3a582ef62daadbde061b58058735788335d09ed972a451242b9943b85d323c239@63.32.214.97:30303", "enode://bd56c0f00dd37e14ae2b84f5eb50e357d3a2d326bdbb0cbb987411268b3f132288f6c86157fc132c6902d18b9be0de8bbdcd12d926e16232ebadd8e274aae780@52.208.81.179:30303", "enode://2f015d5b1571165975382281a2117a9b514e1b38e87a8116596fc9b3b121a93cfb238eb6f7b3ae30cf9c0154384372745ce9edc09cbc30526ab7e2059f57ddee@54.74.160.230:30303" ]
# trusted-nodes = []
# dns = []
dns = [ "enrtree://AKUEZKN7PSKVNR65FZDHECMKOJQSGPARGTPPBI7WS2VUL4EGR6XPC@amoy.polygon-peers.io" ]
# [heimdall]
# url = "http://localhost:1317"
@ -169,6 +169,11 @@ syncmode = "full"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# pprof = false
# port = 6060
# addr = "127.0.0.1"

View file

@ -36,14 +36,14 @@ syncmode = "full"
# nodekey = ""
# nodekeyhex = ""
# txarrivalwait = "500ms"
# [p2p.discovery]
[p2p.discovery]
# v5disc = false
# bootnodesv4 = []
# bootnodesv5 = []
bootnodes = [ "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303" ]
static-nodes = [ "enode://383ec39eb7f7e23538ea846f502602632110a6bcfc7521bfc2b8833f5a190779507d006b28650d83674b75d188cb36bcb3c3e168a0f2b3d98f9a651cc6603146@52.214.229.208:30303", "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://a4a387ad423a2fd0d652808b270082250d3c616b7e8537209584ebad4806dd50ef8dc66a371c85c7f55e6c1f53747edbb11055c8073cfacf312047eaeb328f58@54.171.220.164:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303", "enode://e8fe33b52f90d4bc7a4e75800945df449d1a091bd347c9f11cd1dbcd98ea28cb4c231cb3b1c6feacdabca2aa91f1a6744724b44edc9382c107968792abdef261@52.74.18.182:30303", "enode://b240f1f18e8f3cc61df96a164ba215ea6fc3f00717e4300da6283362a0438bda53f81ecc24c575ff130066d42096319fa027c952681bbb4f003e0bdd5d5b4e61@52.76.37.145:30303", "enode://de55d16b6e1fca28cdd3d11eb0dd89e3b77b96d4722172bd5e04ac255922324076a87748e97bc021af2307dccbb5ef8062389cfcba1845f77219eee7935dea9f@52.74.125.36:30303", "enode://7f2272685fc3e31c8e43c7687dda43ea3192fd310ba01efcb7811d5dc7ad5a64402ea8cd827650e573a174cf29bb69331dffcca6f0b9894ef17eeafabd97a41d@47.128.184.10:30303", "enode://c66e12243b425b63528dd8b1ce87f2f7fbc85f35485e2d8bf6bbf0ec0dcd05b3a582ef62daadbde061b58058735788335d09ed972a451242b9943b85d323c239@63.32.214.97:30303", "enode://bd56c0f00dd37e14ae2b84f5eb50e357d3a2d326bdbb0cbb987411268b3f132288f6c86157fc132c6902d18b9be0de8bbdcd12d926e16232ebadd8e274aae780@52.208.81.179:30303", "enode://2f015d5b1571165975382281a2117a9b514e1b38e87a8116596fc9b3b121a93cfb238eb6f7b3ae30cf9c0154384372745ce9edc09cbc30526ab7e2059f57ddee@54.74.160.230:30303" ]
# trusted-nodes = []
# dns = []
dns = [ "enrtree://AKUEZKN7PSKVNR65FZDHECMKOJQSGPARGTPPBI7WS2VUL4EGR6XPC@amoy.polygon-peers.io" ]
# [heimdall]
# url = "http://localhost:1317"
@ -170,6 +170,11 @@ syncmode = "full"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# pprof = false
# port = 6060
# addr = "127.0.0.1"

View file

@ -35,14 +35,14 @@ syncmode = "full"
# nodekey = ""
# nodekeyhex = ""
# txarrivalwait = "500ms"
# [p2p.discovery]
[p2p.discovery]
# v5disc = false
# bootnodesv4 = []
# bootnodesv5 = []
bootnodes = [ "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303" ]
static-nodes = [ "enode://383ec39eb7f7e23538ea846f502602632110a6bcfc7521bfc2b8833f5a190779507d006b28650d83674b75d188cb36bcb3c3e168a0f2b3d98f9a651cc6603146@52.214.229.208:30303", "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://a4a387ad423a2fd0d652808b270082250d3c616b7e8537209584ebad4806dd50ef8dc66a371c85c7f55e6c1f53747edbb11055c8073cfacf312047eaeb328f58@54.171.220.164:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303", "enode://e8fe33b52f90d4bc7a4e75800945df449d1a091bd347c9f11cd1dbcd98ea28cb4c231cb3b1c6feacdabca2aa91f1a6744724b44edc9382c107968792abdef261@52.74.18.182:30303", "enode://b240f1f18e8f3cc61df96a164ba215ea6fc3f00717e4300da6283362a0438bda53f81ecc24c575ff130066d42096319fa027c952681bbb4f003e0bdd5d5b4e61@52.76.37.145:30303", "enode://de55d16b6e1fca28cdd3d11eb0dd89e3b77b96d4722172bd5e04ac255922324076a87748e97bc021af2307dccbb5ef8062389cfcba1845f77219eee7935dea9f@52.74.125.36:30303", "enode://7f2272685fc3e31c8e43c7687dda43ea3192fd310ba01efcb7811d5dc7ad5a64402ea8cd827650e573a174cf29bb69331dffcca6f0b9894ef17eeafabd97a41d@47.128.184.10:30303", "enode://c66e12243b425b63528dd8b1ce87f2f7fbc85f35485e2d8bf6bbf0ec0dcd05b3a582ef62daadbde061b58058735788335d09ed972a451242b9943b85d323c239@63.32.214.97:30303", "enode://bd56c0f00dd37e14ae2b84f5eb50e357d3a2d326bdbb0cbb987411268b3f132288f6c86157fc132c6902d18b9be0de8bbdcd12d926e16232ebadd8e274aae780@52.208.81.179:30303", "enode://2f015d5b1571165975382281a2117a9b514e1b38e87a8116596fc9b3b121a93cfb238eb6f7b3ae30cf9c0154384372745ce9edc09cbc30526ab7e2059f57ddee@54.74.160.230:30303" ]
# trusted-nodes = []
# dns = []
dns = [ "enrtree://AKUEZKN7PSKVNR65FZDHECMKOJQSGPARGTPPBI7WS2VUL4EGR6XPC@amoy.polygon-peers.io" ]
# [heimdall]
# url = "http://localhost:1317"
@ -169,6 +169,11 @@ syncmode = "full"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# [pprof]
# pprof = false
# port = 6060

View file

@ -36,14 +36,14 @@ syncmode = "full"
# nodekey = ""
# nodekeyhex = ""
# txarrivalwait = "500ms"
# [p2p.discovery]
[p2p.discovery]
# v5disc = false
# bootnodesv5 = []
# bootnodesv4 = []
bootnodes = [ "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303" ]
static-nodes = [ "enode://383ec39eb7f7e23538ea846f502602632110a6bcfc7521bfc2b8833f5a190779507d006b28650d83674b75d188cb36bcb3c3e168a0f2b3d98f9a651cc6603146@52.214.229.208:30303", "enode://bce861be777e91b0a5a49d58a51e14f32f201b4c6c2d1fbea6c7a1f14756cbb3f931f3188d6b65de8b07b53ff28d03b6e366d09e56360d2124a9fc5a15a0913d@54.217.171.196:30303", "enode://a4a387ad423a2fd0d652808b270082250d3c616b7e8537209584ebad4806dd50ef8dc66a371c85c7f55e6c1f53747edbb11055c8073cfacf312047eaeb328f58@54.171.220.164:30303", "enode://4a3dc0081a346d26a73d79dd88216a9402d2292318e2db9947dbc97ea9c4afb2498dc519c0af04420dc13a238c279062da0320181e7c1461216ce4513bfd40bf@13.251.184.185:30303", "enode://e8fe33b52f90d4bc7a4e75800945df449d1a091bd347c9f11cd1dbcd98ea28cb4c231cb3b1c6feacdabca2aa91f1a6744724b44edc9382c107968792abdef261@52.74.18.182:30303", "enode://b240f1f18e8f3cc61df96a164ba215ea6fc3f00717e4300da6283362a0438bda53f81ecc24c575ff130066d42096319fa027c952681bbb4f003e0bdd5d5b4e61@52.76.37.145:30303", "enode://de55d16b6e1fca28cdd3d11eb0dd89e3b77b96d4722172bd5e04ac255922324076a87748e97bc021af2307dccbb5ef8062389cfcba1845f77219eee7935dea9f@52.74.125.36:30303", "enode://7f2272685fc3e31c8e43c7687dda43ea3192fd310ba01efcb7811d5dc7ad5a64402ea8cd827650e573a174cf29bb69331dffcca6f0b9894ef17eeafabd97a41d@47.128.184.10:30303", "enode://c66e12243b425b63528dd8b1ce87f2f7fbc85f35485e2d8bf6bbf0ec0dcd05b3a582ef62daadbde061b58058735788335d09ed972a451242b9943b85d323c239@63.32.214.97:30303", "enode://bd56c0f00dd37e14ae2b84f5eb50e357d3a2d326bdbb0cbb987411268b3f132288f6c86157fc132c6902d18b9be0de8bbdcd12d926e16232ebadd8e274aae780@52.208.81.179:30303", "enode://2f015d5b1571165975382281a2117a9b514e1b38e87a8116596fc9b3b121a93cfb238eb6f7b3ae30cf9c0154384372745ce9edc09cbc30526ab7e2059f57ddee@54.74.160.230:30303" ]
# trusted-nodes = []
# dns = []
dns = [ "enrtree://AKUEZKN7PSKVNR65FZDHECMKOJQSGPARGTPPBI7WS2VUL4EGR6XPC@amoy.polygon-peers.io" ]
# [heimdall]
# url = "http://localhost:1317"
@ -170,6 +170,11 @@ syncmode = "full"
# period = 0
# gaslimit = 11500000
# [parallelevm]
# enable = true
# procs = 8
# enforce = false
# [pprof]
# pprof = false
# port = 6060

View file

@ -23,7 +23,7 @@ import (
const (
VersionMajor = 1 // Major version component of the current release
VersionMinor = 5 // 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
)

View file

@ -3,7 +3,6 @@
package bor
import (
"context"
"crypto/ecdsa"
"encoding/hex"
"encoding/json"
@ -219,8 +218,6 @@ func buildNextBlock(t *testing.T, _bor consensus.Engine, chain *core.BlockChain,
b.addTxWithChain(chain, state, tx, addr)
}
ctx := context.Background()
// Finalize and seal the block
block, err := _bor.FinalizeAndAssemble(chain, b.header, state, &types.Body{
Transactions: b.txs,
@ -242,7 +239,7 @@ func buildNextBlock(t *testing.T, _bor consensus.Engine, chain *core.BlockChain,
res := make(chan *types.Block, 1)
err = _bor.Seal(ctx, chain, block, res, nil)
err = _bor.Seal(chain, block, res, nil)
if err != nil {
// an error case - sign manually
sign(t, header, signer, borConfig)