Skip to content

Commit

Permalink
fix batch index update
Browse files Browse the repository at this point in the history
colinlyguo committed Dec 7, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 5622f8f commit 59c8470
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bridge-history-api/conf/config.json
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
"USDCGatewayAddr": "0xf1AF3b23DE0A5Ca3CAb7261cb0061C0D779A5c7B",
"LIDOGatewayAddr": "0x6625C6332c9F91F2D27c304E729B86db87A3f504",
"DAIGatewayAddr": "0x67260A8B73C5B77B55c1805218A42A7A6F98F515",
"ScrollChainAddr": "0x1799c3Df650caB9DFBb228C971016707D8f8721D",
"ScrollChainAddr": "0xa13BAF47339d63B743e7Da8741db5456DAc1E556",
"GatewayRouterAddr": "0xF8B1378579659D8F7EE5f3C929c2f3E332E41Fd6",
"MessageQueueAddr": "0x0d7E906BD9cAFa154b048cFa766Cc1E54E39AF9B"
},
7 changes: 3 additions & 4 deletions bridge-history-api/internal/orm/batch_event.go
Original file line number Diff line number Diff line change
@@ -50,8 +50,8 @@ func (c *BatchEvent) GetBatchesGEBlockHeight(ctx context.Context, blockHeight ui
db := c.db.WithContext(ctx)
db = db.Model(&BatchEvent{})
db = db.Where("end_block_number >= ?", blockHeight)
db = db.Order("batch_index desc")
if err := db.First(&batches).Error; err != nil {
db = db.Order("batch_index asc")
if err := db.Find(&batches).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return nil, nil
}
@@ -80,8 +80,7 @@ func (c *BatchEvent) InsertOrUpdateBatchEvents(ctx context.Context, l1BatchEvent
db = dbTX[0]
}
db = db.WithContext(ctx)
db = db.Model(&CrossMessage{})
db = db.Model(BatchEvent{})
db = db.Model(&BatchEvent{})
updateFields := make(map[string]interface{})
switch BatchStatusType(l1BatchEvent.BatchStatus) {
case BatchStatusTypeCommitted:
4 changes: 2 additions & 2 deletions bridge-history-api/internal/orm/cross_message.go
Original file line number Diff line number Diff line change
@@ -284,8 +284,8 @@ func (c *CrossMessage) UpdateBatchStatusOfL2Withdrawals(ctx context.Context, sta
db := c.db.WithContext(ctx)
db = db.Model(&CrossMessage{})
db = db.Where("message_type = ?", MessageTypeL2SentMessage)
db = db.Where("l1_block_number >= ?", startBlockNumber)
db = db.Where("l1_block_number <= ?", endBlockNumber)
db = db.Where("l2_block_number >= ?", startBlockNumber)
db = db.Where("l2_block_number <= ?", endBlockNumber)
updateFields := make(map[string]interface{})
updateFields["batch_index"] = batchIndex
updateFields["rollup_status"] = RollupStatusTypeFinalized
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
create table batch_event
(
id BIGSERIAL PRIMARY KEY,
event_type SMALLINT NOT NULL,
batch_status SMALLINT NOT NULL,
batch_index BIGINT NOT NULL,
batch_hash VARCHAR NOT NULL,

0 comments on commit 59c8470

Please sign in to comment.