From 092b35aa892958b0ebcd97f588a9291b19ded18c Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Wed, 22 Sep 2021 19:23:58 +0000 Subject: [PATCH] gofmt --- eth/backend.go | 4 +- eth/ethconfig/config.go | 6 +- miner/collator.go | 128 ++++++++++++++++----------------- miner/default_collator.go | 146 ++++++++++++++++++------------------- miner/miner.go | 50 ++++++------- miner/worker.go | 147 +++++++++++++++++++------------------- 6 files changed, 240 insertions(+), 241 deletions(-) diff --git a/eth/backend.go b/eth/backend.go index 23d47bd2d489c..db790d18d2494 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -123,8 +123,8 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { return nil, err } } else { - minerCollator = &miner.DefaultCollator{} - } + minerCollator = &miner.DefaultCollator{} + } if config.NoPruning && config.TrieDirtyCache > 0 { if config.SnapshotCache > 0 { diff --git a/eth/ethconfig/config.go b/eth/ethconfig/config.go index 1e41fd350e823..4d487f692e4ba 100644 --- a/eth/ethconfig/config.go +++ b/eth/ethconfig/config.go @@ -83,9 +83,9 @@ var Defaults = Config{ TrieTimeout: 60 * time.Minute, SnapshotCache: 102, Miner: miner.Config{ - GasCeil: 8000000, - GasPrice: big.NewInt(params.GWei), - Recommit: 3 * time.Second, + GasCeil: 8000000, + GasPrice: big.NewInt(params.GWei), + Recommit: 3 * time.Second, UseCustomCollator: false, CollatorPath: "", CollatorConfigPath: "", diff --git a/miner/collator.go b/miner/collator.go index ddeff54aa2224..b7ad9f3adde7d 100644 --- a/miner/collator.go +++ b/miner/collator.go @@ -4,16 +4,16 @@ import ( "errors" // "math" //"math/big" + "context" "os" "plugin" "time" - "context" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" + "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/params" "github.com/naoina/toml" ) @@ -106,52 +106,52 @@ type BlockState interface { the account which will receive the block reward. */ Etherbase() common.Address - GasPool() core.GasPool + GasPool() core.GasPool } type collatorBlockState struct { state *state.StateDB - txs []*types.Transaction - receipts []*types.Receipt - env *environment - committed bool - tcount int // tx count in cycle - gasPool *core.GasPool // available gas used to pack transactions - logs []*types.Log - snapshots []int - header *types.Header + txs []*types.Transaction + receipts []*types.Receipt + env *environment + committed bool + tcount int // tx count in cycle + gasPool *core.GasPool // available gas used to pack transactions + logs []*types.Log + snapshots []int + header *types.Header } type MinerState interface { - IsRunning() bool - ChainConfig() *params.ChainConfig + IsRunning() bool + ChainConfig() *params.ChainConfig } type minerState struct { - // keep a copy of ChainConfig here, if collator chooses (erroneously) to modify chainConfig, the chainConfig used by the miner doesn't get changed - chainConfig *params.ChainConfig - worker *worker + // keep a copy of ChainConfig here, if collator chooses (erroneously) to modify chainConfig, the chainConfig used by the miner doesn't get changed + chainConfig *params.ChainConfig + worker *worker } func (m *minerState) ChainConfig() *params.ChainConfig { - return m.chainConfig + return m.chainConfig } func (m *minerState) IsRunning() bool { - return m.worker.isRunning() + return m.worker.isRunning() } type BlockCollatorWork struct { - Ctx context.Context - Block BlockState + Ctx context.Context + Block BlockState } type Collator interface { - CollateBlocks(miner MinerState, blockCh <-chan BlockCollatorWork, exitCh <-chan struct{}) + CollateBlocks(miner MinerState, blockCh <-chan BlockCollatorWork, exitCh <-chan struct{}) } var ( - ErrAlreadyCommitted = errors.New("can't mutate BlockState after calling Commit()") + ErrAlreadyCommitted = errors.New("can't mutate BlockState after calling Commit()") // errors which indicate that a given transaction cannot be // added at a given block or chain configuration. @@ -160,35 +160,35 @@ var ( ErrNonceTooHigh = errors.New("tx nonce too high") ErrTxTypeNotSupported = errors.New("tx type not supported") ErrGasFeeCapTooLow = errors.New("gas fee cap too low") - ErrZeroTxs = errors.New("zero transactions") - ErrTooManyTxs = errors.New("applying txs to block would go over the block gas limit") + ErrZeroTxs = errors.New("zero transactions") + ErrTooManyTxs = errors.New("applying txs to block would go over the block gas limit") // error which encompasses all other reasons a given transaction // could not be added to the block. ErrStrange = errors.New("strange error") ) func (bs *collatorBlockState) Commit() bool { - if bs.committed { - return false - } - bs.env.worker.curEnvMu.Lock() - defer bs.env.worker.curEnvMu.Unlock() - - if bs.env.cycleCtx != nil { - select { - case <-bs.env.cycleCtx.Done(): - return false - default: - } - } - - bs.env.current = bs - if bs.env.shouldSeal { - bs.env.worker.commit(bs.env.copy(), nil, true, time.Now()) - } - - bs.committed = true - return true + if bs.committed { + return false + } + bs.env.worker.curEnvMu.Lock() + defer bs.env.worker.curEnvMu.Unlock() + + if bs.env.cycleCtx != nil { + select { + case <-bs.env.cycleCtx.Done(): + return false + default: + } + } + + bs.env.current = bs + if bs.env.shouldSeal { + bs.env.worker.commit(bs.env.copy(), nil, true, time.Now()) + } + + bs.committed = true + return true } func copyLogs(logs []*types.Log) []*types.Log { @@ -225,30 +225,30 @@ func copyReceipts(receipts []*types.Receipt) []*types.Receipt { } func (bs *collatorBlockState) Copy() BlockState { - return bs.copy() + return bs.copy() } func (bs *collatorBlockState) copy() *collatorBlockState { cpy := collatorBlockState{ - env: bs.env, - state: bs.state.Copy(), - tcount: bs.tcount, - committed: bs.committed, - logs: copyLogs(bs.logs), - receipts: copyReceipts(bs.receipts), - header: types.CopyHeader(bs.header), + env: bs.env, + state: bs.state.Copy(), + tcount: bs.tcount, + committed: bs.committed, + logs: copyLogs(bs.logs), + receipts: copyReceipts(bs.receipts), + header: types.CopyHeader(bs.header), } - if bs.gasPool != nil { - cpy.gasPool = new(core.GasPool) - *cpy.gasPool = *bs.gasPool - } - cpy.txs = make([]*types.Transaction, len(bs.txs)) - copy(cpy.txs, bs.txs) + if bs.gasPool != nil { + cpy.gasPool = new(core.GasPool) + *cpy.gasPool = *bs.gasPool + } + cpy.txs = make([]*types.Transaction, len(bs.txs)) + copy(cpy.txs, bs.txs) cpy.snapshots = make([]int, len(bs.snapshots)) copy(cpy.snapshots, bs.snapshots) - return &cpy + return &cpy } func (bs *collatorBlockState) commitTransaction(tx *types.Transaction) ([]*types.Log, error) { @@ -358,13 +358,13 @@ func (bs *collatorBlockState) Etherbase() common.Address { } func (bs *collatorBlockState) GasPool() core.GasPool { - return *bs.gasPool + return *bs.gasPool } func (bs *collatorBlockState) discard() { - bs.state.StopPrefetcher() + bs.state.StopPrefetcher() } func (bs *collatorBlockState) Header() *types.Header { - return types.CopyHeader(bs.header) + return types.CopyHeader(bs.header) } diff --git a/miner/default_collator.go b/miner/default_collator.go index e9bedf0e82824..faf0890f39a5b 100644 --- a/miner/default_collator.go +++ b/miner/default_collator.go @@ -1,10 +1,10 @@ package miner import ( + "context" "errors" - "time" - "sync" - "context" + "sync" + "time" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -30,12 +30,12 @@ const ( ) type DefaultCollator struct { - recommitMu sync.Mutex - recommit time.Duration - minRecommit time.Duration - miner MinerState - exitCh <-chan struct{} - pool Pool + recommitMu sync.Mutex + recommit time.Duration + minRecommit time.Duration + miner MinerState + exitCh <-chan struct{} + pool Pool } // recalcRecommit recalculates the resubmitting interval upon feedback. @@ -65,7 +65,7 @@ func (c *DefaultCollator) adjustRecommit(bs BlockState, inc bool) { defer c.recommitMu.Unlock() header := bs.Header() gasLimit := header.GasLimit - gasPool := bs.GasPool() + gasPool := bs.GasPool() if inc { before := c.recommit ratio := float64(gasLimit-gasPool.Gas()) / float64(gasLimit) @@ -182,74 +182,74 @@ func (c *DefaultCollator) fillTransactions(ctx context.Context, bs BlockState, t bs.Commit() } -func (c* DefaultCollator) workCycle(work BlockCollatorWork) { - ctx := work.Ctx - emptyBs := work.Block - - for { - c.recommitMu.Lock() - curRecommit := c.recommit - c.recommitMu.Unlock() - timer := time.NewTimer(curRecommit) - - bs := emptyBs.Copy() - c.fillTransactions(ctx, bs, timer) - bs.Commit() - shouldContinue := false - - select { - case <-timer.C: - select { - case <-ctx.Done(): - return - case <-c.exitCh: - return - default: - } - - c.adjustRecommit(bs, true) - shouldContinue = true - default: - } - - if shouldContinue { - continue - } - - select { - case <-ctx.Done(): - return - case <-timer.C: - // If mining is running resubmit a new work cycle periodically to pull in - // higher priced transactions. Disable this overhead for pending blocks. - chainConfig := c.miner.ChainConfig() - if c.miner.IsRunning() && (chainConfig.Clique == nil || chainConfig.Clique.Period > 0) { - c.adjustRecommit(bs, false) - } else { - return - } - case <-c.exitCh: - return - } - } +func (c *DefaultCollator) workCycle(work BlockCollatorWork) { + ctx := work.Ctx + emptyBs := work.Block + + for { + c.recommitMu.Lock() + curRecommit := c.recommit + c.recommitMu.Unlock() + timer := time.NewTimer(curRecommit) + + bs := emptyBs.Copy() + c.fillTransactions(ctx, bs, timer) + bs.Commit() + shouldContinue := false + + select { + case <-timer.C: + select { + case <-ctx.Done(): + return + case <-c.exitCh: + return + default: + } + + c.adjustRecommit(bs, true) + shouldContinue = true + default: + } + + if shouldContinue { + continue + } + + select { + case <-ctx.Done(): + return + case <-timer.C: + // If mining is running resubmit a new work cycle periodically to pull in + // higher priced transactions. Disable this overhead for pending blocks. + chainConfig := c.miner.ChainConfig() + if c.miner.IsRunning() && (chainConfig.Clique == nil || chainConfig.Clique.Period > 0) { + c.adjustRecommit(bs, false) + } else { + return + } + case <-c.exitCh: + return + } + } } func (c *DefaultCollator) SetRecommit(interval time.Duration) { - c.recommitMu.Lock() - defer c.recommitMu.Unlock() + c.recommitMu.Lock() + defer c.recommitMu.Unlock() - c.recommit, c.minRecommit = interval, interval + c.recommit, c.minRecommit = interval, interval } func (c *DefaultCollator) CollateBlocks(miner MinerState, blockCh <-chan BlockCollatorWork, exitCh <-chan struct{}) { - c.miner = miner - c.exitCh = exitCh - for { - select { - case <-c.exitCh: - return - case cycleWork := <-blockCh: - c.workCycle(cycleWork) - } - } + c.miner = miner + c.exitCh = exitCh + for { + select { + case <-c.exitCh: + return + case cycleWork := <-blockCh: + c.workCycle(cycleWork) + } + } } diff --git a/miner/miner.go b/miner/miner.go index 89e4e9e94309c..857fe8d6eff12 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -42,15 +42,15 @@ type Backend interface { // Config is the configuration parameters of mining. type Config struct { - Etherbase common.Address `toml:",omitempty"` // Public address for block mining rewards (default = first account) - Notify []string `toml:",omitempty"` // HTTP URL list to be notified of new work packages (only useful in ethash). - NotifyFull bool `toml:",omitempty"` // Notify with pending block headers instead of work packages - ExtraData hexutil.Bytes `toml:",omitempty"` // Block extra data set by the miner - GasFloor uint64 // Target gas floor for mined blocks. - GasCeil uint64 // Target gas ceiling for mined blocks. - GasPrice *big.Int // Minimum gas price for mining a transaction - Recommit time.Duration // The time interval for miner to re-create mining work. - Noverify bool // Disable remote mining solution verification(only useful in ethash). + Etherbase common.Address `toml:",omitempty"` // Public address for block mining rewards (default = first account) + Notify []string `toml:",omitempty"` // HTTP URL list to be notified of new work packages (only useful in ethash). + NotifyFull bool `toml:",omitempty"` // Notify with pending block headers instead of work packages + ExtraData hexutil.Bytes `toml:",omitempty"` // Block extra data set by the miner + GasFloor uint64 // Target gas floor for mined blocks. + GasCeil uint64 // Target gas ceiling for mined blocks. + GasPrice *big.Int // Minimum gas price for mining a transaction + Recommit time.Duration // The time interval for miner to re-create mining work. + Noverify bool // Disable remote mining solution verification(only useful in ethash). UseCustomCollator bool CollatorPath string CollatorConfigPath string @@ -58,27 +58,27 @@ type Config struct { // Miner creates blocks and searches for proof-of-work values. type Miner struct { - mux *event.TypeMux - worker *worker - coinbase common.Address - eth Backend - engine consensus.Engine - exitCh chan struct{} - startCh chan common.Address - stopCh chan struct{} + mux *event.TypeMux + worker *worker + coinbase common.Address + eth Backend + engine consensus.Engine + exitCh chan struct{} + startCh chan common.Address + stopCh chan struct{} CollatorAPI CollatorAPI } func New(eth Backend, config *Config, chainConfig *params.ChainConfig, mux *event.TypeMux, engine consensus.Engine, isLocalBlock func(block *types.Block) bool, collator Collator, collatorAPI CollatorAPI) *Miner { miner := &Miner{ - eth: eth, - mux: mux, - engine: engine, - exitCh: make(chan struct{}), - startCh: make(chan common.Address), - stopCh: make(chan struct{}), - CollatorAPI: collatorAPI, - worker: newWorker(config, chainConfig, collator, engine, eth, mux, isLocalBlock, true), + eth: eth, + mux: mux, + engine: engine, + exitCh: make(chan struct{}), + startCh: make(chan common.Address), + stopCh: make(chan struct{}), + CollatorAPI: collatorAPI, + worker: newWorker(config, chainConfig, collator, engine, eth, mux, isLocalBlock, true), } go miner.update() diff --git a/miner/worker.go b/miner/worker.go index 98ebb79e64b6c..6ca3f5a405c9a 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -17,13 +17,13 @@ package miner import ( + "context" "errors" "fmt" "math/big" "sync" "sync/atomic" "time" - "context" mapset "github.com/deckarep/golang-set" "github.com/ethereum/go-ethereum/common" @@ -62,20 +62,19 @@ const ( // environment is the worker's current environment and holds all // information of the sealing block generation. type environment struct { - signer types.Signer - ancestors mapset.Set // ancestor set (used for checking uncle parent validity) - family mapset.Set // family set (used for checking uncle invalidity) + signer types.Signer + ancestors mapset.Set // ancestor set (used for checking uncle parent validity) + family mapset.Set // family set (used for checking uncle invalidity) coinbase common.Address - uncles map[common.Hash]*types.Header - current *collatorBlockState - worker *worker - cycleCtx context.Context - cancelCycle func() - shouldSeal bool + uncles map[common.Hash]*types.Header + current *collatorBlockState + worker *worker + cycleCtx context.Context + cancelCycle func() + shouldSeal bool } - // copy creates a deep copy of environment. func (env *environment) copy() *environment { cpy := &environment{ @@ -83,7 +82,7 @@ func (env *environment) copy() *environment { ancestors: env.ancestors.Clone(), family: env.family.Clone(), coinbase: env.coinbase, - current: env.current.copy(), + current: env.current.copy(), } cpy.uncles = make(map[common.Hash]*types.Header) for hash, uncle := range env.uncles { @@ -176,12 +175,12 @@ type worker struct { remoteUncles map[common.Hash]*types.Block // A set of side blocks as the possible uncle blocks. unconfirmed *unconfirmedBlocks // A set of locally mined blocks pending canonicalness confirmations. - isDefaultCollator bool - current *environment // An environment for current running cycle. - curEnvMu sync.Mutex // used to guard updates to the current pending block - mu sync.RWMutex - coinbase common.Address - extra []byte + isDefaultCollator bool + current *environment // An environment for current running cycle. + curEnvMu sync.Mutex // used to guard updates to the current pending block + mu sync.RWMutex + coinbase common.Address + extra []byte pendingMu sync.RWMutex pendingTasks map[common.Hash]*task @@ -205,12 +204,12 @@ type worker struct { isLocalBlock func(block *types.Block) bool // Function used to determine whether the specified block is mined by local miner. // Test hooks - newTaskHook func(*task) // Method to call upon receiving a new sealing task. - skipSealHook func(*task) bool // Method to decide whether skipping the sealing. - fullTaskHook func() // Method to call before pushing the full sealing task. - resubmitHook func(time.Duration, time.Duration) // Method to call upon updating resubmitting interval. - collator Collator - collatorBlockCh chan BlockCollatorWork + newTaskHook func(*task) // Method to call upon receiving a new sealing task. + skipSealHook func(*task) bool // Method to decide whether skipping the sealing. + fullTaskHook func() // Method to call before pushing the full sealing task. + resubmitHook func(time.Duration, time.Duration) // Method to call upon updating resubmitting interval. + collator Collator + collatorBlockCh chan BlockCollatorWork } func newWorker(config *Config, chainConfig *params.ChainConfig, collator Collator, engine consensus.Engine, eth Backend, mux *event.TypeMux, isLocalBlock func(*types.Block) bool, init bool) *worker { @@ -236,13 +235,13 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, collator Collato exitCh: make(chan struct{}), startCh: make(chan struct{}, 1), resubmitIntervalCh: make(chan time.Duration), - collatorBlockCh: make(chan BlockCollatorWork), - collator: collator, + collatorBlockCh: make(chan BlockCollatorWork), + collator: collator, } - if _, ok := collator.(*DefaultCollator); ok { - worker.isDefaultCollator = true - } + if _, ok := collator.(*DefaultCollator); ok { + worker.isDefaultCollator = true + } // Subscribe NewTxsEvent for tx pool worker.txsSub = eth.TxPool().SubscribeNewTxsEvent(worker.txsCh) @@ -262,12 +261,12 @@ func newWorker(config *Config, chainConfig *params.ChainConfig, collator Collato go worker.resultLoop() go worker.taskLoop() - minerState := minerState{ - worker: worker, - chainConfig: params.CopyChainConfig(worker.chainConfig), - } - // - go worker.collator.CollateBlocks(&minerState, worker.collatorBlockCh, worker.exitCh) + minerState := minerState{ + worker: worker, + chainConfig: params.CopyChainConfig(worker.chainConfig), + } + // + go worker.collator.CollateBlocks(&minerState, worker.collatorBlockCh, worker.exitCh) // Submit first work to initialize pending state. if init { @@ -298,12 +297,12 @@ func (w *worker) setExtra(extra []byte) { // setRecommitInterval updates the interval for miner sealing work recommitting. func (w *worker) setRecommitInterval(interval time.Duration) { - if w.isDefaultCollator { - defaultCollator, _ := w.collator.(*DefaultCollator) - defaultCollator.SetRecommit(interval) - } else { - log.Warn("setRecommitInterval has no effect unless using the default collator") - } + if w.isDefaultCollator { + defaultCollator, _ := w.collator.(*DefaultCollator) + defaultCollator.SetRecommit(interval) + } else { + log.Warn("setRecommitInterval has no effect unless using the default collator") + } } // disablePreseal disables pre-sealing feature @@ -371,7 +370,7 @@ func (w *worker) close() { // newWorkLoop is a standalone goroutine to submit new sealing work upon received events. func (w *worker) newWorkLoop(recommit time.Duration) { - var timestamp int64 + var timestamp int64 // commit aborts in-flight transaction execution with given signal and resubmits a new one. commit := func(noempty bool) { @@ -454,11 +453,11 @@ func (w *worker) mainLoop() { // sealing block for higher profit. if w.isRunning() && w.current != nil && len(w.current.uncles) < 2 { start := time.Now() - w.curEnvMu.Lock() + w.curEnvMu.Lock() if err := w.commitUncle(w.current, ev.Block.Header()); err == nil { w.commit(w.current.copy(), nil, true, start) } - w.curEnvMu.Unlock() + w.curEnvMu.Unlock() } case <-cleanTicker.C: @@ -613,28 +612,28 @@ func (w *worker) makeEnv(parent *types.Block, header *types.Header, coinbase com } state.StartPrefetcher("miner") - bs := &collatorBlockState{ - header: header, - state: state, - gasPool: new(core.GasPool).AddGas(header.GasLimit), - tcount: 0, - } + bs := &collatorBlockState{ + header: header, + state: state, + gasPool: new(core.GasPool).AddGas(header.GasLimit), + tcount: 0, + } - ctx, cancel := context.WithCancel(context.Background()) + ctx, cancel := context.WithCancel(context.Background()) // Note the passed coinbase may be different with header.Coinbase. env := &environment{ - signer: types.MakeSigner(w.chainConfig, header.Number), - coinbase: coinbase, - ancestors: mapset.NewSet(), - family: mapset.NewSet(), - uncles: make(map[common.Hash]*types.Header), - current: bs, - cycleCtx: ctx, - cancelCycle: cancel, + signer: types.MakeSigner(w.chainConfig, header.Number), + coinbase: coinbase, + ancestors: mapset.NewSet(), + family: mapset.NewSet(), + uncles: make(map[common.Hash]*types.Header), + current: bs, + cycleCtx: ctx, + cancelCycle: cancel, } - bs.env = env + bs.env = env // when 08 is processed ancestors contain 07 (quick block) for _, ancestor := range w.chain.GetBlocksFromHash(parent.Hash(), 7) { @@ -645,8 +644,8 @@ func (w *worker) makeEnv(parent *types.Block, header *types.Header, coinbase com env.ancestors.Add(ancestor.Hash()) } - // have to copy the empty blockState b/c the collator needs a scratch blockState to modify (current env can only be mutated by holding currentMu) - // this is because we may respond to uncles arriving before collator finishes and need a copy of the empty blockState to finalize a new block. + // have to copy the empty blockState b/c the collator needs a scratch blockState to modify (current env can only be mutated by holding currentMu) + // this is because we may respond to uncles arriving before collator finishes and need a copy of the empty blockState to finalize a new block. return env, bs.copy(), nil } @@ -786,22 +785,22 @@ func (w *worker) generateWork(params *generateParams) (*types.Block, error) { } defer work.discard() - panic("TODO") - // w.collator.CollateBlock(bs) + panic("TODO") + // w.collator.CollateBlock(bs) return w.engine.FinalizeAndAssemble(w.chain, work.current.header, work.current.state, work.current.txs, work.unclelist(), work.current.receipts) } // commitWork generates several new sealing tasks based on the parent block // and submit them to the sealer. func (w *worker) commitWork(noempty bool, timestamp int64) { - w.curEnvMu.Lock() - if w.current != nil { - // Swap out the old work with the new one, terminating any leftover - // prefetcher processes in the mean time and starting a new one. - // TODO can probably move cancelCycle into discard - w.current.cancelCycle() - w.current.discard() - } + w.curEnvMu.Lock() + if w.current != nil { + // Swap out the old work with the new one, terminating any leftover + // prefetcher processes in the mean time and starting a new one. + // TODO can probably move cancelCycle into discard + w.current.cancelCycle() + w.current.discard() + } start := time.Now() work, blockState, err := w.prepareWork(&generateParams{timestamp: uint64(timestamp)}) @@ -814,9 +813,9 @@ func (w *worker) commitWork(noempty bool, timestamp int64) { w.commit(work.copy(), nil, false, start) } w.current = work - w.curEnvMu.Unlock() + w.curEnvMu.Unlock() - w.collatorBlockCh <- BlockCollatorWork{Block: blockState, Ctx: work.cycleCtx} + w.collatorBlockCh <- BlockCollatorWork{Block: blockState, Ctx: work.cycleCtx} } // commit runs any post-transaction state modifications, assembles the final block