Skip to content

Commit

Permalink
Merge branch 'master' into fix-pending-validations-metric
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuacolvin0 authored Jul 10, 2024
2 parents 5e3bb7b + 50a4f1d commit 5963d7e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cmd/nitro/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func isLeveldbNotExistError(err error) bool {

func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeConfig, chainId *big.Int, cacheConfig *core.CacheConfig, persistentConfig *conf.PersistentConfig, l1Client arbutil.L1Interface, rollupAddrs chaininfo.RollupAddresses) (ethdb.Database, *core.BlockChain, error) {
if !config.Init.Force {
if readOnlyDb, err := stack.OpenDatabaseWithFreezerWithExtraOptions("l2chaindata", 0, 0, "", "l2chaindata/", true, persistentConfig.Pebble.ExtraOptions("l2chaindata")); err == nil {
if readOnlyDb, err := stack.OpenDatabaseWithFreezerWithExtraOptions("l2chaindata", 0, 0, config.Persistent.Ancient, "l2chaindata/", true, persistentConfig.Pebble.ExtraOptions("l2chaindata")); err == nil {
if chainConfig := gethexec.TryReadStoredChainConfig(readOnlyDb); chainConfig != nil {
readOnlyDb.Close()
if !arbmath.BigEquals(chainConfig.ChainID, chainId) {
Expand Down
22 changes: 8 additions & 14 deletions das/local_file_storage_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (s *LocalFileStorageService) Put(ctx context.Context, data []byte, expiry u
}
}

if !s.enableLegacyLayout && s.layout.expiryEnabled {
if !s.enableLegacyLayout {
if err := createHardLink(batchPath, s.layout.expiryPath(key, expiry)); err != nil {
return fmt.Errorf("couldn't create by-expiry-path index entry: %w", err)
}
Expand Down Expand Up @@ -360,11 +360,9 @@ func migrate(fl *flatLayout, tl *trieLayout) error {
return err
}

if tl.expiryEnabled {
expiryPath := tl.expiryPath(batch.key, uint64(batch.expiry.Unix()))
if err = createHardLink(newPath, expiryPath); err != nil {
return err
}
expiryPath := tl.expiryPath(batch.key, uint64(batch.expiry.Unix()))
if err = createHardLink(newPath, expiryPath); err != nil {
return err
}
migrated++
}
Expand Down Expand Up @@ -698,10 +696,8 @@ func (l *trieLayout) startMigration() error {
return err
}

if l.expiryEnabled {
if err := os.MkdirAll(filepath.Join(l.root, byExpiryTimestamp+migratingSuffix), 0o700); err != nil {
return err
}
if err := os.MkdirAll(filepath.Join(l.root, byExpiryTimestamp+migratingSuffix), 0o700); err != nil {
return err
}
return nil

Expand All @@ -726,10 +722,8 @@ func (l *trieLayout) commitMigration() error {
return err
}

if l.expiryEnabled {
if err := removeSuffix(byExpiryTimestamp); err != nil {
return err
}
if err := removeSuffix(byExpiryTimestamp); err != nil {
return err
}

syscall.Sync()
Expand Down
7 changes: 3 additions & 4 deletions das/local_file_storage_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ func TestMigrationNoExpiry(t *testing.T) {
countEntries(t, &s.layout, 4)
getByHashAndCheck(t, s, "a", "b", "c", "d")

_, err = s.layout.iterateBatchesByTimestamp(time.Unix(int64(now+10), 0))
if err == nil {
Fail(t, "can't iterate by timestamp when expiry is disabled")
}
// Can still iterate by timestamp even if expiry disabled
countTimestampEntries(t, &s.layout, time.Unix(int64(now+11), 0), 4)

}

func TestMigrationExpiry(t *testing.T) {
Expand Down

0 comments on commit 5963d7e

Please sign in to comment.