From 7a2eb14b49686cd72434b6c9a083011306f2d034 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Fri, 11 Oct 2024 17:48:17 +0200 Subject: [PATCH] Plumbing to be able to start timeboost in nitro --- execution/gethexec/express_lane_service.go | 4 +++ execution/gethexec/sequencer.go | 41 ++++++++++++++++++---- timeboost/bidder_client.go | 4 +-- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/execution/gethexec/express_lane_service.go b/execution/gethexec/express_lane_service.go index d62c4176f4..5354b71bdb 100644 --- a/execution/gethexec/express_lane_service.go +++ b/execution/gethexec/express_lane_service.go @@ -187,6 +187,10 @@ func (es *expressLaneService) Start(ctxIn context.Context) { }) } +func (es *expressLaneService) StopAndWait() { + es.StopWaiter.StopAndWait() +} + func (es *expressLaneService) currentRoundHasController() bool { es.Lock() defer es.Unlock() diff --git a/execution/gethexec/sequencer.go b/execution/gethexec/sequencer.go index 60413f19c2..1a5325a1a0 100644 --- a/execution/gethexec/sequencer.go +++ b/execution/gethexec/sequencer.go @@ -85,15 +85,19 @@ type SequencerConfig struct { } type TimeboostConfig struct { - Enable bool `koanf:"enable"` - ExpressLaneAdvantage time.Duration `koanf:"express-lane-advantage"` - SequencerHTTPEndpoint string `koanf:"sequencer-http-endpoint"` + Enable bool `koanf:"enable"` + AuctionContractAddress string `koanf:"auction-contract-address"` + AuctioneerAddress string `koanf:"auctioneer-address"` + ExpressLaneAdvantage time.Duration `koanf:"express-lane-advantage"` + SequencerHTTPEndpoint string `koanf:"sequencer-http-endpoint"` } var DefaultTimeboostConfig = TimeboostConfig{ - Enable: false, - ExpressLaneAdvantage: time.Millisecond * 200, - SequencerHTTPEndpoint: "http://localhost:9567", + Enable: false, + AuctionContractAddress: "", + AuctioneerAddress: "", + ExpressLaneAdvantage: time.Millisecond * 200, + SequencerHTTPEndpoint: "http://localhost:8547", } func (c *SequencerConfig) Validate() error { @@ -122,6 +126,19 @@ func (c *SequencerConfig) Validate() error { if c.MaxTxDataSize > arbostypes.MaxL2MessageSize-50000 { return errors.New("max-tx-data-size too large for MaxL2MessageSize") } + return c.Timeboost.Validate() +} + +func (c *TimeboostConfig) Validate() error { + if !c.Enable { + return nil + } + if len(c.AuctionContractAddress) > 0 && !common.IsHexAddress(c.AuctionContractAddress) { + return fmt.Errorf("invalid timeboost.auction-contract-address \"%v\"", c.AuctionContractAddress) + } + if len(c.AuctioneerAddress) > 0 && !common.IsHexAddress(c.AuctioneerAddress) { + return fmt.Errorf("invalid timeboost.auctioneer-address \"%v\"", c.AuctioneerAddress) + } return nil } @@ -170,6 +187,8 @@ func SequencerConfigAddOptions(prefix string, f *flag.FlagSet) { func TimeboostAddOptions(prefix string, f *flag.FlagSet) { f.Bool(prefix+".enable", DefaultTimeboostConfig.Enable, "enable timeboost based on express lane auctions") + f.String(prefix+".auction-contract-address", DefaultTimeboostConfig.AuctionContractAddress, "Address of the proxy pointing to the ExpressLaneAuction contract") + f.String(prefix+".auctioneer-address", DefaultTimeboostConfig.AuctioneerAddress, "Address of the Timeboost Autonomous Auctioneer") f.Duration(prefix+".express-lane-advantage", DefaultTimeboostConfig.ExpressLaneAdvantage, "specify the express lane advantage") f.String(prefix+".sequencer-http-endpoint", DefaultTimeboostConfig.SequencerHTTPEndpoint, "this sequencer's http endpoint") } @@ -1215,6 +1234,13 @@ func (s *Sequencer) Start(ctxIn context.Context) error { return 0 }) + if config.Timeboost.Enable { + s.StartExpressLane( + ctxIn, + common.HexToAddress(config.Timeboost.AuctionContractAddress), + common.HexToAddress(config.Timeboost.AuctioneerAddress)) + } + return nil } @@ -1242,6 +1268,9 @@ func (s *Sequencer) StartExpressLane(ctx context.Context, auctionContractAddr co func (s *Sequencer) StopAndWait() { s.StopWaiter.StopAndWait() + if s.config().Timeboost.Enable { + s.expressLaneService.StopWaiter.StopAndWait() + } if s.txRetryQueue.Len() == 0 && len(s.txQueue) == 0 && s.nonceFailures.Len() == 0 { return } diff --git a/timeboost/bidder_client.go b/timeboost/bidder_client.go index 8ca126d961..c51e9fa52d 100644 --- a/timeboost/bidder_client.go +++ b/timeboost/bidder_client.go @@ -32,12 +32,12 @@ type BidderClientConfig struct { } var DefaultBidderClientConfig = BidderClientConfig{ - ArbitrumNodeEndpoint: "http://localhost:9567", + ArbitrumNodeEndpoint: "http://localhost:8547", BidValidatorEndpoint: "http://localhost:9372", } var TestBidderClientConfig = BidderClientConfig{ - ArbitrumNodeEndpoint: "http://localhost:9567", + ArbitrumNodeEndpoint: "http://localhost:8547", BidValidatorEndpoint: "http://localhost:9372", }