mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 01:05:47 +00:00
Add beacon.watch (#3362)
> This is currently a WIP and all features are subject to alteration or removal at any time. ## Overview The successor to #2873. Contains the backbone of `beacon.watch` including syncing code, the initial API, and several core database tables. See `watch/README.md` for more information, requirements and usage.
This commit is contained in:
0
watch/migrations/.gitkeep
Normal file
0
watch/migrations/.gitkeep
Normal file
@@ -0,0 +1,6 @@
|
||||
-- This file was automatically created by Diesel to setup helper functions
|
||||
-- and other internal bookkeeping. This file is safe to edit, any future
|
||||
-- changes will be added to existing projects as new migrations.
|
||||
|
||||
DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass);
|
||||
DROP FUNCTION IF EXISTS diesel_set_updated_at();
|
||||
36
watch/migrations/00000000000000_diesel_initial_setup/up.sql
Normal file
36
watch/migrations/00000000000000_diesel_initial_setup/up.sql
Normal file
@@ -0,0 +1,36 @@
|
||||
-- This file was automatically created by Diesel to setup helper functions
|
||||
-- and other internal bookkeeping. This file is safe to edit, any future
|
||||
-- changes will be added to existing projects as new migrations.
|
||||
|
||||
|
||||
|
||||
|
||||
-- Sets up a trigger for the given table to automatically set a column called
|
||||
-- `updated_at` whenever the row is modified (unless `updated_at` was included
|
||||
-- in the modified columns)
|
||||
--
|
||||
-- # Example
|
||||
--
|
||||
-- ```sql
|
||||
-- CREATE TABLE users (id SERIAL PRIMARY KEY, updated_at TIMESTAMP NOT NULL DEFAULT NOW());
|
||||
--
|
||||
-- SELECT diesel_manage_updated_at('users');
|
||||
-- ```
|
||||
CREATE OR REPLACE FUNCTION diesel_manage_updated_at(_tbl regclass) RETURNS VOID AS $$
|
||||
BEGIN
|
||||
EXECUTE format('CREATE TRIGGER set_updated_at BEFORE UPDATE ON %s
|
||||
FOR EACH ROW EXECUTE PROCEDURE diesel_set_updated_at()', _tbl);
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
|
||||
CREATE OR REPLACE FUNCTION diesel_set_updated_at() RETURNS trigger AS $$
|
||||
BEGIN
|
||||
IF (
|
||||
NEW IS DISTINCT FROM OLD AND
|
||||
NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at
|
||||
) THEN
|
||||
NEW.updated_at := current_timestamp;
|
||||
END IF;
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql;
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE canonical_slots
|
||||
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE canonical_slots (
|
||||
slot integer PRIMARY KEY,
|
||||
root bytea NOT NULL,
|
||||
skipped boolean NOT NULL,
|
||||
beacon_block bytea UNIQUE
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE beacon_blocks
|
||||
7
watch/migrations/2022-01-01-000001_beacon_blocks/up.sql
Normal file
7
watch/migrations/2022-01-01-000001_beacon_blocks/up.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE beacon_blocks (
|
||||
slot integer PRIMARY KEY REFERENCES canonical_slots(slot) ON DELETE CASCADE,
|
||||
root bytea REFERENCES canonical_slots(beacon_block) NOT NULL,
|
||||
parent_root bytea NOT NULL,
|
||||
attestation_count integer NOT NULL,
|
||||
transaction_count integer
|
||||
)
|
||||
1
watch/migrations/2022-01-01-000002_validators/down.sql
Normal file
1
watch/migrations/2022-01-01-000002_validators/down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE validators
|
||||
7
watch/migrations/2022-01-01-000002_validators/up.sql
Normal file
7
watch/migrations/2022-01-01-000002_validators/up.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE validators (
|
||||
index integer PRIMARY KEY,
|
||||
public_key bytea NOT NULL,
|
||||
status text NOT NULL,
|
||||
activation_epoch integer,
|
||||
exit_epoch integer
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE proposer_info
|
||||
5
watch/migrations/2022-01-01-000003_proposer_info/up.sql
Normal file
5
watch/migrations/2022-01-01-000003_proposer_info/up.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
CREATE TABLE proposer_info (
|
||||
slot integer PRIMARY KEY REFERENCES beacon_blocks(slot) ON DELETE CASCADE,
|
||||
proposer_index integer REFERENCES validators(index) ON DELETE CASCADE NOT NULL,
|
||||
graffiti text NOT NULL
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE active_config
|
||||
5
watch/migrations/2022-01-01-000004_active_config/up.sql
Normal file
5
watch/migrations/2022-01-01-000004_active_config/up.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
CREATE TABLE active_config (
|
||||
id integer PRIMARY KEY CHECK (id=1),
|
||||
config_name text NOT NULL,
|
||||
slots_per_epoch integer NOT NULL
|
||||
)
|
||||
1
watch/migrations/2022-01-01-000010_blockprint/down.sql
Normal file
1
watch/migrations/2022-01-01-000010_blockprint/down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE blockprint
|
||||
4
watch/migrations/2022-01-01-000010_blockprint/up.sql
Normal file
4
watch/migrations/2022-01-01-000010_blockprint/up.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
CREATE TABLE blockprint (
|
||||
slot integer PRIMARY KEY REFERENCES beacon_blocks(slot) ON DELETE CASCADE,
|
||||
best_guess text NOT NULL
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE block_rewards
|
||||
6
watch/migrations/2022-01-01-000011_block_rewards/up.sql
Normal file
6
watch/migrations/2022-01-01-000011_block_rewards/up.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE block_rewards (
|
||||
slot integer PRIMARY KEY REFERENCES beacon_blocks(slot) ON DELETE CASCADE,
|
||||
total integer NOT NULL,
|
||||
attestation_reward integer NOT NULL,
|
||||
sync_committee_reward integer NOT NULL
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE block_packing
|
||||
6
watch/migrations/2022-01-01-000012_block_packing/up.sql
Normal file
6
watch/migrations/2022-01-01-000012_block_packing/up.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
CREATE TABLE block_packing (
|
||||
slot integer PRIMARY KEY REFERENCES beacon_blocks(slot) ON DELETE CASCADE,
|
||||
available integer NOT NULL,
|
||||
included integer NOT NULL,
|
||||
prior_skip_slots integer NOT NULL
|
||||
)
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE suboptimal_attestations
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE suboptimal_attestations (
|
||||
epoch_start_slot integer CHECK (epoch_start_slot % 32 = 0) REFERENCES canonical_slots(slot) ON DELETE CASCADE,
|
||||
index integer NOT NULL REFERENCES validators(index) ON DELETE CASCADE,
|
||||
source boolean NOT NULL,
|
||||
head boolean NOT NULL,
|
||||
target boolean NOT NULL,
|
||||
PRIMARY KEY(epoch_start_slot, index)
|
||||
)
|
||||
2
watch/migrations/2022-01-01-000020_capella/down.sql
Normal file
2
watch/migrations/2022-01-01-000020_capella/down.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE beacon_blocks
|
||||
DROP COLUMN withdrawal_count;
|
||||
3
watch/migrations/2022-01-01-000020_capella/up.sql
Normal file
3
watch/migrations/2022-01-01-000020_capella/up.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE beacon_blocks
|
||||
ADD COLUMN withdrawal_count integer;
|
||||
|
||||
Reference in New Issue
Block a user