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.
Add reserved zk counters to pool transactions (0xPolygonHermez#3346)
* add reserved zk counters to pool transaction * add reserved zk counters to pool transaction * correct migration test
- Loading branch information
1 parent
5c2fcff
commit a039a0a
Showing
8 changed files
with
162 additions
and
35 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 pool.transaction | ||
ADD COLUMN reserved_zkcounters jsonb; | ||
|
||
-- +migrate Down | ||
ALTER TABLE pool.transaction | ||
DROP COLUMN reserved_zkcounters; |
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,50 @@ | ||
package pool_migrations_test | ||
|
||
import ( | ||
"database/sql" | ||
"testing" | ||
|
||
"github.com/0xPolygonHermez/zkevm-node/state" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// this migration adds reserved_zkcounters to the transaction | ||
type migrationTest0013 struct{} | ||
|
||
func (m migrationTest0013) InsertData(db *sql.DB) error { | ||
return nil | ||
} | ||
|
||
func (m migrationTest0013) RunAssertsAfterMigrationUp(t *testing.T, db *sql.DB) { | ||
var reserved_zkcounters = state.ZKCounters{ | ||
GasUsed: 0, | ||
KeccakHashes: 1, | ||
PoseidonHashes: 2, | ||
} | ||
|
||
const insertTx = ` | ||
INSERT INTO pool.transaction (hash, ip, received_at, from_address, reserved_zkcounters) | ||
VALUES ('0x0001', '127.0.0.1', '2023-12-07', '0x0011', $1)` | ||
|
||
_, err := db.Exec(insertTx, reserved_zkcounters) | ||
require.NoError(t, err) | ||
} | ||
|
||
func (m migrationTest0013) RunAssertsAfterMigrationDown(t *testing.T, db *sql.DB) { | ||
var reserved_zkcounters = state.ZKCounters{ | ||
GasUsed: 0, | ||
KeccakHashes: 1, | ||
PoseidonHashes: 2, | ||
} | ||
|
||
const insertTx = ` | ||
INSERT INTO pool.transaction (hash, ip, received_at, from_address, reserved_zkcounters) | ||
VALUES ('0x0001', '127.0.0.1', '2023-12-07', '0x0011', $1)` | ||
|
||
_, err := db.Exec(insertTx, reserved_zkcounters) | ||
require.Error(t, err) | ||
} | ||
|
||
func TestMigration0013(t *testing.T) { | ||
runMigrationTest(t, 13, migrationTest0013{}) | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
synchronizer/l2_sync/l2_shared/mocks/state_sync_trusted_state_executor_selector.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.