Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: make sequential blocks trigger configurable #1378

Merged
merged 3 commits into from
Sep 26, 2023

Conversation

lostman
Copy link
Contributor

@lostman lostman commented Sep 26, 2023

Description

This PR adds an option to relax the requirement that indexed blocks must be consecutive and that there can be no gaps. This is done by specifying --allow-non-sequential-blocks flag when starting the indexer service.

Testing steps

  1. Run fuel-indexer with --allow-non-sequential-blocks and confirm with psql that the trigger has been removed:
cargo run -p fuel-indexer -- run --fuel-node-host beta-4.fuel.network --fuel-node-port 80 --replace-indexer --run-migrations --manifest examples/fuel-explorer/fuel-explorer/fuel_explorer.manifest.yaml --allow-non-sequential-blocks
postgres=> \d fuellabs_explorer.indexmetadataentity;
             Table "fuellabs_explorer.indexmetadataentity"
    Column    |         Type          | Collation | Nullable | Default
--------------+-----------------------+-----------+----------+---------
 id           | character varying(64) |           | not null |
 time         | numeric(20,0)         |           | not null |
 block_height | integer               |           | not null |
 block_id     | character varying(64) |           | not null |
 object       | bytea                 |           | not null |
Indexes:
    "indexmetadataentity_pkey" PRIMARY KEY, btree (id)
  1. Run fuel-indexer with --allow-non-sequential-blocks and confirm with psql that the trigger has been added:
cargo run -p fuel-indexer -- run --fuel-node-host beta-4.fuel.network --fuel-node-port 80 --replace-indexer --run-migrations --manifest examples/fuel-explorer/fuel-explorer/fuel_explorer.manifest.yaml
postgres=> \d fuellabs_explorer.indexmetadataentity;
             Table "fuellabs_explorer.indexmetadataentity"
    Column    |         Type          | Collation | Nullable | Default
--------------+-----------------------+-----------+----------+---------
 id           | character varying(64) |           | not null |
 time         | numeric(20,0)         |           | not null |
 block_height | integer               |           | not null |
 block_id     | character varying(64) |           | not null |
 object       | bytea                 |           | not null |
Indexes:
    "indexmetadataentity_pkey" PRIMARY KEY, btree (id)
Triggers:
    trigger_ensure_block_height_consecutive BEFORE INSERT OR UPDATE ON fuellabs_explorer.indexmetadataentity FOR EACH ROW EXECUTE FUNCTION ensure_block_height_consecutive()

Changelog

  • add remove_ensure_block_height_consecutive_trigger query
  • change where create_ensure_block_height_consecutive_trigger is called: previously when the table was created; currently: when the indexer executor starts

@lostman lostman force-pushed the maciej/seq-blocks-err-configurable branch from 32159bf to dedb9d2 Compare September 26, 2023 09:58
@lostman lostman force-pushed the maciej/seq-blocks-err-configurable branch from dedb9d2 to 1fd90b6 Compare September 26, 2023 10:57
@lostman lostman marked this pull request as ready for review September 26, 2023 11:49
@ra0x3 ra0x3 linked an issue Sep 26, 2023 that may be closed by this pull request
Copy link
Contributor

@ra0x3 ra0x3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Looks good thanks @lostman
  • All that's missing is just adding the new arg to the QA script
.arg("--allow-non-sequential-blocks")

@lostman lostman requested a review from ra0x3 September 26, 2023 14:33
Copy link
Contributor

@ra0x3 ra0x3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will defer to @deekerno

@ra0x3 ra0x3 merged commit 3052b23 into develop Sep 26, 2023
19 checks passed
@ra0x3 ra0x3 deleted the maciej/seq-blocks-err-configurable branch September 26, 2023 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make sequential blocks error configurable
3 participants