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

Fix find on-chain checkpoint #1294

Merged
merged 10 commits into from
Oct 1, 2024
Merged

Fix find on-chain checkpoint #1294

merged 10 commits into from
Oct 1, 2024

Conversation

claravanstaden
Copy link
Contributor

@claravanstaden claravanstaden commented Sep 26, 2024

There were 2 bugs in the find on-chain checkpoint method:

  • The check constrains the checkpoint to be in the same sync committee period, which is not a requirement (a checkpoint can span over 2 sync committee periods, for example, header 8288 can prove slots 8192 - 8288 in period 1 and slots 96 - 1892 in period 0).
  • The search does not traverse the ring buffer correctly (it only searches from the latest index to 0. It should wrap around and search to index + 1)

Added new config in Ansible scripts: https://github.com/Snowfork/snowbridge-infra-suite/pull/24/files#diff-0bdba71d49616abfe1a14b43ead54c6df64cdbfca68c8e4e5fe47bd4a1e3ae2bR29

@claravanstaden claravanstaden changed the title Fix beacon header wrap around search Fix find on-chain checkpoint Sep 27, 2024
@claravanstaden claravanstaden marked this pull request as ready for review September 27, 2024 09:28
type ParachainConfig struct {
Endpoint string `mapstructure:"endpoint"`
MaxWatchedExtrinsics int64 `mapstructure:"maxWatchedExtrinsics"`
HeaderRedundancy uint64 `mapstructure:"headerRedundancy"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add a comment in the code describing the config item?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, 1956d87.

slotPeriodIndex := slot / syncCommitteePeriod

for index := startIndex; index >= endIndex; index-- {
totalStates := syncCommitteePeriod * h.protocol.HeaderRedundancy // Total size of the circular buffer,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is total size of the circular buffer be 256*20=5120?

totalStates := h.protocol.Settings.EpochsPerSyncCommitteePeriod * h.protocol.HeaderRedundancy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly. 👍🏻

@@ -18,7 +18,8 @@
"sink": {
"parachain": {
"endpoint": "ws://127.0.0.1:11144",
"maxWatchedExtrinsics": 8
"maxWatchedExtrinsics": 8,
"headerRedundancy": 20
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just move the new config headerRedundancy to config.SpecSettings, then not much change required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true, but it is not really related to the Ethereum spec settings, which is why I didn't add it there.

Copy link
Collaborator

@vgeddes vgeddes 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 just plz add a comment describing the new config item.

@claravanstaden claravanstaden merged commit 02a325b into main Oct 1, 2024
1 check passed
@claravanstaden claravanstaden deleted the populate-checkpoint-fix branch October 1, 2024 07:26
claravanstaden added a commit that referenced this pull request Oct 1, 2024
* Initialize for westend

* Update beacon checkpoint

* add back in para threads

* fix out of bounds error

* Smoke tests on westend

* Load config from env

* Cleanup env

* Remove penpal code

* Cleanup

* Update smoke tests

* Add westend env

* crontab smoke tests

* Split as two tests

* Fix typo

* Remove assets/parachain non-exist

* Revert change

* Wait config from env

* Load interval from env

* Add alarm check no transfer

* Adds paseo UI (#1276)

* adds paseo UI

* remove muse and bump versions

* remove muse and bump versions

* remove veth token

* paseo things

* fix subscan urls

* revert version

* fix versions

* Update api package

* Fix the merge

* Remove unused

* Fix find on-chain checkpoint (#1294)

* fix wrap around

* logs

* doesnt have to be in the same period

* testing something

* fix

* adds test and config

* writer

* fix compilation

* remove temp building relayer

* comment

* bump version

---------

Co-authored-by: Alistair Singh <alistair.singh7@gmail.com>
Co-authored-by: Clara van Staden <claravanstaden64@gmail.com>
claravanstaden added a commit that referenced this pull request Oct 2, 2024
* add back in para threads

* fix out of bounds error

* forward compatible

* fix comment

* move function back up

* move again

* Smoke test on westend (#1291)

* Initialize for westend

* Update beacon checkpoint

* add back in para threads

* fix out of bounds error

* Smoke tests on westend

* Load config from env

* Cleanup env

* Remove penpal code

* Cleanup

* Update smoke tests

* Add westend env

* crontab smoke tests

* Split as two tests

* Fix typo

* Remove assets/parachain non-exist

* Revert change

* Wait config from env

* Load interval from env

* Add alarm check no transfer

* Adds paseo UI (#1276)

* adds paseo UI

* remove muse and bump versions

* remove muse and bump versions

* remove veth token

* paseo things

* fix subscan urls

* revert version

* fix versions

* Update api package

* Fix the merge

* Remove unused

* Fix find on-chain checkpoint (#1294)

* fix wrap around

* logs

* doesnt have to be in the same period

* testing something

* fix

* adds test and config

* writer

* fix compilation

* remove temp building relayer

* comment

* bump version

---------

Co-authored-by: Alistair Singh <alistair.singh7@gmail.com>
Co-authored-by: Clara van Staden <claravanstaden64@gmail.com>

---------

Co-authored-by: Ron <yrong1997@gmail.com>
Co-authored-by: Clara van Staden <claravanstaden64@gmail.com>
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.

3 participants