aboutsummaryrefslogtreecommitdiff
path: root/plugin/evm/vm.go
diff options
context:
space:
mode:
authorDeterminant <[email protected]>2020-08-20 12:09:32 -0400
committerDeterminant <[email protected]>2020-08-20 12:09:32 -0400
commit726ad2214ca0a7e4d165838c531aa0d401524600 (patch)
tree1fb7a76d5caf01648525b864e94a3c720ee9a6ee /plugin/evm/vm.go
parentcb5e141d930e0c245804fe87a2caf4962b8f3c5f (diff)
parent0d2a35293b7aa49d143ce215591104aba1c89388 (diff)
Merge tag 'v0.2.8-rc.6' into ecstasy-transferv0.2.12
Diffstat (limited to 'plugin/evm/vm.go')
-rw-r--r--plugin/evm/vm.go32
1 files changed, 17 insertions, 15 deletions
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go
index f97de09..08d7bcb 100644
--- a/plugin/evm/vm.go
+++ b/plugin/evm/vm.go
@@ -62,11 +62,11 @@ const (
)
const (
- minBlockTime = 250 * time.Millisecond
- maxBlockTime = 1000 * time.Millisecond
- batchSize = 250
-
+ minBlockTime = 250 * time.Millisecond
+ maxBlockTime = 1000 * time.Millisecond
+ batchSize = 250
maxUTXOsToFetch = 1024
+ blockCacheSize = 1 << 17 // 131072
)
const (
@@ -303,9 +303,9 @@ func (vm *VM) Initialize(
}
return tx.UnsignedTx.(UnsignedAtomicTx).EVMStateTransfer(state)
})
- vm.blockCache = cache.LRU{Size: 2048}
- vm.blockStatusCache = cache.LRU{Size: 1024}
- vm.blockAtomicInputCache = cache.LRU{Size: 4096}
+ vm.blockCache = cache.LRU{Size: blockCacheSize}
+ vm.blockStatusCache = cache.LRU{Size: blockCacheSize}
+ vm.blockAtomicInputCache = cache.LRU{Size: blockCacheSize}
vm.newBlockChan = make(chan *Block)
vm.networkChan = toEngine
vm.blockDelayTimer = timer.NewTimer(func() {
@@ -553,10 +553,6 @@ func (vm *VM) updateStatus(blockID ids.ID, status choices.Status) {
vm.blockStatusCache.Put(blockID, status)
}
-func (vm *VM) getCachedBlock(blockID ids.ID) *types.Block {
- return vm.chain.GetBlockByHash(blockID.Key())
-}
-
func (vm *VM) tryBlockGen() error {
vm.bdlock.Lock()
defer vm.bdlock.Unlock()
@@ -605,10 +601,11 @@ func (vm *VM) getCachedStatus(blockID ids.ID) choices.Status {
if statusIntf, ok := vm.blockStatusCache.Get(blockID); ok {
status = statusIntf.(choices.Status)
} else {
- blk := vm.chain.GetBlockByHash(blockID.Key())
- if blk == nil {
+ wrappedBlk := vm.getBlock(blockID)
+ if wrappedBlk == nil {
return choices.Unknown
}
+ blk := wrappedBlk.ethBlock
acceptedBlk := vm.lastAccepted.ethBlock
// TODO: There must be a better way of doing this.
@@ -619,7 +616,12 @@ func (vm *VM) getCachedStatus(blockID ids.ID) choices.Status {
highBlock, lowBlock = lowBlock, highBlock
}
for highBlock.Number().Cmp(lowBlock.Number()) > 0 {
- highBlock = vm.chain.GetBlockByHash(highBlock.ParentHash())
+ parentBlock := vm.getBlock(ids.NewID(highBlock.ParentHash()))
+ if parentBlock == nil {
+ vm.blockStatusCache.Put(blockID, choices.Processing)
+ return choices.Processing
+ }
+ highBlock = parentBlock.ethBlock
}
if highBlock.Hash() == lowBlock.Hash() { // on the same branch
@@ -639,7 +641,7 @@ func (vm *VM) getBlock(id ids.ID) *Block {
if blockIntf, ok := vm.blockCache.Get(id); ok {
return blockIntf.(*Block)
}
- ethBlock := vm.getCachedBlock(id)
+ ethBlock := vm.chain.GetBlockByHash(id.Key())
if ethBlock == nil {
return nil
}