Compare commits

...

24 Commits

Author SHA1 Message Date
Nazarii Denha
d6f839e38e fix test 2023-02-01 14:05:50 +01:00
Nazarii Denha
2f802f4e8b Merge branch 'staging' of github.com:scroll-tech/scroll into fix/upgrade_blockheigth_type 2023-02-01 13:38:45 +01:00
Nazarii Denha
36be17f878 Merge branch 'staging' into fix/upgrade_blockheigth_type 2023-01-13 12:09:05 +01:00
Nazarii Denha
43364accf2 Merge branch 'staging' of github.com:scroll-tech/scroll into fix/upgrade_blockheigth_type 2023-01-11 14:11:34 +01:00
Nazarii Denha
c2e0b09eca Merge branch 'staging' of github.com:scroll-tech/scroll into fix/upgrade_blockheigth_type 2023-01-06 15:02:29 +01:00
Nazarii Denha
47e38dc16c Merge branch 'staging' of github.com:scroll-tech/scroll into fix/upgrade_blockheigth_type 2023-01-04 12:52:57 +01:00
Nazarii Denha
45c50ba296 fix 2022-12-20 14:28:51 +01:00
Nazarii Denha
ee3e1eb1a0 Merge branch 'staging' of github.com:scroll-tech/scroll into fix/upgrade_blockheigth_type 2022-12-20 14:26:53 +01:00
Nazarii Denha
d7d8fdc616 Merge branch 'staging' of github.com:scroll-tech/scroll into fix/upgrade_blockheigth_type 2022-12-12 14:37:11 +01:00
Nazarii Denha
65ac37377c little fixes 2022-12-12 14:37:03 +01:00
Nazarii Denha
bf23abc523 fix 2022-12-12 12:30:07 +01:00
Nazarii Denha
37fadbe6a6 Merge branch 'staging' of github.com:scroll-tech/scroll into fix/upgrade_blockheigth_type 2022-12-12 12:12:48 +01:00
Nazarii Denha
b2901620dc fix bigint and tests 2022-12-12 12:12:35 +01:00
maskpp
ecec756b58 fix(BigInt): Upgrade the struct and use of BigInt. (#154) 2022-12-12 10:14:18 +01:00
Nazarii Denha
b11ba7cdf1 fix test 2022-12-11 16:23:48 +01:00
Nazarii Denha
3476a9cb9a fix, use BIGINT in db, use big.Int and wrap it 2022-12-11 16:08:39 +01:00
Nazarii Denha
679d7520de Merge branch 'staging' of github.com:scroll-tech/scroll into fix/upgrade_blockheigth_type 2022-12-11 14:39:01 +01:00
Nazarii Denha
3cd8ee6f52 Merge branch 'staging' of github.com:scroll-tech/scroll into fix/upgrade_blockheigth_type 2022-12-07 12:48:21 +01:00
Nazarii Denha
f568544ac8 Merge branch 'staging' of github.com:scroll-tech/scroll into fix/upgrade_blockheigth_type 2022-12-01 15:23:06 +01:00
Nazarii Denha
6ced64ca8b pass lint 2022-11-29 14:44:51 +01:00
Nazarii Denha
1b46712007 Merge branch 'staging' of github.com:scroll-tech/scroll into fix/upgrade_blockheigth_type 2022-11-29 14:39:42 +01:00
Nazarii Denha
4c28aafd3b bigint type in database 2022-11-29 14:38:43 +01:00
Nazarii Denha
e87cb53aef Merge branch 'staging' of github.com:scroll-tech/scroll into fix/upgrade_blockheigth_type 2022-11-29 11:48:57 +01:00
Nazarii Denha
0cb297611c big.int type 2022-11-29 11:48:31 +01:00
17 changed files with 230 additions and 134 deletions

View File

@@ -1,6 +1,10 @@
package config
import "github.com/scroll-tech/go-ethereum/common"
import (
"math/big"
"github.com/scroll-tech/go-ethereum/common"
)
// L1Config loads l1eth configuration items.
type L1Config struct {
@@ -9,7 +13,7 @@ type L1Config struct {
// l1 eth node url.
Endpoint string `json:"endpoint"`
// The start height to sync event from layer 1
StartHeight uint64 `json:"start_height"`
StartHeight *big.Int `json:"start_height"`
// The messenger contract address deployed on layer 1 chain.
L1MessengerAddress common.Address `json:"l1_messenger_address"`
// The rollup contract address deployed on layer 1 chain.

View File

@@ -13,6 +13,7 @@ import (
"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/metrics"
"scroll-tech/common/bigint"
"scroll-tech/database"
"scroll-tech/database/orm"
@@ -51,21 +52,21 @@ type Watcher struct {
rollupABI *abi.ABI
// The height of the block that the watcher has retrieved event logs
processedMsgHeight uint64
processedMsgHeight *big.Int
stop chan bool
}
// NewWatcher returns a new instance of Watcher. The instance will be not fully prepared,
// and still needs to be finalized and ran by calling `watcher.Start`.
func NewWatcher(ctx context.Context, client *ethclient.Client, startHeight uint64, confirmations uint64, messengerAddress common.Address, rollupAddress common.Address, db database.OrmFactory) *Watcher {
func NewWatcher(ctx context.Context, client *ethclient.Client, startHeight *big.Int, confirmations uint64, messengerAddress common.Address, rollupAddress common.Address, db database.OrmFactory) *Watcher {
savedHeight, err := db.GetLayer1LatestWatchedHeight()
if err != nil {
log.Warn("Failed to fetch height from db", "err", err)
savedHeight = 0
savedHeight = big.NewInt(0)
}
if savedHeight < int64(startHeight) {
savedHeight = int64(startHeight)
if savedHeight.Cmp(startHeight) < 0 {
savedHeight.Set(startHeight)
}
stop := make(chan bool)
@@ -79,7 +80,7 @@ func NewWatcher(ctx context.Context, client *ethclient.Client, startHeight uint6
messengerABI: bridge_abi.L1MessengerMetaABI,
rollupAddress: rollupAddress,
rollupABI: bridge_abi.RollupMetaABI,
processedMsgHeight: uint64(savedHeight),
processedMsgHeight: savedHeight,
stop: stop,
}
}
@@ -122,7 +123,7 @@ func (w *Watcher) FetchContractEvent(blockHeight uint64) error {
log.Info("l1 watcher fetchContractEvent", "w.processedMsgHeight", w.processedMsgHeight)
}()
fromBlock := int64(w.processedMsgHeight) + 1
fromBlock := w.processedMsgHeight.Int64() + 1
toBlock := int64(blockHeight) - int64(w.confirmations)
for from := fromBlock; from <= toBlock; from += contractEventsBlocksFetchLimit {
@@ -155,7 +156,7 @@ func (w *Watcher) FetchContractEvent(blockHeight uint64) error {
return err
}
if len(logs) == 0 {
w.processedMsgHeight = uint64(to)
w.processedMsgHeight.SetInt64(to)
bridgeL1MsgSyncHeightGauge.Update(to)
continue
}
@@ -220,7 +221,7 @@ func (w *Watcher) FetchContractEvent(blockHeight uint64) error {
return err
}
w.processedMsgHeight = uint64(to)
w.processedMsgHeight.SetInt64(to)
bridgeL1MsgSyncHeightGauge.Update(to)
}
@@ -258,7 +259,7 @@ func (w *Watcher) parseBridgeEventLogs(logs []types.Log) ([]*orm.L1Message, []re
l1Messages = append(l1Messages, &orm.L1Message{
Nonce: event.MessageNonce.Uint64(),
MsgHash: utils.ComputeMessageHash(event.Sender, event.Target, event.Value, event.Fee, event.Deadline, event.Message, event.MessageNonce).String(),
Height: vLog.BlockNumber,
Height: bigint.NewUInt(vLog.BlockNumber),
Sender: event.Sender.String(),
Value: event.Value.String(),
Fee: event.Fee.String(),

View File

@@ -7,6 +7,7 @@ import (
"github.com/scroll-tech/go-ethereum/log"
"scroll-tech/common/bigint"
"scroll-tech/database"
"scroll-tech/database/orm"
@@ -118,7 +119,7 @@ func (w *batchProposer) createBatchForBlocks(blocks []*orm.BlockInfo) error {
startBlock = blocks[0]
endBlock = blocks[len(blocks)-1]
txNum, gasUsed uint64
blockIDs = make([]uint64, len(blocks))
blockIDs = make([]*bigint.BigInt, len(blocks))
)
for i, block := range blocks {
txNum += block.TxNum

View File

@@ -143,7 +143,7 @@ func (r *Layer2Relayer) processSavedEvent(msg *orm.L2Message, index uint64) erro
log.Info("Processing L2 Message", "msg.nonce", msg.Nonce, "msg.height", msg.Height)
proof := bridge_abi.IL1ScrollMessengerL2MessageProof{
BlockHeight: big.NewInt(int64(msg.Height)),
BlockHeight: msg.Height.BigInt(),
BatchIndex: big.NewInt(0).SetUint64(index),
MerkleProof: make([]byte, 0),
}

View File

@@ -12,6 +12,8 @@ import (
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
"scroll-tech/common/bigint"
"scroll-tech/database"
"scroll-tech/database/migrate"
"scroll-tech/database/orm"
@@ -21,7 +23,7 @@ var (
templateL2Message = []*orm.L2Message{
{
Nonce: 1,
Height: 1,
Height: bigint.NewInt(1),
Sender: "0x596a746661dbed76a84556111c2872249b070e15",
Value: "100",
Fee: "100",
@@ -66,12 +68,12 @@ func testL2RelayerProcessSaveEvents(t *testing.T) {
traces := []*types.BlockTrace{
{
Header: &types.Header{
Number: big.NewInt(int64(templateL2Message[0].Height)),
Number: templateL2Message[0].Height.BigInt(),
},
},
{
Header: &types.Header{
Number: big.NewInt(int64(templateL2Message[0].Height + 1)),
Number: big.NewInt(0).Add(templateL2Message[0].Height.BigInt(), big.NewInt(1)),
},
},
}
@@ -82,12 +84,10 @@ func testL2RelayerProcessSaveEvents(t *testing.T) {
assert.NoError(t, err)
batchID, err := db.NewBatchInDBTx(dbTx,
&orm.BlockInfo{Number: templateL2Message[0].Height},
&orm.BlockInfo{Number: templateL2Message[0].Height + 1},
&orm.BlockInfo{Number: bigint.NewInt(templateL2Message[0].Height.Int64() + 1)},
"0f", 1, 194676) // parentHash & totalTxNum & totalL2Gas don't really matter here
assert.NoError(t, err)
err = db.SetBatchIDForBlocksInDBTx(dbTx, []uint64{
templateL2Message[0].Height,
templateL2Message[0].Height + 1}, batchID)
err = db.SetBatchIDForBlocksInDBTx(dbTx, []*bigint.BigInt{templateL2Message[0].Height, bigint.NewInt(templateL2Message[0].Height.Int64() + 1)}, batchID)
assert.NoError(t, err)
err = dbTx.Commit()
assert.NoError(t, err)
@@ -140,13 +140,13 @@ func testL2RelayerProcessPendingBatches(t *testing.T) {
dbTx, err := db.Beginx()
assert.NoError(t, err)
batchID, err := db.NewBatchInDBTx(dbTx,
&orm.BlockInfo{Number: traces[0].Header.Number.Uint64()},
&orm.BlockInfo{Number: traces[1].Header.Number.Uint64()},
&orm.BlockInfo{Number: bigint.NewBigInt(traces[0].Header.Number)},
&orm.BlockInfo{Number: bigint.NewBigInt(traces[1].Header.Number)},
"ff", 1, 194676) // parentHash & totalTxNum & totalL2Gas don't really matter here
assert.NoError(t, err)
err = db.SetBatchIDForBlocksInDBTx(dbTx, []uint64{
traces[0].Header.Number.Uint64(),
traces[1].Header.Number.Uint64()}, batchID)
err = db.SetBatchIDForBlocksInDBTx(dbTx, []*bigint.BigInt{
bigint.NewBigInt(traces[0].Header.Number),
bigint.NewBigInt(traces[1].Header.Number)}, batchID)
assert.NoError(t, err)
err = dbTx.Commit()
assert.NoError(t, err)
@@ -179,7 +179,7 @@ func testL2RelayerProcessCommittedBatches(t *testing.T) {
dbTx, err := db.Beginx()
assert.NoError(t, err)
batchID, err := db.NewBatchInDBTx(dbTx, &orm.BlockInfo{}, &orm.BlockInfo{}, "0", 1, 194676) // startBlock & endBlock & parentHash & totalTxNum & totalL2Gas don't really matter here
batchID, err := db.NewBatchInDBTx(dbTx, &orm.BlockInfo{Number: bigint.NewInt(0)}, &orm.BlockInfo{Number: bigint.NewInt(0)}, "0", 1, 194676) // startBlock & endBlock & parentHash & totalTxNum & totalL2Gas don't really matter here
assert.NoError(t, err)
err = dbTx.Commit()
assert.NoError(t, err)
@@ -219,7 +219,7 @@ func testL2RelayerSkipBatches(t *testing.T) {
createBatch := func(rollupStatus orm.RollupStatus, provingStatus orm.ProvingStatus) string {
dbTx, err := db.Beginx()
assert.NoError(t, err)
batchID, err := db.NewBatchInDBTx(dbTx, &orm.BlockInfo{}, &orm.BlockInfo{}, "0", 1, 194676) // startBlock & endBlock & parentHash & totalTxNum & totalL2Gas don't really matter here
batchID, err := db.NewBatchInDBTx(dbTx, &orm.BlockInfo{Number: bigint.NewInt(0)}, &orm.BlockInfo{Number: bigint.NewInt(0)}, "0", 1, 194676) // startBlock & endBlock & parentHash & totalTxNum & totalL2Gas don't really matter here
assert.NoError(t, err)
err = dbTx.Commit()
assert.NoError(t, err)

View File

@@ -16,6 +16,8 @@ import (
"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/metrics"
"scroll-tech/common/bigint"
bridge_abi "scroll-tech/bridge/abi"
"scroll-tech/bridge/utils"
@@ -63,14 +65,14 @@ func NewL2WatcherClient(ctx context.Context, client *ethclient.Client, confirmat
savedHeight, err := orm.GetLayer2LatestWatchedHeight()
if err != nil {
log.Warn("fetch height from db failed", "err", err)
savedHeight = 0
savedHeight = big.NewInt(0)
}
return &WatcherClient{
ctx: ctx,
Client: client,
orm: orm,
processedMsgHeight: uint64(savedHeight),
processedMsgHeight: savedHeight.Uint64(),
confirmations: confirmations,
messengerAddress: messengerAddress,
messengerABI: bridge_abi.L2MessengerMetaABI,
@@ -180,7 +182,8 @@ func (w *WatcherClient) tryFetchRunningMissingBlocks(ctx context.Context, blockH
// Get newest block in DB. must have blocks at that time.
// Don't use "block_trace" table "trace" column's BlockTrace.Number,
// because it might be empty if the corresponding rollup_result is finalized/finalization_skipped
heightInDB, err := w.orm.GetBlockTracesLatestHeight()
heightInDBBig, err := w.orm.GetBlockTracesLatestHeight()
heightInDB := heightInDBBig.Int64()
if err != nil {
log.Error("failed to GetBlockTracesLatestHeight", "err", err)
return
@@ -336,7 +339,7 @@ func (w *WatcherClient) parseBridgeEventLogs(logs []types.Log) ([]*orm.L2Message
l2Messages = append(l2Messages, &orm.L2Message{
Nonce: event.MessageNonce.Uint64(),
MsgHash: utils.ComputeMessageHash(event.Sender, event.Target, event.Value, event.Fee, event.Deadline, event.Message, event.MessageNonce).String(),
Height: vLog.BlockNumber,
Height: bigint.NewUInt(vLog.BlockNumber),
Sender: event.Sender.String(),
Value: event.Value.String(),
Fee: event.Fee.String(),

View File

@@ -111,7 +111,7 @@ func testMonitorBridgeContract(t *testing.T) {
height, err := db.GetLayer2LatestWatchedHeight()
assert.NoError(t, err)
t.Log("Height in DB is", height)
assert.Greater(t, height, int64(previousHeight))
assert.Greater(t, height.Cmp(big.NewInt(int64(previousHeight))), 0)
msgs, err := db.GetL2Messages(map[string]interface{}{"status": orm.MsgPending})
assert.NoError(t, err)
assert.Equal(t, 2, len(msgs))
@@ -183,7 +183,7 @@ func testFetchMultipleSentMessageInOneBlock(t *testing.T) {
height, err := db.GetLayer2LatestWatchedHeight()
assert.NoError(t, err)
t.Log("LatestHeight is", height)
assert.Greater(t, height, int64(previousHeight)) // height must be greater than previousHeight because confirmations is 0
assert.Greater(t, height.Cmp(big.NewInt(int64(previousHeight))), 0) // height must be greater than previousHeight because confirmations is 0
msgs, err := db.GetL2Messages(map[string]interface{}{"status": orm.MsgPending})
assert.NoError(t, err)
assert.Equal(t, 5, len(msgs))

View File

@@ -3,6 +3,7 @@ package tests
import (
"context"
"math/big"
"scroll-tech/common/bigint"
"scroll-tech/database"
"scroll-tech/database/migrate"
"scroll-tech/database/orm"
@@ -41,7 +42,7 @@ func testRelayL2MessageSucceed(t *testing.T) {
// Create L1Watcher
l1Cfg := cfg.L1Config
l1Watcher := l1.NewWatcher(context.Background(), l1Client, 0, 0, l1Cfg.L1MessengerAddress, l1Cfg.RollupContractAddress, db)
l1Watcher := l1.NewWatcher(context.Background(), l1Client, big.NewInt(0), 0, l1Cfg.L1MessengerAddress, l1Cfg.RollupContractAddress, db)
// send message through l2 messenger contract
nonce, err := l2MessengerInstance.MessageNonce(&bind.CallOpts{})
@@ -84,20 +85,20 @@ func testRelayL2MessageSucceed(t *testing.T) {
assert.NoError(t, err)
batchID, err := db.NewBatchInDBTx(dbTx,
&orm.BlockInfo{
Number: traces[0].Header.Number.Uint64(),
Number: bigint.NewBigInt(traces[0].Header.Number),
Hash: traces[0].Header.Hash().String(),
ParentHash: traces[0].Header.ParentHash.String(),
},
&orm.BlockInfo{
Number: traces[0].Header.Number.Uint64(),
Number: bigint.NewBigInt(traces[0].Header.Number),
Hash: traces[0].Header.Hash().String(),
ParentHash: traces[0].Header.ParentHash.String(),
},
traces[0].Header.ParentHash.String(), 1, 194676)
assert.NoError(t, err)
err = db.SetBatchIDForBlocksInDBTx(dbTx, []uint64{
traces[0].Header.Number.Uint64(),
traces[0].Header.Number.Uint64()}, batchID)
err = db.SetBatchIDForBlocksInDBTx(dbTx, []*bigint.BigInt{
bigint.NewBigInt(traces[0].Header.Number),
bigint.NewBigInt(traces[0].Header.Number)}, batchID)
assert.NoError(t, err)
err = dbTx.Commit()
assert.NoError(t, err)

View File

@@ -3,6 +3,7 @@ package tests
import (
"context"
"math/big"
"scroll-tech/common/bigint"
"scroll-tech/database"
"scroll-tech/database/migrate"
"scroll-tech/database/orm"
@@ -35,7 +36,7 @@ func testCommitBatchAndFinalizeBatch(t *testing.T) {
// Create L1Watcher
l1Cfg := cfg.L1Config
l1Watcher := l1.NewWatcher(context.Background(), l1Client, 0, 0, l1Cfg.L1MessengerAddress, l1Cfg.RollupContractAddress, db)
l1Watcher := l1.NewWatcher(context.Background(), l1Client, big.NewInt(0), 0, l1Cfg.L1MessengerAddress, l1Cfg.RollupContractAddress, db)
// add some blocks to db
var traces []*types.BlockTrace
@@ -61,20 +62,20 @@ func testCommitBatchAndFinalizeBatch(t *testing.T) {
assert.NoError(t, err)
batchID, err := db.NewBatchInDBTx(dbTx,
&orm.BlockInfo{
Number: traces[0].Header.Number.Uint64(),
Number: bigint.NewBigInt(traces[0].Header.Number),
Hash: traces[0].Header.Hash().String(),
ParentHash: traces[0].Header.ParentHash.String(),
},
&orm.BlockInfo{
Number: traces[1].Header.Number.Uint64(),
Number: bigint.NewBigInt(traces[1].Header.Number),
Hash: traces[1].Header.Hash().String(),
ParentHash: traces[1].Header.ParentHash.String(),
},
traces[0].Header.ParentHash.String(), 1, 194676) // parentHash & totalTxNum & totalL2Gas don't really matter here
assert.NoError(t, err)
err = db.SetBatchIDForBlocksInDBTx(dbTx, []uint64{
traces[0].Header.Number.Uint64(),
traces[1].Header.Number.Uint64()}, batchID)
err = db.SetBatchIDForBlocksInDBTx(dbTx, []*bigint.BigInt{
bigint.NewBigInt(traces[0].Header.Number),
bigint.NewBigInt(traces[1].Header.Number)}, batchID)
assert.NoError(t, err)
err = dbTx.Commit()
assert.NoError(t, err)

74
common/bigint/bigint.go Normal file
View File

@@ -0,0 +1,74 @@
package bigint
import (
"database/sql/driver"
"errors"
"fmt"
"math/big"
)
// BigInt is a wrapper around `Big.Int` that implements sqlx's `Scanner` and `Value` interfaces.
type BigInt struct {
big.Int
}
// NewInt allocates and returns a new BigInt set to n.
func NewInt(n int64) *BigInt {
return &BigInt{
Int: *(big.NewInt(n)),
}
}
// NewUInt allocates and returns a new BigInt set to n of type uint64.
func NewUInt(n uint64) *BigInt {
return &BigInt{
Int: *(big.NewInt(0).SetUint64(n)),
}
}
// NewBigInt allocates and returns a new BigInt from big.Int
func NewBigInt(n *big.Int) *BigInt {
return &BigInt{
Int: *(big.NewInt(0).Set(n)),
}
}
// SetBigInt set value by big.int field.
func (b *BigInt) SetBigInt(n *big.Int) {
b.Set(n)
}
// BigInt return origin big.int type.
func (b *BigInt) BigInt() *big.Int {
return &b.Int
}
// Value implements the driver.Valuer interface
func (b *BigInt) Value() (driver.Value, error) {
if b != nil {
return b.String(), nil
}
return nil, nil
}
// Scan implements the sql.Scanner interface
func (b *BigInt) Scan(value interface{}) error {
if value == nil {
b = nil
return errors.New("could not scan nil value into BigInt")
}
switch t := value.(type) {
case int64:
b.SetInt64(value.(int64))
case []uint8:
_, ok := b.SetString(string(value.([]uint8)), 10)
if !ok {
return fmt.Errorf("failed to load BigInt value from []uint8: %v", value)
}
default:
return fmt.Errorf("could not scan type %T into BigInt", t)
}
return nil
}

View File

@@ -19,6 +19,8 @@ import (
"github.com/stretchr/testify/assert"
"golang.org/x/sync/errgroup"
"scroll-tech/common/bigint"
"scroll-tech/database"
"scroll-tech/database/migrate"
"scroll-tech/database/orm"
@@ -251,7 +253,7 @@ func testValidProof(t *testing.T) {
dbTx, err := l2db.Beginx()
assert.NoError(t, err)
for i := range ids {
ID, err := l2db.NewBatchInDBTx(dbTx, &orm.BlockInfo{Number: uint64(i)}, &orm.BlockInfo{Number: uint64(i)}, "0f", 1, 194676)
ID, err := l2db.NewBatchInDBTx(dbTx, &orm.BlockInfo{Number: bigint.NewInt(int64(i))}, &orm.BlockInfo{Number: bigint.NewInt(int64(i))}, "0f", 1, 194676)
assert.NoError(t, err)
ids[i] = ID
}
@@ -310,7 +312,7 @@ func testInvalidProof(t *testing.T) {
dbTx, err := l2db.Beginx()
assert.NoError(t, err)
for i := range ids {
ID, err := l2db.NewBatchInDBTx(dbTx, &orm.BlockInfo{Number: uint64(i)}, &orm.BlockInfo{Number: uint64(i)}, "0f", 1, 194676)
ID, err := l2db.NewBatchInDBTx(dbTx, &orm.BlockInfo{Number: bigint.NewInt(int64(i))}, &orm.BlockInfo{Number: bigint.NewInt(int64(i))}, "0f", 1, 194676)
assert.NoError(t, err)
ids[i] = ID
}
@@ -370,7 +372,7 @@ func testIdleRollerSelection(t *testing.T) {
dbTx, err := l2db.Beginx()
assert.NoError(t, err)
for i := range ids {
ID, err := l2db.NewBatchInDBTx(dbTx, &orm.BlockInfo{Number: uint64(i)}, &orm.BlockInfo{Number: uint64(i)}, "0f", 1, 194676)
ID, err := l2db.NewBatchInDBTx(dbTx, &orm.BlockInfo{Number: bigint.NewUInt(uint64(i))}, &orm.BlockInfo{Number: bigint.NewUInt(uint64(i))}, "0f", 1, 194676)
assert.NoError(t, err)
ids[i] = ID
}
@@ -407,7 +409,7 @@ func testGracefulRestart(t *testing.T) {
dbTx, err := l2db.Beginx()
assert.NoError(t, err)
for i := range ids {
ids[i], err = l2db.NewBatchInDBTx(dbTx, &orm.BlockInfo{Number: uint64(i)}, &orm.BlockInfo{Number: uint64(i)}, "0f", 1, 194676)
ids[i], err = l2db.NewBatchInDBTx(dbTx, &orm.BlockInfo{Number: bigint.NewUInt(uint64(i))}, &orm.BlockInfo{Number: bigint.NewUInt(uint64(i))}, "0f", 1, 194676)
assert.NoError(t, err)
}
assert.NoError(t, dbTx.Commit())

View File

@@ -13,6 +13,7 @@ import (
"github.com/scroll-tech/go-ethereum/common"
"github.com/scroll-tech/go-ethereum/log"
"scroll-tech/common/bigint"
"scroll-tech/common/utils"
)
@@ -80,9 +81,9 @@ type BlockBatch struct {
ID string `json:"id" db:"id"`
Index uint64 `json:"index" db:"index"`
ParentHash string `json:"parent_hash" db:"parent_hash"`
StartBlockNumber uint64 `json:"start_block_number" db:"start_block_number"`
StartBlockNumber *bigint.BigInt `json:"start_block_number" db:"start_block_number"`
StartBlockHash string `json:"start_block_hash" db:"start_block_hash"`
EndBlockNumber uint64 `json:"end_block_number" db:"end_block_number"`
EndBlockNumber *bigint.BigInt `json:"end_block_number" db:"end_block_number"`
EndBlockHash string `json:"end_block_hash" db:"end_block_hash"`
TotalTxNum uint64 `json:"total_tx_num" db:"total_tx_num"`
TotalL2Gas uint64 `json:"total_l2_gas" db:"total_l2_gas"`
@@ -208,9 +209,9 @@ func (o *blockBatchOrm) NewBatchInDBTx(dbTx *sqlx.Tx, startBlock *BlockInfo, end
"id": id,
"index": index,
"parent_hash": parentHash,
"start_block_number": startBlock.Number,
"start_block_number": startBlock.Number.Int64(),
"start_block_hash": startBlock.Hash,
"end_block_number": endBlock.Number,
"end_block_number": endBlock.Number.Int64(),
"end_block_hash": endBlock.Hash,
"total_tx_num": totalTxNum,
"total_l2_gas": totalL2Gas,

View File

@@ -5,6 +5,7 @@ import (
"encoding/json"
"errors"
"fmt"
"math/big"
"strings"
"github.com/jmoiron/sqlx"
@@ -12,6 +13,7 @@ import (
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/log"
"scroll-tech/common/bigint"
"scroll-tech/common/utils"
)
@@ -26,9 +28,9 @@ func NewBlockTraceOrm(db *sqlx.DB) BlockTraceOrm {
return &blockTraceOrm{db: db}
}
func (o *blockTraceOrm) Exist(number uint64) (bool, error) {
func (o *blockTraceOrm) Exist(number *big.Int) (bool, error) {
var res int
err := o.db.QueryRow(o.db.Rebind(`SELECT 1 from block_trace where number = ? limit 1;`), number).Scan(&res)
err := o.db.QueryRow(o.db.Rebind(`SELECT 1 from block_trace where number = ? limit 1;`), number.Int64()).Scan(&res)
if err != nil {
if err != sql.ErrNoRows {
return false, err
@@ -38,14 +40,14 @@ func (o *blockTraceOrm) Exist(number uint64) (bool, error) {
return true, nil
}
func (o *blockTraceOrm) GetBlockTracesLatestHeight() (int64, error) {
func (o *blockTraceOrm) GetBlockTracesLatestHeight() (*big.Int, error) {
row := o.db.QueryRow("SELECT COALESCE(MAX(number), -1) FROM block_trace;")
var height int64
if err := row.Scan(&height); err != nil {
return -1, err
return nil, err
}
return height, nil
return big.NewInt(height), nil
}
func (o *blockTraceOrm) GetBlockTraces(fields map[string]interface{}, args ...string) ([]*types.BlockTrace, error) {
@@ -141,8 +143,8 @@ func (o *blockTraceOrm) GetUnbatchedBlocks(fields map[string]interface{}, args .
return blocks, rows.Close()
}
func (o *blockTraceOrm) GetHashByNumber(number uint64) (*common.Hash, error) {
row := o.db.QueryRow(`SELECT hash FROM block_trace WHERE number = $1`, number)
func (o *blockTraceOrm) GetHashByNumber(number *big.Int) (*common.Hash, error) {
row := o.db.QueryRow(`SELECT hash FROM block_trace WHERE number = $1`, number.Int64())
var hashStr string
if err := row.Scan(&hashStr); err != nil {
return nil, err
@@ -154,7 +156,7 @@ func (o *blockTraceOrm) GetHashByNumber(number uint64) (*common.Hash, error) {
func (o *blockTraceOrm) InsertBlockTraces(blockTraces []*types.BlockTrace) error {
traceMaps := make([]map[string]interface{}, len(blockTraces))
for i, trace := range blockTraces {
number, hash, txNum, mtime := trace.Header.Number.Int64(),
number, hash, txNum, mtime := new(big.Int).Set(trace.Header.Number),
trace.Header.Hash().String(),
len(trace.Transactions),
trace.Header.Time
@@ -170,7 +172,7 @@ func (o *blockTraceOrm) InsertBlockTraces(blockTraces []*types.BlockTrace) error
return err
}
traceMaps[i] = map[string]interface{}{
"number": number,
"number": number.String(),
"hash": hash,
"parent_hash": trace.Header.ParentHash.String(),
"trace": string(data),
@@ -195,9 +197,8 @@ func (o *blockTraceOrm) DeleteTracesByBatchID(batchID string) error {
// http://jmoiron.github.io/sqlx/#inQueries
// https://stackoverflow.com/questions/56568799/how-to-update-multiple-rows-using-sqlx
func (o *blockTraceOrm) SetBatchIDForBlocksInDBTx(dbTx *sqlx.Tx, numbers []uint64, batchID string) error {
func (o *blockTraceOrm) SetBatchIDForBlocksInDBTx(dbTx *sqlx.Tx, numbers []*bigint.BigInt, batchID string) error {
query := "UPDATE block_trace SET batch_id=? WHERE number IN (?)"
qry, args, err := sqlx.In(query, batchID, numbers)
if err != nil {
return err

View File

@@ -4,6 +4,8 @@ import (
"context"
"database/sql"
"fmt"
"math/big"
"scroll-tech/common/bigint"
"github.com/jmoiron/sqlx"
"github.com/scroll-tech/go-ethereum/common"
@@ -35,39 +37,39 @@ const (
// L1Message is structure of stored layer1 bridge message
type L1Message struct {
Nonce uint64 `json:"nonce" db:"nonce"`
MsgHash string `json:"msg_hash" db:"msg_hash"`
Height uint64 `json:"height" db:"height"`
Sender string `json:"sender" db:"sender"`
Value string `json:"value" db:"value"`
Fee string `json:"fee" db:"fee"`
GasLimit uint64 `json:"gas_limit" db:"gas_limit"`
Deadline uint64 `json:"deadline" db:"deadline"`
Target string `json:"target" db:"target"`
Calldata string `json:"calldata" db:"calldata"`
Layer1Hash string `json:"layer1_hash" db:"layer1_hash"`
Status MsgStatus `json:"status" db:"status"`
Nonce uint64 `json:"nonce" db:"nonce"`
MsgHash string `json:"msg_hash" db:"msg_hash"`
Height *bigint.BigInt `json:"height" db:"height"`
Sender string `json:"sender" db:"sender"`
Value string `json:"value" db:"value"`
Fee string `json:"fee" db:"fee"`
GasLimit uint64 `json:"gas_limit" db:"gas_limit"`
Deadline uint64 `json:"deadline" db:"deadline"`
Target string `json:"target" db:"target"`
Calldata string `json:"calldata" db:"calldata"`
Layer1Hash string `json:"layer1_hash" db:"layer1_hash"`
Status MsgStatus `json:"status" db:"status"`
}
// L2Message is structure of stored layer2 bridge message
type L2Message struct {
Nonce uint64 `json:"nonce" db:"nonce"`
MsgHash string `json:"msg_hash" db:"msg_hash"`
Height uint64 `json:"height" db:"height"`
Sender string `json:"sender" db:"sender"`
Value string `json:"value" db:"value"`
Fee string `json:"fee" db:"fee"`
GasLimit uint64 `json:"gas_limit" db:"gas_limit"`
Deadline uint64 `json:"deadline" db:"deadline"`
Target string `json:"target" db:"target"`
Calldata string `json:"calldata" db:"calldata"`
Layer2Hash string `json:"layer2_hash" db:"layer2_hash"`
Status MsgStatus `json:"status" db:"status"`
Nonce uint64 `json:"nonce" db:"nonce"`
MsgHash string `json:"msg_hash" db:"msg_hash"`
Height *bigint.BigInt `json:"height" db:"height"`
Sender string `json:"sender" db:"sender"`
Value string `json:"value" db:"value"`
Fee string `json:"fee" db:"fee"`
GasLimit uint64 `json:"gas_limit" db:"gas_limit"`
Deadline uint64 `json:"deadline" db:"deadline"`
Target string `json:"target" db:"target"`
Calldata string `json:"calldata" db:"calldata"`
Layer2Hash string `json:"layer2_hash" db:"layer2_hash"`
Status MsgStatus `json:"status" db:"status"`
}
// BlockInfo is structure of stored `block_trace` without `trace`
type BlockInfo struct {
Number uint64 `json:"number" db:"number"`
Number *bigint.BigInt `json:"number" db:"number"`
Hash string `json:"hash" db:"hash"`
ParentHash string `json:"parent_hash" db:"parent_hash"`
BatchID sql.NullString `json:"batch_id" db:"batch_id"`
@@ -117,16 +119,16 @@ type SessionInfo struct {
// BlockTraceOrm block_trace operation interface
type BlockTraceOrm interface {
Exist(number uint64) (bool, error)
GetBlockTracesLatestHeight() (int64, error)
Exist(number *big.Int) (bool, error)
GetBlockTracesLatestHeight() (*big.Int, error)
GetBlockTraces(fields map[string]interface{}, args ...string) ([]*types.BlockTrace, error)
GetBlockInfos(fields map[string]interface{}, args ...string) ([]*BlockInfo, error)
// GetUnbatchedBlocks add `GetUnbatchedBlocks` because `GetBlockInfos` cannot support query "batch_id is NULL"
GetUnbatchedBlocks(fields map[string]interface{}, args ...string) ([]*BlockInfo, error)
GetHashByNumber(number uint64) (*common.Hash, error)
GetHashByNumber(number *big.Int) (*common.Hash, error)
DeleteTracesByBatchID(batchID string) error
InsertBlockTraces(blockTraces []*types.BlockTrace) error
SetBatchIDForBlocksInDBTx(dbTx *sqlx.Tx, numbers []uint64, batchID string) error
SetBatchIDForBlocksInDBTx(dbTx *sqlx.Tx, numbers []*bigint.BigInt, batchID string) error
}
// SessionInfoOrm sessions info operation inte
@@ -170,7 +172,7 @@ type L1MessageOrm interface {
UpdateLayer2Hash(ctx context.Context, msgHash string, layer2Hash string) error
UpdateLayer1Status(ctx context.Context, msgHash string, status MsgStatus) error
UpdateLayer1StatusAndLayer2Hash(ctx context.Context, msgHash string, status MsgStatus, layer2Hash string) error
GetLayer1LatestWatchedHeight() (int64, error)
GetLayer1LatestWatchedHeight() (*big.Int, error)
GetRelayL1MessageTxHash(nonce uint64) (sql.NullString, error) // for unit tests only
}
@@ -188,7 +190,7 @@ type L2MessageOrm interface {
UpdateLayer2Status(ctx context.Context, msgHash string, status MsgStatus) error
UpdateLayer2StatusAndLayer1Hash(ctx context.Context, msgHash string, status MsgStatus, layer1Hash string) error
UpdateMessageProof(ctx context.Context, nonce uint64, proof string) error
GetLayer2LatestWatchedHeight() (int64, error)
GetLayer2LatestWatchedHeight() (*big.Int, error)
GetRelayL2MessageTxHash(nonce uint64) (sql.NullString, error) // for unit tests only
}

View File

@@ -4,6 +4,8 @@ import (
"context"
"database/sql"
"errors"
"math/big"
"scroll-tech/common/bigint"
"github.com/jmoiron/sqlx"
"github.com/scroll-tech/go-ethereum/log"
@@ -98,7 +100,7 @@ func (m *l1MessageOrm) SaveL1Messages(ctx context.Context, messages []*L1Message
messageMaps[i] = map[string]interface{}{
"nonce": msg.Nonce,
"msg_hash": msg.MsgHash,
"height": msg.Height,
"height": msg.Height.Int64(),
"sender": msg.Sender,
"target": msg.Target,
"value": msg.Value,
@@ -112,7 +114,7 @@ func (m *l1MessageOrm) SaveL1Messages(ctx context.Context, messages []*L1Message
_, err := m.db.NamedExec(`INSERT INTO public.l1_message (nonce, msg_hash, height, sender, target, value, fee, gas_limit, deadline, calldata, layer1_hash) VALUES (:nonce, :msg_hash, :height, :sender, :target, :value, :fee, :gas_limit, :deadline, :calldata, :layer1_hash);`, messageMaps)
if err != nil {
nonces := make([]uint64, 0, len(messages))
heights := make([]uint64, 0, len(messages))
heights := make([]*bigint.BigInt, 0, len(messages))
for _, msg := range messages {
nonces = append(nonces, msg.Nonce)
heights = append(heights, msg.Height)
@@ -150,22 +152,22 @@ func (m *l1MessageOrm) UpdateLayer1StatusAndLayer2Hash(ctx context.Context, msgH
}
// GetLayer1LatestWatchedHeight returns latest height stored in the table
func (m *l1MessageOrm) GetLayer1LatestWatchedHeight() (int64, error) {
func (m *l1MessageOrm) GetLayer1LatestWatchedHeight() (*big.Int, error) {
// @note It's not correct, since we may don't have message in some blocks.
// But it will only be called at start, some redundancy is acceptable.
row := m.db.QueryRow("SELECT MAX(height) FROM l1_message;")
var height sql.NullInt64
if err := row.Scan(&height); err != nil {
if err == sql.ErrNoRows || !height.Valid {
return -1, nil
if err == sql.ErrNoRows {
return big.NewInt(-1), nil
}
return 0, err
return nil, err
}
if height.Valid {
return height.Int64, nil
return big.NewInt(height.Int64), nil
}
return -1, nil
return big.NewInt(-1), nil
}
func (m *l1MessageOrm) GetRelayL1MessageTxHash(nonce uint64) (sql.NullString, error) {

View File

@@ -5,6 +5,7 @@ import (
"database/sql"
"errors"
"fmt"
"math/big"
"strings"
"github.com/jmoiron/sqlx"
@@ -130,7 +131,7 @@ func (m *layer2MessageOrm) SaveL2Messages(ctx context.Context, messages []*L2Mes
messageMaps[i] = map[string]interface{}{
"nonce": msg.Nonce,
"msg_hash": msg.MsgHash,
"height": msg.Height,
"height": msg.Height.Int64(),
"sender": msg.Sender,
"target": msg.Target,
"value": msg.Value,
@@ -145,10 +146,10 @@ func (m *layer2MessageOrm) SaveL2Messages(ctx context.Context, messages []*L2Mes
_, err := m.db.NamedExec(`INSERT INTO public.l2_message (nonce, msg_hash, height, sender, target, value, fee, gas_limit, deadline, calldata, layer2_hash) VALUES (:nonce, :msg_hash, :height, :sender, :target, :value, :fee, :gas_limit, :deadline, :calldata, :layer2_hash);`, messageMaps)
if err != nil {
nonces := make([]uint64, 0, len(messages))
heights := make([]uint64, 0, len(messages))
heights := make([]*big.Int, 0, len(messages))
for _, msg := range messages {
nonces = append(nonces, msg.Nonce)
heights = append(heights, msg.Height)
heights = append(heights, msg.Height.BigInt())
}
log.Error("failed to insert layer2Messages", "nonces", nonces, "heights", heights, "err", err)
}
@@ -192,19 +193,19 @@ func (m *layer2MessageOrm) UpdateLayer2StatusAndLayer1Hash(ctx context.Context,
}
// GetLayer2LatestWatchedHeight returns latest height stored in the table
func (m *layer2MessageOrm) GetLayer2LatestWatchedHeight() (int64, error) {
func (m *layer2MessageOrm) GetLayer2LatestWatchedHeight() (*big.Int, error) {
// @note It's not correct, since we may don't have message in some blocks.
// But it will only be called at start, some redundancy is acceptable.
row := m.db.QueryRow("SELECT COALESCE(MAX(height), -1) FROM l2_message;")
var height int64
if err := row.Scan(&height); err != nil {
return -1, err
return nil, err
}
if height < 0 {
return -1, fmt.Errorf("could not get height due to database return negative")
return nil, fmt.Errorf("could not get height due to database return negative")
}
return height, nil
return big.NewInt(height), nil
}
func (m *layer2MessageOrm) GetRelayL2MessageTxHash(nonce uint64) (sql.NullString, error) {

View File

@@ -3,6 +3,7 @@ package database_test
import (
"context"
"encoding/json"
"math/big"
"os"
"testing"
"time"
@@ -12,6 +13,7 @@ import (
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
"scroll-tech/common/bigint"
"scroll-tech/common/docker"
"scroll-tech/database"
@@ -24,7 +26,7 @@ var (
{
Nonce: 1,
MsgHash: "msg_hash1",
Height: 1,
Height: bigint.NewInt(1),
Sender: "0x596a746661dbed76a84556111c2872249b070e15",
Value: "0x19ece",
Fee: "0x19ece",
@@ -37,7 +39,7 @@ var (
{
Nonce: 2,
MsgHash: "msg_hash2",
Height: 2,
Height: bigint.NewInt(2),
Sender: "0x596a746661dbed76a84556111c2872249b070e15",
Value: "0x19ece",
Fee: "0x19ece",
@@ -52,7 +54,7 @@ var (
{
Nonce: 1,
MsgHash: "msg_hash1",
Height: 1,
Height: bigint.NewInt(1),
Sender: "0x596a746661dbed76a84556111c2872249b070e15",
Value: "0x19ece",
Fee: "0x19ece",
@@ -65,7 +67,7 @@ var (
{
Nonce: 2,
MsgHash: "msg_hash2",
Height: 2,
Height: bigint.NewInt(2),
Sender: "0x596a746661dbed76a84556111c2872249b070e15",
Value: "0x19ece",
Fee: "0x19ece",
@@ -147,7 +149,7 @@ func testOrmBlockTraces(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, true, len(res) == 0)
exist, err := ormBlock.Exist(blockTrace.Header.Number.Uint64())
exist, err := ormBlock.Exist(blockTrace.Header.Number)
assert.NoError(t, err)
assert.Equal(t, false, exist)
@@ -159,7 +161,7 @@ func testOrmBlockTraces(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, true, len(res2) == 1)
exist, err = ormBlock.Exist(blockTrace.Header.Number.Uint64())
exist, err = ormBlock.Exist(blockTrace.Header.Number)
assert.NoError(t, err)
assert.Equal(t, true, exist)
@@ -205,7 +207,7 @@ func testOrmL1Message(t *testing.T) {
height, err := ormLayer1.GetLayer1LatestWatchedHeight()
assert.NoError(t, err)
assert.Equal(t, int64(2), height)
assert.Equal(t, big.NewInt(2), height)
msg, err := ormLayer1.GetL1MessageByMsgHash("msg_hash2")
assert.NoError(t, err)
@@ -239,7 +241,7 @@ func testOrmL2Message(t *testing.T) {
height, err := ormLayer2.GetLayer2LatestWatchedHeight()
assert.NoError(t, err)
assert.Equal(t, int64(2), height)
assert.Equal(t, big.NewInt(2), height)
msg, err := ormLayer2.GetL2MessageByMsgHash("msg_hash2")
assert.NoError(t, err)
@@ -257,22 +259,22 @@ func testOrmBlockBatch(t *testing.T) {
dbTx, err := factory.Beginx()
assert.NoError(t, err)
batchID1, err := ormBatch.NewBatchInDBTx(dbTx,
&orm.BlockInfo{Number: blockTrace.Header.Number.Uint64()},
&orm.BlockInfo{Number: blockTrace.Header.Number.Uint64() + 1},
&orm.BlockInfo{Number: bigint.NewBigInt(blockTrace.Header.Number)},
&orm.BlockInfo{Number: bigint.NewBigInt(new(big.Int).Add(blockTrace.Header.Number, big.NewInt(1)))},
"ff", 1, 194676) // parentHash & totalTxNum & totalL2Gas don't really matter here
assert.NoError(t, err)
err = ormBlock.SetBatchIDForBlocksInDBTx(dbTx, []uint64{
blockTrace.Header.Number.Uint64(),
blockTrace.Header.Number.Uint64() + 1}, batchID1)
err = ormBlock.SetBatchIDForBlocksInDBTx(dbTx, []*bigint.BigInt{
bigint.NewBigInt(blockTrace.Header.Number),
bigint.NewInt(blockTrace.Header.Number.Int64() + 1)}, batchID1)
assert.NoError(t, err)
batchID2, err := ormBatch.NewBatchInDBTx(dbTx,
&orm.BlockInfo{Number: blockTrace.Header.Number.Uint64() + 2},
&orm.BlockInfo{Number: blockTrace.Header.Number.Uint64() + 3},
&orm.BlockInfo{Number: bigint.NewBigInt(new(big.Int).Add(blockTrace.Header.Number, big.NewInt(2)))},
&orm.BlockInfo{Number: bigint.NewBigInt(new(big.Int).Add(blockTrace.Header.Number, big.NewInt(3)))},
"ff", 1, 194676) // parentHash & totalTxNum & totalL2Gas don't really matter here
assert.NoError(t, err)
err = ormBlock.SetBatchIDForBlocksInDBTx(dbTx, []uint64{
blockTrace.Header.Number.Uint64() + 2,
blockTrace.Header.Number.Uint64() + 3}, batchID2)
err = ormBlock.SetBatchIDForBlocksInDBTx(dbTx, []*bigint.BigInt{
bigint.NewInt(blockTrace.Header.Number.Int64() + 2),
bigint.NewInt(blockTrace.Header.Number.Int64() + 3)}, batchID2)
assert.NoError(t, err)
err = dbTx.Commit()
assert.NoError(t, err)
@@ -346,13 +348,13 @@ func testOrmSessionInfo(t *testing.T) {
dbTx, err := factory.Beginx()
assert.NoError(t, err)
batchID, err := ormBatch.NewBatchInDBTx(dbTx,
&orm.BlockInfo{Number: blockTrace.Header.Number.Uint64()},
&orm.BlockInfo{Number: blockTrace.Header.Number.Uint64() + 1},
&orm.BlockInfo{Number: bigint.NewBigInt(blockTrace.Header.Number)},
&orm.BlockInfo{Number: bigint.NewBigInt(new(big.Int).Add(blockTrace.Header.Number, big.NewInt(1)))},
"ff", 1, 194676)
assert.NoError(t, err)
assert.NoError(t, ormBlock.SetBatchIDForBlocksInDBTx(dbTx, []uint64{
blockTrace.Header.Number.Uint64(),
blockTrace.Header.Number.Uint64() + 1}, batchID))
assert.NoError(t, ormBlock.SetBatchIDForBlocksInDBTx(dbTx, []*bigint.BigInt{
bigint.NewBigInt(blockTrace.Header.Number),
bigint.NewInt(blockTrace.Header.Number.Int64() + 1)}, batchID))
assert.NoError(t, dbTx.Commit())
assert.NoError(t, ormBatch.UpdateProvingStatus(batchID, orm.ProvingTaskAssigned))