Unverified Commit 3a5aceed authored by Felföldi Zsolt's avatar Felföldi Zsolt Committed by GitHub

beacon/engine: move core/beacon to beacon/engine (#26616)

This PR moves core/beacon to beacon/engine so that beacon-chain related code has its own top level package which also can house the the beacon lightclient-code.
parent 8860b397
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License // You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package beacon package engine
import ( import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
......
// Code generated by github.com/fjl/gencodec. DO NOT EDIT. // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package beacon package engine
import ( import (
"encoding/json" "encoding/json"
......
// Code generated by github.com/fjl/gencodec. DO NOT EDIT. // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package beacon package engine
import ( import (
"encoding/json" "encoding/json"
......
// Code generated by github.com/fjl/gencodec. DO NOT EDIT. // Code generated by github.com/fjl/gencodec. DO NOT EDIT.
package beacon package engine
import ( import (
"encoding/json" "encoding/json"
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License // You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package beacon package engine
import ( import (
"fmt" "fmt"
......
This diff is collapsed.
This diff is collapsed.
...@@ -19,8 +19,8 @@ package catalyst ...@@ -19,8 +19,8 @@ package catalyst
import ( import (
"sync" "sync"
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/beacon"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/miner" "github.com/ethereum/go-ethereum/miner"
) )
...@@ -38,7 +38,7 @@ const maxTrackedHeaders = 10 ...@@ -38,7 +38,7 @@ const maxTrackedHeaders = 10
// payloadQueueItem represents an id->payload tuple to store until it's retrieved // payloadQueueItem represents an id->payload tuple to store until it's retrieved
// or evicted. // or evicted.
type payloadQueueItem struct { type payloadQueueItem struct {
id beacon.PayloadID id engine.PayloadID
payload *miner.Payload payload *miner.Payload
} }
...@@ -58,7 +58,7 @@ func newPayloadQueue() *payloadQueue { ...@@ -58,7 +58,7 @@ func newPayloadQueue() *payloadQueue {
} }
// put inserts a new payload into the queue at the given id. // put inserts a new payload into the queue at the given id.
func (q *payloadQueue) put(id beacon.PayloadID, payload *miner.Payload) { func (q *payloadQueue) put(id engine.PayloadID, payload *miner.Payload) {
q.lock.Lock() q.lock.Lock()
defer q.lock.Unlock() defer q.lock.Unlock()
...@@ -70,7 +70,7 @@ func (q *payloadQueue) put(id beacon.PayloadID, payload *miner.Payload) { ...@@ -70,7 +70,7 @@ func (q *payloadQueue) put(id beacon.PayloadID, payload *miner.Payload) {
} }
// get retrieves a previously stored payload item or nil if it does not exist. // get retrieves a previously stored payload item or nil if it does not exist.
func (q *payloadQueue) get(id beacon.PayloadID) *beacon.ExecutionPayloadEnvelope { func (q *payloadQueue) get(id engine.PayloadID) *engine.ExecutionPayloadEnvelope {
q.lock.RLock() q.lock.RLock()
defer q.lock.RUnlock() defer q.lock.RUnlock()
...@@ -86,7 +86,7 @@ func (q *payloadQueue) get(id beacon.PayloadID) *beacon.ExecutionPayloadEnvelope ...@@ -86,7 +86,7 @@ func (q *payloadQueue) get(id beacon.PayloadID) *beacon.ExecutionPayloadEnvelope
} }
// has checks if a particular payload is already tracked. // has checks if a particular payload is already tracked.
func (q *payloadQueue) has(id beacon.PayloadID) bool { func (q *payloadQueue) has(id engine.PayloadID) bool {
q.lock.RLock() q.lock.RLock()
defer q.lock.RUnlock() defer q.lock.RUnlock()
......
...@@ -21,9 +21,9 @@ import ( ...@@ -21,9 +21,9 @@ import (
"errors" "errors"
"fmt" "fmt"
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/beacon"
"github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/node"
...@@ -70,43 +70,43 @@ func NewConsensusAPI(les *les.LightEthereum) *ConsensusAPI { ...@@ -70,43 +70,43 @@ func NewConsensusAPI(les *les.LightEthereum) *ConsensusAPI {
// //
// If there are payloadAttributes: we return an error since block creation is not // If there are payloadAttributes: we return an error since block creation is not
// supported in les mode. // supported in les mode.
func (api *ConsensusAPI) ForkchoiceUpdatedV1(heads beacon.ForkchoiceStateV1, payloadAttributes *beacon.PayloadAttributes) (beacon.ForkChoiceResponse, error) { func (api *ConsensusAPI) ForkchoiceUpdatedV1(heads engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) {
if heads.HeadBlockHash == (common.Hash{}) { if heads.HeadBlockHash == (common.Hash{}) {
log.Warn("Forkchoice requested update to zero hash") log.Warn("Forkchoice requested update to zero hash")
return beacon.STATUS_INVALID, nil // TODO(karalabe): Why does someone send us this? return engine.STATUS_INVALID, nil // TODO(karalabe): Why does someone send us this?
} }
if err := api.checkTerminalTotalDifficulty(heads.HeadBlockHash); err != nil { if err := api.checkTerminalTotalDifficulty(heads.HeadBlockHash); err != nil {
if header := api.les.BlockChain().GetHeaderByHash(heads.HeadBlockHash); header == nil { if header := api.les.BlockChain().GetHeaderByHash(heads.HeadBlockHash); header == nil {
// TODO (MariusVanDerWijden) trigger sync // TODO (MariusVanDerWijden) trigger sync
return beacon.STATUS_SYNCING, nil return engine.STATUS_SYNCING, nil
} }
return beacon.STATUS_INVALID, err return engine.STATUS_INVALID, err
} }
// If the finalized block is set, check if it is in our blockchain // If the finalized block is set, check if it is in our blockchain
if heads.FinalizedBlockHash != (common.Hash{}) { if heads.FinalizedBlockHash != (common.Hash{}) {
if header := api.les.BlockChain().GetHeaderByHash(heads.FinalizedBlockHash); header == nil { if header := api.les.BlockChain().GetHeaderByHash(heads.FinalizedBlockHash); header == nil {
// TODO (MariusVanDerWijden) trigger sync // TODO (MariusVanDerWijden) trigger sync
return beacon.STATUS_SYNCING, nil return engine.STATUS_SYNCING, nil
} }
} }
// SetHead // SetHead
if err := api.setCanonical(heads.HeadBlockHash); err != nil { if err := api.setCanonical(heads.HeadBlockHash); err != nil {
return beacon.STATUS_INVALID, err return engine.STATUS_INVALID, err
} }
if payloadAttributes != nil { if payloadAttributes != nil {
return beacon.STATUS_INVALID, errors.New("not supported") return engine.STATUS_INVALID, errors.New("not supported")
} }
return api.validForkChoiceResponse(), nil return api.validForkChoiceResponse(), nil
} }
// GetPayloadV1 returns a cached payload by id. It's not supported in les mode. // GetPayloadV1 returns a cached payload by id. It's not supported in les mode.
func (api *ConsensusAPI) GetPayloadV1(payloadID beacon.PayloadID) (*beacon.ExecutableData, error) { func (api *ConsensusAPI) GetPayloadV1(payloadID engine.PayloadID) (*engine.ExecutableData, error) {
return nil, beacon.GenericServerError.With(errors.New("not supported in light client mode")) return nil, engine.GenericServerError.With(errors.New("not supported in light client mode"))
} }
// ExecutePayloadV1 creates an Eth1 block, inserts it in the chain, and returns the status of the chain. // ExecutePayloadV1 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
func (api *ConsensusAPI) ExecutePayloadV1(params beacon.ExecutableData) (beacon.PayloadStatusV1, error) { func (api *ConsensusAPI) ExecutePayloadV1(params engine.ExecutableData) (engine.PayloadStatusV1, error) {
block, err := beacon.ExecutableDataToBlock(params) block, err := engine.ExecutableDataToBlock(params)
if err != nil { if err != nil {
return api.invalid(), err return api.invalid(), err
} }
...@@ -118,7 +118,7 @@ func (api *ConsensusAPI) ExecutePayloadV1(params beacon.ExecutableData) (beacon. ...@@ -118,7 +118,7 @@ func (api *ConsensusAPI) ExecutePayloadV1(params beacon.ExecutableData) (beacon.
} }
*/ */
// TODO (MariusVanDerWijden) we should return nil here not empty hash // TODO (MariusVanDerWijden) we should return nil here not empty hash
return beacon.PayloadStatusV1{Status: beacon.SYNCING, LatestValidHash: nil}, nil return engine.PayloadStatusV1{Status: engine.SYNCING, LatestValidHash: nil}, nil
} }
parent := api.les.BlockChain().GetHeaderByHash(params.ParentHash) parent := api.les.BlockChain().GetHeaderByHash(params.ParentHash)
if parent == nil { if parent == nil {
...@@ -136,20 +136,20 @@ func (api *ConsensusAPI) ExecutePayloadV1(params beacon.ExecutableData) (beacon. ...@@ -136,20 +136,20 @@ func (api *ConsensusAPI) ExecutePayloadV1(params beacon.ExecutableData) (beacon.
merger.ReachTTD() merger.ReachTTD()
} }
hash := block.Hash() hash := block.Hash()
return beacon.PayloadStatusV1{Status: beacon.VALID, LatestValidHash: &hash}, nil return engine.PayloadStatusV1{Status: engine.VALID, LatestValidHash: &hash}, nil
} }
func (api *ConsensusAPI) validForkChoiceResponse() beacon.ForkChoiceResponse { func (api *ConsensusAPI) validForkChoiceResponse() engine.ForkChoiceResponse {
currentHash := api.les.BlockChain().CurrentHeader().Hash() currentHash := api.les.BlockChain().CurrentHeader().Hash()
return beacon.ForkChoiceResponse{ return engine.ForkChoiceResponse{
PayloadStatus: beacon.PayloadStatusV1{Status: beacon.VALID, LatestValidHash: &currentHash}, PayloadStatus: engine.PayloadStatusV1{Status: engine.VALID, LatestValidHash: &currentHash},
} }
} }
// invalid returns a response "INVALID" with the latest valid hash set to the current head. // invalid returns a response "INVALID" with the latest valid hash set to the current head.
func (api *ConsensusAPI) invalid() beacon.PayloadStatusV1 { func (api *ConsensusAPI) invalid() engine.PayloadStatusV1 {
currentHash := api.les.BlockChain().CurrentHeader().Hash() currentHash := api.les.BlockChain().CurrentHeader().Hash()
return beacon.PayloadStatusV1{Status: beacon.INVALID, LatestValidHash: &currentHash} return engine.PayloadStatusV1{Status: engine.INVALID, LatestValidHash: &currentHash}
} }
func (api *ConsensusAPI) checkTerminalTotalDifficulty(head common.Hash) error { func (api *ConsensusAPI) checkTerminalTotalDifficulty(head common.Hash) error {
...@@ -193,7 +193,7 @@ func (api *ConsensusAPI) setCanonical(newHead common.Hash) error { ...@@ -193,7 +193,7 @@ func (api *ConsensusAPI) setCanonical(newHead common.Hash) error {
// ExchangeTransitionConfigurationV1 checks the given configuration against // ExchangeTransitionConfigurationV1 checks the given configuration against
// the configuration of the node. // the configuration of the node.
func (api *ConsensusAPI) ExchangeTransitionConfigurationV1(config beacon.TransitionConfigurationV1) (*beacon.TransitionConfigurationV1, error) { func (api *ConsensusAPI) ExchangeTransitionConfigurationV1(config engine.TransitionConfigurationV1) (*engine.TransitionConfigurationV1, error) {
log.Trace("Engine API request received", "method", "ExchangeTransitionConfiguration", "ttd", config.TerminalTotalDifficulty) log.Trace("Engine API request received", "method", "ExchangeTransitionConfiguration", "ttd", config.TerminalTotalDifficulty)
if config.TerminalTotalDifficulty == nil { if config.TerminalTotalDifficulty == nil {
return nil, errors.New("invalid terminal total difficulty") return nil, errors.New("invalid terminal total difficulty")
...@@ -207,7 +207,7 @@ func (api *ConsensusAPI) ExchangeTransitionConfigurationV1(config beacon.Transit ...@@ -207,7 +207,7 @@ func (api *ConsensusAPI) ExchangeTransitionConfigurationV1(config beacon.Transit
if config.TerminalBlockHash != (common.Hash{}) { if config.TerminalBlockHash != (common.Hash{}) {
if hash := api.les.BlockChain().GetCanonicalHash(uint64(config.TerminalBlockNumber)); hash == config.TerminalBlockHash { if hash := api.les.BlockChain().GetCanonicalHash(uint64(config.TerminalBlockNumber)); hash == config.TerminalBlockHash {
return &beacon.TransitionConfigurationV1{ return &engine.TransitionConfigurationV1{
TerminalTotalDifficulty: (*hexutil.Big)(ttd), TerminalTotalDifficulty: (*hexutil.Big)(ttd),
TerminalBlockHash: config.TerminalBlockHash, TerminalBlockHash: config.TerminalBlockHash,
TerminalBlockNumber: config.TerminalBlockNumber, TerminalBlockNumber: config.TerminalBlockNumber,
...@@ -216,5 +216,5 @@ func (api *ConsensusAPI) ExchangeTransitionConfigurationV1(config beacon.Transit ...@@ -216,5 +216,5 @@ func (api *ConsensusAPI) ExchangeTransitionConfigurationV1(config beacon.Transit
return nil, fmt.Errorf("invalid terminal block hash") return nil, fmt.Errorf("invalid terminal block hash")
} }
return &beacon.TransitionConfigurationV1{TerminalTotalDifficulty: (*hexutil.Big)(ttd)}, nil return &engine.TransitionConfigurationV1{TerminalTotalDifficulty: (*hexutil.Big)(ttd)}, nil
} }
...@@ -20,10 +20,10 @@ import ( ...@@ -20,10 +20,10 @@ import (
"math/big" "math/big"
"testing" "testing"
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/beacon"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth/downloader" "github.com/ethereum/go-ethereum/eth/downloader"
...@@ -84,7 +84,7 @@ func TestSetHeadBeforeTotalDifficulty(t *testing.T) { ...@@ -84,7 +84,7 @@ func TestSetHeadBeforeTotalDifficulty(t *testing.T) {
defer n.Close() defer n.Close()
api := NewConsensusAPI(lesService) api := NewConsensusAPI(lesService)
fcState := beacon.ForkchoiceStateV1{ fcState := engine.ForkchoiceStateV1{
HeadBlockHash: blocks[5].Hash(), HeadBlockHash: blocks[5].Hash(),
SafeBlockHash: common.Hash{}, SafeBlockHash: common.Hash{},
FinalizedBlockHash: common.Hash{}, FinalizedBlockHash: common.Hash{},
...@@ -101,7 +101,7 @@ func TestExecutePayloadV1(t *testing.T) { ...@@ -101,7 +101,7 @@ func TestExecutePayloadV1(t *testing.T) {
defer n.Close() defer n.Close()
api := NewConsensusAPI(lesService) api := NewConsensusAPI(lesService)
fcState := beacon.ForkchoiceStateV1{ fcState := engine.ForkchoiceStateV1{
HeadBlockHash: postBlocks[0].Hash(), HeadBlockHash: postBlocks[0].Hash(),
SafeBlockHash: common.Hash{}, SafeBlockHash: common.Hash{},
FinalizedBlockHash: common.Hash{}, FinalizedBlockHash: common.Hash{},
...@@ -130,7 +130,7 @@ func TestExecutePayloadV1(t *testing.T) { ...@@ -130,7 +130,7 @@ func TestExecutePayloadV1(t *testing.T) {
BaseFee: block.BaseFee(), BaseFee: block.BaseFee(),
}, nil, nil, nil, trie.NewStackTrie(nil)) }, nil, nil, nil, trie.NewStackTrie(nil))
_, err := api.ExecutePayloadV1(beacon.ExecutableData{ _, err := api.ExecutePayloadV1(engine.ExecutableData{
ParentHash: fakeBlock.ParentHash(), ParentHash: fakeBlock.ParentHash(),
FeeRecipient: fakeBlock.Coinbase(), FeeRecipient: fakeBlock.Coinbase(),
StateRoot: fakeBlock.Root(), StateRoot: fakeBlock.Root(),
...@@ -153,7 +153,7 @@ func TestExecutePayloadV1(t *testing.T) { ...@@ -153,7 +153,7 @@ func TestExecutePayloadV1(t *testing.T) {
if headHeader.Number.Uint64() != fakeBlock.NumberU64()-1 { if headHeader.Number.Uint64() != fakeBlock.NumberU64()-1 {
t.Fatal("Unexpected chain head update") t.Fatal("Unexpected chain head update")
} }
fcState = beacon.ForkchoiceStateV1{ fcState = engine.ForkchoiceStateV1{
HeadBlockHash: fakeBlock.Hash(), HeadBlockHash: fakeBlock.Hash(),
SafeBlockHash: common.Hash{}, SafeBlockHash: common.Hash{},
FinalizedBlockHash: common.Hash{}, FinalizedBlockHash: common.Hash{},
......
...@@ -23,8 +23,8 @@ import ( ...@@ -23,8 +23,8 @@ import (
"sync" "sync"
"time" "time"
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/beacon"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
...@@ -42,14 +42,14 @@ type BuildPayloadArgs struct { ...@@ -42,14 +42,14 @@ type BuildPayloadArgs struct {
} }
// Id computes an 8-byte identifier by hashing the components of the payload arguments. // Id computes an 8-byte identifier by hashing the components of the payload arguments.
func (args *BuildPayloadArgs) Id() beacon.PayloadID { func (args *BuildPayloadArgs) Id() engine.PayloadID {
// Hash // Hash
hasher := sha256.New() hasher := sha256.New()
hasher.Write(args.Parent[:]) hasher.Write(args.Parent[:])
binary.Write(hasher, binary.BigEndian, args.Timestamp) binary.Write(hasher, binary.BigEndian, args.Timestamp)
hasher.Write(args.Random[:]) hasher.Write(args.Random[:])
hasher.Write(args.FeeRecipient[:]) hasher.Write(args.FeeRecipient[:])
var out beacon.PayloadID var out engine.PayloadID
copy(out[:], hasher.Sum(nil)[:8]) copy(out[:], hasher.Sum(nil)[:8])
return out return out
} }
...@@ -60,7 +60,7 @@ func (args *BuildPayloadArgs) Id() beacon.PayloadID { ...@@ -60,7 +60,7 @@ func (args *BuildPayloadArgs) Id() beacon.PayloadID {
// the revenue. Therefore, the empty-block here is always available and full-block // the revenue. Therefore, the empty-block here is always available and full-block
// will be set/updated afterwards. // will be set/updated afterwards.
type Payload struct { type Payload struct {
id beacon.PayloadID id engine.PayloadID
empty *types.Block empty *types.Block
full *types.Block full *types.Block
fullFees *big.Int fullFees *big.Int
...@@ -70,7 +70,7 @@ type Payload struct { ...@@ -70,7 +70,7 @@ type Payload struct {
} }
// newPayload initializes the payload object. // newPayload initializes the payload object.
func newPayload(empty *types.Block, id beacon.PayloadID) *Payload { func newPayload(empty *types.Block, id engine.PayloadID) *Payload {
payload := &Payload{ payload := &Payload{
id: id, id: id,
empty: empty, empty: empty,
...@@ -108,7 +108,7 @@ func (payload *Payload) update(block *types.Block, fees *big.Int, elapsed time.D ...@@ -108,7 +108,7 @@ func (payload *Payload) update(block *types.Block, fees *big.Int, elapsed time.D
// Resolve returns the latest built payload and also terminates the background // Resolve returns the latest built payload and also terminates the background
// thread for updating payload. It's safe to be called multiple times. // thread for updating payload. It's safe to be called multiple times.
func (payload *Payload) Resolve() *beacon.ExecutionPayloadEnvelope { func (payload *Payload) Resolve() *engine.ExecutionPayloadEnvelope {
payload.lock.Lock() payload.lock.Lock()
defer payload.lock.Unlock() defer payload.lock.Unlock()
...@@ -118,23 +118,23 @@ func (payload *Payload) Resolve() *beacon.ExecutionPayloadEnvelope { ...@@ -118,23 +118,23 @@ func (payload *Payload) Resolve() *beacon.ExecutionPayloadEnvelope {
close(payload.stop) close(payload.stop)
} }
if payload.full != nil { if payload.full != nil {
return beacon.BlockToExecutableData(payload.full, payload.fullFees) return engine.BlockToExecutableData(payload.full, payload.fullFees)
} }
return beacon.BlockToExecutableData(payload.empty, big.NewInt(0)) return engine.BlockToExecutableData(payload.empty, big.NewInt(0))
} }
// ResolveEmpty is basically identical to Resolve, but it expects empty block only. // ResolveEmpty is basically identical to Resolve, but it expects empty block only.
// It's only used in tests. // It's only used in tests.
func (payload *Payload) ResolveEmpty() *beacon.ExecutionPayloadEnvelope { func (payload *Payload) ResolveEmpty() *engine.ExecutionPayloadEnvelope {
payload.lock.Lock() payload.lock.Lock()
defer payload.lock.Unlock() defer payload.lock.Unlock()
return beacon.BlockToExecutableData(payload.empty, big.NewInt(0)) return engine.BlockToExecutableData(payload.empty, big.NewInt(0))
} }
// ResolveFull is basically identical to Resolve, but it expects full block only. // ResolveFull is basically identical to Resolve, but it expects full block only.
// It's only used in tests. // It's only used in tests.
func (payload *Payload) ResolveFull() *beacon.ExecutionPayloadEnvelope { func (payload *Payload) ResolveFull() *engine.ExecutionPayloadEnvelope {
payload.lock.Lock() payload.lock.Lock()
defer payload.lock.Unlock() defer payload.lock.Unlock()
...@@ -146,7 +146,7 @@ func (payload *Payload) ResolveFull() *beacon.ExecutionPayloadEnvelope { ...@@ -146,7 +146,7 @@ func (payload *Payload) ResolveFull() *beacon.ExecutionPayloadEnvelope {
} }
payload.cond.Wait() payload.cond.Wait()
} }
return beacon.BlockToExecutableData(payload.full, payload.fullFees) return engine.BlockToExecutableData(payload.full, payload.fullFees)
} }
// buildPayload builds the payload according to the provided parameters. // buildPayload builds the payload according to the provided parameters.
......
...@@ -21,9 +21,9 @@ import ( ...@@ -21,9 +21,9 @@ import (
"testing" "testing"
"time" "time"
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core/beacon"
"github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
) )
...@@ -47,7 +47,7 @@ func TestBuildPayload(t *testing.T) { ...@@ -47,7 +47,7 @@ func TestBuildPayload(t *testing.T) {
if err != nil { if err != nil {
t.Fatalf("Failed to build payload %v", err) t.Fatalf("Failed to build payload %v", err)
} }
verify := func(outer *beacon.ExecutionPayloadEnvelope, txs int) { verify := func(outer *engine.ExecutionPayloadEnvelope, txs int) {
payload := outer.ExecutionPayload payload := outer.ExecutionPayload
if payload.ParentHash != b.chain.CurrentBlock().Hash() { if payload.ParentHash != b.chain.CurrentBlock().Hash() {
t.Fatal("Unexpect parent hash") t.Fatal("Unexpect parent hash")
......
...@@ -27,11 +27,11 @@ import ( ...@@ -27,11 +27,11 @@ import (
"time" "time"
"github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/fdlimit" "github.com/ethereum/go-ethereum/common/fdlimit"
"github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/beacon"
"github.com/ethereum/go-ethereum/core/txpool" "github.com/ethereum/go-ethereum/core/txpool"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
...@@ -142,7 +142,7 @@ func newNode(typ nodetype, genesis *core.Genesis, enodes []*enode.Node) *ethNode ...@@ -142,7 +142,7 @@ func newNode(typ nodetype, genesis *core.Genesis, enodes []*enode.Node) *ethNode
} }
} }
func (n *ethNode) assembleBlock(parentHash common.Hash, parentTimestamp uint64) (*beacon.ExecutableData, error) { func (n *ethNode) assembleBlock(parentHash common.Hash, parentTimestamp uint64) (*engine.ExecutableData, error) {
if n.typ != eth2MiningNode { if n.typ != eth2MiningNode {
return nil, errors.New("invalid node type") return nil, errors.New("invalid node type")
} }
...@@ -150,12 +150,12 @@ func (n *ethNode) assembleBlock(parentHash common.Hash, parentTimestamp uint64) ...@@ -150,12 +150,12 @@ func (n *ethNode) assembleBlock(parentHash common.Hash, parentTimestamp uint64)
if timestamp <= parentTimestamp { if timestamp <= parentTimestamp {
timestamp = parentTimestamp + 1 timestamp = parentTimestamp + 1
} }
payloadAttribute := beacon.PayloadAttributes{ payloadAttribute := engine.PayloadAttributes{
Timestamp: timestamp, Timestamp: timestamp,
Random: common.Hash{}, Random: common.Hash{},
SuggestedFeeRecipient: common.HexToAddress("0xdeadbeef"), SuggestedFeeRecipient: common.HexToAddress("0xdeadbeef"),
} }
fcState := beacon.ForkchoiceStateV1{ fcState := engine.ForkchoiceStateV1{
HeadBlockHash: parentHash, HeadBlockHash: parentHash,
SafeBlockHash: common.Hash{}, SafeBlockHash: common.Hash{},
FinalizedBlockHash: common.Hash{}, FinalizedBlockHash: common.Hash{},
...@@ -168,7 +168,7 @@ func (n *ethNode) assembleBlock(parentHash common.Hash, parentTimestamp uint64) ...@@ -168,7 +168,7 @@ func (n *ethNode) assembleBlock(parentHash common.Hash, parentTimestamp uint64)
return n.api.GetPayloadV1(*payload.PayloadID) return n.api.GetPayloadV1(*payload.PayloadID)
} }
func (n *ethNode) insertBlock(eb beacon.ExecutableData) error { func (n *ethNode) insertBlock(eb engine.ExecutableData) error {
if !eth2types(n.typ) { if !eth2types(n.typ) {
return errors.New("invalid node type") return errors.New("invalid node type")
} }
...@@ -194,18 +194,18 @@ func (n *ethNode) insertBlock(eb beacon.ExecutableData) error { ...@@ -194,18 +194,18 @@ func (n *ethNode) insertBlock(eb beacon.ExecutableData) error {
} }
} }
func (n *ethNode) insertBlockAndSetHead(parent *types.Header, ed beacon.ExecutableData) error { func (n *ethNode) insertBlockAndSetHead(parent *types.Header, ed engine.ExecutableData) error {
if !eth2types(n.typ) { if !eth2types(n.typ) {
return errors.New("invalid node type") return errors.New("invalid node type")
} }
if err := n.insertBlock(ed); err != nil { if err := n.insertBlock(ed); err != nil {
return err return err
} }
block, err := beacon.ExecutableDataToBlock(ed) block, err := engine.ExecutableDataToBlock(ed)
if err != nil { if err != nil {
return err return err
} }
fcState := beacon.ForkchoiceStateV1{ fcState := engine.ForkchoiceStateV1{
HeadBlockHash: block.ParentHash(), HeadBlockHash: block.ParentHash(),
SafeBlockHash: common.Hash{}, SafeBlockHash: common.Hash{},
FinalizedBlockHash: common.Hash{}, FinalizedBlockHash: common.Hash{},
...@@ -319,7 +319,7 @@ func (mgr *nodeManager) run() { ...@@ -319,7 +319,7 @@ func (mgr *nodeManager) run() {
nodes = append(nodes, mgr.getNodes(eth2NormalNode)...) nodes = append(nodes, mgr.getNodes(eth2NormalNode)...)
//nodes = append(nodes, mgr.getNodes(eth2LightClient)...) //nodes = append(nodes, mgr.getNodes(eth2LightClient)...)
for _, node := range nodes { for _, node := range nodes {
fcState := beacon.ForkchoiceStateV1{ fcState := engine.ForkchoiceStateV1{
HeadBlockHash: parentBlock.Hash(), HeadBlockHash: parentBlock.Hash(),
SafeBlockHash: oldest.Hash(), SafeBlockHash: oldest.Hash(),
FinalizedBlockHash: oldest.Hash(), FinalizedBlockHash: oldest.Hash(),
...@@ -362,7 +362,7 @@ func (mgr *nodeManager) run() { ...@@ -362,7 +362,7 @@ func (mgr *nodeManager) run() {
log.Error("Failed to assemble the block", "err", err) log.Error("Failed to assemble the block", "err", err)
continue continue
} }
block, _ := beacon.ExecutableDataToBlock(*ed) block, _ := engine.ExecutableDataToBlock(*ed)
nodes := mgr.getNodes(eth2MiningNode) nodes := mgr.getNodes(eth2MiningNode)
nodes = append(nodes, mgr.getNodes(eth2NormalNode)...) nodes = append(nodes, mgr.getNodes(eth2NormalNode)...)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment