Skip to content

Commit ae9d641

Browse files
Merge branch 'master' into custom-da
2 parents 2f3388d + 1420803 commit ae9d641

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1277
-924
lines changed

arbnode/dataposter/data_poster.go

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -763,27 +763,6 @@ func (p *DataPoster) PostTransaction(ctx context.Context, dataCreatedAt time.Tim
763763
return p.postTransaction(ctx, lockedState, dataCreatedAt, nonce, meta, to, calldata, gasLimit, value, kzgBlobs, accessList)
764764
}
765765

766-
// shouldEnableCellProofs determines whether to use cell proofs based on the config and L1 state.
767-
// Returns true if cell proofs should be used, false otherwise.
768-
func (p *DataPoster) shouldEnableCellProofs(ctx context.Context) (bool, error) {
769-
config := p.config().EnableCellProofs
770-
771-
switch config {
772-
case "force-enable":
773-
return true, nil
774-
case "force-disable":
775-
return false, nil
776-
case "", "auto":
777-
// Auto-detect based on L1 Osaka fork activation
778-
if p.parentChain == nil {
779-
return false, fmt.Errorf("cannot auto-detect cell proof support: parent chain not configured")
780-
}
781-
return p.parentChain.SupportsCellProofs(ctx, nil)
782-
default:
783-
return false, fmt.Errorf("invalid enable-cell-proofs config value: %q (valid values: \"\", \"auto\", \"force-enable\", \"force-disable\")", config)
784-
}
785-
}
786-
787766
func (p *DataPoster) postTransaction(ctx context.Context, s *state.LockedInternalState, dataCreatedAt time.Time, nonce uint64, meta []byte, to common.Address, calldata []byte, gasLimit uint64, value *big.Int, kzgBlobs []kzg4844.Blob, accessList types.AccessList) (*types.Transaction, error) {
788767
if p.config().DisableNewTx {
789768
return nil, fmt.Errorf("posting new transaction is disabled")
@@ -832,11 +811,7 @@ func (p *DataPoster) postTransaction(ctx context.Context, s *state.LockedInterna
832811
if err != nil {
833812
return nil, fmt.Errorf("failed to compute KZG commitments: %w", err)
834813
}
835-
enableCellProofs, err := p.shouldEnableCellProofs(ctx)
836-
if err != nil {
837-
return nil, fmt.Errorf("failed to determine cell proof support: %w", err)
838-
}
839-
proofs, version, err := blobs.ComputeProofs(kzgBlobs, commitments, enableCellProofs)
814+
proofs, version, err := blobs.ComputeProofs(kzgBlobs, commitments)
840815
if err != nil {
841816
return nil, fmt.Errorf("failed to compute KZG proofs: %w", err)
842817
}
@@ -1314,7 +1289,6 @@ type DataPosterConfig struct {
13141289
MaxFeeBidMultipleBips arbmath.UBips `koanf:"max-fee-bid-multiple-bips" reload:"hot"`
13151290
NonceRbfSoftConfs uint64 `koanf:"nonce-rbf-soft-confs" reload:"hot"`
13161291
Post4844Blobs bool `koanf:"post-4844-blobs" reload:"hot"`
1317-
EnableCellProofs string `koanf:"enable-cell-proofs" reload:"hot"`
13181292
AllocateMempoolBalance bool `koanf:"allocate-mempool-balance" reload:"hot"`
13191293
UseDBStorage bool `koanf:"use-db-storage"`
13201294
UseNoOpStorage bool `koanf:"use-noop-storage"`
@@ -1373,12 +1347,6 @@ type DangerousConfig struct {
13731347

13741348
// Validate checks that the DataPosterConfig is valid.
13751349
func (c *DataPosterConfig) Validate() error {
1376-
switch c.EnableCellProofs {
1377-
case "", "auto", "force-enable", "force-disable":
1378-
// Valid values
1379-
default:
1380-
return fmt.Errorf("invalid enable-cell-proofs value %q (valid: \"\", \"auto\", \"force-enable\", \"force-disable\")", c.EnableCellProofs)
1381-
}
13821350
if len(c.ReplacementTimes) == 0 {
13831351
return fmt.Errorf("replacement-times must have at least one value")
13841352
}
@@ -1439,7 +1407,6 @@ func DataPosterConfigAddOptions(prefix string, f *pflag.FlagSet, defaultDataPost
14391407
f.DurationSlice(prefix+".blob-tx-replacement-times", defaultDataPosterConfig.BlobTxReplacementTimes, "comma-separated list of durations since first posting a blob transaction to attempt a replace-by-fee")
14401408
f.Float64(prefix+".min-blob-tx-tip-cap-gwei", defaultDataPosterConfig.MinBlobTxTipCapGwei, "the minimum tip cap to post EIP-4844 blob carrying transactions at")
14411409
f.Float64(prefix+".max-blob-tx-tip-cap-gwei", defaultDataPosterConfig.MaxBlobTxTipCapGwei, "the maximum tip cap to post EIP-4844 blob carrying transactions at")
1442-
f.String(prefix+".enable-cell-proofs", defaultDataPosterConfig.EnableCellProofs, "enable cell proofs in blob transactions for Fusaka compatibility. Valid values: \"\" or \"auto\" (auto-detect based on L1 Osaka fork), \"force-enable\", \"force-disable\"")
14431410
}
14441411

14451412
// We intentionally don't expose an option to configure Post4844Blobs.
@@ -1475,7 +1442,6 @@ var DefaultDataPosterConfig = DataPosterConfig{
14751442
MaxFeeBidMultipleBips: arbmath.OneInUBips * 10,
14761443
NonceRbfSoftConfs: 1,
14771444
Post4844Blobs: false,
1478-
EnableCellProofs: "", // empty string = auto-detect based on L1 Osaka fork
14791445
AllocateMempoolBalance: true,
14801446
UseDBStorage: true,
14811447
UseNoOpStorage: false,
@@ -1497,7 +1463,6 @@ var DefaultDataPosterConfigForValidator = func() DataPosterConfig {
14971463
config.BlobTxReplacementTimes = nil
14981464
config.MinBlobTxTipCapGwei = 0
14991465
config.MaxBlobTxTipCapGwei = 0
1500-
config.EnableCellProofs = ""
15011466
return config
15021467
}()
15031468

@@ -1517,7 +1482,6 @@ var TestDataPosterConfig = DataPosterConfig{
15171482
MaxFeeBidMultipleBips: arbmath.OneInUBips * 10,
15181483
NonceRbfSoftConfs: 1,
15191484
Post4844Blobs: false,
1520-
EnableCellProofs: "", // empty string = auto-detect based on L1 Osaka fork
15211485
AllocateMempoolBalance: true,
15221486
UseDBStorage: false,
15231487
UseNoOpStorage: false,

arbnode/delayed.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (m *DelayedInboxMessage) AfterInboxAcc() common.Hash {
155155
return crypto.Keccak256Hash(m.BeforeInboxAcc[:], hash)
156156
}
157157

158-
func (b *DelayedBridge) LookupMessagesInRange(ctx context.Context, from, to *big.Int, batchFetcher arbostypes.FallibleBatchFetcher) ([]*DelayedInboxMessage, error) {
158+
func (b *DelayedBridge) LookupMessagesInRange(ctx context.Context, from, to *big.Int, batchFetcher arbostypes.FallibleBatchFetcherWithParentBlock) ([]*DelayedInboxMessage, error) {
159159
query := ethereum.FilterQuery{
160160
BlockHash: nil,
161161
FromBlock: from,
@@ -184,7 +184,7 @@ func (l sortableMessageList) Less(i, j int) bool {
184184
return bytes.Compare(l[i].Message.Header.RequestId.Bytes(), l[j].Message.Header.RequestId.Bytes()) < 0
185185
}
186186

187-
func (b *DelayedBridge) logsToDeliveredMessages(ctx context.Context, logs []types.Log, batchFetcher arbostypes.FallibleBatchFetcher) ([]*DelayedInboxMessage, error) {
187+
func (b *DelayedBridge) logsToDeliveredMessages(ctx context.Context, logs []types.Log, batchFetcher arbostypes.FallibleBatchFetcherWithParentBlock) ([]*DelayedInboxMessage, error) {
188188
if len(logs) == 0 {
189189
return nil, nil
190190
}
@@ -258,7 +258,7 @@ func (b *DelayedBridge) logsToDeliveredMessages(ctx context.Context, logs []type
258258
},
259259
ParentChainBlockNumber: parsedLog.Raw.BlockNumber,
260260
}
261-
err := msg.Message.FillInBatchGasFields(batchFetcher)
261+
err := msg.Message.FillInBatchGasFieldsWithParentBlock(batchFetcher, msg.ParentChainBlockNumber)
262262
if err != nil {
263263
return nil, err
264264
}

arbnode/delayed_sequencer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func (d *DelayedSequencer) sequenceWithoutLockout(ctx context.Context, lastBlock
175175
}
176176
lastDelayedAcc = acc
177177
err = msg.FillInBatchGasFields(func(batchNum uint64) ([]byte, error) {
178-
data, _, err := d.reader.GetSequencerMessageBytes(ctx, batchNum)
178+
data, _, err := d.reader.GetSequencerMessageBytesForParentBlock(ctx, batchNum, parentChainBlockNumber)
179179
return data, err
180180
})
181181
if err != nil {

arbnode/inbox_reader.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,15 +473,16 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error {
473473
if err != nil {
474474
return err
475475
}
476-
delayedMessages, err := r.delayedBridge.LookupMessagesInRange(ctx, from, to, func(batchNum uint64) ([]byte, error) {
476+
delayedMessages, err := r.delayedBridge.LookupMessagesInRange(ctx, from, to, func(batchNum uint64, parentChainBlockNumber uint64) ([]byte, error) {
477477
if len(sequencerBatches) > 0 && batchNum >= sequencerBatches[0].SequenceNumber {
478478
idx := batchNum - sequencerBatches[0].SequenceNumber
479479
if idx < uint64(len(sequencerBatches)) {
480480
return sequencerBatches[idx].Serialize(ctx, r.l1Reader.Client())
481481
}
482482
log.Warn("missing mentioned batch in L1 message lookup", "batch", batchNum)
483483
}
484-
data, _, err := r.GetSequencerMessageBytes(ctx, batchNum)
484+
// Here we pass in the local parentChainBlockNumber as LookupMessagesInRange fetches parentChainBlockNumber from the logs
485+
data, _, err := r.GetSequencerMessageBytesForParentBlock(ctx, batchNum, parentChainBlockNumber)
485486
return data, err
486487
})
487488
if err != nil {
@@ -681,7 +682,11 @@ func (r *InboxReader) GetSequencerMessageBytes(ctx context.Context, seqNum uint6
681682
if err != nil {
682683
return nil, common.Hash{}, err
683684
}
684-
blockNum := arbmath.UintToBig(metadata.ParentChainBlock)
685+
return r.GetSequencerMessageBytesForParentBlock(ctx, seqNum, metadata.ParentChainBlock)
686+
}
687+
688+
func (r *InboxReader) GetSequencerMessageBytesForParentBlock(ctx context.Context, seqNum uint64, parentChainBlock uint64) ([]byte, common.Hash, error) {
689+
blockNum := arbmath.UintToBig(parentChainBlock)
685690
seqBatches, err := r.sequencerInbox.LookupBatchesInRange(ctx, blockNum, blockNum)
686691
if err != nil {
687692
return nil, common.Hash{}, err
@@ -694,7 +699,7 @@ func (r *InboxReader) GetSequencerMessageBytes(ctx context.Context, seqNum uint6
694699
}
695700
seenBatches = append(seenBatches, batch.SequenceNumber)
696701
}
697-
return nil, common.Hash{}, fmt.Errorf("sequencer batch %v not found in L1 block %v (found batches %v)", seqNum, metadata.ParentChainBlock, seenBatches)
702+
return nil, common.Hash{}, fmt.Errorf("sequencer batch %v not found in L1 block %v (found batches %v)", seqNum, parentChainBlock, seenBatches)
698703
}
699704

700705
func (r *InboxReader) GetLastReadBatchCount() uint64 {

arbnode/inbox_tracker.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,15 @@ func (t *InboxTracker) legacyGetDelayedMessageAndAccumulator(ctx context.Context
359359
}
360360

361361
func (t *InboxTracker) GetDelayedMessageAccumulatorAndParentChainBlockNumber(ctx context.Context, seqNum uint64) (*arbostypes.L1IncomingMessage, common.Hash, uint64, error) {
362-
msg, acc, blockNum, err := t.getRawDelayedMessageAccumulatorAndParentChainBlockNumber(ctx, seqNum)
362+
msg, acc, parentChainBlockNumber, err := t.getRawDelayedMessageAccumulatorAndParentChainBlockNumber(ctx, seqNum)
363363
if err != nil {
364-
return msg, acc, blockNum, err
364+
return msg, acc, parentChainBlockNumber, err
365365
}
366366
err = msg.FillInBatchGasFields(func(batchNum uint64) ([]byte, error) {
367-
data, _, err := t.txStreamer.inboxReader.GetSequencerMessageBytes(ctx, batchNum)
367+
data, _, err := t.txStreamer.inboxReader.GetSequencerMessageBytesForParentBlock(ctx, batchNum, parentChainBlockNumber)
368368
return data, err
369369
})
370-
return msg, acc, blockNum, err
370+
return msg, acc, parentChainBlockNumber, err
371371
}
372372

373373
// does not return message, so does not need to fill in batchGasFields

arbnode/maintenance.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func (mr *MaintenanceRunner) MaybeRunMaintenance(ctx context.Context) time.Durat
122122

123123
func (mr *MaintenanceRunner) waitMaintenanceToComplete(ctx context.Context) {
124124
ticker := time.NewTicker(1 * time.Second)
125+
defer ticker.Stop()
125126
for {
126127
select {
127128
case <-ctx.Done():

arbnode/parent/parent.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -110,27 +110,3 @@ func (p *ParentChain) BlobFeePerByte(ctx context.Context, h *types.Header) (*big
110110
}
111111
return eip4844.CalcBlobFee(pCfg, header), nil
112112
}
113-
114-
// SupportsCellProofs returns whether the parent chain has activated the Osaka fork
115-
// (Fusaka), which introduced cell proofs for blobs.
116-
// Passing in a nil header will use the time from the latest header.
117-
func (p *ParentChain) SupportsCellProofs(ctx context.Context, h *types.Header) (bool, error) {
118-
header := h
119-
if h == nil {
120-
lh, err := p.L1Reader.LastHeader(ctx)
121-
if err != nil {
122-
return false, err
123-
}
124-
header = lh
125-
}
126-
pCfg, err := p.chainConfig()
127-
if err != nil {
128-
return false, err
129-
}
130-
if pCfg.IsArbitrum() {
131-
// Arbitrum does not support blob transactions, so this should not have been called.
132-
return false, nil
133-
}
134-
// arbosVersion 0 because we're checking L1 (not L2 Arbitrum)
135-
return pCfg.IsOsaka(pCfg.LondonBlock, header.Time, 0), nil
136-
}

arbnode/transaction_streamer.go

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,37 @@ func (s *TransactionStreamer) GetMessage(msgIdx arbutil.MessageIndex) (*arbostyp
492492
return nil, err
493493
}
494494

495+
ctx, err := s.GetContextSafe()
496+
if err != nil {
497+
return nil, err
498+
}
499+
500+
var parentChainBlockNumber *uint64
501+
if message.DelayedMessagesRead != 0 && s.inboxReader != nil && s.inboxReader.tracker != nil {
502+
_, _, localParentChainBlockNumber, err := s.inboxReader.tracker.getRawDelayedMessageAccumulatorAndParentChainBlockNumber(ctx, message.DelayedMessagesRead-1)
503+
if err != nil {
504+
log.Warn("Failed to fetch parent chain block number for delayed message. Will fall back to BatchMetadata", "idx", message.DelayedMessagesRead-1)
505+
} else {
506+
parentChainBlockNumber = &localParentChainBlockNumber
507+
}
508+
}
509+
495510
err = message.Message.FillInBatchGasFields(func(batchNum uint64) ([]byte, error) {
496511
ctx, err := s.GetContextSafe()
497512
if err != nil {
498513
return nil, err
499514
}
500-
data, _, err := s.inboxReader.GetSequencerMessageBytes(ctx, batchNum)
515+
516+
var data []byte
517+
if parentChainBlockNumber != nil {
518+
data, _, err = s.inboxReader.GetSequencerMessageBytesForParentBlock(ctx, batchNum, *parentChainBlockNumber)
519+
} else {
520+
data, _, err = s.inboxReader.GetSequencerMessageBytes(ctx, batchNum)
521+
}
522+
if err != nil {
523+
return nil, err
524+
}
525+
501526
return data, err
502527
})
503528
if err != nil {

arbos/arbostypes/incomingmessage.go

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
"github.com/ethereum/go-ethereum/common"
1515
"github.com/ethereum/go-ethereum/crypto"
16+
"github.com/ethereum/go-ethereum/log"
1617
"github.com/ethereum/go-ethereum/params"
1718

1819
"github.com/offchainlabs/nitro/arbos/util"
@@ -176,6 +177,10 @@ func LegacyCostForStats(stats *BatchDataStats) uint64 {
176177
}
177178

178179
func (msg *L1IncomingMessage) FillInBatchGasFields(batchFetcher FallibleBatchFetcher) error {
180+
return msg.FillInBatchGasFieldsWithParentBlock(FromFallibleBatchFetcher(batchFetcher), msg.Header.BlockNumber)
181+
}
182+
183+
func (msg *L1IncomingMessage) FillInBatchGasFieldsWithParentBlock(batchFetcher FallibleBatchFetcherWithParentBlock, parentChainBlockNumber uint64) error {
179184
if batchFetcher == nil || msg.Header.Kind != L1MessageType_BatchPostingReport {
180185
return nil
181186
}
@@ -187,16 +192,21 @@ func (msg *L1IncomingMessage) FillInBatchGasFields(batchFetcher FallibleBatchFet
187192
if err != nil {
188193
return fmt.Errorf("failed to parse batch posting report: %w", err)
189194
}
190-
batchData, err := batchFetcher(batchNum)
195+
batchData, err := batchFetcher(batchNum, parentChainBlockNumber)
191196
if err != nil {
192-
return fmt.Errorf("failed to fetch batch mentioned by batch posting report: %w", err)
193-
}
194-
gotHash := crypto.Keccak256Hash(batchData)
195-
if gotHash != batchHash {
196-
return fmt.Errorf("batch fetcher returned incorrect data hash %v (wanted %v for batch %v)", gotHash, batchHash, batchNum)
197+
if msg.LegacyBatchGasCost == nil {
198+
return fmt.Errorf("failed to fetch batch mentioned by batch posting report: %w", err)
199+
}
200+
log.Warn("Failed reading batch data for filling message - leaving BatchDataStats empty")
201+
} else {
202+
gotHash := crypto.Keccak256Hash(batchData)
203+
if gotHash != batchHash {
204+
return fmt.Errorf("batch fetcher returned incorrect data hash %v (wanted %v for batch %v)", gotHash, batchHash, batchNum)
205+
}
206+
msg.BatchDataStats = GetDataStats(batchData)
197207
}
198-
msg.BatchDataStats = GetDataStats(batchData)
199208
}
209+
200210
legacyCost := LegacyCostForStats(msg.BatchDataStats)
201211
msg.LegacyBatchGasCost = &legacyCost
202212
return nil
@@ -271,8 +281,17 @@ func ParseIncomingL1Message(rd io.Reader, batchFetcher FallibleBatchFetcher) (*L
271281
return msg, nil
272282
}
273283

284+
type FallibleBatchFetcherWithParentBlock func(batchNum uint64, parentChainBlock uint64) ([]byte, error)
285+
274286
type FallibleBatchFetcher func(batchNum uint64) ([]byte, error)
275287

288+
// Wraps FallibleBatchFetcher into FallibleBatchFetcherWithParentBlock to ignore parentChainBlock
289+
func FromFallibleBatchFetcher(f FallibleBatchFetcher) FallibleBatchFetcherWithParentBlock {
290+
return func(batchNum uint64, _ uint64) ([]byte, error) {
291+
return f(batchNum)
292+
}
293+
}
294+
276295
type ParsedInitMessage struct {
277296
ChainId *big.Int
278297
InitialL1BaseFee *big.Int
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Copyright 2025, Offchain Labs, Inc.
22
// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md
33

4-
// The constraints package tracks the multi-dimensional gas usage to apply constraint-based pricing.
5-
package constraints
4+
package l2pricing
65

76
import "github.com/offchainlabs/nitro/arbos/storage"
87

0 commit comments

Comments
 (0)