From dad5de297a87b9bbf21acf8bf215c760d7089865 Mon Sep 17 00:00:00 2001 From: Nodar Date: Tue, 27 Jun 2023 18:56:37 +0200 Subject: [PATCH 1/6] Add test for ArbitrumDepositTxType transaction types --- system_tests/retryable_test.go | 52 ++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/system_tests/retryable_test.go b/system_tests/retryable_test.go index 7b0c3a7563..751bea26f5 100644 --- a/system_tests/retryable_test.go +++ b/system_tests/retryable_test.go @@ -58,13 +58,14 @@ func retryableSetup(t *testing.T) ( } var submissionTxs []*types.Transaction for _, message := range messages { - if message.Message.Header.Kind != arbostypes.L1MessageType_SubmitRetryable { + k := message.Message.Header.Kind + if k != arbostypes.L1MessageType_SubmitRetryable && k != arbostypes.L1MessageType_EthDeposit { continue } txs, err := arbos.ParseL2Transactions(message.Message, params.ArbitrumDevTestChainConfig().ChainID, nil) Require(t, err) for _, tx := range txs { - if tx.Type() == types.ArbitrumSubmitRetryableTxType { + if tx.Type() == types.ArbitrumSubmitRetryableTxType || tx.Type() == types.ArbitrumDepositTxType { submissionTxs = append(submissionTxs, tx) } } @@ -385,6 +386,7 @@ func TestSubmissionGasCosts(t *testing.T) { colors.PrintRed("Off by ", arbmath.BigSub(expectedGasChange, diff)) Fatal(t, "Supplied gas was improperly deducted\n", fundsBeforeSubmit, "\n", fundsAfterSubmit) } + t.Errorf("anodar") } func waitForL1DelayBlocks(t *testing.T, ctx context.Context, l1client *ethclient.Client, l1info *BlockchainTestInfo) { @@ -395,3 +397,49 @@ func waitForL1DelayBlocks(t *testing.T, ctx context.Context, l1client *ethclient }) } } + +func TestDepositETH(t *testing.T) { + t.Parallel() + _, l1info, l2client, l1client, delayedInbox, lookupSubmitRetryableL2TxHash, ctx, teardown := retryableSetup(t) + defer teardown() + + faucetAddr := l1info.GetAddress("Faucet") + + oldBalance, err := l2client.BalanceAt(ctx, faucetAddr, nil) + if err != nil { + t.Fatalf("BalanceAt(%v) unexpected error: %v", faucetAddr, err) + } + + txOpts := l1info.GetDefaultTransactOpts("Faucet", ctx) + txOpts.Value = big.NewInt(13) + + l1tx, err := delayedInbox.DepositEth0(&txOpts) + if err != nil { + t.Fatalf("DepositEth0() unexected error: %v", err) + } + + l1Receipt, err := EnsureTxSucceeded(ctx, l1client, l1tx) + if err != nil { + t.Fatalf("EnsureTxSucceeded() unexpected error: %v", err) + } + if l1Receipt.Status != types.ReceiptStatusSuccessful { + t.Errorf("Got transaction status: %v, want: %v", l1Receipt.Status, types.ReceiptStatusSuccessful) + } + waitForL1DelayBlocks(t, ctx, l1client, l1info) + + txHash := lookupSubmitRetryableL2TxHash(l1Receipt) + l2Receipt, err := WaitForTx(ctx, l2client, txHash, time.Second*5) + if err != nil { + t.Fatalf("WaitForTx(%v) unexpected error: %v", txHash, err) + } + if l2Receipt.Status != types.ReceiptStatusSuccessful { + t.Errorf("Got transaction status: %v, want: %v", l2Receipt.Status, types.ReceiptStatusSuccessful) + } + newBalance, err := l2client.BalanceAt(ctx, faucetAddr, l2Receipt.BlockNumber) + if err != nil { + t.Fatalf("BalanceAt(%v) unexpected error: %v", faucetAddr, err) + } + if got := new(big.Int); got.Sub(newBalance, oldBalance).Cmp(txOpts.Value) != 0 { + t.Errorf("Got transferred: %v, want: %v", got, txOpts.Value) + } +} From fc287be3a428cd2eb233b236d82801476047d132 Mon Sep 17 00:00:00 2001 From: Nodar Date: Tue, 27 Jun 2023 18:57:25 +0200 Subject: [PATCH 2/6] remove remnant logging --- system_tests/retryable_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/system_tests/retryable_test.go b/system_tests/retryable_test.go index 751bea26f5..a0b5e9b741 100644 --- a/system_tests/retryable_test.go +++ b/system_tests/retryable_test.go @@ -386,7 +386,6 @@ func TestSubmissionGasCosts(t *testing.T) { colors.PrintRed("Off by ", arbmath.BigSub(expectedGasChange, diff)) Fatal(t, "Supplied gas was improperly deducted\n", fundsBeforeSubmit, "\n", fundsAfterSubmit) } - t.Errorf("anodar") } func waitForL1DelayBlocks(t *testing.T, ctx context.Context, l1client *ethclient.Client, l1info *BlockchainTestInfo) { From 73f3376f0e20297d83a5db04a4bc747a8e5a713b Mon Sep 17 00:00:00 2001 From: Nodar Date: Wed, 12 Jul 2023 16:50:36 +0200 Subject: [PATCH 3/6] merge master --- system_tests/retryable_test.go | 46 ---------------------------------- 1 file changed, 46 deletions(-) diff --git a/system_tests/retryable_test.go b/system_tests/retryable_test.go index f7e466f998..5e4bca1a64 100644 --- a/system_tests/retryable_test.go +++ b/system_tests/retryable_test.go @@ -516,49 +516,3 @@ func TestL1FundedUnsignedTransaction(t *testing.T) { t.Errorf("L2 transaction: %v has failed", receipt.TxHash) } } - -func TestDepositETH(t *testing.T) { - t.Parallel() - _, l1info, l2client, l1client, delayedInbox, lookupSubmitRetryableL2TxHash, ctx, teardown := retryableSetup(t) - defer teardown() - - faucetAddr := l1info.GetAddress("Faucet") - - oldBalance, err := l2client.BalanceAt(ctx, faucetAddr, nil) - if err != nil { - t.Fatalf("BalanceAt(%v) unexpected error: %v", faucetAddr, err) - } - - txOpts := l1info.GetDefaultTransactOpts("Faucet", ctx) - txOpts.Value = big.NewInt(13) - - l1tx, err := delayedInbox.DepositEth0(&txOpts) - if err != nil { - t.Fatalf("DepositEth0() unexected error: %v", err) - } - - l1Receipt, err := EnsureTxSucceeded(ctx, l1client, l1tx) - if err != nil { - t.Fatalf("EnsureTxSucceeded() unexpected error: %v", err) - } - if l1Receipt.Status != types.ReceiptStatusSuccessful { - t.Errorf("Got transaction status: %v, want: %v", l1Receipt.Status, types.ReceiptStatusSuccessful) - } - waitForL1DelayBlocks(t, ctx, l1client, l1info) - - txHash := lookupSubmitRetryableL2TxHash(l1Receipt) - l2Receipt, err := WaitForTx(ctx, l2client, txHash, time.Second*5) - if err != nil { - t.Fatalf("WaitForTx(%v) unexpected error: %v", txHash, err) - } - if l2Receipt.Status != types.ReceiptStatusSuccessful { - t.Errorf("Got transaction status: %v, want: %v", l2Receipt.Status, types.ReceiptStatusSuccessful) - } - newBalance, err := l2client.BalanceAt(ctx, faucetAddr, l2Receipt.BlockNumber) - if err != nil { - t.Fatalf("BalanceAt(%v) unexpected error: %v", faucetAddr, err) - } - if got := new(big.Int); got.Sub(newBalance, oldBalance).Cmp(txOpts.Value) != 0 { - t.Errorf("Got transferred: %v, want: %v", got, txOpts.Value) - } -} From b7fe1933031e52ec76ae76cdd58213995afccf32 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 12 Jul 2023 09:49:58 -0600 Subject: [PATCH 4/6] Fix an off-by-one when loading legacy validation info --- staker/block_validator.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/staker/block_validator.go b/staker/block_validator.go index 108ef5710c..0ff74a8014 100644 --- a/staker/block_validator.go +++ b/staker/block_validator.go @@ -984,9 +984,12 @@ func (v *BlockValidator) checkLegacyValid() error { log.Warn("legacy valid batch ahead of db", "current", batchCount, "required", requiredBatchCount) return nil } - msgCount, err := v.inboxTracker.GetBatchMessageCount(v.legacyValidInfo.AfterPosition.BatchNumber) - if err != nil { - return err + var msgCount arbutil.MessageIndex + if v.legacyValidInfo.AfterPosition.BatchNumber > 0 { + msgCount, err = v.inboxTracker.GetBatchMessageCount(v.legacyValidInfo.AfterPosition.BatchNumber - 1) + if err != nil { + return err + } } msgCount += arbutil.MessageIndex(v.legacyValidInfo.AfterPosition.PosInBatch) processedCount, err := v.streamer.GetProcessedMessageCount() From 8506b11a1402642c69f8cbb2412afe557038e46d Mon Sep 17 00:00:00 2001 From: Nodar Date: Thu, 13 Jul 2023 19:39:24 +0200 Subject: [PATCH 5/6] Document caviat in redis storage --- arbnode/dataposter/data_poster.go | 2 ++ arbnode/dataposter/redis/redisstorage.go | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/arbnode/dataposter/data_poster.go b/arbnode/dataposter/data_poster.go index e6668c8b39..1dec6ad0c4 100644 --- a/arbnode/dataposter/data_poster.go +++ b/arbnode/dataposter/data_poster.go @@ -42,6 +42,8 @@ type queuedTransaction[Meta any] struct { NextReplacement time.Time } +// Note: one of the implementation of this interface (Redis storage) does not +// support duplicate values. type QueueStorage[Item any] interface { GetContents(ctx context.Context, startingIndex uint64, maxResults uint64) ([]*Item, error) GetLast(ctx context.Context) (*Item, error) diff --git a/arbnode/dataposter/redis/redisstorage.go b/arbnode/dataposter/redis/redisstorage.go index 30370a0673..f7aed00e59 100644 --- a/arbnode/dataposter/redis/redisstorage.go +++ b/arbnode/dataposter/redis/redisstorage.go @@ -15,7 +15,10 @@ import ( "github.com/offchainlabs/nitro/util/signature" ) -// Storage requires that Item is RLP encodable/decodable +// Storage implements redis sorted set backed storage. It does not support +// duplicate keys or values. That is, putting the same element on different +// indexes will not yield expected behavior. +// More at: https://redis.io/commands/zadd/. type Storage[Item any] struct { client redis.UniversalClient signer *signature.SimpleHmac From dd4cdd721f12b8a4b4827d7f9a641867b4645a71 Mon Sep 17 00:00:00 2001 From: Tristan Wilson Date: Thu, 13 Jul 2023 12:11:59 -0700 Subject: [PATCH 6/6] das: Don't log l1SyncService l1 errs until >5 --- das/syncing_fallback_storage.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/das/syncing_fallback_storage.go b/das/syncing_fallback_storage.go index 8af39d7d3a..7c67dbec68 100644 --- a/das/syncing_fallback_storage.go +++ b/das/syncing_fallback_storage.go @@ -370,20 +370,25 @@ func (s *l1SyncService) readMore(ctx context.Context) error { func (s *l1SyncService) mainThread(ctx context.Context) { headerChan, unsubscribe := s.l1Reader.Subscribe(false) defer unsubscribe() + errCount := 0 for { err := s.readMore(ctx) if err != nil { if ctx.Err() != nil { return } - log.Error("error trying to sync from L1", "err", err) + errCount++ + if errCount > 5 { + log.Error("error trying to sync from L1", "err", err) + } select { case <-ctx.Done(): return - case <-time.After(s.config.DelayOnError): + case <-time.After(s.config.DelayOnError * time.Duration(errCount)): } continue } + errCount = 0 if s.catchingUp { // we're behind. Don't wait. continue