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') 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') 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') 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