diff --git a/deploy/local/docker-compose/vector-kafka-clickhouse.yaml b/deploy/local/docker-compose/vector-kafka-clickhouse.yaml index f753cfb0..17dc91db 100644 --- a/deploy/local/docker-compose/vector-kafka-clickhouse.yaml +++ b/deploy/local/docker-compose/vector-kafka-clickhouse.yaml @@ -986,14 +986,6 @@ transforms: } } - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } .slot = .data.message.slot slot_start_date_time, err = parse_timestamp(.meta.client.additional_data.slot.start_date_time, format: "%+"); if err == null { @@ -1038,14 +1030,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_block_proposer_slashing source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } .slot = .meta.client.additional_data.block.slot.number slot_start_date_time, err = parse_timestamp(.meta.client.additional_data.block.slot.start_date_time, format: "%+"); if err == null { @@ -1087,14 +1071,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_block_attester_slashing source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } .slot = .meta.client.additional_data.block.slot.number slot_start_date_time, err = parse_timestamp(.meta.client.additional_data.block.slot.start_date_time, format: "%+"); if err == null { @@ -1142,14 +1118,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_block_bls_to_execution_change source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } .slot = .meta.client.additional_data.block.slot.number slot_start_date_time, err = parse_timestamp(.meta.client.additional_data.block.slot.start_date_time, format: "%+"); if err == null { @@ -1183,14 +1151,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_block_execution_transaction source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } .slot = .meta.client.additional_data.block.slot.number slot_start_date_time, err = parse_timestamp(.meta.client.additional_data.block.slot.start_date_time, format: "%+"); if err == null { @@ -1238,14 +1198,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_block_voluntary_exit source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } .slot = .meta.client.additional_data.block.slot.number slot_start_date_time, err = parse_timestamp(.meta.client.additional_data.block.slot.start_date_time, format: "%+"); if err == null { @@ -1278,14 +1230,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_block_deposit source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } .slot = .meta.client.additional_data.block.slot.number slot_start_date_time, err = parse_timestamp(.meta.client.additional_data.block.slot.start_date_time, format: "%+"); if err == null { @@ -1320,14 +1264,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_block_withdrawal source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } .slot = .meta.client.additional_data.block.slot.number slot_start_date_time, err = parse_timestamp(.meta.client.additional_data.block.slot.start_date_time, format: "%+"); if err == null { @@ -1361,14 +1297,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_blob_sidecar source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } .slot = .meta.client.additional_data.slot.number slot_start_date_time, err = parse_timestamp(.meta.client.additional_data.slot.start_date_time, format: "%+"); if err == null { @@ -1405,15 +1333,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_validators source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } - epoch_start_date_time, err = parse_timestamp(.meta.client.additional_data.epoch.start_date_time, format: "%+"); if err == null { .epoch_start_date_time = to_unix_timestamp(epoch_start_date_time) @@ -1429,7 +1348,6 @@ transforms: for_each(array!(.data.validators)) -> |_index, validator| { event = { - "event_date_time": .event_date_time, "updated_date_time": .updated_date_time, "meta_client_name": .meta_client_name, "meta_client_id": .meta_client_id, @@ -1492,15 +1410,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_validators source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } - epoch_start_date_time, err = parse_timestamp(.meta.client.additional_data.epoch.start_date_time, format: "%+"); if err == null { .epoch_start_date_time = to_unix_timestamp(epoch_start_date_time) @@ -1516,7 +1425,6 @@ transforms: for_each(array!(.data.validators)) -> |_index, validator| { events = push(events, { - "event_date_time": .event_date_time, "updated_date_time": .updated_date_time, "meta_client_name": .meta_client_name, "meta_client_id": .meta_client_id, @@ -1552,15 +1460,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_validators source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } - epoch_start_date_time, err = parse_timestamp(.meta.client.additional_data.epoch.start_date_time, format: "%+"); if err == null { .epoch_start_date_time = to_unix_timestamp(epoch_start_date_time) @@ -1576,7 +1475,6 @@ transforms: for_each(array!(.data.validators)) -> |_index, validator| { events = push(events, { - "event_date_time": .event_date_time, "updated_date_time": .updated_date_time, "meta_client_name": .meta_client_name, "meta_client_id": .meta_client_id, @@ -1671,14 +1569,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_proposer_duty source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } .slot = .meta.client.additional_data.slot.number slot_start_date_time, err = parse_timestamp(.meta.client.additional_data.slot.start_date_time, format: "%+"); if err == null { @@ -1708,14 +1598,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_block_elaborated_attestation source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } .block_slot = .meta.client.additional_data.block.slot.number block_slot_start_date_time, err = parse_timestamp(.meta.client.additional_data.block.slot.start_date_time, format: "%+"); if err == null { @@ -1825,14 +1707,6 @@ transforms: inputs: - xatu_server_events_router.canonical_beacon_committee source: |- - event_date_time, err = parse_timestamp(.event.date_time, format: "%+"); - if err == null { - .event_date_time = to_unix_timestamp(event_date_time, unit: "milliseconds") - } else { - .error = err - .error_description = "failed to parse event date time" - log(., level: "error", rate_limit_secs: 60) - } .slot = .data.slot slot_start_date_time, err = parse_timestamp(.meta.client.additional_data.slot.start_date_time, format: "%+"); if err == null { diff --git a/deploy/migrations/clickhouse/046_remove_canonical_event_time.down.sql b/deploy/migrations/clickhouse/046_remove_canonical_event_time.down.sql new file mode 100644 index 00000000..77244a81 --- /dev/null +++ b/deploy/migrations/clickhouse/046_remove_canonical_event_time.down.sql @@ -0,0 +1,294 @@ +DROP TABLE IF EXISTS default.canonical_beacon_blob_sidecar ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_attester_slashing ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_bls_to_execution_change ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_deposit ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_execution_transaction ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_proposer_slashing ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_voluntary_exit ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_withdrawal ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_elaborated_attestation ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_proposer_duty ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_validators ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_validators_pubkeys ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_validators_withdrawal_credentials ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_committee ON CLUSTER '{cluster}' SYNC; + +ALTER TABLE + default.canonical_beacon_blob_sidecar_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_block_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_block_attester_slashing_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_block_bls_to_execution_change_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_block_deposit_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_block_execution_transaction_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_block_proposer_slashing_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_block_voluntary_exit_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_block_withdrawal_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_elaborated_attestation_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_proposer_duty_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_validators_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_validators_pubkeys_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_validators_withdrawal_credentials_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +ALTER TABLE + default.canonical_beacon_committee_local ON CLUSTER '{cluster}' +ADD + COLUMN event_date_time DateTime64(3) COMMENT 'When the client fetched the data from the beacon node' CODEC(DoubleDelta, ZSTD(1)); + +CREATE TABLE default.canonical_beacon_blob_sidecar ON CLUSTER '{cluster}' AS default.canonical_beacon_blob_sidecar_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_blob_sidecar_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + blob_index + ) +); + +CREATE TABLE default.canonical_beacon_block ON CLUSTER '{cluster}' AS default.canonical_beacon_block_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_local, + cityHash64( + slot_start_date_time, + meta_network_name + ) +); + +CREATE TABLE default.canonical_beacon_block_attester_slashing ON CLUSTER '{cluster}' AS default.canonical_beacon_block_attester_slashing_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_attester_slashing_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + attestation_1_attesting_indices, + attestation_2_attesting_indices, + attestation_1_data_slot, + attestation_2_data_slot, + attestation_1_data_beacon_block_root, + attestation_2_data_beacon_block_root + ) +); + +CREATE TABLE default.canonical_beacon_block_bls_to_execution_change ON CLUSTER '{cluster}' AS default.canonical_beacon_block_bls_to_execution_change_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_bls_to_execution_change_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + exchanging_message_validator_index, + exchanging_message_from_bls_pubkey, + exchanging_message_to_execution_address + ) +); + +CREATE TABLE default.canonical_beacon_block_deposit ON CLUSTER '{cluster}' AS default.canonical_beacon_block_deposit_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_deposit_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + deposit_data_pubkey, + deposit_proof + ) +); + +CREATE TABLE default.canonical_beacon_block_execution_transaction ON CLUSTER '{cluster}' AS default.canonical_beacon_block_execution_transaction_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_execution_transaction_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + position, + hash, + nonce + ) +); + +CREATE TABLE default.canonical_beacon_block_proposer_slashing ON CLUSTER '{cluster}' AS default.canonical_beacon_block_proposer_slashing_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_proposer_slashing_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + signed_header_1_message_slot, + signed_header_2_message_slot, + signed_header_1_message_proposer_index, + signed_header_2_message_proposer_index, + signed_header_1_message_body_root, + signed_header_2_message_body_root + ) +); + +CREATE TABLE default.canonical_beacon_block_voluntary_exit ON CLUSTER '{cluster}' AS default.canonical_beacon_block_voluntary_exit_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_voluntary_exit_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + voluntary_exit_message_epoch, + voluntary_exit_message_validator_index + ) +); + +CREATE TABLE default.canonical_beacon_block_withdrawal ON CLUSTER '{cluster}' AS default.canonical_beacon_block_withdrawal_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_withdrawal_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + withdrawal_index, + withdrawal_validator_index + ) +); + +CREATE TABLE default.canonical_beacon_elaborated_attestation ON CLUSTER '{cluster}' AS default.canonical_beacon_elaborated_attestation_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_elaborated_attestation_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + block_slot, + position_in_block, + beacon_block_root, + slot, + committee_index, + source_root, + target_root + ) +); + +CREATE TABLE default.canonical_beacon_proposer_duty ON CLUSTER '{cluster}' AS default.canonical_beacon_proposer_duty_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_proposer_duty_local, + cityHash64( + slot_start_date_time, + meta_network_name, + proposer_validator_index, + proposer_pubkey + ) +); + +CREATE TABLE default.canonical_beacon_validators ON CLUSTER '{cluster}' AS default.canonical_beacon_validators_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_validators_local, + cityHash64( + epoch_start_date_time, + meta_network_name, + `index`, + `status` + ) +); + +CREATE TABLE default.canonical_beacon_validators_pubkeys on cluster '{cluster}' AS default.canonical_beacon_validators_pubkeys_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_validators_pubkeys_local, + cityHash64(`index`, meta_network_name) +); + +CREATE TABLE default.canonical_beacon_validators_withdrawal_credentials on cluster '{cluster}' AS default.canonical_beacon_validators_withdrawal_credentials_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_validators_withdrawal_credentials_local, + cityHash64(`index`, meta_network_name) +); + +CREATE TABLE default.canonical_beacon_committee ON CLUSTER '{cluster}' AS default.canonical_beacon_committee_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_committee_local, + cityHash64( + slot_start_date_time, + meta_network_name, + committee_index + ) +); \ No newline at end of file diff --git a/deploy/migrations/clickhouse/046_remove_canonical_event_time.up.sql b/deploy/migrations/clickhouse/046_remove_canonical_event_time.up.sql new file mode 100644 index 00000000..0fadf779 --- /dev/null +++ b/deploy/migrations/clickhouse/046_remove_canonical_event_time.up.sql @@ -0,0 +1,264 @@ +DROP TABLE IF EXISTS default.canonical_beacon_blob_sidecar ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_attester_slashing ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_bls_to_execution_change ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_deposit ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_execution_transaction ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_proposer_slashing ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_voluntary_exit ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_block_withdrawal ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_elaborated_attestation ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_proposer_duty ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_validators ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_validators_pubkeys ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_validators_withdrawal_credentials ON CLUSTER '{cluster}' SYNC; + +DROP TABLE IF EXISTS default.canonical_beacon_committee ON CLUSTER '{cluster}' SYNC; + +ALTER TABLE + default.canonical_beacon_blob_sidecar_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_block_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_block_attester_slashing_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_block_bls_to_execution_change_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_block_deposit_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_block_execution_transaction_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_block_proposer_slashing_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_block_voluntary_exit_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_block_withdrawal_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_elaborated_attestation_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_proposer_duty_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_validators_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_validators_pubkeys_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_validators_withdrawal_credentials_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +ALTER TABLE + default.canonical_beacon_committee_local ON CLUSTER '{cluster}' DROP COLUMN event_date_time; + +CREATE TABLE default.canonical_beacon_blob_sidecar ON CLUSTER '{cluster}' AS default.canonical_beacon_blob_sidecar_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_blob_sidecar_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + blob_index + ) +) COMMENT 'Contains a blob sidecar from a beacon block.'; + +CREATE TABLE default.canonical_beacon_block ON CLUSTER '{cluster}' AS default.canonical_beacon_block_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_local, + cityHash64( + slot_start_date_time, + meta_network_name + ) +) COMMENT 'Contains beacon block from a beacon node.'; + +CREATE TABLE default.canonical_beacon_block_attester_slashing ON CLUSTER '{cluster}' AS default.canonical_beacon_block_attester_slashing_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_attester_slashing_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + attestation_1_attesting_indices, + attestation_2_attesting_indices, + attestation_1_data_slot, + attestation_2_data_slot, + attestation_1_data_beacon_block_root, + attestation_2_data_beacon_block_root + ) +) COMMENT 'Contains attester slashing from a beacon block.'; + +CREATE TABLE default.canonical_beacon_block_bls_to_execution_change ON CLUSTER '{cluster}' AS default.canonical_beacon_block_bls_to_execution_change_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_bls_to_execution_change_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + exchanging_message_validator_index, + exchanging_message_from_bls_pubkey, + exchanging_message_to_execution_address + ) +) COMMENT 'Contains bls to execution change from a beacon block.'; + +CREATE TABLE default.canonical_beacon_block_deposit ON CLUSTER '{cluster}' AS default.canonical_beacon_block_deposit_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_deposit_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + deposit_data_pubkey, + deposit_proof + ) +) COMMENT 'Contains a deposit from a beacon block.'; + +CREATE TABLE default.canonical_beacon_block_execution_transaction ON CLUSTER '{cluster}' AS default.canonical_beacon_block_execution_transaction_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_execution_transaction_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + position, + hash, + nonce + ) +) COMMENT 'Contains execution transaction from a beacon block.'; + +CREATE TABLE default.canonical_beacon_block_proposer_slashing ON CLUSTER '{cluster}' AS default.canonical_beacon_block_proposer_slashing_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_proposer_slashing_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + signed_header_1_message_slot, + signed_header_2_message_slot, + signed_header_1_message_proposer_index, + signed_header_2_message_proposer_index, + signed_header_1_message_body_root, + signed_header_2_message_body_root + ) +) COMMENT 'Contains proposer slashing from a beacon block.'; + +CREATE TABLE default.canonical_beacon_block_voluntary_exit ON CLUSTER '{cluster}' AS default.canonical_beacon_block_voluntary_exit_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_voluntary_exit_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + voluntary_exit_message_epoch, + voluntary_exit_message_validator_index + ) +) COMMENT 'Contains a voluntary exit from a beacon block.'; + +CREATE TABLE default.canonical_beacon_block_withdrawal ON CLUSTER '{cluster}' AS default.canonical_beacon_block_withdrawal_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_block_withdrawal_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + withdrawal_index, + withdrawal_validator_index + ) +) COMMENT 'Contains a withdrawal from a beacon block.'; + +CREATE TABLE default.canonical_beacon_elaborated_attestation ON CLUSTER '{cluster}' AS default.canonical_beacon_elaborated_attestation_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_elaborated_attestation_local, + cityHash64( + slot_start_date_time, + meta_network_name, + block_root, + block_slot, + position_in_block, + beacon_block_root, + slot, + committee_index, + source_root, + target_root + ) +) COMMENT 'Contains elaborated attestations from beacon blocks.'; + +CREATE TABLE default.canonical_beacon_proposer_duty ON CLUSTER '{cluster}' AS default.canonical_beacon_proposer_duty_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_proposer_duty_local, + cityHash64( + slot_start_date_time, + meta_network_name, + proposer_validator_index, + proposer_pubkey + ) +) COMMENT 'Contains a proposer duty from a beacon block.'; + +CREATE TABLE default.canonical_beacon_validators ON CLUSTER '{cluster}' AS default.canonical_beacon_validators_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_validators_local, + cityHash64( + epoch_start_date_time, + meta_network_name, + `index`, + `status` + ) +) COMMENT 'Contains a validator state for an epoch.'; + +CREATE TABLE default.canonical_beacon_validators_pubkeys on cluster '{cluster}' AS default.canonical_beacon_validators_pubkeys_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_validators_pubkeys_local, + cityHash64(`index`, meta_network_name) +) COMMENT 'Contains a validator pubkeys for an epoch.'; + +CREATE TABLE default.canonical_beacon_validators_withdrawal_credentials on cluster '{cluster}' AS default.canonical_beacon_validators_withdrawal_credentials_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_validators_withdrawal_credentials_local, + cityHash64(`index`, meta_network_name) +) COMMENT 'Contains a validator withdrawal credentials for an epoch.'; + +CREATE TABLE default.canonical_beacon_committee ON CLUSTER '{cluster}' AS default.canonical_beacon_committee_local ENGINE = Distributed( + '{cluster}', + default, + canonical_beacon_committee_local, + cityHash64( + slot_start_date_time, + meta_network_name, + committee_index + ) +) COMMENT 'Contains canonical beacon API /eth/v1/beacon/committees data.';