fix bug after merged feat/record_transaction branch.

This commit is contained in:
maskpp
2023-04-19 11:16:07 +08:00
parent bf6b17d1da
commit cd653d1997
4 changed files with 15 additions and 15 deletions

View File

@@ -71,7 +71,7 @@ func testL1CheckSubmittedMessages(t *testing.T) {
signedTx, err := mockTx(auth, l2Cli)
assert.NoError(t, err)
err = db.SaveTx(templateL1Message[0].MsgHash, auth.From.String(), types.L1toL2MessageTx, signedTx, "")
err = db.SaveScrollTx(templateL1Message[0].MsgHash, auth.From.String(), types.L1toL2MessageTx, signedTx, "")
assert.Nil(t, err)
err = db.SaveL1Messages(context.Background(), templateL1Message)
assert.NoError(t, err)

View File

@@ -370,8 +370,8 @@ func (r *Layer2Relayer) ProcessGasPriceOracle() {
func (r *Layer2Relayer) CheckRollupCommittingBatches() error {
txMsgs, err := r.db.GetScrollTxs(
map[string]interface{}{
"type": types.RollUpCommitTx,
"confirm": false,
"type": types.RollUpCommitTx,
"confirmed": false,
},
"ORDER BY nonce ASC",
)
@@ -384,7 +384,7 @@ func (r *Layer2Relayer) CheckRollupCommittingBatches() error {
}
for _, msg := range txMsgs {
if !msg.ExtraData.Valid {
if !msg.Note.Valid {
return fmt.Errorf("batch hash list is empty, tx.id: %s", msg.ID)
}
// Wait until sender's pending is not full.
@@ -406,7 +406,7 @@ func (r *Layer2Relayer) CheckRollupCommittingBatches() error {
log.Error("failed to load or resend rollup committing tx", "msg.id", msg.ID, "err", err)
return err
}
r.processingBatchesCommitment.Set(msg.ID, strings.Split(msg.ExtraData.String, ","))
r.processingBatchesCommitment.Set(msg.ID, strings.Split(msg.Note.String, ","))
log.Info("successfully check rollup committing tx", "resend", isResend, "msg.id", msg.ID, "tx.Hash", tx.Hash().String())
}
return nil

View File

@@ -224,7 +224,7 @@ func testL2CheckSubmittedMessages(t *testing.T) {
signedTx, err := mockTx(auth, l1Cli)
assert.NoError(t, err)
err = db.SaveTx(templateL2Message[0].MsgHash, auth.From.String(), types.L2toL1MessageTx, signedTx, "")
err = db.SaveScrollTx(templateL2Message[0].MsgHash, auth.From.String(), types.L2toL1MessageTx, signedTx, "")
assert.Nil(t, err)
err = db.SaveL2Messages(context.Background(), templateL2Message)
assert.NoError(t, err)
@@ -303,7 +303,7 @@ func testL2CheckRollupCommittingBatches(t *testing.T) {
signedTx, err := mockTx(auth, l1Cli)
assert.NoError(t, err)
id := "rollup committing tx"
err = db.SaveTx(id, auth.From.String(), types.RollUpCommitTx, signedTx, strings.Join(batchHashes, ","))
err = db.SaveScrollTx(id, auth.From.String(), types.RollUpCommitTx, signedTx, strings.Join(batchHashes, ","))
assert.NoError(t, err)
assert.NoError(t, relayer.CheckRollupCommittingBatches())
@@ -314,8 +314,8 @@ func testL2CheckRollupCommittingBatches(t *testing.T) {
// check tx is confirmed.
txMsgs, err = db.GetScrollTxs(
map[string]interface{}{
"type": types.RollUpCommitTx,
"confirm": true,
"type": types.RollUpCommitTx,
"confirmed": true,
},
"ORDER BY nonce ASC",
)
@@ -323,7 +323,7 @@ func testL2CheckRollupCommittingBatches(t *testing.T) {
})
assert.NoError(t, err)
assert.Equal(t, 1, len(txMsgs))
assert.Equal(t, "", txMsgs[0].ExtraData.String)
assert.Equal(t, "", txMsgs[0].Note.String)
// check tx is on chain.
_, err = l1Cli.TransactionReceipt(context.Background(), common.HexToHash(txMsgs[0].TxHash.String))
assert.NoError(t, err)
@@ -370,7 +370,7 @@ func testL2CheckRollupFinalizingBatches(t *testing.T) {
signedTx, err := mockTx(auth, l1Cli)
assert.NoError(t, err)
err = db.SaveTx(batchHashes[0], auth.From.String(), types.RollupFinalizeTx, signedTx, strings.Join(batchHashes, ","))
err = db.SaveScrollTx(batchHashes[0], auth.From.String(), types.RollupFinalizeTx, signedTx, strings.Join(batchHashes, ","))
assert.NoError(t, err)
assert.NoError(t, relayer.CheckRollupFinalizingBatches())
relayer.WaitRollupFinalizingBatches()
@@ -380,8 +380,8 @@ func testL2CheckRollupFinalizingBatches(t *testing.T) {
// check tx is confirmed.
txMsgs, err = db.GetScrollTxs(
map[string]interface{}{
"type": types.RollupFinalizeTx,
"confirm": true,
"type": types.RollupFinalizeTx,
"confirmed": true,
},
"ORDER BY nonce ASC",
)
@@ -389,7 +389,7 @@ func testL2CheckRollupFinalizingBatches(t *testing.T) {
})
assert.NoError(t, err)
assert.Equal(t, 1, len(txMsgs))
assert.Equal(t, "", txMsgs[0].ExtraData.String)
assert.Equal(t, "", txMsgs[0].Note.String)
// check tx is on chain.
_, err = l1Cli.TransactionReceipt(context.Background(), common.HexToHash(txMsgs[0].TxHash.String))
assert.NoError(t, err)

View File

@@ -55,7 +55,7 @@ func (t *scrollTxOrm) SetScrollTxConfirmedByID(id string, txHash string) error {
// GetScrollTxs get scroll txs by params.
func (t *scrollTxOrm) GetScrollTxs(fields map[string]interface{}, args ...string) ([]*stypes.ScrollTx, error) {
query := "select id, tx_hash, sender, nonce, target, value, data, extra_data from scroll_transaction where 1 = 1"
query := "select id, tx_hash, sender, nonce, target, value, data, note from scroll_transaction where 1 = 1"
for key := range fields {
query = query + fmt.Sprintf(" AND %s = :%s", key, key)
}