forked from 0xPolygonHermez/zkevm-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.
Cherrypick/reorgs (0xPolygonHermez#3588)
* change number migration * add column checked on state.block * if no unchecked blocks return ErrNotFound * migration set to checked all but the block with number below max-1000 * add column checked on state.block (0xPolygonHermez#3543) * add column checked on state.block * if no unchecked blocks return ErrNotFound * migration set to checked all but the block with number below max-1000 * Feature/0xPolygonHermez#3549 reorgs improvement (0xPolygonHermez#3553) * New reorg function * mocks * linter * Synchronizer tests * new elderberry smc docker image * new image * logs * fix json rpc * fix * Test sync from empty block * Regular reorg case tested * linter * remove empty block + fix LatestSyncedBlockEmpty * Improve check reorgs when no block is received during the call * fix RPC error code for eth_estimateGas and eth_call for reverted tx and no return value; fix e2e test; * fix test * Extra unit test * fix reorg until genesis * disable parallel synchronization --------- Co-authored-by: tclemos <[email protected]> * migrations * Fix + remove empty blocks * unit test * linter * Fix + remove empty blocks (0xPolygonHermez#3564) * Fix + remove empty blocks * unit test * linter * Fix/0xPolygonHermez#3565 reorg (0xPolygonHermez#3566) * fix + logs * fix loop * Revert "fix + logs" This reverts commit 39ced69. * fix L1InfoRoot when an error happens during the process of the L1 information (0xPolygonHermez#3576) * fix * Comments + mock * avoid error from some L1providers when fromBlock is higher than toBlock * Revert some changes * comments * add L2BlockModulus to L1check * doc * fix dbTx = nil * fix unit tests * config * fix sync unit test * linter * fix config param typo * synchronizer: check l1blocks (0xPolygonHermez#3546) * wip * run on background L1block checker * fix lint and documentation * fix conflict * add unittest * more unittest * fix lint * increase timeout for async unittest * fix unittest * rename GetResponse for GetResult and fix uniitest * add a second gorutines for check the newest blocks * more unittest * add unittest and run also preCheck on launch * by default Precheck from FINALIZED and SAFE * fix unittest, apply PR comments * changes suggested by ARR552 in integration method * fix documentation * import new network-l1-mock from PR#3553 * import new network-l1-mock from PR#3553 * import new network-l1-mock from PR#3553 * import new network-l1-mock from PR#3553 * fix unittest * fix PR comments * fix error * checkReorgAndExecuteReset can't be call with lastEthBlockSynced=nil * add parentHash to error * fix error * merge 3553 fix unittest * fix unittest * fix wrong merge * adapt parallel reorg detection to flow * fix unit tests * fix log * allow use sync parallel mode --------- Co-authored-by: Alonso <[email protected]> * linter * comment check --------- Co-authored-by: tclemos <[email protected]>
- Loading branch information
Showing
66 changed files
with
6,564 additions
and
828 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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,81 +1,11 @@ | ||
-- +migrate Up | ||
CREATE TABLE state.blob_inner | ||
( | ||
blob_inner_num BIGINT PRIMARY KEY, | ||
data BYTEA, | ||
block_num BIGINT NOT NULL REFERENCES state.block (block_num) ON DELETE CASCADE | ||
); | ||
ALTER TABLE state.block | ||
ADD COLUMN IF NOT EXISTS checked BOOL NOT NULL DEFAULT FALSE; | ||
|
||
ALTER TABLE state.virtual_batch | ||
ADD COLUMN IF NOT EXISTS blob_inner_num BIGINT, -- REFERENCES state.blob_inner (blob_inner_num), | ||
ADD COLUMN IF NOT EXISTS prev_l1_it_root VARCHAR, | ||
ADD COLUMN IF NOT EXISTS prev_l1_it_index BIGINT; | ||
|
||
ALTER TABLE IF EXISTS state.proof RENAME TO batch_proof; | ||
|
||
ALTER TABLE state.batch_proof | ||
ADD COLUMN IF NOT EXISTS blob_inner_num BIGINT; -- NOT NULL REFERENCES state.blob_inner (blob_inner_num) ON DELETE CASCADE; | ||
|
||
CREATE TABLE state.blob_inner_proof | ||
( | ||
blob_inner_num BIGINT NOT NULL, -- REFERENCES state.blob_inner (blob_inner_num) ON DELETE CASCADE, | ||
proof_id VARCHAR, | ||
proof VARCHAR, | ||
input_prover VARCHAR, | ||
prover VARCHAR, | ||
prover_id VARCHAR, | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
generating_since TIMESTAMP WITH TIME ZONE, | ||
PRIMARY KEY (blob_inner_num) | ||
); | ||
|
||
CREATE TABLE state.blob_outer_proof | ||
( | ||
blob_outer_num BIGINT NOT NULL, -- REFERENCES state.blob_inner (blob_inner_num) ON DELETE CASCADE, | ||
blob_outer_num_final BIGINT NOT NULL, -- REFERENCES state.blob_inner (blob_inner_num) ON DELETE CASCADE, | ||
proof_id VARCHAR, | ||
proof VARCHAR, | ||
input_prover VARCHAR, | ||
prover VARCHAR, | ||
prover_id VARCHAR, | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
generating_since TIMESTAMP WITH TIME ZONE, | ||
PRIMARY KEY (blob_outer_num, blob_outer_num_final) | ||
); | ||
-- set block.checked to true for all blocks below max - 100 | ||
UPDATE state.block SET checked = true WHERE block_num <= (SELECT MAX(block_num) - 1000 FROM state.block); | ||
|
||
-- +migrate Down | ||
ALTER TABLE state.virtual_batch | ||
DROP COLUMN IF EXISTS blob_inner_num, | ||
DROP COLUMN IF EXISTS prev_l1_it_root, | ||
DROP COLUMN IF EXISTS prev_l1_it_index; | ||
|
||
DROP TABLE state.blob_outer_proof; | ||
|
||
DROP TABLE state.blob_inner_proof; | ||
|
||
DROP TABLE state.batch_proof; | ||
|
||
DROP TABLE state.blob_inner; | ||
|
||
CREATE TABLE state.proof | ||
( | ||
batch_num BIGINT NOT NULL REFERENCES state.batch (batch_num) ON DELETE CASCADE, | ||
batch_num_final BIGINT NOT NULL REFERENCES state.batch (batch_num) ON DELETE CASCADE, | ||
proof_id VARCHAR, | ||
proof VARCHAR, | ||
input_prover VARCHAR, | ||
prover VARCHAR, | ||
prover_id VARCHAR, | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
generating_since TIMESTAMP WITH TIME ZONE, | ||
PRIMARY KEY (batch_num, batch_num_final) | ||
); | ||
ALTER TABLE state.block | ||
DROP COLUMN IF EXISTS checked; | ||
|
||
ALTER TABLE state.virtual_batch | ||
DROP COLUMN IF EXISTS blob_inner_num, | ||
DROP COLUMN IF EXISTS prev_l1_it_root, | ||
DROP COLUMN IF EXISTS prev_l1_it_index; | ||
|
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 |
---|---|---|
@@ -1,25 +1,81 @@ | ||
-- +migrate Up | ||
CREATE TABLE state.blob_inner | ||
( | ||
blob_inner_num BIGINT PRIMARY KEY, | ||
data BYTEA, | ||
block_num BIGINT NOT NULL REFERENCES state.block (block_num) ON DELETE CASCADE | ||
); | ||
|
||
-- the update below fix the wrong receipt TX indexes | ||
WITH map_fix_tx_index AS ( | ||
SELECT t.l2_block_num AS block_num | ||
, t.hash AS tx_hash | ||
, r.tx_index AS current_index | ||
, (ROW_NUMBER() OVER (PARTITION BY t.l2_block_num ORDER BY r.tx_index))-1 AS correct_index | ||
FROM state.receipt r | ||
INNER JOIN state."transaction" t | ||
ON t.hash = r.tx_hash | ||
) | ||
UPDATE state.receipt AS r | ||
SET tx_index = m.correct_index | ||
FROM map_fix_tx_index m | ||
WHERE m.block_num = r.block_num | ||
AND m.tx_hash = r.tx_hash | ||
AND m.current_index = r.tx_index | ||
AND m.current_index != m.correct_index; | ||
ALTER TABLE state.virtual_batch | ||
ADD COLUMN IF NOT EXISTS blob_inner_num BIGINT, -- REFERENCES state.blob_inner (blob_inner_num), | ||
ADD COLUMN IF NOT EXISTS prev_l1_it_root VARCHAR, | ||
ADD COLUMN IF NOT EXISTS prev_l1_it_index BIGINT; | ||
|
||
ALTER TABLE IF EXISTS state.proof RENAME TO batch_proof; | ||
|
||
ALTER TABLE state.batch_proof | ||
ADD COLUMN IF NOT EXISTS blob_inner_num BIGINT; -- NOT NULL REFERENCES state.blob_inner (blob_inner_num) ON DELETE CASCADE; | ||
|
||
CREATE TABLE state.blob_inner_proof | ||
( | ||
blob_inner_num BIGINT NOT NULL, -- REFERENCES state.blob_inner (blob_inner_num) ON DELETE CASCADE, | ||
proof_id VARCHAR, | ||
proof VARCHAR, | ||
input_prover VARCHAR, | ||
prover VARCHAR, | ||
prover_id VARCHAR, | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
generating_since TIMESTAMP WITH TIME ZONE, | ||
PRIMARY KEY (blob_inner_num) | ||
); | ||
|
||
CREATE TABLE state.blob_outer_proof | ||
( | ||
blob_outer_num BIGINT NOT NULL, -- REFERENCES state.blob_inner (blob_inner_num) ON DELETE CASCADE, | ||
blob_outer_num_final BIGINT NOT NULL, -- REFERENCES state.blob_inner (blob_inner_num) ON DELETE CASCADE, | ||
proof_id VARCHAR, | ||
proof VARCHAR, | ||
input_prover VARCHAR, | ||
prover VARCHAR, | ||
prover_id VARCHAR, | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
generating_since TIMESTAMP WITH TIME ZONE, | ||
PRIMARY KEY (blob_outer_num, blob_outer_num_final) | ||
); | ||
|
||
-- +migrate Down | ||
ALTER TABLE state.virtual_batch | ||
DROP COLUMN IF EXISTS blob_inner_num, | ||
DROP COLUMN IF EXISTS prev_l1_it_root, | ||
DROP COLUMN IF EXISTS prev_l1_it_index; | ||
|
||
DROP TABLE state.blob_outer_proof; | ||
|
||
DROP TABLE state.blob_inner_proof; | ||
|
||
DROP TABLE state.batch_proof; | ||
|
||
DROP TABLE state.blob_inner; | ||
|
||
CREATE TABLE state.proof | ||
( | ||
batch_num BIGINT NOT NULL REFERENCES state.batch (batch_num) ON DELETE CASCADE, | ||
batch_num_final BIGINT NOT NULL REFERENCES state.batch (batch_num) ON DELETE CASCADE, | ||
proof_id VARCHAR, | ||
proof VARCHAR, | ||
input_prover VARCHAR, | ||
prover VARCHAR, | ||
prover_id VARCHAR, | ||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
generating_since TIMESTAMP WITH TIME ZONE, | ||
PRIMARY KEY (batch_num, batch_num_final) | ||
); | ||
|
||
-- no action is needed, the data fixed by the | ||
-- migrate up must remain fixed | ||
ALTER TABLE state.virtual_batch | ||
DROP COLUMN IF EXISTS blob_inner_num, | ||
DROP COLUMN IF EXISTS prev_l1_it_root, | ||
DROP COLUMN IF EXISTS prev_l1_it_index; | ||
|
Oops, something went wrong.