Skip to content

Commit

Permalink
Merge branch 'develop' into feat/upgrade4
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo authored Jul 2, 2024
2 parents e679052 + ab9c541 commit 0b32509
Show file tree
Hide file tree
Showing 286 changed files with 47 additions and 57,831 deletions.
138 changes: 0 additions & 138 deletions .github/workflows/contracts.yml

This file was deleted.

15 changes: 3 additions & 12 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
[submodule "l2geth"]
path = l2geth
url = [email protected]:scroll-tech/go-ethereum.git
[submodule "contracts/lib/ds-test"]
path = contracts/lib/ds-test
url = https://github.com/dapphub/ds-test
[submodule "contracts/lib/forge-std"]
path = contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "contracts/lib/solmate"]
path = contracts/lib/solmate
url = https://github.com/rari-capital/solmate
[submodule "scroll-contracts"]
path = scroll-contracts
url = https://github.com/scroll-tech/scroll-contracts.git
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ go test -v -race -covermode=atomic scroll-tech/database/...
go test -v -race -covermode=atomic scroll-tech/common/...
```

## Testing Contracts

You can find the unit tests in [`contracts/src/test/`](/contracts/src/test/), and integration tests in [`contracts/integration-test/`](/contracts/integration-test/).

See [`contracts`](/contracts) for more details on the contracts.

## License

Scroll Monorepo is licensed under the [MIT](./LICENSE) license.
1 change: 0 additions & 1 deletion bridge-history-api/internal/logic/l1_event_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ func (e *L1EventParser) ParseL1BatchEventLogs(ctx context.Context, logs []types.
l1BatchEvents = append(l1BatchEvents, &orm.BatchEvent{
BatchStatus: int(btypes.BatchStatusTypeFinalized),
BatchIndex: event.BatchIndex.Uint64(),
BatchHash: event.BatchHash.String(),
L1BlockNumber: vlog.BlockNumber,
})
}
Expand Down
30 changes: 25 additions & 5 deletions bridge-history-api/internal/orm/batch_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func (c *BatchEvent) GetFinalizedBatchesLEBlockHeight(ctx context.Context, block

// InsertOrUpdateBatchEvents inserts a new batch event or updates an existing one based on the BatchStatusType.
func (c *BatchEvent) InsertOrUpdateBatchEvents(ctx context.Context, l1BatchEvents []*BatchEvent) error {
var maxFinalizedBatchIndex uint64
var containsFinalizedEvent bool
var maxL1BlockNumber uint64
for _, l1BatchEvent := range l1BatchEvents {
db := c.db
db = db.WithContext(ctx)
Expand All @@ -89,11 +92,13 @@ func (c *BatchEvent) InsertOrUpdateBatchEvents(ctx context.Context, l1BatchEvent
return fmt.Errorf("failed to insert or ignore batch event, error: %w", err)
}
case btypes.BatchStatusTypeFinalized:
db = db.Where("batch_index = ?", l1BatchEvent.BatchIndex)
db = db.Where("batch_hash = ?", l1BatchEvent.BatchHash)
updateFields["batch_status"] = btypes.BatchStatusTypeFinalized
if err := db.Updates(updateFields).Error; err != nil {
return fmt.Errorf("failed to update batch event, error: %w", err)
containsFinalizedEvent = true
// get the maxFinalizedBatchIndex, which signals all the batch before it are all finalized
if l1BatchEvent.BatchIndex > maxFinalizedBatchIndex {
maxFinalizedBatchIndex = l1BatchEvent.BatchIndex
}
if l1BatchEvent.L1BlockNumber > maxL1BlockNumber {
maxL1BlockNumber = l1BatchEvent.L1BlockNumber
}
case btypes.BatchStatusTypeReverted:
db = db.Where("batch_index = ?", l1BatchEvent.BatchIndex)
Expand All @@ -108,6 +113,21 @@ func (c *BatchEvent) InsertOrUpdateBatchEvents(ctx context.Context, l1BatchEvent
}
}
}
if containsFinalizedEvent {
db := c.db
db = db.WithContext(ctx)
db = db.Model(&BatchEvent{})
updateFields := make(map[string]interface{})
// After darwin, FinalizeBatch event signals a range of batches are finalized,
// thus losing the batch hash info. Meanwhile, only batch_index is enough to update finalized batches.
db = db.Where("batch_index <= ?", maxFinalizedBatchIndex)
db = db.Where("batch_status != ?", btypes.BatchStatusTypeFinalized)
updateFields["batch_status"] = btypes.BatchStatusTypeFinalized
updateFields["l1_block_number"] = maxL1BlockNumber
if err := db.Updates(updateFields).Error; err != nil {
return fmt.Errorf("failed to update batch event, error: %w", err)
}
}
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion common/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"runtime/debug"
)

var tag = "v4.4.20"
var tag = "v4.4.23"

var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
Expand Down
12 changes: 0 additions & 12 deletions contracts/.env.example

This file was deleted.

4 changes: 0 additions & 4 deletions contracts/.eslintignore

This file was deleted.

24 changes: 0 additions & 24 deletions contracts/.eslintrc.js

This file was deleted.

17 changes: 0 additions & 17 deletions contracts/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions contracts/.husky/pre-commit

This file was deleted.

3 changes: 0 additions & 3 deletions contracts/.npmignore

This file was deleted.

1 change: 0 additions & 1 deletion contracts/.nvmrc

This file was deleted.

8 changes: 0 additions & 8 deletions contracts/.prettierignore

This file was deleted.

28 changes: 0 additions & 28 deletions contracts/.prettierrc

This file was deleted.

10 changes: 0 additions & 10 deletions contracts/.solcover.js

This file was deleted.

7 changes: 0 additions & 7 deletions contracts/.solhint.json

This file was deleted.

1 change: 0 additions & 1 deletion contracts/.solhintignore

This file was deleted.

Loading

0 comments on commit 0b32509

Please sign in to comment.