aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authoraaronbuchwald <[email protected]>2020-09-17 09:36:44 -0400
committerGitHub <[email protected]>2020-09-17 09:36:44 -0400
commit42ee77a946d062a4c8e1fabc394ac016ae30e68e (patch)
tree85da01f5b75788e257d3c355917a4b3a8ad8603b /plugin
parent92fdc0a4b6208387424029182a131b25a2f92dac (diff)
parent6b4efa7ff5537a7cdb1d73b18dd75f56bdadc032 (diff)
Merge pull request #33 from ava-labs/fix-nil-pointer
Fix potential nil pointer dereference
Diffstat (limited to 'plugin')
-rw-r--r--plugin/evm/vm.go28
1 files changed, 19 insertions, 9 deletions
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go
index 2b78d43..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"
@@ -160,7 +161,7 @@ type VM struct {
chaindb Database
newBlockChan chan *Block
networkChan chan<- commonEng.Message
- newTxPoolHeadChan chan core.NewTxPoolHeadEvent
+ newTxPoolHeadChan *event.TypeMuxSubscription
acceptedDB database.Database
@@ -244,6 +245,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
@@ -340,23 +345,28 @@ 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.(type) {
+ case core.NewMinedBlockEvent:
+ vm.txPoolStabilizedLock.Lock()
+ if vm.txPoolStabilizedHead == h.Block.Hash() {
+ vm.txPoolStabilizedOk <- struct{}{}
+ vm.txPoolStabilizedHead = common.Hash{}
+ }
+ vm.txPoolStabilizedLock.Unlock()
+ default:
}
- vm.txPoolStabilizedLock.Unlock()
}
}
})