From b2397fc5ac92bb324ac09594c87463ec37ea96e0 Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Wed, 16 Sep 2020 11:55:36 -0400 Subject: Add nil to newBlockChan if block verification errors --- plugin/evm/vm.go | 1 + 1 file changed, 1 insertion(+) (limited to 'plugin/evm/vm.go') diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 9ab4781..d9ddd70 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -295,6 +295,7 @@ func (vm *VM) Initialize( vm: vm, } if blk.Verify() != nil { + vm.newBlockChan <- nil return errInvalidBlock } vm.newBlockChan <- blk -- cgit v1.2.3 From 8478802ddacc027a8d8c866da9365f6739d9d9d4 Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 16 Sep 2020 18:26:55 -0400 Subject: ... --- plugin/evm/vm.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'plugin/evm/vm.go') diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 9ab4781..5c5a5b5 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -22,11 +22,11 @@ import ( "github.com/ava-labs/coreth/node" "github.com/ava-labs/coreth/params" - "github.com/ava-labs/go-ethereum/common" - "github.com/ava-labs/go-ethereum/rlp" - "github.com/ava-labs/go-ethereum/rpc" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/rpc" - ethcrypto "github.com/ava-labs/go-ethereum/crypto" + ethcrypto "github.com/ethereum/go-ethereum/crypto" avalancheRPC "github.com/gorilla/rpc/v2" -- cgit v1.2.3 From ed839907e592ad25e6119e145e7e05ca78b00fcd Mon Sep 17 00:00:00 2001 From: Determinant Date: Wed, 16 Sep 2020 22:54:37 -0400 Subject: ... --- plugin/evm/vm.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugin/evm/vm.go') diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 5c5a5b5..993727e 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -22,9 +22,9 @@ import ( "github.com/ava-labs/coreth/node" "github.com/ava-labs/coreth/params" + "github.com/ava-labs/coreth/rpc" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" - "github.com/ethereum/go-ethereum/rpc" ethcrypto "github.com/ethereum/go-ethereum/crypto" -- cgit v1.2.3 From 92fdc0a4b6208387424029182a131b25a2f92dac Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Wed, 16 Sep 2020 23:39:26 -0400 Subject: Switch from ctx.Log to eth logger --- plugin/evm/vm.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'plugin/evm/vm.go') diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 67ae5ce..2b78d43 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -22,9 +22,10 @@ import ( "github.com/ava-labs/coreth/node" "github.com/ava-labs/coreth/params" - "github.com/ava-labs/coreth/rpc" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/rpc" ethcrypto "github.com/ethereum/go-ethereum/crypto" @@ -287,7 +288,7 @@ func (vm *VM) Initialize( return nil, nil }) chain.SetOnSealFinish(func(block *types.Block) error { - vm.ctx.Log.Verbo("EVM sealed a block") + log.Trace("EVM sealed a block") blk := &Block{ id: ids.NewID(block.Hash()), @@ -366,14 +367,14 @@ func (vm *VM) Initialize( var hash common.Hash if err = rlp.DecodeBytes(b, &hash); err == nil { if block := chain.GetBlockByHash(hash); block == nil { - vm.ctx.Log.Debug("lastAccepted block not found in chaindb") + log.Debug("lastAccepted block not found in chaindb") } else { lastAccepted = block } } } if lastAccepted == nil { - vm.ctx.Log.Debug("lastAccepted is unavailable, setting to the genesis block") + log.Debug("lastAccepted is unavailable, setting to the genesis block") lastAccepted = chain.GetGenesisBlock() } vm.lastAccepted = &Block{ @@ -382,7 +383,7 @@ func (vm *VM) Initialize( vm: vm, } vm.genesisHash = chain.GetGenesisBlock().Hash() - vm.ctx.Log.Info(fmt.Sprintf("lastAccepted = %s", vm.lastAccepted.ethBlock.Hash().Hex())) + log.Info(fmt.Sprintf("lastAccepted = %s", vm.lastAccepted.ethBlock.Hash().Hex())) // TODO: shutdown this go routine go vm.ctx.Log.RecoverAndPanic(func() { @@ -390,10 +391,10 @@ func (vm *VM) Initialize( for { select { case <-vm.txSubmitChan: - vm.ctx.Log.Verbo("New tx detected, trying to generate a block") + log.Trace("New tx detected, trying to generate a block") vm.tryBlockGen() case <-vm.atomicTxSubmitChan: - vm.ctx.Log.Verbo("New atomic Tx detected, trying to generate a block") + log.Trace("New atomic Tx detected, trying to generate a block") vm.tryBlockGen() case <-time.After(5 * time.Second): vm.tryBlockGen() @@ -439,7 +440,7 @@ func (vm *VM) BuildBlock() (snowman.Block, error) { vm.blockDelayTimer.SetTimeoutIn(minBlockTime) vm.bdlock.Unlock() - vm.ctx.Log.Debug("built block 0x%x", block.ID().Bytes()) + log.Debug(fmt.Sprintf("built block 0x%x", block.ID().Bytes())) // make sure Tx Pool is updated <-vm.txPoolStabilizedOk return block, nil @@ -623,7 +624,7 @@ func (vm *VM) getCachedStatus(blockID ids.ID) choices.Status { acceptedIDBytes, err := vm.acceptedDB.Get(heightKey) if err == nil { if acceptedID, err := ids.ToID(acceptedIDBytes); err != nil { - vm.ctx.Log.Error("snowman-eth: acceptedID bytes didn't match expected value: %s", err) + log.Error(fmt.Sprintf("snowman-eth: acceptedID bytes didn't match expected value: %s", err)) } else { if acceptedID.Equals(blockID) { vm.blockStatusCache.Put(blockID, choices.Accepted) @@ -638,7 +639,7 @@ func (vm *VM) getCachedStatus(blockID ids.ID) choices.Status { if status == choices.Accepted { err := vm.acceptedDB.Put(heightKey, blockID.Bytes()) if err != nil { - vm.ctx.Log.Error("snowman-eth: failed to write back acceptedID bytes: %s", err) + log.Error(fmt.Sprintf("snowman-eth: failed to write back acceptedID bytes: %s", err)) } tempBlock := wrappedBlk @@ -656,7 +657,7 @@ func (vm *VM) getCachedStatus(blockID ids.ID) choices.Status { } if err := vm.acceptedDB.Put(heightKey, parentID.Bytes()); err != nil { - vm.ctx.Log.Error("snowman-eth: failed to write back acceptedID bytes: %s", err) + log.Error(fmt.Sprintf("snowman-eth: failed to write back acceptedID bytes: %s", err)) } } } @@ -726,10 +727,10 @@ func (vm *VM) writeBackMetadata() { b, err := rlp.EncodeToBytes(vm.lastAccepted.ethBlock.Hash()) if err != nil { - vm.ctx.Log.Error("snowman-eth: error while writing back metadata") + log.Error("snowman-eth: error while writing back metadata") return } - vm.ctx.Log.Debug("writing back metadata") + log.Debug("writing back metadata") vm.chaindb.Put([]byte(lastAcceptedKey), b) atomic.StoreUint32(&vm.writingMetadata, 0) } -- cgit v1.2.3 From 7063564c571bcdc94b981db7ed3707902f0466d0 Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 17 Sep 2020 00:25:32 -0400 Subject: disable snapshot --- plugin/evm/vm.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'plugin/evm/vm.go') diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 993727e..55411cf 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -243,6 +243,10 @@ func (vm *VM) Initialize( config := eth.DefaultConfig config.ManualCanonical = true config.Genesis = g + // disable the experimental snapshot feature from geth + config.TrieCleanCache += config.SnapshotCache + config.SnapshotCache = 0 + config.Miner.ManualMining = true config.Miner.DisableUncle = true -- cgit v1.2.3 From aedd4b46cdc0a48c1b06a3e920bf57f8c28d401d Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 17 Sep 2020 03:08:39 -0400 Subject: fix the block completion race --- plugin/evm/vm.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'plugin/evm/vm.go') diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index c6bc728..c9836c6 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -160,7 +160,7 @@ type VM struct { chaindb Database newBlockChan chan *Block networkChan chan<- commonEng.Message - newTxPoolHeadChan chan core.NewTxPoolHeadEvent + newTxPoolHeadChan *event.TypeMuxSubscription acceptedDB database.Database @@ -344,23 +344,26 @@ func (vm *VM) Initialize( vm.bdTimerState = bdTimerStateLong vm.bdGenWaitFlag = true - vm.newTxPoolHeadChan = make(chan core.NewTxPoolHeadEvent, 1) + //vm.newTxPoolHeadChan = make(chan core.NewTxPoolHeadEvent, 1) vm.txPoolStabilizedOk = make(chan struct{}, 1) // TODO: read size from options vm.pendingAtomicTxs = make(chan *Tx, 1024) vm.atomicTxSubmitChan = make(chan struct{}, 1) - chain.GetTxPool().SubscribeNewHeadEvent(vm.newTxPoolHeadChan) + //chain.GetTxPool().SubscribeNewHeadEvent(vm.newTxPoolHeadChan) + vm.newTxPoolHeadChan = vm.chain.SubscribeNewMinedBlockEvent() // TODO: shutdown this go routine go ctx.Log.RecoverAndPanic(func() { for { select { - case h := <-vm.newTxPoolHeadChan: - vm.txPoolStabilizedLock.Lock() - if vm.txPoolStabilizedHead == h.Block.Hash() { - vm.txPoolStabilizedOk <- struct{}{} - vm.txPoolStabilizedHead = common.Hash{} + case e := <-vm.newTxPoolHeadChan.Chan(): + switch h := e.Data.(core.NewTxPoolHeadEvent) { + vm.txPoolStabilizedLock.Lock() + if vm.txPoolStabilizedHead == h.Block.Hash() { + vm.txPoolStabilizedOk <- struct{}{} + vm.txPoolStabilizedHead = common.Hash{} + } + vm.txPoolStabilizedLock.Unlock() } - vm.txPoolStabilizedLock.Unlock() } } }) -- cgit v1.2.3 From 8123ec9caeb1917519c1f8f67f386df142578728 Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 17 Sep 2020 03:23:13 -0400 Subject: ... --- plugin/evm/vm.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'plugin/evm/vm.go') diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index c9836c6..73a97e8 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -24,6 +24,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" @@ -356,13 +357,15 @@ func (vm *VM) Initialize( for { select { case e := <-vm.newTxPoolHeadChan.Chan(): - switch h := e.Data.(core.NewTxPoolHeadEvent) { + switch h := e.Data.(type) { + case core.NewMinedBlockEvent: vm.txPoolStabilizedLock.Lock() if vm.txPoolStabilizedHead == h.Block.Hash() { vm.txPoolStabilizedOk <- struct{}{} vm.txPoolStabilizedHead = common.Hash{} } vm.txPoolStabilizedLock.Unlock() + default: } } } -- cgit v1.2.3 From b9cb07277a70f126e5ce098faff6fb88cab6c29a Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Thu, 17 Sep 2020 14:11:53 -0400 Subject: Fix panic on shutdown form orphaned goroutine --- plugin/evm/vm.go | 98 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 37 deletions(-) (limited to 'plugin/evm/vm.go') diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 73a97e8..583a0c5 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -23,8 +23,8 @@ import ( "github.com/ava-labs/coreth/params" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/event" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" @@ -165,9 +165,10 @@ type VM struct { acceptedDB database.Database - txPoolStabilizedHead common.Hash - txPoolStabilizedOk chan struct{} - txPoolStabilizedLock sync.Mutex + txPoolStabilizedHead common.Hash + txPoolStabilizedOk chan struct{} + txPoolStabilizedLock sync.Mutex + txPoolStabilizedShutdownChan chan struct{} metalock sync.Mutex blockCache, blockStatusCache cache.LRU @@ -183,12 +184,15 @@ type VM struct { genlock sync.Mutex txSubmitChan <-chan struct{} atomicTxSubmitChan chan struct{} + shutdownSubmitChan chan struct{} codec codec.Codec clock timer.Clock txFee uint64 pendingAtomicTxs chan *Tx blockAtomicInputCache cache.LRU + shutdownWg sync.WaitGroup + fx secp256k1fx.Fx } @@ -347,29 +351,14 @@ func (vm *VM) Initialize( vm.bdGenWaitFlag = true //vm.newTxPoolHeadChan = make(chan core.NewTxPoolHeadEvent, 1) vm.txPoolStabilizedOk = make(chan struct{}, 1) + vm.txPoolStabilizedShutdownChan = make(chan struct{}, 1) // Signal goroutine to shutdown // TODO: read size from options vm.pendingAtomicTxs = make(chan *Tx, 1024) vm.atomicTxSubmitChan = make(chan struct{}, 1) + vm.shutdownSubmitChan = make(chan struct{}, 1) //chain.GetTxPool().SubscribeNewHeadEvent(vm.newTxPoolHeadChan) vm.newTxPoolHeadChan = vm.chain.SubscribeNewMinedBlockEvent() - // TODO: shutdown this go routine - go ctx.Log.RecoverAndPanic(func() { - for { - select { - case e := <-vm.newTxPoolHeadChan.Chan(): - switch h := e.Data.(type) { - case core.NewMinedBlockEvent: - vm.txPoolStabilizedLock.Lock() - if vm.txPoolStabilizedHead == h.Block.Hash() { - vm.txPoolStabilizedOk <- struct{}{} - vm.txPoolStabilizedHead = common.Hash{} - } - vm.txPoolStabilizedLock.Unlock() - default: - } - } - } - }) + go ctx.Log.RecoverAndPanic(vm.awaitTxPoolStabilized) chain.Start() var lastAccepted *types.Block @@ -396,21 +385,7 @@ func (vm *VM) Initialize( log.Info(fmt.Sprintf("lastAccepted = %s", vm.lastAccepted.ethBlock.Hash().Hex())) // TODO: shutdown this go routine - go vm.ctx.Log.RecoverAndPanic(func() { - vm.txSubmitChan = vm.chain.GetTxSubmitCh() - for { - select { - case <-vm.txSubmitChan: - log.Trace("New tx detected, trying to generate a block") - vm.tryBlockGen() - case <-vm.atomicTxSubmitChan: - log.Trace("New atomic Tx detected, trying to generate a block") - vm.tryBlockGen() - case <-time.After(5 * time.Second): - vm.tryBlockGen() - } - } - }) + go vm.ctx.Log.RecoverAndPanic(vm.awaitSubmittedTxs) vm.codec = Codec return vm.fx.Initialize(vm) @@ -431,7 +406,10 @@ func (vm *VM) Shutdown() error { } vm.writeBackMetadata() + close(vm.txPoolStabilizedShutdownChan) + close(vm.shutdownSubmitChan) vm.chain.Stop() + vm.shutdownWg.Wait() return nil } @@ -745,6 +723,52 @@ func (vm *VM) writeBackMetadata() { atomic.StoreUint32(&vm.writingMetadata, 0) } +// awaitTxPoolStabilized waits for a txPoolHead channel event +// and notifies the VM when the tx pool has stabilized to the +// expected block hash +// Waits for signal to shutdown from txPoolStabilizedShutdownChan chan +func (vm *VM) awaitTxPoolStabilized() { + vm.shutdownWg.Add(1) + for { + select { + case e := <-vm.newTxPoolHeadChan.Chan(): + switch h := e.Data.(type) { + case core.NewMinedBlockEvent: + vm.txPoolStabilizedLock.Lock() + if vm.txPoolStabilizedHead == h.Block.Hash() { + vm.txPoolStabilizedOk <- struct{}{} + vm.txPoolStabilizedHead = common.Hash{} + } + vm.txPoolStabilizedLock.Unlock() + default: + } + case <-vm.txPoolStabilizedShutdownChan: + vm.shutdownWg.Done() + return + } + } +} + +func (vm *VM) awaitSubmittedTxs() { + vm.shutdownWg.Add(1) + vm.txSubmitChan = vm.chain.GetTxSubmitCh() + for { + select { + case <-vm.txSubmitChan: + log.Trace("New tx detected, trying to generate a block") + vm.tryBlockGen() + case <-vm.atomicTxSubmitChan: + log.Trace("New atomic Tx detected, trying to generate a block") + vm.tryBlockGen() + case <-time.After(5 * time.Second): + vm.tryBlockGen() + case <-vm.shutdownSubmitChan: + vm.shutdownWg.Done() + return + } + } +} + func (vm *VM) getLastAccepted() *Block { vm.metalock.Lock() defer vm.metalock.Unlock() -- cgit v1.2.3 From 1a17fcec0e23aba017e3641c708e40e79be8e153 Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Thu, 17 Sep 2020 14:32:42 -0400 Subject: move wg add outside of goroutines to prevent race condition --- plugin/evm/vm.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugin/evm/vm.go') diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 583a0c5..92e51e6 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -358,6 +358,7 @@ func (vm *VM) Initialize( vm.shutdownSubmitChan = make(chan struct{}, 1) //chain.GetTxPool().SubscribeNewHeadEvent(vm.newTxPoolHeadChan) vm.newTxPoolHeadChan = vm.chain.SubscribeNewMinedBlockEvent() + vm.shutdownWg.Add(1) go ctx.Log.RecoverAndPanic(vm.awaitTxPoolStabilized) chain.Start() @@ -385,6 +386,7 @@ func (vm *VM) Initialize( log.Info(fmt.Sprintf("lastAccepted = %s", vm.lastAccepted.ethBlock.Hash().Hex())) // TODO: shutdown this go routine + vm.shutdownWg.Add(1) go vm.ctx.Log.RecoverAndPanic(vm.awaitSubmittedTxs) vm.codec = Codec @@ -728,7 +730,6 @@ func (vm *VM) writeBackMetadata() { // expected block hash // Waits for signal to shutdown from txPoolStabilizedShutdownChan chan func (vm *VM) awaitTxPoolStabilized() { - vm.shutdownWg.Add(1) for { select { case e := <-vm.newTxPoolHeadChan.Chan(): @@ -750,7 +751,6 @@ func (vm *VM) awaitTxPoolStabilized() { } func (vm *VM) awaitSubmittedTxs() { - vm.shutdownWg.Add(1) vm.txSubmitChan = vm.chain.GetTxSubmitCh() for { select { -- cgit v1.2.3 From b0a75c03303fe22f31fe1e1f0fa29a1e1cd78253 Mon Sep 17 00:00:00 2001 From: Aaron Buchwald Date: Thu, 17 Sep 2020 14:37:10 -0400 Subject: Defer wg Done call instead of calling before return --- plugin/evm/vm.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugin/evm/vm.go') diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index 92e51e6..c02b835 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -730,6 +730,7 @@ func (vm *VM) writeBackMetadata() { // expected block hash // Waits for signal to shutdown from txPoolStabilizedShutdownChan chan func (vm *VM) awaitTxPoolStabilized() { + defer vm.shutdownWg.Done() for { select { case e := <-vm.newTxPoolHeadChan.Chan(): @@ -744,13 +745,13 @@ func (vm *VM) awaitTxPoolStabilized() { default: } case <-vm.txPoolStabilizedShutdownChan: - vm.shutdownWg.Done() return } } } func (vm *VM) awaitSubmittedTxs() { + defer vm.shutdownWg.Done() vm.txSubmitChan = vm.chain.GetTxSubmitCh() for { select { @@ -763,7 +764,6 @@ func (vm *VM) awaitSubmittedTxs() { case <-time.After(5 * time.Second): vm.tryBlockGen() case <-vm.shutdownSubmitChan: - vm.shutdownWg.Done() return } } -- cgit v1.2.3 From 3ea6a7940e40677b629270dfc7a1466bca295bd3 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 18 Sep 2020 13:09:22 -0400 Subject: clean up the code --- plugin/evm/vm.go | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'plugin/evm/vm.go') diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go index c02b835..200a08d 100644 --- a/plugin/evm/vm.go +++ b/plugin/evm/vm.go @@ -154,14 +154,14 @@ func init() { type VM struct { ctx *snow.Context - chainID *big.Int - networkID uint64 - genesisHash common.Hash - chain *coreth.ETHChain - chaindb Database - newBlockChan chan *Block - networkChan chan<- commonEng.Message - newTxPoolHeadChan *event.TypeMuxSubscription + chainID *big.Int + networkID uint64 + genesisHash common.Hash + chain *coreth.ETHChain + chaindb Database + newBlockChan chan *Block + networkChan chan<- commonEng.Message + newMinedBlockSub *event.TypeMuxSubscription acceptedDB database.Database @@ -349,15 +349,13 @@ func (vm *VM) Initialize( vm.bdTimerState = bdTimerStateLong vm.bdGenWaitFlag = true - //vm.newTxPoolHeadChan = make(chan core.NewTxPoolHeadEvent, 1) vm.txPoolStabilizedOk = make(chan struct{}, 1) vm.txPoolStabilizedShutdownChan = make(chan struct{}, 1) // Signal goroutine to shutdown // TODO: read size from options vm.pendingAtomicTxs = make(chan *Tx, 1024) vm.atomicTxSubmitChan = make(chan struct{}, 1) vm.shutdownSubmitChan = make(chan struct{}, 1) - //chain.GetTxPool().SubscribeNewHeadEvent(vm.newTxPoolHeadChan) - vm.newTxPoolHeadChan = vm.chain.SubscribeNewMinedBlockEvent() + vm.newMinedBlockSub = vm.chain.SubscribeNewMinedBlockEvent() vm.shutdownWg.Add(1) go ctx.Log.RecoverAndPanic(vm.awaitTxPoolStabilized) chain.Start() @@ -733,7 +731,7 @@ func (vm *VM) awaitTxPoolStabilized() { defer vm.shutdownWg.Done() for { select { - case e := <-vm.newTxPoolHeadChan.Chan(): + case e := <-vm.newMinedBlockSub.Chan(): switch h := e.Data.(type) { case core.NewMinedBlockEvent: vm.txPoolStabilizedLock.Lock() -- cgit v1.2.3