forked from okx/xlayer-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: etrog: synchronize trusted batches (0xPolygonHermez#2871)
* docker + genesis * new prover image * wip: isolate syncTrustedState code * Feature/0xPolygonHermez#2840 l1 info root (0xPolygonHermez#2865) * Keep siblings in memory + AddLeaf + tests * l1infotree state and synchronizer * synchronizer:moved common objects to common package * pre-execution trs use ETROG * fix generateReceipt. Use StoreL2Block from the state (0xPolygonHermez#2880) * refactor init/get wip batch. Add SHA256 counter. Fixes (0xPolygonHermez#2882) * process etrog batches with ExecuteBatchV2 * Fix final StateRoot for batch when it is closed (0xPolygonHermez#2887) * removed timestamp comparation on virtualization of batches * timestamp check * use time.Now() as minTimestamp for open a trusted batch --------- Co-authored-by: Alonso <[email protected]> Co-authored-by: Alonso Rodriguez <[email protected]> Co-authored-by: agnusmor <[email protected]> Co-authored-by: tclemos <[email protected]> Co-authored-by: Toni Ramírez <[email protected]> Co-authored-by: agnusmor <[email protected]>
- Loading branch information
1 parent
f77d582
commit 1a229c6
Showing
72 changed files
with
3,466 additions
and
2,974 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- +migrate Up | ||
ALTER TABLE pool.transaction | ||
ADD COLUMN l2_hash VARCHAR UNIQUE, | ||
ADD COLUMN used_sha256_hashes INTEGER; | ||
CREATE INDEX IF NOT EXISTS idx_transaction_l2_hash ON pool.transaction (l2_hash); | ||
|
||
-- +migrate Down | ||
DROP INDEX IF EXISTS pool.idx_transaction_l2_hash; | ||
ALTER TABLE pool.transaction | ||
DROP COLUMN l2_hash, | ||
DROP COLUMN used_sha256_hashes; | ||
|
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,63 @@ | ||
package pool_migrations_test | ||
|
||
import ( | ||
"database/sql" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// this migration changes length of the token name | ||
type migrationTest0012 struct{} | ||
|
||
func (m migrationTest0012) InsertData(db *sql.DB) error { | ||
const insertTx = ` | ||
INSERT INTO pool.transaction (hash, ip, received_at, from_address) | ||
VALUES ('0x0001', '127.0.0.1', '2023-12-07', '0x0011')` | ||
|
||
_, err := db.Exec(insertTx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
var indexesMigration12 = []string{ | ||
"idx_transaction_l2_hash", | ||
} | ||
|
||
func (m migrationTest0012) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { | ||
// Check indexes adding | ||
for _, idx := range indexesMigration12 { | ||
// getIndex | ||
const getIndex = `SELECT count(*) FROM pg_indexes WHERE indexname = $1;` | ||
row := db.QueryRow(getIndex, idx) | ||
var result int | ||
assert.NoError(t, row.Scan(&result)) | ||
assert.Equal(t, 1, result) | ||
} | ||
|
||
const insertTx = ` | ||
INSERT INTO pool.transaction (hash, ip, received_at, from_address, used_sha256_hashes) | ||
VALUES ('0x0002', '127.0.0.1', '2023-12-07', '0x0022', 222)` | ||
|
||
_, err := db.Exec(insertTx) | ||
assert.NoError(t, err) | ||
} | ||
|
||
func (m migrationTest0012) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { | ||
// Check indexes removing | ||
for _, idx := range indexesMigration12 { | ||
// getIndex | ||
const getIndex = `SELECT count(*) FROM pg_indexes WHERE indexname = $1;` | ||
row := db.QueryRow(getIndex, idx) | ||
var result int | ||
assert.NoError(t, row.Scan(&result)) | ||
assert.Equal(t, 0, result) | ||
} | ||
} | ||
|
||
func TestMigration0012(t *testing.T) { | ||
runMigrationTest(t, 12, migrationTest0012{}) | ||
} |
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.