@@ -36,9 +36,9 @@ import (
3636 "github.com/ethereum/go-ethereum/rpc"
3737 "github.com/ethereum/hive/hivesim"
3838 "github.com/ethereum/hive/simulators/ethereum/engine/client"
39- client_types "github.com/ethereum/hive/simulators/ethereum/engine/client/types"
4039 "github.com/ethereum/hive/simulators/ethereum/engine/globals"
4140 "github.com/ethereum/hive/simulators/ethereum/engine/helper"
41+ e_typ "github.com/ethereum/hive/simulators/ethereum/engine/types"
4242)
4343
4444type GethNodeTestConfiguration struct {
@@ -206,6 +206,8 @@ type GethNode struct {
206206 config GethNodeTestConfiguration
207207}
208208
209+ var _ client.EngineClient = (* GethNode )(nil )
210+
209211func newNode (config GethNodeTestConfiguration , bootnodes []string , genesis * core.Genesis ) (* GethNode , error ) {
210212 // Define the basic configurations for the Ethereum node
211213 datadir , _ := os .MkdirTemp ("" , "" )
@@ -234,14 +236,14 @@ func restart(startConfig GethNodeTestConfiguration, bootnodes []string, datadir
234236 return nil , err
235237 }
236238 econfig := & ethconfig.Config {
237- Genesis : genesis ,
238- NetworkId : genesis .Config .ChainID .Uint64 (),
239- SyncMode : downloader .FullSync ,
240- DatabaseCache : 256 ,
241- DatabaseHandles : 256 ,
242- TxPool : txpool .DefaultConfig ,
243- GPO : ethconfig .Defaults .GPO ,
244- Ethash : ethconfig .Defaults .Ethash ,
239+ Genesis : genesis ,
240+ NetworkId : genesis .Config .ChainID .Uint64 (),
241+ SyncMode : downloader .FullSync ,
242+ DatabaseCache : 256 ,
243+ DatabaseHandles : 256 ,
244+ TxPool : txpool .DefaultConfig ,
245+ GPO : ethconfig .Defaults .GPO ,
246+ // Ethash: ethconfig.Defaults.Ethash,
245247 Miner : ethconfig .Defaults .Miner ,
246248 LightServ : 100 ,
247249 LightPeers : int (startConfig .MaxPeers .Int64 ()) - 1 ,
@@ -288,18 +290,20 @@ func restart(startConfig GethNodeTestConfiguration, bootnodes []string, datadir
288290 }
289291
290292 g .running , g .closing = context .WithCancel (context .Background ())
291- if startConfig .PoWMiner || startConfig .Ethash {
292- // Create the ethash consensus module
293- ethashConfig := ethconfig .Defaults .Ethash
294- ethashConfig .PowMode = ethash .ModeNormal
295- ethashConfig .CacheDir = "/ethash"
296- ethashConfig .DatasetDir = ethashConfig .CacheDir
297- g .ethashEngine = ethash .New (ethashConfig , nil , false )
298- }
299- if startConfig .PoWMiner {
300- // Enable mining
301- go g .EnablePoWMining ()
302- }
293+ /*
294+ if startConfig.PoWMiner || startConfig.Ethash {
295+ // Create the ethash consensus module
296+ ethashConfig := ethconfig.Defaults.Ethash
297+ ethashConfig.PowMode = ethash.ModeNormal
298+ ethashConfig.CacheDir = "/ethash"
299+ ethashConfig.DatasetDir = ethashConfig.CacheDir
300+ g.ethashEngine = ethash.New(ethashConfig, nil, false)
301+ }
302+ if startConfig.PoWMiner {
303+ // Enable mining
304+ go g.EnablePoWMining()
305+ }
306+ */
303307
304308 // Start thread to monitor the amount of gossiped blocks this node receives
305309 go g .SubscribeP2PEvents ()
@@ -457,7 +461,7 @@ func (n *GethNode) PoWMiningLoop() {
457461 // Modify the sealed block if necessary
458462 if n .config .BlockModifier != nil {
459463 sealVerifier := func (h * types.Header ) bool {
460- return n .ethashEngine .VerifyHeader (n .eth .BlockChain (), h , true ) == nil
464+ return n .ethashEngine .VerifyHeader (n .eth .BlockChain (), h ) == nil
461465 }
462466 b , err = n .config .BlockModifier .ModifySealedBlock (sealVerifier , b )
463467 if err != nil {
@@ -616,7 +620,7 @@ func (v *validator) ValidateState(block *types.Block, state *state.StateDB, rece
616620
617621type processor struct {}
618622
619- func (p * processor ) Process (block * types.Block , excessDataGas * big. Int , statedb * state.StateDB , cfg vm.Config ) (types.Receipts , []* types.Log , uint64 , error ) {
623+ func (p * processor ) Process (block * types.Block , statedb * state.StateDB , cfg vm.Config ) (types.Receipts , []* types.Log , uint64 , error ) {
620624 return types.Receipts {}, []* types.Log {}, 21000 , nil
621625}
622626
@@ -656,7 +660,7 @@ func (n *GethNode) SetBlock(block *types.Block, parentNumber uint64, parentRoot
656660 }
657661 statedb .StartPrefetcher ("chain" )
658662 var failedProcessing bool
659- receipts , _ , _ , err := n .eth .BlockChain ().Processor ().Process (block , n . eth . BlockChain (). CurrentBlock (). ExcessDataGas , statedb , * n .eth .BlockChain ().GetVMConfig ())
663+ receipts , _ , _ , err := n .eth .BlockChain ().Processor ().Process (block , statedb , * n .eth .BlockChain ().GetVMConfig ())
660664 if err != nil {
661665 failedProcessing = true
662666 }
@@ -698,7 +702,7 @@ func (n *GethNode) SetBlock(block *types.Block, parentNumber uint64, parentRoot
698702func (n * GethNode ) NewPayload (ctx context.Context , version int , pl interface {}, vh []common.Hash ) (beacon.PayloadStatusV1 , error ) {
699703 switch version {
700704 case 1 :
701- if c , ok := pl .(* client_types .ExecutableDataV1 ); ok {
705+ if c , ok := pl .(* e_typ .ExecutableDataV1 ); ok {
702706 return n .NewPayloadV1 (ctx , c )
703707 } else {
704708 return beacon.PayloadStatusV1 {}, fmt .Errorf ("wrong type %T" , pl )
@@ -719,7 +723,7 @@ func (n *GethNode) NewPayload(ctx context.Context, version int, pl interface{},
719723 return beacon.PayloadStatusV1 {}, fmt .Errorf ("unknown version %d" , version )
720724}
721725
722- func (n * GethNode ) NewPayloadV1 (ctx context.Context , pl * client_types .ExecutableDataV1 ) (beacon.PayloadStatusV1 , error ) {
726+ func (n * GethNode ) NewPayloadV1 (ctx context.Context , pl * e_typ .ExecutableDataV1 ) (beacon.PayloadStatusV1 , error ) {
723727 ed := pl .ToExecutableData ()
724728 n .latestPayloadSent = & ed
725729 resp , err := n .api .NewPayloadV1 (ed )
@@ -783,23 +787,23 @@ func (n *GethNode) GetPayloadV2(ctx context.Context, payloadId *beacon.PayloadID
783787 return * p .ExecutionPayload , p .BlockValue , err
784788}
785789
786- func (n * GethNode ) GetPayloadV3 (ctx context.Context , payloadId * beacon.PayloadID ) (beacon.ExecutableData , * big.Int , * beacon .BlobsBundle , error ) {
790+ func (n * GethNode ) GetPayloadV3 (ctx context.Context , payloadId * beacon.PayloadID ) (beacon.ExecutableData , * big.Int , * e_typ .BlobsBundle , error ) {
787791 p , err := n .api .GetPayloadV3 (* payloadId )
788792 if p == nil || err != nil {
789793 return beacon.ExecutableData {}, nil , nil , err
790794 }
791- return * p .ExecutionPayload , p .BlockValue , p . BlobsBundle , err
795+ return * p .ExecutionPayload , p .BlockValue , nil , err
792796}
793797
794- func (n * GethNode ) GetPayloadBodiesByRangeV1 (ctx context.Context , start uint64 , count uint64 ) ([]* client_types .ExecutionPayloadBodyV1 , error ) {
798+ func (n * GethNode ) GetPayloadBodiesByRangeV1 (ctx context.Context , start uint64 , count uint64 ) ([]* e_typ .ExecutionPayloadBodyV1 , error ) {
795799 return nil , fmt .Errorf ("not implemented" )
796800}
797801
798- func (n * GethNode ) GetPayloadBodiesByHashV1 (ctx context.Context , hashes []common.Hash ) ([]* client_types .ExecutionPayloadBodyV1 , error ) {
802+ func (n * GethNode ) GetPayloadBodiesByHashV1 (ctx context.Context , hashes []common.Hash ) ([]* e_typ .ExecutionPayloadBodyV1 , error ) {
799803 return nil , fmt .Errorf ("not implemented" )
800804}
801805
802- func (n * GethNode ) GetBlobsBundleV1 (ctx context.Context , payloadId * beacon.PayloadID ) (* beacon .BlobsBundle , error ) {
806+ func (n * GethNode ) GetBlobsBundleV1 (ctx context.Context , payloadId * beacon.PayloadID ) (* e_typ .BlobsBundle , error ) {
803807 return nil , fmt .Errorf ("not implemented" )
804808}
805809
@@ -860,16 +864,24 @@ func (n *GethNode) HeaderByNumber(ctx context.Context, number *big.Int) (*types.
860864 return b .Header (), err
861865}
862866
863- func (n * GethNode ) SendTransaction (ctx context.Context , tx * types.Transaction ) error {
864- return n .eth .APIBackend .SendTx (ctx , tx )
867+ func (n * GethNode ) SendTransaction (ctx context.Context , tx e_typ.Transaction ) error {
868+ if v , ok := tx .(* types.Transaction ); ok {
869+ return n .eth .APIBackend .SendTx (ctx , v )
870+ }
871+ return fmt .Errorf ("invalid transaction type" )
865872}
866873
867- func (n * GethNode ) SendTransactions (ctx context.Context , txs [] * types .Transaction ) []error {
874+ func (n * GethNode ) SendTransactions (ctx context.Context , txs ... e_typ .Transaction ) []error {
868875 for _ , tx := range txs {
869- err := n .eth .APIBackend .SendTx (ctx , tx )
870- if err != nil {
871- return []error {err }
876+ if v , ok := tx .(* types.Transaction ); ok {
877+ err := n .eth .APIBackend .SendTx (ctx , v )
878+ if err != nil {
879+ return []error {err }
880+ }
881+ } else {
882+ return []error {fmt .Errorf ("invalid transaction type" )}
872883 }
884+
873885 }
874886 return nil
875887}
0 commit comments