Skip to content

Commit 213fee9

Browse files
authored
Clean flags (#335)
* Checkout submodules recursively * Remove unnecessary flags in tx-streamer and sequencer
1 parent 9f75472 commit 213fee9

10 files changed

+71
-145
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- name: Checkout
5757
uses: actions/checkout@v4
5858
with:
59-
submodules: true
59+
submodules: recursive
6060

6161
- uses: cargo-bins/cargo-binstall@main
6262
- name: Make more disk space available on public runner

.github/workflows/espresso-e2e.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Checkout
2323
uses: actions/checkout@v4
2424
with:
25-
submodules: true
25+
submodules: recursive
2626

2727
- name: Install dependencies
2828
run: >

Dockerfile

-9
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,6 @@ RUN ./download-machine.sh consensus-v30 0xb0de9cb89e4d944ae6023a3b62276e54804c24
224224
RUN ./download-machine.sh consensus-v31 0x260f5fa5c3176a856893642e149cf128b5a8de9f828afec8d11184415dd8dc69
225225
RUN ./download-machine.sh consensus-v32 0x184884e1eb9fefdc158f6c8ac912bb183bf3cf83f0090317e0bc4ac5860baa39
226226

227-
#Download Espresso WASM machine
228-
COPY ./scripts/download-machine-espresso.sh .
229-
# To use a new wasm machine
230-
# 1. Create a release on github: for example YYYYMMDD-consensus
231-
# 2. Find the module module-root.txt in the release artifacts on
232-
# https://github.com/EspressoSystems/nitro-espresso-integration/releases
233-
# and add the corresponding download step below.
234-
# 3. Create a new release on github with the change: for example YYYYMMDD
235-
236227
FROM golang:1.21.10-bookworm AS node-builder
237228
WORKDIR /workspace
238229
ARG version=""

arbnode/batch_poster.go

+20-7
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,20 @@ type BatchPosterConfig struct {
180180
gasRefunder common.Address
181181
l1BlockBound l1BlockBound
182182
// Espresso specific flags
183-
LightClientAddress string `koanf:"light-client-address"`
184-
HotShotUrl string `koanf:"hotshot-url"`
185-
UserDataAttestationFile string `koanf:"user-data-attestation-file"`
186-
QuoteFile string `koanf:"quote-file"`
187-
UseEscapeHatch bool `koanf:"use-escape-hatch"`
183+
LightClientAddress string `koanf:"light-client-address"`
184+
HotShotUrl string `koanf:"hotshot-url"`
185+
UserDataAttestationFile string `koanf:"user-data-attestation-file"`
186+
QuoteFile string `koanf:"quote-file"`
187+
UseEscapeHatch bool `koanf:"use-escape-hatch"`
188+
EspressoTxnsPollingInterval time.Duration `koanf:"espresso-txns-polling-interval"`
189+
EspressoSwitchDelayThreshold uint64 `koanf:"espresso-switch-delay-threshold"`
188190
}
189191

190192
func (c *BatchPosterConfig) Validate() error {
193+
if (c.LightClientAddress == "") != (c.HotShotUrl == "") {
194+
return errors.New("light client address and hotshot URL must both be set together, or both left unset")
195+
196+
}
191197
if len(c.GasRefunderAddress) > 0 && !common.IsHexAddress(c.GasRefunderAddress) {
192198
return fmt.Errorf("invalid gas refunder address \"%v\"", c.GasRefunderAddress)
193199
}
@@ -240,6 +246,8 @@ func BatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) {
240246
f.String(prefix+".user-data-attestation-file", DefaultBatchPosterConfig.UserDataAttestationFile, "specifies the file containing the user data attestation")
241247
f.String(prefix+".quote-file", DefaultBatchPosterConfig.QuoteFile, "specifies the file containing the quote")
242248
f.Bool(prefix+".use-escape-hatch", DefaultBatchPosterConfig.UseEscapeHatch, "if true, batches will be posted without doing the espresso verification when hotshot is down. If false, wait for hotshot being up")
249+
f.Duration(prefix+".espresso-txns-polling-interval", DefaultBatchPosterConfig.EspressoTxnsPollingInterval, "interval between polling for transactions to be included in the block")
250+
f.Uint64(prefix+".espresso-switch-delay-threshold", DefaultBatchPosterConfig.EspressoSwitchDelayThreshold, "specifies the switch delay threshold used to determine hotshot liveness")
243251
redislock.AddConfigOptions(prefix+".redis-lock", f)
244252
dataposter.DataPosterConfigAddOptions(prefix+".data-poster", f, dataposter.DefaultDataPosterConfig)
245253
genericconf.WalletConfigAddOptions(prefix+".parent-chain-wallet", f, DefaultBatchPosterConfig.ParentChainWallet.Pathname)
@@ -274,6 +282,8 @@ var DefaultBatchPosterConfig = BatchPosterConfig{
274282
UserDataAttestationFile: "",
275283
QuoteFile: "",
276284
UseEscapeHatch: false,
285+
EspressoTxnsPollingInterval: time.Millisecond * 100,
286+
EspressoSwitchDelayThreshold: 20,
277287
}
278288

279289
var DefaultBatchPosterL1WalletConfig = genericconf.WalletConfig{
@@ -306,6 +316,8 @@ var TestBatchPosterConfig = BatchPosterConfig{
306316
GasEstimateBaseFeeMultipleBips: arbmath.OneInUBips * 3 / 2,
307317
CheckBatchCorrectness: true,
308318
UseEscapeHatch: false,
319+
EspressoTxnsPollingInterval: time.Millisecond * 100,
320+
EspressoSwitchDelayThreshold: 10,
309321
}
310322

311323
type BatchPosterOpts struct {
@@ -367,10 +379,11 @@ func NewBatchPoster(ctx context.Context, opts *BatchPosterOpts) (*BatchPoster, e
367379
return nil, err
368380
}
369381
opts.Streamer.lightClientReader = lightClientReader
382+
opts.Streamer.UseEscapeHatch = opts.Config().UseEscapeHatch
383+
opts.Streamer.espressoTxnsPollingInterval = opts.Config().EspressoTxnsPollingInterval
384+
opts.Streamer.espressoSwitchDelayThreshold = opts.Config().EspressoSwitchDelayThreshold
370385
}
371386

372-
opts.Streamer.UseEscapeHatch = opts.Config().UseEscapeHatch
373-
374387
b := &BatchPoster{
375388
l1Reader: opts.L1Reader,
376389
inbox: opts.Inbox,

arbnode/transaction_streamer.go

+32-51
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@ type TransactionStreamer struct {
7777
broadcastServer *broadcaster.Broadcaster
7878
inboxReader *InboxReader
7979
delayedBridge *DelayedBridge
80-
espressoClient *espressoClient.Client
8180

82-
lightClientReader lightclient.LightClientReaderInterface
81+
// Espresso specific fields. These fields are set from batch poster
82+
espressoClient *espressoClient.Client
83+
lightClientReader lightclient.LightClientReaderInterface
84+
espressoTxnsPollingInterval time.Duration
85+
espressoSwitchDelayThreshold uint64
8386
// Public these fields for testing
8487
HotshotDown bool
8588
UseEscapeHatch bool
@@ -89,46 +92,26 @@ type TransactionStreamerConfig struct {
8992
MaxBroadcasterQueueSize int `koanf:"max-broadcaster-queue-size"`
9093
MaxReorgResequenceDepth int64 `koanf:"max-reorg-resequence-depth" reload:"hot"`
9194
ExecuteMessageLoopDelay time.Duration `koanf:"execute-message-loop-delay" reload:"hot"`
92-
93-
// Espresso specific fields
94-
SovereignSequencerEnabled bool `koanf:"sovereign-sequencer-enabled"`
95-
HotShotUrl string `koanf:"hotshot-url"`
96-
EspressoNamespace uint64 `koanf:"espresso-namespace"`
97-
EspressoTxnsPollingInterval time.Duration `koanf:"espresso-txns-polling-interval"`
98-
EspressoSwitchDelayThreshold uint64 `koanf:"espresso-switch-delay-threshold"`
9995
}
10096

10197
type TransactionStreamerConfigFetcher func() *TransactionStreamerConfig
10298

10399
var DefaultTransactionStreamerConfig = TransactionStreamerConfig{
104-
MaxBroadcasterQueueSize: 50_000,
105-
MaxReorgResequenceDepth: 1024,
106-
ExecuteMessageLoopDelay: time.Millisecond * 100,
107-
SovereignSequencerEnabled: false,
108-
HotShotUrl: "",
109-
EspressoTxnsPollingInterval: time.Millisecond * 100,
110-
EspressoSwitchDelayThreshold: 20,
100+
MaxBroadcasterQueueSize: 50_000,
101+
MaxReorgResequenceDepth: 1024,
102+
ExecuteMessageLoopDelay: time.Millisecond * 100,
111103
}
112104

113105
var TestTransactionStreamerConfig = TransactionStreamerConfig{
114-
MaxBroadcasterQueueSize: 10_000,
115-
MaxReorgResequenceDepth: 128 * 1024,
116-
ExecuteMessageLoopDelay: time.Millisecond,
117-
SovereignSequencerEnabled: false,
118-
HotShotUrl: "",
119-
EspressoTxnsPollingInterval: time.Millisecond * 100,
120-
EspressoSwitchDelayThreshold: 10,
106+
MaxBroadcasterQueueSize: 10_000,
107+
MaxReorgResequenceDepth: 128 * 1024,
108+
ExecuteMessageLoopDelay: time.Millisecond,
121109
}
122110

123111
func TransactionStreamerConfigAddOptions(prefix string, f *flag.FlagSet) {
124112
f.Int(prefix+".max-broadcaster-queue-size", DefaultTransactionStreamerConfig.MaxBroadcasterQueueSize, "maximum cache of pending broadcaster messages")
125113
f.Int64(prefix+".max-reorg-resequence-depth", DefaultTransactionStreamerConfig.MaxReorgResequenceDepth, "maximum number of messages to attempt to resequence on reorg (0 = never resequence, -1 = always resequence)")
126114
f.Duration(prefix+".execute-message-loop-delay", DefaultTransactionStreamerConfig.ExecuteMessageLoopDelay, "delay when polling calls to execute messages")
127-
f.Bool(prefix+".sovereign-sequencer-enabled", DefaultTransactionStreamerConfig.SovereignSequencerEnabled, "if true, transactions will be sent to espresso's sovereign sequencer to be notarized by espresso network")
128-
f.String(prefix+".hotshot-url", DefaultTransactionStreamerConfig.HotShotUrl, "url of the hotshot sequencer")
129-
f.Uint64(prefix+".espresso-namespace", DefaultTransactionStreamerConfig.EspressoNamespace, "espresso namespace that corresponds the L2 chain")
130-
f.Duration(prefix+".espresso-txns-polling-interval", DefaultTransactionStreamerConfig.EspressoTxnsPollingInterval, "interval between polling for transactions to be included in the block")
131-
f.Uint64(prefix+".espresso-switch-delay-threshold", DefaultTransactionStreamerConfig.EspressoSwitchDelayThreshold, "specifies the switch delay threshold used to determine hotshot liveness")
132115
}
133116

134117
func NewTransactionStreamer(
@@ -151,12 +134,6 @@ func NewTransactionStreamer(
151134
snapSyncConfig: snapSyncConfig,
152135
}
153136

154-
if config().SovereignSequencerEnabled {
155-
espressoClient := espressoClient.NewClient(config().HotShotUrl)
156-
streamer.espressoClient = espressoClient
157-
158-
}
159-
160137
err := streamer.cleanupInconsistentState()
161138
if err != nil {
162139
return nil, err
@@ -693,6 +670,10 @@ func (s *TransactionStreamer) AddFakeInitMessage() error {
693670
}})
694671
}
695672

673+
func (s *TransactionStreamer) isEspressoMode() bool {
674+
return s.lightClientReader != nil && s.espressoClient != nil
675+
}
676+
696677
// Used in redis tests
697678
func (s *TransactionStreamer) GetMessageCountSync(t *testing.T) (arbutil.MessageIndex, error) {
698679
s.insertionMutex.Lock()
@@ -1297,7 +1278,7 @@ func (s *TransactionStreamer) pollSubmittedTransactionForFinality(ctx context.Co
12971278
}
12981279

12991280
// Verify the namespace proof
1300-
resp, err := s.espressoClient.FetchTransactionsInBlock(ctx, height, s.config().EspressoNamespace)
1281+
resp, err := s.espressoClient.FetchTransactionsInBlock(ctx, height, s.chainConfig.ChainID.Uint64())
13011282
if err != nil {
13021283
log.Warn("failed to fetch the transactions in block, will retry", "err", err)
13031284
return false
@@ -1627,7 +1608,7 @@ func (s *TransactionStreamer) submitEspressoTransactions(ctx context.Context) ti
16271608

16281609
pendingTxnsPos, err := s.getEspressoPendingTxnsPos()
16291610
if err != nil {
1630-
return s.config().EspressoTxnsPollingInterval
1611+
return s.espressoTxnsPollingInterval
16311612
}
16321613

16331614
if len(pendingTxnsPos) > 0 {
@@ -1637,7 +1618,7 @@ func (s *TransactionStreamer) submitEspressoTransactions(ctx context.Context) ti
16371618
msg, err := s.GetMessage(pos)
16381619
if err != nil {
16391620
log.Error("failed to get espresso submitted pos", "err", err)
1640-
return s.config().EspressoTxnsPollingInterval
1621+
return s.espressoTxnsPollingInterval
16411622
}
16421623
if msg.Message != nil {
16431624
msgs = append(msgs, *msg.Message)
@@ -1646,20 +1627,20 @@ func (s *TransactionStreamer) submitEspressoTransactions(ctx context.Context) ti
16461627
payload, msgCnt := arbos.BuildHotShotPayload(&msgs)
16471628
if msgCnt == 0 {
16481629
log.Error("failed to build the hotshot transaction: a large message has exceeded the size limit")
1649-
return s.config().EspressoTxnsPollingInterval
1630+
return s.espressoTxnsPollingInterval
16501631
}
16511632

16521633
log.Info("submitting transaction to espresso using sovereign sequencer")
16531634

16541635
// Note: same key should not be used for two namespaces for this to work
16551636
hash, err := s.espressoClient.SubmitTransaction(ctx, espressoTypes.Transaction{
16561637
Payload: payload,
1657-
Namespace: s.config().EspressoNamespace,
1638+
Namespace: s.chainConfig.ChainID.Uint64(),
16581639
})
16591640

16601641
if err != nil {
16611642
log.Error("failed to submit transaction to espresso", "err", err)
1662-
return s.config().EspressoTxnsPollingInterval
1643+
return s.espressoTxnsPollingInterval
16631644
}
16641645

16651646
s.espressoTxnsStateInsertionMutex.Lock()
@@ -1670,32 +1651,32 @@ func (s *TransactionStreamer) submitEspressoTransactions(ctx context.Context) ti
16701651
err = s.setEspressoSubmittedPos(batch, submittedPos)
16711652
if err != nil {
16721653
log.Error("failed to set the submitted txn pos", "err", err)
1673-
return s.config().EspressoTxnsPollingInterval
1654+
return s.espressoTxnsPollingInterval
16741655
}
16751656
pendingTxnsPos = pendingTxnsPos[msgCnt:]
16761657
err = s.setEspressoPendingTxnsPos(batch, pendingTxnsPos)
16771658
if err != nil {
16781659
log.Error("failed to set the pending txns", "err", err)
1679-
return s.config().EspressoTxnsPollingInterval
1660+
return s.espressoTxnsPollingInterval
16801661
}
16811662
err = s.setEspressoSubmittedHash(batch, hash)
16821663
if err != nil {
16831664
log.Error("failed to set the submitted hash", "err", err)
1684-
return s.config().EspressoTxnsPollingInterval
1665+
return s.espressoTxnsPollingInterval
16851666
}
16861667

16871668
err = batch.Write()
16881669
if err != nil {
16891670
log.Error("failed to write to db", "err", err)
1690-
return s.config().EspressoTxnsPollingInterval
1671+
return s.espressoTxnsPollingInterval
16911672
}
16921673
}
16931674

1694-
return s.config().EspressoTxnsPollingInterval
1675+
return s.espressoTxnsPollingInterval
16951676
}
16961677

16971678
func (s *TransactionStreamer) toggleEscapeHatch(ctx context.Context) error {
1698-
live, err := s.lightClientReader.IsHotShotLive(s.config().EspressoSwitchDelayThreshold)
1679+
live, err := s.lightClientReader.IsHotShotLive(s.espressoSwitchDelayThreshold)
16991680
if err != nil {
17001681
return err
17011682
}
@@ -1738,7 +1719,7 @@ func (s *TransactionStreamer) toggleEscapeHatch(ctx context.Context) error {
17381719
}
17391720

17401721
l1Height := header.Header.GetL1Head()
1741-
hotshotLive, err := s.lightClientReader.IsHotShotLiveAtHeight(l1Height, s.config().EspressoSwitchDelayThreshold)
1722+
hotshotLive, err := s.lightClientReader.IsHotShotLiveAtHeight(l1Height, s.espressoSwitchDelayThreshold)
17421723
if err != nil {
17431724
return err
17441725
}
@@ -1790,7 +1771,7 @@ func (s *TransactionStreamer) toggleEscapeHatch(ctx context.Context) error {
17901771
}
17911772

17921773
func (s *TransactionStreamer) espressoSwitch(ctx context.Context, ignored struct{}) time.Duration {
1793-
retryRate := s.config().EspressoTxnsPollingInterval * 50
1774+
retryRate := s.espressoTxnsPollingInterval * 50
17941775
config, err := s.exec.GetArbOSConfigAtHeight(0) // Pass 0 to get the ArbOS config at current block height.
17951776
if err != nil {
17961777
log.Error("Error Obtaining ArbOS Config ", "err", err)
@@ -1802,7 +1783,7 @@ func (s *TransactionStreamer) espressoSwitch(ctx context.Context, ignored struct
18021783
}
18031784
// TODO: `SovereignSequencerEnabled` should be removed as it is only the sovereign sequencer
18041785
// will use this function.
1805-
if config.ArbitrumChainParams.EnableEspresso && s.config().SovereignSequencerEnabled {
1786+
if config.ArbitrumChainParams.EnableEspresso && s.isEspressoMode() {
18061787
err := s.toggleEscapeHatch(ctx)
18071788
if err != nil {
18081789
log.Error("error checking escape hatch", "err", err)
@@ -1813,14 +1794,14 @@ func (s *TransactionStreamer) espressoSwitch(ctx context.Context, ignored struct
18131794
return s.submitEspressoTransactions(ctx)
18141795
}
18151796

1816-
return s.config().EspressoTxnsPollingInterval
1797+
return s.espressoTxnsPollingInterval
18171798
} else {
18181799
return retryRate
18191800
}
18201801
}
18211802

18221803
func (s *TransactionStreamer) shouldSubmitEspressoTransaction() bool {
1823-
if !s.config().SovereignSequencerEnabled {
1804+
if !s.isEspressoMode() {
18241805
// Not using hotshot as finality layer
18251806
return false
18261807
}

execution/gethexec/espresso_finality_node.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (n *EspressoFinalityNode) createBlock(ctx context.Context) (returnValue boo
9696
}
9797

9898
hooks := arbos.NoopSequencingHooks()
99-
_, err = n.execEngine.SequenceTransactions(arbHeader, txes, hooks, false)
99+
_, err = n.execEngine.SequenceTransactions(arbHeader, txes, hooks)
100100
if err != nil {
101101
log.Error("espresso finality node: failed to sequence transactions", "err", err)
102102
return false

execution/gethexec/executionengine.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ func (s *ExecutionEngine) sequencerWrapper(sequencerFunc func() (*types.Block, e
500500
}
501501
}
502502

503-
func (s *ExecutionEngine) SequenceTransactions(header *arbostypes.L1IncomingMessageHeader, txes types.Transactions, hooks *arbos.SequencingHooks, espressoSovereign bool) (*types.Block, error) {
503+
func (s *ExecutionEngine) SequenceTransactions(header *arbostypes.L1IncomingMessageHeader, txes types.Transactions, hooks *arbos.SequencingHooks) (*types.Block, error) {
504504
return s.sequencerWrapper(func() (*types.Block, error) {
505505
hooks.TxErrors = nil
506506
return s.sequenceTransactionsWithBlockMutex(header, txes, hooks)
@@ -510,7 +510,7 @@ func (s *ExecutionEngine) SequenceTransactions(header *arbostypes.L1IncomingMess
510510
// SequenceTransactionsWithProfiling runs SequenceTransactions with tracing and
511511
// CPU profiling enabled. If the block creation takes longer than 2 seconds, it
512512
// keeps both and prints out filenames in an error log line.
513-
func (s *ExecutionEngine) SequenceTransactionsWithProfiling(header *arbostypes.L1IncomingMessageHeader, txes types.Transactions, hooks *arbos.SequencingHooks, espressoSovereign bool) (*types.Block, error) {
513+
func (s *ExecutionEngine) SequenceTransactionsWithProfiling(header *arbostypes.L1IncomingMessageHeader, txes types.Transactions, hooks *arbos.SequencingHooks) (*types.Block, error) {
514514
pprofBuf, traceBuf := bytes.NewBuffer(nil), bytes.NewBuffer(nil)
515515
if err := pprof.StartCPUProfile(pprofBuf); err != nil {
516516
log.Error("Starting CPU profiling", "error", err)
@@ -519,7 +519,7 @@ func (s *ExecutionEngine) SequenceTransactionsWithProfiling(header *arbostypes.L
519519
log.Error("Starting tracing", "error", err)
520520
}
521521
start := time.Now()
522-
res, err := s.SequenceTransactions(header, txes, hooks, espressoSovereign)
522+
res, err := s.SequenceTransactions(header, txes, hooks)
523523
elapsed := time.Since(start)
524524
pprof.StopCPUProfile()
525525
trace.Stop()

0 commit comments

Comments
 (0)