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

EVM Staking - Validator Tables & Selection updates #1929

Merged
merged 7 commits into from
Jan 4, 2024

Conversation

devpavan04
Copy link
Member

Summary of changes

  • Nominators can select validators from both the active and waiting pools to nominate.
  • Nominators can sort validators by status when choosing validators to nominate.
  • An alert message is shown to nominators if they select validators exceeding the maximum nomination quota.
  • A table status is added for active and waiting validators. For example, if there are no validators in the waiting pool, the waiting validators table will display a "no validators in waiting pool" status.

Proposed area of change

  • apps/bridge-dapp
  • apps/hubble-stats
  • apps/stats-dapp
  • apps/tangle-dapp
  • apps/testnet-leaderboard
  • apps/faucet
  • libs/webb-ui-components

Reference issue to close (if applicable)

Screenshots

CleanShot 2024-01-03 at 06 45 41

CleanShot 2024-01-03 at 06 44 30

CleanShot 2024-01-03 at 06 44 17

Copy link

netlify bot commented Jan 3, 2024

Deploy Preview for tangle-dapp ready!

Name Link
🔨 Latest commit 084eb7f
🔍 Latest deploy log https://app.netlify.com/sites/tangle-dapp/deploys/6597139506b698000895cd9d
😎 Deploy Preview https://deploy-preview-1929--tangle-dapp.netlify.app/500
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 3, 2024

Deploy Preview for hubble-stats ready!

Name Link
🔨 Latest commit 084eb7f
🔍 Latest deploy log https://app.netlify.com/sites/hubble-stats/deploys/65971395b9b44c0008a0c0ce
😎 Deploy Preview https://deploy-preview-1929--hubble-stats.netlify.app/500
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 3, 2024

Deploy Preview for testnet-leaderboard ready!

Name Link
🔨 Latest commit 084eb7f
🔍 Latest deploy log https://app.netlify.com/sites/testnet-leaderboard/deploys/65971395bd09e70008004821
😎 Deploy Preview https://deploy-preview-1929--testnet-leaderboard.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@devpavan04 devpavan04 marked this pull request as draft January 3, 2024 14:48
Copy link

netlify bot commented Jan 3, 2024

Deploy Preview for zkexplorer ready!

Name Link
🔨 Latest commit 084eb7f
🔍 Latest deploy log https://app.netlify.com/sites/zkexplorer/deploys/659713953dcede0008c4d026
😎 Deploy Preview https://deploy-preview-1929--zkexplorer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@devpavan04 devpavan04 marked this pull request as ready for review January 3, 2024 16:41
@drewstone
Copy link
Contributor

Can you provide a video of test/QA?

@devpavan04
Copy link
Member Author

@drewstone

CleanShot.2024-01-03.at.09.54.16.mp4

@devpavan04 devpavan04 marked this pull request as draft January 3, 2024 20:02
@devpavan04
Copy link
Member Author

@drewstone Currently on the testnet, there are zero validators in the waiting pool. This is why we can't see any waiting validators in the above screen recording. I was able to setup a validator locally and test it. The video below demonstrates the working changes. Thanks to @1xstj for helping me run the validator locally ❤️

First-time nomination flow

CleanShot.2024-01-03.at.13.04.39.mp4

Second time nomination flow

CleanShot.2024-01-03.at.13.06.46.mp4

@devpavan04 devpavan04 marked this pull request as ready for review January 3, 2024 21:22
Copy link
Member

@AtelyPham AtelyPham left a comment

Choose a reason for hiding this comment

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

Left some comments.


useEffect(() => {
getMaxNominationQuota().then((maxNominationQuota) => {
setMaxNominationQuota(maxNominationQuota ? maxNominationQuota : 16);
Copy link
Member

Choose a reason for hiding this comment

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

The variable maxNominationQuota can potentially be undefined, 0, or NaN. I recommend implementing a more stringent check for this scenario.

const allValidators = useMemo(() => {
if (!activeValidatorsData || !waitingValidatorsData) return [];

return [...activeValidatorsData, ...waitingValidatorsData];
Copy link
Member

Choose a reason for hiding this comment

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

Is there any case where we have duplicate validators? Just out of curiosity.

Copy link
Member Author

Choose a reason for hiding this comment

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

No there won't be.

const [maxNominationQuota, setMaxNominationQuota] = useState<number>(0);

useEffect(() => {
getMaxNominationQuota().then((maxNominationQuota) => {
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

Comment on lines 37 to 54
const { data: waitingValidatorsData } = useSWR(
[getWaitingValidators.name],
([, ...args]) => getWaitingValidators(...args)
);

const [maxNominationQuota, setMaxNominationQuota] = useState<number>(0);

useEffect(() => {
getMaxNominationQuota().then((maxNominationQuota) => {
setMaxNominationQuota(maxNominationQuota ? maxNominationQuota : 16);
});
}, []);

const allValidators = useMemo(() => {
if (!activeValidatorsData || !waitingValidatorsData) return [];

return [...activeValidatorsData, ...waitingValidatorsData];
}, [activeValidatorsData, waitingValidatorsData]);
Copy link
Member

Choose a reason for hiding this comment

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

Could you please deduplicate this code? You can achieve this by creating a custom hook to encapsulate the logic. Afterwards, ensure to reuse the hook in both this file and apps/tangle-dapp/containers/DelegateTxContainer/DelegateTxContainer.tsx.

@devpavan04 devpavan04 marked this pull request as draft January 4, 2024 19:00
@devpavan04 devpavan04 marked this pull request as ready for review January 4, 2024 20:23
@devpavan04 devpavan04 requested a review from AtelyPham January 4, 2024 20:24
@drewstone drewstone merged commit 77b7dc1 into develop Jan 4, 2024
22 of 23 checks passed
@drewstone drewstone deleted the PS/validator-list-and-limit branch January 4, 2024 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants