Skip to content

Commit

Permalink
Merge branch 'master' into test-cases-contractTxType
Browse files Browse the repository at this point in the history
  • Loading branch information
anodar committed Jul 13, 2023
2 parents a1352f7 + c6b3434 commit b97d2c9
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ jobs:

- name: Set environment variables
run: |
mkdir -p target/tmp
echo "TMPDIR=$(pwd)/target/tmp" >> "$GITHUB_ENV"
mkdir -p target/tmp/deadbeefbee
echo "TMPDIR=$(pwd)/target/tmp/deadbeefbee" >> "$GITHUB_ENV"
echo "GOMEMLIMIT=6GiB" >> "$GITHUB_ENV"
echo "GOGC=80" >> "$GITHUB_ENV"
Expand Down
2 changes: 2 additions & 0 deletions arbnode/dataposter/leveldb/leveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func idxToKey(idx uint64) []byte {
func (s *Storage[Item]) GetContents(_ context.Context, startingIndex uint64, maxResults uint64) ([]*Item, error) {
var res []*Item
it := s.db.NewIterator([]byte(""), idxToKey(startingIndex))
defer it.Release()
for i := 0; i < int(maxResults); i++ {
if !it.Next() {
break
Expand Down Expand Up @@ -91,6 +92,7 @@ func (s *Storage[Item]) Prune(ctx context.Context, keepStartingAt uint64) error
}
end := idxToKey(keepStartingAt)
it := s.db.NewIterator([]byte{}, idxToKey(0))
defer it.Release()
b := s.db.NewBatch()
for it.Next() {
if bytes.Compare(it.Key(), end) >= 0 {
Expand Down
9 changes: 6 additions & 3 deletions staker/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
14 changes: 13 additions & 1 deletion system_tests/forwarder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"fmt"
"math/big"
"os"
"path/filepath"
"strings"
"sync"
Expand Down Expand Up @@ -157,7 +158,18 @@ func createSequencer(

// tmpPath returns file path with specified filename from temporary directory of the test.
func tmpPath(t *testing.T, filename string) string {
return filepath.Join(t.TempDir(), filename)
t.Helper()
// create a unique, maximum 10 characters-long temporary directory {name} with path as $TMPDIR/{name}
tmpDir, err := os.MkdirTemp("", "")
if err != nil {
t.Fatalf("Failed to create temp dir: %v", err)
}
t.Cleanup(func() {
if err = os.RemoveAll(tmpDir); err != nil {
t.Errorf("Failed to cleanup temp dir: %v", err)
}
})
return filepath.Join(tmpDir, filename)
}

// testNodes creates specified number of paths for ipc from temporary directory of the test.
Expand Down
51 changes: 49 additions & 2 deletions system_tests/retryable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,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)
}
}
Expand Down Expand Up @@ -398,6 +399,52 @@ 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)
}
}

func TestArbitrumContractTx(t *testing.T) {
ctx := context.Background()
l2Info, node, l2Client, l1Info, _, l1Client, l1Stack := createTestNodeOnL1(t, ctx, true)
Expand Down

0 comments on commit b97d2c9

Please sign in to comment.