-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
101 additions
and
2 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
18 changes: 18 additions & 0 deletions
18
cmd/migration/postgres/migrations/evidence/000001_initialize_tables.down.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 @@ | ||
DROP INDEX IF EXISTS payload_delivered_slot_idx; | ||
DROP INDEX IF EXISTS payload_delivered_blockhash_idx; | ||
DROP INDEX IF EXISTS payload_delivered_blocknumber_idx; | ||
DROP INDEX IF EXISTS payload_delivered_proposerpubkey_idx; | ||
DROP INDEX IF EXISTS payload_delivered_builderpubkey_idx; | ||
DROP INDEX IF EXISTS payload_delivered_executionpayloadid_idx; | ||
DROP INDEX IF EXISTS payload_delivered_value_idx; | ||
DROP TABLE IF EXISTS payload_delivered; | ||
|
||
DROP INDEX IF EXISTS builder_block_submission_slot_idx; | ||
DROP INDEX IF EXISTS builder_block_submission_blockhash_idx; | ||
DROP INDEX IF EXISTS builder_block_submission_blocknumber_idx; | ||
DROP INDEX IF EXISTS builder_block_submission_builderpubkey_idx; | ||
DROP INDEX IF EXISTS builder_block_submission_simsuccess_idx; | ||
DROP INDEX IF EXISTS builder_block_submission_mostprofit_idx; | ||
DROP INDEX IF EXISTS builder_block_submission_executionpayloadid_idx; | ||
DROP TABLE IF EXISTS builder_block_submission; | ||
|
63 changes: 63 additions & 0 deletions
63
cmd/migration/postgres/migrations/evidence/000001_initialize_tables.up.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,63 @@ | ||
CREATE TABLE IF NOT EXISTS builder_block_submission ( | ||
slot bigint NOT NULL, | ||
parent_hash varchar(66) NOT NULL, | ||
block_hash varchar(66) NOT NULL, | ||
|
||
builder_pubkey varchar(98) NOT NULL, | ||
proposer_pubkey varchar(98) NOT NULL, | ||
proposer_fee_recipient varchar(42) NOT NULL, | ||
|
||
gas_used bigint NOT NULL, | ||
gas_limit bigint NOT NULL, | ||
|
||
value NUMERIC(48, 0), | ||
|
||
epoch bigint NOT NULL, | ||
block_number bigint NOT NULL, | ||
was_most_profitable boolean NOT NULL, | ||
block_time timestamp , | ||
|
||
inserted_at timestamp NOT NULL default current_timestamp, | ||
|
||
UNIQUE (slot, proposer_pubkey, block_hash) | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS builder_block_submission_slot_idx ON builder_block_submission("slot"); | ||
CREATE INDEX IF NOT EXISTS builder_block_submission_slts_idx ON builder_block_submission("slot", "block_time"); | ||
CREATE INDEX IF NOT EXISTS builder_block_submission_ts_idx ON builder_block_submission("block_time"); | ||
CREATE INDEX IF NOT EXISTS builder_block_submission_blockhash_idx ON builder_block_submission("block_hash"); | ||
CREATE INDEX IF NOT EXISTS builder_block_submission_blocknumber_idx ON builder_block_submission("block_number"); | ||
CREATE INDEX IF NOT EXISTS builder_block_submission_builderpubkey_idx ON builder_block_submission("builder_pubkey"); | ||
|
||
|
||
CREATE TABLE IF NOT EXISTS payload_delivered ( | ||
builder_pubkey varchar(98) NOT NULL, | ||
proposer_pubkey varchar(98) NOT NULL, | ||
proposer_fee_recipient varchar(42) NOT NULL, | ||
|
||
epoch bigint NOT NULL, | ||
slot bigint NOT NULL, | ||
|
||
|
||
parent_hash varchar(66) NOT NULL, | ||
block_hash varchar(66) NOT NULL, | ||
block_number bigint NOT NULL, | ||
|
||
gas_used bigint NOT NULL, | ||
gas_limit bigint NOT NULL, | ||
|
||
value NUMERIC(48, 0), | ||
|
||
inserted_at timestamp NOT NULL default current_timestamp, | ||
|
||
UNIQUE (slot, proposer_pubkey, block_hash) | ||
); | ||
|
||
CREATE INDEX IF NOT EXISTS payload_delivered_slot_idx ON payload_delivered("slot"); | ||
CREATE INDEX IF NOT EXISTS payload_delivered_slbh_idx ON payload_delivered("slot","inserted_at"); | ||
CREATE INDEX IF NOT EXISTS payload_delivered_blockhash_idx ON payload_delivered("block_hash"); | ||
CREATE INDEX IF NOT EXISTS payload_delivered_blocknumber_idx ON payload_delivered("block_number"); | ||
CREATE INDEX IF NOT EXISTS payload_delivered_proposerpubkey_idx ON payload_delivered("proposer_pubkey"); | ||
CREATE INDEX IF NOT EXISTS payload_delivered_builderpubkey_idx ON payload_delivered("builder_pubkey"); | ||
CREATE INDEX IF NOT EXISTS payload_delivered_value_idx ON payload_delivered("value"); | ||
|
1 change: 1 addition & 0 deletions
1
cmd/migration/postgres/migrations/evidence/000002_add_num_tx.down.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 @@ | ||
ALTER TABLE payload_delivered DROP COLUMN IF EXISTS num_tx; |
1 change: 1 addition & 0 deletions
1
cmd/migration/postgres/migrations/evidence/000002_add_num_tx.up.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 @@ | ||
ALTER TABLE payload_delivered ADD COLUMN IF NOT EXISTS num_tx integer NOT NULL DEFAULT 0; |
1 change: 1 addition & 0 deletions
1
cmd/migration/postgres/migrations/evidence/000003_add_num_tx_to_proposed_blocks.down.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 @@ | ||
ALTER TABLE builder_block_submission DROP COLUMN IF EXISTS num_tx; |
1 change: 1 addition & 0 deletions
1
cmd/migration/postgres/migrations/evidence/000003_add_num_tx_to_proposed_blocks.up.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 @@ | ||
ALTER TABLE builder_block_submission ADD COLUMN IF NOT EXISTS num_tx integer NOT NULL DEFAULT 0; |
7 changes: 7 additions & 0 deletions
7
cmd/migration/postgres/migrations/evidence/000004_add_multi_relays.down.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,7 @@ | ||
ALTER TABLE payload_delivered DROP COLUMN IF EXISTS relay_id; | ||
ALTER TABLE payload_delivered DROP CONSTRAINT IF EXISTS payload_delivered_relay_id_slot_proposer_pubkey_block_hash_key; | ||
ALTER TABLE payload_delivered ADD UNIQUE(slot, proposer_pubkey, block_hash); | ||
|
||
ALTER TABLE builder_block_submission DROP COLUMN IF EXISTS relay_id; | ||
ALTER TABLE builder_block_submission DROP CONSTRAINT IF EXISTS builder_block_submission_relay_id_slot_proposer_pubkey_block_hash_key; | ||
ALTER TABLE builder_block_submission ADD UNIQUE(slot, proposer_pubkey, block_hash); |
7 changes: 7 additions & 0 deletions
7
cmd/migration/postgres/migrations/evidence/000004_add_multi_relays.up.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,7 @@ | ||
ALTER TABLE payload_delivered ADD COLUMN IF NOT EXISTS relay_id smallint NOT NULL DEFAULT 0; | ||
ALTER TABLE payload_delivered DROP CONSTRAINT IF EXISTS payload_delivered_slot_proposer_pubkey_block_hash_key; | ||
ALTER TABLE payload_delivered ADD UNIQUE(relay_id, slot, proposer_pubkey, block_hash); | ||
|
||
ALTER TABLE builder_block_submission ADD COLUMN IF NOT EXISTS relay_id smallint NOT NULL DEFAULT 0; | ||
ALTER TABLE builder_block_submission DROP CONSTRAINT IF EXISTS builder_block_submission_slot_proposer_pubkey_block_hash_key; | ||
ALTER TABLE builder_block_submission ADD UNIQUE(relay_id, slot, proposer_pubkey, block_hash); |