diff options
author | Determinant <[email protected]> | 2020-06-28 01:00:40 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2020-06-28 01:00:40 -0400 |
commit | 13ebd8bd9468e9d769d598b0ca2afb72ba78cb97 (patch) | |
tree | 69f5c9be8f9793f753b29ad7937d182692d1648d /plugin | |
parent | 110a55012a0cb29694157723535bbcf5142b671c (diff) |
use non-zero hash as the blackholev0.2.7-rc.4
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/evm/vm.go | 17 |
1 files changed, 9 insertions, 8 deletions
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, } |