Follow consensus-specs sync protocol more closely#840
Follow consensus-specs sync protocol more closely#840yrong merged 10 commits intovincent/improve-ancestry-proofsfrom
Conversation
61fc13b to
a948332
Compare
|
More checks added per spec required as following: snowbridge/parachain/pallets/ethereum-beacon-client/src/lib.rs Lines 263 to 267 in a948332 snowbridge/parachain/pallets/ethereum-beacon-client/src/lib.rs Lines 331 to 337 in a948332 snowbridge/parachain/pallets/ethereum-beacon-client/src/lib.rs Lines 375 to 380 in a948332 |
vgeddes
left a comment
There was a problem hiding this comment.
Thanks Ron, this is also a good improvement.
Just wanted to say, we don't have to strictly follow the design in ALC consensus-specs. We can also improve on it, and change the algorithm if it makes sense.
IMHO we first follow spec closely which make it easy to find missing checks as above, also make audit/review a bit easier. Then we do optimization based on that and yes we can definitely change as required. |
| (update.next_sync_committee_update.is_some() && | ||
| update_attested_period == store_period); | ||
| ensure!( | ||
| update.attested_header.slot > store_period || update_has_next_sync_committee, |
There was a problem hiding this comment.
bug fix here. should be update.attested_header.slot > latest_finalized_state.slot
| .try_into() | ||
| .map_err(|_| <Error<T>>::BLSPreparePublicKeysFailed)?; | ||
| <CurrentSyncCommittee<T>>::set(sync_committee_prepared); | ||
| <NextSyncCommittee<T>>::kill(); |
There was a problem hiding this comment.
Kill NextSyncCommittee here.
| return fmt.Errorf("get initial sync: %w", err) | ||
| } | ||
| initialSync := initialSyncScale.ToJSON() | ||
| err = writeJSONToFile(initialSync, fmt.Sprintf("initial-checkpoint.%s.json", activeSpec.ToString())) |
There was a problem hiding this comment.
As mentioned before, we can not use initialSync generated in same command together with other updates.
There was a problem hiding this comment.
How can we improve the command so that it generates all the updates, without having to run it twice? Surely this possible to implement.
|
See this comment here #839 (comment). I don't want to prune FinalizedBeaconState right now, because it depends on |
4606b52 to
495d724
Compare
| log.Info("downloading beacon state, this can take a few minutes...") | ||
| syncCommitteePeriod := s.ComputeSyncPeriodAtSlot(initialSyncHeaderSlot) | ||
| // wait for 5 blocks | ||
| time.Sleep(6 * time.Second * 5) |
There was a problem hiding this comment.
Is the block time 6s in our E2E stack? Curious if we configured this explicitly somewhere
You should probably make it wait some more time in case the 5th block hasn't been produced yet.
There was a problem hiding this comment.
Yes, it's 6s for minimal spec and we did not hack it for this test. Waiting for 5 blocks is just a decent value to make sure FinalizedUpdate change and SyncPeriod does not change in that period. This is requied by recently added check in our light client here.
There is chance at some time we run command but fail to get data meet requirements, in that case we just fail with error as following and rerun it at another time.
snowbridge/relayer/cmd/generate_beacon_data.go
Lines 214 to 219 in 3accd34
|
|
||
| log.Info("downloading beacon state, this can take a few minutes...") | ||
| syncCommitteePeriod := s.ComputeSyncPeriodAtSlot(initialSyncHeaderSlot) | ||
| // wait for 5 blocks |
There was a problem hiding this comment.
Is 5 special number here?
For SNO-446
strict follows ALC spec only
apply_light_client_updateafter successfullyvalidate_light_client_update