diff --git a/db/migrations/00016_create_stored_procedures.sql b/db/migrations/00016_create_stored_procedures.sql index 7792ca3..3cf35d8 100644 --- a/db/migrations/00016_create_stored_procedures.sql +++ b/db/migrations/00016_create_stored_procedures.sql @@ -1,6 +1,6 @@ -- +goose Up -- +goose StatementBegin --- returns if the state leaf key is vacated (previously existed but now is empty) at the provided block hash +-- returns whether the state leaf key is vacated (previously existed but now is empty) at the provided block hash CREATE OR REPLACE FUNCTION was_state_leaf_removed(v_key VARCHAR(66), v_hash VARCHAR) RETURNS boolean AS $$ SELECT state_cids.removed = true @@ -16,7 +16,7 @@ language sql; -- +goose StatementEnd -- +goose StatementBegin --- returns if the state leaf key is vacated (previously existed but now is empty) at the provided block height +-- returns whether the state leaf key is vacated (previously existed but now is empty) at the provided block height CREATE OR REPLACE FUNCTION public.was_state_leaf_removed_by_number(v_key VARCHAR(66), v_block_no BIGINT) RETURNS BOOLEAN AS $$ SELECT state_cids.removed = true diff --git a/db/migrations/00017_create_get_storage_at_functions.sql b/db/migrations/00017_create_get_storage_at_functions.sql index b5f1790..11a00c0 100644 --- a/db/migrations/00017_create_get_storage_at_functions.sql +++ b/db/migrations/00017_create_get_storage_at_functions.sql @@ -49,7 +49,7 @@ BEGIN RAISE NOTICE 'get_storage_at_by_number: chosen header NULL OR % != canonical header % for block number %, trying again.', v_header, v_canonical_header, v_block_no; TRUNCATE tmp_tt_stg2; -- If we hit on a non-canonical block, we need to go back and do a comprehensive check. - -- We try to avoid this to avoid joining between storage_cids, state_cids, and header_cids + -- We try to avoid this to avoid joining between storage_cids and header_cids INSERT INTO tmp_tt_stg2 SELECT storage_cids.header_id, storage_cids.cid, @@ -62,8 +62,8 @@ BEGIN ) AS state_leaf_removed FROM eth.storage_cids INNER JOIN eth.header_cids ON ( - state_cids.header_id = header_cids.block_hash - AND state_cids.block_number = header_cids.block_number + storage_cids.header_id = header_cids.block_hash + AND storage_cids.block_number = header_cids.block_number ) WHERE state_leaf_key = v_state_leaf_key AND storage_leaf_key = v_storage_leaf_key diff --git a/schema.sql b/schema.sql index c83d66e..69d8629 100644 --- a/schema.sql +++ b/schema.sql @@ -248,7 +248,7 @@ BEGIN RAISE NOTICE 'get_storage_at_by_number: chosen header NULL OR % != canonical header % for block number %, trying again.', v_header, v_canonical_header, v_block_no; TRUNCATE tmp_tt_stg2; -- If we hit on a non-canonical block, we need to go back and do a comprehensive check. - -- We try to avoid this to avoid joining between storage_cids, state_cids, and header_cids + -- We try to avoid this to avoid joining between storage_cids and header_cids INSERT INTO tmp_tt_stg2 SELECT storage_cids.header_id, storage_cids.cid, @@ -261,8 +261,8 @@ BEGIN ) AS state_leaf_removed FROM eth.storage_cids INNER JOIN eth.header_cids ON ( - state_cids.header_id = header_cids.block_hash - AND state_cids.block_number = header_cids.block_number + storage_cids.header_id = header_cids.block_hash + AND storage_cids.block_number = header_cids.block_number ) WHERE state_leaf_key = v_state_leaf_key AND storage_leaf_key = v_storage_leaf_key