aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDeterminant <tederminant@gmail.com>2020-06-27 22:46:31 -0400
committerDeterminant <tederminant@gmail.com>2020-06-27 22:46:31 -0400
commit1c68a9849d5f493ab62e18a125158f6288c1e363 (patch)
tree5215d77ab546bc55a85ecfec97191c0b61df2d65
parent07a9f9db09f7ade1be5a90197c46fde2e5245fea (diff)
check the coinbase in ParseBlockv0.2.7-rc.1v0.2.6
-rw-r--r--coreth.go12
-rw-r--r--plugin/evm/vm.go7
2 files changed, 14 insertions, 5 deletions
diff --git a/coreth.go b/coreth.go
index 06399b9..f0111d0 100644
--- a/coreth.go
+++ b/coreth.go
@@ -22,6 +22,13 @@ import (
"github.com/mattn/go-isatty"
)
+var (
+ ZeroAddr = common.Address{
+ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ }
+)
+
type Tx = types.Transaction
type Block = types.Block
type Hash = common.Hash
@@ -59,10 +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 = &common.Address{
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- }
+ etherBase = &ZeroAddr
}
backend.SetEtherbase(*etherBase)
return chain
diff --git a/plugin/evm/vm.go b/plugin/evm/vm.go
index 4fa2267..93e2fe2 100644
--- a/plugin/evm/vm.go
+++ b/plugin/evm/vm.go
@@ -25,6 +25,7 @@ import (
"github.com/ava-labs/go-ethereum/rlp"
"github.com/ava-labs/go-ethereum/rpc"
+ "github.com/ava-labs/gecko/api/admin"
"github.com/ava-labs/gecko/cache"
"github.com/ava-labs/gecko/database"
"github.com/ava-labs/gecko/ids"
@@ -32,7 +33,6 @@ import (
"github.com/ava-labs/gecko/snow/choices"
"github.com/ava-labs/gecko/snow/consensus/snowman"
"github.com/ava-labs/gecko/utils/timer"
- "github.com/ava-labs/gecko/api/admin"
commonEng "github.com/ava-labs/gecko/snow/engine/common"
)
@@ -59,6 +59,7 @@ var (
errUnknownBlock = errors.New("unknown block")
errBlockFrequency = errors.New("too frequent block issuance")
errUnsupportedFXs = errors.New("unsupported feature extensions")
+ errInvalidBlock = errors.New("invalid block")
)
func maxDuration(x, y time.Duration) time.Duration {
@@ -303,6 +304,10 @@ func (vm *VM) ParseBlock(b []byte) (snowman.Block, error) {
if err := rlp.DecodeBytes(b, ethBlock); err != nil {
return nil, err
}
+ // Coinbase must be zero on C-Chain
+ if bytes.Compare(ethBlock.Coinbase(), coreth.ZeroAddr) != 0 {
+ return nil, errInvalidBlock
+ }
block := &Block{
id: ids.NewID(ethBlock.Hash()),
ethBlock: ethBlock,