aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <tederminant@gmail.com>2020-06-28 01:00:40 -0400
committerDeterminant <tederminant@gmail.com>2020-06-28 01:00:40 -0400
commit13ebd8bd9468e9d769d598b0ca2afb72ba78cb97 (patch)
tree69f5c9be8f9793f753b29ad7937d182692d1648d
parent110a55012a0cb29694157723535bbcf5142b671c (diff)
use non-zero hash as the blackholev0.2.7-rc.4
-rw-r--r--coreth.go6
-rw-r--r--plugin/evm/vm.go17
2 files changed, 12 insertions, 11 deletions
diff --git a/coreth.go b/coreth.go
index f7e89ef..b7e45af 100644
--- a/coreth.go
+++ b/coreth.go
@@ -23,8 +23,8 @@ import (
)
var (
- ZeroAddr = common.Address{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ BlackholeAddr = common.Address{
+ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}
)
@@ -66,7 +66,7 @@ func NewETHChain(config *eth.Config, nodecfg *node.Config, etherBase *common.Add
backend, _ := eth.New(&ctx, config, cb, mcb, bcb, chainDB)
chain := &ETHChain{backend: backend, cb: cb, mcb: mcb, bcb: bcb}
if etherBase == nil {
- etherBase = &ZeroAddr
+ etherBase = &BlackholeAddr
}
backend.SetEtherbase(*etherBase)
return chain
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go
index db1f5a9..4b16f71 100644
--- a/plugin/evm/vm.go
+++ b/plugin/evm/vm.go
@@ -39,11 +39,10 @@ import (
)
var (
- oldZeroAddr = common.Address{
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ zeroAddr = common.Address{
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}
- zeroAddr = coreth.ZeroAddr
)
const (
@@ -84,6 +83,7 @@ type VM struct {
chainID *big.Int
networkID uint64
+ genesisHash common.Hash
chain *coreth.ETHChain
chaindb Database
newBlockChan chan *Block
@@ -146,7 +146,7 @@ func (vm *VM) Initialize(
panic(err)
}
nodecfg := node.Config{NoUSB: true}
- chain := coreth.NewETHChain(&config, &nodecfg, &zeroAddr, vm.chaindb)
+ chain := coreth.NewETHChain(&config, &nodecfg, nil, vm.chaindb)
vm.chain = chain
vm.networkID = config.NetworkId
chain.SetOnHeaderNew(func(header *types.Header) {
@@ -245,6 +245,7 @@ func (vm *VM) Initialize(
ethBlock: lastAccepted,
vm: vm,
}
+ vm.genesisHash = chain.GetGenesisBlock().Hash()
vm.ctx.Log.Info(fmt.Sprintf("lastAccepted = %s", vm.lastAccepted.ethBlock.Hash().Hex()))
// TODO: shutdown this go routine
@@ -313,14 +314,14 @@ func (vm *VM) ParseBlock(b []byte) (snowman.Block, error) {
if err := rlp.DecodeBytes(b, ethBlock); err != nil {
return nil, err
}
+ blockHash := ethBlock.Hash()
// Coinbase must be zero on C-Chain
- coinbase := ethBlock.Coinbase()
- if bytes.Compare(coinbase.Bytes(), oldZeroAddr.Bytes()) != 0 &&
- bytes.Compare(coinbase.Bytes(), zeroAddr.Bytes()) != 0 {
+ if bytes.Compare(blockHash.Bytes(), vm.genesisHash.Bytes()) != 0 &&
+ bytes.Compare(ethBlock.Coinbase().Bytes(), coreth.BlackholeAddr.Bytes()) != 0 {
return nil, errInvalidBlock
}
block := &Block{
- id: ids.NewID(ethBlock.Hash()),
+ id: ids.NewID(blockHash),
ethBlock: ethBlock,
vm: vm,
}