Skip to content

Commit

Permalink
Merge branch 'develop' into check-address-is-not-zero
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmountaintop authored Dec 11, 2023
2 parents ab972dd + 566fb23 commit f5bb4fd
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 22 deletions.
4 changes: 2 additions & 2 deletions bridge-history-api/abi/backend_abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var (
L2BatchWithdrawERC721Sig common.Hash
L2BatchWithdrawERC1155Sig common.Hash

// scroll mono repo
// scroll monorepo

// ScrollChainABI holds information about ScrollChain's context and available invokable methods.
ScrollChainABI *abi.ABI
Expand Down Expand Up @@ -323,7 +323,7 @@ type L1RelayedMessageEvent struct {
MessageHash common.Hash
}

// L2AppendMessageEvent represents a AppendMessage event raised by the L2MessageQueue contract.
// L2AppendMessageEvent represents an AppendMessage event raised by the L2MessageQueue contract.
type L2AppendMessageEvent struct {
Index *big.Int
MessageHash common.Hash
Expand Down
2 changes: 2 additions & 0 deletions bridge-history-api/utils/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ func InitDB(config *config.DBConfig) (*gorm.DB, error) {
return nil, pingErr
}

sqlDB.SetConnMaxLifetime(time.Minute * 10)
sqlDB.SetConnMaxIdleTime(time.Minute * 5)
sqlDB.SetMaxOpenConns(config.MaxOpenNum)
sqlDB.SetMaxIdleConns(config.MaxIdleNum)

Expand Down
2 changes: 1 addition & 1 deletion common/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var verbose bool

func init() {
v := os.Getenv("LOG_DOCKER")
if v == "true" || v == "TRUE" {
if strings.ToLower(v) == "true" {
verbose = true
}
}
Expand Down
3 changes: 3 additions & 0 deletions common/database/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ func InitDB(config *Config) (*gorm.DB, error) {
return nil, pingErr
}

sqlDB.SetConnMaxLifetime(time.Minute * 10)
sqlDB.SetConnMaxIdleTime(time.Minute * 5)

sqlDB.SetMaxOpenConns(config.MaxOpenNum)
sqlDB.SetMaxIdleConns(config.MaxIdleNum)

Expand Down
22 changes: 11 additions & 11 deletions common/libzkp/impl/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion common/libzkp/impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ halo2curves = { git = "https://github.com/scroll-tech/halo2curves.git", branch =

[dependencies]
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "develop" }
prover = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.9.7", default-features = false, features = ["parallel_syn", "scroll", "shanghai"] }
prover = { git = "https://github.com/scroll-tech/zkevm-circuits.git", tag = "v0.9.8", default-features = false, features = ["parallel_syn", "scroll", "shanghai", "strict-ccc"] }

base64 = "0.13.0"
env_logger = "0.9.0"
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.3.40"
var tag = "v4.3.43"

var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {
Expand Down
8 changes: 6 additions & 2 deletions prover/core/prover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ func TestFFI(t *testing.T) {
func readChunkTrace(filePat string, as *assert.Assertions) []*types.BlockTrace {
f, err := os.Open(filePat)
as.NoError(err)
defer as.NoError(f.Close())
defer func() {
as.NoError(f.Close())
}()
byt, err := io.ReadAll(f)
as.NoError(err)

Expand All @@ -105,7 +107,9 @@ func readChunkTrace(filePat string, as *assert.Assertions) []*types.BlockTrace {
func readVk(filePat string, as *assert.Assertions) string {
f, err := os.Open(filePat)
as.NoError(err)
defer as.NoError(f.Close())
defer func() {
as.NoError(f.Close())
}()
byt, err := io.ReadAll(f)
as.NoError(err)

Expand Down
30 changes: 27 additions & 3 deletions rollup/internal/controller/relayer/l2_relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"math/big"
"sort"
"sync"
"time"

Expand Down Expand Up @@ -488,7 +489,7 @@ func (r *Layer2Relayer) finalizeBatch(batch *orm.Batch, withProof bool) error {
// Check batch status before send `finalizeBatch` tx.
if r.cfg.ChainMonitor.Enabled {
var batchStatus bool
batchStatus, err := r.getBatchStatusByIndex(batch.Index)
batchStatus, err := r.getBatchStatusByIndex(batch)
if err != nil {
r.metrics.rollupL2ChainMonitorLatestFailedCall.Inc()
log.Warn("failed to get batch status, please check chain_monitor api server", "batch_index", batch.Index, "err", err)
Expand Down Expand Up @@ -602,9 +603,32 @@ type batchStatusResponse struct {
Data bool `json:"data"`
}

func (r *Layer2Relayer) getBatchStatusByIndex(batchIndex uint64) (bool, error) {
func (r *Layer2Relayer) getBatchStatusByIndex(batch *orm.Batch) (bool, error) {
chunks, getChunkErr := r.chunkOrm.GetChunksInRange(r.ctx, batch.StartChunkIndex, batch.EndChunkIndex)
if getChunkErr != nil {
log.Error("Layer2Relayer.getBatchStatusByIndex get chunks range failed", "startChunkIndex", batch.StartChunkIndex, "endChunkIndex", batch.EndChunkIndex, "err", getChunkErr)
return false, getChunkErr
}
if len(chunks) == 0 {
log.Error("Layer2Relayer.getBatchStatusByIndex get empty chunks", "startChunkIndex", batch.StartChunkIndex, "endChunkIndex", batch.EndChunkIndex)
return false, fmt.Errorf("startChunksIndex:%d endChunkIndex:%d get empty chunks", batch.StartChunkIndex, batch.EndChunkIndex)
}

sort.Slice(chunks, func(i, j int) bool {
return chunks[i].StartBlockNumber < chunks[j].StartBlockNumber
})

startBlockNum := chunks[0].StartBlockNumber
endBlockNum := chunks[len(chunks)-1].EndBlockNumber
var response batchStatusResponse
resp, err := r.chainMonitorClient.R().SetResult(&response).Get(fmt.Sprintf("%s/v1/batch_status?batch_index=%d", r.cfg.ChainMonitor.BaseURL, batchIndex))
resp, err := r.chainMonitorClient.R().
SetQueryParams(map[string]string{
"batch_index": fmt.Sprintf("%d", batch.Index),
"start_block_number": fmt.Sprintf("%d", startBlockNum),
"end_block_number": fmt.Sprintf("%d", endBlockNum),
}).
SetResult(&response).
Get(fmt.Sprintf("%s/v1/batch_status", r.cfg.ChainMonitor.BaseURL))
if err != nil {
return false, err
}
Expand Down
20 changes: 19 additions & 1 deletion rollup/internal/controller/relayer/l2_relayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,30 @@ func testGetBatchStatusByIndex(t *testing.T) {
db := setupL2RelayerDB(t)
defer database.CloseDB(db)

l2BlockOrm := orm.NewL2Block(db)
err := l2BlockOrm.InsertL2Blocks(context.Background(), []*types.WrappedBlock{wrappedBlock1, wrappedBlock2})
assert.NoError(t, err)
chunkOrm := orm.NewChunk(db)
dbChunk1, err := chunkOrm.InsertChunk(context.Background(), chunk1)
assert.NoError(t, err)
dbChunk2, err := chunkOrm.InsertChunk(context.Background(), chunk2)
assert.NoError(t, err)
batchMeta := &types.BatchMeta{
StartChunkIndex: 0,
StartChunkHash: dbChunk1.Hash,
EndChunkIndex: 1,
EndChunkHash: dbChunk2.Hash,
}
batchOrm := orm.NewBatch(db)
batch, err := batchOrm.InsertBatch(context.Background(), []*types.Chunk{chunk1, chunk2}, batchMeta)
assert.NoError(t, err)

cfg.L2Config.RelayerConfig.ChainMonitor.Enabled = true
relayer, err := NewLayer2Relayer(context.Background(), l2Cli, db, cfg.L2Config.RelayerConfig, false, nil)
assert.NoError(t, err)
assert.NotNil(t, relayer)

status, err := relayer.getBatchStatusByIndex(1)
status, err := relayer.getBatchStatusByIndex(batch)
assert.NoError(t, err)
assert.Equal(t, true, status)
}

0 comments on commit f5bb4fd

Please sign in to comment.