-
Notifications
You must be signed in to change notification settings - Fork 701
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ne. Do fatal for some finalizer halt events. Several fixes. Optmize purge pool (#3241) * sequence batch only when sanity check is done. Do fatal for some halt events. Several fixes * feat: optimize purge txn pool query (#3137) * feat: optimize purge txn pool query * fix: add new method to state interface * feat: generate new state mocks * fix merge * fix %w --------- Co-authored-by: Idris Hanafi <ifh101@gmail.com>
- Loading branch information
1 parent
8d135de
commit 0e47e24
Showing
23 changed files
with
667 additions
and
780 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- +migrate Up | ||
ALTER TABLE state.batch | ||
ADD COLUMN IF NOT EXISTS checked BOOLEAN NOT NULL DEFAULT TRUE; | ||
|
||
-- +migrate Down | ||
ALTER TABLE state.batch | ||
DROP COLUMN IF EXISTS checked; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package migrations_test | ||
|
||
import ( | ||
"database/sql" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type migrationTest0016 struct{} | ||
|
||
func (m migrationTest0016) InsertData(db *sql.DB) error { | ||
const insertBatch0 = ` | ||
INSERT INTO state.batch (batch_num, global_exit_root, local_exit_root, acc_input_hash, state_root, timestamp, coinbase, raw_txs_data, forced_batch_num, wip) | ||
VALUES (0,'0x0000', '0x0000', '0x0000', '0x0000', now(), '0x0000', null, null, true)` | ||
|
||
// insert batch | ||
_, err := db.Exec(insertBatch0) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (m migrationTest0016) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { | ||
var result int | ||
|
||
// Check column checked exists in state.batch table | ||
const getCheckedColumn = `SELECT count(*) FROM information_schema.columns WHERE table_name='batch' and column_name='checked'` | ||
row := db.QueryRow(getCheckedColumn) | ||
assert.NoError(t, row.Scan(&result)) | ||
assert.Equal(t, 1, result) | ||
|
||
const insertBatch0 = ` | ||
INSERT INTO state.batch (batch_num, global_exit_root, local_exit_root, acc_input_hash, state_root, timestamp, coinbase, raw_txs_data, forced_batch_num, wip, checked) | ||
VALUES (1,'0x0001', '0x0001', '0x0001', '0x0001', now(), '0x0001', null, null, true, false)` | ||
|
||
// insert batch 1 | ||
_, err := db.Exec(insertBatch0) | ||
assert.NoError(t, err) | ||
|
||
const insertBatch1 = ` | ||
INSERT INTO state.batch (batch_num, global_exit_root, local_exit_root, acc_input_hash, state_root, timestamp, coinbase, raw_txs_data, forced_batch_num, wip, checked) | ||
VALUES (2,'0x0002', '0x0002', '0x0002', '0x0002', now(), '0x0002', null, null, false, true)` | ||
|
||
// insert batch 2 | ||
_, err = db.Exec(insertBatch1) | ||
assert.NoError(t, err) | ||
} | ||
|
||
func (m migrationTest0016) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { | ||
var result int | ||
|
||
// Check column wip doesn't exists in state.batch table | ||
const getCheckedColumn = `SELECT count(*) FROM information_schema.columns WHERE table_name='batch' and column_name='checked'` | ||
row := db.QueryRow(getCheckedColumn) | ||
assert.NoError(t, row.Scan(&result)) | ||
assert.Equal(t, 0, result) | ||
} | ||
|
||
func TestMigration0016(t *testing.T) { | ||
runMigrationTest(t, 16, migrationTest0016{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.