Skip to content

Commit

Permalink
Merge tag 'v2.1.0-beta.12' into nitro_merge
Browse files Browse the repository at this point in the history
Arbitrum Nitro v2.1.0 Beta 12
  • Loading branch information
tsahee committed Aug 28, 2023
2 parents b5e83e1 + 8af8cbf commit 59ab57d
Show file tree
Hide file tree
Showing 36 changed files with 573 additions and 181 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ solgen/go/
target/
yarn-error.log
local/
testdata
system_tests/test-data/*
.configs/
system_tests/testdata/*
arbos/testdata/*
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ contracts/test/prover/proofs/%.json: $(arbitrator_cases)/%.wasm $(prover_bin)
# strategic rules to minimize dependency building

.make/lint: $(DEP_PREDICATE) build-node-deps $(ORDER_ONLY_PREDICATE) .make
go run linter/pointercheck/pointer.go ./...
golangci-lint run --fix
yarn --cwd contracts solhint
@touch $@
Expand Down
55 changes: 43 additions & 12 deletions arbnode/batch_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ type BatchPoster struct {
dataPoster *dataposter.DataPoster
redisLock *redislock.Simple
firstAccErr time.Time // first time a continuous missing accumulator occurred
backlog uint64 // An estimate of the number of unposted batches
// An estimate of the number of batches we want to post but haven't yet.
// This doesn't include batches which we don't want to post yet due to the L1 bounds.
backlog uint64
lastHitL1Bounds time.Time // The last time we wanted to post a message but hit the L1 bounds

batchReverted atomic.Bool // indicates whether data poster batch was reverted
}
Expand All @@ -96,8 +99,8 @@ type BatchPosterConfig struct {
MaxDelay time.Duration `koanf:"max-delay" reload:"hot"`
// Wait for max BatchPost delay.
WaitForMaxDelay bool `koanf:"wait-for-max-delay" reload:"hot"`
// Batch post polling delay.
PollDelay time.Duration `koanf:"poll-delay" reload:"hot"`
// Batch post polling interval.
PollInterval time.Duration `koanf:"poll-interval" reload:"hot"`
// Batch posting error delay.
ErrorDelay time.Duration `koanf:"error-delay" reload:"hot"`
CompressionLevel int `koanf:"compression-level" reload:"hot"`
Expand Down Expand Up @@ -147,7 +150,7 @@ func BatchPosterConfigAddOptions(prefix string, f *pflag.FlagSet) {
f.Int(prefix+".max-size", DefaultBatchPosterConfig.MaxSize, "maximum batch size")
f.Duration(prefix+".max-delay", DefaultBatchPosterConfig.MaxDelay, "maximum batch posting delay")
f.Bool(prefix+".wait-for-max-delay", DefaultBatchPosterConfig.WaitForMaxDelay, "wait for the max batch delay, even if the batch is full")
f.Duration(prefix+".poll-delay", DefaultBatchPosterConfig.PollDelay, "how long to delay after successfully posting batch")
f.Duration(prefix+".poll-interval", DefaultBatchPosterConfig.PollInterval, "how long to wait after no batches are ready to be posted before checking again")
f.Duration(prefix+".error-delay", DefaultBatchPosterConfig.ErrorDelay, "how long to delay after error posting batch")
f.Int(prefix+".compression-level", DefaultBatchPosterConfig.CompressionLevel, "batch compression level")
f.Duration(prefix+".das-retention-period", DefaultBatchPosterConfig.DASRetentionPeriod, "In AnyTrust mode, the period which DASes are requested to retain the stored batches.")
Expand All @@ -165,7 +168,7 @@ var DefaultBatchPosterConfig = BatchPosterConfig{
Enable: false,
DisableDasFallbackStoreDataOnChain: false,
MaxSize: 100000,
PollDelay: time.Second * 10,
PollInterval: time.Second * 10,
ErrorDelay: time.Second * 10,
MaxDelay: time.Hour,
WaitForMaxDelay: false,
Expand All @@ -190,7 +193,7 @@ var DefaultBatchPosterL1WalletConfig = genericconf.WalletConfig{
var TestBatchPosterConfig = BatchPosterConfig{
Enable: true,
MaxSize: 100000,
PollDelay: time.Millisecond * 10,
PollInterval: time.Millisecond * 10,
ErrorDelay: time.Millisecond * 10,
MaxDelay: 0,
WaitForMaxDelay: false,
Expand Down Expand Up @@ -256,6 +259,8 @@ func NewBatchPoster(dataPosterDB ethdb.Database, l1Reader *headerreader.HeaderRe

// checkRevert checks blocks with number in range [from, to] whether they
// contain reverted batch_poster transaction.
// It returns true if it finds batch posting needs to halt, which is true if a batch reverts
// unless the data poster is configured with noop storage which can tolerate reverts.
func (b *BatchPoster) checkReverts(ctx context.Context, from, to int64) (bool, error) {
if from > to {
return false, fmt.Errorf("wrong range, from: %d is more to: %d", from, to)
Expand All @@ -277,8 +282,13 @@ func (b *BatchPoster) checkReverts(ctx context.Context, from, to int64) (bool, e
return false, fmt.Errorf("getting a receipt for transaction: %v, %w", tx.Hash(), err)
}
if r.Status == types.ReceiptStatusFailed {
log.Error("Transaction from batch poster reverted", "nonce", tx.Nonce(), "txHash", tx.Hash(), "blockNumber", r.BlockNumber, "blockHash", r.BlockHash)
return true, nil
shouldHalt := !b.config().DataPoster.UseNoOpStorage
logLevel := log.Warn
if shouldHalt {
logLevel = log.Error
}
logLevel("Transaction from batch poster reverted", "nonce", tx.Nonce(), "txHash", tx.Hash(), "blockNumber", r.BlockNumber, "blockHash", r.BlockHash)
return shouldHalt, nil
}
}
}
Expand Down Expand Up @@ -803,6 +813,7 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
l1BoundMaxTimestamp = math.MaxUint64
}
if msg.Message.Header.BlockNumber > l1BoundMaxBlockNumber || msg.Message.Header.Timestamp > l1BoundMaxTimestamp {
b.lastHitL1Bounds = time.Now()
log.Info(
"not posting more messages because block number or timestamp exceed L1 bounds",
"blockNumber", msg.Message.Header.BlockNumber,
Expand Down Expand Up @@ -877,7 +888,8 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
if err != nil {
return false, err
}
if _, err := b.dataPoster.PostTransaction(ctx, firstMsgTime, nonce, newMeta, b.seqInboxAddr, data, gasLimit, new(big.Int)); err != nil {
tx, err := b.dataPoster.PostTransaction(ctx, firstMsgTime, nonce, newMeta, b.seqInboxAddr, data, gasLimit, new(big.Int))
if err != nil {
return false, err
}
log.Info(
Expand All @@ -889,24 +901,43 @@ func (b *BatchPoster) maybePostSequencerBatch(ctx context.Context) (bool, error)
"current delayed", b.building.segments.delayedMsg,
"total segments", len(b.building.segments.rawSegments),
)
recentlyHitL1Bounds := time.Since(b.lastHitL1Bounds) < config.PollInterval*3
postedMessages := b.building.msgCount - batchPosition.MessageCount
unpostedMessages := msgCount - b.building.msgCount
b.backlog = uint64(unpostedMessages) / uint64(postedMessages)
if b.backlog > 10 {
logLevel := log.Warn
if b.backlog > 30 {
if recentlyHitL1Bounds {
logLevel = log.Info
} else if b.backlog > 30 {
logLevel = log.Error
}
logLevel(
"a large batch posting backlog exists",
"recentlyHitL1Bounds", recentlyHitL1Bounds,
"currentPosition", b.building.msgCount,
"messageCount", msgCount,
"lastPostedMessages", postedMessages,
"unpostedMessages", unpostedMessages,
"batchBacklogEstimate", b.backlog,
)
}
if recentlyHitL1Bounds {
// This backlog isn't "real" in that we don't want to post any more messages.
// Setting the backlog to 0 here ensures that we don't lower compression as a result.
b.backlog = 0
}
b.building = nil

// If we aren't queueing up transactions, wait for the receipt before moving on to the next batch.
if config.DataPoster.UseNoOpStorage {
receipt, err := b.l1Reader.WaitForTxApproval(ctx, tx)
if err != nil {
return false, fmt.Errorf("error waiting for tx receipt: %w", err)
}
log.Info("Got successful receipt from batch poster transaction", "txHash", tx.Hash(), "blockNumber", receipt.BlockNumber, "blockHash", receipt.BlockHash)
}

return true, nil
}

Expand Down Expand Up @@ -935,7 +966,7 @@ func (b *BatchPoster) Start(ctxIn context.Context) {
}
if !b.redisLock.AttemptLock(ctx) {
b.building = nil
return b.config().PollDelay
return b.config().PollInterval
}
posted, err := b.maybePostSequencerBatch(ctx)
if err != nil {
Expand All @@ -958,7 +989,7 @@ func (b *BatchPoster) Start(ctxIn context.Context) {
} else if posted {
return 0
} else {
return b.config().PollDelay
return b.config().PollInterval
}
})
}
Expand Down
Loading

0 comments on commit 59ab57d

Please sign in to comment.