@@ -69,6 +69,7 @@ type Config struct {
6969 SlotTime * big.Int
7070 TerminalTotalDifficulty * big.Int
7171 SafeSlotsToImportOptimistically * big.Int
72+ ExtraShares * big.Int
7273
7374 // Node configurations to launch. Each node as a proportional share of
7475 // validators.
@@ -104,6 +105,7 @@ func (a *Config) join(b *Config) *Config {
104105 c .SlotTime = choose (a .SlotTime , b .SlotTime )
105106 c .TerminalTotalDifficulty = choose (a .TerminalTotalDifficulty , b .TerminalTotalDifficulty )
106107 c .SafeSlotsToImportOptimistically = choose (a .SafeSlotsToImportOptimistically , b .SafeSlotsToImportOptimistically )
108+ c .ExtraShares = choose (a .ExtraShares , b .ExtraShares )
107109
108110 // EL config
109111 c .InitialBaseFeePerGas = choose (a .InitialBaseFeePerGas , b .InitialBaseFeePerGas )
@@ -560,9 +562,46 @@ func forkchoiceResponseSpoof(method string, status PayloadStatusV1, payloadID *P
560562 }, nil
561563}
562564
565+ // List of Hashes that can be accessed concurrently
566+ type SyncHashes struct {
567+ Hashes []common.Hash
568+ Lock * sync.Mutex
569+ }
570+
571+ func NewSyncHashes (hashes ... common.Hash ) * SyncHashes {
572+ newSyncHashes := & SyncHashes {
573+ Hashes : make ([]common.Hash , 0 ),
574+ Lock : & sync.Mutex {},
575+ }
576+ for _ , h := range hashes {
577+ newSyncHashes .Hashes = append (newSyncHashes .Hashes , h )
578+ }
579+ return newSyncHashes
580+ }
581+
582+ func (syncHashes * SyncHashes ) Contains (hash common.Hash ) bool {
583+ syncHashes .Lock .Lock ()
584+ defer syncHashes .Lock .Unlock ()
585+ if syncHashes .Hashes == nil {
586+ return false
587+ }
588+ for _ , h := range syncHashes .Hashes {
589+ if h == hash {
590+ return true
591+ }
592+ }
593+ return false
594+ }
595+
596+ func (syncHashes * SyncHashes ) Add (hash common.Hash ) {
597+ syncHashes .Lock .Lock ()
598+ defer syncHashes .Lock .Unlock ()
599+ syncHashes .Hashes = append (syncHashes .Hashes , hash )
600+ }
601+
563602// Generate a callback that invalidates either a call to `engine_forkchoiceUpdatedV1` or `engine_newPayloadV1`
564- // if the hash of the payload matches the specified hash .
565- func InvalidateExecutionPayloadByHash (method string , payloadHash common.Hash , called chan <- interface {} ) func ([]byte , []byte ) * proxy.Spoof {
603+ // for all hashes with given exceptions, and a given LatestValidHash .
604+ func InvalidateExecutionPayloads (method string , exceptions * SyncHashes , latestValidHash * common.Hash , invalidated chan <- common. Hash ) func ([]byte , []byte ) * proxy.Spoof {
566605 if method == EngineForkchoiceUpdatedV1 {
567606 return func (res []byte , req []byte ) * proxy.Spoof {
568607 var (
@@ -575,18 +614,17 @@ func InvalidateExecutionPayloadByHash(method string, payloadHash common.Hash, ca
575614 if err != nil {
576615 panic (err )
577616 }
578- if fcState .HeadBlockHash == payloadHash {
579- zeroHash := common.Hash {}
617+ if ! exceptions .Contains (fcState .HeadBlockHash ) {
580618 spoof , err = forkchoiceResponseSpoof (EngineForkchoiceUpdatedV1 , PayloadStatusV1 {
581619 Status : Invalid ,
582- LatestValidHash : & zeroHash ,
620+ LatestValidHash : latestValidHash ,
583621 ValidationError : nil ,
584622 }, nil )
585623 if err != nil {
586624 panic (err )
587625 }
588626 select {
589- case called <- fcState :
627+ case invalidated <- fcState . HeadBlockHash :
590628 default :
591629 }
592630 return spoof
@@ -605,18 +643,17 @@ func InvalidateExecutionPayloadByHash(method string, payloadHash common.Hash, ca
605643 if err != nil {
606644 panic (err )
607645 }
608- if payload .BlockHash == payloadHash {
609- zeroHash := common.Hash {}
646+ if ! exceptions .Contains (payload .BlockHash ) {
610647 spoof , err = payloadStatusSpoof (EngineNewPayloadV1 , & PayloadStatusV1 {
611648 Status : Invalid ,
612- LatestValidHash : & zeroHash ,
649+ LatestValidHash : latestValidHash ,
613650 ValidationError : nil ,
614651 })
615652 if err != nil {
616653 panic (err )
617654 }
618655 select {
619- case called <- payload :
656+ case invalidated <- payload . BlockHash :
620657 default :
621658 }
622659 return spoof
@@ -713,8 +750,9 @@ func SlotsUntilBellatrix(genesisTime beacon.Timestamp, spec *beacon.Spec) beacon
713750 if currentTimestamp >= bellatrixTime {
714751 return beacon .Slot (0 )
715752 }
716- fmt .Printf ("INFO: bellatrixTime:%d, currentTimestamp:%d\n " , bellatrixTime , currentTimestamp )
717- return beacon .Slot ((bellatrixTime - currentTimestamp )/ spec .SECONDS_PER_SLOT ) + 1
753+ s := beacon .Slot ((bellatrixTime - currentTimestamp )/ spec .SECONDS_PER_SLOT ) + 1
754+ fmt .Printf ("INFO: bellatrixTime:%d, currentTimestamp:%d, slots=%d\n " , bellatrixTime , currentTimestamp , s )
755+ return s
718756}
719757
720758func TimeUntilTerminalBlock (e * Eth1Node , c setup.Eth1Consensus , defaultTTD * big.Int , n node ) uint64 {
0 commit comments