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

Check stale validators with RPC #776

Merged
merged 5 commits into from Mar 28, 2022
Merged

Check stale validators with RPC #776

merged 5 commits into from Mar 28, 2022

Conversation

lukaw3d
Copy link
Member

@lukaw3d lukaw3d commented Mar 25, 2022

Resolves #751

Summary of new flow to fetch validators from comments:

  • Skip if validators are already in store, and network didn't change
  • Fetch validators from API
  • If API fails on testnet/local, fall back to empty list
  • If fetching dump_validators fails, fall back to empty list
  • If API fails on mainnet, fall back to dump_validators, and refresh validators' status with RPC
  • If RPC fails, fall back to dump_validators with unknown validators' status
  • Fall back to dump_validators with refreshed validators' status from RPC

@github-actions
Copy link

github-actions bot commented Mar 25, 2022

MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ EDITORCONFIG editorconfig-checker 13 0 0.57s
✅ GIT git_diff yes no 0.04s
✅ JSON eslint-plugin-jsonc 2 0 0 1.1s
✅ JSON jsonlint 2 0 0.56s
✅ JSON prettier 2 0 0 0.74s
✅ JSON v8r 2 0 1.93s
✅ TSX eslint 2 0 0 6.1s
✅ TYPESCRIPT eslint 6 0 0 5.45s

See errors details in artifact MegaLinter reports on CI Job page
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

@codecov
Copy link

codecov bot commented Mar 25, 2022

Codecov Report

Merging #776 (c745647) into master (09cbc04) will decrease coverage by 0.24%.
The diff coverage is 79.16%.

@@            Coverage Diff             @@
##           master     #776      +/-   ##
==========================================
- Coverage   88.52%   88.28%   -0.25%     
==========================================
  Files         100      100              
  Lines        1664     1698      +34     
  Branches      332      339       +7     
==========================================
+ Hits         1473     1499      +26     
- Misses        191      199       +8     
Flag Coverage Δ
cypress 58.01% <31.25%> (-0.86%) ⬇️
jest 74.89% <75.00%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...pages/StakingPage/Features/ValidatorList/index.tsx 74.28% <0.00%> (-13.60%) ⬇️
src/app/state/staking/index.ts 89.28% <40.00%> (-3.82%) ⬇️
src/app/state/staking/saga.ts 94.89% <86.48%> (-0.63%) ⬇️
src/app/state/staking/selectors.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 09cbc04...c745647. Read the comment docs.

export const selectValidators = createSelector([selectStaking], state => state.validators?.list ?? [])
export const selectValidatorsTimestamp = createSelector(
[selectStaking],
state => state.validators?.timestamp ?? 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

When it can be undefined? Do we want to show 1970 in updateValidatorsError?

Copy link
Member Author

Choose a reason for hiding this comment

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

1970 should never appear with current code. It is undefined until first maybeRefreshValidators (initialState = { validators: null })

Annoying options:

  1. keep default 0, so type is number
  2. default to null, and force checking nullable everywhere we want to display timestamp. You have to check nullable even if we already check updateValidatorsError.
  3. create selector for state.validators, so that it is a single variable for nullable checks. But it probably isn't best practice, not minimal for mocking, and redux wouldn't detect changes if subfield changed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, wait, 2. is fine if we just use non-null assertion

src/app/state/staking/saga.ts Outdated Show resolved Hide resolved
@lukaw3d lukaw3d merged commit 481a81d into master Mar 28, 2022
@lukaw3d lukaw3d deleted the lw/fallback-refresh branch March 28, 2022 23:25
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.

Check stale validators with RPC
2 participants