From 1467ea392452323a38bc5b7a5b37d7ae425bcba5 Mon Sep 17 00:00:00 2001 From: Arijit Das Date: Thu, 9 Sep 2021 17:42:26 +0530 Subject: [PATCH] Fix state leaf key removed query. --- db/migrations/00014_create_stored_functions.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrations/00014_create_stored_functions.sql b/db/migrations/00014_create_stored_functions.sql index 0aa5c5f3..544cd715 100644 --- a/db/migrations/00014_create_stored_functions.sql +++ b/db/migrations/00014_create_stored_functions.sql @@ -18,14 +18,14 @@ $$ LANGUAGE SQL; -- +goose StatementEnd -- +goose StatementBegin --- returns if a state node at the provided path was removed in the range > the provided height and <= the provided block hash +-- returns if a state node at the provided path was removed in the range >= the provided height and <= the provided block hash CREATE OR REPLACE FUNCTION was_state_removed(path BYTEA, height BIGINT, hash VARCHAR(66)) RETURNS BOOLEAN AS $$ SELECT exists(SELECT 1 FROM eth.state_cids INNER JOIN eth.header_cids ON (state_cids.header_id = header_cids.id) WHERE state_path = path - AND block_number > height + AND block_number >= height AND block_number <= (SELECT block_number FROM eth.header_cids WHERE block_hash = hash)