aboutsummaryrefslogtreecommitdiff
path: root/plugin/evm/vm.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/evm/vm.go')
-rw-r--r--plugin/evm/vm.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go
index 1f7e501..09e2ad5 100644
--- a/plugin/evm/vm.go
+++ b/plugin/evm/vm.go
@@ -309,7 +309,7 @@ func (vm *VM) Initialize(
log.Trace("EVM sealed a block")
blk := &Block{
- id: ids.NewID(block.Hash()),
+ id: ids.ID(block.Hash()),
ethBlock: block,
vm: vm,
}
@@ -318,7 +318,7 @@ func (vm *VM) Initialize(
return errInvalidBlock
}
vm.newBlockChan <- blk
- vm.updateStatus(ids.NewID(block.Hash()), choices.Processing)
+ vm.updateStatus(ids.ID(block.Hash()), choices.Processing)
vm.txPoolStabilizedLock.Lock()
vm.txPoolStabilizedHead = block.Hash()
vm.txPoolStabilizedLock.Unlock()
@@ -385,7 +385,7 @@ func (vm *VM) Initialize(
lastAccepted = chain.GetGenesisBlock()
}
vm.lastAccepted = &Block{
- id: ids.NewID(lastAccepted.Hash()),
+ id: ids.ID(lastAccepted.Hash()),
ethBlock: lastAccepted,
vm: vm,
}
@@ -437,7 +437,7 @@ func (vm *VM) BuildBlock() (snowman.Block, error) {
vm.blockDelayTimer.SetTimeoutIn(minBlockTime)
vm.bdlock.Unlock()
- log.Debug(fmt.Sprintf("built block 0x%x", block.ID().Bytes()))
+ log.Debug(fmt.Sprintf("built block %s", block.ID()))
// make sure Tx Pool is updated
<-vm.txPoolStabilizedOk
return block, nil
@@ -462,7 +462,7 @@ func (vm *VM) ParseBlock(b []byte) (snowman.Block, error) {
return nil, errInvalidBlock
}
block := &Block{
- id: ids.NewID(blockHash),
+ id: ids.ID(blockHash),
ethBlock: ethBlock,
vm: vm,
}
@@ -484,7 +484,7 @@ func (vm *VM) GetBlock(id ids.ID) (snowman.Block, error) {
// SetPreference sets what the current tail of the chain is
func (vm *VM) SetPreference(blkID ids.ID) {
- err := vm.chain.SetTail(blkID.Key())
+ err := vm.chain.SetTail(common.Hash(blkID))
vm.ctx.Log.AssertNoError(err)
}
@@ -630,7 +630,7 @@ func (vm *VM) getCachedStatus(blockID ids.ID) choices.Status {
if acceptedID, err := ids.ToID(acceptedIDBytes); err != nil {
log.Error(fmt.Sprintf("snowman-eth: acceptedID bytes didn't match expected value: %s", err))
} else {
- if acceptedID.Equals(blockID) {
+ if acceptedID == blockID {
vm.blockStatusCache.Put(blockID, choices.Accepted)
return choices.Accepted
}
@@ -641,14 +641,14 @@ func (vm *VM) getCachedStatus(blockID ids.ID) choices.Status {
status := vm.getUncachedStatus(blk)
if status == choices.Accepted {
- err := vm.acceptedDB.Put(heightKey, blockID.Bytes())
+ err := vm.acceptedDB.Put(heightKey, blockID[:])
if err != nil {
log.Error(fmt.Sprintf("snowman-eth: failed to write back acceptedID bytes: %s", err))
}
tempBlock := wrappedBlk
for tempBlock.ethBlock != nil {
- parentID := ids.NewID(tempBlock.ethBlock.ParentHash())
+ parentID := ids.ID(tempBlock.ethBlock.ParentHash())
tempBlock = vm.getBlock(parentID)
if tempBlock == nil || tempBlock.ethBlock == nil {
break
@@ -660,7 +660,7 @@ func (vm *VM) getCachedStatus(blockID ids.ID) choices.Status {
break
}
- if err := vm.acceptedDB.Put(heightKey, parentID.Bytes()); err != nil {
+ if err := vm.acceptedDB.Put(heightKey, parentID[:]); err != nil {
log.Error(fmt.Sprintf("snowman-eth: failed to write back acceptedID bytes: %s", err))
}
}
@@ -681,7 +681,7 @@ func (vm *VM) getUncachedStatus(blk *types.Block) choices.Status {
highBlock, lowBlock = lowBlock, highBlock
}
for highBlock.Number().Cmp(lowBlock.Number()) > 0 {
- parentBlock := vm.getBlock(ids.NewID(highBlock.ParentHash()))
+ parentBlock := vm.getBlock(ids.ID(highBlock.ParentHash()))
if parentBlock == nil {
return choices.Processing
}
@@ -702,12 +702,12 @@ func (vm *VM) getBlock(id ids.ID) *Block {
if blockIntf, ok := vm.blockCache.Get(id); ok {
return blockIntf.(*Block)
}
- ethBlock := vm.chain.GetBlockByHash(id.Key())
+ ethBlock := vm.chain.GetBlockByHash(common.Hash(id))
if ethBlock == nil {
return nil
}
block := &Block{
- id: ids.NewID(ethBlock.Hash()),
+ id: ids.ID(ethBlock.Hash()),
ethBlock: ethBlock,
vm: vm,
}
@@ -898,10 +898,10 @@ func (vm *VM) GetSpendableFunds(keys []*crypto.PrivateKeySECP256K1R, assetID ids
}
addr := GetEthAddress(key)
var balance uint64
- if assetID.Equals(vm.ctx.AVAXAssetID) {
+ if assetID == vm.ctx.AVAXAssetID {
balance = new(big.Int).Div(state.GetBalance(addr), x2cRate).Uint64()
} else {
- balance = state.GetBalanceMultiCoin(addr, assetID.Key()).Uint64()
+ balance = state.GetBalanceMultiCoin(addr, common.Hash(assetID)).Uint64()
}
if balance == 0 {
continue