-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add log_poller_blocks migration and tests
- Loading branch information
1 parent
3d2f239
commit c2b2a28
Showing
5 changed files
with
59 additions
and
4 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
4 changes: 4 additions & 0 deletions
4
core/store/migrate/plugins/relayer/evm/log_poller_blocksDown.tmpl.sql
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,4 @@ | ||
INSERT INTO evm.log_poller_blocks (evm_chain_id, block_hash, block_number, created_at, block_timestamp, finalized_block_number) | ||
SELECT '{{ .ChainID }}', block_hash, block_number, created_at, block_timestamp, finalized_block_number FROM {{ .Schema }}.log_poller_blocks; | ||
|
||
DROP TABLE {{ .Schema }}.log_poller_blocks; |
18 changes: 18 additions & 0 deletions
18
core/store/migrate/plugins/relayer/evm/log_poller_blocksUp.tmpl.sql
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,18 @@ | ||
CREATE TABLE {{ .Schema }}.log_poller_blocks ( | ||
-- evm_chain_id numeric(78) NOT NULL, | ||
block_hash bytea NOT NULL, | ||
block_number int8 NOT NULL, | ||
created_at timestamptz NOT NULL, | ||
block_timestamp timestamptz NOT NULL, | ||
finalized_block_number int8 DEFAULT 0 NOT NULL, | ||
CONSTRAINT block_hash_uniq UNIQUE (block_hash), | ||
CONSTRAINT log_poller_blocks_block_number_check CHECK ((block_number > 0)), | ||
CONSTRAINT log_poller_blocks_finalized_block_number_check CHECK ((finalized_block_number >= 0)), | ||
CONSTRAINT log_poller_blocks_pkey PRIMARY KEY (block_number) | ||
); | ||
CREATE INDEX idx_evm_log_poller_blocks_order_by_block ON {{ .Schema }}.log_poller_blocks USING btree (block_number DESC); | ||
|
||
INSERT INTO {{ .Schema }}.log_poller_blocks (block_hash, block_number, created_at, block_timestamp, finalized_block_number) | ||
SELECT block_hash, block_number, created_at, block_timestamp, finalized_block_number FROM evm.log_poller_blocks WHERE evm_chain_id = '{{ .ChainID}}'; | ||
|
||
DELETE FROM evm.log_poller_blocks WHERE evm_chain_id = '{{ .ChainID}}'; |
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
4 changes: 4 additions & 0 deletions
4
core/store/migrate/plugins/relayer/evm/testdata/log_poller_blocks/initial.sql
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,4 @@ | ||
INSERT INTO evm.log_poller_blocks (evm_chain_id,block_hash,block_number,created_at,block_timestamp,finalized_block_number) VALUES | ||
(0,decode('303132333435363738393061626364656630313233343536373839616263646566','hex'),1,'2024-06-26 17:14:14.633973-06','2024-06-26 17:14:14.633973-06',0), | ||
(0,decode('6162636465663031323334353637383961626364656630313233343536373839','hex'),2,'2024-06-26 17:14:18.605884-06','2024-06-26 17:14:18.605884-06',1), | ||
(1,decode('303132333435363738393061626364656630313233343536373839616263646566','hex'),1,'2024-06-26 17:14:32.572612-06','2024-06-26 17:14:32.572612-06',0); |